@feedmepos/mf-connect 0.1.38-beta.74 → 0.1.38-beta.76

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