chordia-ui 3.3.8 → 3.3.9

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 (159) hide show
  1. package/dist/AgentLiftCard.cjs.js.map +1 -1
  2. package/dist/AgentLiftCard.es.js +5 -3
  3. package/dist/AgentLiftCard.es.js.map +1 -1
  4. package/dist/CustomFilterChips.cjs.js.map +1 -1
  5. package/dist/CustomFilterChips.es.js +2 -1
  6. package/dist/CustomFilterChips.es.js.map +1 -1
  7. package/dist/FileUploadingState.cjs.js.map +1 -1
  8. package/dist/FileUploadingState.es.js +16 -10
  9. package/dist/FileUploadingState.es.js.map +1 -1
  10. package/dist/IntegrationCard.cjs.js.map +1 -1
  11. package/dist/IntegrationCard.es.js +3 -3
  12. package/dist/IntegrationCard.es.js.map +1 -1
  13. package/dist/SectionLabel.cjs.js.map +1 -1
  14. package/dist/SectionLabel.es.js.map +1 -1
  15. package/dist/SmallButton.cjs.js.map +1 -1
  16. package/dist/SmallButton.es.js +16 -16
  17. package/dist/SmallButton.es.js.map +1 -1
  18. package/dist/SummarySection.cjs.js.map +1 -1
  19. package/dist/SummarySection.es.js +11 -9
  20. package/dist/SummarySection.es.js.map +1 -1
  21. package/dist/TextInput.cjs.js.map +1 -1
  22. package/dist/TextInput.es.js.map +1 -1
  23. package/dist/Timeline.cjs.js.map +1 -1
  24. package/dist/Timeline.es.js +14 -8
  25. package/dist/Timeline.es.js.map +1 -1
  26. package/dist/Tooltip.cjs.js +1 -1
  27. package/dist/Tooltip.cjs.js.map +1 -1
  28. package/dist/Tooltip.es.js +31 -20
  29. package/dist/Tooltip.es.js.map +1 -1
  30. package/dist/TourGuideTooltip.cjs.js.map +1 -1
  31. package/dist/TourGuideTooltip.es.js +2 -1
  32. package/dist/TourGuideTooltip.es.js.map +1 -1
  33. package/dist/UpdatedInteractionRecording.cjs.js +1 -1
  34. package/dist/UpdatedInteractionRecording.cjs.js.map +1 -1
  35. package/dist/UpdatedInteractionRecording.es.js +79 -97
  36. package/dist/UpdatedInteractionRecording.es.js.map +1 -1
  37. package/dist/UploadInteraction.cjs.js.map +1 -1
  38. package/dist/UploadInteraction.es.js.map +1 -1
  39. package/dist/colors.cjs.js +2 -0
  40. package/dist/colors.cjs.js.map +1 -0
  41. package/dist/colors.es.js +2 -0
  42. package/dist/colors.es.js.map +1 -0
  43. package/dist/components/UpdatedInteractionDetails.cjs.js +10 -1
  44. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  45. package/dist/components/UpdatedInteractionDetails.es.js +1531 -9
  46. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  47. package/dist/components/chat.cjs.js +30 -1
  48. package/dist/components/chat.cjs.js.map +1 -1
  49. package/dist/components/chat.es.js +2222 -7
  50. package/dist/components/chat.es.js.map +1 -1
  51. package/dist/components/common.cjs.js +1 -1
  52. package/dist/components/common.es.js +32 -25
  53. package/dist/components/common.es.js.map +1 -1
  54. package/dist/components/data.cjs.js +1 -1
  55. package/dist/components/data.cjs.js.map +1 -1
  56. package/dist/components/data.es.js +1033 -4
  57. package/dist/components/data.es.js.map +1 -1
  58. package/dist/components/layout.cjs.js +3 -1
  59. package/dist/components/layout.cjs.js.map +1 -1
  60. package/dist/components/layout.es.js +1533 -8
  61. package/dist/components/layout.es.js.map +1 -1
  62. package/dist/components/login.cjs.js +1 -1
  63. package/dist/components/login.es.js +6 -2
  64. package/dist/components/login.es.js.map +1 -1
  65. package/dist/components/media.cjs.js +1 -1
  66. package/dist/components/media.cjs.js.map +1 -1
  67. package/dist/components/media.es.js +220 -6
  68. package/dist/components/media.es.js.map +1 -1
  69. package/dist/components/models.cjs.js +1 -1
  70. package/dist/components/models.cjs.js.map +1 -1
  71. package/dist/components/models.es.js +91 -2
  72. package/dist/components/models.es.js.map +1 -1
  73. package/dist/components/navigation.cjs.js +1 -1
  74. package/dist/components/navigation.cjs.js.map +1 -1
  75. package/dist/components/navigation.es.js +766 -7
  76. package/dist/components/navigation.es.js.map +1 -1
  77. package/dist/components/notifications.cjs.js +1 -1
  78. package/dist/components/notifications.cjs.js.map +1 -1
  79. package/dist/components/notifications.es.js +368 -3
  80. package/dist/components/notifications.es.js.map +1 -1
  81. package/dist/components/onboarding.cjs.js +1 -1
  82. package/dist/components/onboarding.cjs.js.map +1 -1
  83. package/dist/components/onboarding.es.js +985 -7
  84. package/dist/components/onboarding.es.js.map +1 -1
  85. package/dist/components/primitives.cjs.js +1 -1
  86. package/dist/components/primitives.cjs.js.map +1 -1
  87. package/dist/components/primitives.es.js +635 -25
  88. package/dist/components/primitives.es.js.map +1 -1
  89. package/dist/debugger-wc.cjs.js +4 -4
  90. package/dist/debugger-wc.cjs.js.map +1 -1
  91. package/dist/debugger-wc.es.js +15 -11
  92. package/dist/debugger-wc.es.js.map +1 -1
  93. package/dist/index.cjs.js +1 -1
  94. package/dist/index.cjs2.js +2 -49
  95. package/dist/index.cjs2.js.map +1 -1
  96. package/dist/index.cjs3.js +50 -0
  97. package/dist/index.cjs3.js.map +1 -0
  98. package/dist/index.es.js +104 -99
  99. package/dist/index.es.js.map +1 -1
  100. package/dist/index.es2.js +2632 -1776
  101. package/dist/index.es2.js.map +1 -1
  102. package/dist/index.es3.js +1944 -0
  103. package/dist/index.es3.js.map +1 -0
  104. package/dist/pages/interactionDetails.cjs.js +1 -1
  105. package/dist/pages/interactionDetails.cjs.js.map +1 -1
  106. package/dist/pages/interactionDetails.es.js +70 -47
  107. package/dist/pages/interactionDetails.es.js.map +1 -1
  108. package/dist/sortable.esm.cjs.js +1 -1
  109. package/dist/sortable.esm.cjs.js.map +1 -1
  110. package/dist/sortable.esm.es.js +55 -53
  111. package/dist/sortable.esm.es.js.map +1 -1
  112. package/dist/{chordia-ui.css → style.css} +1 -1
  113. package/package.json +1 -1
  114. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +318 -77
  115. package/src/components/UpdatedInteractionDetails/UpdatedInteractionRecording.jsx +7 -17
  116. package/dist/ChartRenderer.cjs.js +0 -31
  117. package/dist/ChartRenderer.cjs.js.map +0 -1
  118. package/dist/ChartRenderer.es.js +0 -2210
  119. package/dist/ChartRenderer.es.js.map +0 -1
  120. package/dist/GettingStarted.cjs.js +0 -2
  121. package/dist/GettingStarted.cjs.js.map +0 -1
  122. package/dist/GettingStarted.es.js +0 -983
  123. package/dist/GettingStarted.es.js.map +0 -1
  124. package/dist/InlineConfirm.cjs.js +0 -2
  125. package/dist/InlineConfirm.cjs.js.map +0 -1
  126. package/dist/InlineConfirm.es.js +0 -618
  127. package/dist/InlineConfirm.es.js.map +0 -1
  128. package/dist/InteractionSummaryCard.cjs.js +0 -2
  129. package/dist/InteractionSummaryCard.cjs.js.map +0 -1
  130. package/dist/InteractionSummaryCard.es.js +0 -216
  131. package/dist/InteractionSummaryCard.es.js.map +0 -1
  132. package/dist/LoginPage.cjs.js +0 -3
  133. package/dist/LoginPage.cjs.js.map +0 -1
  134. package/dist/LoginPage.es.js +0 -2618
  135. package/dist/LoginPage.es.js.map +0 -1
  136. package/dist/NavigationBar.cjs.js +0 -2
  137. package/dist/NavigationBar.cjs.js.map +0 -1
  138. package/dist/NavigationBar.es.js +0 -762
  139. package/dist/NavigationBar.es.js.map +0 -1
  140. package/dist/NotificationPanel.cjs.js +0 -2
  141. package/dist/NotificationPanel.cjs.js.map +0 -1
  142. package/dist/NotificationPanel.es.js +0 -371
  143. package/dist/NotificationPanel.es.js.map +0 -1
  144. package/dist/OverlayPanel.cjs.js +0 -2
  145. package/dist/OverlayPanel.cjs.js.map +0 -1
  146. package/dist/OverlayPanel.es.js +0 -93
  147. package/dist/OverlayPanel.es.js.map +0 -1
  148. package/dist/SplitPane.cjs.js +0 -4
  149. package/dist/SplitPane.cjs.js.map +0 -1
  150. package/dist/SplitPane.es.js +0 -1531
  151. package/dist/SplitPane.es.js.map +0 -1
  152. package/dist/SummaryStatsPanel.cjs.js +0 -2
  153. package/dist/SummaryStatsPanel.cjs.js.map +0 -1
  154. package/dist/SummaryStatsPanel.es.js +0 -1027
  155. package/dist/SummaryStatsPanel.es.js.map +0 -1
  156. package/dist/UpdatedInteractionDetails.cjs.js +0 -11
  157. package/dist/UpdatedInteractionDetails.cjs.js.map +0 -1
  158. package/dist/UpdatedInteractionDetails.es.js +0 -1310
  159. package/dist/UpdatedInteractionDetails.es.js.map +0 -1
