@feedmepos/mf-connect 0.1.98-beta.40 → 0.1.98-beta.41

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