@feedmepos/mf-connect 0.1.98-beta.15 → 0.1.98-beta.16

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