@@ -0,0 +1,1944 @@
1
+ import { b as y, _ as r, a as S, c as be, h as j, r as R, s as zi, E as he, X as Yi, Z as Qi } from "./index.es2.js";
2
+ const Ge = typeof localStorage < "u", Gt = "J151000", Xi = "J151001", kt = "E103205", Zi = "E102004", es = "E103202", ts = Ge && localStorage.getItem("base.content.url") || "", is = "https://static.descope.com/pages", ss = "v2-beta", os = "v2-alpha", ns = "config.json", At = "base.ui.components.url";
3
+ Ge && localStorage.getItem(At), Ge && localStorage.getItem(At);
4
+ const ot = "descope-login-flow", nt = "t", rt = "code", Jt = "redirect_mode", at = "err", rs = "ra-challenge", as = "ra-callback", ls = "ra-backup-callback", cs = "ra-initiator", ds = "data-descope-", lt = "data-exclude-field", Et = "data-exclude-next", zt = "dls_last_auth", Yt = "state_id", Qt = "saml_idp_state_id", Xt = "saml_idp_username", Zt = "descope_idp_initiated", ei = "sso_app_id", ti = "third_party_app_id", ii = "third_party_app_state_id", si = "oidc_login_hint", oi = "oidc_prompt", ni = "oidc_resource", ri = "oidc_error_redirect_uri", ai = "application_scopes", Fe = "data-type", us = "sdkScriptsResults", K = { redirect: "redirect", poll: "poll", webauthnCreate: "webauthnCreate", webauthnGet: "webauthnGet", nativeBridge: "nativeBridge", loadForm: "loadForm" }, pe = { submit: "submit", polling: "polling" }, hs = "data-has-dynamic-attr-values", ps = ["descope-multi-select-combo-box", "descope-text-area"], li = 5e3, gs = ["cssVars", "componentsConfig", "inputs", "errorText", "errorType", "clientScripts"];
5
+ var Ne;
6
+ (function(i) {
7
+ i.backward = "backward", i.forward = "forward";
8
+ })(Ne || (Ne = {}));
9
+ const fs = ["descope-enriched-text"];
10
+ function ms(i, e, t) {
11
+ return (...s) => y(this, void 0, void 0, function* () {
12
+ let o;
13
+ const n = t + 1;
14
+ for (let a = 0; a < n; a++)
15
+ try {
16
+ return yield i(...s);
17
+ } catch (l) {
18
+ o = l, a < t && (yield new Promise((d) => {
19
+ setTimeout(d, e * Math.pow(2, a + 1));
20
+ }));
21
+ }
22
+ throw o;
23
+ });
24
+ }
25
+ function x(i) {
26
+ return new URLSearchParams(window.location.search).get(i);
27
+ }
28
+ function $(i) {
29
+ if (window.history.replaceState && x(i)) {
30
+ const e = new URL(window.location.href), t = new URLSearchParams(e.search);
31
+ t.delete(i), e.search = t.toString(), window.history.replaceState({}, "", e.toString());
32
+ }
33
+ }
34
+ function vs(i, e) {
35
+ return y(this, void 0, void 0, function* () {
36
+ const t = yield fetch(i, { cache: "default" });
37
+ if (!t.ok)
38
+ throw Error(`Error fetching URL ${i} [${t.status}]`);
39
+ return { body: yield t[e](), headers: Object.fromEntries(t.headers.entries()) };
40
+ });
41
+ }
42
+ function bs({ projectId: i, filename: e, assetsFolder: t = ss, baseUrl: s }) {
43
+ const o = new URL(ts || s || is);
44
+ return o.pathname = ((...n) => n.join("/").replace(/\/+/g, "/"))(o.pathname, i, t, e), o.toString();
45
+ }
46
+ function ws(i, e) {
47
+ if (!e)
48
+ return;
49
+ const t = +i, s = +e;
50
+ return Number.isNaN(t) || Number.isNaN(s) ? void 0 : t > s ? Ne.forward : t < s ? Ne.backward : void 0;
51
+ }
52
+ const ci = (i) => {
53
+ let [e = "", t = ""] = (x(ot) || "").split("_");
54
+ const s = ((o) => {
55
+ var n;
56
+ return ((n = /(.*)\|#\|.*/.exec(o)) === null || n === void 0 ? void 0 : n[1]) || "";
57
+ })(e);
58
+ return (!i || s && s !== i) && (e = "", t = ""), { executionId: e, stepId: t, executionFlowId: s };
59
+ };
60
+ function ys() {
61
+ return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
62
+ }
63
+ function di() {
64
+ $(ot);
65
+ }
66
+ function Cs() {
67
+ return x(nt) || void 0;
68
+ }
69
+ function Ss() {
70
+ $(nt);
71
+ }
72
+ function ks() {
73
+ return x(rt) || void 0;
74
+ }
75
+ function As() {
76
+ return x(Jt) === "popup";
77
+ }
78
+ function Es() {
79
+ return x(at) || void 0;
80
+ }
81
+ function xs() {
82
+ $(rt);
83
+ }
84
+ function Is() {
85
+ $(Jt);
86
+ }
87
+ function _s() {
88
+ $(at);
89
+ }
90
+ function $s() {
91
+ return { redirectAuthCodeChallenge: x(rs), redirectAuthCallbackUrl: x(as), redirectAuthBackupCallbackUri: x(ls), redirectAuthInitiator: x(cs) };
92
+ }
93
+ function Os() {
94
+ return x(Yt);
95
+ }
96
+ function Ms() {
97
+ $(Yt);
98
+ }
99
+ function Us() {
100
+ return x(Qt);
101
+ }
102
+ function js() {
103
+ $(Qt);
104
+ }
105
+ function Rs() {
106
+ return x(Xt);
107
+ }
108
+ function Ts() {
109
+ $(Xt);
110
+ }
111
+ function Ls() {
112
+ return x(Zt);
113
+ }
114
+ function Ws() {
115
+ $(Zt);
116
+ }
117
+ function Ps() {
118
+ return x(ei);
119
+ }
120
+ function Ns() {
121
+ return x(ti);
122
+ }
123
+ function Ds() {
124
+ $(ei);
125
+ }
126
+ function Fs() {
127
+ $(ti);
128
+ }
129
+ function Vs() {
130
+ return x(ii);
131
+ }
132
+ function Bs() {
133
+ $(ii);
134
+ }
135
+ function qs() {
136
+ return x(ai);
137
+ }
138
+ function Ks() {
139
+ $(ai);
140
+ }
141
+ function Hs() {
142
+ return x(si);
143
+ }
144
+ function Gs() {
145
+ $(si);
146
+ }
147
+ function Js() {
148
+ return x(oi);
149
+ }
150
+ function zs() {
151
+ $(oi);
152
+ }
153
+ function Ys() {
154
+ return x(ri);
155
+ }
156
+ function Qs() {
157
+ $(ri);
158
+ }
159
+ function Xs() {
160
+ return x(ni);
161
+ }
162
+ function Zs() {
163
+ $(ni);
164
+ }
165
+ const ui = (i) => i.replace(/-./g, (e) => e[1].toUpperCase()), eo = (i, e) => (t) => i[t] !== e[t], to = (i) => Array.from((i == null ? void 0 : i.attributes) || []).reduce((e, t) => {
166
+ var s;
167
+ const o = (s = new RegExp(`^${ds}(\\S+)$`).exec(t.name)) === null || s === void 0 ? void 0 : s[1];
168
+ return o ? Object.assign(e, { [o]: t.value }) : e;
169
+ }, {}), io = (i, e) => {
170
+ const { executionId: t, stepId: s, executionFlowId: o } = ci(i);
171
+ if (o && i !== o)
172
+ return e.debug("Flow id does not match the execution flow id, skipping url params handling"), { ssoQueryParams: {} };
173
+ (t || s) && di();
174
+ const n = Cs();
175
+ n && Ss();
176
+ const a = ks();
177
+ a && xs();
178
+ const l = As();
179
+ l && Is();
180
+ const d = Es();
181
+ d && _s();
182
+ const { redirectAuthCodeChallenge: u, redirectAuthCallbackUrl: c, redirectAuthBackupCallbackUri: h, redirectAuthInitiator: p } = $s(), m = Os();
183
+ m && Ms();
184
+ const v = Us();
185
+ v && js();
186
+ const A = Rs();
187
+ v && Ts();
188
+ const C = Ls();
189
+ C && Ws();
190
+ const g = Ps();
191
+ g && Ds();
192
+ const f = Ns();
193
+ f && Fs();
194
+ const b = Vs();
195
+ b && Bs();
196
+ const k = qs();
197
+ k && Ks();
198
+ const T = Hs();
199
+ T && Gs();
200
+ const L = Js();
201
+ L && zs();
202
+ const P = Ys();
203
+ P && Qs();
204
+ const D = Xs();
205
+ return D && Zs(), { executionId: t, stepId: s, token: n, code: a, isPopup: l, exchangeError: d, redirectAuthCodeChallenge: u, redirectAuthCallbackUrl: c, redirectAuthBackupCallbackUri: h, redirectAuthInitiator: p, ssoQueryParams: { oidcIdpStateId: m, samlIdpStateId: v, samlIdpUsername: A, descopeIdpInitiated: C === "true", ssoAppId: g, oidcLoginHint: T, oidcPrompt: L, oidcErrorRedirectUri: P, oidcResource: D, thirdPartyAppId: f, thirdPartyAppStateId: b, applicationScopes: k } };
206
+ }, hi = (i) => {
207
+ let e, t;
208
+ return Object.assign((...s) => {
209
+ return e && (n = s, (o = e).length === n.length && o.every((a, l) => a === n[l])) || (e = s, t = i(...s)), t;
210
+ var o, n;
211
+ }, { reset: () => {
212
+ e = void 0, t = void 0;
213
+ } });
214
+ }, so = '*[name]:not([auto-focus="false"]):not([aria-hidden="true"])', pi = (i, e, t) => {
215
+ if (e === !0 || e === "skipFirstScreen" && !t) {
216
+ const s = i.querySelector(so);
217
+ setTimeout(() => {
218
+ s == null || s.focus();
219
+ });
220
+ }
221
+ }, oo = (i) => {
222
+ i.querySelectorAll("*[name]").forEach((e) => {
223
+ e.addEventListener("blur", () => {
224
+ var t;
225
+ const s = () => {
226
+ var a;
227
+ const l = e.focus;
228
+ e.focus = () => {
229
+ }, (a = e.reportValidity) === null || a === void 0 || a.call(e), setTimeout(() => {
230
+ e.focus = l;
231
+ });
232
+ };
233
+ if (e.getAttribute("invalid") === "true" || !((t = e.value) === null || t === void 0) && t.length)
234
+ return void s();
235
+ const o = { timer: void 0 }, n = (a) => {
236
+ a.target.getAttribute("formnovalidate") === "true" && (clearTimeout(o.timer), o.timer = void 0);
237
+ };
238
+ o.timer = setTimeout(() => {
239
+ i.removeEventListener("click", n), s(), o.timer = void 0;
240
+ }, 150), i.addEventListener("click", n, { once: !0 });
241
+ });
242
+ });
243
+ };
244
+ function ct(i, e, t) {
245
+ return new Promise((s, o) => {
246
+ let n = !1;
247
+ const a = setTimeout(() => {
248
+ n = !0, t !== void 0 ? s(t) : o(new Error(`Promise timed out after ${i} ms`));
249
+ }, i);
250
+ e.then((l) => {
251
+ n || (clearTimeout(a), s(l));
252
+ }).catch((l) => {
253
+ n || (clearTimeout(a), o(l));
254
+ });
255
+ });
256
+ }
257
+ const no = () => {
258
+ var i;
259
+ const e = (i = navigator == null ? void 0 : navigator.userAgentData) === null || i === void 0 ? void 0 : i.brands, t = e == null ? void 0 : e.find(({ brand: s, version: o }) => s === "Chromium" && parseFloat(o));
260
+ return t ? t.version : 0;
261
+ }, xt = (i, { oidcIdpStateId: e, samlIdpStateId: t, samlIdpUsername: s, ssoAppId: o, oidcLoginHint: n, oidcPrompt: a, oidcErrorRedirectUri: l, oidcResource: d, thirdPartyAppId: u, thirdPartyAppStateId: c, applicationScopes: h }) => !(!i || e || t || s || o || n || a || l || d || u || c || h), ro = (i, e, t, s) => {
262
+ const o = document.createElement("form");
263
+ o.method = "POST", o.action = i, o.innerHTML = `
264
+ <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />
265
+ <input type="hidden" role="saml-relay-state" name="RelayState" value="${t}" />
266
+ <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />
267
+ `, document.body.appendChild(o), s(o);
268
+ }, ao = (i) => i == null ? void 0 : i.submit(), It = (i, e) => {
269
+ const t = e.find((s) => i[s]);
270
+ return t ? i[t] : null;
271
+ }, lo = (i, e = 100) => {
272
+ let t;
273
+ return function(...s) {
274
+ t || i.apply(this, s), clearTimeout(t), t = setTimeout(() => {
275
+ t = null;
276
+ }, e);
277
+ };
278
+ };
279
+ function $e(i) {
280
+ if (i)
281
+ return { locale: i.toLowerCase(), fallback: i.toLowerCase() };
282
+ const e = navigator.language;
283
+ return e ? e.includes("-") ? { locale: e.toLowerCase(), fallback: e.split("-")[0].toLowerCase() } : { locale: e.toLowerCase(), fallback: e.toLowerCase() } : { locale: "", fallback: "" };
284
+ }
285
+ const co = () => {
286
+ document.querySelectorAll('[data-hidden-input="true"]').forEach((i) => i.remove());
287
+ }, uo = (i) => fs.includes(i), ho = (i) => {
288
+ var e, t, s;
289
+ const o = (n = i.screenState, a = (u, c) => gs.includes(c) || c.startsWith("_"), Object.fromEntries(Object.entries(n).filter(([u, c]) => !a(c, u))));
290
+ var n, a;
291
+ const { screenState: { errorText: l, errorType: d } } = i;
292
+ return (l || d) && (o.error = { text: l, type: d }), i.action && (o.action = i.action), !((s = (t = (e = i.screenState) === null || e === void 0 ? void 0 : e.componentsConfig) === null || t === void 0 ? void 0 : t.thirdPartyAppApproveScopes) === null || s === void 0) && s.data && (o.inboundAppApproveScopes = i.screenState.componentsConfig.thirdPartyAppApproveScopes.data), o;
293
+ }, _t = (i) => {
294
+ const e = Object.assign({}, i);
295
+ return i.inboundAppApproveScopes && (e.thirdPartyAppApproveScopes = i.inboundAppApproveScopes), e;
296
+ };
297
+ function po(i, e) {
298
+ return `${us}.${e ? `${i}_${e}` : i}`;
299
+ }
300
+ const go = (i, e, t, s) => {
301
+ const o = window.screenLeft !== void 0 ? window.screenLeft : window.screen.left, n = window.screenTop !== void 0 ? window.screenTop : window.screen.top, a = ((window.innerWidth || document.documentElement.clientWidth || window.screen.width) - t) / 2 + o, l = ((window.innerHeight || document.documentElement.clientHeight || window.screen.height) - s) / 2 + n, d = function() {
302
+ const c = navigator.userAgent || "", h = /\b(iPhone)\b/.test(c), p = /Safari/.test(c) && !/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(c);
303
+ return h && p;
304
+ }() ? "about:blank" : "", u = window.open(d, e, `width=${t},height=${s},top=${l},left=${a},scrollbars=yes,resizable=yes`);
305
+ return u.location.href = i, u.focus(), u;
306
+ };
307
+ var H, ie, re, ge;
308
+ function gi(i, e) {
309
+ const t = Object.getOwnPropertyNames(i), s = Object.getOwnPropertyNames(e);
310
+ if (t.length !== s.length)
311
+ return !1;
312
+ for (let o = 0; o < t.length; o += 1) {
313
+ const n = t[o], a = i[n], l = e[n];
314
+ if (a === null || l === null) {
315
+ if (a !== l)
316
+ return !1;
317
+ } else if (typeof a == "object" && typeof l == "object") {
318
+ if (!gi(a, l))
319
+ return !1;
320
+ } else if (a !== l)
321
+ return !1;
322
+ }
323
+ return !0;
324
+ }
325
+ class we {
326
+ constructor(e = {}, { forceUpdate: t = !1 } = {}) {
327
+ H.set(this, void 0), ie.set(this, {}), re.set(this, 0), ge.set(this, !0), this.update = (s) => {
328
+ const o = typeof s == "function" ? s(r(this, H, "f")) : s, n = Object.assign(Object.assign({}, r(this, H, "f")), o), a = r(this, H, "f");
329
+ S(this, H, n, "f"), Object.freeze(r(this, H, "f")), setTimeout(() => {
330
+ Object.values(r(this, ie, "f")).forEach(({ cb: l, selector: d, forceUpdate: u }) => {
331
+ const c = d(a), h = d(n);
332
+ (r(this, ge, "f") || u || (function(p) {
333
+ if (typeof p != "object" || p === null)
334
+ return !1;
335
+ const m = Object.getPrototypeOf(p);
336
+ return m === Object.prototype || m === null;
337
+ }(h) ? !gi(c, h) : c !== h)) && l(h, c, eo(h, c));
338
+ });
339
+ }, 0);
340
+ }, S(this, H, e, "f"), S(this, ge, t, "f");
341
+ }
342
+ get current() {
343
+ return Object.assign({}, r(this, H, "f"));
344
+ }
345
+ set forceUpdate(e) {
346
+ S(this, ge, e, "f");
347
+ }
348
+ subscribe(e, t = (o) => o, { forceUpdate: s = !1 } = {}) {
349
+ return S(this, re, r(this, re, "f") + 1, "f"), r(this, ie, "f")[r(this, re, "f")] = { cb: e, selector: t, forceUpdate: s }, r(this, re, "f").toString();
350
+ }
351
+ unsubscribe(e) {
352
+ const t = !!r(this, ie, "f")[e];
353
+ return t && delete r(this, ie, "f")[e], t;
354
+ }
355
+ unsubscribeAll() {
356
+ return S(this, ie, {}, "f"), !0;
357
+ }
358
+ }
359
+ H = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap();
360
+ const fo = ["*", "#", "/", "(", ")", "[", "]", "_", "<", ">", "`"], mo = (i) => {
361
+ const e = fo.map((t) => `${i}${t}`).join("|");
362
+ return new RegExp(`(${e})`, "g");
363
+ }, vo = (i) => typeof i != "string" ? i : i.replace(mo("\\"), "\\$1"), bo = ["disabled"], wo = (i, e, t = "") => {
364
+ i.querySelectorAll(`[${Fe}="${e}"]`).forEach((s) => {
365
+ s.textContent = t, s.classList[t ? "remove" : "add"]("hide");
366
+ });
367
+ }, $t = (i, e) => {
368
+ Object.entries(e || {}).forEach(([t, s]) => {
369
+ Array.from(i.querySelectorAll(`*[name="${t}"]:not([${lt}])`)).forEach((o) => {
370
+ o.value = s;
371
+ });
372
+ });
373
+ }, Ot = (i, e) => e.split(".").reduce((t, s) => (t == null ? void 0 : t[s]) || "", i), Ke = (i, e, t) => i.replace(/{{(.+?)}}/g, (s, o) => t ? vo(Ot(e, o)) : Ot(e, o)), Mt = (i, e, t) => {
374
+ i.querySelectorAll(`[${Fe}="${e}"]`).forEach((s) => {
375
+ s.setAttribute("href", t);
376
+ });
377
+ }, yo = (i, e, t, s) => {
378
+ t && Object.keys(t).forEach((o) => {
379
+ if (!e.querySelector(o))
380
+ return void s.debug(`Skipping css vars for component "${o}"`, `Got css vars for component ${o} but Could not find it on next page`);
381
+ const n = customElements.get(o);
382
+ n ? Object.keys(t[o]).forEach((a) => {
383
+ var l;
384
+ const d = t[o], u = (l = n == null ? void 0 : n.cssVarList) === null || l === void 0 ? void 0 : l[a];
385
+ if (!u)
386
+ return void s.info(`Could not find css variable name for ${a} in ${o}`, "Check if the css variable is defined in the component");
387
+ const c = d[a];
388
+ i.style.setProperty(u, c);
389
+ }) : s.debug(`Could not find component class for ${o}`, "Check if the component is registered");
390
+ });
391
+ }, fi = (i, e, t) => {
392
+ var s, o;
393
+ const n = (s = customElements.get(e)) === null || s === void 0 ? void 0 : s.cssVarList.url;
394
+ t && n && ((o = i == null ? void 0 : i.style) === null || o === void 0 || o.setProperty(n, `url(data:image/jpg;base64,${t})`));
395
+ }, Co = (i, e, t, s) => {
396
+ var o, n;
397
+ Mt(i, "totp-link", (o = e == null ? void 0 : e.totp) === null || o === void 0 ? void 0 : o.provisionUrl), Mt(i, "notp-link", (n = e == null ? void 0 : e.notp) === null || n === void 0 ? void 0 : n.redirectUrl), ((a, l) => {
398
+ a.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((d) => {
399
+ const u = uo(d.localName);
400
+ d.textContent = Ke(d.textContent, l, u);
401
+ const c = d.getAttribute("href");
402
+ c && d.setAttribute("href", Ke(c, l));
403
+ });
404
+ })(i, e), ((a, l, d) => {
405
+ if (!l)
406
+ return;
407
+ const { componentsDynamicAttrs: u } = l, c = be(l, ["componentsDynamicAttrs"]), h = Object.keys(c).reduce((p, m) => (p[`[name=${m}]`] = c[m], p), {});
408
+ u && Object.keys(u).forEach((p) => {
409
+ const m = u[p];
410
+ if (m) {
411
+ const { attributes: v } = m;
412
+ v && Object.keys(v).length && (h[p] = v);
413
+ }
414
+ }), Object.keys(h).forEach((p) => {
415
+ a.querySelectorAll(p).forEach((m) => {
416
+ const v = h[p];
417
+ Object.keys(v).forEach((A) => {
418
+ let C = v[A];
419
+ if (typeof C != "string")
420
+ try {
421
+ C = JSON.stringify(C);
422
+ } catch (g) {
423
+ d.error(`Could not stringify value "${C}" for "${A}"`, g.message), C = "";
424
+ }
425
+ m.setAttribute(A, C);
426
+ });
427
+ });
428
+ });
429
+ })(i, e == null ? void 0 : e.componentsConfig, s), ((a, l) => {
430
+ a.querySelectorAll(`[${hs}]`).forEach((d) => {
431
+ Array.from(d.attributes).forEach((u) => {
432
+ u.value = Ke(u.value, l);
433
+ });
434
+ });
435
+ })(i, e), ((a, l) => {
436
+ Object.entries(l).forEach(([d, u]) => {
437
+ a.querySelectorAll(`[name="${d}"]`).forEach((c) => {
438
+ Object.entries(u).forEach(([h, p]) => {
439
+ bo.includes(h) && c.setAttribute(h, p);
440
+ });
441
+ });
442
+ });
443
+ })(i, t), ((a, l = {}, d) => {
444
+ Object.entries(l).forEach(([u, c]) => {
445
+ a.querySelectorAll(`[id="${CSS.escape(u)}"]`).forEach((h) => {
446
+ switch (c) {
447
+ case "disable":
448
+ h.setAttribute("disabled", "true");
449
+ break;
450
+ case "hide":
451
+ h.classList.add("hidden");
452
+ break;
453
+ default:
454
+ d == null || d.error(`Unknown component state "${c}" for component with id "${u}"`, 'Valid states are "disable" and "hide"');
455
+ }
456
+ });
457
+ });
458
+ })(i, e == null ? void 0 : e.componentsState, s);
459
+ }, So = (i, e) => {
460
+ $t(i, e == null ? void 0 : e.inputs), $t(i, e == null ? void 0 : e.form);
461
+ }, ko = (i, e) => {
462
+ fi(i, "descope-totp-image", e);
463
+ }, Ao = (i, e) => {
464
+ fi(i, "descope-notp-image", e);
465
+ }, Eo = (i, e) => {
466
+ Object.entries({ "default-code": "autoDetect", "default-country": "autoDetect" }).forEach(([t, s]) => {
467
+ Array.from(i.querySelectorAll(`[${t}="${s}"]`)).forEach((o) => {
468
+ o.setAttribute(t, e || s);
469
+ });
470
+ });
471
+ }, xo = (i, e) => {
472
+ Object.entries({ lang: "autoDetect" }).forEach(([t, s]) => {
473
+ Array.from(i.querySelectorAll(`[${t}="${s}"]`)).forEach((o) => {
474
+ o.setAttribute(t, e || s);
475
+ });
476
+ });
477
+ }, Io = (i) => {
478
+ i.querySelectorAll(`descope-button[${Fe}="biometrics"]`).forEach((e) => e.setAttribute("disabled", "true"));
479
+ }, _o = hi(() => y(void 0, void 0, void 0, function* () {
480
+ var i, e;
481
+ if (!window.PublicKeyCredential || !PublicKeyCredential.isConditionalMediationAvailable || !PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)
482
+ return !1;
483
+ try {
484
+ const t = Promise.all([(i = window.PublicKeyCredential) === null || i === void 0 ? void 0 : i.isConditionalMediationAvailable(), (e = window.PublicKeyCredential) === null || e === void 0 ? void 0 : e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((o) => o.every((n) => !!n)), s = no() >= 108;
485
+ return yield ct(100, t, s);
486
+ } catch (t) {
487
+ return console.error("Conditional login check failed", t), !1;
488
+ }
489
+ }));
490
+ let Se;
491
+ const mi = (i, e) => {
492
+ Se ? Se.setItem(i, e) : (window == null ? void 0 : window.localStorage) !== void 0 && window.localStorage.setItem(i, e);
493
+ }, vi = (i) => Se ? Se.getItem(i) : (window == null ? void 0 : window.localStorage) !== void 0 ? window.localStorage.getItem(i) : null, $o = (i) => {
494
+ Se = i;
495
+ }, Ut = "dls_ab_testing_id", Oo = () => {
496
+ const i = vi(Ut);
497
+ if (!i) {
498
+ const e = Math.floor(100 * Math.random() + 1);
499
+ return mi(Ut, e.toString()), e;
500
+ }
501
+ return Number(i);
502
+ }, bi = { "lastAuth.loginId": { "not-empty": (i) => {
503
+ var e;
504
+ return !!i.loginId || !!(!((e = i.lastAuth) === null || e === void 0) && e.loginId);
505
+ }, empty: (i) => {
506
+ var e;
507
+ return !i.loginId && !(!((e = i.lastAuth) === null || e === void 0) && e.loginId);
508
+ } }, idpInitiated: { "is-true": (i) => !!i.code, "is-false": (i) => !i.code }, externalToken: { "is-true": (i) => !!i.token, "is-false": (i) => !i.token }, abTestingKey: { "greater-than": (i, e) => (i.abTestingKey || 0) > e, "less-than": (i, e) => (i.abTestingKey || 0) < e, "greater-than-or-equal": (i, e) => (i.abTestingKey || 0) >= e, "less-than-or-equal": (i, e) => (i.abTestingKey || 0) <= e, "in-range": (i, e) => {
509
+ const [t, s] = e ? e.split(",").map(Number) : [void 0, void 0];
510
+ return (i.abTestingKey || 0) >= (t ?? 0) && (i.abTestingKey || 0) <= (s ?? 0);
511
+ }, "not-in-range": (i, e) => {
512
+ const [t, s] = e ? e.split(",").map(Number) : [void 0, void 0];
513
+ return !(t !== void 0 && s !== void 0 && !Number.isNaN(t) && !Number.isNaN(s)) || (i.abTestingKey || 0) < t || (i.abTestingKey || 0) > s;
514
+ }, "devised-by": (i, e) => {
515
+ const t = Number(e);
516
+ return !Number.isNaN(t) && (i.abTestingKey || 0) % t == 0;
517
+ } } }, Mo = (i, e) => {
518
+ var t;
519
+ const s = (t = bi[i == null ? void 0 : i.key]) === null || t === void 0 ? void 0 : t[i.operator];
520
+ if (!s)
521
+ return {};
522
+ const o = s(e, i.predicate) ? i.met : i.unmet;
523
+ return { startScreenId: o == null ? void 0 : o.screenId, startScreenName: o == null ? void 0 : o.screenName, conditionInteractionId: o == null ? void 0 : o.interactionId };
524
+ }, Uo = (i, e) => {
525
+ const t = e == null ? void 0 : e.find(({ key: s, operator: o, predicate: n }) => {
526
+ var a;
527
+ if (s === "ELSE")
528
+ return !0;
529
+ const l = (a = bi[s]) === null || a === void 0 ? void 0 : a[o];
530
+ return !!(l != null && l(i, n));
531
+ });
532
+ return t ? { startScreenId: t.met.screenId, startScreenName: t.met.screenName, conditionInteractionId: t.met.interactionId, clientScripts: t.met.clientScripts, componentsConfig: t.met.componentsConfig } : {};
533
+ };
534
+ function Oe(i) {
535
+ const e = {};
536
+ try {
537
+ Object.assign(e, JSON.parse(vi(zt)));
538
+ } catch {
539
+ }
540
+ return e != null && e.loginId || i ? e : {};
541
+ }
542
+ function jt(i, e) {
543
+ i != null && i.authMethod && (e && !(i != null && i.loginId) || mi(zt, JSON.stringify(i)));
544
+ }
545
+ const jo = ["error", "warn", "info", "debug"], Rt = {
546
+ error: console.error.bind(console, "[Descope]"),
547
+ warn: console.warn.bind(console, "[Descope]"),
548
+ info: console.info.bind(console, "[Descope]"),
549
+ debug: console.debug.bind(console, "[Descope]")
550
+ }, ke = j((i) => {
551
+ var e, t, s, o;
552
+ return o = class extends i {
553
+ constructor() {
554
+ super(...arguments), e.add(this), t.set(this, r(this, e, "m", s).call(this, Rt));
555
+ }
556
+ set logger(a) {
557
+ S(this, t, r(this, e, "m", s).call(this, a || Rt), "f");
558
+ }
559
+ get logger() {
560
+ return r(this, t, "f");
561
+ }
562
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
563
+ onLogEvent(a, l) {
564
+ }
565
+ }, t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakSet(), s = function(a) {
566
+ return jo.reduce((l, d) => (l[d] = (...u) => {
567
+ var c;
568
+ this.onLogEvent(d, u), (c = a[d]) === null || c === void 0 || c.call(a, ...u);
569
+ }, l), {});
570
+ }, o;
571
+ }), wi = typeof localStorage < "u", Ro = "base.content.url", Ue = "https://static.descope.com/pages", Tt = "https://static2.descope.com/pages", To = wi && localStorage.getItem(Ro) || "", Lo = "v2-beta", dt = (i, e) => !e && `${i} cannot be empty, please make sure to set this attribute`, Ae = j((i) => {
572
+ var e, t;
573
+ return t = class extends i {
574
+ constructor() {
575
+ super(...arguments), e.set(this, !0);
576
+ }
577
+ connectedCallback() {
578
+ var o, n;
579
+ (o = super.connectedCallback) === null || o === void 0 || o.call(this), !((n = this.shadowRoot) === null || n === void 0) && n.isConnected && r(this, e, "f") && (S(this, e, !1, "f"), this.init());
580
+ }
581
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
582
+ async init() {
583
+ }
584
+ }, e = /* @__PURE__ */ new WeakMap(), t;
585
+ }), Wo = (i, e) => {
586
+ Array.from(i.attributes).forEach((s) => e(s.name)), new MutationObserver((s) => {
587
+ s.forEach((o) => {
588
+ o.type === "attributes" && e(o.attributeName);
589
+ });
590
+ }).observe(i, { attributes: !0 });
591
+ }, ut = j((i) => {
592
+ var e, t;
593
+ const s = R(ke, Ae)(i);
594
+ return t = class extends s {
595
+ constructor() {
596
+ super(...arguments), e.set(this, {});
597
+ }
598
+ async init() {
599
+ var n;
600
+ await ((n = super.init) === null || n === void 0 ? void 0 : n.call(this)), Wo(this, (a) => {
601
+ var l;
602
+ (l = r(this, e, "f")[a]) === null || l === void 0 || l.forEach((d) => {
603
+ d(a, this.getAttribute(a));
604
+ });
605
+ });
606
+ }
607
+ observeAttribute(n, a) {
608
+ r(this, e, "f")[n] || (r(this, e, "f")[n] = []);
609
+ const l = r(this, e, "f")[n].push(a);
610
+ return () => r(this, e, "f")[n].splice(l, 1);
611
+ }
612
+ observeAttributes(n, a) {
613
+ const l = n.reduce((d, u) => (d.push(this.observeAttribute(u, a)), d), []);
614
+ return () => l.forEach((d) => d());
615
+ }
616
+ }, e = /* @__PURE__ */ new WeakMap(), t;
617
+ }), Ve = (i) => (e) => {
618
+ var t, s, o;
619
+ const n = R(ke, Ae, ut)(e), a = Object.keys(i);
620
+ return o = class extends n {
621
+ constructor(...d) {
622
+ super(...d), t.add(this), this.observeAttributes(a, r(this, t, "m", s).bind(this));
623
+ }
624
+ async init() {
625
+ var d;
626
+ a.forEach((u) => r(this, t, "m", s).call(this, u, this.getAttribute(u))), await ((d = super.init) === null || d === void 0 ? void 0 : d.call(this));
627
+ }
628
+ }, t = /* @__PURE__ */ new WeakSet(), s = function(d, u) {
629
+ const c = i[d], h = typeof c == "function" ? c(d, u) : c;
630
+ h && this.logger.error(h);
631
+ }, o;
632
+ };
633
+ Ve.missingAttrValidator = dt;
634
+ const Po = j((i) => {
635
+ const e = R(Ve({ "project-id": dt }))(i);
636
+ return class extends e {
637
+ get projectId() {
638
+ return this.getAttribute("project-id");
639
+ }
640
+ };
641
+ }), No = j((i) => class extends i {
642
+ get baseUrl() {
643
+ return this.getAttribute("base-url") || "";
644
+ }
645
+ }), Lt = "Trying the next fallback URL...", Do = async (i, e, { logger: t } = {}) => {
646
+ try {
647
+ return await fetch(i, e);
648
+ } catch (s) {
649
+ return t == null || t.debug(`Network error fetching URL ${i} [${s.message}], retrying...`), fetch(i, e);
650
+ }
651
+ }, Fo = async (i, e, { logger: t, onSuccess: s } = {}) => {
652
+ const o = Array.isArray(i) ? i : [i];
653
+ for (let n = 0; n < o.length; n++) {
654
+ const a = o[n], l = n === o.length - 1;
655
+ try {
656
+ const d = await Do(a.toString(), e, { logger: t });
657
+ if (d.ok)
658
+ return s == null || s(n), t == null || t.debug(`Successfully fetched URL ${a}`), d;
659
+ const u = `Error fetching URL ${a} [${d.status}]`;
660
+ if (l)
661
+ throw new Error(u);
662
+ t == null || t.debug(`${u}. ${Lt}`);
663
+ } catch (d) {
664
+ const u = `Error fetching URL ${a} [${d.message}]`;
665
+ if (l)
666
+ throw new Error(u);
667
+ t == null || t.debug(`${u}. ${Lt}`);
668
+ }
669
+ }
670
+ };
671
+ function Vo({ projectId: i, filename: e, assetsFolder: t = Lo, baseUrl: s = Ue }) {
672
+ const o = new URL(s);
673
+ return o.pathname = zi(o.pathname, i, t, e), o.baseUrl = s, o;
674
+ }
675
+ const ht = j((i) => {
676
+ var e, t, s, o, n, a, l;
677
+ const d = R(ke, Po, No)(i);
678
+ return l = class extends d {
679
+ constructor() {
680
+ super(...arguments), e.add(this), t.set(this, void 0), s.set(this, void 0), o.set(this, /* @__PURE__ */ new Set());
681
+ }
682
+ async fetchStaticResource(c, h) {
683
+ const p = r(this, e, "m", n).call(this, c), m = Array.isArray(p) ? (v) => {
684
+ const { baseUrl: A } = p[v];
685
+ S(this, s, A, "f");
686
+ for (let C = 0; C < v; C++) {
687
+ const g = p[C].baseUrl;
688
+ r(this, o, "f").add(g);
689
+ }
690
+ } : null;
691
+ try {
692
+ const v = await Fo(p, { cache: "default" }, { logger: this.logger, onSuccess: m });
693
+ return {
694
+ body: await v[h](),
695
+ headers: Object.fromEntries(v.headers.entries())
696
+ };
697
+ } catch (v) {
698
+ this.logger.error(v.message);
699
+ }
700
+ }
701
+ get baseStaticUrl() {
702
+ return this.getAttribute("base-static-url") || "";
703
+ }
704
+ }, t = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakSet(), n = function(c) {
705
+ const h = To || this.baseStaticUrl;
706
+ if (h)
707
+ return r(this, e, "m", a).call(this, c, h);
708
+ r(this, t, "f") !== this.baseUrl && (S(this, t, this.baseUrl, "f"), S(this, s, void 0, "f"), r(this, o, "f").clear());
709
+ const p = [];
710
+ if (r(this, s, "f"))
711
+ p.push(r(this, e, "m", a).call(this, c, r(this, s, "f"))), r(this, s, "f") === Ue && p.push(r(this, e, "m", a).call(this, c, Tt));
712
+ else {
713
+ const m = this.baseUrl + "/pages";
714
+ this.baseUrl && !r(this, o, "f").has(m) && p.push(r(this, e, "m", a).call(this, c, m)), r(this, o, "f").has(Ue) || p.push(r(this, e, "m", a).call(this, c, Ue)), p.push(r(this, e, "m", a).call(this, c, Tt));
715
+ }
716
+ return p.length === 1 ? p[0] : p;
717
+ }, a = function(c, h) {
718
+ return Vo({
719
+ projectId: this.projectId,
720
+ filename: c,
721
+ baseUrl: h
722
+ });
723
+ }, l;
724
+ }), Bo = "config.json", qo = j((i) => {
725
+ var e, t;
726
+ const s = R(Ve({ "project-id": dt }))(i);
727
+ return t = class extends s {
728
+ constructor() {
729
+ super(...arguments), e.set(this, /* @__PURE__ */ new Map());
730
+ }
731
+ onReset(n, a) {
732
+ if (r(this, e, "f").has(n))
733
+ throw new Error(`Callback for sectionId ${n} already exists`);
734
+ return r(this, e, "f").set(n, a), () => {
735
+ r(this, e, "f").delete(n);
736
+ };
737
+ }
738
+ async reset(...n) {
739
+ n.length === 0 ? await Promise.all(Array.from(r(this, e, "f").values()).map((a) => a())) : await Promise.all(n.map((a) => {
740
+ var l;
741
+ if (!r(this, e, "f").has(a))
742
+ throw new Error(`Callback for sectionId ${a} does not exist`);
743
+ return (l = r(this, e, "f").get(a)) === null || l === void 0 ? void 0 : l();
744
+ }));
745
+ }
746
+ }, e = /* @__PURE__ */ new WeakMap(), t;
747
+ }), yi = j((i) => {
748
+ var e, t, s, o, n;
749
+ const a = R(ht, qo, Ae)(i);
750
+ return n = class extends a {
751
+ constructor() {
752
+ super(...arguments), e.add(this), s.set(this, void 0), o.set(this, async () => {
753
+ try {
754
+ const { body: d, headers: u } = await this.fetchStaticResource(Bo, "json");
755
+ return {
756
+ projectConfig: d,
757
+ executionContext: { geo: u["x-geo"] }
758
+ };
759
+ } catch {
760
+ this.logger.error("Cannot fetch config file", "make sure that your projectId & flowId are correct");
761
+ }
762
+ });
763
+ }
764
+ async init() {
765
+ await super.init(), this.onReset("config", r(this, e, "m", t).bind(this));
766
+ }
767
+ get config() {
768
+ return r(this, s, "f") || S(this, s, r(this, o, "f").call(this), "f"), r(this, s, "f");
769
+ }
770
+ }, s = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakSet(), t = function() {
771
+ S(this, s, void 0, "f");
772
+ }, n;
773
+ }), Ko = [
774
+ "https://descopecdn.com",
775
+ "https://static.descope.com",
776
+ "https://cdn.jsdelivr.net"
777
+ ], Ho = (i) => document.querySelector(`script#${i}`), Go = (i) => i.getAttribute("status") === "loaded", Jo = (i) => i.getAttribute("status") === "error", zo = (i) => {
778
+ let e = 0;
779
+ const t = i.toString();
780
+ for (let s = 0; s < t.length; s++) {
781
+ const o = t.charCodeAt(s);
782
+ e = (e << 5) - e + o, e = e & e;
783
+ }
784
+ return `${Math.abs(e).toString()}`;
785
+ }, Yo = (i, e) => {
786
+ const t = document.createElement("script");
787
+ return t.id = i, e && (t.integrity = e, t.crossOrigin = "anonymous"), window.DESCOPE_NONCE && t.setAttribute("nonce", window.DESCOPE_NONCE), t;
788
+ }, Qo = (i, e, t) => new Promise((s, o) => {
789
+ const n = Yo(i, t);
790
+ n.onerror = (a) => {
791
+ n.setAttribute("status", "error"), o(a);
792
+ }, n.onload = () => {
793
+ n.setAttribute("status", "loaded"), s(n);
794
+ }, n.src = e.toString(), document.body.appendChild(n);
795
+ }), Xo = (i, e) => {
796
+ if (e) {
797
+ const t = i.integrity;
798
+ if (t !== e)
799
+ return Promise.reject(new Error(`Integrity mismatch: expected ${e}, found ${t}`));
800
+ }
801
+ return Go(i) ? Promise.resolve(i) : Jo(i) ? Promise.reject() : new Promise((t, s) => {
802
+ i.addEventListener("load", () => {
803
+ t(i);
804
+ }), i.addEventListener("error", (o) => {
805
+ s(o);
806
+ });
807
+ });
808
+ }, Zo = async (i, e) => {
809
+ for (const t of i) {
810
+ const { id: s, url: o, integrity: n } = t, a = Ho(s);
811
+ if (a)
812
+ try {
813
+ return await Xo(a, n), t;
814
+ } catch {
815
+ e(t, !0);
816
+ }
817
+ else
818
+ try {
819
+ return await Qo(s, o, n), t;
820
+ } catch {
821
+ e(t, !1);
822
+ }
823
+ }
824
+ throw new Error("All scripts failed to load");
825
+ }, en = (i, e, t, s = "", o) => i.reduce((n, a) => {
826
+ const l = a;
827
+ if (!l)
828
+ return n;
829
+ let d;
830
+ try {
831
+ d = new URL(l);
832
+ } catch {
833
+ throw new Error(`Invalid URL: ${l}`);
834
+ }
835
+ d.pathname !== "/" || (d.pathname = `/npm/${e}@${t}/${s}`);
836
+ const c = {
837
+ url: d,
838
+ id: `npmlib-${e.replaceAll("@", "").replaceAll("/", "_")}-${zo(d)}`
839
+ };
840
+ return o && (c.integrity = o), [...n, c];
841
+ }, []), tn = j((i) => {
842
+ const e = R(ke)(i);
843
+ return class extends e {
844
+ get baseCdnUrl() {
845
+ return this.getAttribute("base-cdn-url") || "";
846
+ }
847
+ injectNpmLib(s, o, n = "", a = [], l) {
848
+ return this.logger.debug(`Injecting npm lib: "${s}" with version: "${o}"${l ? " with SRI integrity check" : ""}`), Zo(en([...a, this.baseCdnUrl, ...Ko], s, o, n, l), (d, u) => {
849
+ if (u) {
850
+ this.logger.error(`Existing script cannot be loaded: "${d.url}"`);
851
+ return;
852
+ }
853
+ this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${d.url}"`);
854
+ });
855
+ }
856
+ };
857
+ }), sn = (i) => [
858
+ ...Array.from(i.content.querySelectorAll("*")).reduce((e, t) => t.localName.startsWith("descope-") ? e.add(t.localName) : e, /* @__PURE__ */ new Set())
859
+ ], pt = "base.ui.components.url", on = wi && localStorage.getItem(pt), nn = "dist/umd/index.js", rn = "@descope/web-components-ui", an = j((i) => {
860
+ var e, t, s, o, n, a, l;
861
+ const d = R(ke, yi, tn)(i);
862
+ return l = class extends d {
863
+ constructor() {
864
+ super(...arguments), e.add(this), o.set(this, void 0);
865
+ }
866
+ get descopeUi() {
867
+ return r(this, o, "f") || S(this, o, r(this, e, "m", a).call(this), "f"), r(this, o, "f");
868
+ }
869
+ async loadDescopeUiComponents(c) {
870
+ const h = Array.isArray(c) ? c : sn(c);
871
+ return Promise.all(h.map((p) => r(this, e, "m", n).call(this, p)));
872
+ }
873
+ }, o = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakSet(), t = // eslint-disable-next-line class-methods-use-this
874
+ async function() {
875
+ var c;
876
+ const h = await this.config, p = (c = h == null ? void 0 : h.projectConfig) === null || c === void 0 ? void 0 : c.componentsVersion;
877
+ return p ? this.logger.debug(`Got component version "${p}"`) : this.logger.error("Could not get components version"), p;
878
+ }, s = async function() {
879
+ var c;
880
+ const h = await this.config, p = (c = h == null ? void 0 : h.projectConfig) === null || c === void 0 ? void 0 : c.componentsVersionSri;
881
+ return p && this.logger.debug("SRI hash available for components"), p;
882
+ }, n = async function(c) {
883
+ if (!!customElements.get(c)) {
884
+ this.logger.debug(`Loading component "${c}" is skipped as it is already defined`);
885
+ return;
886
+ }
887
+ const p = await this.descopeUi;
888
+ if (!p[c]) {
889
+ this.logger.error(`Cannot load UI component "${c}"`, `Descope UI does not have a component named "${c}", available components are: "${Object.keys(p).join(", ")}"`);
890
+ return;
891
+ }
892
+ try {
893
+ return await p[c]();
894
+ } catch (m) {
895
+ if (m.name === "NotSupportedError")
896
+ console.debug(`Encountered an error while attempting to define the "${c}" component, it is likely that this component is already defined`);
897
+ else
898
+ throw m;
899
+ }
900
+ }, a = async function() {
901
+ if (globalThis.DescopeUI)
902
+ return globalThis.DescopeUI;
903
+ try {
904
+ const c = await r(this, e, "m", t).call(this), h = await r(this, e, "m", s).call(this);
905
+ return await this.injectNpmLib(rn, c, nn, [on], h), this.logger.debug("DescopeUI was loaded"), globalThis.DescopeUI;
906
+ } catch (c) {
907
+ throw this.logger.error(c), new Error("DescopeUI was not loaded");
908
+ }
909
+ }, l;
910
+ }), ln = j((i) => {
911
+ var e, t, s;
912
+ const o = R(Ae, ut)(i);
913
+ return s = class extends o {
914
+ constructor() {
915
+ super(...arguments), e.add(this);
916
+ }
917
+ get nonce() {
918
+ return this.getAttribute("nonce") || "";
919
+ }
920
+ async init() {
921
+ var a;
922
+ await ((a = super.init) === null || a === void 0 ? void 0 : a.call(this)), this.observeAttribute("nonce", r(this, e, "m", t).bind(this)), r(this, e, "m", t).call(this);
923
+ }
924
+ }, e = /* @__PURE__ */ new WeakSet(), t = function() {
925
+ this.nonce && (window.DESCOPE_NONCE = this.nonce);
926
+ }, s;
927
+ });
928
+ class cn {
929
+ constructor(e, t, { prepend: s = !1 } = {}) {
930
+ this.styleEle = document.createElement("style"), this.styleEle.setAttribute("nonce", t), this.ref = e, this.ref && (s ? this.ref.prepend(this.styleEle) : this.ref.append(this.styleEle));
931
+ }
932
+ replaceSync(e) {
933
+ this.styleEle.textContent = e;
934
+ }
935
+ get cssRules() {
936
+ var e;
937
+ return (e = this.styleEle.sheet) === null || e === void 0 ? void 0 : e.cssRules;
938
+ }
939
+ }
940
+ const gt = j((i) => {
941
+ const e = R(ln)(i);
942
+ return class extends e {
943
+ injectStyle(s, { prepend: o = !1 } = {}) {
944
+ let n;
945
+ try {
946
+ n = new CSSStyleSheet();
947
+ } catch {
948
+ n = new cn(this.shadowRoot, this.nonce, {
949
+ prepend: o
950
+ });
951
+ }
952
+ if (s && n.replaceSync(s), n instanceof CSSStyleSheet) {
953
+ const a = this.shadowRoot;
954
+ if (a && "adoptedStyleSheets" in a) {
955
+ const l = [...a.adoptedStyleSheets || []];
956
+ l[o ? "unshift" : "push"](n), a.adoptedStyleSheets = l;
957
+ }
958
+ }
959
+ return n;
960
+ }
961
+ };
962
+ }), He = "content-root", Me = "root", dn = j((i) => {
963
+ const e = R(gt)(i);
964
+ return class extends e {
965
+ constructor(...s) {
966
+ var o, n;
967
+ super(...s), this.attachShadow({ mode: "open" }).innerHTML = `
968
+ <div id="${Me}">
969
+ <div id="${He}"></div>
970
+ </div>
971
+ `, this.injectStyle(`
972
+ #${Me}, #${He} {
973
+ height: 100%;
974
+ }
975
+ #${Me} {
976
+ position: relative;
977
+ height: fit-content;
978
+ }
979
+ `), this.contentRootElement = (o = this.shadowRoot) === null || o === void 0 ? void 0 : o.getElementById(He), this.rootElement = (n = this.shadowRoot) === null || n === void 0 ? void 0 : n.getElementById(Me);
980
+ }
981
+ };
982
+ }), un = "theme", hn = (i) => {
983
+ const e = document.createElement("link");
984
+ e.href = i, e.rel = "stylesheet", document.head.appendChild(e);
985
+ }, pn = async () => {
986
+ const i = localStorage.getItem(pt), e = i == null ? void 0 : i.replace(/[^\/]+$/, "DescopeDev.js");
987
+ console.warn("Trying to load DescopeDev.js from", e);
988
+ const t = document.createElement("script");
989
+ if (t.src = e, document.body.appendChild(t), await new Promise((s, o) => {
990
+ t.onload = s, t.onerror = o;
991
+ }), globalThis.DescopeDev) {
992
+ const { themeToStyle: s, defaultTheme: o, darkTheme: n } = globalThis.DescopeDev;
993
+ return {
994
+ light: s(o),
995
+ dark: s(n)
996
+ };
997
+ }
998
+ }, gn = (i, e) => (e || !1) && e !== "light" && e !== "dark" && 'Supported theme values are "light", "dark", or leave empty for using the OS theme', fn = j((i) => {
999
+ var e, t, s, o, n, a, l, d, u, c, h, p, m, v;
1000
+ const A = R(Ve({ theme: gn }), ht, Ae, an, yi, dn, ut, gt)(i);
1001
+ return v = class extends A {
1002
+ constructor() {
1003
+ super(...arguments), e.add(this), t.set(this, void 0), s.set(this, void 0), h.set(this, () => {
1004
+ r(this, e, "m", p).call(this), r(this, m, "f").call(this, this.getAttribute("theme") === "os");
1005
+ }), m.set(this, (g) => {
1006
+ var f, b, k;
1007
+ const T = g ? "addEventListener" : "removeEventListener";
1008
+ (k = (b = (f = window.matchMedia) === null || f === void 0 ? void 0 : f.call(window, "(prefers-color-scheme: dark)")) === null || b === void 0 ? void 0 : b[T]) === null || k === void 0 || k.call(b, "change", () => r(this, e, "m", p).call(this));
1009
+ });
1010
+ }
1011
+ get theme() {
1012
+ var g, f;
1013
+ const b = this.getAttribute("theme");
1014
+ return b === "os" ? window.matchMedia && ((f = (g = window.matchMedia) === null || g === void 0 ? void 0 : g.call(window, "(prefers-color-scheme: dark)")) === null || f === void 0 ? void 0 : f.matches) ? "dark" : "light" : b || "light";
1015
+ }
1016
+ get styleId() {
1017
+ return this.getAttribute("style-id") || un;
1018
+ }
1019
+ async init() {
1020
+ var g;
1021
+ await ((g = super.init) === null || g === void 0 ? void 0 : g.call(this)), r(this, h, "f").call(this), await Promise.all([
1022
+ r(this, e, "m", a).call(this),
1023
+ r(this, e, "m", l).call(this)
1024
+ ]), this.observeAttributes(["theme"], r(this, h, "f")), this.observeAttributes(["style-id"], () => {
1025
+ S(this, s, null, "f"), r(this, e, "m", u).call(this), r(this, e, "m", a).call(this), r(this, e, "m", l).call(this);
1026
+ });
1027
+ }
1028
+ }, t = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakSet(), o = async function() {
1029
+ try {
1030
+ const { body: g } = await this.fetchStaticResource(`${this.styleId}.json`, "json");
1031
+ if (process.env.NODE_ENV === "development" && localStorage != null && localStorage.getItem(pt))
1032
+ try {
1033
+ this.logger.warn(`You are in DEV mode, and UI components override URL was found
1034
+ trying to merge project theme with the default theme of the UI components`);
1035
+ const f = await pn();
1036
+ f && (g.light.components = Object.assign(Object.assign({}, g.light.components), f.light.components), g.dark.components = Object.assign(Object.assign({}, g.dark.components), f.dark.components), this.logger.warn("Theme was merged successfully"), console.log(`%cNOTICE! This is not the theme that will be used in production!
1037
+
1038
+ Make sure to test it without the override UI components URL!`, "color: black; background-color:yellow; font-size: x-large"));
1039
+ } catch (f) {
1040
+ this.logger.error(`Failed to merge UI components theme
1041
+ `, f);
1042
+ }
1043
+ return g;
1044
+ } catch {
1045
+ this.logger.error("Cannot fetch theme file", "make sure that your projectId & flowId are correct");
1046
+ }
1047
+ }, n = function() {
1048
+ return r(this, s, "f") || (S(this, s, r(this, e, "m", o).call(this), "f"), r(this, s, "f").then((g) => this.logger.debug("Fetched theme", g))), r(this, s, "f");
1049
+ }, a = async function() {
1050
+ var g, f;
1051
+ const b = await r(this, e, "a", n);
1052
+ b && (r(this, t, "f") || S(this, t, this.injectStyle(""), "f"), r(this, t, "f").replaceSync((((g = b == null ? void 0 : b.light) === null || g === void 0 ? void 0 : g.globals) || "") + (((f = b == null ? void 0 : b.dark) === null || f === void 0 ? void 0 : f.globals) || "")));
1053
+ }, l = async function() {
1054
+ var g, f;
1055
+ const b = await r(this, e, "a", n);
1056
+ if (!b)
1057
+ return;
1058
+ const k = await this.descopeUi;
1059
+ k != null && k.componentsThemeManager && (k.componentsThemeManager.themes = {
1060
+ light: (g = b == null ? void 0 : b.light) === null || g === void 0 ? void 0 : g.components,
1061
+ dark: (f = b == null ? void 0 : b.dark) === null || f === void 0 ? void 0 : f.components
1062
+ });
1063
+ }, d = async function() {
1064
+ var g, f;
1065
+ const { projectConfig: b } = await this.config || {}, k = (g = b == null ? void 0 : b.styles) === null || g === void 0 ? void 0 : g[this.styleId], T = b == null ? void 0 : b.cssTemplate, L = k || T;
1066
+ return (f = L == null ? void 0 : L[this.theme]) === null || f === void 0 ? void 0 : f.fonts;
1067
+ }, u = async function() {
1068
+ const g = await r(this, e, "m", d).call(this);
1069
+ g ? Object.values(g).forEach((f) => {
1070
+ f.url && (this.logger.debug(`Loading font from URL "${f.url}"`), hn(f.url));
1071
+ }) : this.logger.debug("No fonts to load");
1072
+ }, c = async function() {
1073
+ this.rootElement.setAttribute("data-theme", this.theme);
1074
+ const g = await this.descopeUi;
1075
+ g != null && g.componentsThemeManager && (g.componentsThemeManager.currentThemeName = this.theme);
1076
+ }, p = function() {
1077
+ r(this, e, "m", u).call(this), r(this, e, "m", c).call(this);
1078
+ }, v;
1079
+ }), Je = (i, e = "") => Object.keys(i).reduce((t, s) => {
1080
+ var o;
1081
+ if (Array.isArray(i[s]))
1082
+ return Object.assign(Object.assign({}, t), { [s]: { value: i[s].map((l) => typeof l == "object" && l !== null ? Je(l) : l) } });
1083
+ if (typeof i[s] == "object" && i[s] !== null && !(!((o = i[s]) === null || o === void 0) && o.value))
1084
+ return Object.assign(Object.assign({}, t), Je(i[s], `${e + s}.`));
1085
+ const n = typeof i[s] == "object" ? i[s] : { value: i[s] }, a = Object.assign(Object.assign({}, t), { [e + s]: n, [`form.${e}${s}`]: n });
1086
+ return s === "displayName" ? Object.assign(Object.assign({}, a), { [`${e}fullName`]: n, [`form.${e}fullName`]: n }) : a;
1087
+ }, []), mn = (i) => {
1088
+ try {
1089
+ return Je(JSON.parse(i));
1090
+ } catch {
1091
+ return {};
1092
+ }
1093
+ }, vn = (i, e) => Object.fromEntries(Object.entries(i).map(([t, s]) => [t, s[e]])), bn = j((i) => {
1094
+ var e, t, s, o;
1095
+ return o = class extends i {
1096
+ constructor() {
1097
+ super(...arguments), e.add(this);
1098
+ }
1099
+ connectedCallback() {
1100
+ var n;
1101
+ r(this, e, "m", t).call(this) && r(this, e, "m", s).call(this), (n = super.connectedCallback) === null || n === void 0 || n.call(this);
1102
+ }
1103
+ }, e = /* @__PURE__ */ new WeakSet(), t = function() {
1104
+ return !this.shadowRoot.host.closest("form") && ys();
1105
+ }, s = function() {
1106
+ const n = this.shadowRoot.host, a = document.createElement("form");
1107
+ a.style.width = "100%", a.style.height = "100%", n.parentElement.appendChild(a), a.appendChild(n);
1108
+ }, o;
1109
+ });
1110
+ var M, je, Re, de, se, ae, ye, X, le, De, Wt, Ci, ze, Si, Pt, ki, Ai, Nt, Ei, Ye, xi, Ii;
1111
+ const wn = R(fn, ht, bn, gt)(HTMLElement);
1112
+ class Ce extends wn {
1113
+ static get observedAttributes() {
1114
+ return ["project-id", "flow-id", "base-url", "tenant", "locale", "debug", "storage-prefix", "preview", "redirect-url", "auto-focus", "store-last-authenticated-user", "refresh-cookie-name", "keep-last-authenticated-user-after-logout", "validate-on-blur", "style-id"];
1115
+ }
1116
+ constructor(e) {
1117
+ super(), M.add(this), Re.set(this, !1), de.set(this, void 0), this.flowStatus = "initial", this.loggerWrapper = { error: (t, s = "") => {
1118
+ this.logger.error(t, s, new Error()), r(this, M, "m", Ii).call(this, t, s);
1119
+ }, warn: (t, s = "") => {
1120
+ this.logger.warn(t, s);
1121
+ }, info: (t, s = "", o = {}) => {
1122
+ this.logger.info(t, s, o);
1123
+ }, debug: (t, s = "") => {
1124
+ this.logger.debug(t, s);
1125
+ } }, se.set(this, new we()), ae.set(this, new we()), ye.set(this, {}), this.getComponentsContext = () => r(this, ye, "f"), this.nextRequestStatus = new we({ isLoading: !1 }), X.set(this, void 0), le.set(this, { popstate: r(this, M, "m", Si).bind(this), componentsContext: r(this, M, "m", Ei).bind(this) }), De.set(this, void 0), this.getConfig = () => y(this, void 0, void 0, function* () {
1126
+ return (yield this.config) || { isMissingConfig: !0 };
1127
+ }), S(this, De, e, "f"), r(this, M, "m", Ci).call(this);
1128
+ }
1129
+ get flowId() {
1130
+ return this.getAttribute("flow-id");
1131
+ }
1132
+ get client() {
1133
+ try {
1134
+ return JSON.parse(this.getAttribute("client")) || {};
1135
+ } catch {
1136
+ return {};
1137
+ }
1138
+ }
1139
+ get tenantId() {
1140
+ return this.getAttribute("tenant") || void 0;
1141
+ }
1142
+ get redirectUrl() {
1143
+ return this.getAttribute("redirect-url") || void 0;
1144
+ }
1145
+ get debug() {
1146
+ return this.getAttribute("debug") === "true";
1147
+ }
1148
+ get locale() {
1149
+ return this.getAttribute("locale") || void 0;
1150
+ }
1151
+ get autoFocus() {
1152
+ var e;
1153
+ const t = (e = this.getAttribute("auto-focus")) !== null && e !== void 0 ? e : "true";
1154
+ return t === "skipFirstScreen" ? t : t === "true";
1155
+ }
1156
+ get validateOnBlur() {
1157
+ return this.getAttribute("validate-on-blur") === "true";
1158
+ }
1159
+ get storeLastAuthenticatedUser() {
1160
+ var e;
1161
+ return ((e = this.getAttribute("store-last-authenticated-user")) !== null && e !== void 0 ? e : "true") === "true";
1162
+ }
1163
+ get refreshCookieName() {
1164
+ return this.getAttribute("refresh-cookie-name") || "";
1165
+ }
1166
+ get keepLastAuthenticatedUserAfterLogout() {
1167
+ return this.getAttribute("keep-last-authenticated-user-after-logout") === "true";
1168
+ }
1169
+ get storagePrefix() {
1170
+ return this.getAttribute("storage-prefix") || "";
1171
+ }
1172
+ get preview() {
1173
+ return !!this.getAttribute("preview");
1174
+ }
1175
+ get formConfig() {
1176
+ return mn(this.form);
1177
+ }
1178
+ get form() {
1179
+ return this.getAttribute("form");
1180
+ }
1181
+ get formConfigValues() {
1182
+ return vn(this.formConfig, "value");
1183
+ }
1184
+ get outboundAppId() {
1185
+ return this.getAttribute("outbound-app-id");
1186
+ }
1187
+ get outboundAppScopes() {
1188
+ try {
1189
+ return JSON.parse(this.getAttribute("outbound-app-scopes")) || null;
1190
+ } catch {
1191
+ return null;
1192
+ }
1193
+ }
1194
+ get popupOrigin() {
1195
+ return this.getAttribute("popup-origin");
1196
+ }
1197
+ get customStorage() {
1198
+ return r(this, de, "f");
1199
+ }
1200
+ set customStorage(e) {
1201
+ if (e && typeof e.getItem != "function")
1202
+ throw new Error("Custom storage must have a getItem method");
1203
+ if (e && typeof e.setItem != "function")
1204
+ throw new Error("Custom storage must have a setItem method");
1205
+ if (e && typeof e.removeItem != "function")
1206
+ throw new Error("Custom storage must have a removeItem method");
1207
+ S(this, de, e, "f"), $o(e);
1208
+ }
1209
+ get isRestartOnError() {
1210
+ return this.getAttribute("restart-on-error") === "true";
1211
+ }
1212
+ getExecutionContext() {
1213
+ return y(this, void 0, void 0, function* () {
1214
+ const e = yield this.getConfig();
1215
+ return "executionContext" in e ? e.executionContext : void 0;
1216
+ });
1217
+ }
1218
+ getProjectConfig() {
1219
+ return y(this, void 0, void 0, function* () {
1220
+ const e = yield this.getConfig();
1221
+ return "projectConfig" in e ? e.projectConfig : void 0;
1222
+ });
1223
+ }
1224
+ getFlowConfig() {
1225
+ return y(this, void 0, void 0, function* () {
1226
+ var e, t;
1227
+ const s = yield this.getProjectConfig(), o = ((e = s == null ? void 0 : s.flows) === null || e === void 0 ? void 0 : e[this.flowId]) || {};
1228
+ return (t = o.version) !== null && t !== void 0 || (o.version = 0), o;
1229
+ });
1230
+ }
1231
+ getTargetLocales() {
1232
+ return y(this, void 0, void 0, function* () {
1233
+ const e = yield this.getFlowConfig();
1234
+ return ((e == null ? void 0 : e.targetLocales) || []).map((t) => t.toLowerCase());
1235
+ });
1236
+ }
1237
+ handleKeyPress() {
1238
+ this.logger.debug("Enable key press handler"), this.rootElement.onkeydown = (e) => {
1239
+ var t, s, o;
1240
+ const n = !!(!((t = this.shadowRoot.activeElement) === null || t === void 0) && t.getAttribute("href")), a = ps.includes((o = (s = this.shadowRoot.activeElement) === null || s === void 0 ? void 0 : s.localName) !== null && o !== void 0 ? o : "");
1241
+ if (e.key !== "Enter" || n || a)
1242
+ return;
1243
+ e.preventDefault();
1244
+ const l = this.rootElement.querySelectorAll("descope-button");
1245
+ if (l.length === 1 && l[0].getAttribute("auto-submit") !== "false")
1246
+ return void l[0].click();
1247
+ const d = Array.from(l).filter((c) => c.getAttribute("auto-submit") === "true");
1248
+ if (d.length === 1)
1249
+ return void d[0].click();
1250
+ const u = Array.from(l).filter((c) => c.getAttribute("data-type") === "button");
1251
+ if (u.length === 1)
1252
+ u[0].getAttribute("auto-submit") !== "false" && u[0].click();
1253
+ else if (u.length === 0) {
1254
+ const c = Array.from(l).filter((h) => h.getAttribute("data-type") === "sso");
1255
+ c.length === 1 && c[0].getAttribute("auto-submit") !== "false" && c[0].click();
1256
+ }
1257
+ };
1258
+ }
1259
+ disableKeyPressHandler() {
1260
+ this.logger.debug("Disable key press handler"), this.rootElement.onkeydown = null;
1261
+ }
1262
+ getComponentsVersion() {
1263
+ return y(this, void 0, void 0, function* () {
1264
+ var e;
1265
+ const t = yield this.getConfig();
1266
+ return ("projectConfig" in t ? (e = t.projectConfig) === null || e === void 0 ? void 0 : e.componentsVersion : {}) || (this.logger.error("Did not get components version, using latest version"), "latest");
1267
+ });
1268
+ }
1269
+ init() {
1270
+ const e = Object.create(null, { init: { get: () => super.init } });
1271
+ return y(this, void 0, void 0, function* () {
1272
+ var t;
1273
+ if (this.flowStatus = "loading", ["ready", "error", "success"].forEach((A) => this.addEventListener(A, () => {
1274
+ this.flowStatus = A;
1275
+ })), yield (t = e.init) === null || t === void 0 ? void 0 : t.call(this), r(this, ae, "f").subscribe(r(this, M, "m", xi).bind(this)), r(this, ae, "f").update({ isDebug: this.debug }), r(this, M, "m", ze).call(this), yield r(this, M, "m", Ai).call(this))
1276
+ return void this.loggerWrapper.error("This SDK version does not support your flows version", "Make sure to upgrade your flows to the latest version or use an older SDK version");
1277
+ const s = yield this.getConfig();
1278
+ if ("isMissingConfig" in s && s.isMissingConfig)
1279
+ return void this.loggerWrapper.error("Cannot get config file", "Make sure that your projectId & flowId are correct");
1280
+ const { executionId: o, stepId: n, token: a, code: l, isPopup: d, exchangeError: u, redirectAuthCallbackUrl: c, redirectAuthBackupCallbackUri: h, redirectAuthCodeChallenge: p, redirectAuthInitiator: m, ssoQueryParams: v } = io(this.flowId, this.loggerWrapper);
1281
+ window.addEventListener("popstate", r(this, le, "f").popstate), window.addEventListener("components-context", r(this, le, "f").componentsContext), r(this, se, "f").subscribe(r(this, M, "m", ki).bind(this)), r(this, se, "f").update(Object.assign({ projectId: this.projectId, flowId: this.flowId, baseUrl: this.baseUrl, tenant: this.tenantId, redirectUrl: this.redirectUrl, locale: this.locale, stepId: n, executionId: o, token: a, code: l, isPopup: d, exchangeError: u, redirectAuthCallbackUrl: c, redirectAuthBackupCallbackUri: h, redirectAuthCodeChallenge: p, redirectAuthInitiator: m }, v)), S(this, Re, !0, "f");
1282
+ });
1283
+ }
1284
+ disconnectedCallback() {
1285
+ r(this, se, "f").unsubscribeAll(), r(this, ae, "f").unsubscribeAll(), r(this, M, "m", Ye).call(this), window.removeEventListener("popstate", r(this, le, "f").popstate), window.removeEventListener("components-context", r(this, le, "f").componentsContext);
1286
+ }
1287
+ attributeChangedCallback(e, t, s) {
1288
+ if (this.shadowRoot.isConnected && r(this, Re, "f") && t !== s && je.observedAttributes.includes(e)) {
1289
+ r(this, M, "m", ze).call(this);
1290
+ const o = t === null;
1291
+ r(this, se, "f").update(({ stepId: n, executionId: a }) => {
1292
+ let l = n, d = a;
1293
+ return o || (d = null, l = null, di()), { [ui(e)]: s, stepId: l, executionId: d };
1294
+ }), r(this, ae, "f").update({ isDebug: this.debug });
1295
+ }
1296
+ }
1297
+ }
1298
+ je = Ce, Re = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakSet(), Wt = function() {
1299
+ this.injectStyle(`
1300
+ :host {
1301
+ width: 100%;
1302
+ display: block;
1303
+ }
1304
+
1305
+ #root {
1306
+ height: 100%;
1307
+ display: flex;
1308
+ flex-direction: column;
1309
+ }
1310
+
1311
+ #content-root {
1312
+ all: initial;
1313
+ transition: opacity 200ms ease-in-out;
1314
+ }
1315
+
1316
+ #root[data-theme] {
1317
+ background-color: transparent;
1318
+ }
1319
+
1320
+ .fade-out {
1321
+ opacity: 0.1!important;
1322
+ }
1323
+
1324
+ .hidden {
1325
+ display: none;
1326
+ }
1327
+ `);
1328
+ }, Ci = function() {
1329
+ r(this, M, "m", Wt).call(this), this.slotElement = document.createElement("slot"), this.slotElement.classList.add("hidden"), this.rootElement.appendChild(this.slotElement);
1330
+ }, ze = function() {
1331
+ const i = ["base-url", "tenant", "locale", "debug", "redirect-url", "auto-focus", "store-last-authenticated-user", "refresh-cookie-name", "keep-last-authenticated-user-after-logout", "preview", "storage-prefix", "form", "client", "validate-on-blur", "style-id", "outbound-app-id", "outbound-app-scopes"];
1332
+ je.observedAttributes.forEach((e) => {
1333
+ if (!i.includes(e) && !this[ui(e)])
1334
+ throw Error(`${e} cannot be empty`);
1335
+ });
1336
+ }, Si = function() {
1337
+ const { stepId: i, executionId: e } = ci(this.flowId);
1338
+ r(this, se, "f").update({ stepId: i, executionId: e });
1339
+ }, Pt = function(i, e) {
1340
+ he && typeof he == "function" || this.logger.error("SDK was not loaded properly", he, JSON.stringify(he));
1341
+ const t = Object.assign(Object.assign({ persistTokens: !0, preview: this.preview, storagePrefix: this.storagePrefix, storeLastAuthenticatedUser: this.storeLastAuthenticatedUser, keepLastAuthenticatedUserAfterLogout: this.keepLastAuthenticatedUserAfterLogout, refreshCookieName: this.refreshCookieName }, je.sdkConfigOverrides), { projectId: i, baseUrl: e });
1342
+ r(this, de, "f") && (t.customStorage = r(this, de, "f")), this.sdk = he(t), ["start", "next"].forEach((s) => {
1343
+ const o = this.sdk.flow[s], n = ms(o, 1e3, 3);
1344
+ this.sdk.flow[s] = (...a) => y(this, void 0, void 0, function* () {
1345
+ try {
1346
+ return yield n(...a);
1347
+ } catch (l) {
1348
+ return this.logger.error(`Error in sdk flow ${s} function`, l), { error: { errorCode: Gt, errorDescription: l.toString() } };
1349
+ }
1350
+ });
1351
+ });
1352
+ }, ki = function(i, e, t) {
1353
+ return y(this, void 0, void 0, function* () {
1354
+ const { projectId: s, baseUrl: o } = i;
1355
+ if (t("projectId") || t("baseUrl")) {
1356
+ if (!s)
1357
+ return;
1358
+ r(this, M, "m", Pt).call(this, s, o);
1359
+ }
1360
+ r(this, De, "f").call(this, i);
1361
+ });
1362
+ }, Ai = function() {
1363
+ return y(this, void 0, void 0, function* () {
1364
+ const i = yield this.getConfig();
1365
+ return "isMissingConfig" in i && i.isMissingConfig && (yield r(this, M, "m", Nt).call(this));
1366
+ });
1367
+ }, Nt = function() {
1368
+ return y(this, void 0, void 0, function* () {
1369
+ const i = bs({ projectId: this.projectId, filename: ns, assetsFolder: os, baseUrl: this.baseStaticUrl });
1370
+ try {
1371
+ return yield vs(i, "json"), !0;
1372
+ } catch {
1373
+ return !1;
1374
+ }
1375
+ });
1376
+ }, Ei = function(i) {
1377
+ S(this, ye, Object.assign(Object.assign({}, r(this, ye, "f")), i.detail), "f");
1378
+ }, Ye = function() {
1379
+ var i;
1380
+ (i = r(this, X, "f")) === null || i === void 0 || i.remove(), S(this, X, null, "f");
1381
+ }, xi = function(i) {
1382
+ return y(this, arguments, void 0, function* ({ isDebug: e }) {
1383
+ e ? (S(this, X, document.createElement("descope-debugger"), "f"), Object.assign(r(this, X, "f").style, { position: "fixed", top: "0", right: "0", height: "100vh", width: "100vw", pointerEvents: "none", zIndex: 99999 }), yield import("./debugger-wc.es.js"), document.body.appendChild(r(this, X, "f"))) : r(this, M, "m", Ye).call(this);
1384
+ });
1385
+ }, Ii = function(i, e) {
1386
+ var t;
1387
+ i && this.debug && ((t = r(this, X, "f")) === null || t === void 0 || t.updateData({ title: i, description: e }));
1388
+ }, Ce.sdkConfigOverrides = { baseHeaders: { "x-descope-sdk-name": "web-component", "x-descope-sdk-version": "3.58.0" } };
1389
+ var w, fe, J, ue, Te, _i, Dt, Ft, Le, Vt, Qe, Bt, $i, We, Oi, Xe, Ze, ce, me, et, G, tt, qt, Mi, it, Ui, ji, ve, Ri, Ti, Li, Kt, Pe, st, Ht, Wi, z, Pi;
1390
+ class Ni extends Ce {
1391
+ static set sdkConfigOverrides(e) {
1392
+ Ce.sdkConfigOverrides = e;
1393
+ }
1394
+ static get sdkConfigOverrides() {
1395
+ return Ce.sdkConfigOverrides;
1396
+ }
1397
+ constructor() {
1398
+ const e = new we({ deferredRedirect: !1, deferredPolling: !1 });
1399
+ super(e.update.bind(e)), w.add(this), this.stepState = new we({}), fe.set(this, void 0), J.set(this, null), ue.set(this, null), Te.set(this, { visibilitychange: r(this, w, "m", _i).bind(this) }), this.bridgeVersion = 2, this.nativeCallbacks = {}, We.set(this, !1), this.handleRedirect = (t) => {
1400
+ window.location.assign(t);
1401
+ }, Xe.set(this, (t) => {
1402
+ const s = () => {
1403
+ this.contentRootElement.classList.toggle("hidden", t), this.slotElement.classList.toggle("hidden", !t), t && (this.contentRootElement.innerHTML = "");
1404
+ };
1405
+ t && this.contentRootElement.hasChildNodes() ? r(this, w, "m", Ze).call(this, s) : s();
1406
+ }), ce.set(this, (t, s, o, n, a = !1) => {
1407
+ const l = [kt, es];
1408
+ if (this.flowState.current.action === K.poll) {
1409
+ if (r(this, et, "f").call(this) && document.hidden)
1410
+ return this.logger.debug("polling - Deferring polling until in foreground"), void this.flowState.update({ deferredPolling: !0 });
1411
+ this.logger.debug("polling - Scheduling polling request");
1412
+ const d = Date.now(), u = a ? 500 : 2e3;
1413
+ S(this, fe, setTimeout(() => y(this, void 0, void 0, function* () {
1414
+ var c, h;
1415
+ this.logger.debug("polling - Calling next");
1416
+ const p = this.sdk.flow.next(t, s, pe.polling, o, n, {}), m = document.hidden && !a && Date.now() - d > u + 500;
1417
+ let v;
1418
+ m && this.logger.debug("polling - The polling seems to be throttled");
1419
+ try {
1420
+ v = yield ct(m ? 1e3 : 6e3, p);
1421
+ } catch {
1422
+ return this.logger.warn(`polling - The ${m ? "throttled fetch" : "fetch"} call timed out or was aborted`), void r(this, ce, "f").call(this, t, s, o, n, m);
1423
+ }
1424
+ if (((c = v == null ? void 0 : v.error) === null || c === void 0 ? void 0 : c.errorCode) === Gt)
1425
+ return this.logger.debug("polling - Got a generic error due to exception in fetch call"), void r(this, ce, "f").call(this, t, s, o, n);
1426
+ this.logger.debug("polling - Got a response"), v != null && v.error && this.logger.debug("polling - Response has an error", JSON.stringify(v.error, null, 4)), !((h = v == null ? void 0 : v.error) === null || h === void 0) && h.errorCode && l.includes(v.error.errorCode) ? this.logger.debug("polling - Stopping polling due to error") : r(this, ce, "f").call(this, t, s, o, n), r(this, G, "f").call(this, v);
1427
+ }), u), "f");
1428
+ }
1429
+ }), me.set(this, () => {
1430
+ clearTimeout(r(this, fe, "f")), S(this, fe, null, "f");
1431
+ }), et.set(this, () => !!window.descopeBridge || /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)), G.set(this, (t) => {
1432
+ var s, o, n, a, l, d, u, c, h, p, m, v, A;
1433
+ if (!(t != null && t.ok)) {
1434
+ const q = (s = t == null ? void 0 : t.response) === null || s === void 0 ? void 0 : s.url, Z = `${(o = t == null ? void 0 : t.response) === null || o === void 0 ? void 0 : o.status} - ${(n = t == null ? void 0 : t.response) === null || n === void 0 ? void 0 : n.statusText}`;
1435
+ r(this, w, "m", z).call(this, "error", (t == null ? void 0 : t.error) || { errorCode: Xi, errorDescription: Z, errorMessage: q }), this.loggerWrapper.error(((a = t == null ? void 0 : t.error) === null || a === void 0 ? void 0 : a.errorDescription) || q, ((l = t == null ? void 0 : t.error) === null || l === void 0 ? void 0 : l.errorMessage) || Z);
1436
+ const U = (d = t == null ? void 0 : t.error) === null || d === void 0 ? void 0 : d.errorCode;
1437
+ return void (U !== Zi && U !== kt || !this.isRestartOnError || r(this, w, "m", $i).call(this));
1438
+ }
1439
+ (c = (u = t.data) === null || u === void 0 ? void 0 : u.runnerLogs) === null || c === void 0 || c.forEach((q) => {
1440
+ const { level: Z, title: U, log: N } = q;
1441
+ Z && this.loggerWrapper[Z] ? this.loggerWrapper[Z](U, N) : this.loggerWrapper.info(U, N);
1442
+ });
1443
+ const C = (m = (p = (h = t.data) === null || h === void 0 ? void 0 : h.screen) === null || p === void 0 ? void 0 : p.state) === null || m === void 0 ? void 0 : m.errorText;
1444
+ !((v = t.data) === null || v === void 0) && v.error ? this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`, `${C ? `${C} - ` : ""}${t.data.error.message}`) : C && this.loggerWrapper.error(C);
1445
+ const { status: g, authInfo: f, lastAuth: b, action: k, openInNewTabUrl: T } = t.data;
1446
+ if (k !== K.poll && r(this, me, "f").call(this), g === "completed") {
1447
+ this.storeLastAuthenticatedUser && jt(b);
1448
+ const q = Object.assign({}, f);
1449
+ return t.data.output && Object.keys(t.data.output).length > 0 && (q.flowOutput = t.data.output), void r(this, w, "m", z).call(this, "success", q);
1450
+ }
1451
+ this.storeLastAuthenticatedUser && jt(b, !0), T && window.open(T, "_blank");
1452
+ const { executionId: L, stepId: P, stepName: D, screen: F, redirect: oe, webauthn: V, error: Ee, samlIdpResponse: B, nativeResponse: ne } = t.data, xe = Date.now();
1453
+ k !== K.poll ? (this.loggerWrapper.info(`Step "${D || `#${P}`}" is ${g}`, "", { screen: F, status: g, stepId: P, stepName: D, action: k, error: Ee }), !((A = F.state) === null || A === void 0) && A.clientScripts && S(this, ue, this.loadSdkScripts(F.state.clientScripts), "f"), this.flowState.update({ stepId: P, stepName: D, executionId: L, action: k, redirectTo: oe == null ? void 0 : oe.url, redirectIsPopup: oe == null ? void 0 : oe.isPopup, screenId: F == null ? void 0 : F.id, screenState: F == null ? void 0 : F.state, webauthnTransactionId: V == null ? void 0 : V.transactionId, webauthnOptions: V == null ? void 0 : V.options, samlIdpResponseUrl: B == null ? void 0 : B.url, samlIdpResponseSamlResponse: B == null ? void 0 : B.samlResponse, samlIdpResponseRelayState: B == null ? void 0 : B.relayState, nativeResponseType: ne == null ? void 0 : ne.type, nativePayload: ne == null ? void 0 : ne.payload, reqTimestamp: xe })) : this.flowState.update({ action: k, reqTimestamp: xe });
1454
+ }), tt.set(this, hi(() => y(this, void 0, void 0, function* () {
1455
+ var t;
1456
+ try {
1457
+ const s = yield this.sdk.webauthn.signIn.start("", window.location.origin);
1458
+ return s.ok || this.loggerWrapper.warn("Webauthn start failed", (t = s == null ? void 0 : s.error) === null || t === void 0 ? void 0 : t.errorMessage), s.data;
1459
+ } catch (s) {
1460
+ this.loggerWrapper.warn("Webauthn start failed", s.message);
1461
+ }
1462
+ }))), ve.set(this, null), Pe.set(this, lo((t, s) => y(this, void 0, void 0, function* () {
1463
+ var o;
1464
+ if (t.getAttribute("formnovalidate") === "true" || r(this, w, "m", Ui).call(this)) {
1465
+ const n = t == null ? void 0 : t.getAttribute("id");
1466
+ r(this, w, "m", Ri).call(this, t);
1467
+ const a = yield r(this, w, "m", ji).call(this), l = to(t);
1468
+ this.nextRequestStatus.update({ isLoading: !0 });
1469
+ const d = Object.assign(Object.assign(Object.assign({}, l), a), { origin: ((o = this.nativeOptions) === null || o === void 0 ? void 0 : o.origin) || window.location.origin });
1470
+ yield s(n, d), this.nextRequestStatus.update({ isLoading: !1 }), r(this, w, "m", Ti).call(this, a);
1471
+ }
1472
+ }))), this.flowState = e;
1473
+ }
1474
+ nativeResume(e, t) {
1475
+ var s, o, n, a, l, d;
1476
+ const u = JSON.parse(t);
1477
+ if (e === "oauthWeb" || e === "sso") {
1478
+ let c, { exchangeCode: h } = u;
1479
+ if (!h) {
1480
+ const p = new URL(u.url);
1481
+ h = (s = p.searchParams) === null || s === void 0 ? void 0 : s.get(rt), c = ((o = p.searchParams) === null || o === void 0 ? void 0 : o.get(at)) || void 0;
1482
+ }
1483
+ (a = (n = this.nativeCallbacks).complete) === null || a === void 0 || a.call(n, { exchangeCode: h, exchangeError: c, idpInitiated: !0 });
1484
+ } else if (e === "magicLink") {
1485
+ const c = new URL(u.url), h = c.searchParams.get(nt), p = c.searchParams.get(ot).split("_").pop();
1486
+ r(this, me, "f").call(this), this.flowState.update({ token: h, stepId: p, action: void 0 });
1487
+ } else if (e === "beforeScreen") {
1488
+ const { screenResolve: c } = this.nativeCallbacks;
1489
+ this.nativeCallbacks.screenResolve = null;
1490
+ const { override: h } = u;
1491
+ h || (this.nativeCallbacks.screenNext = null), c == null || c(h);
1492
+ } else if (e === "resumeScreen") {
1493
+ const { interactionId: c, form: h } = u, { screenNext: p } = this.nativeCallbacks;
1494
+ this.nativeCallbacks.screenNext = null, p == null || p(c, h);
1495
+ } else
1496
+ (d = (l = this.nativeCallbacks).complete) === null || d === void 0 || d.call(l, u);
1497
+ }
1498
+ loadSdkScriptsModules() {
1499
+ const e = this.shadowRoot.querySelectorAll("div[data-script-id]");
1500
+ return Array.from(e).map((t) => t.moduleRes).filter((t) => !!t);
1501
+ }
1502
+ loadSdkScripts(e) {
1503
+ if (!(e != null && e.length))
1504
+ return null;
1505
+ const t = (n, a) => (l) => {
1506
+ this.dispatchEvent(new CustomEvent("components-context", { detail: { [po(n.id, n.resultKey)]: l }, bubbles: !0, composed: !0 })), a(n.id);
1507
+ };
1508
+ this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((n) => n.id).join(", ")}`);
1509
+ const s = Promise.all(e == null ? void 0 : e.map((n) => y(this, void 0, void 0, function* () {
1510
+ var a, l;
1511
+ const d = this.shadowRoot.querySelector(`[data-script-id="${n.id}"]`);
1512
+ if (d) {
1513
+ this.loggerWrapper.debug("Script already loaded", n.id);
1514
+ const { moduleRes: c } = d;
1515
+ return (a = c == null ? void 0 : c.start) === null || a === void 0 || a.call(c), c;
1516
+ }
1517
+ yield this.injectNpmLib("@descope/flow-scripts", "1.0.14", `dist/${n.id}.js`);
1518
+ const u = (l = globalThis.descope) === null || l === void 0 ? void 0 : l[n.id];
1519
+ return new Promise((c, h) => {
1520
+ try {
1521
+ const p = u(n.initArgs, { baseUrl: this.baseUrl, ref: this }, t(n, c), this.loggerWrapper);
1522
+ if (p) {
1523
+ const m = document.createElement("div");
1524
+ m.setAttribute("data-script-id", n.id), m.moduleRes = p, this.shadowRoot.appendChild(m), this.nextRequestStatus.subscribe(() => {
1525
+ var v;
1526
+ this.loggerWrapper.debug("Unloading script", n.id), (v = p.stop) === null || v === void 0 || v.call(p);
1527
+ });
1528
+ }
1529
+ } catch (p) {
1530
+ h(p);
1531
+ }
1532
+ });
1533
+ }))), o = new Promise((n) => {
1534
+ setTimeout(() => {
1535
+ this.loggerWrapper.warn("SDK scripts loading timeout"), n(!0);
1536
+ }, li);
1537
+ });
1538
+ return Promise.race([s, o]);
1539
+ }
1540
+ get isDismissScreenErrorOnInput() {
1541
+ return this.getAttribute("dismiss-screen-error-on-input") === "true";
1542
+ }
1543
+ init() {
1544
+ if (!window.descopeBridge)
1545
+ return this._init();
1546
+ this.lazyInit = this._init;
1547
+ }
1548
+ _init() {
1549
+ const e = Object.create(null, { init: { get: () => super.init } });
1550
+ return y(this, void 0, void 0, function* () {
1551
+ var t, s;
1552
+ this.shadowRoot.isConnected && ((t = this.flowState) === null || t === void 0 || t.subscribe(this.onFlowChange.bind(this)), r(this, w, "m", Qe).call(this), window.addEventListener("visibilitychange", r(this, Te, "f").visibilitychange)), yield (s = e.init) === null || s === void 0 ? void 0 : s.call(this);
1553
+ });
1554
+ }
1555
+ disconnectedCallback() {
1556
+ var e;
1557
+ super.disconnectedCallback(), this.flowState.unsubscribeAll(), this.stepState.unsubscribeAll(), r(this, me, "f").call(this), (e = r(this, J, "f")) === null || e === void 0 || e.abort(), S(this, J, null, "f"), window.removeEventListener("visibilitychange", r(this, Te, "f").visibilitychange);
1558
+ }
1559
+ getHtmlFilenameWithLocale(e, t) {
1560
+ return y(this, void 0, void 0, function* () {
1561
+ let s;
1562
+ const o = $e(e), n = yield this.getTargetLocales();
1563
+ return n.includes(o.locale) ? s = `${t}-${o.locale}.html` : n.includes(o.fallback) && (s = `${t}-${o.fallback}.html`), s;
1564
+ });
1565
+ }
1566
+ getPageContent(e, t) {
1567
+ return y(this, void 0, void 0, function* () {
1568
+ if (t)
1569
+ try {
1570
+ const { body: s } = yield this.fetchStaticResource(t, "text");
1571
+ return s;
1572
+ } catch (s) {
1573
+ this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`, s);
1574
+ }
1575
+ try {
1576
+ const { body: s } = yield this.fetchStaticResource(e, "text");
1577
+ return s;
1578
+ } catch (s) {
1579
+ this.loggerWrapper.error("Failed to fetch flow page", s.message);
1580
+ }
1581
+ return null;
1582
+ });
1583
+ }
1584
+ onFlowChange(e, t, s) {
1585
+ return y(this, void 0, void 0, function* () {
1586
+ var o, n;
1587
+ const { projectId: a, flowId: l, tenant: d, stepId: u, executionId: c, action: h, screenId: p, screenState: m, redirectTo: v, redirectIsPopup: A, redirectUrl: C, token: g, code: f, isPopup: b, exchangeError: k, webauthnTransactionId: T, webauthnOptions: L, redirectAuthCodeChallenge: P, redirectAuthCallbackUrl: D, redirectAuthBackupCallbackUri: F, redirectAuthInitiator: oe, locale: V, samlIdpResponseUrl: Ee, samlIdpResponseSamlResponse: B, samlIdpResponseRelayState: ne, nativeResponseType: xe, nativePayload: q, reqTimestamp: Z } = e, U = be(e, ["projectId", "flowId", "tenant", "stepId", "executionId", "action", "screenId", "screenState", "redirectTo", "redirectIsPopup", "redirectUrl", "token", "code", "isPopup", "exchangeError", "webauthnTransactionId", "webauthnOptions", "redirectAuthCodeChallenge", "redirectAuthCallbackUrl", "redirectAuthBackupCallbackUri", "redirectAuthInitiator", "locale", "samlIdpResponseUrl", "samlIdpResponseSamlResponse", "samlIdpResponseRelayState", "nativeResponseType", "nativePayload", "reqTimestamp"]);
1588
+ let N, Be, Ie;
1589
+ const _e = Oo(), { outboundAppId: ft } = this, { outboundAppScopes: mt } = this, Y = this.sdk.getLastUserLoginId(), _ = yield this.getFlowConfig(), Q = yield this.getProjectConfig(), vt = Object.entries(Q.flows || {}).reduce((I, [E, W]) => (I[E] = W.version, I), {}), bt = D && P ? { callbackUrl: D, codeChallenge: P, backupCallbackUri: F } : void 0, wt = this.nativeOptions ? { platform: this.nativeOptions.platform, bridgeVersion: this.nativeOptions.bridgeVersion, oauthProvider: this.nativeOptions.oauthProvider, oauthRedirect: this.nativeOptions.oauthRedirect, magicLinkRedirect: this.nativeOptions.magicLinkRedirect, ssoRedirect: this.nativeOptions.ssoRedirect } : void 0;
1590
+ let yt = {};
1591
+ if (!c) {
1592
+ const I = [..._.clientScripts || [], ..._.sdkScripts || []];
1593
+ if (_.conditions) {
1594
+ let E = [];
1595
+ ({ startScreenId: N, conditionInteractionId: Ie, startScreenName: Be, clientScripts: E, componentsConfig: yt } = Uo({ loginId: Y, code: f, token: g, abTestingKey: _e, lastAuth: Oe(Y) }, _.conditions)), I.push(...E || []);
1596
+ } else
1597
+ _.condition ? { startScreenId: N, conditionInteractionId: Ie } = Mo(_.condition, { loginId: Y, code: f, token: g, abTestingKey: _e, lastAuth: Oe(Y) }) : (Be = _.startScreenName, N = _.startScreenId);
1598
+ if (S(this, ue, this.loadSdkScripts(I), "f"), _.fingerprintEnabled && _.fingerprintKey ? yield Yi(_.fingerprintKey, this.baseUrl) : Qi(), !xt(N, U)) {
1599
+ const E = yield this.sdk.flow.start(l, Object.assign(Object.assign(Object.assign(Object.assign({ tenant: d, redirectAuth: bt }, U), { client: this.client }), C && { redirectUrl: C }), { lastAuth: Oe(Y), abTestingKey: _e, locale: $e(V).locale, nativeOptions: wt, outboundAppId: ft, outboundAppScopes: mt }), Ie, "", Q.componentsVersion, vt, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.formConfigValues), f ? { exchangeCode: f, idpInitiated: !0 } : {}), U.descopeIdpInitiated && { idpInitiated: !0 }), g ? { token: g } : {}), U.oidcLoginHint ? { externalId: U.oidcLoginHint } : {}));
1600
+ return r(this, G, "f").call(this, E), void (((o = E == null ? void 0 : E.data) === null || o === void 0 ? void 0 : o.status) !== "completed" && this.flowState.update({ code: void 0, token: void 0 }));
1601
+ }
1602
+ }
1603
+ if (this.loggerWrapper.debug("Before popup postmessage send", JSON.stringify({ isPopup: b, code: f, exchangeError: k, isCodeChanged: s("code"), isExchangeErrorChanged: s("exchangeError") })), b && (s("code") && f || s("exchangeError") && k))
1604
+ return void r(this, w, "m", Pi).call(this, c, f, k);
1605
+ if (c && (s("token") && g || s("code") && f || s("exchangeError") && k)) {
1606
+ const I = yield this.sdk.flow.next(c, u, pe.submit, _.version, Q.componentsVersion, { token: g, exchangeCode: f, exchangeError: k });
1607
+ return r(this, G, "f").call(this, I), void this.flowState.update({ token: void 0, code: void 0, exchangeError: void 0 });
1608
+ }
1609
+ if (h === K.loadForm && ["samlIdpResponseUrl", "samlIdpResponseSamlResponse", "samlIdpResponseRelayState"].some((I) => s(I))) {
1610
+ if (!Ee || !B)
1611
+ return void this.loggerWrapper.error("Did not get saml idp params data to load");
1612
+ ro(Ee, B, ne || "", ao);
1613
+ }
1614
+ if (h === K.redirect && (s("redirectTo") || s("deferredRedirect"))) {
1615
+ if (!v)
1616
+ return void this.loggerWrapper.error("Did not get redirect url");
1617
+ if (v === "no-op")
1618
+ return;
1619
+ if (oe === "android" && document.hidden)
1620
+ return void this.flowState.update({ deferredRedirect: !0 });
1621
+ if (this.loggerWrapper.debug(`Redirect is popup ${A}`), A) {
1622
+ this.loggerWrapper.debug("Opening redirect in popup");
1623
+ const I = go(v, "?", 598, 700), E = this.shouldUsePopupPostMessage();
1624
+ E && (I.name = `descope-wc|${window.location.origin}`), this.loggerWrapper.debug("Popup communication method: " + (E ? "postMessage" : "BroadcastChannel"));
1625
+ const W = (te) => {
1626
+ this.loggerWrapper.debug("Received popup message", JSON.stringify(te.data));
1627
+ const Ct = E ? this.popupOrigin : window.location.origin;
1628
+ if (te.origin !== Ct)
1629
+ return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${te.origin}", expected: "${Ct}"`);
1630
+ const { action: Ji, data: St } = te.data || {};
1631
+ Ji === "code" && this.flowState.update({ code: St.code, exchangeError: St.exchangeError });
1632
+ };
1633
+ let O;
1634
+ this.loggerWrapper.debug("Starting popup closed detection");
1635
+ const Gi = setInterval(() => {
1636
+ I.closed && (this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"), clearInterval(Gi), r(this, w, "m", z).call(this, "popupclosed", {}), this.loggerWrapper.debug("Cleaning up popup listeners"), O == null || O());
1637
+ }, 1e3);
1638
+ if (E)
1639
+ window.addEventListener("message", W), O = () => {
1640
+ this.loggerWrapper.debug("Cleaning up popup postMessage listener"), window.removeEventListener("message", W);
1641
+ };
1642
+ else {
1643
+ this.loggerWrapper.debug("Creating broadcast channel");
1644
+ const te = new BroadcastChannel(c);
1645
+ te.onmessage = W, O = () => {
1646
+ this.loggerWrapper.debug("Closing channel"), te.close();
1647
+ };
1648
+ }
1649
+ } else
1650
+ this.handleRedirect(v), this.flowState.update({ redirectTo: "no-op" }), r(this, w, "m", z).call(this, "popupclosed", {});
1651
+ return;
1652
+ }
1653
+ if (h === K.webauthnCreate || h === K.webauthnGet) {
1654
+ if (!T || !L)
1655
+ return void this.loggerWrapper.error("Did not get webauthn transaction id or options");
1656
+ let I, E;
1657
+ (n = r(this, J, "f")) === null || n === void 0 || n.abort(), S(this, J, null, "f");
1658
+ try {
1659
+ I = h === K.webauthnCreate ? yield this.sdk.webauthn.helpers.create(L) : yield this.sdk.webauthn.helpers.get(L);
1660
+ } catch (O) {
1661
+ O.name === "InvalidStateError" ? this.loggerWrapper.warn("WebAuthn operation failed", O.message) : O.name !== "NotAllowedError" && this.loggerWrapper.error(O.message), E = O.name;
1662
+ }
1663
+ const W = yield this.sdk.flow.next(c, u, pe.submit, _.version, Q.componentsVersion, { transactionId: T, response: I, failure: E });
1664
+ r(this, G, "f").call(this, W);
1665
+ }
1666
+ if (h === K.nativeBridge)
1667
+ return this.nativeCallbacks.complete = (I) => y(this, void 0, void 0, function* () {
1668
+ const E = yield this.sdk.flow.next(c, u, pe.submit, _.version, Q.componentsVersion, I);
1669
+ r(this, G, "f").call(this, E);
1670
+ }), r(this, w, "m", Le).call(this, xe, q), void setTimeout(() => {
1671
+ this.dispatchEvent(new Event("popupclosed"));
1672
+ }, 500);
1673
+ if ((s("action") || s("deferredPolling")) && r(this, ce, "f").call(this, c, u, _.version, Q.componentsVersion), !p && !N)
1674
+ return void this.loggerWrapper.warn("No screen was found to show");
1675
+ const qe = N || p, Di = yield this.getHtmlFilenameWithLocale(V, qe), { oidcLoginHint: Fi, oidcPrompt: Vi, oidcErrorRedirectUri: Bi, oidcResource: qi, samlIdpUsername: Ki } = U, ee = { direction: ws(u, t.stepId), screenState: Object.assign(Object.assign({}, m), { form: Object.assign(Object.assign({}, this.formConfigValues), m == null ? void 0 : m.form), lastAuth: { loginId: Y, name: this.sdk.getLastUserDisplayName() || Y }, componentsConfig: Object.assign(Object.assign(Object.assign({}, _.componentsConfig), yt), m == null ? void 0 : m.componentsConfig) }), htmlFilename: `${qe}.html`, htmlLocaleFilename: Di, screenId: qe, stepName: e.stepName || Be, samlIdpUsername: Ki, oidcLoginHint: Fi, oidcPrompt: Vi, oidcErrorRedirectUri: Bi, oidcResource: qi, action: h, locale: $e(V).locale }, Hi = Oe(Y);
1676
+ xt(N, U) ? ee.next = (I, E) => y(this, void 0, void 0, function* () {
1677
+ const W = (_ == null ? void 0 : _.clientScripts) || [];
1678
+ yield r(this, w, "m", st).call(this, W);
1679
+ const O = yield this.sdk.flow.start(l, Object.assign(Object.assign(Object.assign(Object.assign({ tenant: d, redirectAuth: bt }, U), { lastAuth: Hi, preview: this.preview, abTestingKey: _e, client: this.client }), C && { redirectUrl: C }), { locale: $e(V).locale, nativeOptions: wt, outboundAppId: ft, outboundAppScopes: mt }), Ie, I, Q.componentsVersion, vt, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.formConfigValues), this.getComponentsContext()), _t(E)), f && { exchangeCode: f, idpInitiated: !0 }), U.descopeIdpInitiated && { idpInitiated: !0 }), g && { token: g }), ee.next.isCustomScreen);
1680
+ return r(this, G, "f").call(this, O), O;
1681
+ }) : (s("projectId") || s("baseUrl") || s("executionId") || s("stepId")) && (ee.next = (I, E) => y(this, void 0, void 0, function* () {
1682
+ const W = (m == null ? void 0 : m.clientScripts) || [];
1683
+ yield r(this, w, "m", st).call(this, W);
1684
+ const O = yield this.sdk.flow.next(c, u, I, _.version, Q.componentsVersion, Object.assign(Object.assign({}, this.getComponentsContext()), _t(E)), ee.next.isCustomScreen);
1685
+ return r(this, G, "f").call(this, O), O;
1686
+ })), this.loggerWrapper.debug("Got a screen with id", ee.screenId), yield r(this, w, "m", Oi).call(this, ee), this.stepState.update(ee);
1687
+ });
1688
+ }
1689
+ onStepChange(e, t) {
1690
+ return y(this, void 0, void 0, function* () {
1691
+ var s, o, n;
1692
+ const { htmlFilename: a, htmlLocaleFilename: l, direction: d, next: u, screenState: c } = e;
1693
+ this.loggerWrapper.debug("Rendering a flow screen");
1694
+ const h = document.createElement("template");
1695
+ h.innerHTML = yield this.getPageContent(a, l);
1696
+ const p = h.content.cloneNode(!0), m = this.loadDescopeUiComponents(h);
1697
+ this.sdk.webauthn.helpers.isSupported() ? yield r(this, w, "m", Mi).call(this, p, u) : Io(p), !e.samlIdpUsername || !((s = c.form) === null || s === void 0) && s.loginId || !((o = c.form) === null || o === void 0) && o.email || (c.form || (c.form = {}), c.form.loginId = e.samlIdpUsername, c.form.email = e.samlIdpUsername), Co(p, c, this.formConfig, this.loggerWrapper);
1698
+ const { geo: v } = (n = yield this.getExecutionContext()) !== null && n !== void 0 ? n : {};
1699
+ Eo(p, v), xo(p, e.locale);
1700
+ const A = () => y(this, void 0, void 0, function* () {
1701
+ var C, g;
1702
+ yield m;
1703
+ const f = this.contentRootElement;
1704
+ ko(f, (C = c == null ? void 0 : c.totp) === null || C === void 0 ? void 0 : C.image), Ao(f, (g = c == null ? void 0 : c.notp) === null || g === void 0 ? void 0 : g.image), yo(f, p, c.cssVars, this.loggerWrapper), f.replaceChildren(p);
1705
+ const b = !t.htmlFilename;
1706
+ setTimeout(() => {
1707
+ r(this, w, "m", Li).call(this), this.validateOnBlur && oo(f), So(f, c), r(this, w, "m", it).call(this, { isFirstScreen: b, isCustomScreen: !1, stepName: e.stepName }), pi(f, this.autoFocus, b);
1708
+ }), r(this, w, "m", Wi).call(this, u), f.querySelector(`[${Fe}="polling"]`) && u(pe.polling, {});
1709
+ });
1710
+ d ? r(this, w, "m", Ze).call(this, A) : A();
1711
+ });
1712
+ }
1713
+ getInputs() {
1714
+ return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${lt}])`));
1715
+ }
1716
+ shouldUsePopupPostMessage() {
1717
+ if (!this.popupOrigin)
1718
+ return !1;
1719
+ try {
1720
+ new URL(this.popupOrigin);
1721
+ } catch {
1722
+ return !1;
1723
+ }
1724
+ return !0;
1725
+ }
1726
+ }
1727
+ fe = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), et = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakSet(), _i = function() {
1728
+ document.hidden || setTimeout(() => {
1729
+ this.flowState.update({ deferredRedirect: !1, deferredPolling: !1 });
1730
+ }, 300);
1731
+ }, Dt = function(i, e, t) {
1732
+ return y(this, void 0, void 0, function* () {
1733
+ var s;
1734
+ return ((s = this.nativeOptions) === null || s === void 0 ? void 0 : s.bridgeVersion) >= 2 && new Promise((o) => {
1735
+ this.nativeCallbacks.screenNext = t, this.nativeCallbacks.screenResolve = o, r(this, w, "m", Le).call(this, "beforeScreen", { screen: i, context: e });
1736
+ });
1737
+ });
1738
+ }, Ft = function(i) {
1739
+ var e;
1740
+ ((e = this.nativeOptions) === null || e === void 0 ? void 0 : e.bridgeVersion) >= 2 && r(this, w, "m", Le).call(this, "afterScreen", { screen: i });
1741
+ }, Le = function(i, e) {
1742
+ r(this, w, "m", z).call(this, "bridge", { type: i, payload: e });
1743
+ }, Vt = function({ errorText: i, errorType: e }) {
1744
+ const t = () => {
1745
+ var s;
1746
+ let o = i;
1747
+ try {
1748
+ o = ((s = this.errorTransformer) === null || s === void 0 ? void 0 : s.call(this, { text: i, type: e })) || i;
1749
+ } catch (n) {
1750
+ this.loggerWrapper.error("Error transforming error message", n.message);
1751
+ }
1752
+ wo(this.contentRootElement, "error-message", o);
1753
+ };
1754
+ this.addEventListener("screen-updated", t, { once: !0 }), t();
1755
+ }, Qe = function() {
1756
+ var i, e, t;
1757
+ (i = this.stepState) === null || i === void 0 || i.subscribe(this.onStepChange.bind(this), (s) => {
1758
+ var o = s.screenState, n = be(o === void 0 ? {} : o, ["errorText", "errorType"]), a = be(s, ["screenState"]);
1759
+ return Object.assign(Object.assign({}, a), { screenState: n });
1760
+ }), (e = this.stepState) === null || e === void 0 || e.subscribe(r(this, w, "m", Vt).bind(this), (s) => {
1761
+ var o, n;
1762
+ return { errorText: (o = s == null ? void 0 : s.screenState) === null || o === void 0 ? void 0 : o.errorText, errorType: (n = s == null ? void 0 : s.screenState) === null || n === void 0 ? void 0 : n.errorType };
1763
+ }, { forceUpdate: !0 }), (t = this.stepState) === null || t === void 0 || t.subscribe(r(this, w, "m", Bt).bind(this), (s) => {
1764
+ var o, n;
1765
+ return { errorText: (o = s == null ? void 0 : s.screenState) === null || o === void 0 ? void 0 : o.errorText, errorType: (n = s == null ? void 0 : s.screenState) === null || n === void 0 ? void 0 : n.errorType };
1766
+ }, { forceUpdate: !0 });
1767
+ }, Bt = function({ errorText: i, errorType: e }) {
1768
+ (e || i) && (this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t) => {
1769
+ t.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((s) => {
1770
+ s.value = "";
1771
+ });
1772
+ }), pi(this.contentRootElement, this.autoFocus, !1));
1773
+ }, $i = function() {
1774
+ return y(this, void 0, void 0, function* () {
1775
+ this.loggerWrapper.debug("Trying to restart the flow");
1776
+ const i = yield this.getComponentsVersion();
1777
+ this.reset(), i === (yield this.getComponentsVersion()) ? (this.loggerWrapper.debug("Components version was not changed, restarting flow"), this.flowState.update({ stepId: null, executionId: null })) : this.loggerWrapper.error("Components version mismatch, please reload the page");
1778
+ });
1779
+ }, Oi = function(i) {
1780
+ return y(this, void 0, void 0, function* () {
1781
+ var e;
1782
+ const t = Object.assign(Object.assign({}, this.stepState.current), i), { next: s, stepName: o } = t, n = be(t, ["next", "stepName"]), a = ho(n);
1783
+ let l = yield r(this, w, "m", Dt).call(this, o, a, s);
1784
+ l || (l = !!(yield (e = this.onScreenUpdate) === null || e === void 0 ? void 0 : e.call(this, o, a, s, this)));
1785
+ const d = !this.stepState.current.htmlFilename;
1786
+ if (r(this, Xe, "f").call(this, l), s && (s.isCustomScreen = l), r(this, We, "f") !== l) {
1787
+ const [u, c] = ["flow", "custom"].sort(() => l ? -1 : 1);
1788
+ this.loggerWrapper.debug(`Switching from ${c} screen to ${u} screen`), S(this, We, l, "f"), l ? this.stepState.unsubscribeAll() : r(this, w, "m", Qe).call(this);
1789
+ }
1790
+ l ? (this.loggerWrapper.debug("Showing a custom screen"), r(this, w, "m", it).call(this, { isFirstScreen: d, isCustomScreen: l, stepName: i.stepName }), this.disableKeyPressHandler()) : this.handleKeyPress(), this.stepState.forceUpdate = l;
1791
+ });
1792
+ }, Ze = function(i) {
1793
+ this.contentRootElement.addEventListener("transitionend", () => {
1794
+ this.loggerWrapper.debug("page switch transition end"), this.contentRootElement.classList.remove("fade-out"), i();
1795
+ }, { once: !0 }), this.loggerWrapper.debug("page switch transition start"), this.contentRootElement.classList.add("fade-out");
1796
+ }, qt = function(i) {
1797
+ const e = i.getAttribute("name");
1798
+ if (!["email"].includes(e)) {
1799
+ const t = `user-${e}`;
1800
+ i.setAttribute("name", t), i.addEventListener("input", () => {
1801
+ i.setAttribute("name", i.value ? e : t);
1802
+ });
1803
+ }
1804
+ }, Mi = function(i, e) {
1805
+ return y(this, void 0, void 0, function* () {
1806
+ var t;
1807
+ (t = r(this, J, "f")) === null || t === void 0 || t.abort();
1808
+ const s = i.querySelector('*[autocomplete="webauthn"]');
1809
+ if (s && (yield _o())) {
1810
+ const { options: o, transactionId: n } = (yield r(this, tt, "f").call(this)) || {};
1811
+ o && n && (r(this, w, "m", qt).call(this, s), S(this, J, new AbortController(), "f"), this.sdk.webauthn.helpers.conditional(o, r(this, J, "f")).then((a) => y(this, void 0, void 0, function* () {
1812
+ e(s.id, { transactionId: n, response: a });
1813
+ })).catch((a) => {
1814
+ a.name !== "AbortError" && this.loggerWrapper.error("Conditional login failed", a.message);
1815
+ }));
1816
+ }
1817
+ });
1818
+ }, it = function({ isFirstScreen: i, isCustomScreen: e, stepName: t }) {
1819
+ i && r(this, w, "m", z).call(this, "ready", {}), e || r(this, w, "m", Ft).call(this, t), r(this, w, "m", z).call(this, "page-updated", { screenName: t }), r(this, w, "m", z).call(this, "screen-updated", { screenName: t });
1820
+ }, Ui = function() {
1821
+ let i = !0;
1822
+ return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e) => {
1823
+ var t, s;
1824
+ e.localName === "slot" || e.classList.contains("hidden") || ((t = e.reportValidity) === null || t === void 0 || t.call(e), i && (i = (s = e.checkValidity) === null || s === void 0 ? void 0 : s.call(e)));
1825
+ }), i;
1826
+ }, ji = function() {
1827
+ return y(this, void 0, void 0, function* () {
1828
+ const i = this.getInputs();
1829
+ return (yield Promise.all(i.map((e) => y(this, void 0, void 0, function* () {
1830
+ return { name: e.getAttribute("name"), value: e.value };
1831
+ })))).reduce((e, t) => Object.assign(Object.assign({}, e), { [t.name]: t.value }), {});
1832
+ });
1833
+ }, Ri = function(i) {
1834
+ const e = Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((n) => n !== i), t = () => y(this, void 0, void 0, function* () {
1835
+ this.loggerWrapper.debug("Restoring components state"), this.removeEventListener("popupclosed", t), i.removeAttribute("loading"), e.forEach((l) => {
1836
+ l.removeAttribute("disabled");
1837
+ });
1838
+ const n = yield this.getFlowConfig(), a = [...n.clientScripts || [], ...n.sdkScripts || []];
1839
+ this.loadSdkScripts(a);
1840
+ }), s = () => {
1841
+ var n;
1842
+ window.removeEventListener("pageshow", r(this, ve, "f")), S(this, ve, (l) => {
1843
+ l.persisted && (this.logger.debug("Page was loaded from cache, restoring components state"), t());
1844
+ }, "f"), window.addEventListener("pageshow", r(this, ve, "f"), { once: !0 });
1845
+ const a = (n = this.stepState) === null || n === void 0 ? void 0 : n.subscribe((l, d) => {
1846
+ l === d && t(), this.removeEventListener("popupclosed", t), this.stepState.unsubscribe(a);
1847
+ }, (l) => l.screenId, { forceUpdate: !0 });
1848
+ }, o = this.nextRequestStatus.subscribe(({ isLoading: n }) => {
1849
+ n ? (this.addEventListener("popupclosed", t, { once: !0 }), i.setAttribute("loading", "true"), e.forEach((a) => a.setAttribute("disabled", "true"))) : (this.nextRequestStatus.unsubscribe(o), s());
1850
+ });
1851
+ }, Ti = function(i = {}) {
1852
+ var e, t;
1853
+ const s = It(i, ["externalId", "email", "phone"]), o = It(i, ["newPassword", "password"]);
1854
+ if (s && o)
1855
+ try {
1856
+ if (!globalThis.PasswordCredential)
1857
+ return;
1858
+ const n = new globalThis.PasswordCredential({ id: s, password: o });
1859
+ (t = (e = navigator == null ? void 0 : navigator.credentials) === null || e === void 0 ? void 0 : e.store) === null || t === void 0 || t.call(e, n);
1860
+ } catch (n) {
1861
+ this.loggerWrapper.error("Could not store credentials", n.message);
1862
+ }
1863
+ }, Li = function() {
1864
+ co(), this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((i) => r(this, w, "m", Kt).call(this, i));
1865
+ }, Kt = function(i) {
1866
+ i && i.querySelectorAll("input").forEach((e) => {
1867
+ const t = e.getAttribute("slot"), s = `input-${i.id}-${t}`, o = document.createElement("slot");
1868
+ o.setAttribute("name", s), o.setAttribute("slot", t), i.appendChild(o), e.setAttribute("slot", s), this.appendChild(e);
1869
+ });
1870
+ }, st = function(i) {
1871
+ return y(this, void 0, void 0, function* () {
1872
+ if (r(this, ue, "f")) {
1873
+ this.loggerWrapper.debug("Waiting for sdk scripts to load");
1874
+ const o = Date.now();
1875
+ yield r(this, ue, "f"), this.loggerWrapper.debug("Sdk scripts loaded for", (Date.now() - o).toString());
1876
+ }
1877
+ const e = this.loadSdkScriptsModules(), t = i.map((o) => o.id);
1878
+ for (const o of e)
1879
+ if (t.includes(o.id))
1880
+ try {
1881
+ typeof o.present == "function" && ((yield o.present()) || this.loggerWrapper.debug(`Sdk script ${o.id} was cancelled`));
1882
+ } catch (n) {
1883
+ this.loggerWrapper.error(`Failed to present ${o.id} script module`, n.message);
1884
+ }
1885
+ const s = [];
1886
+ for (const o of e)
1887
+ typeof o.refresh == "function" && s.push(o.refresh());
1888
+ if (s.length > 0)
1889
+ try {
1890
+ yield ct(li, Promise.all(s), null);
1891
+ } catch (o) {
1892
+ this.loggerWrapper.error("Failed to refresh script module", o.message);
1893
+ }
1894
+ });
1895
+ }, Ht = function(i) {
1896
+ this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e) => {
1897
+ e.addEventListener("input", () => {
1898
+ var t;
1899
+ !((t = e.checkValidity) === null || t === void 0) && t.call(e) && r(this, Pe, "f").call(this, e, i);
1900
+ });
1901
+ });
1902
+ }, Wi = function(i) {
1903
+ this.contentRootElement.querySelectorAll(`descope-button:not([${Et}]), [data-type="button"]:not([${Et}]`).forEach((e) => {
1904
+ e.onclick = () => {
1905
+ r(this, Pe, "f").call(this, e, i);
1906
+ };
1907
+ }), r(this, w, "m", Ht).call(this, i), this.isDismissScreenErrorOnInput && this.contentRootElement.querySelectorAll(`*[name]:not([${lt}])`).forEach((e) => {
1908
+ e.addEventListener("input", () => {
1909
+ this.stepState.update((t) => Object.assign(Object.assign({}, t), { screenState: Object.assign(Object.assign({}, t.screenState), { errorText: "", errorType: "" }) }));
1910
+ });
1911
+ });
1912
+ }, z = function(i, e) {
1913
+ this.dispatchEvent(new CustomEvent(i, { detail: e }));
1914
+ }, Pi = function(i, e, t) {
1915
+ var s;
1916
+ const [o, n] = ((s = window.name) === null || s === void 0 ? void 0 : s.split("|")) || [], a = { data: { code: e, exchangeError: t }, action: "code" };
1917
+ if (o === "descope-wc" && n) {
1918
+ this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin", n);
1919
+ try {
1920
+ window.opener.postMessage(a, n);
1921
+ } catch (l) {
1922
+ this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)", l == null ? void 0 : l.message);
1923
+ }
1924
+ } else {
1925
+ this.loggerWrapper.debug("Creating popup channel", i);
1926
+ const l = new BroadcastChannel(i);
1927
+ l.postMessage(a), l.close();
1928
+ }
1929
+ try {
1930
+ window.close();
1931
+ } catch {
1932
+ }
1933
+ };
1934
+ customElements.get("descope-wc") ? console.log("descope-wc is already defined") : customElements.define("descope-wc", Ni);
1935
+ const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1936
+ __proto__: null,
1937
+ default: Ni
1938
+ }, Symbol.toStringTag, { value: "Module" }));
1939
+ export {
1940
+ Ln as a,
1941
+ we as c,
1942
+ gt as i
1943
+ };
1944
+ //# sourceMappingURL=index.es3.js.map