@feedmepos/mf-settings 0.0.48-beta.0-ex → 0.0.48-beta.1-ex

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.
@@ -0,0 +1,4351 @@
1
+ import { defineComponent as Ye, computed as Pe, ref as xt, watchEffect as Vt, resolveComponent as Wt, openBlock as Xe, createBlock as Qe, onMounted as Ht, unref as $t } from "vue";
2
+ import { useRouter as jt, RouterView as Bt } from "vue-router";
3
+ import { useI18n as Kt, useCoreStore as Ze, FeedMeAuth as qt } from "@feedmepos/mf-common";
4
+ import { routers as Gt } from "./app.js";
5
+ import { Pos as zt } from "@feedmepos/core";
6
+ import { F_FEATURE as Jt } from "@feedmepos/core/entity";
7
+ import { r as de, g as et, i as Yt, a as Xt, _ as Ne, C as Oe, b as Qt, S as F, c as O, E as pe, d as Zt, e as tt, f as en, h as tn, L as nt, j as f, k as nn, l as rn, F as ge, q as x, m as sn, n as on, o as an, p as cn, s as ln, t as un, u as dn, v as hn } from "./index.esm2017-c60b1ce5.js";
8
+ import "@feedmepos/mf-mdm";
9
+ import "@feedmepos/mf-e-invoice";
10
+ function me(n, e) {
11
+ var t = {};
12
+ for (var i in n)
13
+ Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
14
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
15
+ for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
16
+ e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
17
+ return t;
18
+ }
19
+ const fn = /* @__PURE__ */ Ye({
20
+ __name: "NavigationTab",
21
+ emits: ["close-navigation"],
22
+ setup(n, { emit: e }) {
23
+ const t = e, { t: i } = Kt(), r = jt(), s = Ze(), o = Pe(() => s.restaurants.value.some(({ posVersion: l }) => zt.canUse({ feature: Jt.Enum.templateBuilder, posVersion: l ?? "" }))), c = Pe(() => Gt.filter((d) => {
24
+ var h;
25
+ return d.redirect || (h = d.meta) != null && h.hideNavigation ? !1 : !(d.name === "$settings-template-builder" && !o.value);
26
+ }).map((d) => {
27
+ var h;
28
+ return {
29
+ label: i((h = d.meta) == null ? void 0 : h.i18nKey),
30
+ value: d.name,
31
+ action: () => {
32
+ d.name === "$settings-e-invoice" ? r.push({ name: "SUBMISSION" }) : d.name === "$settings-device" ? r.push({ name: "$devices" }) : r.push({ name: d.name }), t("close-navigation");
33
+ }
34
+ };
35
+ })), a = xt();
36
+ return Vt(() => {
37
+ var d;
38
+ const l = (d = r.currentRoute.value) == null ? void 0 : d.name;
39
+ l === "SUBMISSION" ? a.value = "$settings-e-invoice" : l === "$devices" ? a.value = "$settings-device" : a.value = l;
40
+ }), (l, d) => {
41
+ const h = Wt("fm-collapsible-tabs");
42
+ return Xe(), Qe(h, {
43
+ modelValue: a.value,
44
+ "onUpdate:modelValue": d[0] || (d[0] = (p) => a.value = p),
45
+ items: c.value,
46
+ class: "py-16 px-8"
47
+ }, null, 8, ["modelValue", "items"]);
48
+ };
49
+ }
50
+ });
51
+ class M {
52
+ constructor(e = null, t = {}) {
53
+ if (this.apiKey = e, this.options = t, typeof window > "u")
54
+ throw new Error("google-maps is supported only in browser environment");
55
+ }
56
+ load() {
57
+ return typeof this.api < "u" ? Promise.resolve(this.api) : typeof this.loader < "u" ? this.loader : (window[M.CALLBACK_NAME] = () => {
58
+ if (this.api = window.google, typeof this.resolve > "u")
59
+ throw new Error("Should not happen");
60
+ this.resolve(this.api);
61
+ }, window.gm_authFailure = () => {
62
+ if (typeof this.reject > "u")
63
+ throw new Error("Should not happen");
64
+ this.reject(new Error("google-maps: authentication error"));
65
+ }, this.loader = new Promise((e, t) => {
66
+ this.resolve = e, this.reject = t;
67
+ const i = document.createElement("script");
68
+ i.src = this.createUrl(), i.async = !0, i.onerror = (r) => t(r), document.head.appendChild(i);
69
+ }));
70
+ }
71
+ createUrl() {
72
+ const e = [
73
+ `callback=${M.CALLBACK_NAME}`
74
+ ];
75
+ this.apiKey && e.push(`key=${this.apiKey}`);
76
+ for (let t in this.options)
77
+ if (this.options.hasOwnProperty(t)) {
78
+ let i = this.options[t];
79
+ t === "version" && (t = "v"), t === "libraries" && (i = i.join(",")), e.push(`${t}=${i}`);
80
+ }
81
+ return `https://maps.googleapis.com/maps/api/js?${e.join("&")}`;
82
+ }
83
+ }
84
+ M.CALLBACK_NAME = "_dk_google_maps_loader_cb";
85
+ var pn = "firebase", gn = "9.23.0";
86
+ /**
87
+ * @license
88
+ * Copyright 2020 Google LLC
89
+ *
90
+ * Licensed under the Apache License, Version 2.0 (the "License");
91
+ * you may not use this file except in compliance with the License.
92
+ * You may obtain a copy of the License at
93
+ *
94
+ * http://www.apache.org/licenses/LICENSE-2.0
95
+ *
96
+ * Unless required by applicable law or agreed to in writing, software
97
+ * distributed under the License is distributed on an "AS IS" BASIS,
98
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
+ * See the License for the specific language governing permissions and
100
+ * limitations under the License.
101
+ */
102
+ de(pn, gn, "app");
103
+ function it() {
104
+ return {
105
+ "dependent-sdk-initialized-before-auth": "Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."
106
+ };
107
+ }
108
+ const mn = it, rt = new pe("auth", "Firebase", it());
109
+ /**
110
+ * @license
111
+ * Copyright 2020 Google LLC
112
+ *
113
+ * Licensed under the Apache License, Version 2.0 (the "License");
114
+ * you may not use this file except in compliance with the License.
115
+ * You may obtain a copy of the License at
116
+ *
117
+ * http://www.apache.org/licenses/LICENSE-2.0
118
+ *
119
+ * Unless required by applicable law or agreed to in writing, software
120
+ * distributed under the License is distributed on an "AS IS" BASIS,
121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
+ * See the License for the specific language governing permissions and
123
+ * limitations under the License.
124
+ */
125
+ const X = new rn("@firebase/auth");
126
+ function _n(n, ...e) {
127
+ X.logLevel <= nt.WARN && X.warn(`Auth (${F}): ${n}`, ...e);
128
+ }
129
+ function G(n, ...e) {
130
+ X.logLevel <= nt.ERROR && X.error(`Auth (${F}): ${n}`, ...e);
131
+ }
132
+ /**
133
+ * @license
134
+ * Copyright 2020 Google LLC
135
+ *
136
+ * Licensed under the Apache License, Version 2.0 (the "License");
137
+ * you may not use this file except in compliance with the License.
138
+ * You may obtain a copy of the License at
139
+ *
140
+ * http://www.apache.org/licenses/LICENSE-2.0
141
+ *
142
+ * Unless required by applicable law or agreed to in writing, software
143
+ * distributed under the License is distributed on an "AS IS" BASIS,
144
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145
+ * See the License for the specific language governing permissions and
146
+ * limitations under the License.
147
+ */
148
+ function I(n, ...e) {
149
+ throw _e(n, ...e);
150
+ }
151
+ function g(n, ...e) {
152
+ return _e(n, ...e);
153
+ }
154
+ function vn(n, e, t) {
155
+ const i = Object.assign(Object.assign({}, mn()), { [e]: t });
156
+ return new pe("auth", "Firebase", i).create(e, {
157
+ appName: n.name
158
+ });
159
+ }
160
+ function _e(n, ...e) {
161
+ if (typeof n != "string") {
162
+ const t = e[0], i = [...e.slice(1)];
163
+ return i[0] && (i[0].appName = n.name), n._errorFactory.create(t, ...i);
164
+ }
165
+ return rt.create(n, ...e);
166
+ }
167
+ function u(n, e, ...t) {
168
+ if (!n)
169
+ throw _e(e, ...t);
170
+ }
171
+ function _(n) {
172
+ const e = "INTERNAL ASSERTION FAILED: " + n;
173
+ throw G(e), new Error(e);
174
+ }
175
+ function y(n, e) {
176
+ n || _(e);
177
+ }
178
+ /**
179
+ * @license
180
+ * Copyright 2020 Google LLC
181
+ *
182
+ * Licensed under the Apache License, Version 2.0 (the "License");
183
+ * you may not use this file except in compliance with the License.
184
+ * You may obtain a copy of the License at
185
+ *
186
+ * http://www.apache.org/licenses/LICENSE-2.0
187
+ *
188
+ * Unless required by applicable law or agreed to in writing, software
189
+ * distributed under the License is distributed on an "AS IS" BASIS,
190
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191
+ * See the License for the specific language governing permissions and
192
+ * limitations under the License.
193
+ */
194
+ function he() {
195
+ var n;
196
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.href) || "";
197
+ }
198
+ function In() {
199
+ return Le() === "http:" || Le() === "https:";
200
+ }
201
+ function Le() {
202
+ var n;
203
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.protocol) || null;
204
+ }
205
+ /**
206
+ * @license
207
+ * Copyright 2020 Google LLC
208
+ *
209
+ * Licensed under the Apache License, Version 2.0 (the "License");
210
+ * you may not use this file except in compliance with the License.
211
+ * You may obtain a copy of the License at
212
+ *
213
+ * http://www.apache.org/licenses/LICENSE-2.0
214
+ *
215
+ * Unless required by applicable law or agreed to in writing, software
216
+ * distributed under the License is distributed on an "AS IS" BASIS,
217
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ * See the License for the specific language governing permissions and
219
+ * limitations under the License.
220
+ */
221
+ function yn() {
222
+ return typeof navigator < "u" && navigator && "onLine" in navigator && typeof navigator.onLine == "boolean" && // Apply only for traditional web apps and Chrome extensions.
223
+ // This is especially true for Cordova apps which have unreliable
224
+ // navigator.onLine behavior unless cordova-plugin-network-information is
225
+ // installed which overwrites the native navigator.onLine value and
226
+ // defines navigator.connection.
227
+ (In() || Qt() || "connection" in navigator) ? navigator.onLine : !0;
228
+ }
229
+ function Tn() {
230
+ if (typeof navigator > "u")
231
+ return null;
232
+ const n = navigator;
233
+ return (
234
+ // Most reliable, but only supported in Chrome/Firefox.
235
+ n.languages && n.languages[0] || // Supported in most browsers, but returns the language of the browser
236
+ // UI, not the language set in browser settings.
237
+ n.language || // Couldn't determine language.
238
+ null
239
+ );
240
+ }
241
+ /**
242
+ * @license
243
+ * Copyright 2020 Google LLC
244
+ *
245
+ * Licensed under the Apache License, Version 2.0 (the "License");
246
+ * you may not use this file except in compliance with the License.
247
+ * You may obtain a copy of the License at
248
+ *
249
+ * http://www.apache.org/licenses/LICENSE-2.0
250
+ *
251
+ * Unless required by applicable law or agreed to in writing, software
252
+ * distributed under the License is distributed on an "AS IS" BASIS,
253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254
+ * See the License for the specific language governing permissions and
255
+ * limitations under the License.
256
+ */
257
+ class V {
258
+ constructor(e, t) {
259
+ this.shortDelay = e, this.longDelay = t, y(t > e, "Short delay should be less than long delay!"), this.isMobile = Yt() || Xt();
260
+ }
261
+ get() {
262
+ return yn() ? this.isMobile ? this.longDelay : this.shortDelay : Math.min(5e3, this.shortDelay);
263
+ }
264
+ }
265
+ /**
266
+ * @license
267
+ * Copyright 2020 Google LLC
268
+ *
269
+ * Licensed under the Apache License, Version 2.0 (the "License");
270
+ * you may not use this file except in compliance with the License.
271
+ * You may obtain a copy of the License at
272
+ *
273
+ * http://www.apache.org/licenses/LICENSE-2.0
274
+ *
275
+ * Unless required by applicable law or agreed to in writing, software
276
+ * distributed under the License is distributed on an "AS IS" BASIS,
277
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
278
+ * See the License for the specific language governing permissions and
279
+ * limitations under the License.
280
+ */
281
+ function ve(n, e) {
282
+ y(n.emulator, "Emulator should always be set here");
283
+ const { url: t } = n.emulator;
284
+ return e ? `${t}${e.startsWith("/") ? e.slice(1) : e}` : t;
285
+ }
286
+ /**
287
+ * @license
288
+ * Copyright 2020 Google LLC
289
+ *
290
+ * Licensed under the Apache License, Version 2.0 (the "License");
291
+ * you may not use this file except in compliance with the License.
292
+ * You may obtain a copy of the License at
293
+ *
294
+ * http://www.apache.org/licenses/LICENSE-2.0
295
+ *
296
+ * Unless required by applicable law or agreed to in writing, software
297
+ * distributed under the License is distributed on an "AS IS" BASIS,
298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
+ * See the License for the specific language governing permissions and
300
+ * limitations under the License.
301
+ */
302
+ class st {
303
+ static initialize(e, t, i) {
304
+ this.fetchImpl = e, t && (this.headersImpl = t), i && (this.responseImpl = i);
305
+ }
306
+ static fetch() {
307
+ if (this.fetchImpl)
308
+ return this.fetchImpl;
309
+ if (typeof self < "u" && "fetch" in self)
310
+ return self.fetch;
311
+ _("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
312
+ }
313
+ static headers() {
314
+ if (this.headersImpl)
315
+ return this.headersImpl;
316
+ if (typeof self < "u" && "Headers" in self)
317
+ return self.Headers;
318
+ _("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
319
+ }
320
+ static response() {
321
+ if (this.responseImpl)
322
+ return this.responseImpl;
323
+ if (typeof self < "u" && "Response" in self)
324
+ return self.Response;
325
+ _("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
326
+ }
327
+ }
328
+ /**
329
+ * @license
330
+ * Copyright 2020 Google LLC
331
+ *
332
+ * Licensed under the Apache License, Version 2.0 (the "License");
333
+ * you may not use this file except in compliance with the License.
334
+ * You may obtain a copy of the License at
335
+ *
336
+ * http://www.apache.org/licenses/LICENSE-2.0
337
+ *
338
+ * Unless required by applicable law or agreed to in writing, software
339
+ * distributed under the License is distributed on an "AS IS" BASIS,
340
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
341
+ * See the License for the specific language governing permissions and
342
+ * limitations under the License.
343
+ */
344
+ const wn = {
345
+ // Custom token errors.
346
+ CREDENTIAL_MISMATCH: "custom-token-mismatch",
347
+ // This can only happen if the SDK sends a bad request.
348
+ MISSING_CUSTOM_TOKEN: "internal-error",
349
+ // Create Auth URI errors.
350
+ INVALID_IDENTIFIER: "invalid-email",
351
+ // This can only happen if the SDK sends a bad request.
352
+ MISSING_CONTINUE_URI: "internal-error",
353
+ // Sign in with email and password errors (some apply to sign up too).
354
+ INVALID_PASSWORD: "wrong-password",
355
+ // This can only happen if the SDK sends a bad request.
356
+ MISSING_PASSWORD: "missing-password",
357
+ // Sign up with email and password errors.
358
+ EMAIL_EXISTS: "email-already-in-use",
359
+ PASSWORD_LOGIN_DISABLED: "operation-not-allowed",
360
+ // Verify assertion for sign in with credential errors:
361
+ INVALID_IDP_RESPONSE: "invalid-credential",
362
+ INVALID_PENDING_TOKEN: "invalid-credential",
363
+ FEDERATED_USER_ID_ALREADY_LINKED: "credential-already-in-use",
364
+ // This can only happen if the SDK sends a bad request.
365
+ MISSING_REQ_TYPE: "internal-error",
366
+ // Send Password reset email errors:
367
+ EMAIL_NOT_FOUND: "user-not-found",
368
+ RESET_PASSWORD_EXCEED_LIMIT: "too-many-requests",
369
+ EXPIRED_OOB_CODE: "expired-action-code",
370
+ INVALID_OOB_CODE: "invalid-action-code",
371
+ // This can only happen if the SDK sends a bad request.
372
+ MISSING_OOB_CODE: "internal-error",
373
+ // Operations that require ID token in request:
374
+ CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "requires-recent-login",
375
+ INVALID_ID_TOKEN: "invalid-user-token",
376
+ TOKEN_EXPIRED: "user-token-expired",
377
+ USER_NOT_FOUND: "user-token-expired",
378
+ // Other errors.
379
+ TOO_MANY_ATTEMPTS_TRY_LATER: "too-many-requests",
380
+ // Phone Auth related errors.
381
+ INVALID_CODE: "invalid-verification-code",
382
+ INVALID_SESSION_INFO: "invalid-verification-id",
383
+ INVALID_TEMPORARY_PROOF: "invalid-credential",
384
+ MISSING_SESSION_INFO: "missing-verification-id",
385
+ SESSION_EXPIRED: "code-expired",
386
+ // Other action code errors when additional settings passed.
387
+ // MISSING_CONTINUE_URI is getting mapped to INTERNAL_ERROR above.
388
+ // This is OK as this error will be caught by client side validation.
389
+ MISSING_ANDROID_PACKAGE_NAME: "missing-android-pkg-name",
390
+ UNAUTHORIZED_DOMAIN: "unauthorized-continue-uri",
391
+ // getProjectConfig errors when clientId is passed.
392
+ INVALID_OAUTH_CLIENT_ID: "invalid-oauth-client-id",
393
+ // User actions (sign-up or deletion) disabled errors.
394
+ ADMIN_ONLY_OPERATION: "admin-restricted-operation",
395
+ // Multi factor related errors.
396
+ INVALID_MFA_PENDING_CREDENTIAL: "invalid-multi-factor-session",
397
+ MFA_ENROLLMENT_NOT_FOUND: "multi-factor-info-not-found",
398
+ MISSING_MFA_ENROLLMENT_ID: "missing-multi-factor-info",
399
+ MISSING_MFA_PENDING_CREDENTIAL: "missing-multi-factor-session",
400
+ SECOND_FACTOR_EXISTS: "second-factor-already-in-use",
401
+ SECOND_FACTOR_LIMIT_EXCEEDED: "maximum-second-factor-count-exceeded",
402
+ // Blocking functions related errors.
403
+ BLOCKING_FUNCTION_ERROR_RESPONSE: "internal-error",
404
+ // Recaptcha related errors.
405
+ RECAPTCHA_NOT_ENABLED: "recaptcha-not-enabled",
406
+ MISSING_RECAPTCHA_TOKEN: "missing-recaptcha-token",
407
+ INVALID_RECAPTCHA_TOKEN: "invalid-recaptcha-token",
408
+ INVALID_RECAPTCHA_ACTION: "invalid-recaptcha-action",
409
+ MISSING_CLIENT_TYPE: "missing-client-type",
410
+ MISSING_RECAPTCHA_VERSION: "missing-recaptcha-version",
411
+ INVALID_RECAPTCHA_VERSION: "invalid-recaptcha-version",
412
+ INVALID_REQ_TYPE: "invalid-req-type"
413
+ /* AuthErrorCode.INVALID_REQ_TYPE */
414
+ };
415
+ /**
416
+ * @license
417
+ * Copyright 2020 Google LLC
418
+ *
419
+ * Licensed under the Apache License, Version 2.0 (the "License");
420
+ * you may not use this file except in compliance with the License.
421
+ * You may obtain a copy of the License at
422
+ *
423
+ * http://www.apache.org/licenses/LICENSE-2.0
424
+ *
425
+ * Unless required by applicable law or agreed to in writing, software
426
+ * distributed under the License is distributed on an "AS IS" BASIS,
427
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
428
+ * See the License for the specific language governing permissions and
429
+ * limitations under the License.
430
+ */
431
+ const En = new V(3e4, 6e4);
432
+ function Ie(n, e) {
433
+ return n.tenantId && !e.tenantId ? Object.assign(Object.assign({}, e), { tenantId: n.tenantId }) : e;
434
+ }
435
+ async function W(n, e, t, i, r = {}) {
436
+ return ot(n, r, async () => {
437
+ let s = {}, o = {};
438
+ i && (e === "GET" ? o = i : s = {
439
+ body: JSON.stringify(i)
440
+ });
441
+ const c = x(Object.assign({ key: n.config.apiKey }, o)).slice(1), a = await n._getAdditionalHeaders();
442
+ return a[
443
+ "Content-Type"
444
+ /* HttpHeader.CONTENT_TYPE */
445
+ ] = "application/json", n.languageCode && (a[
446
+ "X-Firebase-Locale"
447
+ /* HttpHeader.X_FIREBASE_LOCALE */
448
+ ] = n.languageCode), st.fetch()(ct(n, n.config.apiHost, t, c), Object.assign({
449
+ method: e,
450
+ headers: a,
451
+ referrerPolicy: "no-referrer"
452
+ }, s));
453
+ });
454
+ }
455
+ async function ot(n, e, t) {
456
+ n._canInitEmulator = !1;
457
+ const i = Object.assign(Object.assign({}, wn), e);
458
+ try {
459
+ const r = new kn(n), s = await Promise.race([
460
+ t(),
461
+ r.promise
462
+ ]);
463
+ r.clearNetworkTimeout();
464
+ const o = await s.json();
465
+ if ("needConfirmation" in o)
466
+ throw q(n, "account-exists-with-different-credential", o);
467
+ if (s.ok && !("errorMessage" in o))
468
+ return o;
469
+ {
470
+ const c = s.ok ? o.errorMessage : o.error.message, [a, l] = c.split(" : ");
471
+ if (a === "FEDERATED_USER_ID_ALREADY_LINKED")
472
+ throw q(n, "credential-already-in-use", o);
473
+ if (a === "EMAIL_EXISTS")
474
+ throw q(n, "email-already-in-use", o);
475
+ if (a === "USER_DISABLED")
476
+ throw q(n, "user-disabled", o);
477
+ const d = i[a] || a.toLowerCase().replace(/[_\s]+/g, "-");
478
+ if (l)
479
+ throw vn(n, d, l);
480
+ I(n, d);
481
+ }
482
+ } catch (r) {
483
+ if (r instanceof ge)
484
+ throw r;
485
+ I(n, "network-request-failed", { message: String(r) });
486
+ }
487
+ }
488
+ async function at(n, e, t, i, r = {}) {
489
+ const s = await W(n, e, t, i, r);
490
+ return "mfaPendingCredential" in s && I(n, "multi-factor-auth-required", {
491
+ _serverResponse: s
492
+ }), s;
493
+ }
494
+ function ct(n, e, t, i) {
495
+ const r = `${e}${t}?${i}`;
496
+ return n.config.emulator ? ve(n.config, r) : `${n.config.apiScheme}://${r}`;
497
+ }
498
+ class kn {
499
+ constructor(e) {
500
+ this.auth = e, this.timer = null, this.promise = new Promise((t, i) => {
501
+ this.timer = setTimeout(() => i(g(
502
+ this.auth,
503
+ "network-request-failed"
504
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
505
+ )), En.get());
506
+ });
507
+ }
508
+ clearNetworkTimeout() {
509
+ clearTimeout(this.timer);
510
+ }
511
+ }
512
+ function q(n, e, t) {
513
+ const i = {
514
+ appName: n.name
515
+ };
516
+ t.email && (i.email = t.email), t.phoneNumber && (i.phoneNumber = t.phoneNumber);
517
+ const r = g(n, e, i);
518
+ return r.customData._tokenResponse = t, r;
519
+ }
520
+ /**
521
+ * @license
522
+ * Copyright 2020 Google LLC
523
+ *
524
+ * Licensed under the Apache License, Version 2.0 (the "License");
525
+ * you may not use this file except in compliance with the License.
526
+ * You may obtain a copy of the License at
527
+ *
528
+ * http://www.apache.org/licenses/LICENSE-2.0
529
+ *
530
+ * Unless required by applicable law or agreed to in writing, software
531
+ * distributed under the License is distributed on an "AS IS" BASIS,
532
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
533
+ * See the License for the specific language governing permissions and
534
+ * limitations under the License.
535
+ */
536
+ async function Rn(n, e) {
537
+ return W(n, "POST", "/v1/accounts:delete", e);
538
+ }
539
+ async function bn(n, e) {
540
+ return W(n, "POST", "/v1/accounts:lookup", e);
541
+ }
542
+ /**
543
+ * @license
544
+ * Copyright 2020 Google LLC
545
+ *
546
+ * Licensed under the Apache License, Version 2.0 (the "License");
547
+ * you may not use this file except in compliance with the License.
548
+ * You may obtain a copy of the License at
549
+ *
550
+ * http://www.apache.org/licenses/LICENSE-2.0
551
+ *
552
+ * Unless required by applicable law or agreed to in writing, software
553
+ * distributed under the License is distributed on an "AS IS" BASIS,
554
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
555
+ * See the License for the specific language governing permissions and
556
+ * limitations under the License.
557
+ */
558
+ function L(n) {
559
+ if (n)
560
+ try {
561
+ const e = new Date(Number(n));
562
+ if (!isNaN(e.getTime()))
563
+ return e.toUTCString();
564
+ } catch {
565
+ }
566
+ }
567
+ async function Sn(n, e = !1) {
568
+ const t = O(n), i = await t.getIdToken(e), r = ye(i);
569
+ u(
570
+ r && r.exp && r.auth_time && r.iat,
571
+ t.auth,
572
+ "internal-error"
573
+ /* AuthErrorCode.INTERNAL_ERROR */
574
+ );
575
+ const s = typeof r.firebase == "object" ? r.firebase : void 0, o = s == null ? void 0 : s.sign_in_provider;
576
+ return {
577
+ claims: r,
578
+ token: i,
579
+ authTime: L(le(r.auth_time)),
580
+ issuedAtTime: L(le(r.iat)),
581
+ expirationTime: L(le(r.exp)),
582
+ signInProvider: o || null,
583
+ signInSecondFactor: (s == null ? void 0 : s.sign_in_second_factor) || null
584
+ };
585
+ }
586
+ function le(n) {
587
+ return Number(n) * 1e3;
588
+ }
589
+ function ye(n) {
590
+ const [e, t, i] = n.split(".");
591
+ if (e === void 0 || t === void 0 || i === void 0)
592
+ return G("JWT malformed, contained fewer than 3 sections"), null;
593
+ try {
594
+ const r = sn(t);
595
+ return r ? JSON.parse(r) : (G("Failed to decode base64 JWT payload"), null);
596
+ } catch (r) {
597
+ return G("Caught error parsing JWT payload as JSON", r == null ? void 0 : r.toString()), null;
598
+ }
599
+ }
600
+ function An(n) {
601
+ const e = ye(n);
602
+ return u(
603
+ e,
604
+ "internal-error"
605
+ /* AuthErrorCode.INTERNAL_ERROR */
606
+ ), u(
607
+ typeof e.exp < "u",
608
+ "internal-error"
609
+ /* AuthErrorCode.INTERNAL_ERROR */
610
+ ), u(
611
+ typeof e.iat < "u",
612
+ "internal-error"
613
+ /* AuthErrorCode.INTERNAL_ERROR */
614
+ ), Number(e.exp) - Number(e.iat);
615
+ }
616
+ /**
617
+ * @license
618
+ * Copyright 2020 Google LLC
619
+ *
620
+ * Licensed under the Apache License, Version 2.0 (the "License");
621
+ * you may not use this file except in compliance with the License.
622
+ * You may obtain a copy of the License at
623
+ *
624
+ * http://www.apache.org/licenses/LICENSE-2.0
625
+ *
626
+ * Unless required by applicable law or agreed to in writing, software
627
+ * distributed under the License is distributed on an "AS IS" BASIS,
628
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629
+ * See the License for the specific language governing permissions and
630
+ * limitations under the License.
631
+ */
632
+ async function U(n, e, t = !1) {
633
+ if (t)
634
+ return e;
635
+ try {
636
+ return await e;
637
+ } catch (i) {
638
+ throw i instanceof ge && Cn(i) && n.auth.currentUser === n && await n.auth.signOut(), i;
639
+ }
640
+ }
641
+ function Cn({ code: n }) {
642
+ return n === "auth/user-disabled" || n === "auth/user-token-expired";
643
+ }
644
+ /**
645
+ * @license
646
+ * Copyright 2020 Google LLC
647
+ *
648
+ * Licensed under the Apache License, Version 2.0 (the "License");
649
+ * you may not use this file except in compliance with the License.
650
+ * You may obtain a copy of the License at
651
+ *
652
+ * http://www.apache.org/licenses/LICENSE-2.0
653
+ *
654
+ * Unless required by applicable law or agreed to in writing, software
655
+ * distributed under the License is distributed on an "AS IS" BASIS,
656
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
657
+ * See the License for the specific language governing permissions and
658
+ * limitations under the License.
659
+ */
660
+ class Pn {
661
+ constructor(e) {
662
+ this.user = e, this.isRunning = !1, this.timerId = null, this.errorBackoff = 3e4;
663
+ }
664
+ _start() {
665
+ this.isRunning || (this.isRunning = !0, this.schedule());
666
+ }
667
+ _stop() {
668
+ this.isRunning && (this.isRunning = !1, this.timerId !== null && clearTimeout(this.timerId));
669
+ }
670
+ getInterval(e) {
671
+ var t;
672
+ if (e) {
673
+ const i = this.errorBackoff;
674
+ return this.errorBackoff = Math.min(
675
+ this.errorBackoff * 2,
676
+ 96e4
677
+ /* Duration.RETRY_BACKOFF_MAX */
678
+ ), i;
679
+ } else {
680
+ this.errorBackoff = 3e4;
681
+ const r = ((t = this.user.stsTokenManager.expirationTime) !== null && t !== void 0 ? t : 0) - Date.now() - 3e5;
682
+ return Math.max(0, r);
683
+ }
684
+ }
685
+ schedule(e = !1) {
686
+ if (!this.isRunning)
687
+ return;
688
+ const t = this.getInterval(e);
689
+ this.timerId = setTimeout(async () => {
690
+ await this.iteration();
691
+ }, t);
692
+ }
693
+ async iteration() {
694
+ try {
695
+ await this.user.getIdToken(!0);
696
+ } catch (e) {
697
+ (e == null ? void 0 : e.code) === "auth/network-request-failed" && this.schedule(
698
+ /* wasError */
699
+ !0
700
+ );
701
+ return;
702
+ }
703
+ this.schedule();
704
+ }
705
+ }
706
+ /**
707
+ * @license
708
+ * Copyright 2020 Google LLC
709
+ *
710
+ * Licensed under the Apache License, Version 2.0 (the "License");
711
+ * you may not use this file except in compliance with the License.
712
+ * You may obtain a copy of the License at
713
+ *
714
+ * http://www.apache.org/licenses/LICENSE-2.0
715
+ *
716
+ * Unless required by applicable law or agreed to in writing, software
717
+ * distributed under the License is distributed on an "AS IS" BASIS,
718
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719
+ * See the License for the specific language governing permissions and
720
+ * limitations under the License.
721
+ */
722
+ class lt {
723
+ constructor(e, t) {
724
+ this.createdAt = e, this.lastLoginAt = t, this._initializeTime();
725
+ }
726
+ _initializeTime() {
727
+ this.lastSignInTime = L(this.lastLoginAt), this.creationTime = L(this.createdAt);
728
+ }
729
+ _copy(e) {
730
+ this.createdAt = e.createdAt, this.lastLoginAt = e.lastLoginAt, this._initializeTime();
731
+ }
732
+ toJSON() {
733
+ return {
734
+ createdAt: this.createdAt,
735
+ lastLoginAt: this.lastLoginAt
736
+ };
737
+ }
738
+ }
739
+ /**
740
+ * @license
741
+ * Copyright 2019 Google LLC
742
+ *
743
+ * Licensed under the Apache License, Version 2.0 (the "License");
744
+ * you may not use this file except in compliance with the License.
745
+ * You may obtain a copy of the License at
746
+ *
747
+ * http://www.apache.org/licenses/LICENSE-2.0
748
+ *
749
+ * Unless required by applicable law or agreed to in writing, software
750
+ * distributed under the License is distributed on an "AS IS" BASIS,
751
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
752
+ * See the License for the specific language governing permissions and
753
+ * limitations under the License.
754
+ */
755
+ async function Q(n) {
756
+ var e;
757
+ const t = n.auth, i = await n.getIdToken(), r = await U(n, bn(t, { idToken: i }));
758
+ u(
759
+ r == null ? void 0 : r.users.length,
760
+ t,
761
+ "internal-error"
762
+ /* AuthErrorCode.INTERNAL_ERROR */
763
+ );
764
+ const s = r.users[0];
765
+ n._notifyReloadListener(s);
766
+ const o = !((e = s.providerUserInfo) === null || e === void 0) && e.length ? Ln(s.providerUserInfo) : [], c = On(n.providerData, o), a = n.isAnonymous, l = !(n.email && s.passwordHash) && !(c != null && c.length), d = a ? l : !1, h = {
767
+ uid: s.localId,
768
+ displayName: s.displayName || null,
769
+ photoURL: s.photoUrl || null,
770
+ email: s.email || null,
771
+ emailVerified: s.emailVerified || !1,
772
+ phoneNumber: s.phoneNumber || null,
773
+ tenantId: s.tenantId || null,
774
+ providerData: c,
775
+ metadata: new lt(s.createdAt, s.lastLoginAt),
776
+ isAnonymous: d
777
+ };
778
+ Object.assign(n, h);
779
+ }
780
+ async function Nn(n) {
781
+ const e = O(n);
782
+ await Q(e), await e.auth._persistUserIfCurrent(e), e.auth._notifyListenersIfCurrent(e);
783
+ }
784
+ function On(n, e) {
785
+ return [...n.filter((i) => !e.some((r) => r.providerId === i.providerId)), ...e];
786
+ }
787
+ function Ln(n) {
788
+ return n.map((e) => {
789
+ var { providerId: t } = e, i = me(e, ["providerId"]);
790
+ return {
791
+ providerId: t,
792
+ uid: i.rawId || "",
793
+ displayName: i.displayName || null,
794
+ email: i.email || null,
795
+ phoneNumber: i.phoneNumber || null,
796
+ photoURL: i.photoUrl || null
797
+ };
798
+ });
799
+ }
800
+ /**
801
+ * @license
802
+ * Copyright 2020 Google LLC
803
+ *
804
+ * Licensed under the Apache License, Version 2.0 (the "License");
805
+ * you may not use this file except in compliance with the License.
806
+ * You may obtain a copy of the License at
807
+ *
808
+ * http://www.apache.org/licenses/LICENSE-2.0
809
+ *
810
+ * Unless required by applicable law or agreed to in writing, software
811
+ * distributed under the License is distributed on an "AS IS" BASIS,
812
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
813
+ * See the License for the specific language governing permissions and
814
+ * limitations under the License.
815
+ */
816
+ async function Mn(n, e) {
817
+ const t = await ot(n, {}, async () => {
818
+ const i = x({
819
+ grant_type: "refresh_token",
820
+ refresh_token: e
821
+ }).slice(1), { tokenApiHost: r, apiKey: s } = n.config, o = ct(n, r, "/v1/token", `key=${s}`), c = await n._getAdditionalHeaders();
822
+ return c[
823
+ "Content-Type"
824
+ /* HttpHeader.CONTENT_TYPE */
825
+ ] = "application/x-www-form-urlencoded", st.fetch()(o, {
826
+ method: "POST",
827
+ headers: c,
828
+ body: i
829
+ });
830
+ });
831
+ return {
832
+ accessToken: t.access_token,
833
+ expiresIn: t.expires_in,
834
+ refreshToken: t.refresh_token
835
+ };
836
+ }
837
+ /**
838
+ * @license
839
+ * Copyright 2020 Google LLC
840
+ *
841
+ * Licensed under the Apache License, Version 2.0 (the "License");
842
+ * you may not use this file except in compliance with the License.
843
+ * You may obtain a copy of the License at
844
+ *
845
+ * http://www.apache.org/licenses/LICENSE-2.0
846
+ *
847
+ * Unless required by applicable law or agreed to in writing, software
848
+ * distributed under the License is distributed on an "AS IS" BASIS,
849
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
850
+ * See the License for the specific language governing permissions and
851
+ * limitations under the License.
852
+ */
853
+ class D {
854
+ constructor() {
855
+ this.refreshToken = null, this.accessToken = null, this.expirationTime = null;
856
+ }
857
+ get isExpired() {
858
+ return !this.expirationTime || Date.now() > this.expirationTime - 3e4;
859
+ }
860
+ updateFromServerResponse(e) {
861
+ u(
862
+ e.idToken,
863
+ "internal-error"
864
+ /* AuthErrorCode.INTERNAL_ERROR */
865
+ ), u(
866
+ typeof e.idToken < "u",
867
+ "internal-error"
868
+ /* AuthErrorCode.INTERNAL_ERROR */
869
+ ), u(
870
+ typeof e.refreshToken < "u",
871
+ "internal-error"
872
+ /* AuthErrorCode.INTERNAL_ERROR */
873
+ );
874
+ const t = "expiresIn" in e && typeof e.expiresIn < "u" ? Number(e.expiresIn) : An(e.idToken);
875
+ this.updateTokensAndExpiration(e.idToken, e.refreshToken, t);
876
+ }
877
+ async getToken(e, t = !1) {
878
+ return u(
879
+ !this.accessToken || this.refreshToken,
880
+ e,
881
+ "user-token-expired"
882
+ /* AuthErrorCode.TOKEN_EXPIRED */
883
+ ), !t && this.accessToken && !this.isExpired ? this.accessToken : this.refreshToken ? (await this.refresh(e, this.refreshToken), this.accessToken) : null;
884
+ }
885
+ clearRefreshToken() {
886
+ this.refreshToken = null;
887
+ }
888
+ async refresh(e, t) {
889
+ const { accessToken: i, refreshToken: r, expiresIn: s } = await Mn(e, t);
890
+ this.updateTokensAndExpiration(i, r, Number(s));
891
+ }
892
+ updateTokensAndExpiration(e, t, i) {
893
+ this.refreshToken = t || null, this.accessToken = e || null, this.expirationTime = Date.now() + i * 1e3;
894
+ }
895
+ static fromJSON(e, t) {
896
+ const { refreshToken: i, accessToken: r, expirationTime: s } = t, o = new D();
897
+ return i && (u(typeof i == "string", "internal-error", {
898
+ appName: e
899
+ }), o.refreshToken = i), r && (u(typeof r == "string", "internal-error", {
900
+ appName: e
901
+ }), o.accessToken = r), s && (u(typeof s == "number", "internal-error", {
902
+ appName: e
903
+ }), o.expirationTime = s), o;
904
+ }
905
+ toJSON() {
906
+ return {
907
+ refreshToken: this.refreshToken,
908
+ accessToken: this.accessToken,
909
+ expirationTime: this.expirationTime
910
+ };
911
+ }
912
+ _assign(e) {
913
+ this.accessToken = e.accessToken, this.refreshToken = e.refreshToken, this.expirationTime = e.expirationTime;
914
+ }
915
+ _clone() {
916
+ return Object.assign(new D(), this.toJSON());
917
+ }
918
+ _performRefresh() {
919
+ return _("not implemented");
920
+ }
921
+ }
922
+ /**
923
+ * @license
924
+ * Copyright 2020 Google LLC
925
+ *
926
+ * Licensed under the Apache License, Version 2.0 (the "License");
927
+ * you may not use this file except in compliance with the License.
928
+ * You may obtain a copy of the License at
929
+ *
930
+ * http://www.apache.org/licenses/LICENSE-2.0
931
+ *
932
+ * Unless required by applicable law or agreed to in writing, software
933
+ * distributed under the License is distributed on an "AS IS" BASIS,
934
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
935
+ * See the License for the specific language governing permissions and
936
+ * limitations under the License.
937
+ */
938
+ function T(n, e) {
939
+ u(typeof n == "string" || typeof n > "u", "internal-error", { appName: e });
940
+ }
941
+ class b {
942
+ constructor(e) {
943
+ var { uid: t, auth: i, stsTokenManager: r } = e, s = me(e, ["uid", "auth", "stsTokenManager"]);
944
+ this.providerId = "firebase", this.proactiveRefresh = new Pn(this), this.reloadUserInfo = null, this.reloadListener = null, this.uid = t, this.auth = i, this.stsTokenManager = r, this.accessToken = r.accessToken, this.displayName = s.displayName || null, this.email = s.email || null, this.emailVerified = s.emailVerified || !1, this.phoneNumber = s.phoneNumber || null, this.photoURL = s.photoURL || null, this.isAnonymous = s.isAnonymous || !1, this.tenantId = s.tenantId || null, this.providerData = s.providerData ? [...s.providerData] : [], this.metadata = new lt(s.createdAt || void 0, s.lastLoginAt || void 0);
945
+ }
946
+ async getIdToken(e) {
947
+ const t = await U(this, this.stsTokenManager.getToken(this.auth, e));
948
+ return u(
949
+ t,
950
+ this.auth,
951
+ "internal-error"
952
+ /* AuthErrorCode.INTERNAL_ERROR */
953
+ ), this.accessToken !== t && (this.accessToken = t, await this.auth._persistUserIfCurrent(this), this.auth._notifyListenersIfCurrent(this)), t;
954
+ }
955
+ getIdTokenResult(e) {
956
+ return Sn(this, e);
957
+ }
958
+ reload() {
959
+ return Nn(this);
960
+ }
961
+ _assign(e) {
962
+ this !== e && (u(
963
+ this.uid === e.uid,
964
+ this.auth,
965
+ "internal-error"
966
+ /* AuthErrorCode.INTERNAL_ERROR */
967
+ ), this.displayName = e.displayName, this.photoURL = e.photoURL, this.email = e.email, this.emailVerified = e.emailVerified, this.phoneNumber = e.phoneNumber, this.isAnonymous = e.isAnonymous, this.tenantId = e.tenantId, this.providerData = e.providerData.map((t) => Object.assign({}, t)), this.metadata._copy(e.metadata), this.stsTokenManager._assign(e.stsTokenManager));
968
+ }
969
+ _clone(e) {
970
+ const t = new b(Object.assign(Object.assign({}, this), { auth: e, stsTokenManager: this.stsTokenManager._clone() }));
971
+ return t.metadata._copy(this.metadata), t;
972
+ }
973
+ _onReload(e) {
974
+ u(
975
+ !this.reloadListener,
976
+ this.auth,
977
+ "internal-error"
978
+ /* AuthErrorCode.INTERNAL_ERROR */
979
+ ), this.reloadListener = e, this.reloadUserInfo && (this._notifyReloadListener(this.reloadUserInfo), this.reloadUserInfo = null);
980
+ }
981
+ _notifyReloadListener(e) {
982
+ this.reloadListener ? this.reloadListener(e) : this.reloadUserInfo = e;
983
+ }
984
+ _startProactiveRefresh() {
985
+ this.proactiveRefresh._start();
986
+ }
987
+ _stopProactiveRefresh() {
988
+ this.proactiveRefresh._stop();
989
+ }
990
+ async _updateTokensIfNecessary(e, t = !1) {
991
+ let i = !1;
992
+ e.idToken && e.idToken !== this.stsTokenManager.accessToken && (this.stsTokenManager.updateFromServerResponse(e), i = !0), t && await Q(this), await this.auth._persistUserIfCurrent(this), i && this.auth._notifyListenersIfCurrent(this);
993
+ }
994
+ async delete() {
995
+ const e = await this.getIdToken();
996
+ return await U(this, Rn(this.auth, { idToken: e })), this.stsTokenManager.clearRefreshToken(), this.auth.signOut();
997
+ }
998
+ toJSON() {
999
+ return Object.assign(Object.assign({
1000
+ uid: this.uid,
1001
+ email: this.email || void 0,
1002
+ emailVerified: this.emailVerified,
1003
+ displayName: this.displayName || void 0,
1004
+ isAnonymous: this.isAnonymous,
1005
+ photoURL: this.photoURL || void 0,
1006
+ phoneNumber: this.phoneNumber || void 0,
1007
+ tenantId: this.tenantId || void 0,
1008
+ providerData: this.providerData.map((e) => Object.assign({}, e)),
1009
+ stsTokenManager: this.stsTokenManager.toJSON(),
1010
+ // Redirect event ID must be maintained in case there is a pending
1011
+ // redirect event.
1012
+ _redirectEventId: this._redirectEventId
1013
+ }, this.metadata.toJSON()), {
1014
+ // Required for compatibility with the legacy SDK (go/firebase-auth-sdk-persistence-parsing):
1015
+ apiKey: this.auth.config.apiKey,
1016
+ appName: this.auth.name
1017
+ });
1018
+ }
1019
+ get refreshToken() {
1020
+ return this.stsTokenManager.refreshToken || "";
1021
+ }
1022
+ static _fromJSON(e, t) {
1023
+ var i, r, s, o, c, a, l, d;
1024
+ const h = (i = t.displayName) !== null && i !== void 0 ? i : void 0, p = (r = t.email) !== null && r !== void 0 ? r : void 0, B = (s = t.phoneNumber) !== null && s !== void 0 ? s : void 0, K = (o = t.photoURL) !== null && o !== void 0 ? o : void 0, ke = (c = t.tenantId) !== null && c !== void 0 ? c : void 0, se = (a = t._redirectEventId) !== null && a !== void 0 ? a : void 0, Re = (l = t.createdAt) !== null && l !== void 0 ? l : void 0, be = (d = t.lastLoginAt) !== null && d !== void 0 ? d : void 0, { uid: oe, emailVerified: Se, isAnonymous: Ae, providerData: ae, stsTokenManager: Ce } = t;
1025
+ u(
1026
+ oe && Ce,
1027
+ e,
1028
+ "internal-error"
1029
+ /* AuthErrorCode.INTERNAL_ERROR */
1030
+ );
1031
+ const Dt = D.fromJSON(this.name, Ce);
1032
+ u(
1033
+ typeof oe == "string",
1034
+ e,
1035
+ "internal-error"
1036
+ /* AuthErrorCode.INTERNAL_ERROR */
1037
+ ), T(h, e.name), T(p, e.name), u(
1038
+ typeof Se == "boolean",
1039
+ e,
1040
+ "internal-error"
1041
+ /* AuthErrorCode.INTERNAL_ERROR */
1042
+ ), u(
1043
+ typeof Ae == "boolean",
1044
+ e,
1045
+ "internal-error"
1046
+ /* AuthErrorCode.INTERNAL_ERROR */
1047
+ ), T(B, e.name), T(K, e.name), T(ke, e.name), T(se, e.name), T(Re, e.name), T(be, e.name);
1048
+ const ce = new b({
1049
+ uid: oe,
1050
+ auth: e,
1051
+ email: p,
1052
+ emailVerified: Se,
1053
+ displayName: h,
1054
+ isAnonymous: Ae,
1055
+ photoURL: K,
1056
+ phoneNumber: B,
1057
+ tenantId: ke,
1058
+ stsTokenManager: Dt,
1059
+ createdAt: Re,
1060
+ lastLoginAt: be
1061
+ });
1062
+ return ae && Array.isArray(ae) && (ce.providerData = ae.map((Ft) => Object.assign({}, Ft))), se && (ce._redirectEventId = se), ce;
1063
+ }
1064
+ /**
1065
+ * Initialize a User from an idToken server response
1066
+ * @param auth
1067
+ * @param idTokenResponse
1068
+ */
1069
+ static async _fromIdTokenResponse(e, t, i = !1) {
1070
+ const r = new D();
1071
+ r.updateFromServerResponse(t);
1072
+ const s = new b({
1073
+ uid: t.localId,
1074
+ auth: e,
1075
+ stsTokenManager: r,
1076
+ isAnonymous: i
1077
+ });
1078
+ return await Q(s), s;
1079
+ }
1080
+ }
1081
+ /**
1082
+ * @license
1083
+ * Copyright 2020 Google LLC
1084
+ *
1085
+ * Licensed under the Apache License, Version 2.0 (the "License");
1086
+ * you may not use this file except in compliance with the License.
1087
+ * You may obtain a copy of the License at
1088
+ *
1089
+ * http://www.apache.org/licenses/LICENSE-2.0
1090
+ *
1091
+ * Unless required by applicable law or agreed to in writing, software
1092
+ * distributed under the License is distributed on an "AS IS" BASIS,
1093
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094
+ * See the License for the specific language governing permissions and
1095
+ * limitations under the License.
1096
+ */
1097
+ const Me = /* @__PURE__ */ new Map();
1098
+ function v(n) {
1099
+ y(n instanceof Function, "Expected a class definition");
1100
+ let e = Me.get(n);
1101
+ return e ? (y(e instanceof n, "Instance stored in cache mismatched with class"), e) : (e = new n(), Me.set(n, e), e);
1102
+ }
1103
+ /**
1104
+ * @license
1105
+ * Copyright 2019 Google LLC
1106
+ *
1107
+ * Licensed under the Apache License, Version 2.0 (the "License");
1108
+ * you may not use this file except in compliance with the License.
1109
+ * You may obtain a copy of the License at
1110
+ *
1111
+ * http://www.apache.org/licenses/LICENSE-2.0
1112
+ *
1113
+ * Unless required by applicable law or agreed to in writing, software
1114
+ * distributed under the License is distributed on an "AS IS" BASIS,
1115
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1116
+ * See the License for the specific language governing permissions and
1117
+ * limitations under the License.
1118
+ */
1119
+ class ut {
1120
+ constructor() {
1121
+ this.type = "NONE", this.storage = {};
1122
+ }
1123
+ async _isAvailable() {
1124
+ return !0;
1125
+ }
1126
+ async _set(e, t) {
1127
+ this.storage[e] = t;
1128
+ }
1129
+ async _get(e) {
1130
+ const t = this.storage[e];
1131
+ return t === void 0 ? null : t;
1132
+ }
1133
+ async _remove(e) {
1134
+ delete this.storage[e];
1135
+ }
1136
+ _addListener(e, t) {
1137
+ }
1138
+ _removeListener(e, t) {
1139
+ }
1140
+ }
1141
+ ut.type = "NONE";
1142
+ const Ue = ut;
1143
+ /**
1144
+ * @license
1145
+ * Copyright 2019 Google LLC
1146
+ *
1147
+ * Licensed under the Apache License, Version 2.0 (the "License");
1148
+ * you may not use this file except in compliance with the License.
1149
+ * You may obtain a copy of the License at
1150
+ *
1151
+ * http://www.apache.org/licenses/LICENSE-2.0
1152
+ *
1153
+ * Unless required by applicable law or agreed to in writing, software
1154
+ * distributed under the License is distributed on an "AS IS" BASIS,
1155
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1156
+ * See the License for the specific language governing permissions and
1157
+ * limitations under the License.
1158
+ */
1159
+ function z(n, e, t) {
1160
+ return `firebase:${n}:${e}:${t}`;
1161
+ }
1162
+ class P {
1163
+ constructor(e, t, i) {
1164
+ this.persistence = e, this.auth = t, this.userKey = i;
1165
+ const { config: r, name: s } = this.auth;
1166
+ this.fullUserKey = z(this.userKey, r.apiKey, s), this.fullPersistenceKey = z("persistence", r.apiKey, s), this.boundEventHandler = t._onStorageEvent.bind(t), this.persistence._addListener(this.fullUserKey, this.boundEventHandler);
1167
+ }
1168
+ setCurrentUser(e) {
1169
+ return this.persistence._set(this.fullUserKey, e.toJSON());
1170
+ }
1171
+ async getCurrentUser() {
1172
+ const e = await this.persistence._get(this.fullUserKey);
1173
+ return e ? b._fromJSON(this.auth, e) : null;
1174
+ }
1175
+ removeCurrentUser() {
1176
+ return this.persistence._remove(this.fullUserKey);
1177
+ }
1178
+ savePersistenceForRedirect() {
1179
+ return this.persistence._set(this.fullPersistenceKey, this.persistence.type);
1180
+ }
1181
+ async setPersistence(e) {
1182
+ if (this.persistence === e)
1183
+ return;
1184
+ const t = await this.getCurrentUser();
1185
+ if (await this.removeCurrentUser(), this.persistence = e, t)
1186
+ return this.setCurrentUser(t);
1187
+ }
1188
+ delete() {
1189
+ this.persistence._removeListener(this.fullUserKey, this.boundEventHandler);
1190
+ }
1191
+ static async create(e, t, i = "authUser") {
1192
+ if (!t.length)
1193
+ return new P(v(Ue), e, i);
1194
+ const r = (await Promise.all(t.map(async (l) => {
1195
+ if (await l._isAvailable())
1196
+ return l;
1197
+ }))).filter((l) => l);
1198
+ let s = r[0] || v(Ue);
1199
+ const o = z(i, e.config.apiKey, e.name);
1200
+ let c = null;
1201
+ for (const l of t)
1202
+ try {
1203
+ const d = await l._get(o);
1204
+ if (d) {
1205
+ const h = b._fromJSON(e, d);
1206
+ l !== s && (c = h), s = l;
1207
+ break;
1208
+ }
1209
+ } catch {
1210
+ }
1211
+ const a = r.filter((l) => l._shouldAllowMigration);
1212
+ return !s._shouldAllowMigration || !a.length ? new P(s, e, i) : (s = a[0], c && await s._set(o, c.toJSON()), await Promise.all(t.map(async (l) => {
1213
+ if (l !== s)
1214
+ try {
1215
+ await l._remove(o);
1216
+ } catch {
1217
+ }
1218
+ })), new P(s, e, i));
1219
+ }
1220
+ }
1221
+ /**
1222
+ * @license
1223
+ * Copyright 2020 Google LLC
1224
+ *
1225
+ * Licensed under the Apache License, Version 2.0 (the "License");
1226
+ * you may not use this file except in compliance with the License.
1227
+ * You may obtain a copy of the License at
1228
+ *
1229
+ * http://www.apache.org/licenses/LICENSE-2.0
1230
+ *
1231
+ * Unless required by applicable law or agreed to in writing, software
1232
+ * distributed under the License is distributed on an "AS IS" BASIS,
1233
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1234
+ * See the License for the specific language governing permissions and
1235
+ * limitations under the License.
1236
+ */
1237
+ function De(n) {
1238
+ const e = n.toLowerCase();
1239
+ if (e.includes("opera/") || e.includes("opr/") || e.includes("opios/"))
1240
+ return "Opera";
1241
+ if (ft(e))
1242
+ return "IEMobile";
1243
+ if (e.includes("msie") || e.includes("trident/"))
1244
+ return "IE";
1245
+ if (e.includes("edge/"))
1246
+ return "Edge";
1247
+ if (dt(e))
1248
+ return "Firefox";
1249
+ if (e.includes("silk/"))
1250
+ return "Silk";
1251
+ if (gt(e))
1252
+ return "Blackberry";
1253
+ if (mt(e))
1254
+ return "Webos";
1255
+ if (Te(e))
1256
+ return "Safari";
1257
+ if ((e.includes("chrome/") || ht(e)) && !e.includes("edge/"))
1258
+ return "Chrome";
1259
+ if (pt(e))
1260
+ return "Android";
1261
+ {
1262
+ const t = /([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/, i = n.match(t);
1263
+ if ((i == null ? void 0 : i.length) === 2)
1264
+ return i[1];
1265
+ }
1266
+ return "Other";
1267
+ }
1268
+ function dt(n = f()) {
1269
+ return /firefox\//i.test(n);
1270
+ }
1271
+ function Te(n = f()) {
1272
+ const e = n.toLowerCase();
1273
+ return e.includes("safari/") && !e.includes("chrome/") && !e.includes("crios/") && !e.includes("android");
1274
+ }
1275
+ function ht(n = f()) {
1276
+ return /crios\//i.test(n);
1277
+ }
1278
+ function ft(n = f()) {
1279
+ return /iemobile/i.test(n);
1280
+ }
1281
+ function pt(n = f()) {
1282
+ return /android/i.test(n);
1283
+ }
1284
+ function gt(n = f()) {
1285
+ return /blackberry/i.test(n);
1286
+ }
1287
+ function mt(n = f()) {
1288
+ return /webos/i.test(n);
1289
+ }
1290
+ function ne(n = f()) {
1291
+ return /iphone|ipad|ipod/i.test(n) || /macintosh/i.test(n) && /mobile/i.test(n);
1292
+ }
1293
+ function Un(n = f()) {
1294
+ var e;
1295
+ return ne(n) && !!(!((e = window.navigator) === null || e === void 0) && e.standalone);
1296
+ }
1297
+ function Dn() {
1298
+ return on() && document.documentMode === 10;
1299
+ }
1300
+ function _t(n = f()) {
1301
+ return ne(n) || pt(n) || mt(n) || gt(n) || /windows phone/i.test(n) || ft(n);
1302
+ }
1303
+ function Fn() {
1304
+ try {
1305
+ return !!(window && window !== window.top);
1306
+ } catch {
1307
+ return !1;
1308
+ }
1309
+ }
1310
+ /**
1311
+ * @license
1312
+ * Copyright 2020 Google LLC
1313
+ *
1314
+ * Licensed under the Apache License, Version 2.0 (the "License");
1315
+ * you may not use this file except in compliance with the License.
1316
+ * You may obtain a copy of the License at
1317
+ *
1318
+ * http://www.apache.org/licenses/LICENSE-2.0
1319
+ *
1320
+ * Unless required by applicable law or agreed to in writing, software
1321
+ * distributed under the License is distributed on an "AS IS" BASIS,
1322
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1323
+ * See the License for the specific language governing permissions and
1324
+ * limitations under the License.
1325
+ */
1326
+ function vt(n, e = []) {
1327
+ let t;
1328
+ switch (n) {
1329
+ case "Browser":
1330
+ t = De(f());
1331
+ break;
1332
+ case "Worker":
1333
+ t = `${De(f())}-${n}`;
1334
+ break;
1335
+ default:
1336
+ t = n;
1337
+ }
1338
+ const i = e.length ? e.join(",") : "FirebaseCore-web";
1339
+ return `${t}/JsCore/${F}/${i}`;
1340
+ }
1341
+ async function It(n, e) {
1342
+ return W(n, "GET", "/v2/recaptchaConfig", Ie(n, e));
1343
+ }
1344
+ function Fe(n) {
1345
+ return n !== void 0 && n.enterprise !== void 0;
1346
+ }
1347
+ class yt {
1348
+ constructor(e) {
1349
+ if (this.siteKey = "", this.emailPasswordEnabled = !1, e.recaptchaKey === void 0)
1350
+ throw new Error("recaptchaKey undefined");
1351
+ this.siteKey = e.recaptchaKey.split("/")[3], this.emailPasswordEnabled = e.recaptchaEnforcementState.some((t) => t.provider === "EMAIL_PASSWORD_PROVIDER" && t.enforcementState !== "OFF");
1352
+ }
1353
+ }
1354
+ /**
1355
+ * @license
1356
+ * Copyright 2020 Google LLC
1357
+ *
1358
+ * Licensed under the Apache License, Version 2.0 (the "License");
1359
+ * you may not use this file except in compliance with the License.
1360
+ * You may obtain a copy of the License at
1361
+ *
1362
+ * http://www.apache.org/licenses/LICENSE-2.0
1363
+ *
1364
+ * Unless required by applicable law or agreed to in writing, software
1365
+ * distributed under the License is distributed on an "AS IS" BASIS,
1366
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1367
+ * See the License for the specific language governing permissions and
1368
+ * limitations under the License.
1369
+ */
1370
+ function xn() {
1371
+ var n, e;
1372
+ return (e = (n = document.getElementsByTagName("head")) === null || n === void 0 ? void 0 : n[0]) !== null && e !== void 0 ? e : document;
1373
+ }
1374
+ function Tt(n) {
1375
+ return new Promise((e, t) => {
1376
+ const i = document.createElement("script");
1377
+ i.setAttribute("src", n), i.onload = e, i.onerror = (r) => {
1378
+ const s = g(
1379
+ "internal-error"
1380
+ /* AuthErrorCode.INTERNAL_ERROR */
1381
+ );
1382
+ s.customData = r, t(s);
1383
+ }, i.type = "text/javascript", i.charset = "UTF-8", xn().appendChild(i);
1384
+ });
1385
+ }
1386
+ function Vn(n) {
1387
+ return `__${n}${Math.floor(Math.random() * 1e6)}`;
1388
+ }
1389
+ const Wn = "https://www.google.com/recaptcha/enterprise.js?render=", Hn = "recaptcha-enterprise", $n = "NO_RECAPTCHA";
1390
+ class jn {
1391
+ /**
1392
+ *
1393
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
1394
+ *
1395
+ */
1396
+ constructor(e) {
1397
+ this.type = Hn, this.auth = H(e);
1398
+ }
1399
+ /**
1400
+ * Executes the verification process.
1401
+ *
1402
+ * @returns A Promise for a token that can be used to assert the validity of a request.
1403
+ */
1404
+ async verify(e = "verify", t = !1) {
1405
+ async function i(s) {
1406
+ if (!t) {
1407
+ if (s.tenantId == null && s._agentRecaptchaConfig != null)
1408
+ return s._agentRecaptchaConfig.siteKey;
1409
+ if (s.tenantId != null && s._tenantRecaptchaConfigs[s.tenantId] !== void 0)
1410
+ return s._tenantRecaptchaConfigs[s.tenantId].siteKey;
1411
+ }
1412
+ return new Promise(async (o, c) => {
1413
+ It(s, {
1414
+ clientType: "CLIENT_TYPE_WEB",
1415
+ version: "RECAPTCHA_ENTERPRISE"
1416
+ /* RecaptchaVersion.ENTERPRISE */
1417
+ }).then((a) => {
1418
+ if (a.recaptchaKey === void 0)
1419
+ c(new Error("recaptcha Enterprise site key undefined"));
1420
+ else {
1421
+ const l = new yt(a);
1422
+ return s.tenantId == null ? s._agentRecaptchaConfig = l : s._tenantRecaptchaConfigs[s.tenantId] = l, o(l.siteKey);
1423
+ }
1424
+ }).catch((a) => {
1425
+ c(a);
1426
+ });
1427
+ });
1428
+ }
1429
+ function r(s, o, c) {
1430
+ const a = window.grecaptcha;
1431
+ Fe(a) ? a.enterprise.ready(() => {
1432
+ a.enterprise.execute(s, { action: e }).then((l) => {
1433
+ o(l);
1434
+ }).catch(() => {
1435
+ o($n);
1436
+ });
1437
+ }) : c(Error("No reCAPTCHA enterprise script loaded."));
1438
+ }
1439
+ return new Promise((s, o) => {
1440
+ i(this.auth).then((c) => {
1441
+ if (!t && Fe(window.grecaptcha))
1442
+ r(c, s, o);
1443
+ else {
1444
+ if (typeof window > "u") {
1445
+ o(new Error("RecaptchaVerifier is only supported in browser"));
1446
+ return;
1447
+ }
1448
+ Tt(Wn + c).then(() => {
1449
+ r(c, s, o);
1450
+ }).catch((a) => {
1451
+ o(a);
1452
+ });
1453
+ }
1454
+ }).catch((c) => {
1455
+ o(c);
1456
+ });
1457
+ });
1458
+ }
1459
+ }
1460
+ /**
1461
+ * @license
1462
+ * Copyright 2022 Google LLC
1463
+ *
1464
+ * Licensed under the Apache License, Version 2.0 (the "License");
1465
+ * you may not use this file except in compliance with the License.
1466
+ * You may obtain a copy of the License at
1467
+ *
1468
+ * http://www.apache.org/licenses/LICENSE-2.0
1469
+ *
1470
+ * Unless required by applicable law or agreed to in writing, software
1471
+ * distributed under the License is distributed on an "AS IS" BASIS,
1472
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1473
+ * See the License for the specific language governing permissions and
1474
+ * limitations under the License.
1475
+ */
1476
+ class Bn {
1477
+ constructor(e) {
1478
+ this.auth = e, this.queue = [];
1479
+ }
1480
+ pushCallback(e, t) {
1481
+ const i = (s) => new Promise((o, c) => {
1482
+ try {
1483
+ const a = e(s);
1484
+ o(a);
1485
+ } catch (a) {
1486
+ c(a);
1487
+ }
1488
+ });
1489
+ i.onAbort = t, this.queue.push(i);
1490
+ const r = this.queue.length - 1;
1491
+ return () => {
1492
+ this.queue[r] = () => Promise.resolve();
1493
+ };
1494
+ }
1495
+ async runMiddleware(e) {
1496
+ if (this.auth.currentUser === e)
1497
+ return;
1498
+ const t = [];
1499
+ try {
1500
+ for (const i of this.queue)
1501
+ await i(e), i.onAbort && t.push(i.onAbort);
1502
+ } catch (i) {
1503
+ t.reverse();
1504
+ for (const r of t)
1505
+ try {
1506
+ r();
1507
+ } catch {
1508
+ }
1509
+ throw this.auth._errorFactory.create("login-blocked", {
1510
+ originalMessage: i == null ? void 0 : i.message
1511
+ });
1512
+ }
1513
+ }
1514
+ }
1515
+ /**
1516
+ * @license
1517
+ * Copyright 2020 Google LLC
1518
+ *
1519
+ * Licensed under the Apache License, Version 2.0 (the "License");
1520
+ * you may not use this file except in compliance with the License.
1521
+ * You may obtain a copy of the License at
1522
+ *
1523
+ * http://www.apache.org/licenses/LICENSE-2.0
1524
+ *
1525
+ * Unless required by applicable law or agreed to in writing, software
1526
+ * distributed under the License is distributed on an "AS IS" BASIS,
1527
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1528
+ * See the License for the specific language governing permissions and
1529
+ * limitations under the License.
1530
+ */
1531
+ class Kn {
1532
+ constructor(e, t, i, r) {
1533
+ this.app = e, this.heartbeatServiceProvider = t, this.appCheckServiceProvider = i, this.config = r, this.currentUser = null, this.emulatorConfig = null, this.operations = Promise.resolve(), this.authStateSubscription = new xe(this), this.idTokenSubscription = new xe(this), this.beforeStateQueue = new Bn(this), this.redirectUser = null, this.isProactiveRefreshEnabled = !1, this._canInitEmulator = !0, this._isInitialized = !1, this._deleted = !1, this._initializationPromise = null, this._popupRedirectResolver = null, this._errorFactory = rt, this._agentRecaptchaConfig = null, this._tenantRecaptchaConfigs = {}, this.lastNotifiedUid = void 0, this.languageCode = null, this.tenantId = null, this.settings = { appVerificationDisabledForTesting: !1 }, this.frameworks = [], this.name = e.name, this.clientVersion = r.sdkClientVersion;
1534
+ }
1535
+ _initializeWithPersistence(e, t) {
1536
+ return t && (this._popupRedirectResolver = v(t)), this._initializationPromise = this.queue(async () => {
1537
+ var i, r;
1538
+ if (!this._deleted && (this.persistenceManager = await P.create(this, e), !this._deleted)) {
1539
+ if (!((i = this._popupRedirectResolver) === null || i === void 0) && i._shouldInitProactively)
1540
+ try {
1541
+ await this._popupRedirectResolver._initialize(this);
1542
+ } catch {
1543
+ }
1544
+ await this.initializeCurrentUser(t), this.lastNotifiedUid = ((r = this.currentUser) === null || r === void 0 ? void 0 : r.uid) || null, !this._deleted && (this._isInitialized = !0);
1545
+ }
1546
+ }), this._initializationPromise;
1547
+ }
1548
+ /**
1549
+ * If the persistence is changed in another window, the user manager will let us know
1550
+ */
1551
+ async _onStorageEvent() {
1552
+ if (this._deleted)
1553
+ return;
1554
+ const e = await this.assertedPersistence.getCurrentUser();
1555
+ if (!(!this.currentUser && !e)) {
1556
+ if (this.currentUser && e && this.currentUser.uid === e.uid) {
1557
+ this._currentUser._assign(e), await this.currentUser.getIdToken();
1558
+ return;
1559
+ }
1560
+ await this._updateCurrentUser(
1561
+ e,
1562
+ /* skipBeforeStateCallbacks */
1563
+ !0
1564
+ );
1565
+ }
1566
+ }
1567
+ async initializeCurrentUser(e) {
1568
+ var t;
1569
+ const i = await this.assertedPersistence.getCurrentUser();
1570
+ let r = i, s = !1;
1571
+ if (e && this.config.authDomain) {
1572
+ await this.getOrInitRedirectPersistenceManager();
1573
+ const o = (t = this.redirectUser) === null || t === void 0 ? void 0 : t._redirectEventId, c = r == null ? void 0 : r._redirectEventId, a = await this.tryRedirectSignIn(e);
1574
+ (!o || o === c) && (a != null && a.user) && (r = a.user, s = !0);
1575
+ }
1576
+ if (!r)
1577
+ return this.directlySetCurrentUser(null);
1578
+ if (!r._redirectEventId) {
1579
+ if (s)
1580
+ try {
1581
+ await this.beforeStateQueue.runMiddleware(r);
1582
+ } catch (o) {
1583
+ r = i, this._popupRedirectResolver._overrideRedirectResult(this, () => Promise.reject(o));
1584
+ }
1585
+ return r ? this.reloadAndSetCurrentUserOrClear(r) : this.directlySetCurrentUser(null);
1586
+ }
1587
+ return u(
1588
+ this._popupRedirectResolver,
1589
+ this,
1590
+ "argument-error"
1591
+ /* AuthErrorCode.ARGUMENT_ERROR */
1592
+ ), await this.getOrInitRedirectPersistenceManager(), this.redirectUser && this.redirectUser._redirectEventId === r._redirectEventId ? this.directlySetCurrentUser(r) : this.reloadAndSetCurrentUserOrClear(r);
1593
+ }
1594
+ async tryRedirectSignIn(e) {
1595
+ let t = null;
1596
+ try {
1597
+ t = await this._popupRedirectResolver._completeRedirectFn(this, e, !0);
1598
+ } catch {
1599
+ await this._setRedirectUser(null);
1600
+ }
1601
+ return t;
1602
+ }
1603
+ async reloadAndSetCurrentUserOrClear(e) {
1604
+ try {
1605
+ await Q(e);
1606
+ } catch (t) {
1607
+ if ((t == null ? void 0 : t.code) !== "auth/network-request-failed")
1608
+ return this.directlySetCurrentUser(null);
1609
+ }
1610
+ return this.directlySetCurrentUser(e);
1611
+ }
1612
+ useDeviceLanguage() {
1613
+ this.languageCode = Tn();
1614
+ }
1615
+ async _delete() {
1616
+ this._deleted = !0;
1617
+ }
1618
+ async updateCurrentUser(e) {
1619
+ const t = e ? O(e) : null;
1620
+ return t && u(
1621
+ t.auth.config.apiKey === this.config.apiKey,
1622
+ this,
1623
+ "invalid-user-token"
1624
+ /* AuthErrorCode.INVALID_AUTH */
1625
+ ), this._updateCurrentUser(t && t._clone(this));
1626
+ }
1627
+ async _updateCurrentUser(e, t = !1) {
1628
+ if (!this._deleted)
1629
+ return e && u(
1630
+ this.tenantId === e.tenantId,
1631
+ this,
1632
+ "tenant-id-mismatch"
1633
+ /* AuthErrorCode.TENANT_ID_MISMATCH */
1634
+ ), t || await this.beforeStateQueue.runMiddleware(e), this.queue(async () => {
1635
+ await this.directlySetCurrentUser(e), this.notifyAuthListeners();
1636
+ });
1637
+ }
1638
+ async signOut() {
1639
+ return await this.beforeStateQueue.runMiddleware(null), (this.redirectPersistenceManager || this._popupRedirectResolver) && await this._setRedirectUser(null), this._updateCurrentUser(
1640
+ null,
1641
+ /* skipBeforeStateCallbacks */
1642
+ !0
1643
+ );
1644
+ }
1645
+ setPersistence(e) {
1646
+ return this.queue(async () => {
1647
+ await this.assertedPersistence.setPersistence(v(e));
1648
+ });
1649
+ }
1650
+ async initializeRecaptchaConfig() {
1651
+ const e = await It(this, {
1652
+ clientType: "CLIENT_TYPE_WEB",
1653
+ version: "RECAPTCHA_ENTERPRISE"
1654
+ /* RecaptchaVersion.ENTERPRISE */
1655
+ }), t = new yt(e);
1656
+ this.tenantId == null ? this._agentRecaptchaConfig = t : this._tenantRecaptchaConfigs[this.tenantId] = t, t.emailPasswordEnabled && new jn(this).verify();
1657
+ }
1658
+ _getRecaptchaConfig() {
1659
+ return this.tenantId == null ? this._agentRecaptchaConfig : this._tenantRecaptchaConfigs[this.tenantId];
1660
+ }
1661
+ _getPersistence() {
1662
+ return this.assertedPersistence.persistence.type;
1663
+ }
1664
+ _updateErrorMap(e) {
1665
+ this._errorFactory = new pe("auth", "Firebase", e());
1666
+ }
1667
+ onAuthStateChanged(e, t, i) {
1668
+ return this.registerStateListener(this.authStateSubscription, e, t, i);
1669
+ }
1670
+ beforeAuthStateChanged(e, t) {
1671
+ return this.beforeStateQueue.pushCallback(e, t);
1672
+ }
1673
+ onIdTokenChanged(e, t, i) {
1674
+ return this.registerStateListener(this.idTokenSubscription, e, t, i);
1675
+ }
1676
+ toJSON() {
1677
+ var e;
1678
+ return {
1679
+ apiKey: this.config.apiKey,
1680
+ authDomain: this.config.authDomain,
1681
+ appName: this.name,
1682
+ currentUser: (e = this._currentUser) === null || e === void 0 ? void 0 : e.toJSON()
1683
+ };
1684
+ }
1685
+ async _setRedirectUser(e, t) {
1686
+ const i = await this.getOrInitRedirectPersistenceManager(t);
1687
+ return e === null ? i.removeCurrentUser() : i.setCurrentUser(e);
1688
+ }
1689
+ async getOrInitRedirectPersistenceManager(e) {
1690
+ if (!this.redirectPersistenceManager) {
1691
+ const t = e && v(e) || this._popupRedirectResolver;
1692
+ u(
1693
+ t,
1694
+ this,
1695
+ "argument-error"
1696
+ /* AuthErrorCode.ARGUMENT_ERROR */
1697
+ ), this.redirectPersistenceManager = await P.create(
1698
+ this,
1699
+ [v(t._redirectPersistence)],
1700
+ "redirectUser"
1701
+ /* KeyName.REDIRECT_USER */
1702
+ ), this.redirectUser = await this.redirectPersistenceManager.getCurrentUser();
1703
+ }
1704
+ return this.redirectPersistenceManager;
1705
+ }
1706
+ async _redirectUserForId(e) {
1707
+ var t, i;
1708
+ return this._isInitialized && await this.queue(async () => {
1709
+ }), ((t = this._currentUser) === null || t === void 0 ? void 0 : t._redirectEventId) === e ? this._currentUser : ((i = this.redirectUser) === null || i === void 0 ? void 0 : i._redirectEventId) === e ? this.redirectUser : null;
1710
+ }
1711
+ async _persistUserIfCurrent(e) {
1712
+ if (e === this.currentUser)
1713
+ return this.queue(async () => this.directlySetCurrentUser(e));
1714
+ }
1715
+ /** Notifies listeners only if the user is current */
1716
+ _notifyListenersIfCurrent(e) {
1717
+ e === this.currentUser && this.notifyAuthListeners();
1718
+ }
1719
+ _key() {
1720
+ return `${this.config.authDomain}:${this.config.apiKey}:${this.name}`;
1721
+ }
1722
+ _startProactiveRefresh() {
1723
+ this.isProactiveRefreshEnabled = !0, this.currentUser && this._currentUser._startProactiveRefresh();
1724
+ }
1725
+ _stopProactiveRefresh() {
1726
+ this.isProactiveRefreshEnabled = !1, this.currentUser && this._currentUser._stopProactiveRefresh();
1727
+ }
1728
+ /** Returns the current user cast as the internal type */
1729
+ get _currentUser() {
1730
+ return this.currentUser;
1731
+ }
1732
+ notifyAuthListeners() {
1733
+ var e, t;
1734
+ if (!this._isInitialized)
1735
+ return;
1736
+ this.idTokenSubscription.next(this.currentUser);
1737
+ const i = (t = (e = this.currentUser) === null || e === void 0 ? void 0 : e.uid) !== null && t !== void 0 ? t : null;
1738
+ this.lastNotifiedUid !== i && (this.lastNotifiedUid = i, this.authStateSubscription.next(this.currentUser));
1739
+ }
1740
+ registerStateListener(e, t, i, r) {
1741
+ if (this._deleted)
1742
+ return () => {
1743
+ };
1744
+ const s = typeof t == "function" ? t : t.next.bind(t), o = this._isInitialized ? Promise.resolve() : this._initializationPromise;
1745
+ return u(
1746
+ o,
1747
+ this,
1748
+ "internal-error"
1749
+ /* AuthErrorCode.INTERNAL_ERROR */
1750
+ ), o.then(() => s(this.currentUser)), typeof t == "function" ? e.addObserver(t, i, r) : e.addObserver(t);
1751
+ }
1752
+ /**
1753
+ * Unprotected (from race conditions) method to set the current user. This
1754
+ * should only be called from within a queued callback. This is necessary
1755
+ * because the queue shouldn't rely on another queued callback.
1756
+ */
1757
+ async directlySetCurrentUser(e) {
1758
+ this.currentUser && this.currentUser !== e && this._currentUser._stopProactiveRefresh(), e && this.isProactiveRefreshEnabled && e._startProactiveRefresh(), this.currentUser = e, e ? await this.assertedPersistence.setCurrentUser(e) : await this.assertedPersistence.removeCurrentUser();
1759
+ }
1760
+ queue(e) {
1761
+ return this.operations = this.operations.then(e, e), this.operations;
1762
+ }
1763
+ get assertedPersistence() {
1764
+ return u(
1765
+ this.persistenceManager,
1766
+ this,
1767
+ "internal-error"
1768
+ /* AuthErrorCode.INTERNAL_ERROR */
1769
+ ), this.persistenceManager;
1770
+ }
1771
+ _logFramework(e) {
1772
+ !e || this.frameworks.includes(e) || (this.frameworks.push(e), this.frameworks.sort(), this.clientVersion = vt(this.config.clientPlatform, this._getFrameworks()));
1773
+ }
1774
+ _getFrameworks() {
1775
+ return this.frameworks;
1776
+ }
1777
+ async _getAdditionalHeaders() {
1778
+ var e;
1779
+ const t = {
1780
+ "X-Client-Version": this.clientVersion
1781
+ };
1782
+ this.app.options.appId && (t[
1783
+ "X-Firebase-gmpid"
1784
+ /* HttpHeader.X_FIREBASE_GMPID */
1785
+ ] = this.app.options.appId);
1786
+ const i = await ((e = this.heartbeatServiceProvider.getImmediate({
1787
+ optional: !0
1788
+ })) === null || e === void 0 ? void 0 : e.getHeartbeatsHeader());
1789
+ i && (t[
1790
+ "X-Firebase-Client"
1791
+ /* HttpHeader.X_FIREBASE_CLIENT */
1792
+ ] = i);
1793
+ const r = await this._getAppCheckToken();
1794
+ return r && (t[
1795
+ "X-Firebase-AppCheck"
1796
+ /* HttpHeader.X_FIREBASE_APP_CHECK */
1797
+ ] = r), t;
1798
+ }
1799
+ async _getAppCheckToken() {
1800
+ var e;
1801
+ const t = await ((e = this.appCheckServiceProvider.getImmediate({ optional: !0 })) === null || e === void 0 ? void 0 : e.getToken());
1802
+ return t != null && t.error && _n(`Error while retrieving App Check token: ${t.error}`), t == null ? void 0 : t.token;
1803
+ }
1804
+ }
1805
+ function H(n) {
1806
+ return O(n);
1807
+ }
1808
+ class xe {
1809
+ constructor(e) {
1810
+ this.auth = e, this.observer = null, this.addObserver = Zt((t) => this.observer = t);
1811
+ }
1812
+ get next() {
1813
+ return u(
1814
+ this.observer,
1815
+ this.auth,
1816
+ "internal-error"
1817
+ /* AuthErrorCode.INTERNAL_ERROR */
1818
+ ), this.observer.next.bind(this.observer);
1819
+ }
1820
+ }
1821
+ /**
1822
+ * @license
1823
+ * Copyright 2020 Google LLC
1824
+ *
1825
+ * Licensed under the Apache License, Version 2.0 (the "License");
1826
+ * you may not use this file except in compliance with the License.
1827
+ * You may obtain a copy of the License at
1828
+ *
1829
+ * http://www.apache.org/licenses/LICENSE-2.0
1830
+ *
1831
+ * Unless required by applicable law or agreed to in writing, software
1832
+ * distributed under the License is distributed on an "AS IS" BASIS,
1833
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1834
+ * See the License for the specific language governing permissions and
1835
+ * limitations under the License.
1836
+ */
1837
+ function qn(n, e) {
1838
+ const t = tt(n, "auth");
1839
+ if (t.isInitialized()) {
1840
+ const r = t.getImmediate(), s = t.getOptions();
1841
+ if (nn(s, e ?? {}))
1842
+ return r;
1843
+ I(
1844
+ r,
1845
+ "already-initialized"
1846
+ /* AuthErrorCode.ALREADY_INITIALIZED */
1847
+ );
1848
+ }
1849
+ return t.initialize({ options: e });
1850
+ }
1851
+ function Gn(n, e) {
1852
+ const t = (e == null ? void 0 : e.persistence) || [], i = (Array.isArray(t) ? t : [t]).map(v);
1853
+ e != null && e.errorMap && n._updateErrorMap(e.errorMap), n._initializeWithPersistence(i, e == null ? void 0 : e.popupRedirectResolver);
1854
+ }
1855
+ function zn(n, e, t) {
1856
+ const i = H(n);
1857
+ u(
1858
+ i._canInitEmulator,
1859
+ i,
1860
+ "emulator-config-failed"
1861
+ /* AuthErrorCode.EMULATOR_CONFIG_FAILED */
1862
+ ), u(
1863
+ /^https?:\/\//.test(e),
1864
+ i,
1865
+ "invalid-emulator-scheme"
1866
+ /* AuthErrorCode.INVALID_EMULATOR_SCHEME */
1867
+ );
1868
+ const r = !!(t != null && t.disableWarnings), s = wt(e), { host: o, port: c } = Jn(e), a = c === null ? "" : `:${c}`;
1869
+ i.config.emulator = { url: `${s}//${o}${a}/` }, i.settings.appVerificationDisabledForTesting = !0, i.emulatorConfig = Object.freeze({
1870
+ host: o,
1871
+ port: c,
1872
+ protocol: s.replace(":", ""),
1873
+ options: Object.freeze({ disableWarnings: r })
1874
+ }), r || Yn();
1875
+ }
1876
+ function wt(n) {
1877
+ const e = n.indexOf(":");
1878
+ return e < 0 ? "" : n.substr(0, e + 1);
1879
+ }
1880
+ function Jn(n) {
1881
+ const e = wt(n), t = /(\/\/)?([^?#/]+)/.exec(n.substr(e.length));
1882
+ if (!t)
1883
+ return { host: "", port: null };
1884
+ const i = t[2].split("@").pop() || "", r = /^(\[[^\]]+\])(:|$)/.exec(i);
1885
+ if (r) {
1886
+ const s = r[1];
1887
+ return { host: s, port: Ve(i.substr(s.length + 1)) };
1888
+ } else {
1889
+ const [s, o] = i.split(":");
1890
+ return { host: s, port: Ve(o) };
1891
+ }
1892
+ }
1893
+ function Ve(n) {
1894
+ if (!n)
1895
+ return null;
1896
+ const e = Number(n);
1897
+ return isNaN(e) ? null : e;
1898
+ }
1899
+ function Yn() {
1900
+ function n() {
1901
+ const e = document.createElement("p"), t = e.style;
1902
+ e.innerText = "Running in emulator mode. Do not use with production credentials.", t.position = "fixed", t.width = "100%", t.backgroundColor = "#ffffff", t.border = ".1em solid #000000", t.color = "#b50000", t.bottom = "0px", t.left = "0px", t.margin = "0px", t.zIndex = "10000", t.textAlign = "center", e.classList.add("firebase-emulator-warning"), document.body.appendChild(e);
1903
+ }
1904
+ typeof console < "u" && typeof console.info == "function" && console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."), typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", n) : n());
1905
+ }
1906
+ /**
1907
+ * @license
1908
+ * Copyright 2020 Google LLC
1909
+ *
1910
+ * Licensed under the Apache License, Version 2.0 (the "License");
1911
+ * you may not use this file except in compliance with the License.
1912
+ * You may obtain a copy of the License at
1913
+ *
1914
+ * http://www.apache.org/licenses/LICENSE-2.0
1915
+ *
1916
+ * Unless required by applicable law or agreed to in writing, software
1917
+ * distributed under the License is distributed on an "AS IS" BASIS,
1918
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1919
+ * See the License for the specific language governing permissions and
1920
+ * limitations under the License.
1921
+ */
1922
+ class Et {
1923
+ /** @internal */
1924
+ constructor(e, t) {
1925
+ this.providerId = e, this.signInMethod = t;
1926
+ }
1927
+ /**
1928
+ * Returns a JSON-serializable representation of this object.
1929
+ *
1930
+ * @returns a JSON-serializable representation of this object.
1931
+ */
1932
+ toJSON() {
1933
+ return _("not implemented");
1934
+ }
1935
+ /** @internal */
1936
+ _getIdTokenResponse(e) {
1937
+ return _("not implemented");
1938
+ }
1939
+ /** @internal */
1940
+ _linkToIdToken(e, t) {
1941
+ return _("not implemented");
1942
+ }
1943
+ /** @internal */
1944
+ _getReauthenticationResolver(e) {
1945
+ return _("not implemented");
1946
+ }
1947
+ }
1948
+ /**
1949
+ * @license
1950
+ * Copyright 2020 Google LLC
1951
+ *
1952
+ * Licensed under the Apache License, Version 2.0 (the "License");
1953
+ * you may not use this file except in compliance with the License.
1954
+ * You may obtain a copy of the License at
1955
+ *
1956
+ * http://www.apache.org/licenses/LICENSE-2.0
1957
+ *
1958
+ * Unless required by applicable law or agreed to in writing, software
1959
+ * distributed under the License is distributed on an "AS IS" BASIS,
1960
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1961
+ * See the License for the specific language governing permissions and
1962
+ * limitations under the License.
1963
+ */
1964
+ async function N(n, e) {
1965
+ return at(n, "POST", "/v1/accounts:signInWithIdp", Ie(n, e));
1966
+ }
1967
+ /**
1968
+ * @license
1969
+ * Copyright 2020 Google LLC
1970
+ *
1971
+ * Licensed under the Apache License, Version 2.0 (the "License");
1972
+ * you may not use this file except in compliance with the License.
1973
+ * You may obtain a copy of the License at
1974
+ *
1975
+ * http://www.apache.org/licenses/LICENSE-2.0
1976
+ *
1977
+ * Unless required by applicable law or agreed to in writing, software
1978
+ * distributed under the License is distributed on an "AS IS" BASIS,
1979
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1980
+ * See the License for the specific language governing permissions and
1981
+ * limitations under the License.
1982
+ */
1983
+ const Xn = "http://localhost";
1984
+ class S extends Et {
1985
+ constructor() {
1986
+ super(...arguments), this.pendingToken = null;
1987
+ }
1988
+ /** @internal */
1989
+ static _fromParams(e) {
1990
+ const t = new S(e.providerId, e.signInMethod);
1991
+ return e.idToken || e.accessToken ? (e.idToken && (t.idToken = e.idToken), e.accessToken && (t.accessToken = e.accessToken), e.nonce && !e.pendingToken && (t.nonce = e.nonce), e.pendingToken && (t.pendingToken = e.pendingToken)) : e.oauthToken && e.oauthTokenSecret ? (t.accessToken = e.oauthToken, t.secret = e.oauthTokenSecret) : I(
1992
+ "argument-error"
1993
+ /* AuthErrorCode.ARGUMENT_ERROR */
1994
+ ), t;
1995
+ }
1996
+ /** {@inheritdoc AuthCredential.toJSON} */
1997
+ toJSON() {
1998
+ return {
1999
+ idToken: this.idToken,
2000
+ accessToken: this.accessToken,
2001
+ secret: this.secret,
2002
+ nonce: this.nonce,
2003
+ pendingToken: this.pendingToken,
2004
+ providerId: this.providerId,
2005
+ signInMethod: this.signInMethod
2006
+ };
2007
+ }
2008
+ /**
2009
+ * Static method to deserialize a JSON representation of an object into an
2010
+ * {@link AuthCredential}.
2011
+ *
2012
+ * @param json - Input can be either Object or the stringified representation of the object.
2013
+ * When string is provided, JSON.parse would be called first.
2014
+ *
2015
+ * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
2016
+ */
2017
+ static fromJSON(e) {
2018
+ const t = typeof e == "string" ? JSON.parse(e) : e, { providerId: i, signInMethod: r } = t, s = me(t, ["providerId", "signInMethod"]);
2019
+ if (!i || !r)
2020
+ return null;
2021
+ const o = new S(i, r);
2022
+ return o.idToken = s.idToken || void 0, o.accessToken = s.accessToken || void 0, o.secret = s.secret, o.nonce = s.nonce, o.pendingToken = s.pendingToken || null, o;
2023
+ }
2024
+ /** @internal */
2025
+ _getIdTokenResponse(e) {
2026
+ const t = this.buildRequest();
2027
+ return N(e, t);
2028
+ }
2029
+ /** @internal */
2030
+ _linkToIdToken(e, t) {
2031
+ const i = this.buildRequest();
2032
+ return i.idToken = t, N(e, i);
2033
+ }
2034
+ /** @internal */
2035
+ _getReauthenticationResolver(e) {
2036
+ const t = this.buildRequest();
2037
+ return t.autoCreate = !1, N(e, t);
2038
+ }
2039
+ buildRequest() {
2040
+ const e = {
2041
+ requestUri: Xn,
2042
+ returnSecureToken: !0
2043
+ };
2044
+ if (this.pendingToken)
2045
+ e.pendingToken = this.pendingToken;
2046
+ else {
2047
+ const t = {};
2048
+ this.idToken && (t.id_token = this.idToken), this.accessToken && (t.access_token = this.accessToken), this.secret && (t.oauth_token_secret = this.secret), t.providerId = this.providerId, this.nonce && !this.pendingToken && (t.nonce = this.nonce), e.postBody = x(t);
2049
+ }
2050
+ return e;
2051
+ }
2052
+ }
2053
+ /**
2054
+ * @license
2055
+ * Copyright 2020 Google LLC
2056
+ *
2057
+ * Licensed under the Apache License, Version 2.0 (the "License");
2058
+ * you may not use this file except in compliance with the License.
2059
+ * You may obtain a copy of the License at
2060
+ *
2061
+ * http://www.apache.org/licenses/LICENSE-2.0
2062
+ *
2063
+ * Unless required by applicable law or agreed to in writing, software
2064
+ * distributed under the License is distributed on an "AS IS" BASIS,
2065
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2066
+ * See the License for the specific language governing permissions and
2067
+ * limitations under the License.
2068
+ */
2069
+ class kt {
2070
+ /**
2071
+ * Constructor for generic OAuth providers.
2072
+ *
2073
+ * @param providerId - Provider for which credentials should be generated.
2074
+ */
2075
+ constructor(e) {
2076
+ this.providerId = e, this.defaultLanguageCode = null, this.customParameters = {};
2077
+ }
2078
+ /**
2079
+ * Set the language gode.
2080
+ *
2081
+ * @param languageCode - language code
2082
+ */
2083
+ setDefaultLanguage(e) {
2084
+ this.defaultLanguageCode = e;
2085
+ }
2086
+ /**
2087
+ * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
2088
+ * operations.
2089
+ *
2090
+ * @remarks
2091
+ * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
2092
+ * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
2093
+ *
2094
+ * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
2095
+ */
2096
+ setCustomParameters(e) {
2097
+ return this.customParameters = e, this;
2098
+ }
2099
+ /**
2100
+ * Retrieve the current list of {@link CustomParameters}.
2101
+ */
2102
+ getCustomParameters() {
2103
+ return this.customParameters;
2104
+ }
2105
+ }
2106
+ /**
2107
+ * @license
2108
+ * Copyright 2019 Google LLC
2109
+ *
2110
+ * Licensed under the Apache License, Version 2.0 (the "License");
2111
+ * you may not use this file except in compliance with the License.
2112
+ * You may obtain a copy of the License at
2113
+ *
2114
+ * http://www.apache.org/licenses/LICENSE-2.0
2115
+ *
2116
+ * Unless required by applicable law or agreed to in writing, software
2117
+ * distributed under the License is distributed on an "AS IS" BASIS,
2118
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2119
+ * See the License for the specific language governing permissions and
2120
+ * limitations under the License.
2121
+ */
2122
+ class $ extends kt {
2123
+ constructor() {
2124
+ super(...arguments), this.scopes = [];
2125
+ }
2126
+ /**
2127
+ * Add an OAuth scope to the credential.
2128
+ *
2129
+ * @param scope - Provider OAuth scope to add.
2130
+ */
2131
+ addScope(e) {
2132
+ return this.scopes.includes(e) || this.scopes.push(e), this;
2133
+ }
2134
+ /**
2135
+ * Retrieve the current list of OAuth scopes.
2136
+ */
2137
+ getScopes() {
2138
+ return [...this.scopes];
2139
+ }
2140
+ }
2141
+ /**
2142
+ * @license
2143
+ * Copyright 2020 Google LLC
2144
+ *
2145
+ * Licensed under the Apache License, Version 2.0 (the "License");
2146
+ * you may not use this file except in compliance with the License.
2147
+ * You may obtain a copy of the License at
2148
+ *
2149
+ * http://www.apache.org/licenses/LICENSE-2.0
2150
+ *
2151
+ * Unless required by applicable law or agreed to in writing, software
2152
+ * distributed under the License is distributed on an "AS IS" BASIS,
2153
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2154
+ * See the License for the specific language governing permissions and
2155
+ * limitations under the License.
2156
+ */
2157
+ class w extends $ {
2158
+ constructor() {
2159
+ super(
2160
+ "facebook.com"
2161
+ /* ProviderId.FACEBOOK */
2162
+ );
2163
+ }
2164
+ /**
2165
+ * Creates a credential for Facebook.
2166
+ *
2167
+ * @example
2168
+ * ```javascript
2169
+ * // `event` from the Facebook auth.authResponseChange callback.
2170
+ * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
2171
+ * const result = await signInWithCredential(credential);
2172
+ * ```
2173
+ *
2174
+ * @param accessToken - Facebook access token.
2175
+ */
2176
+ static credential(e) {
2177
+ return S._fromParams({
2178
+ providerId: w.PROVIDER_ID,
2179
+ signInMethod: w.FACEBOOK_SIGN_IN_METHOD,
2180
+ accessToken: e
2181
+ });
2182
+ }
2183
+ /**
2184
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2185
+ *
2186
+ * @param userCredential - The user credential.
2187
+ */
2188
+ static credentialFromResult(e) {
2189
+ return w.credentialFromTaggedObject(e);
2190
+ }
2191
+ /**
2192
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2193
+ * thrown during a sign-in, link, or reauthenticate operation.
2194
+ *
2195
+ * @param userCredential - The user credential.
2196
+ */
2197
+ static credentialFromError(e) {
2198
+ return w.credentialFromTaggedObject(e.customData || {});
2199
+ }
2200
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2201
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2202
+ return null;
2203
+ try {
2204
+ return w.credential(e.oauthAccessToken);
2205
+ } catch {
2206
+ return null;
2207
+ }
2208
+ }
2209
+ }
2210
+ w.FACEBOOK_SIGN_IN_METHOD = "facebook.com";
2211
+ w.PROVIDER_ID = "facebook.com";
2212
+ /**
2213
+ * @license
2214
+ * Copyright 2020 Google LLC
2215
+ *
2216
+ * Licensed under the Apache License, Version 2.0 (the "License");
2217
+ * you may not use this file except in compliance with the License.
2218
+ * You may obtain a copy of the License at
2219
+ *
2220
+ * http://www.apache.org/licenses/LICENSE-2.0
2221
+ *
2222
+ * Unless required by applicable law or agreed to in writing, software
2223
+ * distributed under the License is distributed on an "AS IS" BASIS,
2224
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2225
+ * See the License for the specific language governing permissions and
2226
+ * limitations under the License.
2227
+ */
2228
+ class E extends $ {
2229
+ constructor() {
2230
+ super(
2231
+ "google.com"
2232
+ /* ProviderId.GOOGLE */
2233
+ ), this.addScope("profile");
2234
+ }
2235
+ /**
2236
+ * Creates a credential for Google. At least one of ID token and access token is required.
2237
+ *
2238
+ * @example
2239
+ * ```javascript
2240
+ * // \`googleUser\` from the onsuccess Google Sign In callback.
2241
+ * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
2242
+ * const result = await signInWithCredential(credential);
2243
+ * ```
2244
+ *
2245
+ * @param idToken - Google ID token.
2246
+ * @param accessToken - Google access token.
2247
+ */
2248
+ static credential(e, t) {
2249
+ return S._fromParams({
2250
+ providerId: E.PROVIDER_ID,
2251
+ signInMethod: E.GOOGLE_SIGN_IN_METHOD,
2252
+ idToken: e,
2253
+ accessToken: t
2254
+ });
2255
+ }
2256
+ /**
2257
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2258
+ *
2259
+ * @param userCredential - The user credential.
2260
+ */
2261
+ static credentialFromResult(e) {
2262
+ return E.credentialFromTaggedObject(e);
2263
+ }
2264
+ /**
2265
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2266
+ * thrown during a sign-in, link, or reauthenticate operation.
2267
+ *
2268
+ * @param userCredential - The user credential.
2269
+ */
2270
+ static credentialFromError(e) {
2271
+ return E.credentialFromTaggedObject(e.customData || {});
2272
+ }
2273
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2274
+ if (!e)
2275
+ return null;
2276
+ const { oauthIdToken: t, oauthAccessToken: i } = e;
2277
+ if (!t && !i)
2278
+ return null;
2279
+ try {
2280
+ return E.credential(t, i);
2281
+ } catch {
2282
+ return null;
2283
+ }
2284
+ }
2285
+ }
2286
+ E.GOOGLE_SIGN_IN_METHOD = "google.com";
2287
+ E.PROVIDER_ID = "google.com";
2288
+ /**
2289
+ * @license
2290
+ * Copyright 2020 Google LLC
2291
+ *
2292
+ * Licensed under the Apache License, Version 2.0 (the "License");
2293
+ * you may not use this file except in compliance with the License.
2294
+ * You may obtain a copy of the License at
2295
+ *
2296
+ * http://www.apache.org/licenses/LICENSE-2.0
2297
+ *
2298
+ * Unless required by applicable law or agreed to in writing, software
2299
+ * distributed under the License is distributed on an "AS IS" BASIS,
2300
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2301
+ * See the License for the specific language governing permissions and
2302
+ * limitations under the License.
2303
+ */
2304
+ class k extends $ {
2305
+ constructor() {
2306
+ super(
2307
+ "github.com"
2308
+ /* ProviderId.GITHUB */
2309
+ );
2310
+ }
2311
+ /**
2312
+ * Creates a credential for Github.
2313
+ *
2314
+ * @param accessToken - Github access token.
2315
+ */
2316
+ static credential(e) {
2317
+ return S._fromParams({
2318
+ providerId: k.PROVIDER_ID,
2319
+ signInMethod: k.GITHUB_SIGN_IN_METHOD,
2320
+ accessToken: e
2321
+ });
2322
+ }
2323
+ /**
2324
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2325
+ *
2326
+ * @param userCredential - The user credential.
2327
+ */
2328
+ static credentialFromResult(e) {
2329
+ return k.credentialFromTaggedObject(e);
2330
+ }
2331
+ /**
2332
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2333
+ * thrown during a sign-in, link, or reauthenticate operation.
2334
+ *
2335
+ * @param userCredential - The user credential.
2336
+ */
2337
+ static credentialFromError(e) {
2338
+ return k.credentialFromTaggedObject(e.customData || {});
2339
+ }
2340
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2341
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2342
+ return null;
2343
+ try {
2344
+ return k.credential(e.oauthAccessToken);
2345
+ } catch {
2346
+ return null;
2347
+ }
2348
+ }
2349
+ }
2350
+ k.GITHUB_SIGN_IN_METHOD = "github.com";
2351
+ k.PROVIDER_ID = "github.com";
2352
+ /**
2353
+ * @license
2354
+ * Copyright 2020 Google LLC
2355
+ *
2356
+ * Licensed under the Apache License, Version 2.0 (the "License");
2357
+ * you may not use this file except in compliance with the License.
2358
+ * You may obtain a copy of the License at
2359
+ *
2360
+ * http://www.apache.org/licenses/LICENSE-2.0
2361
+ *
2362
+ * Unless required by applicable law or agreed to in writing, software
2363
+ * distributed under the License is distributed on an "AS IS" BASIS,
2364
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2365
+ * See the License for the specific language governing permissions and
2366
+ * limitations under the License.
2367
+ */
2368
+ class R extends $ {
2369
+ constructor() {
2370
+ super(
2371
+ "twitter.com"
2372
+ /* ProviderId.TWITTER */
2373
+ );
2374
+ }
2375
+ /**
2376
+ * Creates a credential for Twitter.
2377
+ *
2378
+ * @param token - Twitter access token.
2379
+ * @param secret - Twitter secret.
2380
+ */
2381
+ static credential(e, t) {
2382
+ return S._fromParams({
2383
+ providerId: R.PROVIDER_ID,
2384
+ signInMethod: R.TWITTER_SIGN_IN_METHOD,
2385
+ oauthToken: e,
2386
+ oauthTokenSecret: t
2387
+ });
2388
+ }
2389
+ /**
2390
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2391
+ *
2392
+ * @param userCredential - The user credential.
2393
+ */
2394
+ static credentialFromResult(e) {
2395
+ return R.credentialFromTaggedObject(e);
2396
+ }
2397
+ /**
2398
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2399
+ * thrown during a sign-in, link, or reauthenticate operation.
2400
+ *
2401
+ * @param userCredential - The user credential.
2402
+ */
2403
+ static credentialFromError(e) {
2404
+ return R.credentialFromTaggedObject(e.customData || {});
2405
+ }
2406
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2407
+ if (!e)
2408
+ return null;
2409
+ const { oauthAccessToken: t, oauthTokenSecret: i } = e;
2410
+ if (!t || !i)
2411
+ return null;
2412
+ try {
2413
+ return R.credential(t, i);
2414
+ } catch {
2415
+ return null;
2416
+ }
2417
+ }
2418
+ }
2419
+ R.TWITTER_SIGN_IN_METHOD = "twitter.com";
2420
+ R.PROVIDER_ID = "twitter.com";
2421
+ /**
2422
+ * @license
2423
+ * Copyright 2020 Google LLC
2424
+ *
2425
+ * Licensed under the Apache License, Version 2.0 (the "License");
2426
+ * you may not use this file except in compliance with the License.
2427
+ * You may obtain a copy of the License at
2428
+ *
2429
+ * http://www.apache.org/licenses/LICENSE-2.0
2430
+ *
2431
+ * Unless required by applicable law or agreed to in writing, software
2432
+ * distributed under the License is distributed on an "AS IS" BASIS,
2433
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2434
+ * See the License for the specific language governing permissions and
2435
+ * limitations under the License.
2436
+ */
2437
+ class A {
2438
+ constructor(e) {
2439
+ this.user = e.user, this.providerId = e.providerId, this._tokenResponse = e._tokenResponse, this.operationType = e.operationType;
2440
+ }
2441
+ static async _fromIdTokenResponse(e, t, i, r = !1) {
2442
+ const s = await b._fromIdTokenResponse(e, i, r), o = We(i);
2443
+ return new A({
2444
+ user: s,
2445
+ providerId: o,
2446
+ _tokenResponse: i,
2447
+ operationType: t
2448
+ });
2449
+ }
2450
+ static async _forOperation(e, t, i) {
2451
+ await e._updateTokensIfNecessary(
2452
+ i,
2453
+ /* reload */
2454
+ !0
2455
+ );
2456
+ const r = We(i);
2457
+ return new A({
2458
+ user: e,
2459
+ providerId: r,
2460
+ _tokenResponse: i,
2461
+ operationType: t
2462
+ });
2463
+ }
2464
+ }
2465
+ function We(n) {
2466
+ return n.providerId ? n.providerId : "phoneNumber" in n ? "phone" : null;
2467
+ }
2468
+ /**
2469
+ * @license
2470
+ * Copyright 2020 Google LLC
2471
+ *
2472
+ * Licensed under the Apache License, Version 2.0 (the "License");
2473
+ * you may not use this file except in compliance with the License.
2474
+ * You may obtain a copy of the License at
2475
+ *
2476
+ * http://www.apache.org/licenses/LICENSE-2.0
2477
+ *
2478
+ * Unless required by applicable law or agreed to in writing, software
2479
+ * distributed under the License is distributed on an "AS IS" BASIS,
2480
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2481
+ * See the License for the specific language governing permissions and
2482
+ * limitations under the License.
2483
+ */
2484
+ class Z extends ge {
2485
+ constructor(e, t, i, r) {
2486
+ var s;
2487
+ super(t.code, t.message), this.operationType = i, this.user = r, Object.setPrototypeOf(this, Z.prototype), this.customData = {
2488
+ appName: e.name,
2489
+ tenantId: (s = e.tenantId) !== null && s !== void 0 ? s : void 0,
2490
+ _serverResponse: t.customData._serverResponse,
2491
+ operationType: i
2492
+ };
2493
+ }
2494
+ static _fromErrorAndOperation(e, t, i, r) {
2495
+ return new Z(e, t, i, r);
2496
+ }
2497
+ }
2498
+ function Rt(n, e, t, i) {
2499
+ return (e === "reauthenticate" ? t._getReauthenticationResolver(n) : t._getIdTokenResponse(n)).catch((s) => {
2500
+ throw s.code === "auth/multi-factor-auth-required" ? Z._fromErrorAndOperation(n, s, e, i) : s;
2501
+ });
2502
+ }
2503
+ async function Qn(n, e, t = !1) {
2504
+ const i = await U(n, e._linkToIdToken(n.auth, await n.getIdToken()), t);
2505
+ return A._forOperation(n, "link", i);
2506
+ }
2507
+ /**
2508
+ * @license
2509
+ * Copyright 2019 Google LLC
2510
+ *
2511
+ * Licensed under the Apache License, Version 2.0 (the "License");
2512
+ * you may not use this file except in compliance with the License.
2513
+ * You may obtain a copy of the License at
2514
+ *
2515
+ * http://www.apache.org/licenses/LICENSE-2.0
2516
+ *
2517
+ * Unless required by applicable law or agreed to in writing, software
2518
+ * distributed under the License is distributed on an "AS IS" BASIS,
2519
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2520
+ * See the License for the specific language governing permissions and
2521
+ * limitations under the License.
2522
+ */
2523
+ async function Zn(n, e, t = !1) {
2524
+ const { auth: i } = n, r = "reauthenticate";
2525
+ try {
2526
+ const s = await U(n, Rt(i, r, e, n), t);
2527
+ u(
2528
+ s.idToken,
2529
+ i,
2530
+ "internal-error"
2531
+ /* AuthErrorCode.INTERNAL_ERROR */
2532
+ );
2533
+ const o = ye(s.idToken);
2534
+ u(
2535
+ o,
2536
+ i,
2537
+ "internal-error"
2538
+ /* AuthErrorCode.INTERNAL_ERROR */
2539
+ );
2540
+ const { sub: c } = o;
2541
+ return u(
2542
+ n.uid === c,
2543
+ i,
2544
+ "user-mismatch"
2545
+ /* AuthErrorCode.USER_MISMATCH */
2546
+ ), A._forOperation(n, r, s);
2547
+ } catch (s) {
2548
+ throw (s == null ? void 0 : s.code) === "auth/user-not-found" && I(
2549
+ i,
2550
+ "user-mismatch"
2551
+ /* AuthErrorCode.USER_MISMATCH */
2552
+ ), s;
2553
+ }
2554
+ }
2555
+ /**
2556
+ * @license
2557
+ * Copyright 2020 Google LLC
2558
+ *
2559
+ * Licensed under the Apache License, Version 2.0 (the "License");
2560
+ * you may not use this file except in compliance with the License.
2561
+ * You may obtain a copy of the License at
2562
+ *
2563
+ * http://www.apache.org/licenses/LICENSE-2.0
2564
+ *
2565
+ * Unless required by applicable law or agreed to in writing, software
2566
+ * distributed under the License is distributed on an "AS IS" BASIS,
2567
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2568
+ * See the License for the specific language governing permissions and
2569
+ * limitations under the License.
2570
+ */
2571
+ async function ei(n, e, t = !1) {
2572
+ const i = "signIn", r = await Rt(n, i, e), s = await A._fromIdTokenResponse(n, i, r);
2573
+ return t || await n._updateCurrentUser(s.user), s;
2574
+ }
2575
+ /**
2576
+ * @license
2577
+ * Copyright 2020 Google LLC
2578
+ *
2579
+ * Licensed under the Apache License, Version 2.0 (the "License");
2580
+ * you may not use this file except in compliance with the License.
2581
+ * You may obtain a copy of the License at
2582
+ *
2583
+ * http://www.apache.org/licenses/LICENSE-2.0
2584
+ *
2585
+ * Unless required by applicable law or agreed to in writing, software
2586
+ * distributed under the License is distributed on an "AS IS" BASIS,
2587
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2588
+ * See the License for the specific language governing permissions and
2589
+ * limitations under the License.
2590
+ */
2591
+ async function ti(n, e) {
2592
+ return at(n, "POST", "/v1/accounts:signInWithCustomToken", Ie(n, e));
2593
+ }
2594
+ /**
2595
+ * @license
2596
+ * Copyright 2020 Google LLC
2597
+ *
2598
+ * Licensed under the Apache License, Version 2.0 (the "License");
2599
+ * you may not use this file except in compliance with the License.
2600
+ * You may obtain a copy of the License at
2601
+ *
2602
+ * http://www.apache.org/licenses/LICENSE-2.0
2603
+ *
2604
+ * Unless required by applicable law or agreed to in writing, software
2605
+ * distributed under the License is distributed on an "AS IS" BASIS,
2606
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2607
+ * See the License for the specific language governing permissions and
2608
+ * limitations under the License.
2609
+ */
2610
+ async function ni(n, e) {
2611
+ const t = H(n), i = await ti(t, {
2612
+ token: e,
2613
+ returnSecureToken: !0
2614
+ }), r = await A._fromIdTokenResponse(t, "signIn", i);
2615
+ return await t._updateCurrentUser(r.user), r;
2616
+ }
2617
+ function ii(n, e, t, i) {
2618
+ return O(n).onIdTokenChanged(e, t, i);
2619
+ }
2620
+ function ri(n, e, t) {
2621
+ return O(n).beforeAuthStateChanged(e, t);
2622
+ }
2623
+ const ee = "__sak";
2624
+ /**
2625
+ * @license
2626
+ * Copyright 2019 Google LLC
2627
+ *
2628
+ * Licensed under the Apache License, Version 2.0 (the "License");
2629
+ * you may not use this file except in compliance with the License.
2630
+ * You may obtain a copy of the License at
2631
+ *
2632
+ * http://www.apache.org/licenses/LICENSE-2.0
2633
+ *
2634
+ * Unless required by applicable law or agreed to in writing, software
2635
+ * distributed under the License is distributed on an "AS IS" BASIS,
2636
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2637
+ * See the License for the specific language governing permissions and
2638
+ * limitations under the License.
2639
+ */
2640
+ class bt {
2641
+ constructor(e, t) {
2642
+ this.storageRetriever = e, this.type = t;
2643
+ }
2644
+ _isAvailable() {
2645
+ try {
2646
+ return this.storage ? (this.storage.setItem(ee, "1"), this.storage.removeItem(ee), Promise.resolve(!0)) : Promise.resolve(!1);
2647
+ } catch {
2648
+ return Promise.resolve(!1);
2649
+ }
2650
+ }
2651
+ _set(e, t) {
2652
+ return this.storage.setItem(e, JSON.stringify(t)), Promise.resolve();
2653
+ }
2654
+ _get(e) {
2655
+ const t = this.storage.getItem(e);
2656
+ return Promise.resolve(t ? JSON.parse(t) : null);
2657
+ }
2658
+ _remove(e) {
2659
+ return this.storage.removeItem(e), Promise.resolve();
2660
+ }
2661
+ get storage() {
2662
+ return this.storageRetriever();
2663
+ }
2664
+ }
2665
+ /**
2666
+ * @license
2667
+ * Copyright 2020 Google LLC
2668
+ *
2669
+ * Licensed under the Apache License, Version 2.0 (the "License");
2670
+ * you may not use this file except in compliance with the License.
2671
+ * You may obtain a copy of the License at
2672
+ *
2673
+ * http://www.apache.org/licenses/LICENSE-2.0
2674
+ *
2675
+ * Unless required by applicable law or agreed to in writing, software
2676
+ * distributed under the License is distributed on an "AS IS" BASIS,
2677
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2678
+ * See the License for the specific language governing permissions and
2679
+ * limitations under the License.
2680
+ */
2681
+ function si() {
2682
+ const n = f();
2683
+ return Te(n) || ne(n);
2684
+ }
2685
+ const oi = 1e3, ai = 10;
2686
+ class St extends bt {
2687
+ constructor() {
2688
+ super(
2689
+ () => window.localStorage,
2690
+ "LOCAL"
2691
+ /* PersistenceType.LOCAL */
2692
+ ), this.boundEventHandler = (e, t) => this.onStorageEvent(e, t), this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.safariLocalStorageNotSynced = si() && Fn(), this.fallbackToPolling = _t(), this._shouldAllowMigration = !0;
2693
+ }
2694
+ forAllChangedKeys(e) {
2695
+ for (const t of Object.keys(this.listeners)) {
2696
+ const i = this.storage.getItem(t), r = this.localCache[t];
2697
+ i !== r && e(t, r, i);
2698
+ }
2699
+ }
2700
+ onStorageEvent(e, t = !1) {
2701
+ if (!e.key) {
2702
+ this.forAllChangedKeys((o, c, a) => {
2703
+ this.notifyListeners(o, a);
2704
+ });
2705
+ return;
2706
+ }
2707
+ const i = e.key;
2708
+ if (t ? this.detachListener() : this.stopPolling(), this.safariLocalStorageNotSynced) {
2709
+ const o = this.storage.getItem(i);
2710
+ if (e.newValue !== o)
2711
+ e.newValue !== null ? this.storage.setItem(i, e.newValue) : this.storage.removeItem(i);
2712
+ else if (this.localCache[i] === e.newValue && !t)
2713
+ return;
2714
+ }
2715
+ const r = () => {
2716
+ const o = this.storage.getItem(i);
2717
+ !t && this.localCache[i] === o || this.notifyListeners(i, o);
2718
+ }, s = this.storage.getItem(i);
2719
+ Dn() && s !== e.newValue && e.newValue !== e.oldValue ? setTimeout(r, ai) : r();
2720
+ }
2721
+ notifyListeners(e, t) {
2722
+ this.localCache[e] = t;
2723
+ const i = this.listeners[e];
2724
+ if (i)
2725
+ for (const r of Array.from(i))
2726
+ r(t && JSON.parse(t));
2727
+ }
2728
+ startPolling() {
2729
+ this.stopPolling(), this.pollTimer = setInterval(() => {
2730
+ this.forAllChangedKeys((e, t, i) => {
2731
+ this.onStorageEvent(
2732
+ new StorageEvent("storage", {
2733
+ key: e,
2734
+ oldValue: t,
2735
+ newValue: i
2736
+ }),
2737
+ /* poll */
2738
+ !0
2739
+ );
2740
+ });
2741
+ }, oi);
2742
+ }
2743
+ stopPolling() {
2744
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
2745
+ }
2746
+ attachListener() {
2747
+ window.addEventListener("storage", this.boundEventHandler);
2748
+ }
2749
+ detachListener() {
2750
+ window.removeEventListener("storage", this.boundEventHandler);
2751
+ }
2752
+ _addListener(e, t) {
2753
+ Object.keys(this.listeners).length === 0 && (this.fallbackToPolling ? this.startPolling() : this.attachListener()), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this.localCache[e] = this.storage.getItem(e)), this.listeners[e].add(t);
2754
+ }
2755
+ _removeListener(e, t) {
2756
+ this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && (this.detachListener(), this.stopPolling());
2757
+ }
2758
+ // Update local cache on base operations:
2759
+ async _set(e, t) {
2760
+ await super._set(e, t), this.localCache[e] = JSON.stringify(t);
2761
+ }
2762
+ async _get(e) {
2763
+ const t = await super._get(e);
2764
+ return this.localCache[e] = JSON.stringify(t), t;
2765
+ }
2766
+ async _remove(e) {
2767
+ await super._remove(e), delete this.localCache[e];
2768
+ }
2769
+ }
2770
+ St.type = "LOCAL";
2771
+ const ci = St;
2772
+ /**
2773
+ * @license
2774
+ * Copyright 2020 Google LLC
2775
+ *
2776
+ * Licensed under the Apache License, Version 2.0 (the "License");
2777
+ * you may not use this file except in compliance with the License.
2778
+ * You may obtain a copy of the License at
2779
+ *
2780
+ * http://www.apache.org/licenses/LICENSE-2.0
2781
+ *
2782
+ * Unless required by applicable law or agreed to in writing, software
2783
+ * distributed under the License is distributed on an "AS IS" BASIS,
2784
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2785
+ * See the License for the specific language governing permissions and
2786
+ * limitations under the License.
2787
+ */
2788
+ class At extends bt {
2789
+ constructor() {
2790
+ super(
2791
+ () => window.sessionStorage,
2792
+ "SESSION"
2793
+ /* PersistenceType.SESSION */
2794
+ );
2795
+ }
2796
+ _addListener(e, t) {
2797
+ }
2798
+ _removeListener(e, t) {
2799
+ }
2800
+ }
2801
+ At.type = "SESSION";
2802
+ const Ct = At;
2803
+ /**
2804
+ * @license
2805
+ * Copyright 2019 Google LLC
2806
+ *
2807
+ * Licensed under the Apache License, Version 2.0 (the "License");
2808
+ * you may not use this file except in compliance with the License.
2809
+ * You may obtain a copy of the License at
2810
+ *
2811
+ * http://www.apache.org/licenses/LICENSE-2.0
2812
+ *
2813
+ * Unless required by applicable law or agreed to in writing, software
2814
+ * distributed under the License is distributed on an "AS IS" BASIS,
2815
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2816
+ * See the License for the specific language governing permissions and
2817
+ * limitations under the License.
2818
+ */
2819
+ function li(n) {
2820
+ return Promise.all(n.map(async (e) => {
2821
+ try {
2822
+ return {
2823
+ fulfilled: !0,
2824
+ value: await e
2825
+ };
2826
+ } catch (t) {
2827
+ return {
2828
+ fulfilled: !1,
2829
+ reason: t
2830
+ };
2831
+ }
2832
+ }));
2833
+ }
2834
+ /**
2835
+ * @license
2836
+ * Copyright 2019 Google LLC
2837
+ *
2838
+ * Licensed under the Apache License, Version 2.0 (the "License");
2839
+ * you may not use this file except in compliance with the License.
2840
+ * You may obtain a copy of the License at
2841
+ *
2842
+ * http://www.apache.org/licenses/LICENSE-2.0
2843
+ *
2844
+ * Unless required by applicable law or agreed to in writing, software
2845
+ * distributed under the License is distributed on an "AS IS" BASIS,
2846
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2847
+ * See the License for the specific language governing permissions and
2848
+ * limitations under the License.
2849
+ */
2850
+ class ie {
2851
+ constructor(e) {
2852
+ this.eventTarget = e, this.handlersMap = {}, this.boundEventHandler = this.handleEvent.bind(this);
2853
+ }
2854
+ /**
2855
+ * Obtain an instance of a Receiver for a given event target, if none exists it will be created.
2856
+ *
2857
+ * @param eventTarget - An event target (such as window or self) through which the underlying
2858
+ * messages will be received.
2859
+ */
2860
+ static _getInstance(e) {
2861
+ const t = this.receivers.find((r) => r.isListeningto(e));
2862
+ if (t)
2863
+ return t;
2864
+ const i = new ie(e);
2865
+ return this.receivers.push(i), i;
2866
+ }
2867
+ isListeningto(e) {
2868
+ return this.eventTarget === e;
2869
+ }
2870
+ /**
2871
+ * Fans out a MessageEvent to the appropriate listeners.
2872
+ *
2873
+ * @remarks
2874
+ * Sends an {@link Status.ACK} upon receipt and a {@link Status.DONE} once all handlers have
2875
+ * finished processing.
2876
+ *
2877
+ * @param event - The MessageEvent.
2878
+ *
2879
+ */
2880
+ async handleEvent(e) {
2881
+ const t = e, { eventId: i, eventType: r, data: s } = t.data, o = this.handlersMap[r];
2882
+ if (!(o != null && o.size))
2883
+ return;
2884
+ t.ports[0].postMessage({
2885
+ status: "ack",
2886
+ eventId: i,
2887
+ eventType: r
2888
+ });
2889
+ const c = Array.from(o).map(async (l) => l(t.origin, s)), a = await li(c);
2890
+ t.ports[0].postMessage({
2891
+ status: "done",
2892
+ eventId: i,
2893
+ eventType: r,
2894
+ response: a
2895
+ });
2896
+ }
2897
+ /**
2898
+ * Subscribe an event handler for a particular event.
2899
+ *
2900
+ * @param eventType - Event name to subscribe to.
2901
+ * @param eventHandler - The event handler which should receive the events.
2902
+ *
2903
+ */
2904
+ _subscribe(e, t) {
2905
+ Object.keys(this.handlersMap).length === 0 && this.eventTarget.addEventListener("message", this.boundEventHandler), this.handlersMap[e] || (this.handlersMap[e] = /* @__PURE__ */ new Set()), this.handlersMap[e].add(t);
2906
+ }
2907
+ /**
2908
+ * Unsubscribe an event handler from a particular event.
2909
+ *
2910
+ * @param eventType - Event name to unsubscribe from.
2911
+ * @param eventHandler - Optinoal event handler, if none provided, unsubscribe all handlers on this event.
2912
+ *
2913
+ */
2914
+ _unsubscribe(e, t) {
2915
+ this.handlersMap[e] && t && this.handlersMap[e].delete(t), (!t || this.handlersMap[e].size === 0) && delete this.handlersMap[e], Object.keys(this.handlersMap).length === 0 && this.eventTarget.removeEventListener("message", this.boundEventHandler);
2916
+ }
2917
+ }
2918
+ ie.receivers = [];
2919
+ /**
2920
+ * @license
2921
+ * Copyright 2020 Google LLC
2922
+ *
2923
+ * Licensed under the Apache License, Version 2.0 (the "License");
2924
+ * you may not use this file except in compliance with the License.
2925
+ * You may obtain a copy of the License at
2926
+ *
2927
+ * http://www.apache.org/licenses/LICENSE-2.0
2928
+ *
2929
+ * Unless required by applicable law or agreed to in writing, software
2930
+ * distributed under the License is distributed on an "AS IS" BASIS,
2931
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2932
+ * See the License for the specific language governing permissions and
2933
+ * limitations under the License.
2934
+ */
2935
+ function we(n = "", e = 10) {
2936
+ let t = "";
2937
+ for (let i = 0; i < e; i++)
2938
+ t += Math.floor(Math.random() * 10);
2939
+ return n + t;
2940
+ }
2941
+ /**
2942
+ * @license
2943
+ * Copyright 2019 Google LLC
2944
+ *
2945
+ * Licensed under the Apache License, Version 2.0 (the "License");
2946
+ * you may not use this file except in compliance with the License.
2947
+ * You may obtain a copy of the License at
2948
+ *
2949
+ * http://www.apache.org/licenses/LICENSE-2.0
2950
+ *
2951
+ * Unless required by applicable law or agreed to in writing, software
2952
+ * distributed under the License is distributed on an "AS IS" BASIS,
2953
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2954
+ * See the License for the specific language governing permissions and
2955
+ * limitations under the License.
2956
+ */
2957
+ class ui {
2958
+ constructor(e) {
2959
+ this.target = e, this.handlers = /* @__PURE__ */ new Set();
2960
+ }
2961
+ /**
2962
+ * Unsubscribe the handler and remove it from our tracking Set.
2963
+ *
2964
+ * @param handler - The handler to unsubscribe.
2965
+ */
2966
+ removeMessageHandler(e) {
2967
+ e.messageChannel && (e.messageChannel.port1.removeEventListener("message", e.onMessage), e.messageChannel.port1.close()), this.handlers.delete(e);
2968
+ }
2969
+ /**
2970
+ * Send a message to the Receiver located at {@link target}.
2971
+ *
2972
+ * @remarks
2973
+ * We'll first wait a bit for an ACK , if we get one we will wait significantly longer until the
2974
+ * receiver has had a chance to fully process the event.
2975
+ *
2976
+ * @param eventType - Type of event to send.
2977
+ * @param data - The payload of the event.
2978
+ * @param timeout - Timeout for waiting on an ACK from the receiver.
2979
+ *
2980
+ * @returns An array of settled promises from all the handlers that were listening on the receiver.
2981
+ */
2982
+ async _send(e, t, i = 50) {
2983
+ const r = typeof MessageChannel < "u" ? new MessageChannel() : null;
2984
+ if (!r)
2985
+ throw new Error(
2986
+ "connection_unavailable"
2987
+ /* _MessageError.CONNECTION_UNAVAILABLE */
2988
+ );
2989
+ let s, o;
2990
+ return new Promise((c, a) => {
2991
+ const l = we("", 20);
2992
+ r.port1.start();
2993
+ const d = setTimeout(() => {
2994
+ a(new Error(
2995
+ "unsupported_event"
2996
+ /* _MessageError.UNSUPPORTED_EVENT */
2997
+ ));
2998
+ }, i);
2999
+ o = {
3000
+ messageChannel: r,
3001
+ onMessage(h) {
3002
+ const p = h;
3003
+ if (p.data.eventId === l)
3004
+ switch (p.data.status) {
3005
+ case "ack":
3006
+ clearTimeout(d), s = setTimeout(
3007
+ () => {
3008
+ a(new Error(
3009
+ "timeout"
3010
+ /* _MessageError.TIMEOUT */
3011
+ ));
3012
+ },
3013
+ 3e3
3014
+ /* _TimeoutDuration.COMPLETION */
3015
+ );
3016
+ break;
3017
+ case "done":
3018
+ clearTimeout(s), c(p.data.response);
3019
+ break;
3020
+ default:
3021
+ clearTimeout(d), clearTimeout(s), a(new Error(
3022
+ "invalid_response"
3023
+ /* _MessageError.INVALID_RESPONSE */
3024
+ ));
3025
+ break;
3026
+ }
3027
+ }
3028
+ }, this.handlers.add(o), r.port1.addEventListener("message", o.onMessage), this.target.postMessage({
3029
+ eventType: e,
3030
+ eventId: l,
3031
+ data: t
3032
+ }, [r.port2]);
3033
+ }).finally(() => {
3034
+ o && this.removeMessageHandler(o);
3035
+ });
3036
+ }
3037
+ }
3038
+ /**
3039
+ * @license
3040
+ * Copyright 2020 Google LLC
3041
+ *
3042
+ * Licensed under the Apache License, Version 2.0 (the "License");
3043
+ * you may not use this file except in compliance with the License.
3044
+ * You may obtain a copy of the License at
3045
+ *
3046
+ * http://www.apache.org/licenses/LICENSE-2.0
3047
+ *
3048
+ * Unless required by applicable law or agreed to in writing, software
3049
+ * distributed under the License is distributed on an "AS IS" BASIS,
3050
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3051
+ * See the License for the specific language governing permissions and
3052
+ * limitations under the License.
3053
+ */
3054
+ function m() {
3055
+ return window;
3056
+ }
3057
+ function di(n) {
3058
+ m().location.href = n;
3059
+ }
3060
+ /**
3061
+ * @license
3062
+ * Copyright 2020 Google LLC.
3063
+ *
3064
+ * Licensed under the Apache License, Version 2.0 (the "License");
3065
+ * you may not use this file except in compliance with the License.
3066
+ * You may obtain a copy of the License at
3067
+ *
3068
+ * http://www.apache.org/licenses/LICENSE-2.0
3069
+ *
3070
+ * Unless required by applicable law or agreed to in writing, software
3071
+ * distributed under the License is distributed on an "AS IS" BASIS,
3072
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3073
+ * See the License for the specific language governing permissions and
3074
+ * limitations under the License.
3075
+ */
3076
+ function Pt() {
3077
+ return typeof m().WorkerGlobalScope < "u" && typeof m().importScripts == "function";
3078
+ }
3079
+ async function hi() {
3080
+ if (!(navigator != null && navigator.serviceWorker))
3081
+ return null;
3082
+ try {
3083
+ return (await navigator.serviceWorker.ready).active;
3084
+ } catch {
3085
+ return null;
3086
+ }
3087
+ }
3088
+ function fi() {
3089
+ var n;
3090
+ return ((n = navigator == null ? void 0 : navigator.serviceWorker) === null || n === void 0 ? void 0 : n.controller) || null;
3091
+ }
3092
+ function pi() {
3093
+ return Pt() ? self : null;
3094
+ }
3095
+ /**
3096
+ * @license
3097
+ * Copyright 2019 Google LLC
3098
+ *
3099
+ * Licensed under the Apache License, Version 2.0 (the "License");
3100
+ * you may not use this file except in compliance with the License.
3101
+ * You may obtain a copy of the License at
3102
+ *
3103
+ * http://www.apache.org/licenses/LICENSE-2.0
3104
+ *
3105
+ * Unless required by applicable law or agreed to in writing, software
3106
+ * distributed under the License is distributed on an "AS IS" BASIS,
3107
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3108
+ * See the License for the specific language governing permissions and
3109
+ * limitations under the License.
3110
+ */
3111
+ const Nt = "firebaseLocalStorageDb", gi = 1, te = "firebaseLocalStorage", Ot = "fbase_key";
3112
+ class j {
3113
+ constructor(e) {
3114
+ this.request = e;
3115
+ }
3116
+ toPromise() {
3117
+ return new Promise((e, t) => {
3118
+ this.request.addEventListener("success", () => {
3119
+ e(this.request.result);
3120
+ }), this.request.addEventListener("error", () => {
3121
+ t(this.request.error);
3122
+ });
3123
+ });
3124
+ }
3125
+ }
3126
+ function re(n, e) {
3127
+ return n.transaction([te], e ? "readwrite" : "readonly").objectStore(te);
3128
+ }
3129
+ function mi() {
3130
+ const n = indexedDB.deleteDatabase(Nt);
3131
+ return new j(n).toPromise();
3132
+ }
3133
+ function fe() {
3134
+ const n = indexedDB.open(Nt, gi);
3135
+ return new Promise((e, t) => {
3136
+ n.addEventListener("error", () => {
3137
+ t(n.error);
3138
+ }), n.addEventListener("upgradeneeded", () => {
3139
+ const i = n.result;
3140
+ try {
3141
+ i.createObjectStore(te, { keyPath: Ot });
3142
+ } catch (r) {
3143
+ t(r);
3144
+ }
3145
+ }), n.addEventListener("success", async () => {
3146
+ const i = n.result;
3147
+ i.objectStoreNames.contains(te) ? e(i) : (i.close(), await mi(), e(await fe()));
3148
+ });
3149
+ });
3150
+ }
3151
+ async function He(n, e, t) {
3152
+ const i = re(n, !0).put({
3153
+ [Ot]: e,
3154
+ value: t
3155
+ });
3156
+ return new j(i).toPromise();
3157
+ }
3158
+ async function _i(n, e) {
3159
+ const t = re(n, !1).get(e), i = await new j(t).toPromise();
3160
+ return i === void 0 ? null : i.value;
3161
+ }
3162
+ function $e(n, e) {
3163
+ const t = re(n, !0).delete(e);
3164
+ return new j(t).toPromise();
3165
+ }
3166
+ const vi = 800, Ii = 3;
3167
+ class Lt {
3168
+ constructor() {
3169
+ this.type = "LOCAL", this._shouldAllowMigration = !0, this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.pendingWrites = 0, this.receiver = null, this.sender = null, this.serviceWorkerReceiverAvailable = !1, this.activeServiceWorker = null, this._workerInitializationPromise = this.initializeServiceWorkerMessaging().then(() => {
3170
+ }, () => {
3171
+ });
3172
+ }
3173
+ async _openDb() {
3174
+ return this.db ? this.db : (this.db = await fe(), this.db);
3175
+ }
3176
+ async _withRetries(e) {
3177
+ let t = 0;
3178
+ for (; ; )
3179
+ try {
3180
+ const i = await this._openDb();
3181
+ return await e(i);
3182
+ } catch (i) {
3183
+ if (t++ > Ii)
3184
+ throw i;
3185
+ this.db && (this.db.close(), this.db = void 0);
3186
+ }
3187
+ }
3188
+ /**
3189
+ * IndexedDB events do not propagate from the main window to the worker context. We rely on a
3190
+ * postMessage interface to send these events to the worker ourselves.
3191
+ */
3192
+ async initializeServiceWorkerMessaging() {
3193
+ return Pt() ? this.initializeReceiver() : this.initializeSender();
3194
+ }
3195
+ /**
3196
+ * As the worker we should listen to events from the main window.
3197
+ */
3198
+ async initializeReceiver() {
3199
+ this.receiver = ie._getInstance(pi()), this.receiver._subscribe("keyChanged", async (e, t) => ({
3200
+ keyProcessed: (await this._poll()).includes(t.key)
3201
+ })), this.receiver._subscribe("ping", async (e, t) => [
3202
+ "keyChanged"
3203
+ /* _EventType.KEY_CHANGED */
3204
+ ]);
3205
+ }
3206
+ /**
3207
+ * As the main window, we should let the worker know when keys change (set and remove).
3208
+ *
3209
+ * @remarks
3210
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/ready | ServiceWorkerContainer.ready}
3211
+ * may not resolve.
3212
+ */
3213
+ async initializeSender() {
3214
+ var e, t;
3215
+ if (this.activeServiceWorker = await hi(), !this.activeServiceWorker)
3216
+ return;
3217
+ this.sender = new ui(this.activeServiceWorker);
3218
+ const i = await this.sender._send(
3219
+ "ping",
3220
+ {},
3221
+ 800
3222
+ /* _TimeoutDuration.LONG_ACK */
3223
+ );
3224
+ i && !((e = i[0]) === null || e === void 0) && e.fulfilled && !((t = i[0]) === null || t === void 0) && t.value.includes(
3225
+ "keyChanged"
3226
+ /* _EventType.KEY_CHANGED */
3227
+ ) && (this.serviceWorkerReceiverAvailable = !0);
3228
+ }
3229
+ /**
3230
+ * Let the worker know about a changed key, the exact key doesn't technically matter since the
3231
+ * worker will just trigger a full sync anyway.
3232
+ *
3233
+ * @remarks
3234
+ * For now, we only support one service worker per page.
3235
+ *
3236
+ * @param key - Storage key which changed.
3237
+ */
3238
+ async notifyServiceWorker(e) {
3239
+ if (!(!this.sender || !this.activeServiceWorker || fi() !== this.activeServiceWorker))
3240
+ try {
3241
+ await this.sender._send(
3242
+ "keyChanged",
3243
+ { key: e },
3244
+ // Use long timeout if receiver has previously responded to a ping from us.
3245
+ this.serviceWorkerReceiverAvailable ? 800 : 50
3246
+ /* _TimeoutDuration.ACK */
3247
+ );
3248
+ } catch {
3249
+ }
3250
+ }
3251
+ async _isAvailable() {
3252
+ try {
3253
+ if (!indexedDB)
3254
+ return !1;
3255
+ const e = await fe();
3256
+ return await He(e, ee, "1"), await $e(e, ee), !0;
3257
+ } catch {
3258
+ }
3259
+ return !1;
3260
+ }
3261
+ async _withPendingWrite(e) {
3262
+ this.pendingWrites++;
3263
+ try {
3264
+ await e();
3265
+ } finally {
3266
+ this.pendingWrites--;
3267
+ }
3268
+ }
3269
+ async _set(e, t) {
3270
+ return this._withPendingWrite(async () => (await this._withRetries((i) => He(i, e, t)), this.localCache[e] = t, this.notifyServiceWorker(e)));
3271
+ }
3272
+ async _get(e) {
3273
+ const t = await this._withRetries((i) => _i(i, e));
3274
+ return this.localCache[e] = t, t;
3275
+ }
3276
+ async _remove(e) {
3277
+ return this._withPendingWrite(async () => (await this._withRetries((t) => $e(t, e)), delete this.localCache[e], this.notifyServiceWorker(e)));
3278
+ }
3279
+ async _poll() {
3280
+ const e = await this._withRetries((r) => {
3281
+ const s = re(r, !1).getAll();
3282
+ return new j(s).toPromise();
3283
+ });
3284
+ if (!e)
3285
+ return [];
3286
+ if (this.pendingWrites !== 0)
3287
+ return [];
3288
+ const t = [], i = /* @__PURE__ */ new Set();
3289
+ for (const { fbase_key: r, value: s } of e)
3290
+ i.add(r), JSON.stringify(this.localCache[r]) !== JSON.stringify(s) && (this.notifyListeners(r, s), t.push(r));
3291
+ for (const r of Object.keys(this.localCache))
3292
+ this.localCache[r] && !i.has(r) && (this.notifyListeners(r, null), t.push(r));
3293
+ return t;
3294
+ }
3295
+ notifyListeners(e, t) {
3296
+ this.localCache[e] = t;
3297
+ const i = this.listeners[e];
3298
+ if (i)
3299
+ for (const r of Array.from(i))
3300
+ r(t);
3301
+ }
3302
+ startPolling() {
3303
+ this.stopPolling(), this.pollTimer = setInterval(async () => this._poll(), vi);
3304
+ }
3305
+ stopPolling() {
3306
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
3307
+ }
3308
+ _addListener(e, t) {
3309
+ Object.keys(this.listeners).length === 0 && this.startPolling(), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this._get(e)), this.listeners[e].add(t);
3310
+ }
3311
+ _removeListener(e, t) {
3312
+ this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && this.stopPolling();
3313
+ }
3314
+ }
3315
+ Lt.type = "LOCAL";
3316
+ const yi = Lt;
3317
+ new V(3e4, 6e4);
3318
+ /**
3319
+ * @license
3320
+ * Copyright 2021 Google LLC
3321
+ *
3322
+ * Licensed under the Apache License, Version 2.0 (the "License");
3323
+ * you may not use this file except in compliance with the License.
3324
+ * You may obtain a copy of the License at
3325
+ *
3326
+ * http://www.apache.org/licenses/LICENSE-2.0
3327
+ *
3328
+ * Unless required by applicable law or agreed to in writing, software
3329
+ * distributed under the License is distributed on an "AS IS" BASIS,
3330
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3331
+ * See the License for the specific language governing permissions and
3332
+ * limitations under the License.
3333
+ */
3334
+ function Ti(n, e) {
3335
+ return e ? v(e) : (u(
3336
+ n._popupRedirectResolver,
3337
+ n,
3338
+ "argument-error"
3339
+ /* AuthErrorCode.ARGUMENT_ERROR */
3340
+ ), n._popupRedirectResolver);
3341
+ }
3342
+ /**
3343
+ * @license
3344
+ * Copyright 2019 Google LLC
3345
+ *
3346
+ * Licensed under the Apache License, Version 2.0 (the "License");
3347
+ * you may not use this file except in compliance with the License.
3348
+ * You may obtain a copy of the License at
3349
+ *
3350
+ * http://www.apache.org/licenses/LICENSE-2.0
3351
+ *
3352
+ * Unless required by applicable law or agreed to in writing, software
3353
+ * distributed under the License is distributed on an "AS IS" BASIS,
3354
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3355
+ * See the License for the specific language governing permissions and
3356
+ * limitations under the License.
3357
+ */
3358
+ class Ee extends Et {
3359
+ constructor(e) {
3360
+ super(
3361
+ "custom",
3362
+ "custom"
3363
+ /* ProviderId.CUSTOM */
3364
+ ), this.params = e;
3365
+ }
3366
+ _getIdTokenResponse(e) {
3367
+ return N(e, this._buildIdpRequest());
3368
+ }
3369
+ _linkToIdToken(e, t) {
3370
+ return N(e, this._buildIdpRequest(t));
3371
+ }
3372
+ _getReauthenticationResolver(e) {
3373
+ return N(e, this._buildIdpRequest());
3374
+ }
3375
+ _buildIdpRequest(e) {
3376
+ const t = {
3377
+ requestUri: this.params.requestUri,
3378
+ sessionId: this.params.sessionId,
3379
+ postBody: this.params.postBody,
3380
+ tenantId: this.params.tenantId,
3381
+ pendingToken: this.params.pendingToken,
3382
+ returnSecureToken: !0,
3383
+ returnIdpCredential: !0
3384
+ };
3385
+ return e && (t.idToken = e), t;
3386
+ }
3387
+ }
3388
+ function wi(n) {
3389
+ return ei(n.auth, new Ee(n), n.bypassAuthState);
3390
+ }
3391
+ function Ei(n) {
3392
+ const { auth: e, user: t } = n;
3393
+ return u(
3394
+ t,
3395
+ e,
3396
+ "internal-error"
3397
+ /* AuthErrorCode.INTERNAL_ERROR */
3398
+ ), Zn(t, new Ee(n), n.bypassAuthState);
3399
+ }
3400
+ async function ki(n) {
3401
+ const { auth: e, user: t } = n;
3402
+ return u(
3403
+ t,
3404
+ e,
3405
+ "internal-error"
3406
+ /* AuthErrorCode.INTERNAL_ERROR */
3407
+ ), Qn(t, new Ee(n), n.bypassAuthState);
3408
+ }
3409
+ /**
3410
+ * @license
3411
+ * Copyright 2020 Google LLC
3412
+ *
3413
+ * Licensed under the Apache License, Version 2.0 (the "License");
3414
+ * you may not use this file except in compliance with the License.
3415
+ * You may obtain a copy of the License at
3416
+ *
3417
+ * http://www.apache.org/licenses/LICENSE-2.0
3418
+ *
3419
+ * Unless required by applicable law or agreed to in writing, software
3420
+ * distributed under the License is distributed on an "AS IS" BASIS,
3421
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3422
+ * See the License for the specific language governing permissions and
3423
+ * limitations under the License.
3424
+ */
3425
+ class Mt {
3426
+ constructor(e, t, i, r, s = !1) {
3427
+ this.auth = e, this.resolver = i, this.user = r, this.bypassAuthState = s, this.pendingPromise = null, this.eventManager = null, this.filter = Array.isArray(t) ? t : [t];
3428
+ }
3429
+ execute() {
3430
+ return new Promise(async (e, t) => {
3431
+ this.pendingPromise = { resolve: e, reject: t };
3432
+ try {
3433
+ this.eventManager = await this.resolver._initialize(this.auth), await this.onExecution(), this.eventManager.registerConsumer(this);
3434
+ } catch (i) {
3435
+ this.reject(i);
3436
+ }
3437
+ });
3438
+ }
3439
+ async onAuthEvent(e) {
3440
+ const { urlResponse: t, sessionId: i, postBody: r, tenantId: s, error: o, type: c } = e;
3441
+ if (o) {
3442
+ this.reject(o);
3443
+ return;
3444
+ }
3445
+ const a = {
3446
+ auth: this.auth,
3447
+ requestUri: t,
3448
+ sessionId: i,
3449
+ tenantId: s || void 0,
3450
+ postBody: r || void 0,
3451
+ user: this.user,
3452
+ bypassAuthState: this.bypassAuthState
3453
+ };
3454
+ try {
3455
+ this.resolve(await this.getIdpTask(c)(a));
3456
+ } catch (l) {
3457
+ this.reject(l);
3458
+ }
3459
+ }
3460
+ onError(e) {
3461
+ this.reject(e);
3462
+ }
3463
+ getIdpTask(e) {
3464
+ switch (e) {
3465
+ case "signInViaPopup":
3466
+ case "signInViaRedirect":
3467
+ return wi;
3468
+ case "linkViaPopup":
3469
+ case "linkViaRedirect":
3470
+ return ki;
3471
+ case "reauthViaPopup":
3472
+ case "reauthViaRedirect":
3473
+ return Ei;
3474
+ default:
3475
+ I(
3476
+ this.auth,
3477
+ "internal-error"
3478
+ /* AuthErrorCode.INTERNAL_ERROR */
3479
+ );
3480
+ }
3481
+ }
3482
+ resolve(e) {
3483
+ y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.resolve(e), this.unregisterAndCleanUp();
3484
+ }
3485
+ reject(e) {
3486
+ y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.reject(e), this.unregisterAndCleanUp();
3487
+ }
3488
+ unregisterAndCleanUp() {
3489
+ this.eventManager && this.eventManager.unregisterConsumer(this), this.pendingPromise = null, this.cleanUp();
3490
+ }
3491
+ }
3492
+ /**
3493
+ * @license
3494
+ * Copyright 2020 Google LLC
3495
+ *
3496
+ * Licensed under the Apache License, Version 2.0 (the "License");
3497
+ * you may not use this file except in compliance with the License.
3498
+ * You may obtain a copy of the License at
3499
+ *
3500
+ * http://www.apache.org/licenses/LICENSE-2.0
3501
+ *
3502
+ * Unless required by applicable law or agreed to in writing, software
3503
+ * distributed under the License is distributed on an "AS IS" BASIS,
3504
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3505
+ * See the License for the specific language governing permissions and
3506
+ * limitations under the License.
3507
+ */
3508
+ const Ri = new V(2e3, 1e4);
3509
+ class C extends Mt {
3510
+ constructor(e, t, i, r, s) {
3511
+ super(e, t, r, s), this.provider = i, this.authWindow = null, this.pollId = null, C.currentPopupAction && C.currentPopupAction.cancel(), C.currentPopupAction = this;
3512
+ }
3513
+ async executeNotNull() {
3514
+ const e = await this.execute();
3515
+ return u(
3516
+ e,
3517
+ this.auth,
3518
+ "internal-error"
3519
+ /* AuthErrorCode.INTERNAL_ERROR */
3520
+ ), e;
3521
+ }
3522
+ async onExecution() {
3523
+ y(this.filter.length === 1, "Popup operations only handle one event");
3524
+ const e = we();
3525
+ this.authWindow = await this.resolver._openPopup(
3526
+ this.auth,
3527
+ this.provider,
3528
+ this.filter[0],
3529
+ // There's always one, see constructor
3530
+ e
3531
+ ), this.authWindow.associatedEvent = e, this.resolver._originValidation(this.auth).catch((t) => {
3532
+ this.reject(t);
3533
+ }), this.resolver._isIframeWebStorageSupported(this.auth, (t) => {
3534
+ t || this.reject(g(
3535
+ this.auth,
3536
+ "web-storage-unsupported"
3537
+ /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */
3538
+ ));
3539
+ }), this.pollUserCancellation();
3540
+ }
3541
+ get eventId() {
3542
+ var e;
3543
+ return ((e = this.authWindow) === null || e === void 0 ? void 0 : e.associatedEvent) || null;
3544
+ }
3545
+ cancel() {
3546
+ this.reject(g(
3547
+ this.auth,
3548
+ "cancelled-popup-request"
3549
+ /* AuthErrorCode.EXPIRED_POPUP_REQUEST */
3550
+ ));
3551
+ }
3552
+ cleanUp() {
3553
+ this.authWindow && this.authWindow.close(), this.pollId && window.clearTimeout(this.pollId), this.authWindow = null, this.pollId = null, C.currentPopupAction = null;
3554
+ }
3555
+ pollUserCancellation() {
3556
+ const e = () => {
3557
+ var t, i;
3558
+ if (!((i = (t = this.authWindow) === null || t === void 0 ? void 0 : t.window) === null || i === void 0) && i.closed) {
3559
+ this.pollId = window.setTimeout(
3560
+ () => {
3561
+ this.pollId = null, this.reject(g(
3562
+ this.auth,
3563
+ "popup-closed-by-user"
3564
+ /* AuthErrorCode.POPUP_CLOSED_BY_USER */
3565
+ ));
3566
+ },
3567
+ 8e3
3568
+ /* _Timeout.AUTH_EVENT */
3569
+ );
3570
+ return;
3571
+ }
3572
+ this.pollId = window.setTimeout(e, Ri.get());
3573
+ };
3574
+ e();
3575
+ }
3576
+ }
3577
+ C.currentPopupAction = null;
3578
+ /**
3579
+ * @license
3580
+ * Copyright 2020 Google LLC
3581
+ *
3582
+ * Licensed under the Apache License, Version 2.0 (the "License");
3583
+ * you may not use this file except in compliance with the License.
3584
+ * You may obtain a copy of the License at
3585
+ *
3586
+ * http://www.apache.org/licenses/LICENSE-2.0
3587
+ *
3588
+ * Unless required by applicable law or agreed to in writing, software
3589
+ * distributed under the License is distributed on an "AS IS" BASIS,
3590
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3591
+ * See the License for the specific language governing permissions and
3592
+ * limitations under the License.
3593
+ */
3594
+ const bi = "pendingRedirect", J = /* @__PURE__ */ new Map();
3595
+ class Si extends Mt {
3596
+ constructor(e, t, i = !1) {
3597
+ super(e, [
3598
+ "signInViaRedirect",
3599
+ "linkViaRedirect",
3600
+ "reauthViaRedirect",
3601
+ "unknown"
3602
+ /* AuthEventType.UNKNOWN */
3603
+ ], t, void 0, i), this.eventId = null;
3604
+ }
3605
+ /**
3606
+ * Override the execute function; if we already have a redirect result, then
3607
+ * just return it.
3608
+ */
3609
+ async execute() {
3610
+ let e = J.get(this.auth._key());
3611
+ if (!e) {
3612
+ try {
3613
+ const i = await Ai(this.resolver, this.auth) ? await super.execute() : null;
3614
+ e = () => Promise.resolve(i);
3615
+ } catch (t) {
3616
+ e = () => Promise.reject(t);
3617
+ }
3618
+ J.set(this.auth._key(), e);
3619
+ }
3620
+ return this.bypassAuthState || J.set(this.auth._key(), () => Promise.resolve(null)), e();
3621
+ }
3622
+ async onAuthEvent(e) {
3623
+ if (e.type === "signInViaRedirect")
3624
+ return super.onAuthEvent(e);
3625
+ if (e.type === "unknown") {
3626
+ this.resolve(null);
3627
+ return;
3628
+ }
3629
+ if (e.eventId) {
3630
+ const t = await this.auth._redirectUserForId(e.eventId);
3631
+ if (t)
3632
+ return this.user = t, super.onAuthEvent(e);
3633
+ this.resolve(null);
3634
+ }
3635
+ }
3636
+ async onExecution() {
3637
+ }
3638
+ cleanUp() {
3639
+ }
3640
+ }
3641
+ async function Ai(n, e) {
3642
+ const t = Ni(e), i = Pi(n);
3643
+ if (!await i._isAvailable())
3644
+ return !1;
3645
+ const r = await i._get(t) === "true";
3646
+ return await i._remove(t), r;
3647
+ }
3648
+ function Ci(n, e) {
3649
+ J.set(n._key(), e);
3650
+ }
3651
+ function Pi(n) {
3652
+ return v(n._redirectPersistence);
3653
+ }
3654
+ function Ni(n) {
3655
+ return z(bi, n.config.apiKey, n.name);
3656
+ }
3657
+ async function Oi(n, e, t = !1) {
3658
+ const i = H(n), r = Ti(i, e), o = await new Si(i, r, t).execute();
3659
+ return o && !t && (delete o.user._redirectEventId, await i._persistUserIfCurrent(o.user), await i._setRedirectUser(null, e)), o;
3660
+ }
3661
+ /**
3662
+ * @license
3663
+ * Copyright 2020 Google LLC
3664
+ *
3665
+ * Licensed under the Apache License, Version 2.0 (the "License");
3666
+ * you may not use this file except in compliance with the License.
3667
+ * You may obtain a copy of the License at
3668
+ *
3669
+ * http://www.apache.org/licenses/LICENSE-2.0
3670
+ *
3671
+ * Unless required by applicable law or agreed to in writing, software
3672
+ * distributed under the License is distributed on an "AS IS" BASIS,
3673
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3674
+ * See the License for the specific language governing permissions and
3675
+ * limitations under the License.
3676
+ */
3677
+ const Li = 10 * 60 * 1e3;
3678
+ class Mi {
3679
+ constructor(e) {
3680
+ this.auth = e, this.cachedEventUids = /* @__PURE__ */ new Set(), this.consumers = /* @__PURE__ */ new Set(), this.queuedRedirectEvent = null, this.hasHandledPotentialRedirect = !1, this.lastProcessedEventTime = Date.now();
3681
+ }
3682
+ registerConsumer(e) {
3683
+ this.consumers.add(e), this.queuedRedirectEvent && this.isEventForConsumer(this.queuedRedirectEvent, e) && (this.sendToConsumer(this.queuedRedirectEvent, e), this.saveEventToCache(this.queuedRedirectEvent), this.queuedRedirectEvent = null);
3684
+ }
3685
+ unregisterConsumer(e) {
3686
+ this.consumers.delete(e);
3687
+ }
3688
+ onEvent(e) {
3689
+ if (this.hasEventBeenHandled(e))
3690
+ return !1;
3691
+ let t = !1;
3692
+ return this.consumers.forEach((i) => {
3693
+ this.isEventForConsumer(e, i) && (t = !0, this.sendToConsumer(e, i), this.saveEventToCache(e));
3694
+ }), this.hasHandledPotentialRedirect || !Ui(e) || (this.hasHandledPotentialRedirect = !0, t || (this.queuedRedirectEvent = e, t = !0)), t;
3695
+ }
3696
+ sendToConsumer(e, t) {
3697
+ var i;
3698
+ if (e.error && !Ut(e)) {
3699
+ const r = ((i = e.error.code) === null || i === void 0 ? void 0 : i.split("auth/")[1]) || "internal-error";
3700
+ t.onError(g(this.auth, r));
3701
+ } else
3702
+ t.onAuthEvent(e);
3703
+ }
3704
+ isEventForConsumer(e, t) {
3705
+ const i = t.eventId === null || !!e.eventId && e.eventId === t.eventId;
3706
+ return t.filter.includes(e.type) && i;
3707
+ }
3708
+ hasEventBeenHandled(e) {
3709
+ return Date.now() - this.lastProcessedEventTime >= Li && this.cachedEventUids.clear(), this.cachedEventUids.has(je(e));
3710
+ }
3711
+ saveEventToCache(e) {
3712
+ this.cachedEventUids.add(je(e)), this.lastProcessedEventTime = Date.now();
3713
+ }
3714
+ }
3715
+ function je(n) {
3716
+ return [n.type, n.eventId, n.sessionId, n.tenantId].filter((e) => e).join("-");
3717
+ }
3718
+ function Ut({ type: n, error: e }) {
3719
+ return n === "unknown" && (e == null ? void 0 : e.code) === "auth/no-auth-event";
3720
+ }
3721
+ function Ui(n) {
3722
+ switch (n.type) {
3723
+ case "signInViaRedirect":
3724
+ case "linkViaRedirect":
3725
+ case "reauthViaRedirect":
3726
+ return !0;
3727
+ case "unknown":
3728
+ return Ut(n);
3729
+ default:
3730
+ return !1;
3731
+ }
3732
+ }
3733
+ /**
3734
+ * @license
3735
+ * Copyright 2020 Google LLC
3736
+ *
3737
+ * Licensed under the Apache License, Version 2.0 (the "License");
3738
+ * you may not use this file except in compliance with the License.
3739
+ * You may obtain a copy of the License at
3740
+ *
3741
+ * http://www.apache.org/licenses/LICENSE-2.0
3742
+ *
3743
+ * Unless required by applicable law or agreed to in writing, software
3744
+ * distributed under the License is distributed on an "AS IS" BASIS,
3745
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3746
+ * See the License for the specific language governing permissions and
3747
+ * limitations under the License.
3748
+ */
3749
+ async function Di(n, e = {}) {
3750
+ return W(n, "GET", "/v1/projects", e);
3751
+ }
3752
+ /**
3753
+ * @license
3754
+ * Copyright 2020 Google LLC
3755
+ *
3756
+ * Licensed under the Apache License, Version 2.0 (the "License");
3757
+ * you may not use this file except in compliance with the License.
3758
+ * You may obtain a copy of the License at
3759
+ *
3760
+ * http://www.apache.org/licenses/LICENSE-2.0
3761
+ *
3762
+ * Unless required by applicable law or agreed to in writing, software
3763
+ * distributed under the License is distributed on an "AS IS" BASIS,
3764
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3765
+ * See the License for the specific language governing permissions and
3766
+ * limitations under the License.
3767
+ */
3768
+ const Fi = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, xi = /^https?/;
3769
+ async function Vi(n) {
3770
+ if (n.config.emulator)
3771
+ return;
3772
+ const { authorizedDomains: e } = await Di(n);
3773
+ for (const t of e)
3774
+ try {
3775
+ if (Wi(t))
3776
+ return;
3777
+ } catch {
3778
+ }
3779
+ I(
3780
+ n,
3781
+ "unauthorized-domain"
3782
+ /* AuthErrorCode.INVALID_ORIGIN */
3783
+ );
3784
+ }
3785
+ function Wi(n) {
3786
+ const e = he(), { protocol: t, hostname: i } = new URL(e);
3787
+ if (n.startsWith("chrome-extension://")) {
3788
+ const o = new URL(n);
3789
+ return o.hostname === "" && i === "" ? t === "chrome-extension:" && n.replace("chrome-extension://", "") === e.replace("chrome-extension://", "") : t === "chrome-extension:" && o.hostname === i;
3790
+ }
3791
+ if (!xi.test(t))
3792
+ return !1;
3793
+ if (Fi.test(n))
3794
+ return i === n;
3795
+ const r = n.replace(/\./g, "\\.");
3796
+ return new RegExp("^(.+\\." + r + "|" + r + ")$", "i").test(i);
3797
+ }
3798
+ /**
3799
+ * @license
3800
+ * Copyright 2020 Google LLC.
3801
+ *
3802
+ * Licensed under the Apache License, Version 2.0 (the "License");
3803
+ * you may not use this file except in compliance with the License.
3804
+ * You may obtain a copy of the License at
3805
+ *
3806
+ * http://www.apache.org/licenses/LICENSE-2.0
3807
+ *
3808
+ * Unless required by applicable law or agreed to in writing, software
3809
+ * distributed under the License is distributed on an "AS IS" BASIS,
3810
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3811
+ * See the License for the specific language governing permissions and
3812
+ * limitations under the License.
3813
+ */
3814
+ const Hi = new V(3e4, 6e4);
3815
+ function Be() {
3816
+ const n = m().___jsl;
3817
+ if (n != null && n.H) {
3818
+ for (const e of Object.keys(n.H))
3819
+ if (n.H[e].r = n.H[e].r || [], n.H[e].L = n.H[e].L || [], n.H[e].r = [...n.H[e].L], n.CP)
3820
+ for (let t = 0; t < n.CP.length; t++)
3821
+ n.CP[t] = null;
3822
+ }
3823
+ }
3824
+ function $i(n) {
3825
+ return new Promise((e, t) => {
3826
+ var i, r, s;
3827
+ function o() {
3828
+ Be(), gapi.load("gapi.iframes", {
3829
+ callback: () => {
3830
+ e(gapi.iframes.getContext());
3831
+ },
3832
+ ontimeout: () => {
3833
+ Be(), t(g(
3834
+ n,
3835
+ "network-request-failed"
3836
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3837
+ ));
3838
+ },
3839
+ timeout: Hi.get()
3840
+ });
3841
+ }
3842
+ if (!((r = (i = m().gapi) === null || i === void 0 ? void 0 : i.iframes) === null || r === void 0) && r.Iframe)
3843
+ e(gapi.iframes.getContext());
3844
+ else if (!((s = m().gapi) === null || s === void 0) && s.load)
3845
+ o();
3846
+ else {
3847
+ const c = Vn("iframefcb");
3848
+ return m()[c] = () => {
3849
+ gapi.load ? o() : t(g(
3850
+ n,
3851
+ "network-request-failed"
3852
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3853
+ ));
3854
+ }, Tt(`https://apis.google.com/js/api.js?onload=${c}`).catch((a) => t(a));
3855
+ }
3856
+ }).catch((e) => {
3857
+ throw Y = null, e;
3858
+ });
3859
+ }
3860
+ let Y = null;
3861
+ function ji(n) {
3862
+ return Y = Y || $i(n), Y;
3863
+ }
3864
+ /**
3865
+ * @license
3866
+ * Copyright 2020 Google LLC.
3867
+ *
3868
+ * Licensed under the Apache License, Version 2.0 (the "License");
3869
+ * you may not use this file except in compliance with the License.
3870
+ * You may obtain a copy of the License at
3871
+ *
3872
+ * http://www.apache.org/licenses/LICENSE-2.0
3873
+ *
3874
+ * Unless required by applicable law or agreed to in writing, software
3875
+ * distributed under the License is distributed on an "AS IS" BASIS,
3876
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3877
+ * See the License for the specific language governing permissions and
3878
+ * limitations under the License.
3879
+ */
3880
+ const Bi = new V(5e3, 15e3), Ki = "__/auth/iframe", qi = "emulator/auth/iframe", Gi = {
3881
+ style: {
3882
+ position: "absolute",
3883
+ top: "-100px",
3884
+ width: "1px",
3885
+ height: "1px"
3886
+ },
3887
+ "aria-hidden": "true",
3888
+ tabindex: "-1"
3889
+ }, zi = /* @__PURE__ */ new Map([
3890
+ ["identitytoolkit.googleapis.com", "p"],
3891
+ ["staging-identitytoolkit.sandbox.googleapis.com", "s"],
3892
+ ["test-identitytoolkit.sandbox.googleapis.com", "t"]
3893
+ // test
3894
+ ]);
3895
+ function Ji(n) {
3896
+ const e = n.config;
3897
+ u(
3898
+ e.authDomain,
3899
+ n,
3900
+ "auth-domain-config-required"
3901
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
3902
+ );
3903
+ const t = e.emulator ? ve(e, qi) : `https://${n.config.authDomain}/${Ki}`, i = {
3904
+ apiKey: e.apiKey,
3905
+ appName: n.name,
3906
+ v: F
3907
+ }, r = zi.get(n.config.apiHost);
3908
+ r && (i.eid = r);
3909
+ const s = n._getFrameworks();
3910
+ return s.length && (i.fw = s.join(",")), `${t}?${x(i).slice(1)}`;
3911
+ }
3912
+ async function Yi(n) {
3913
+ const e = await ji(n), t = m().gapi;
3914
+ return u(
3915
+ t,
3916
+ n,
3917
+ "internal-error"
3918
+ /* AuthErrorCode.INTERNAL_ERROR */
3919
+ ), e.open({
3920
+ where: document.body,
3921
+ url: Ji(n),
3922
+ messageHandlersFilter: t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
3923
+ attributes: Gi,
3924
+ dontclear: !0
3925
+ }, (i) => new Promise(async (r, s) => {
3926
+ await i.restyle({
3927
+ // Prevent iframe from closing on mouse out.
3928
+ setHideOnLeave: !1
3929
+ });
3930
+ const o = g(
3931
+ n,
3932
+ "network-request-failed"
3933
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3934
+ ), c = m().setTimeout(() => {
3935
+ s(o);
3936
+ }, Bi.get());
3937
+ function a() {
3938
+ m().clearTimeout(c), r(i);
3939
+ }
3940
+ i.ping(a).then(a, () => {
3941
+ s(o);
3942
+ });
3943
+ }));
3944
+ }
3945
+ /**
3946
+ * @license
3947
+ * Copyright 2020 Google LLC.
3948
+ *
3949
+ * Licensed under the Apache License, Version 2.0 (the "License");
3950
+ * you may not use this file except in compliance with the License.
3951
+ * You may obtain a copy of the License at
3952
+ *
3953
+ * http://www.apache.org/licenses/LICENSE-2.0
3954
+ *
3955
+ * Unless required by applicable law or agreed to in writing, software
3956
+ * distributed under the License is distributed on an "AS IS" BASIS,
3957
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3958
+ * See the License for the specific language governing permissions and
3959
+ * limitations under the License.
3960
+ */
3961
+ const Xi = {
3962
+ location: "yes",
3963
+ resizable: "yes",
3964
+ statusbar: "yes",
3965
+ toolbar: "no"
3966
+ }, Qi = 500, Zi = 600, er = "_blank", tr = "http://localhost";
3967
+ class Ke {
3968
+ constructor(e) {
3969
+ this.window = e, this.associatedEvent = null;
3970
+ }
3971
+ close() {
3972
+ if (this.window)
3973
+ try {
3974
+ this.window.close();
3975
+ } catch {
3976
+ }
3977
+ }
3978
+ }
3979
+ function nr(n, e, t, i = Qi, r = Zi) {
3980
+ const s = Math.max((window.screen.availHeight - r) / 2, 0).toString(), o = Math.max((window.screen.availWidth - i) / 2, 0).toString();
3981
+ let c = "";
3982
+ const a = Object.assign(Object.assign({}, Xi), {
3983
+ width: i.toString(),
3984
+ height: r.toString(),
3985
+ top: s,
3986
+ left: o
3987
+ }), l = f().toLowerCase();
3988
+ t && (c = ht(l) ? er : t), dt(l) && (e = e || tr, a.scrollbars = "yes");
3989
+ const d = Object.entries(a).reduce((p, [B, K]) => `${p}${B}=${K},`, "");
3990
+ if (Un(l) && c !== "_self")
3991
+ return ir(e || "", c), new Ke(null);
3992
+ const h = window.open(e || "", c, d);
3993
+ u(
3994
+ h,
3995
+ n,
3996
+ "popup-blocked"
3997
+ /* AuthErrorCode.POPUP_BLOCKED */
3998
+ );
3999
+ try {
4000
+ h.focus();
4001
+ } catch {
4002
+ }
4003
+ return new Ke(h);
4004
+ }
4005
+ function ir(n, e) {
4006
+ const t = document.createElement("a");
4007
+ t.href = n, t.target = e;
4008
+ const i = document.createEvent("MouseEvent");
4009
+ i.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 1, null), t.dispatchEvent(i);
4010
+ }
4011
+ /**
4012
+ * @license
4013
+ * Copyright 2021 Google LLC
4014
+ *
4015
+ * Licensed under the Apache License, Version 2.0 (the "License");
4016
+ * you may not use this file except in compliance with the License.
4017
+ * You may obtain a copy of the License at
4018
+ *
4019
+ * http://www.apache.org/licenses/LICENSE-2.0
4020
+ *
4021
+ * Unless required by applicable law or agreed to in writing, software
4022
+ * distributed under the License is distributed on an "AS IS" BASIS,
4023
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4024
+ * See the License for the specific language governing permissions and
4025
+ * limitations under the License.
4026
+ */
4027
+ const rr = "__/auth/handler", sr = "emulator/auth/handler", or = encodeURIComponent("fac");
4028
+ async function qe(n, e, t, i, r, s) {
4029
+ u(
4030
+ n.config.authDomain,
4031
+ n,
4032
+ "auth-domain-config-required"
4033
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
4034
+ ), u(
4035
+ n.config.apiKey,
4036
+ n,
4037
+ "invalid-api-key"
4038
+ /* AuthErrorCode.INVALID_API_KEY */
4039
+ );
4040
+ const o = {
4041
+ apiKey: n.config.apiKey,
4042
+ appName: n.name,
4043
+ authType: t,
4044
+ redirectUrl: i,
4045
+ v: F,
4046
+ eventId: r
4047
+ };
4048
+ if (e instanceof kt) {
4049
+ e.setDefaultLanguage(n.languageCode), o.providerId = e.providerId || "", an(e.getCustomParameters()) || (o.customParameters = JSON.stringify(e.getCustomParameters()));
4050
+ for (const [d, h] of Object.entries(s || {}))
4051
+ o[d] = h;
4052
+ }
4053
+ if (e instanceof $) {
4054
+ const d = e.getScopes().filter((h) => h !== "");
4055
+ d.length > 0 && (o.scopes = d.join(","));
4056
+ }
4057
+ n.tenantId && (o.tid = n.tenantId);
4058
+ const c = o;
4059
+ for (const d of Object.keys(c))
4060
+ c[d] === void 0 && delete c[d];
4061
+ const a = await n._getAppCheckToken(), l = a ? `#${or}=${encodeURIComponent(a)}` : "";
4062
+ return `${ar(n)}?${x(c).slice(1)}${l}`;
4063
+ }
4064
+ function ar({ config: n }) {
4065
+ return n.emulator ? ve(n, sr) : `https://${n.authDomain}/${rr}`;
4066
+ }
4067
+ /**
4068
+ * @license
4069
+ * Copyright 2020 Google LLC
4070
+ *
4071
+ * Licensed under the Apache License, Version 2.0 (the "License");
4072
+ * you may not use this file except in compliance with the License.
4073
+ * You may obtain a copy of the License at
4074
+ *
4075
+ * http://www.apache.org/licenses/LICENSE-2.0
4076
+ *
4077
+ * Unless required by applicable law or agreed to in writing, software
4078
+ * distributed under the License is distributed on an "AS IS" BASIS,
4079
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4080
+ * See the License for the specific language governing permissions and
4081
+ * limitations under the License.
4082
+ */
4083
+ const ue = "webStorageSupport";
4084
+ class cr {
4085
+ constructor() {
4086
+ this.eventManagers = {}, this.iframes = {}, this.originValidationPromises = {}, this._redirectPersistence = Ct, this._completeRedirectFn = Oi, this._overrideRedirectResult = Ci;
4087
+ }
4088
+ // Wrapping in async even though we don't await anywhere in order
4089
+ // to make sure errors are raised as promise rejections
4090
+ async _openPopup(e, t, i, r) {
4091
+ var s;
4092
+ y((s = this.eventManagers[e._key()]) === null || s === void 0 ? void 0 : s.manager, "_initialize() not called before _openPopup()");
4093
+ const o = await qe(e, t, i, he(), r);
4094
+ return nr(e, o, we());
4095
+ }
4096
+ async _openRedirect(e, t, i, r) {
4097
+ await this._originValidation(e);
4098
+ const s = await qe(e, t, i, he(), r);
4099
+ return di(s), new Promise(() => {
4100
+ });
4101
+ }
4102
+ _initialize(e) {
4103
+ const t = e._key();
4104
+ if (this.eventManagers[t]) {
4105
+ const { manager: r, promise: s } = this.eventManagers[t];
4106
+ return r ? Promise.resolve(r) : (y(s, "If manager is not set, promise should be"), s);
4107
+ }
4108
+ const i = this.initAndGetManager(e);
4109
+ return this.eventManagers[t] = { promise: i }, i.catch(() => {
4110
+ delete this.eventManagers[t];
4111
+ }), i;
4112
+ }
4113
+ async initAndGetManager(e) {
4114
+ const t = await Yi(e), i = new Mi(e);
4115
+ return t.register("authEvent", (r) => (u(
4116
+ r == null ? void 0 : r.authEvent,
4117
+ e,
4118
+ "invalid-auth-event"
4119
+ /* AuthErrorCode.INVALID_AUTH_EVENT */
4120
+ ), {
4121
+ status: i.onEvent(r.authEvent) ? "ACK" : "ERROR"
4122
+ /* GapiOutcome.ERROR */
4123
+ }), gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER), this.eventManagers[e._key()] = { manager: i }, this.iframes[e._key()] = t, i;
4124
+ }
4125
+ _isIframeWebStorageSupported(e, t) {
4126
+ this.iframes[e._key()].send(ue, { type: ue }, (r) => {
4127
+ var s;
4128
+ const o = (s = r == null ? void 0 : r[0]) === null || s === void 0 ? void 0 : s[ue];
4129
+ o !== void 0 && t(!!o), I(
4130
+ e,
4131
+ "internal-error"
4132
+ /* AuthErrorCode.INTERNAL_ERROR */
4133
+ );
4134
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
4135
+ }
4136
+ _originValidation(e) {
4137
+ const t = e._key();
4138
+ return this.originValidationPromises[t] || (this.originValidationPromises[t] = Vi(e)), this.originValidationPromises[t];
4139
+ }
4140
+ get _shouldInitProactively() {
4141
+ return _t() || Te() || ne();
4142
+ }
4143
+ }
4144
+ const lr = cr;
4145
+ var Ge = "@firebase/auth", ze = "0.23.2";
4146
+ /**
4147
+ * @license
4148
+ * Copyright 2020 Google LLC
4149
+ *
4150
+ * Licensed under the Apache License, Version 2.0 (the "License");
4151
+ * you may not use this file except in compliance with the License.
4152
+ * You may obtain a copy of the License at
4153
+ *
4154
+ * http://www.apache.org/licenses/LICENSE-2.0
4155
+ *
4156
+ * Unless required by applicable law or agreed to in writing, software
4157
+ * distributed under the License is distributed on an "AS IS" BASIS,
4158
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4159
+ * See the License for the specific language governing permissions and
4160
+ * limitations under the License.
4161
+ */
4162
+ class ur {
4163
+ constructor(e) {
4164
+ this.auth = e, this.internalListeners = /* @__PURE__ */ new Map();
4165
+ }
4166
+ getUid() {
4167
+ var e;
4168
+ return this.assertAuthConfigured(), ((e = this.auth.currentUser) === null || e === void 0 ? void 0 : e.uid) || null;
4169
+ }
4170
+ async getToken(e) {
4171
+ return this.assertAuthConfigured(), await this.auth._initializationPromise, this.auth.currentUser ? { accessToken: await this.auth.currentUser.getIdToken(e) } : null;
4172
+ }
4173
+ addAuthTokenListener(e) {
4174
+ if (this.assertAuthConfigured(), this.internalListeners.has(e))
4175
+ return;
4176
+ const t = this.auth.onIdTokenChanged((i) => {
4177
+ e((i == null ? void 0 : i.stsTokenManager.accessToken) || null);
4178
+ });
4179
+ this.internalListeners.set(e, t), this.updateProactiveRefresh();
4180
+ }
4181
+ removeAuthTokenListener(e) {
4182
+ this.assertAuthConfigured();
4183
+ const t = this.internalListeners.get(e);
4184
+ t && (this.internalListeners.delete(e), t(), this.updateProactiveRefresh());
4185
+ }
4186
+ assertAuthConfigured() {
4187
+ u(
4188
+ this.auth._initializationPromise,
4189
+ "dependent-sdk-initialized-before-auth"
4190
+ /* AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH */
4191
+ );
4192
+ }
4193
+ updateProactiveRefresh() {
4194
+ this.internalListeners.size > 0 ? this.auth._startProactiveRefresh() : this.auth._stopProactiveRefresh();
4195
+ }
4196
+ }
4197
+ /**
4198
+ * @license
4199
+ * Copyright 2020 Google LLC
4200
+ *
4201
+ * Licensed under the Apache License, Version 2.0 (the "License");
4202
+ * you may not use this file except in compliance with the License.
4203
+ * You may obtain a copy of the License at
4204
+ *
4205
+ * http://www.apache.org/licenses/LICENSE-2.0
4206
+ *
4207
+ * Unless required by applicable law or agreed to in writing, software
4208
+ * distributed under the License is distributed on an "AS IS" BASIS,
4209
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4210
+ * See the License for the specific language governing permissions and
4211
+ * limitations under the License.
4212
+ */
4213
+ function dr(n) {
4214
+ switch (n) {
4215
+ case "Node":
4216
+ return "node";
4217
+ case "ReactNative":
4218
+ return "rn";
4219
+ case "Worker":
4220
+ return "webworker";
4221
+ case "Cordova":
4222
+ return "cordova";
4223
+ default:
4224
+ return;
4225
+ }
4226
+ }
4227
+ function hr(n) {
4228
+ Ne(new Oe(
4229
+ "auth",
4230
+ (e, { options: t }) => {
4231
+ const i = e.getProvider("app").getImmediate(), r = e.getProvider("heartbeat"), s = e.getProvider("app-check-internal"), { apiKey: o, authDomain: c } = i.options;
4232
+ u(o && !o.includes(":"), "invalid-api-key", { appName: i.name });
4233
+ const a = {
4234
+ apiKey: o,
4235
+ authDomain: c,
4236
+ clientPlatform: n,
4237
+ apiHost: "identitytoolkit.googleapis.com",
4238
+ tokenApiHost: "securetoken.googleapis.com",
4239
+ apiScheme: "https",
4240
+ sdkClientVersion: vt(n)
4241
+ }, l = new Kn(i, r, s, a);
4242
+ return Gn(l, t), l;
4243
+ },
4244
+ "PUBLIC"
4245
+ /* ComponentType.PUBLIC */
4246
+ ).setInstantiationMode(
4247
+ "EXPLICIT"
4248
+ /* InstantiationMode.EXPLICIT */
4249
+ ).setInstanceCreatedCallback((e, t, i) => {
4250
+ e.getProvider(
4251
+ "auth-internal"
4252
+ /* _ComponentName.AUTH_INTERNAL */
4253
+ ).initialize();
4254
+ })), Ne(new Oe(
4255
+ "auth-internal",
4256
+ (e) => {
4257
+ const t = H(e.getProvider(
4258
+ "auth"
4259
+ /* _ComponentName.AUTH */
4260
+ ).getImmediate());
4261
+ return ((i) => new ur(i))(t);
4262
+ },
4263
+ "PRIVATE"
4264
+ /* ComponentType.PRIVATE */
4265
+ ).setInstantiationMode(
4266
+ "EXPLICIT"
4267
+ /* InstantiationMode.EXPLICIT */
4268
+ )), de(Ge, ze, dr(n)), de(Ge, ze, "esm2017");
4269
+ }
4270
+ /**
4271
+ * @license
4272
+ * Copyright 2021 Google LLC
4273
+ *
4274
+ * Licensed under the Apache License, Version 2.0 (the "License");
4275
+ * you may not use this file except in compliance with the License.
4276
+ * You may obtain a copy of the License at
4277
+ *
4278
+ * http://www.apache.org/licenses/LICENSE-2.0
4279
+ *
4280
+ * Unless required by applicable law or agreed to in writing, software
4281
+ * distributed under the License is distributed on an "AS IS" BASIS,
4282
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4283
+ * See the License for the specific language governing permissions and
4284
+ * limitations under the License.
4285
+ */
4286
+ const fr = 5 * 60, pr = et("authIdTokenMaxAge") || fr;
4287
+ let Je = null;
4288
+ const gr = (n) => async (e) => {
4289
+ const t = e && await e.getIdTokenResult(), i = t && ((/* @__PURE__ */ new Date()).getTime() - Date.parse(t.issuedAtTime)) / 1e3;
4290
+ if (i && i > pr)
4291
+ return;
4292
+ const r = t == null ? void 0 : t.token;
4293
+ Je !== r && (Je = r, await fetch(n, {
4294
+ method: r ? "POST" : "DELETE",
4295
+ headers: r ? {
4296
+ Authorization: `Bearer ${r}`
4297
+ } : {}
4298
+ }));
4299
+ };
4300
+ function mr(n = tn()) {
4301
+ const e = tt(n, "auth");
4302
+ if (e.isInitialized())
4303
+ return e.getImmediate();
4304
+ const t = qn(n, {
4305
+ popupRedirectResolver: lr,
4306
+ persistence: [
4307
+ yi,
4308
+ ci,
4309
+ Ct
4310
+ ]
4311
+ }), i = et("authTokenSyncURL");
4312
+ if (i) {
4313
+ const s = gr(i);
4314
+ ri(t, s, () => s(t.currentUser)), ii(t, (o) => s(o));
4315
+ }
4316
+ const r = en("auth");
4317
+ return r && zn(t, `http://${r}`), t;
4318
+ }
4319
+ hr(
4320
+ "Browser"
4321
+ /* ClientPlatform.BROWSER */
4322
+ );
4323
+ async function _r() {
4324
+ if (cn().length)
4325
+ return;
4326
+ const n = ln({ apiKey: "AIzaSyAj8JdCHtP0Vc5vZobCfgoLzWxPIn0WUG4", authDomain: "feedme-dev-4c3ef.firebaseapp.com", databaseURL: "https://feedme-dev-4c3ef.firebaseio.com", projectId: "feedme-dev-4c3ef", storageBucket: "feedme-dev-4c3ef.appspot.com", messagingSenderId: "458797803788", appId: "1:458797803788:web:37f2af2926a84288f0c129", measurementId: "G-J2QG09D2Q7" }), e = await qt.getCustomToken(), t = mr();
4327
+ await ni(t, e), un(n);
4328
+ }
4329
+ async function vr() {
4330
+ if (dn())
4331
+ return;
4332
+ const e = await new M("AIzaSyA_isPR1-9bX7UmRiJIhsIRNNwdn6DdmW4", {
4333
+ libraries: ["places"]
4334
+ }).load();
4335
+ hn(e);
4336
+ }
4337
+ async function Ir() {
4338
+ await _r(), await vr();
4339
+ }
4340
+ const Cr = /* @__PURE__ */ Ye({
4341
+ __name: "App",
4342
+ setup(n) {
4343
+ const e = Ze();
4344
+ return Ht(() => {
4345
+ e.registerSidebarComponent(fn), Ir();
4346
+ }), (t, i) => (Xe(), Qe($t(Bt)));
4347
+ }
4348
+ });
4349
+ export {
4350
+ Cr as default
4351
+ };