@cal.macconnachie/web-components 1.0.1 → 1.0.3

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.
@@ -1,2436 +0,0 @@
1
- const B = globalThis, Z = B.ShadowRoot && (B.ShadyCSS === void 0 || B.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Q = Symbol(), ot = /* @__PURE__ */ new WeakMap();
2
- let $t = class {
3
- constructor(t, s, r) {
4
- if (this._$cssResult$ = !0, r !== Q) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
5
- this.cssText = t, this.t = s;
6
- }
7
- get styleSheet() {
8
- let t = this.o;
9
- const s = this.t;
10
- if (Z && t === void 0) {
11
- const r = s !== void 0 && s.length === 1;
12
- r && (t = ot.get(s)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && ot.set(s, t));
13
- }
14
- return t;
15
- }
16
- toString() {
17
- return this.cssText;
18
- }
19
- };
20
- const St = (e) => new $t(typeof e == "string" ? e : e + "", void 0, Q), kt = (e, ...t) => {
21
- const s = e.length === 1 ? e[0] : t.reduce(((r, i, o) => r + ((a) => {
22
- if (a._$cssResult$ === !0) return a.cssText;
23
- if (typeof a == "number") return a;
24
- throw Error("Value passed to 'css' function must be a 'css' function result: " + a + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
25
- })(i) + e[o + 1]), e[0]);
26
- return new $t(s, e, Q);
27
- }, Et = (e, t) => {
28
- if (Z) e.adoptedStyleSheets = t.map(((s) => s instanceof CSSStyleSheet ? s : s.styleSheet));
29
- else for (const s of t) {
30
- const r = document.createElement("style"), i = B.litNonce;
31
- i !== void 0 && r.setAttribute("nonce", i), r.textContent = s.cssText, e.appendChild(r);
32
- }
33
- }, at = Z ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => {
34
- let s = "";
35
- for (const r of t.cssRules) s += r.cssText;
36
- return St(s);
37
- })(e) : e;
38
- const { is: xt, defineProperty: Ct, getOwnPropertyDescriptor: Tt, getOwnPropertyNames: Pt, getOwnPropertySymbols: Ot, getPrototypeOf: Ut } = Object, W = globalThis, nt = W.trustedTypes, Rt = nt ? nt.emptyScript : "", Dt = W.reactiveElementPolyfillSupport, M = (e, t) => e, K = { toAttribute(e, t) {
39
- switch (t) {
40
- case Boolean:
41
- e = e ? Rt : null;
42
- break;
43
- case Object:
44
- case Array:
45
- e = e == null ? e : JSON.stringify(e);
46
- }
47
- return e;
48
- }, fromAttribute(e, t) {
49
- let s = e;
50
- switch (t) {
51
- case Boolean:
52
- s = e !== null;
53
- break;
54
- case Number:
55
- s = e === null ? null : Number(e);
56
- break;
57
- case Object:
58
- case Array:
59
- try {
60
- s = JSON.parse(e);
61
- } catch {
62
- s = null;
63
- }
64
- }
65
- return s;
66
- } }, X = (e, t) => !xt(e, t), lt = { attribute: !0, type: String, converter: K, reflect: !1, useDefault: !1, hasChanged: X };
67
- Symbol.metadata ??= Symbol("metadata"), W.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
68
- let R = class extends HTMLElement {
69
- static addInitializer(t) {
70
- this._$Ei(), (this.l ??= []).push(t);
71
- }
72
- static get observedAttributes() {
73
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
74
- }
75
- static createProperty(t, s = lt) {
76
- if (s.state && (s.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = !0), this.elementProperties.set(t, s), !s.noAccessor) {
77
- const r = Symbol(), i = this.getPropertyDescriptor(t, r, s);
78
- i !== void 0 && Ct(this.prototype, t, i);
79
- }
80
- }
81
- static getPropertyDescriptor(t, s, r) {
82
- const { get: i, set: o } = Tt(this.prototype, t) ?? { get() {
83
- return this[s];
84
- }, set(a) {
85
- this[s] = a;
86
- } };
87
- return { get: i, set(a) {
88
- const p = i?.call(this);
89
- o?.call(this, a), this.requestUpdate(t, p, r);
90
- }, configurable: !0, enumerable: !0 };
91
- }
92
- static getPropertyOptions(t) {
93
- return this.elementProperties.get(t) ?? lt;
94
- }
95
- static _$Ei() {
96
- if (this.hasOwnProperty(M("elementProperties"))) return;
97
- const t = Ut(this);
98
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
99
- }
100
- static finalize() {
101
- if (this.hasOwnProperty(M("finalized"))) return;
102
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(M("properties"))) {
103
- const s = this.properties, r = [...Pt(s), ...Ot(s)];
104
- for (const i of r) this.createProperty(i, s[i]);
105
- }
106
- const t = this[Symbol.metadata];
107
- if (t !== null) {
108
- const s = litPropertyMetadata.get(t);
109
- if (s !== void 0) for (const [r, i] of s) this.elementProperties.set(r, i);
110
- }
111
- this._$Eh = /* @__PURE__ */ new Map();
112
- for (const [s, r] of this.elementProperties) {
113
- const i = this._$Eu(s, r);
114
- i !== void 0 && this._$Eh.set(i, s);
115
- }
116
- this.elementStyles = this.finalizeStyles(this.styles);
117
- }
118
- static finalizeStyles(t) {
119
- const s = [];
120
- if (Array.isArray(t)) {
121
- const r = new Set(t.flat(1 / 0).reverse());
122
- for (const i of r) s.unshift(at(i));
123
- } else t !== void 0 && s.push(at(t));
124
- return s;
125
- }
126
- static _$Eu(t, s) {
127
- const r = s.attribute;
128
- return r === !1 ? void 0 : typeof r == "string" ? r : typeof t == "string" ? t.toLowerCase() : void 0;
129
- }
130
- constructor() {
131
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
132
- }
133
- _$Ev() {
134
- this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
135
- }
136
- addController(t) {
137
- (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
138
- }
139
- removeController(t) {
140
- this._$EO?.delete(t);
141
- }
142
- _$E_() {
143
- const t = /* @__PURE__ */ new Map(), s = this.constructor.elementProperties;
144
- for (const r of s.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]);
145
- t.size > 0 && (this._$Ep = t);
146
- }
147
- createRenderRoot() {
148
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
149
- return Et(t, this.constructor.elementStyles), t;
150
- }
151
- connectedCallback() {
152
- this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
153
- }
154
- enableUpdating(t) {
155
- }
156
- disconnectedCallback() {
157
- this._$EO?.forEach(((t) => t.hostDisconnected?.()));
158
- }
159
- attributeChangedCallback(t, s, r) {
160
- this._$AK(t, r);
161
- }
162
- _$ET(t, s) {
163
- const r = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, r);
164
- if (i !== void 0 && r.reflect === !0) {
165
- const o = (r.converter?.toAttribute !== void 0 ? r.converter : K).toAttribute(s, r.type);
166
- this._$Em = t, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
167
- }
168
- }
169
- _$AK(t, s) {
170
- const r = this.constructor, i = r._$Eh.get(t);
171
- if (i !== void 0 && this._$Em !== i) {
172
- const o = r.getPropertyOptions(i), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : K;
173
- this._$Em = i;
174
- const p = a.fromAttribute(s, o.type);
175
- this[i] = p ?? this._$Ej?.get(i) ?? p, this._$Em = null;
176
- }
177
- }
178
- requestUpdate(t, s, r) {
179
- if (t !== void 0) {
180
- const i = this.constructor, o = this[t];
181
- if (r ??= i.getPropertyOptions(t), !((r.hasChanged ?? X)(o, s) || r.useDefault && r.reflect && o === this._$Ej?.get(t) && !this.hasAttribute(i._$Eu(t, r)))) return;
182
- this.C(t, s, r);
183
- }
184
- this.isUpdatePending === !1 && (this._$ES = this._$EP());
185
- }
186
- C(t, s, { useDefault: r, reflect: i, wrapped: o }, a) {
187
- r && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, a ?? s ?? this[t]), o !== !0 || a !== void 0) || (this._$AL.has(t) || (this.hasUpdated || r || (s = void 0), this._$AL.set(t, s)), i === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
188
- }
189
- async _$EP() {
190
- this.isUpdatePending = !0;
191
- try {
192
- await this._$ES;
193
- } catch (s) {
194
- Promise.reject(s);
195
- }
196
- const t = this.scheduleUpdate();
197
- return t != null && await t, !this.isUpdatePending;
198
- }
199
- scheduleUpdate() {
200
- return this.performUpdate();
201
- }
202
- performUpdate() {
203
- if (!this.isUpdatePending) return;
204
- if (!this.hasUpdated) {
205
- if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
206
- for (const [i, o] of this._$Ep) this[i] = o;
207
- this._$Ep = void 0;
208
- }
209
- const r = this.constructor.elementProperties;
210
- if (r.size > 0) for (const [i, o] of r) {
211
- const { wrapped: a } = o, p = this[i];
212
- a !== !0 || this._$AL.has(i) || p === void 0 || this.C(i, void 0, o, p);
213
- }
214
- }
215
- let t = !1;
216
- const s = this._$AL;
217
- try {
218
- t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(((r) => r.hostUpdate?.())), this.update(s)) : this._$EM();
219
- } catch (r) {
220
- throw t = !1, this._$EM(), r;
221
- }
222
- t && this._$AE(s);
223
- }
224
- willUpdate(t) {
225
- }
226
- _$AE(t) {
227
- this._$EO?.forEach(((s) => s.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
228
- }
229
- _$EM() {
230
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
231
- }
232
- get updateComplete() {
233
- return this.getUpdateComplete();
234
- }
235
- getUpdateComplete() {
236
- return this._$ES;
237
- }
238
- shouldUpdate(t) {
239
- return !0;
240
- }
241
- update(t) {
242
- this._$Eq &&= this._$Eq.forEach(((s) => this._$ET(s, this[s]))), this._$EM();
243
- }
244
- updated(t) {
245
- }
246
- firstUpdated(t) {
247
- }
248
- };
249
- R.elementStyles = [], R.shadowRootOptions = { mode: "open" }, R[M("elementProperties")] = /* @__PURE__ */ new Map(), R[M("finalized")] = /* @__PURE__ */ new Map(), Dt?.({ ReactiveElement: R }), (W.reactiveElementVersions ??= []).push("2.1.1");
250
- const tt = globalThis, F = tt.trustedTypes, ht = F ? F.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, bt = "$lit$", E = `lit$${Math.random().toFixed(9).slice(2)}$`, wt = "?" + E, It = `<${wt}>`, O = document, j = () => O.createComment(""), q = (e) => e === null || typeof e != "object" && typeof e != "function", et = Array.isArray, Nt = (e) => et(e) || typeof e?.[Symbol.iterator] == "function", G = `[
251
- \f\r]`, N = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ct = /-->/g, dt = />/g, C = RegExp(`>|${G}(?:([^\\s"'>=/]+)(${G}*=${G}*(?:[^
252
- \f\r"'\`<>=]|("|')|))|$)`, "g"), pt = /'/g, ut = /"/g, vt = /^(?:script|style|textarea|title)$/i, Lt = (e) => (t, ...s) => ({ _$litType$: e, strings: t, values: s }), m = Lt(1), U = Symbol.for("lit-noChange"), g = Symbol.for("lit-nothing"), gt = /* @__PURE__ */ new WeakMap(), P = O.createTreeWalker(O, 129);
253
- function At(e, t) {
254
- if (!et(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
255
- return ht !== void 0 ? ht.createHTML(t) : t;
256
- }
257
- const Mt = (e, t) => {
258
- const s = e.length - 1, r = [];
259
- let i, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = N;
260
- for (let p = 0; p < s; p++) {
261
- const n = e[p];
262
- let h, c, l = -1, d = 0;
263
- for (; d < n.length && (a.lastIndex = d, c = a.exec(n), c !== null); ) d = a.lastIndex, a === N ? c[1] === "!--" ? a = ct : c[1] !== void 0 ? a = dt : c[2] !== void 0 ? (vt.test(c[2]) && (i = RegExp("</" + c[2], "g")), a = C) : c[3] !== void 0 && (a = C) : a === C ? c[0] === ">" ? (a = i ?? N, l = -1) : c[1] === void 0 ? l = -2 : (l = a.lastIndex - c[2].length, h = c[1], a = c[3] === void 0 ? C : c[3] === '"' ? ut : pt) : a === ut || a === pt ? a = C : a === ct || a === dt ? a = N : (a = C, i = void 0);
264
- const u = a === C && e[p + 1].startsWith("/>") ? " " : "";
265
- o += a === N ? n + It : l >= 0 ? (r.push(h), n.slice(0, l) + bt + n.slice(l) + E + u) : n + E + (l === -2 ? p : u);
266
- }
267
- return [At(e, o + (e[s] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
268
- };
269
- class z {
270
- constructor({ strings: t, _$litType$: s }, r) {
271
- let i;
272
- this.parts = [];
273
- let o = 0, a = 0;
274
- const p = t.length - 1, n = this.parts, [h, c] = Mt(t, s);
275
- if (this.el = z.createElement(h, r), P.currentNode = this.el.content, s === 2 || s === 3) {
276
- const l = this.el.content.firstChild;
277
- l.replaceWith(...l.childNodes);
278
- }
279
- for (; (i = P.nextNode()) !== null && n.length < p; ) {
280
- if (i.nodeType === 1) {
281
- if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(bt)) {
282
- const d = c[a++], u = i.getAttribute(l).split(E), f = /([.?@])?(.*)/.exec(d);
283
- n.push({ type: 1, index: o, name: f[2], strings: u, ctor: f[1] === "." ? jt : f[1] === "?" ? qt : f[1] === "@" ? zt : V }), i.removeAttribute(l);
284
- } else l.startsWith(E) && (n.push({ type: 6, index: o }), i.removeAttribute(l));
285
- if (vt.test(i.tagName)) {
286
- const l = i.textContent.split(E), d = l.length - 1;
287
- if (d > 0) {
288
- i.textContent = F ? F.emptyScript : "";
289
- for (let u = 0; u < d; u++) i.append(l[u], j()), P.nextNode(), n.push({ type: 2, index: ++o });
290
- i.append(l[d], j());
291
- }
292
- }
293
- } else if (i.nodeType === 8) if (i.data === wt) n.push({ type: 2, index: o });
294
- else {
295
- let l = -1;
296
- for (; (l = i.data.indexOf(E, l + 1)) !== -1; ) n.push({ type: 7, index: o }), l += E.length - 1;
297
- }
298
- o++;
299
- }
300
- }
301
- static createElement(t, s) {
302
- const r = O.createElement("template");
303
- return r.innerHTML = t, r;
304
- }
305
- }
306
- function D(e, t, s = e, r) {
307
- if (t === U) return t;
308
- let i = r !== void 0 ? s._$Co?.[r] : s._$Cl;
309
- const o = q(t) ? void 0 : t._$litDirective$;
310
- return i?.constructor !== o && (i?._$AO?.(!1), o === void 0 ? i = void 0 : (i = new o(e), i._$AT(e, s, r)), r !== void 0 ? (s._$Co ??= [])[r] = i : s._$Cl = i), i !== void 0 && (t = D(e, i._$AS(e, t.values), i, r)), t;
311
- }
312
- let Ht = class {
313
- constructor(t, s) {
314
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = s;
315
- }
316
- get parentNode() {
317
- return this._$AM.parentNode;
318
- }
319
- get _$AU() {
320
- return this._$AM._$AU;
321
- }
322
- u(t) {
323
- const { el: { content: s }, parts: r } = this._$AD, i = (t?.creationScope ?? O).importNode(s, !0);
324
- P.currentNode = i;
325
- let o = P.nextNode(), a = 0, p = 0, n = r[0];
326
- for (; n !== void 0; ) {
327
- if (a === n.index) {
328
- let h;
329
- n.type === 2 ? h = new I(o, o.nextSibling, this, t) : n.type === 1 ? h = new n.ctor(o, n.name, n.strings, this, t) : n.type === 6 && (h = new Bt(o, this, t)), this._$AV.push(h), n = r[++p];
330
- }
331
- a !== n?.index && (o = P.nextNode(), a++);
332
- }
333
- return P.currentNode = O, i;
334
- }
335
- p(t) {
336
- let s = 0;
337
- for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, s), s += r.strings.length - 2) : r._$AI(t[s])), s++;
338
- }
339
- };
340
- class I {
341
- get _$AU() {
342
- return this._$AM?._$AU ?? this._$Cv;
343
- }
344
- constructor(t, s, r, i) {
345
- this.type = 2, this._$AH = g, this._$AN = void 0, this._$AA = t, this._$AB = s, this._$AM = r, this.options = i, this._$Cv = i?.isConnected ?? !0;
346
- }
347
- get parentNode() {
348
- let t = this._$AA.parentNode;
349
- const s = this._$AM;
350
- return s !== void 0 && t?.nodeType === 11 && (t = s.parentNode), t;
351
- }
352
- get startNode() {
353
- return this._$AA;
354
- }
355
- get endNode() {
356
- return this._$AB;
357
- }
358
- _$AI(t, s = this) {
359
- t = D(this, t, s), q(t) ? t === g || t == null || t === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : t !== this._$AH && t !== U && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Nt(t) ? this.k(t) : this._(t);
360
- }
361
- O(t) {
362
- return this._$AA.parentNode.insertBefore(t, this._$AB);
363
- }
364
- T(t) {
365
- this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
366
- }
367
- _(t) {
368
- this._$AH !== g && q(this._$AH) ? this._$AA.nextSibling.data = t : this.T(O.createTextNode(t)), this._$AH = t;
369
- }
370
- $(t) {
371
- const { values: s, _$litType$: r } = t, i = typeof r == "number" ? this._$AC(t) : (r.el === void 0 && (r.el = z.createElement(At(r.h, r.h[0]), this.options)), r);
372
- if (this._$AH?._$AD === i) this._$AH.p(s);
373
- else {
374
- const o = new Ht(i, this), a = o.u(this.options);
375
- o.p(s), this.T(a), this._$AH = o;
376
- }
377
- }
378
- _$AC(t) {
379
- let s = gt.get(t.strings);
380
- return s === void 0 && gt.set(t.strings, s = new z(t)), s;
381
- }
382
- k(t) {
383
- et(this._$AH) || (this._$AH = [], this._$AR());
384
- const s = this._$AH;
385
- let r, i = 0;
386
- for (const o of t) i === s.length ? s.push(r = new I(this.O(j()), this.O(j()), this, this.options)) : r = s[i], r._$AI(o), i++;
387
- i < s.length && (this._$AR(r && r._$AB.nextSibling, i), s.length = i);
388
- }
389
- _$AR(t = this._$AA.nextSibling, s) {
390
- for (this._$AP?.(!1, !0, s); t !== this._$AB; ) {
391
- const r = t.nextSibling;
392
- t.remove(), t = r;
393
- }
394
- }
395
- setConnected(t) {
396
- this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
397
- }
398
- }
399
- class V {
400
- get tagName() {
401
- return this.element.tagName;
402
- }
403
- get _$AU() {
404
- return this._$AM._$AU;
405
- }
406
- constructor(t, s, r, i, o) {
407
- this.type = 1, this._$AH = g, this._$AN = void 0, this.element = t, this.name = s, this._$AM = i, this.options = o, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = g;
408
- }
409
- _$AI(t, s = this, r, i) {
410
- const o = this.strings;
411
- let a = !1;
412
- if (o === void 0) t = D(this, t, s, 0), a = !q(t) || t !== this._$AH && t !== U, a && (this._$AH = t);
413
- else {
414
- const p = t;
415
- let n, h;
416
- for (t = o[0], n = 0; n < o.length - 1; n++) h = D(this, p[r + n], s, n), h === U && (h = this._$AH[n]), a ||= !q(h) || h !== this._$AH[n], h === g ? t = g : t !== g && (t += (h ?? "") + o[n + 1]), this._$AH[n] = h;
417
- }
418
- a && !i && this.j(t);
419
- }
420
- j(t) {
421
- t === g ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
422
- }
423
- }
424
- class jt extends V {
425
- constructor() {
426
- super(...arguments), this.type = 3;
427
- }
428
- j(t) {
429
- this.element[this.name] = t === g ? void 0 : t;
430
- }
431
- }
432
- class qt extends V {
433
- constructor() {
434
- super(...arguments), this.type = 4;
435
- }
436
- j(t) {
437
- this.element.toggleAttribute(this.name, !!t && t !== g);
438
- }
439
- }
440
- class zt extends V {
441
- constructor(t, s, r, i, o) {
442
- super(t, s, r, i, o), this.type = 5;
443
- }
444
- _$AI(t, s = this) {
445
- if ((t = D(this, t, s, 0) ?? g) === U) return;
446
- const r = this._$AH, i = t === g && r !== g || t.capture !== r.capture || t.once !== r.once || t.passive !== r.passive, o = t !== g && (r === g || i);
447
- i && this.element.removeEventListener(this.name, this, r), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
448
- }
449
- handleEvent(t) {
450
- typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
451
- }
452
- }
453
- class Bt {
454
- constructor(t, s, r) {
455
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = s, this.options = r;
456
- }
457
- get _$AU() {
458
- return this._$AM._$AU;
459
- }
460
- _$AI(t) {
461
- D(this, t);
462
- }
463
- }
464
- const Kt = { I }, Ft = tt.litHtmlPolyfillSupport;
465
- Ft?.(z, I), (tt.litHtmlVersions ??= []).push("3.3.1");
466
- const Wt = (e, t, s) => {
467
- const r = s?.renderBefore ?? t;
468
- let i = r._$litPart$;
469
- if (i === void 0) {
470
- const o = s?.renderBefore ?? null;
471
- r._$litPart$ = i = new I(t.insertBefore(j(), o), o, void 0, s ?? {});
472
- }
473
- return i._$AI(e), i;
474
- };
475
- const st = globalThis;
476
- let H = class extends R {
477
- constructor() {
478
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
479
- }
480
- createRenderRoot() {
481
- const t = super.createRenderRoot();
482
- return this.renderOptions.renderBefore ??= t.firstChild, t;
483
- }
484
- update(t) {
485
- const s = this.render();
486
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Wt(s, this.renderRoot, this.renderOptions);
487
- }
488
- connectedCallback() {
489
- super.connectedCallback(), this._$Do?.setConnected(!0);
490
- }
491
- disconnectedCallback() {
492
- super.disconnectedCallback(), this._$Do?.setConnected(!1);
493
- }
494
- render() {
495
- return U;
496
- }
497
- };
498
- H._$litElement$ = !0, H.finalized = !0, st.litElementHydrateSupport?.({ LitElement: H });
499
- const Vt = st.litElementPolyfillSupport;
500
- Vt?.({ LitElement: H });
501
- (st.litElementVersions ??= []).push("4.2.1");
502
- const Gt = (e) => (t, s) => {
503
- s !== void 0 ? s.addInitializer((() => {
504
- customElements.define(e, t);
505
- })) : customElements.define(e, t);
506
- };
507
- const Jt = { attribute: !0, type: String, converter: K, reflect: !1, hasChanged: X }, Yt = (e = Jt, t, s) => {
508
- const { kind: r, metadata: i } = s;
509
- let o = globalThis.litPropertyMetadata.get(i);
510
- if (o === void 0 && globalThis.litPropertyMetadata.set(i, o = /* @__PURE__ */ new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), o.set(s.name, e), r === "accessor") {
511
- const { name: a } = s;
512
- return { set(p) {
513
- const n = t.get.call(this);
514
- t.set.call(this, p), this.requestUpdate(a, n, e);
515
- }, init(p) {
516
- return p !== void 0 && this.C(a, void 0, e, p), p;
517
- } };
518
- }
519
- if (r === "setter") {
520
- const { name: a } = s;
521
- return function(p) {
522
- const n = this[a];
523
- t.call(this, p), this.requestUpdate(a, n, e);
524
- };
525
- }
526
- throw Error("Unsupported decorator location: " + r);
527
- };
528
- function S(e) {
529
- return (t, s) => typeof s == "object" ? Yt(e, t, s) : ((r, i, o) => {
530
- const a = i.hasOwnProperty(o);
531
- return i.constructor.createProperty(o, r), a ? Object.getOwnPropertyDescriptor(i, o) : void 0;
532
- })(e, t, s);
533
- }
534
- function v(e) {
535
- return S({ ...e, state: !0, attribute: !1 });
536
- }
537
- const Zt = (e, t, s) => (s.configurable = !0, s.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(e, t, s), s);
538
- function Qt(e, t) {
539
- return (s, r, i) => {
540
- const o = (a) => a.renderRoot?.querySelector(e) ?? null;
541
- return Zt(s, r, { get() {
542
- return o(this);
543
- } });
544
- };
545
- }
546
- const Xt = { CHILD: 2 }, te = (e) => (...t) => ({ _$litDirective$: e, values: t });
547
- class ee {
548
- constructor(t) {
549
- }
550
- get _$AU() {
551
- return this._$AM._$AU;
552
- }
553
- _$AT(t, s, r) {
554
- this._$Ct = t, this._$AM = s, this._$Ci = r;
555
- }
556
- _$AS(t, s) {
557
- return this.update(t, s);
558
- }
559
- update(t, s) {
560
- return this.render(...s);
561
- }
562
- }
563
- const { I: se } = Kt, mt = () => document.createComment(""), L = (e, t, s) => {
564
- const r = e._$AA.parentNode, i = t === void 0 ? e._$AB : t._$AA;
565
- if (s === void 0) {
566
- const o = r.insertBefore(mt(), i), a = r.insertBefore(mt(), i);
567
- s = new se(o, a, e, e.options);
568
- } else {
569
- const o = s._$AB.nextSibling, a = s._$AM, p = a !== e;
570
- if (p) {
571
- let n;
572
- s._$AQ?.(e), s._$AM = e, s._$AP !== void 0 && (n = e._$AU) !== a._$AU && s._$AP(n);
573
- }
574
- if (o !== i || p) {
575
- let n = s._$AA;
576
- for (; n !== o; ) {
577
- const h = n.nextSibling;
578
- r.insertBefore(n, i), n = h;
579
- }
580
- }
581
- }
582
- return s;
583
- }, T = (e, t, s = e) => (e._$AI(t, s), e), ie = {}, re = (e, t = ie) => e._$AH = t, oe = (e) => e._$AH, J = (e) => {
584
- e._$AR(), e._$AA.remove();
585
- };
586
- const ft = (e, t, s) => {
587
- const r = /* @__PURE__ */ new Map();
588
- for (let i = t; i <= s; i++) r.set(e[i], i);
589
- return r;
590
- }, yt = te(class extends ee {
591
- constructor(e) {
592
- if (super(e), e.type !== Xt.CHILD) throw Error("repeat() can only be used in text expressions");
593
- }
594
- dt(e, t, s) {
595
- let r;
596
- s === void 0 ? s = t : t !== void 0 && (r = t);
597
- const i = [], o = [];
598
- let a = 0;
599
- for (const p of e) i[a] = r ? r(p, a) : a, o[a] = s(p, a), a++;
600
- return { values: o, keys: i };
601
- }
602
- render(e, t, s) {
603
- return this.dt(e, t, s).values;
604
- }
605
- update(e, [t, s, r]) {
606
- const i = oe(e), { values: o, keys: a } = this.dt(t, s, r);
607
- if (!Array.isArray(i)) return this.ut = a, o;
608
- const p = this.ut ??= [], n = [];
609
- let h, c, l = 0, d = i.length - 1, u = 0, f = o.length - 1;
610
- for (; l <= d && u <= f; ) if (i[l] === null) l++;
611
- else if (i[d] === null) d--;
612
- else if (p[l] === a[u]) n[u] = T(i[l], o[u]), l++, u++;
613
- else if (p[d] === a[f]) n[f] = T(i[d], o[f]), d--, f--;
614
- else if (p[l] === a[f]) n[f] = T(i[l], o[f]), L(e, n[f + 1], i[l]), l++, f--;
615
- else if (p[d] === a[u]) n[u] = T(i[d], o[u]), L(e, i[l], i[d]), d--, u++;
616
- else if (h === void 0 && (h = ft(a, u, f), c = ft(p, l, d)), h.has(p[l])) if (h.has(p[d])) {
617
- const w = c.get(a[u]), A = w !== void 0 ? i[w] : null;
618
- if (A === null) {
619
- const b = L(e, i[l]);
620
- T(b, o[u]), n[u] = b;
621
- } else n[u] = T(A, o[u]), L(e, i[l], A), i[w] = null;
622
- u++;
623
- } else J(i[d]), d--;
624
- else J(i[l]), l++;
625
- for (; u <= f; ) {
626
- const w = L(e, n[f + 1]);
627
- T(w, o[u]), n[u++] = w;
628
- }
629
- for (; l <= d; ) {
630
- const w = i[l++];
631
- w !== null && J(w);
632
- }
633
- return this.ut = a, re(e, n), U;
634
- }
635
- });
636
- var ae = Object.defineProperty, _t = (e, t, s, r) => {
637
- for (var i = void 0, o = e.length - 1, a; o >= 0; o--)
638
- (a = e[o]) && (i = a(t, s, i) || i);
639
- return i && ae(t, s, i), i;
640
- };
641
- class it extends H {
642
- constructor() {
643
- super(...arguments), this.theme = "light", this.storageKey = "theme-preference", this.boundThemeChangeHandler = this.handleGlobalThemeChange.bind(this);
644
- }
645
- connectedCallback() {
646
- super.connectedCallback();
647
- const t = document.documentElement.getAttribute("data-theme"), s = localStorage.getItem(this.storageKey), r = window.matchMedia("(prefers-color-scheme: dark)").matches;
648
- t ? this.theme = t : s ? (this.theme = s, this.applyTheme()) : r ? (this.theme = "dark", this.applyTheme()) : this.applyTheme(), window.addEventListener("theme-changed", this.boundThemeChangeHandler);
649
- }
650
- disconnectedCallback() {
651
- window.removeEventListener("theme-changed", this.boundThemeChangeHandler), super.disconnectedCallback();
652
- }
653
- handleGlobalThemeChange(t) {
654
- const s = t;
655
- s.target !== this && s.detail.theme !== this.theme && (this.theme = s.detail.theme);
656
- }
657
- applyTheme() {
658
- document.documentElement.setAttribute("data-theme", this.theme), localStorage.setItem(this.storageKey, this.theme), this.dispatchEvent(
659
- new CustomEvent("theme-changed", {
660
- detail: { theme: this.theme },
661
- bubbles: !0,
662
- composed: !0
663
- })
664
- );
665
- }
666
- }
667
- _t([
668
- S({ type: String, attribute: "data-theme", reflect: !0 })
669
- ], it.prototype, "theme");
670
- _t([
671
- S({ type: String, attribute: "storage-key" })
672
- ], it.prototype, "storageKey");
673
- const ne = ({
674
- baseUrl: e
675
- }) => {
676
- const t = {
677
- login: "auth/login",
678
- logout: "auth/logout",
679
- refresh: "auth/refresh",
680
- requestRegisterOtp: "auth/request-register-otp",
681
- register: "auth/register",
682
- requestResetPassword: "auth/request-reset-password",
683
- resetPassword: "auth/reset-password"
684
- };
685
- return {
686
- login: async ({
687
- email: h,
688
- password: c,
689
- accessToken: l,
690
- refreshToken: d,
691
- idToken: u
692
- }) => {
693
- const f = await fetch(`${e}${t.login}`, {
694
- method: "POST",
695
- headers: {
696
- "Content-Type": "application/json"
697
- },
698
- body: JSON.stringify({
699
- email: h,
700
- password: c,
701
- accessToken: l,
702
- refreshToken: d,
703
- idToken: u
704
- })
705
- });
706
- if (!f.ok) {
707
- const w = await f.json();
708
- throw new Error(w.message || w.error || "Login failed");
709
- }
710
- return f.json();
711
- },
712
- logout: async ({
713
- accessToken: h,
714
- refreshToken: c,
715
- authToken: l
716
- }) => {
717
- const d = await fetch(`${e}${t.logout}`, {
718
- method: "POST",
719
- headers: {
720
- "Content-Type": "application/json",
721
- Authorization: `Bearer ${l}`
722
- },
723
- body: JSON.stringify({
724
- accessToken: h,
725
- refreshToken: c
726
- })
727
- });
728
- if (!d.ok) {
729
- const u = await d.json();
730
- throw new Error(u.message || u.error || "Logout failed");
731
- }
732
- return d.json();
733
- },
734
- refresh: async ({ refreshToken: h }) => {
735
- const c = await fetch(`${e}${t.refresh}`, {
736
- method: "POST",
737
- headers: {
738
- "Content-Type": "application/json"
739
- },
740
- body: JSON.stringify({
741
- refreshToken: h
742
- })
743
- });
744
- if (!c.ok) {
745
- const l = await c.json();
746
- throw new Error(l.message || l.error || "Failed to refresh token");
747
- }
748
- return c.json();
749
- },
750
- requestRegisterOtp: async ({ email: h }) => {
751
- const c = await fetch(`${e}${t.requestRegisterOtp}`, {
752
- method: "POST",
753
- headers: {
754
- "Content-Type": "application/json"
755
- },
756
- body: JSON.stringify({
757
- email: h
758
- })
759
- });
760
- if (!c.ok) {
761
- const l = await c.json();
762
- throw new Error(l.message || l.error || "Failed to request OTP");
763
- }
764
- return c.json();
765
- },
766
- register: async ({
767
- email: h,
768
- password: c,
769
- phone_number: l,
770
- family_name: d,
771
- given_name: u,
772
- code: f
773
- }) => {
774
- const w = await fetch(`${e}${t.register}`, {
775
- method: "POST",
776
- headers: {
777
- "Content-Type": "application/json"
778
- },
779
- body: JSON.stringify({
780
- email: h,
781
- password: c,
782
- phone_number: l,
783
- family_name: d,
784
- given_name: u,
785
- code: f
786
- })
787
- });
788
- if (!w.ok) {
789
- const A = await w.json();
790
- throw new Error(A.message || A.error || "Registration failed");
791
- }
792
- return w.json();
793
- },
794
- requestResetPassword: async ({ email: h }) => {
795
- const c = await fetch(`${e}${t.requestResetPassword}`, {
796
- method: "POST",
797
- headers: {
798
- "Content-Type": "application/json"
799
- },
800
- body: JSON.stringify({
801
- email: h
802
- })
803
- });
804
- if (!c.ok) {
805
- const l = await c.json();
806
- throw new Error(l.message || l.error || "Failed to request password reset");
807
- }
808
- return c.json();
809
- },
810
- resetPassword: async ({
811
- email: h,
812
- otp: c,
813
- newPassword: l
814
- }) => {
815
- const d = await fetch(`${e}${t.resetPassword}`, {
816
- method: "POST",
817
- headers: {
818
- "Content-Type": "application/json"
819
- },
820
- body: JSON.stringify({
821
- email: h,
822
- otp: c,
823
- newPassword: l
824
- })
825
- });
826
- if (!d.ok) {
827
- const u = await d.json();
828
- throw new Error(u.message || u.error || "Failed to reset password");
829
- }
830
- return d.json();
831
- }
832
- };
833
- }, Y = {
834
- AUTH_TOKEN: "authToken",
835
- ACCESS_TOKEN: "accessToken",
836
- REFRESH_TOKEN: "refreshToken"
837
- }, le = {
838
- maxAge: 3600 * 24 * 7,
839
- // 7 days
840
- secure: !0,
841
- sameSite: "lax",
842
- path: "/"
843
- }, he = () => {
844
- const e = (n, h, c = {}) => {
845
- const {
846
- maxAge: l,
847
- path: d = "/",
848
- secure: u = window.location.protocol === "https:",
849
- sameSite: f = "lax",
850
- domain: w
851
- } = c;
852
- let A = `${encodeURIComponent(n)}=${encodeURIComponent(h)}`;
853
- l !== void 0 && (A += `; Max-Age=${l}`), A += `; Path=${d}`, u && (A += "; Secure"), A += `; SameSite=${f}`, w && (A += `; Domain=${w}`), document.cookie = A;
854
- }, t = (n) => {
855
- const h = encodeURIComponent(n) + "=", c = document.cookie.split(";");
856
- for (let l = 0; l < c.length; l++) {
857
- let d = c[l];
858
- for (; d.charAt(0) === " "; )
859
- d = d.substring(1);
860
- if (d.indexOf(h) === 0)
861
- return decodeURIComponent(d.substring(h.length));
862
- }
863
- return null;
864
- }, s = (n, h = {}) => {
865
- e(n, "", {
866
- ...h,
867
- maxAge: -1
868
- });
869
- }, r = (n) => t(n) !== null, i = (n, h) => {
870
- e(Y[n], h, le);
871
- }, o = (n) => t(Y[n]), a = (n) => {
872
- s(Y[n]);
873
- };
874
- return {
875
- setCookie: e,
876
- getCookie: t,
877
- removeCookie: s,
878
- hasCookie: r,
879
- setAuthToken: i,
880
- getAuthToken: o,
881
- removeAuthToken: a,
882
- clearAllAuthTokens: () => {
883
- a("AUTH_TOKEN"), a("ACCESS_TOKEN"), a("REFRESH_TOKEN");
884
- }
885
- };
886
- }, ce = ["code", "state", "error", "error_description"], de = (e) => {
887
- if (e) return e;
888
- const t = new URL(window.location.href);
889
- return ce.forEach((s) => t.searchParams.delete(s)), t.toString();
890
- }, pe = ({
891
- domain: e,
892
- cognitoRegion: t,
893
- userPoolId: s,
894
- clientId: r,
895
- redirectUri: i
896
- }) => {
897
- const o = {
898
- domain: e,
899
- clientId: r,
900
- redirectUri: de(i)
901
- }, a = (b) => {
902
- const _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", k = new Uint8Array(b);
903
- return crypto.getRandomValues(k), Array.from(k).map((x) => _[x % _.length]).join("");
904
- }, p = async (b) => {
905
- const k = new TextEncoder().encode(b), x = await crypto.subtle.digest("SHA-256", k);
906
- return btoa(String.fromCharCode(...new Uint8Array(x))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
907
- }, n = async () => {
908
- const b = a(128), _ = await p(b);
909
- return sessionStorage.setItem("pkce_code_verifier", b), { codeVerifier: b, codeChallenge: _ };
910
- }, h = () => {
911
- const b = a(32);
912
- return sessionStorage.setItem("oauth_state", b), b;
913
- }, c = async () => {
914
- const { codeChallenge: b } = await n(), _ = h(), k = new URLSearchParams({
915
- response_type: "code",
916
- client_id: o.clientId,
917
- redirect_uri: o.redirectUri,
918
- identity_provider: "Google",
919
- scope: "openid email profile",
920
- state: _,
921
- code_challenge_method: "S256",
922
- code_challenge: b,
923
- prompt: "select_account"
924
- });
925
- return `${o.domain}/oauth2/authorize?${k.toString()}`;
926
- }, l = async () => {
927
- const b = await c();
928
- window.location.href = b;
929
- }, d = async () => {
930
- const { codeChallenge: b } = await n(), _ = h(), k = new URLSearchParams({
931
- response_type: "code",
932
- client_id: o.clientId,
933
- redirect_uri: o.redirectUri,
934
- identity_provider: "SignInWithApple",
935
- scope: "openid email profile",
936
- state: _,
937
- code_challenge_method: "S256",
938
- code_challenge: b
939
- });
940
- return `${o.domain}/oauth2/authorize?${k.toString()}`;
941
- }, u = async () => {
942
- const b = await d();
943
- window.location.href = b;
944
- }, f = (b) => {
945
- const _ = sessionStorage.getItem("oauth_state");
946
- return sessionStorage.removeItem("oauth_state"), _ === b;
947
- }, w = () => {
948
- const b = sessionStorage.getItem("pkce_code_verifier");
949
- return sessionStorage.removeItem("pkce_code_verifier"), b;
950
- };
951
- return {
952
- redirectToGoogleAuth: l,
953
- redirectToAppleAuth: u,
954
- validateState: f,
955
- getCodeVerifier: w,
956
- exchangeCodeForTokens: async (b) => {
957
- const _ = w();
958
- if (!_)
959
- throw new Error("PKCE code verifier not found. Please restart the authentication flow.");
960
- const k = new URLSearchParams({
961
- grant_type: "authorization_code",
962
- client_id: o.clientId,
963
- code: b,
964
- redirect_uri: o.redirectUri,
965
- code_verifier: _
966
- }), x = await fetch(`${o.domain}/oauth2/token`, {
967
- method: "POST",
968
- headers: {
969
- "Content-Type": "application/x-www-form-urlencoded"
970
- },
971
- body: k.toString()
972
- });
973
- if (!x.ok) {
974
- const rt = await x.text();
975
- throw new Error(`Token exchange failed: ${rt}`);
976
- }
977
- return x.json();
978
- }
979
- };
980
- }, ue = () => kt`
981
- :host {
982
- display: inline-block;
983
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
984
- box-sizing: border-box;
985
- --color-primary: var(--auth-color-primary, #2563eb);
986
- --color-bg-primary: var(--auth-color-bg-primary, #ffffff);
987
- --color-bg-secondary: var(--auth-color-bg-secondary, #f8fafc);
988
- --color-text-primary: var(--auth-color-text-primary, #0f172a);
989
- --color-text-secondary: var(--auth-color-text-secondary, #64748b);
990
- --color-text-muted: var(--auth-color-text-muted, #94a3b8);
991
- --color-border: var(--auth-color-border, #e2e8f0);
992
- --color-error: var(--auth-color-error, #dc2626);
993
- --color-success: var(--auth-color-success, #16a34a);
994
- --transition-slow: var(--auth-transition-slow, 300ms);
995
- --radius-md: var(--auth-radius-md, 0.5rem);
996
- --radius-lg: var(--auth-radius-lg, 0.75rem);
997
- --radius-xl: var(--auth-radius-xl, 1.25rem);
998
- --space-2: var(--auth-space-2, 0.5rem);
999
- --space-3: var(--auth-space-3, 0.75rem);
1000
- --space-4: var(--auth-space-4, 1rem);
1001
- --space-5: var(--auth-space-5, 1.25rem);
1002
- --space-6: var(--auth-space-6, 1.5rem);
1003
- }
1004
-
1005
- *,
1006
- *::before,
1007
- *::after {
1008
- box-sizing: border-box;
1009
- }
1010
-
1011
- /* Body scroll lock */
1012
- :host(.modal-open) {
1013
- overflow: hidden;
1014
- }
1015
-
1016
- .modal-overlay {
1017
- position: fixed;
1018
- top: 0;
1019
- left: 0;
1020
- right: 0;
1021
- bottom: 0;
1022
- background: rgba(0, 0, 0, 0.5);
1023
- display: flex;
1024
- align-items: flex-end;
1025
- justify-content: center;
1026
- z-index: 1000;
1027
- backdrop-filter: none;
1028
- animation: fadeIn 0.2s ease-out;
1029
- }
1030
-
1031
- .modal-overlay--closing {
1032
- animation: fadeOut var(--transition-slow) ease-out forwards;
1033
- }
1034
-
1035
- .modal-container {
1036
- background: var(--color-bg-primary);
1037
- border-top-left-radius: var(--radius-xl);
1038
- border-top-right-radius: var(--radius-xl);
1039
- box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
1040
- width: 100vw;
1041
- max-width: 100vw;
1042
- height: 85dvh;
1043
- display: flex;
1044
- flex-direction: column;
1045
- overflow: hidden;
1046
- animation: slideUp var(--transition-slow);
1047
- transform-origin: bottom center;
1048
- transition: height var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
1049
- }
1050
-
1051
- .modal-container--closing {
1052
- animation: slideDown var(--transition-slow);
1053
- }
1054
-
1055
- .modal-container--dragging {
1056
- user-select: none;
1057
- -webkit-user-select: none;
1058
- cursor: grabbing;
1059
- }
1060
-
1061
- .drawer-handle {
1062
- display: flex;
1063
- justify-content: center;
1064
- padding-top: var(--space-3);
1065
- padding-bottom: var(--space-2);
1066
- flex-shrink: 0;
1067
- cursor: pointer;
1068
- user-select: none;
1069
- -webkit-tap-highlight-color: transparent;
1070
- }
1071
-
1072
- .drawer-handle:hover .drawer-handle-bar {
1073
- opacity: 0.7;
1074
- }
1075
-
1076
- .drawer-handle-bar {
1077
- width: 36px;
1078
- height: 5px;
1079
- background: var(--color-text-muted);
1080
- border-radius: 100px;
1081
- opacity: 0.5;
1082
- transition: opacity var(--transition-slow) ease;
1083
- }
1084
-
1085
- .drawer-content {
1086
- width: 100%;
1087
- max-width: 100%;
1088
- margin: 0 auto;
1089
- display: flex;
1090
- flex-direction: column;
1091
- overflow: hidden;
1092
- height: 100%;
1093
- }
1094
-
1095
- .drawer-content--sm {
1096
- max-width: 400px;
1097
- }
1098
-
1099
- .drawer-content--md {
1100
- max-width: 600px;
1101
- }
1102
-
1103
- .drawer-content--lg {
1104
- max-width: 900px;
1105
- }
1106
-
1107
- .modal-header {
1108
- display: flex;
1109
- align-items: center;
1110
- justify-content: center;
1111
- padding: var(--space-4) var(--space-6);
1112
- flex-shrink: 0;
1113
- }
1114
-
1115
- .auth-logo {
1116
- display: block;
1117
- }
1118
- .auth-logo {
1119
- position: relative;
1120
- transition: all 0.3s ease;
1121
- }
1122
- .auth-logo[src] {
1123
- opacity: 1;
1124
- position: relative;
1125
- z-index: 1;
1126
- }
1127
- :host([data-theme='dark']) .auth-header {
1128
- filter: brightness(0) saturate(100%) invert(98%) sepia(4%) saturate(346%)
1129
- hue-rotate(183deg) brightness(106%) contrast(93%);
1130
- }
1131
-
1132
- .modal-body {
1133
- padding: var(--space-4) var(--space-6);
1134
- overflow-y: auto;
1135
- flex: 1;
1136
- min-height: 0;
1137
- }
1138
-
1139
- .auth-form {
1140
- display: flex;
1141
- flex-direction: column;
1142
- gap: var(--space-5);
1143
- }
1144
-
1145
- .field {
1146
- display: flex;
1147
- flex-direction: column;
1148
- gap: var(--space-1);
1149
- }
1150
-
1151
- .field-label {
1152
- font-weight: 500;
1153
- font-size: 0.875rem;
1154
- color: var(--color-text-primary);
1155
- }
1156
-
1157
- .field-input {
1158
- width: 100%;
1159
- padding: 0.75rem 1rem;
1160
- border: 1px solid var(--color-border);
1161
- border-radius: var(--radius-md);
1162
- background: var(--color-bg-primary);
1163
- color: var(--color-text-primary);
1164
- font-size: 1rem;
1165
- transition: all 0.15s ease;
1166
- }
1167
-
1168
- .field-input:focus {
1169
- outline: none;
1170
- border-color: var(--color-primary);
1171
- box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
1172
- }
1173
-
1174
- .field-input:-webkit-autofill,
1175
- .field-input:-webkit-autofill:hover,
1176
- .field-input:-webkit-autofill:focus,
1177
- .field-input:-webkit-autofill:active {
1178
- -webkit-box-shadow: 0 0 0 1000px var(--color-bg-primary) inset !important;
1179
- -webkit-text-fill-color: var(--color-text-primary) !important;
1180
- transition: background-color 5000s ease-in-out 0s;
1181
- }
1182
-
1183
- .field-input:-moz-autofill {
1184
- box-shadow: 0 0 0 1000px var(--color-bg-primary) inset !important;
1185
- color: var(--color-text-primary) !important;
1186
- }
1187
-
1188
- .field-input--error {
1189
- border-color: var(--color-error);
1190
- }
1191
-
1192
- .field-error {
1193
- color: var(--color-error);
1194
- font-size: 0.875rem;
1195
- }
1196
-
1197
- .forgot-row {
1198
- display: flex;
1199
- justify-content: flex-end;
1200
- margin-top: calc(var(--space-2) * -1);
1201
- }
1202
-
1203
- .text-btn {
1204
- background: none;
1205
- border: none;
1206
- color: var(--color-primary);
1207
- cursor: pointer;
1208
- font-weight: 600;
1209
- font-size: 0.875rem;
1210
- padding: 0;
1211
- text-decoration: none;
1212
- }
1213
-
1214
- .text-btn:hover {
1215
- text-decoration: underline;
1216
- }
1217
-
1218
- .form-actions {
1219
- display: flex;
1220
- flex-direction: column;
1221
- gap: var(--space-3);
1222
- margin-top: var(--space-2);
1223
- }
1224
-
1225
- .cta {
1226
- width: 100%;
1227
- padding: 0.875rem 1rem;
1228
- border: none;
1229
- border-radius: var(--radius-md);
1230
- background: var(--color-primary);
1231
- color: white;
1232
- font-weight: 600;
1233
- font-size: 1rem;
1234
- cursor: pointer;
1235
- transition: all 0.15s ease;
1236
- }
1237
-
1238
- .cta:hover:not(:disabled) {
1239
- background: color-mix(in srgb, var(--color-primary), black 10%);
1240
- transform: translateY(-1px);
1241
- }
1242
-
1243
- .cta:disabled {
1244
- opacity: 0.5;
1245
- cursor: not-allowed;
1246
- }
1247
-
1248
- .button-row {
1249
- display: flex;
1250
- gap: var(--space-3);
1251
- width: 100%;
1252
- }
1253
-
1254
- .oauth-btn {
1255
- flex: 1;
1256
- padding: 0.875rem 1rem;
1257
- border: 1px solid var(--color-border);
1258
- border-radius: var(--radius-md);
1259
- background: var(--color-bg-primary);
1260
- cursor: pointer;
1261
- transition: all 0.15s ease;
1262
- display: flex;
1263
- align-items: center;
1264
- justify-content: center;
1265
- }
1266
-
1267
- .oauth-btn:hover:not(:disabled) {
1268
- background: var(--color-bg-secondary);
1269
- border-color: var(--color-text-muted);
1270
- }
1271
-
1272
- .oauth-btn:disabled {
1273
- opacity: 0.5;
1274
- cursor: not-allowed;
1275
- }
1276
-
1277
- .apple-icon path {
1278
- fill: #0b0b0a;
1279
- }
1280
-
1281
- /* Dark theme */
1282
- :host([data-theme='dark']) {
1283
- --color-primary: #3b82f6;
1284
- --color-bg-primary: #1e293b;
1285
- --color-bg-secondary: #0f172a;
1286
- --color-text-primary: #f8fafc;
1287
- --color-text-secondary: #cbd5e1;
1288
- --color-text-muted: #94a3b8;
1289
- --color-border: #334155;
1290
- --color-error: #ef4444;
1291
- --color-success: #10b981;
1292
- }
1293
-
1294
- :host([data-theme='dark']) .apple-icon path {
1295
- fill: #8e8e93;
1296
- }
1297
-
1298
- @media (prefers-color-scheme: dark) {
1299
- .apple-icon path {
1300
- fill: #8e8e93;
1301
- }
1302
- }
1303
-
1304
- .otp-section {
1305
- display: flex;
1306
- flex-direction: column;
1307
- gap: var(--space-2);
1308
- }
1309
-
1310
- .otp-label {
1311
- display: block;
1312
- font-weight: 500;
1313
- font-size: 0.875rem;
1314
- color: var(--color-text-primary);
1315
- }
1316
-
1317
- .otp-inputs {
1318
- display: flex;
1319
- gap: var(--space-2);
1320
- justify-content: center;
1321
- }
1322
-
1323
- .otp-input {
1324
- width: 44px;
1325
- height: 52px;
1326
- text-align: center;
1327
- font-size: 1.25rem;
1328
- font-weight: 600;
1329
- border: 1px solid var(--color-border);
1330
- border-radius: var(--radius-md);
1331
- background: var(--color-bg-primary);
1332
- color: var(--color-text-primary);
1333
- transition: all 0.15s ease;
1334
- }
1335
-
1336
- .otp-input:focus {
1337
- outline: none;
1338
- border-color: var(--color-primary);
1339
- box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
1340
- }
1341
-
1342
- .otp-input--error {
1343
- border-color: var(--color-error);
1344
- }
1345
-
1346
- .otp-error {
1347
- margin: 0;
1348
- color: var(--color-error);
1349
- font-size: 0.875rem;
1350
- text-align: center;
1351
- }
1352
-
1353
- .new-password-fields {
1354
- display: flex;
1355
- flex-direction: column;
1356
- gap: var(--space-5);
1357
- animation: fadeSlide 0.2s ease;
1358
- }
1359
-
1360
- .alert {
1361
- padding: var(--space-3) var(--space-4);
1362
- border-radius: var(--radius-md);
1363
- font-size: 0.875rem;
1364
- display: flex;
1365
- align-items: center;
1366
- justify-content: space-between;
1367
- gap: var(--space-2);
1368
- }
1369
-
1370
- .alert--success {
1371
- background: color-mix(in srgb, var(--color-success) 10%, transparent);
1372
- border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
1373
- color: var(--color-success);
1374
- }
1375
-
1376
- .alert--error {
1377
- background: color-mix(in srgb, var(--color-error) 10%, transparent);
1378
- border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
1379
- color: var(--color-error);
1380
- }
1381
-
1382
- .alert-close {
1383
- background: none;
1384
- border: none;
1385
- color: inherit;
1386
- cursor: pointer;
1387
- font-size: 1.5rem;
1388
- line-height: 1;
1389
- padding: 0;
1390
- opacity: 0.7;
1391
- }
1392
-
1393
- .alert-close:hover {
1394
- opacity: 1;
1395
- }
1396
-
1397
- .auth-footer {
1398
- display: flex;
1399
- align-items: center;
1400
- justify-content: center;
1401
- gap: var(--space-2);
1402
- padding-top: var(--space-4);
1403
- text-align: center;
1404
- }
1405
-
1406
- .toggle-text {
1407
- margin: 0;
1408
- font-size: 0.875rem;
1409
- color: var(--color-text-secondary);
1410
- }
1411
-
1412
- .toggle-text a {
1413
- color: var(--color-primary);
1414
- text-decoration: none;
1415
- }
1416
-
1417
- .toggle-text a:hover {
1418
- text-decoration: underline;
1419
- }
1420
-
1421
- @keyframes fadeIn {
1422
- from {
1423
- opacity: 0;
1424
- }
1425
- to {
1426
- opacity: 1;
1427
- }
1428
- }
1429
-
1430
- @keyframes fadeOut {
1431
- from {
1432
- opacity: 1;
1433
- }
1434
- to {
1435
- opacity: 0;
1436
- }
1437
- }
1438
-
1439
- @keyframes slideUp {
1440
- from {
1441
- transform: translateY(100%);
1442
- }
1443
- to {
1444
- transform: translateY(0);
1445
- }
1446
- }
1447
-
1448
- @keyframes slideDown {
1449
- from {
1450
- transform: translateY(0);
1451
- }
1452
- to {
1453
- transform: translateY(100%);
1454
- }
1455
- }
1456
-
1457
- @keyframes fadeSlide {
1458
- from {
1459
- opacity: 0;
1460
- transform: translateY(6px);
1461
- }
1462
- to {
1463
- opacity: 1;
1464
- transform: translateY(0);
1465
- }
1466
- }
1467
-
1468
- @media (max-width: 640px) {
1469
- .modal-container {
1470
- height: 80dvh;
1471
- }
1472
- }
1473
-
1474
- @media (prefers-reduced-motion: reduce) {
1475
- * {
1476
- animation: none !important;
1477
- transition: none !important;
1478
- }
1479
- }`;
1480
- var ge = Object.defineProperty, me = Object.getOwnPropertyDescriptor, $ = (e, t, s, r) => {
1481
- for (var i = r > 1 ? void 0 : r ? me(t, s) : t, o = e.length - 1, a; o >= 0; o--)
1482
- (a = e[o]) && (i = (r ? a(t, s, i) : a(i)) || i);
1483
- return r && i && ge(t, s, i), i;
1484
- };
1485
- const fe = [
1486
- "code",
1487
- "state",
1488
- "error",
1489
- "error_description",
1490
- "access_token",
1491
- "id_token",
1492
- "refresh_token",
1493
- "token_type",
1494
- "expires_in"
1495
- ];
1496
- let y = class extends it {
1497
- constructor() {
1498
- super(...arguments), this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.oauthSpaDomain = "", this.disableSignup = !1, this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.cookies = he(), this.hasHandledOAuthCallback = !1, this.baseUrlErrorMessage = "Authentication service is not configured correctly. Please add an API domain or contact support.";
1499
- }
1500
- hasApiBaseUrl() {
1501
- return this.baseUrl.trim().length > 0;
1502
- }
1503
- getNormalizedBaseUrl() {
1504
- const e = this.baseUrl.trim();
1505
- if (!e) return "";
1506
- const t = e.startsWith("http://") || e.startsWith("https://") ? e : `https://${e}`;
1507
- return t.endsWith("/") ? t : `${t}/`;
1508
- }
1509
- getApiService() {
1510
- if (!this.hasApiBaseUrl())
1511
- throw new Error("API domain is not set");
1512
- return this.apiService || (this.apiService = ne({
1513
- baseUrl: this.getNormalizedBaseUrl()
1514
- })), this.apiService;
1515
- }
1516
- connectedCallback() {
1517
- super.connectedCallback();
1518
- const e = this.cookies.getAuthToken("AUTH_TOKEN"), t = this.cookies.getAuthToken("REFRESH_TOKEN");
1519
- this.isLoggedIn = !!(e && t), this.mode = this.disableSignup && this.initialMode === "signup" ? "signin" : this.initialMode, this.hasApiBaseUrl() || (this.error = this.baseUrlErrorMessage), this.handleOAuthCallbackIfPresent();
1520
- }
1521
- firstUpdated() {
1522
- setTimeout(() => {
1523
- this.emailInput?.focus();
1524
- }, 100);
1525
- }
1526
- updated(e) {
1527
- e.has("disableSignup") && this.disableSignup && this.mode === "signup" && (this.mode = "signin", this.signupStep = "form"), e.has("baseUrl") && (this.apiService = void 0, this.hasApiBaseUrl() ? (this.error === this.baseUrlErrorMessage && (this.error = ""), this.hasHandledOAuthCallback || this.handleOAuthCallbackIfPresent()) : this.error = this.baseUrlErrorMessage), (e.has("oauthDomain") || e.has("oauthRegion") || e.has("oauthUserPoolId") || e.has("oauthClientId") || e.has("oauthRedirectUri")) && (this.oauthService = void 0, this.handleOAuthCallbackIfPresent());
1528
- }
1529
- resetState() {
1530
- this.error = "", this.notice = "", this.errors = {}, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.resetStep = "none", this.signupStep = "form", this.mode = this.initialMode;
1531
- }
1532
- toggleMode() {
1533
- this.resetStep === "none" && (this.disableSignup && this.mode === "signin" || (this.mode = this.mode === "signin" ? "signup" : "signin", this.signupStep = "form", this.error = "", this.notice = "", this.errors = {}, this.confirmPassword = "", this.mode === "signin" && (this.givenName = "", this.familyName = "", this.signupOtpDigits = ["", "", "", "", "", ""])));
1534
- }
1535
- startReset() {
1536
- this.mode = "signin", this.resetStep = "request", this.error = "", this.notice = "", this.errors = {}, this.password = "", this.newPassword = "", this.confirmPassword = "";
1537
- }
1538
- cancelReset() {
1539
- this.resetStep = "none", this.error = "", this.notice = "", this.otpDigits = ["", "", "", "", "", ""], this.errors = {}, this.newPassword = "", this.confirmPassword = "";
1540
- }
1541
- backToRequest() {
1542
- this.resetStep = "request", this.error = "", this.notice = "", this.otpDigits = ["", "", "", "", "", ""], this.errors = {}, this.newPassword = "", this.confirmPassword = "";
1543
- }
1544
- backToSignupForm() {
1545
- this.signupStep = "form", this.error = "", this.notice = "", this.signupOtpDigits = ["", "", "", "", "", ""], this.errors = {};
1546
- }
1547
- // Validation
1548
- validate() {
1549
- const e = {};
1550
- if (this.email.trim() ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email) || (e.email = "Enter a valid email") : e.email = "Email is required", this.resetStep === "none" && this.signupStep === "form") {
1551
- if (!this.password)
1552
- e.password = "Password is required";
1553
- else if (this.password.length < 8)
1554
- e.password = "Password must be at least 8 characters";
1555
- else if (this.mode === "signup") {
1556
- const t = /[A-Z]/.test(this.password), s = /[a-z]/.test(this.password), r = /[0-9]/.test(this.password);
1557
- (!t || !s || !r) && (e.password = "Password must contain uppercase, lowercase, and number");
1558
- }
1559
- }
1560
- if (this.mode === "signup" && this.resetStep === "none" && this.signupStep === "form" && (this.givenName.trim() ? /^[a-zA-Z\s-']+$/.test(this.givenName.trim()) || (e.givenName = "Invalid first name") : e.givenName = "First name is required", this.familyName.trim() ? /^[a-zA-Z\s-']+$/.test(this.familyName.trim()) || (e.familyName = "Invalid last name") : e.familyName = "Last name is required", this.confirmPassword ? this.password !== this.confirmPassword && (e.confirm_password = "Passwords must match") : e.confirm_password = "Please confirm your password"), this.signupStep === "otp") {
1561
- const t = this.signupOtpDigits.join("");
1562
- (t.length !== 6 || !/^\d{6}$/.test(t)) && (e.signup_otp = "Enter the 6-digit code");
1563
- }
1564
- if (this.resetStep === "confirm") {
1565
- const t = this.otpDigits.join("");
1566
- if ((t.length !== 6 || !/^\d{6}$/.test(t)) && (e.otp = "Enter the 6-digit code"), t.length === 6) {
1567
- if (!this.newPassword)
1568
- e.new_password = "New password is required";
1569
- else if (this.newPassword.length < 8)
1570
- e.new_password = "Password must be at least 8 characters";
1571
- else {
1572
- const s = /[A-Z]/.test(this.newPassword), r = /[a-z]/.test(this.newPassword), i = /[0-9]/.test(this.newPassword);
1573
- (!s || !r || !i) && (e.new_password = "Password must contain uppercase, lowercase, and number");
1574
- }
1575
- this.confirmPassword ? this.newPassword !== this.confirmPassword && (e.confirm_password = "Passwords must match") : e.confirm_password = "Please confirm your password";
1576
- }
1577
- }
1578
- return this.errors = e, Object.keys(e).length === 0;
1579
- }
1580
- // Form submission
1581
- async handleSubmit(e) {
1582
- if (e.preventDefault(), this.notice = "", this.error = "", !this.hasApiBaseUrl()) {
1583
- this.error = this.baseUrlErrorMessage;
1584
- return;
1585
- }
1586
- if (this.validate()) {
1587
- this.isLoading = !0;
1588
- try {
1589
- switch (`${this.resetStep}-${this.mode}-${this.signupStep}`) {
1590
- case "request-signin-form":
1591
- try {
1592
- await this.handleRequestReset();
1593
- } catch {
1594
- this.error = "Reset request failed. Please check your details and try again.";
1595
- }
1596
- break;
1597
- case "confirm-signin-form":
1598
- try {
1599
- await this.handleConfirmReset();
1600
- } catch {
1601
- this.error = "Reset confirmation failed. Please check your details and try again.";
1602
- }
1603
- break;
1604
- case "none-signup-form":
1605
- try {
1606
- await this.handleRequestSignupOtp();
1607
- } catch {
1608
- this.error = "Signup failed. Please check your details and try again.";
1609
- }
1610
- break;
1611
- case "none-signup-otp":
1612
- try {
1613
- await this.handleSignupWithOtp();
1614
- } catch {
1615
- this.error = "Signup failed. Please check your details and try again.";
1616
- }
1617
- break;
1618
- default:
1619
- try {
1620
- await this.handleSignIn();
1621
- } catch {
1622
- this.error = "Login failed. Please check your credentials and try again.";
1623
- }
1624
- break;
1625
- }
1626
- } finally {
1627
- this.isLoading = !1;
1628
- }
1629
- }
1630
- }
1631
- setAuthTokens(e, t, s, r) {
1632
- this.cookies.setAuthToken("ACCESS_TOKEN", e), this.cookies.setAuthToken("AUTH_TOKEN", t), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.cookies.setCookie("USER_EMAIL", r.email), this.isLoggedIn = !0, this.dispatchEvent(
1633
- new CustomEvent("auth-success", {
1634
- bubbles: !0,
1635
- composed: !0
1636
- })
1637
- );
1638
- }
1639
- async handleSignIn() {
1640
- const e = {
1641
- email: this.email.trim(),
1642
- password: this.password
1643
- }, { accessToken: t, idToken: s, refreshToken: r, user: i } = await this.getApiService().login(e);
1644
- this.setAuthTokens(t, s, r, i);
1645
- }
1646
- isOAuthConfigured() {
1647
- return [this.oauthDomain, this.oauthRegion, this.oauthUserPoolId, this.oauthClientId].every(
1648
- (e) => !!e?.trim()
1649
- );
1650
- }
1651
- getOAuthService() {
1652
- if (!this.isOAuthConfigured())
1653
- return null;
1654
- if (!this.oauthService) {
1655
- const e = this.oauthRedirectUri?.trim() ? this.oauthRedirectUri.trim() : void 0;
1656
- this.oauthService = pe({
1657
- domain: this.oauthDomain.trim(),
1658
- cognitoRegion: this.oauthRegion.trim(),
1659
- userPoolId: this.oauthUserPoolId.trim(),
1660
- clientId: this.oauthClientId.trim(),
1661
- redirectUri: e
1662
- });
1663
- }
1664
- return this.oauthService;
1665
- }
1666
- stripOAuthParamsFromUrl() {
1667
- const e = new URL(window.location.href);
1668
- let t = !1;
1669
- for (const s of fe)
1670
- e.searchParams.has(s) && (e.searchParams.delete(s), t = !0);
1671
- if (t) {
1672
- const s = e.searchParams.toString(), r = `${e.pathname}${s ? `?${s}` : ""}${e.hash}`;
1673
- window.history.replaceState({}, document.title, r);
1674
- }
1675
- }
1676
- async handleOAuthCallbackIfPresent() {
1677
- const e = new URLSearchParams(window.location.search), t = e.get("access_token"), s = e.get("id_token"), r = e.get("refresh_token"), i = e.get("code"), o = e.get("state"), a = e.get("error"), p = e.get("error_description");
1678
- if ((t || s || i || a) && !this.hasHandledOAuthCallback) {
1679
- if (!this.hasApiBaseUrl()) {
1680
- this.error = this.baseUrlErrorMessage;
1681
- return;
1682
- }
1683
- this.hasHandledOAuthCallback = !0, this.isLoading = !0, this.error = "";
1684
- try {
1685
- if (a)
1686
- throw new Error(p || `OAuth error: ${a}`);
1687
- if (t && s && r) {
1688
- const { accessToken: h, idToken: c, refreshToken: l, user: d } = await this.getApiService().login({
1689
- accessToken: t,
1690
- refreshToken: r,
1691
- idToken: s
1692
- });
1693
- this.setAuthTokens(h, c, l ?? r, d);
1694
- } else if (i && o) {
1695
- if (!this.isOAuthConfigured())
1696
- throw new Error("OAuth is not configured correctly. Please try again later.");
1697
- const h = this.getOAuthService();
1698
- if (!h)
1699
- throw new Error("OAuth is not configured correctly. Please try again later.");
1700
- if (!h.validateState(o))
1701
- throw new Error("Invalid state parameter. Please try signing in again.");
1702
- const c = await h.exchangeCodeForTokens(i), { accessToken: l, idToken: d, refreshToken: u, user: f } = await this.getApiService().login({
1703
- accessToken: c.access_token,
1704
- refreshToken: c.refresh_token,
1705
- idToken: c.id_token
1706
- });
1707
- this.setAuthTokens(l, d, u ?? c.refresh_token, f);
1708
- } else
1709
- throw new Error("Missing required OAuth parameters");
1710
- } catch (h) {
1711
- this.error = h.message || "An unexpected error occurred during authentication";
1712
- } finally {
1713
- this.stripOAuthParamsFromUrl(), this.isLoading = !1;
1714
- }
1715
- }
1716
- }
1717
- async handleRequestSignupOtp() {
1718
- this.signupStep = "otp", this.notice = "A 6-digit code has been sent to your email", this.signupOtpDigits = ["", "", "", "", "", ""], await this.getApiService().requestRegisterOtp({ email: this.email.trim() }), setTimeout(() => {
1719
- this.shadowRoot?.querySelector(".signup-otp-input")?.focus();
1720
- }, 200);
1721
- }
1722
- async handleSignupWithOtp() {
1723
- const e = {
1724
- email: this.email.trim(),
1725
- password: this.password,
1726
- givenName: this.givenName.trim(),
1727
- familyName: this.familyName.trim(),
1728
- code: this.signupOtpDigits.join("")
1729
- };
1730
- await this.getApiService().register({
1731
- email: e.email,
1732
- password: e.password,
1733
- given_name: e.givenName,
1734
- family_name: e.familyName,
1735
- code: e.code
1736
- }), await this.handleSignIn();
1737
- }
1738
- async handleRequestReset() {
1739
- const e = {
1740
- email: this.email.trim()
1741
- };
1742
- this.resetStep = "confirm", this.notice = "If an account exists, a 6-digit code has been sent", this.otpDigits = ["", "", "", "", "", ""], await this.getApiService().requestResetPassword(e), setTimeout(() => {
1743
- this.shadowRoot?.querySelector(".reset-otp-input")?.focus();
1744
- }, 100);
1745
- }
1746
- async handleConfirmReset() {
1747
- const e = {
1748
- email: this.email.trim(),
1749
- newPassword: this.newPassword,
1750
- otp: this.otpDigits.join("")
1751
- };
1752
- await this.getApiService().resetPassword({
1753
- email: e.email,
1754
- newPassword: e.newPassword,
1755
- otp: e.otp
1756
- }), await this.handleSignIn();
1757
- }
1758
- isUserLoggedIn() {
1759
- return this.isLoggedIn || !!this.cookies.getAuthToken("ACCESS_TOKEN") && !!this.cookies.getAuthToken("REFRESH_TOKEN") && !!this.cookies.getAuthToken("AUTH_TOKEN");
1760
- }
1761
- async logout() {
1762
- const e = this.cookies.getAuthToken("ACCESS_TOKEN"), t = this.cookies.getAuthToken("AUTH_TOKEN"), s = this.cookies.getAuthToken("REFRESH_TOKEN");
1763
- try {
1764
- if (e == null || s == null || t == null)
1765
- return;
1766
- if (!this.hasApiBaseUrl()) {
1767
- this.error = this.baseUrlErrorMessage;
1768
- return;
1769
- }
1770
- const r = this.getApiService(), {
1771
- redirectUrl: i,
1772
- requiresRedirect: o
1773
- } = await r.logout({
1774
- accessToken: e,
1775
- refreshToken: s,
1776
- authToken: t
1777
- });
1778
- if (o && i) {
1779
- const a = window.location.host;
1780
- new URL(i).host !== a ? window.open(i, "newWindow", "width=400,height=500,resizable=yes,scrollbars=yes,status=yes") : window.location.href = i;
1781
- }
1782
- } catch {
1783
- } finally {
1784
- this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
1785
- }
1786
- }
1787
- // OAuth handlers
1788
- handleGoogleSignIn() {
1789
- this.handleOAuthSignIn("google");
1790
- }
1791
- handleAppleSignIn() {
1792
- this.handleOAuthSignIn("apple");
1793
- }
1794
- handleOAuthSignIn(e) {
1795
- if (this.oauthSpaDomain?.trim()) {
1796
- const t = this.oauthSpaDomain.trim(), s = t.startsWith("http://") || t.startsWith("https://") ? t : `https://${t}`, r = s.endsWith("/") ? s.slice(0, -1) : s, i = window.location.href, o = `${r}?return_url=${encodeURIComponent(i)}&provider=${e}&theme=${this.theme}`;
1797
- window.location.href = o;
1798
- return;
1799
- }
1800
- e === "google" ? this.getOAuthService()?.redirectToGoogleAuth() : this.getOAuthService()?.redirectToAppleAuth();
1801
- }
1802
- // OTP input handlers
1803
- handleOtpInput(e, t, s) {
1804
- const r = t.target, i = r.value.replace(/\D/g, "");
1805
- if (!i) {
1806
- s ? (this.signupOtpDigits[e] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = "", this.otpDigits = [...this.otpDigits]);
1807
- return;
1808
- }
1809
- const o = i[i.length - 1];
1810
- if (s ? (this.signupOtpDigits[e] = o, this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = o, this.otpDigits = [...this.otpDigits]), e < 5) {
1811
- const a = this.shadowRoot?.querySelector(
1812
- `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e + 1}"]`
1813
- );
1814
- a?.focus(), a?.select();
1815
- } else
1816
- r.blur();
1817
- }
1818
- handleOtpKeydown(e, t, s) {
1819
- const r = s ? this.signupOtpDigits : this.otpDigits;
1820
- if (t.key === "Backspace") {
1821
- if (r[e]) {
1822
- s ? (this.signupOtpDigits[e] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = "", this.otpDigits = [...this.otpDigits]);
1823
- return;
1824
- }
1825
- if (e > 0) {
1826
- const i = this.shadowRoot?.querySelector(
1827
- `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e - 1}"]`
1828
- );
1829
- i?.focus(), i?.select(), s ? (this.signupOtpDigits[e - 1] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e - 1] = "", this.otpDigits = [...this.otpDigits]);
1830
- }
1831
- }
1832
- if (t.key === "ArrowLeft" && e > 0) {
1833
- const i = this.shadowRoot?.querySelector(
1834
- `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e - 1}"]`
1835
- );
1836
- i?.focus(), i?.select(), t.preventDefault();
1837
- }
1838
- if (t.key === "ArrowRight" && e < 5) {
1839
- const i = this.shadowRoot?.querySelector(
1840
- `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e + 1}"]`
1841
- );
1842
- i?.focus(), i?.select(), t.preventDefault();
1843
- }
1844
- t.key.length === 1 && /\D/.test(t.key) && t.preventDefault();
1845
- }
1846
- handleOtpPaste(e, t) {
1847
- const r = (e.clipboardData?.getData("text") || "").replace(/\D/g, "").slice(0, 6).split("");
1848
- if (r.length === 0) return;
1849
- e.preventDefault();
1850
- for (let o = 0; o < 6; o++)
1851
- t ? this.signupOtpDigits[o] = r[o] || "" : this.otpDigits[o] = r[o] || "";
1852
- t ? this.signupOtpDigits = [...this.signupOtpDigits] : this.otpDigits = [...this.otpDigits];
1853
- const i = (t ? this.signupOtpDigits : this.otpDigits).findIndex((o) => !o);
1854
- if (i === -1)
1855
- this.shadowRoot?.querySelector(
1856
- `${t ? ".signup-otp-input" : ".reset-otp-input"}[data-index="5"]`
1857
- )?.blur();
1858
- else {
1859
- const o = this.shadowRoot?.querySelector(
1860
- `${t ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${i}"]`
1861
- );
1862
- o?.focus(), o?.select();
1863
- }
1864
- }
1865
- render() {
1866
- if (!this.hasApiBaseUrl()) {
1867
- const e = this.baseUrlErrorMessage;
1868
- return m`
1869
- ${this.logoUrl.length > 0 ? m`
1870
- <header class="modal-header">
1871
- <div class="auth-header">
1872
- <img
1873
- src="${this.logoUrl}"
1874
- width="48"
1875
- height="48"
1876
- alt="Logo"
1877
- class="auth-logo"
1878
- />
1879
- </div>
1880
- </header>
1881
- ` : g}
1882
-
1883
- <div class="modal-body">
1884
- <div class="auth-form">
1885
- <div class="alert alert--error">
1886
- ${e}
1887
- </div>
1888
- </div>
1889
- </div>
1890
- `;
1891
- }
1892
- return this.isLoading && this.hasHandledOAuthCallback ? m`
1893
- ${this.logoUrl.length > 0 ? m`
1894
- <header class="modal-header">
1895
- <div class="auth-header">
1896
- <img
1897
- src="${this.logoUrl}"
1898
- width="48"
1899
- height="48"
1900
- alt="Logo"
1901
- class="auth-logo"
1902
- />
1903
- </div>
1904
- </header>
1905
- ` : g}
1906
-
1907
- <div class="modal-body">
1908
- <div class="auth-form">
1909
- <div class="form-actions">
1910
- <base-button
1911
- type="button"
1912
- variant="primary"
1913
- full-width
1914
- loading
1915
- disabled
1916
- >
1917
- Signing in...
1918
- </base-button>
1919
- </div>
1920
- ${this.renderAlerts()}
1921
- </div>
1922
- </div>
1923
- ` : this.isLoggedIn ? m`
1924
- <!-- Header -->
1925
- ${this.logoUrl.length > 0 ? m`
1926
- <header class="modal-header">
1927
- <div class="auth-header">
1928
- <img
1929
- src="${this.logoUrl}"
1930
- width="48"
1931
- height="48"
1932
- alt="Logo"
1933
- class="auth-logo"
1934
- />
1935
- </div>
1936
- </header>
1937
- ` : g}
1938
-
1939
- <!-- Body -->
1940
- <div class="modal-body">
1941
- <div class="auth-form">
1942
- <div class="form-actions">
1943
- <base-button
1944
- type="button"
1945
- variant="primary"
1946
- full-width
1947
- @click=${this.logout}
1948
- >
1949
- Logout
1950
- </base-button>
1951
- </div>
1952
- ${this.renderAlerts()}
1953
- </div>
1954
- </div>
1955
- ` : m`
1956
- <!-- Header -->
1957
- ${(!this.mode || this.resetStep === "none") && this.logoUrl.length > 0 && this.mode === "signin" ? m`
1958
- <header class="modal-header">
1959
-
1960
- <div class="auth-header">
1961
- <img
1962
- src="${this.logoUrl}"
1963
- width="48"
1964
- height="48"
1965
- alt="Logo"
1966
- class="auth-logo"
1967
- />
1968
- </div>
1969
- </header>
1970
- ` : g}
1971
-
1972
- <!-- Body -->
1973
- <div class="modal-body">
1974
- <form @submit=${this.handleSubmit} class="auth-form" novalidate>
1975
- ${this.renderFormContent()}
1976
-
1977
- <!-- Actions -->
1978
- <div class="form-actions">
1979
- ${this.renderActions()}
1980
- </div>
1981
-
1982
- ${this.renderAlerts()}
1983
- </form>
1984
-
1985
- ${this.renderFooter()}
1986
- </div>
1987
- `;
1988
- }
1989
- renderFormContent() {
1990
- if (this.resetStep === "none" && (!this.mode || this.mode === "signin" || this.signupStep === "form"))
1991
- return m`
1992
- <!-- Email -->
1993
- <base-input
1994
- id="email-input"
1995
- type="email"
1996
- label="Email Address"
1997
- placeholder="Enter your email"
1998
- .value=${this.email}
1999
- .error=${this.errors.email}
2000
- ?required=${!0}
2001
- autocomplete="email"
2002
- @input=${(e) => this.email = e.detail.value}
2003
- ></base-input>
2004
-
2005
- <!-- Password -->
2006
- <base-input
2007
- type="password"
2008
- label="Password"
2009
- placeholder="Enter your password"
2010
- .value=${this.password}
2011
- .error=${this.errors.password}
2012
- ?required=${!0}
2013
- autocomplete=${this.mode === "signup" ? "new-password" : "current-password"}
2014
- @input=${(e) => this.password = e.detail.value}
2015
- ></base-input>
2016
-
2017
- ${this.mode === "signin" && this.error ? m`
2018
- <div class="forgot-row">
2019
- <button type="button" class="text-btn" @click=${this.startReset}>
2020
- Forgot your password?
2021
- </button>
2022
- </div>
2023
- ` : g}
2024
-
2025
- ${this.mode === "signup" ? m`
2026
- <!-- Confirm Password -->
2027
- <base-input
2028
- type="password"
2029
- label="Confirm Password"
2030
- placeholder="Re-enter your password"
2031
- .value=${this.confirmPassword}
2032
- .error=${this.errors.confirm_password}
2033
- ?required=${!0}
2034
- autocomplete="new-password"
2035
- @input=${(e) => this.confirmPassword = e.detail.value}
2036
- ></base-input>
2037
-
2038
- <!-- First Name -->
2039
- <base-input
2040
- type="text"
2041
- label="First Name"
2042
- placeholder="Enter your first name"
2043
- .value=${this.givenName}
2044
- .error=${this.errors.givenName}
2045
- ?required=${!0}
2046
- autocomplete="given-name"
2047
- @input=${(e) => this.givenName = e.detail.value}
2048
- ></base-input>
2049
-
2050
- <!-- Last Name -->
2051
- <base-input
2052
- type="text"
2053
- label="Last Name"
2054
- placeholder="Enter your last name"
2055
- .value=${this.familyName}
2056
- .error=${this.errors.familyName}
2057
- ?required=${!0}
2058
- autocomplete="family-name"
2059
- @input=${(e) => this.familyName = e.detail.value}
2060
- ></base-input>
2061
- ` : g}
2062
- `;
2063
- if (this.mode === "signup" && this.signupStep === "otp")
2064
- return m`
2065
- <div class="otp-section">
2066
- <label class="otp-label">Enter 6-digit code</label>
2067
- <div class="otp-inputs" role="group" aria-label="One time code">
2068
- ${yt(
2069
- Array.from({ length: 6 }, (e, t) => t),
2070
- (e) => e,
2071
- (e) => m`
2072
- <input
2073
- class="otp-input signup-otp-input ${this.errors.signup_otp ? "otp-input--error" : ""}"
2074
- type="text"
2075
- inputmode="numeric"
2076
- pattern="[0-9]*"
2077
- maxlength="1"
2078
- data-index="${e}"
2079
- .value=${this.signupOtpDigits[e]}
2080
- @input=${(t) => this.handleOtpInput(e, t, !0)}
2081
- @keydown=${(t) => this.handleOtpKeydown(e, t, !0)}
2082
- @paste=${(t) => this.handleOtpPaste(t, !0)}
2083
- aria-label="Digit ${e + 1}"
2084
- />
2085
- `
2086
- )}
2087
- </div>
2088
- ${this.errors.signup_otp ? m`<p class="otp-error">${this.errors.signup_otp}</p>` : g}
2089
- </div>
2090
- <div class="forgot-row">
2091
- <button type="button" class="text-btn" @click=${this.backToSignupForm}>
2092
- Didn't get a code? Go back
2093
- </button>
2094
- </div>
2095
- `;
2096
- if (this.resetStep === "request")
2097
- return m`
2098
- <base-input
2099
- id="email-input"
2100
- type="email"
2101
- label="Email Address"
2102
- placeholder="Enter your email"
2103
- .value=${this.email}
2104
- .error=${this.errors.email}
2105
- ?required=${!0}
2106
- autocomplete="email"
2107
- @input=${(e) => this.email = e.detail.value}
2108
- ></base-input>
2109
- <div class="forgot-row">
2110
- <button type="button" class="text-btn" @click=${this.cancelReset}>
2111
- Back to Sign In
2112
- </button>
2113
- </div>
2114
- `;
2115
- if (this.resetStep === "confirm") {
2116
- const e = this.otpDigits.every((t) => /^\d$/.test(t));
2117
- return m`
2118
- <base-input
2119
- type="email"
2120
- label="Email Address"
2121
- placeholder="Enter your email"
2122
- .value=${this.email}
2123
- .error=${this.errors.email}
2124
- ?required=${!0}
2125
- autocomplete="email"
2126
- @input=${(t) => this.email = t.detail.value}
2127
- ></base-input>
2128
-
2129
- <div class="otp-section">
2130
- <label class="otp-label">Enter 6-digit code</label>
2131
- <div class="otp-inputs" role="group" aria-label="One time code">
2132
- ${yt(
2133
- Array.from({ length: 6 }, (t, s) => s),
2134
- (t) => t,
2135
- (t) => m`
2136
- <input
2137
- class="otp-input reset-otp-input ${this.errors.otp ? "otp-input--error" : ""}"
2138
- type="text"
2139
- inputmode="numeric"
2140
- pattern="[0-9]*"
2141
- maxlength="1"
2142
- data-index="${t}"
2143
- .value=${this.otpDigits[t]}
2144
- @input=${(s) => this.handleOtpInput(t, s, !1)}
2145
- @keydown=${(s) => this.handleOtpKeydown(t, s, !1)}
2146
- @paste=${(s) => this.handleOtpPaste(s, !1)}
2147
- aria-label="Digit ${t + 1}"
2148
- />
2149
- `
2150
- )}
2151
- </div>
2152
- ${this.errors.otp ? m`<p class="otp-error">${this.errors.otp}</p>` : g}
2153
- </div>
2154
-
2155
- ${e ? m`
2156
- <div class="new-password-fields">
2157
- <base-input
2158
- type="password"
2159
- label="New Password"
2160
- placeholder="Enter your new password"
2161
- .value=${this.newPassword}
2162
- .error=${this.errors.new_password}
2163
- ?required=${!0}
2164
- autocomplete="new-password"
2165
- @input=${(t) => this.newPassword = t.detail.value}
2166
- ></base-input>
2167
-
2168
- <base-input
2169
- type="password"
2170
- label="Confirm New Password"
2171
- placeholder="Re-enter your new password"
2172
- .value=${this.confirmPassword}
2173
- .error=${this.errors.confirm_password}
2174
- ?required=${!0}
2175
- autocomplete="new-password"
2176
- @input=${(t) => this.confirmPassword = t.detail.value}
2177
- ></base-input>
2178
- </div>
2179
- ` : g}
2180
-
2181
- <div class="forgot-row">
2182
- <button type="button" class="text-btn" @click=${this.backToRequest}>
2183
- Didn't get a code? Resend
2184
- </button>
2185
- </div>
2186
- `;
2187
- }
2188
- return g;
2189
- }
2190
- renderActions() {
2191
- if (this.resetStep === "request")
2192
- return m`
2193
- <base-button
2194
- type="submit"
2195
- variant="primary"
2196
- full-width
2197
- ?loading=${this.isLoading}
2198
- ?disabled=${this.isLoading}
2199
- >
2200
- ${this.isLoading ? "Sending..." : "Send Reset Code"}
2201
- </base-button>
2202
- `;
2203
- if (this.resetStep === "confirm")
2204
- return this.otpDigits.every((t) => /^\d$/.test(t)) ? m`
2205
- <base-button
2206
- type="submit"
2207
- variant="primary"
2208
- full-width
2209
- ?loading=${this.isLoading}
2210
- ?disabled=${this.isLoading}
2211
- >
2212
- ${this.isLoading ? "Resetting..." : "Reset Password"}
2213
- </base-button>
2214
- ` : g;
2215
- if (this.mode === "signup" && this.signupStep === "otp") {
2216
- const e = this.signupOtpDigits.every((t) => /^\d$/.test(t));
2217
- return m`
2218
- <base-button
2219
- type="submit"
2220
- variant="primary"
2221
- full-width
2222
- ?loading=${this.isLoading}
2223
- ?disabled=${!e || this.isLoading}
2224
- >
2225
- ${this.isLoading ? "Completing..." : "Complete Registration"}
2226
- </base-button>
2227
- `;
2228
- }
2229
- return m`
2230
- <base-button
2231
- type="submit"
2232
- variant="primary"
2233
- full-width
2234
- ?loading=${this.isLoading}
2235
- ?disabled=${this.isLoading}
2236
- >
2237
- ${this.isLoading ? "Loading..." : this.mode === "signup" ? "Continue" : "Sign In"}
2238
- </base-button>
2239
-
2240
- ${this.isOAuthConfigured() && this.mode === "signin" ? m`
2241
- <div class="button-row">
2242
- <button
2243
- type="button"
2244
- class="oauth-btn"
2245
- @click=${this.handleGoogleSignIn}
2246
- ?disabled=${this.isLoading}
2247
- >
2248
- ${this.renderGoogleIcon()}
2249
- </button>
2250
-
2251
- <button
2252
- type="button"
2253
- class="oauth-btn"
2254
- @click=${this.handleAppleSignIn}
2255
- ?disabled=${this.isLoading}
2256
- >
2257
- ${this.renderAppleIcon()}
2258
- </button>
2259
- </div>
2260
- ` : g}
2261
- `;
2262
- }
2263
- renderAlerts() {
2264
- return m`
2265
- ${this.notice ? m`
2266
- <div class="alert alert--success">
2267
- ${this.notice}
2268
- <button class="alert-close" @click=${() => this.notice = ""} aria-label="Dismiss">
2269
- ×
2270
- </button>
2271
- </div>
2272
- ` : g}
2273
- ${this.error ? m`
2274
- <div class="alert alert--error">
2275
- ${this.error}
2276
- <button class="alert-close" @click=${() => this.error = ""} aria-label="Dismiss">
2277
- ×
2278
- </button>
2279
- </div>
2280
- ` : g}
2281
- `;
2282
- }
2283
- renderFooter() {
2284
- return this.isLoggedIn ? g : this.resetStep === "none" && (!this.mode || this.mode === "signin" || this.signupStep === "form") ? this.disableSignup ? g : m`
2285
- <div class="auth-footer">
2286
- <p class="toggle-text">
2287
- ${this.mode === "signup" ? "Already have an account?" : "Don't have an account?"}
2288
- </p>
2289
- <button type="button" class="text-btn" @click=${this.toggleMode}>
2290
- ${this.mode === "signup" ? "Sign In" : "Sign Up"}
2291
- </button>
2292
- </div>
2293
- ` : m`
2294
- <div class="auth-footer">
2295
- <p class="toggle-text">
2296
- Having trouble? Email
2297
- <a href="mailto:support@example.com">support@example.com</a>
2298
- </p>
2299
- </div>
2300
- `;
2301
- }
2302
- renderGoogleIcon() {
2303
- return m`
2304
- <svg viewBox="-0.5 0 48 48" width="18" height="18" fill="none">
2305
- <path d="M9.82727273,24 C9.82727273,22.4757333 10.0804318,21.0144 10.5322727,19.6437333 L2.62345455,13.6042667 C1.08206818,16.7338667 0.213636364,20.2602667 0.213636364,24 C0.213636364,27.7365333 1.081,31.2608 2.62025,34.3882667 L10.5247955,28.3370667 C10.0772273,26.9728 9.82727273,25.5168 9.82727273,24" fill="#FBBC05"></path>
2306
- <path d="M23.7136364,10.1333333 C27.025,10.1333333 30.0159091,11.3066667 32.3659091,13.2266667 L39.2022727,6.4 C35.0363636,2.77333333 29.6954545,0.533333333 23.7136364,0.533333333 C14.4268636,0.533333333 6.44540909,5.84426667 2.62345455,13.6042667 L10.5322727,19.6437333 C12.3545909,14.112 17.5491591,10.1333333 23.7136364,10.1333333" fill="#EB4335"></path>
2307
- <path d="M23.7136364,37.8666667 C17.5491591,37.8666667 12.3545909,33.888 10.5322727,28.3562667 L2.62345455,34.3946667 C6.44540909,42.1557333 14.4268636,47.4666667 23.7136364,47.4666667 C29.4455,47.4666667 34.9177955,45.4314667 39.0249545,41.6181333 L31.5177727,35.8144 C29.3995682,37.1488 26.7323182,37.8666667 23.7136364,37.8666667" fill="#34A853"></path>
2308
- <path d="M46.1454545,24 C46.1454545,22.6133333 45.9318182,21.12 45.6113636,19.7333333 L23.7136364,19.7333333 L23.7136364,28.8 L36.3181818,28.8 C35.6879545,31.8912 33.9724545,34.2677333 31.5177727,35.8144 L39.0249545,41.6181333 C43.3393409,37.6138667 46.1454545,31.6490667 46.1454545,24" fill="#4285F4"></path>
2309
- </svg>
2310
- `;
2311
- }
2312
- renderAppleIcon() {
2313
- return m`
2314
- <svg viewBox="-3.5 0 48 48" width="18" height="18" class="apple-icon">
2315
- <path d="M231.174735,567.792499 C232.740177,565.771699 233.926883,562.915484 233.497649,560 C230.939077,560.177808 227.948466,561.814769 226.203475,563.948463 C224.612784,565.88177 223.305444,568.757742 223.816036,571.549042 C226.613071,571.636535 229.499881,569.960061 231.174735,567.792499 L231.174735,567.792499 Z M245,595.217241 C243.880625,597.712195 243.341978,598.827022 241.899976,601.03692 C239.888467,604.121745 237.052156,607.962958 233.53412,607.991182 C230.411652,608.02505 229.606488,605.94498 225.367451,605.970382 C221.128414,605.99296 220.244696,608.030695 217.116618,607.999649 C213.601387,607.968603 210.913765,604.502761 208.902256,601.417937 C203.27452,592.79849 202.68257,582.680377 206.152914,577.298162 C208.621711,573.476705 212.515678,571.241407 216.173986,571.241407 C219.89682,571.241407 222.239372,573.296075 225.322563,573.296075 C228.313175,573.296075 230.133913,571.235762 234.440281,571.235762 C237.700215,571.235762 241.153726,573.022307 243.611302,576.10431 C235.554045,580.546683 236.85858,592.121127 245,595.217241 L245,595.217241 Z" transform="translate(-204.000000, -560.000000)" fill="#0b0b0a"></path>
2316
- </svg>
2317
- `;
2318
- }
2319
- // Public methods for external control
2320
- setError(e) {
2321
- this.error = e;
2322
- }
2323
- setNotice(e) {
2324
- this.notice = e;
2325
- }
2326
- async refresh() {
2327
- try {
2328
- if (!this.hasApiBaseUrl()) {
2329
- this.error = this.baseUrlErrorMessage;
2330
- return;
2331
- }
2332
- const e = this.cookies.getAuthToken("REFRESH_TOKEN"), t = this.cookies.getAuthToken("ACCESS_TOKEN"), s = this.cookies.getAuthToken("AUTH_TOKEN");
2333
- if (!e || !t || !s) {
2334
- this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
2335
- return;
2336
- }
2337
- const { accessToken: r, idToken: i, refreshToken: o } = await this.getApiService().refresh({
2338
- refreshToken: e
2339
- });
2340
- this.cookies.setAuthToken("ACCESS_TOKEN", r), this.cookies.setAuthToken("AUTH_TOKEN", i), this.cookies.setAuthToken("REFRESH_TOKEN", o ?? e);
2341
- } catch {
2342
- this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
2343
- }
2344
- }
2345
- getUserEmail() {
2346
- return this.cookies.getCookie("USER_EMAIL") || null;
2347
- }
2348
- };
2349
- y.styles = ue();
2350
- $([
2351
- S({ type: String, attribute: "initial-mode" })
2352
- ], y.prototype, "initialMode", 2);
2353
- $([
2354
- S({ type: String, attribute: "logo-url" })
2355
- ], y.prototype, "logoUrl", 2);
2356
- $([
2357
- S({ type: String, attribute: "api-domain" })
2358
- ], y.prototype, "baseUrl", 2);
2359
- $([
2360
- S({ type: String, attribute: "oauth-domain" })
2361
- ], y.prototype, "oauthDomain", 2);
2362
- $([
2363
- S({ type: String, attribute: "oauth-region" })
2364
- ], y.prototype, "oauthRegion", 2);
2365
- $([
2366
- S({ type: String, attribute: "oauth-user-pool-id" })
2367
- ], y.prototype, "oauthUserPoolId", 2);
2368
- $([
2369
- S({ type: String, attribute: "oauth-client-id" })
2370
- ], y.prototype, "oauthClientId", 2);
2371
- $([
2372
- S({ type: String, attribute: "oauth-redirect-uri" })
2373
- ], y.prototype, "oauthRedirectUri", 2);
2374
- $([
2375
- S({ type: String, attribute: "oauth-spa-domain" })
2376
- ], y.prototype, "oauthSpaDomain", 2);
2377
- $([
2378
- S({ type: Boolean, attribute: "disable-signup" })
2379
- ], y.prototype, "disableSignup", 2);
2380
- $([
2381
- v()
2382
- ], y.prototype, "mode", 2);
2383
- $([
2384
- v()
2385
- ], y.prototype, "resetStep", 2);
2386
- $([
2387
- v()
2388
- ], y.prototype, "signupStep", 2);
2389
- $([
2390
- v()
2391
- ], y.prototype, "isLoading", 2);
2392
- $([
2393
- v()
2394
- ], y.prototype, "isLoggedIn", 2);
2395
- $([
2396
- v()
2397
- ], y.prototype, "email", 2);
2398
- $([
2399
- v()
2400
- ], y.prototype, "password", 2);
2401
- $([
2402
- v()
2403
- ], y.prototype, "givenName", 2);
2404
- $([
2405
- v()
2406
- ], y.prototype, "familyName", 2);
2407
- $([
2408
- v()
2409
- ], y.prototype, "newPassword", 2);
2410
- $([
2411
- v()
2412
- ], y.prototype, "confirmPassword", 2);
2413
- $([
2414
- v()
2415
- ], y.prototype, "notice", 2);
2416
- $([
2417
- v()
2418
- ], y.prototype, "error", 2);
2419
- $([
2420
- v()
2421
- ], y.prototype, "errors", 2);
2422
- $([
2423
- v()
2424
- ], y.prototype, "otpDigits", 2);
2425
- $([
2426
- v()
2427
- ], y.prototype, "signupOtpDigits", 2);
2428
- $([
2429
- Qt("#email-input")
2430
- ], y.prototype, "emailInput", 2);
2431
- y = $([
2432
- Gt("auth-form")
2433
- ], y);
2434
- export {
2435
- y as AuthForm
2436
- };