@wral/report-it 0.2.0 → 0.2.2
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.
- package/README.md +39 -3
- package/dist/define.mjs +1 -1
- package/dist/define.standalone.js +1650 -1549
- package/dist/index.mjs +130 -123
- package/dist/{wral-code-input-BZTBgLk3.js → wral-code-input-BA1oCHMu.js} +951 -850
- package/package.json +1 -1
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { getAuthContext as
|
|
3
|
-
const K = globalThis,
|
|
4
|
-
\f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
5
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g,
|
|
6
|
-
function
|
|
7
|
-
if (!Q(
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
const
|
|
11
|
-
const t =
|
|
12
|
-
let
|
|
1
|
+
import { css as b, html as c, nothing as f, LitElement as G } from "lit";
|
|
2
|
+
import { getAuthContext as Re, createStorage as Oe, verifyCode as Me, extractTokens as J, saveTokens as X, decodeJwtPayload as ee, refreshTokenSimple as te, sendCode as Ne, createUserPool as De, createCognitoUser as Pe, STORAGE_KEYS as S, isAuthenticatedSimple as Ue, signUpIfNeeded as ze } from "@wral/sdk-auth-audience";
|
|
3
|
+
const K = globalThis, se = (r) => r, P = K.trustedTypes, re = P ? P.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ve = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, _e = "?" + _, Be = `<${_e}>`, F = document, U = () => F.createComment(""), R = (r) => r === null || typeof r != "object" && typeof r != "function", Q = Array.isArray, Le = (r) => Q(r) || typeof r?.[Symbol.iterator] == "function", q = `[
|
|
4
|
+
\f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ne = /-->/g, ie = />/g, k = RegExp(`>|${q}(?:([^\\s"'>=/]+)(${q}*=${q}*(?:[^
|
|
5
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g, $e = /^(?:script|style|textarea|title)$/i, O = /* @__PURE__ */ Symbol.for("lit-noChange"), g = /* @__PURE__ */ Symbol.for("lit-nothing"), le = /* @__PURE__ */ new WeakMap(), A = F.createTreeWalker(F, 129);
|
|
6
|
+
function ke(r, e) {
|
|
7
|
+
if (!Q(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
8
|
+
return re !== void 0 ? re.createHTML(e) : e;
|
|
9
|
+
}
|
|
10
|
+
const He = (r, e) => {
|
|
11
|
+
const t = r.length - 1, s = [];
|
|
12
|
+
let n, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", o = C;
|
|
13
13
|
for (let a = 0; a < t; a++) {
|
|
14
|
-
const l =
|
|
15
|
-
let d,
|
|
16
|
-
for (;
|
|
17
|
-
const
|
|
18
|
-
|
|
14
|
+
const l = r[a];
|
|
15
|
+
let d, h, u = -1, p = 0;
|
|
16
|
+
for (; p < l.length && (o.lastIndex = p, h = o.exec(l), h !== null); ) p = o.lastIndex, o === C ? h[1] === "!--" ? o = ne : h[1] !== void 0 ? o = ie : h[2] !== void 0 ? ($e.test(h[2]) && (n = RegExp("</" + h[2], "g")), o = k) : h[3] !== void 0 && (o = k) : o === k ? h[0] === ">" ? (o = n ?? C, u = -1) : h[1] === void 0 ? u = -2 : (u = o.lastIndex - h[2].length, d = h[1], o = h[3] === void 0 ? k : h[3] === '"' ? ae : oe) : o === ae || o === oe ? o = k : o === ne || o === ie ? o = C : (o = k, n = void 0);
|
|
17
|
+
const y = o === k && r[a + 1].startsWith("/>") ? " " : "";
|
|
18
|
+
i += o === C ? l + Be : u >= 0 ? (s.push(d), l.slice(0, u) + ve + l.slice(u) + _ + y) : l + _ + (u === -2 ? a : y);
|
|
19
19
|
}
|
|
20
|
-
return [
|
|
20
|
+
return [ke(r, i + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
|
|
21
21
|
};
|
|
22
|
-
class
|
|
23
|
-
constructor({ strings: e, _$litType$: t },
|
|
24
|
-
let
|
|
22
|
+
class M {
|
|
23
|
+
constructor({ strings: e, _$litType$: t }, s) {
|
|
24
|
+
let n;
|
|
25
25
|
this.parts = [];
|
|
26
|
-
let
|
|
27
|
-
const a = e.length - 1, l = this.parts, [d,
|
|
28
|
-
if (this.el =
|
|
26
|
+
let i = 0, o = 0;
|
|
27
|
+
const a = e.length - 1, l = this.parts, [d, h] = He(e, t);
|
|
28
|
+
if (this.el = M.createElement(d, s), A.currentNode = this.el.content, t === 2 || t === 3) {
|
|
29
29
|
const u = this.el.content.firstChild;
|
|
30
30
|
u.replaceWith(...u.childNodes);
|
|
31
31
|
}
|
|
32
|
-
for (; (
|
|
33
|
-
if (
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
l.push({ type: 1, index:
|
|
37
|
-
} else u.startsWith(
|
|
38
|
-
if (
|
|
39
|
-
const u =
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
for (let
|
|
43
|
-
|
|
32
|
+
for (; (n = A.nextNode()) !== null && l.length < a; ) {
|
|
33
|
+
if (n.nodeType === 1) {
|
|
34
|
+
if (n.hasAttributes()) for (const u of n.getAttributeNames()) if (u.endsWith(ve)) {
|
|
35
|
+
const p = h[o++], y = n.getAttribute(u).split(_), w = /([.?@])?(.*)/.exec(p);
|
|
36
|
+
l.push({ type: 1, index: i, name: w[2], strings: y, ctor: w[1] === "." ? We : w[1] === "?" ? Ve : w[1] === "@" ? je : B }), n.removeAttribute(u);
|
|
37
|
+
} else u.startsWith(_) && (l.push({ type: 6, index: i }), n.removeAttribute(u));
|
|
38
|
+
if ($e.test(n.tagName)) {
|
|
39
|
+
const u = n.textContent.split(_), p = u.length - 1;
|
|
40
|
+
if (p > 0) {
|
|
41
|
+
n.textContent = P ? P.emptyScript : "";
|
|
42
|
+
for (let y = 0; y < p; y++) n.append(u[y], U()), A.nextNode(), l.push({ type: 2, index: ++i });
|
|
43
|
+
n.append(u[p], U());
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
} else if (
|
|
46
|
+
} else if (n.nodeType === 8) if (n.data === _e) l.push({ type: 2, index: i });
|
|
47
47
|
else {
|
|
48
48
|
let u = -1;
|
|
49
|
-
for (; (u =
|
|
49
|
+
for (; (u = n.data.indexOf(_, u + 1)) !== -1; ) l.push({ type: 7, index: i }), u += _.length - 1;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
i++;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
static createElement(e, t) {
|
|
55
|
-
const
|
|
56
|
-
return
|
|
55
|
+
const s = F.createElement("template");
|
|
56
|
+
return s.innerHTML = e, s;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function E(
|
|
60
|
-
if (e ===
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
return
|
|
59
|
+
function E(r, e, t = r, s) {
|
|
60
|
+
if (e === O) return e;
|
|
61
|
+
let n = s !== void 0 ? t._$Co?.[s] : t._$Cl;
|
|
62
|
+
const i = R(e) ? void 0 : e._$litDirective$;
|
|
63
|
+
return n?.constructor !== i && (n?._$AO?.(!1), i === void 0 ? n = void 0 : (n = new i(r), n._$AT(r, t, s)), s !== void 0 ? (t._$Co ??= [])[s] = n : t._$Cl = n), n !== void 0 && (e = E(r, n._$AS(r, e.values), n, s)), e;
|
|
64
64
|
}
|
|
65
|
-
class
|
|
65
|
+
class qe {
|
|
66
66
|
constructor(e, t) {
|
|
67
67
|
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
|
|
68
68
|
}
|
|
@@ -73,29 +73,29 @@ class Le {
|
|
|
73
73
|
return this._$AM._$AU;
|
|
74
74
|
}
|
|
75
75
|
u(e) {
|
|
76
|
-
const { el: { content: t }, parts:
|
|
77
|
-
|
|
78
|
-
let
|
|
76
|
+
const { el: { content: t }, parts: s } = this._$AD, n = (e?.creationScope ?? F).importNode(t, !0);
|
|
77
|
+
A.currentNode = n;
|
|
78
|
+
let i = A.nextNode(), o = 0, a = 0, l = s[0];
|
|
79
79
|
for (; l !== void 0; ) {
|
|
80
80
|
if (o === l.index) {
|
|
81
81
|
let d;
|
|
82
|
-
l.type === 2 ? d = new
|
|
82
|
+
l.type === 2 ? d = new z(i, i.nextSibling, this, e) : l.type === 1 ? d = new l.ctor(i, l.name, l.strings, this, e) : l.type === 6 && (d = new Ye(i, this, e)), this._$AV.push(d), l = s[++a];
|
|
83
83
|
}
|
|
84
|
-
o !== l?.index && (
|
|
84
|
+
o !== l?.index && (i = A.nextNode(), o++);
|
|
85
85
|
}
|
|
86
|
-
return
|
|
86
|
+
return A.currentNode = F, n;
|
|
87
87
|
}
|
|
88
88
|
p(e) {
|
|
89
89
|
let t = 0;
|
|
90
|
-
for (const
|
|
90
|
+
for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
class
|
|
93
|
+
class z {
|
|
94
94
|
get _$AU() {
|
|
95
95
|
return this._$AM?._$AU ?? this._$Cv;
|
|
96
96
|
}
|
|
97
|
-
constructor(e, t,
|
|
98
|
-
this.type = 2, this._$AH =
|
|
97
|
+
constructor(e, t, s, n) {
|
|
98
|
+
this.type = 2, this._$AH = g, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = n, this._$Cv = n?.isConnected ?? !0;
|
|
99
99
|
}
|
|
100
100
|
get parentNode() {
|
|
101
101
|
let e = this._$AA.parentNode;
|
|
@@ -109,7 +109,7 @@ class U {
|
|
|
109
109
|
return this._$AB;
|
|
110
110
|
}
|
|
111
111
|
_$AI(e, t = this) {
|
|
112
|
-
e = E(this, e, t), R(e) ? e ===
|
|
112
|
+
e = E(this, e, t), R(e) ? e === g || e == null || e === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : e !== this._$AH && e !== O && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Le(e) ? this.k(e) : this._(e);
|
|
113
113
|
}
|
|
114
114
|
O(e) {
|
|
115
115
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -118,94 +118,94 @@ class U {
|
|
|
118
118
|
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
119
119
|
}
|
|
120
120
|
_(e) {
|
|
121
|
-
this._$AH !==
|
|
121
|
+
this._$AH !== g && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(F.createTextNode(e)), this._$AH = e;
|
|
122
122
|
}
|
|
123
123
|
$(e) {
|
|
124
|
-
const { values: t, _$litType$:
|
|
125
|
-
if (this._$AH?._$AD ===
|
|
124
|
+
const { values: t, _$litType$: s } = e, n = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = M.createElement(ke(s.h, s.h[0]), this.options)), s);
|
|
125
|
+
if (this._$AH?._$AD === n) this._$AH.p(t);
|
|
126
126
|
else {
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
const i = new qe(n, this), o = i.u(this.options);
|
|
128
|
+
i.p(t), this.T(o), this._$AH = i;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
_$AC(e) {
|
|
132
132
|
let t = le.get(e.strings);
|
|
133
|
-
return t === void 0 && le.set(e.strings, t = new
|
|
133
|
+
return t === void 0 && le.set(e.strings, t = new M(e)), t;
|
|
134
134
|
}
|
|
135
135
|
k(e) {
|
|
136
136
|
Q(this._$AH) || (this._$AH = [], this._$AR());
|
|
137
137
|
const t = this._$AH;
|
|
138
|
-
let
|
|
139
|
-
for (const
|
|
140
|
-
|
|
138
|
+
let s, n = 0;
|
|
139
|
+
for (const i of e) n === t.length ? t.push(s = new z(this.O(U()), this.O(U()), this, this.options)) : s = t[n], s._$AI(i), n++;
|
|
140
|
+
n < t.length && (this._$AR(s && s._$AB.nextSibling, n), t.length = n);
|
|
141
141
|
}
|
|
142
142
|
_$AR(e = this._$AA.nextSibling, t) {
|
|
143
143
|
for (this._$AP?.(!1, !0, t); e !== this._$AB; ) {
|
|
144
|
-
const
|
|
145
|
-
|
|
144
|
+
const s = se(e).nextSibling;
|
|
145
|
+
se(e).remove(), e = s;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
setConnected(e) {
|
|
149
149
|
this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
class
|
|
152
|
+
class B {
|
|
153
153
|
get tagName() {
|
|
154
154
|
return this.element.tagName;
|
|
155
155
|
}
|
|
156
156
|
get _$AU() {
|
|
157
157
|
return this._$AM._$AU;
|
|
158
158
|
}
|
|
159
|
-
constructor(e, t,
|
|
160
|
-
this.type = 1, this._$AH =
|
|
159
|
+
constructor(e, t, s, n, i) {
|
|
160
|
+
this.type = 1, this._$AH = g, this._$AN = void 0, this.element = e, this.name = t, this._$AM = n, this.options = i, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = g;
|
|
161
161
|
}
|
|
162
|
-
_$AI(e, t = this,
|
|
163
|
-
const
|
|
162
|
+
_$AI(e, t = this, s, n) {
|
|
163
|
+
const i = this.strings;
|
|
164
164
|
let o = !1;
|
|
165
|
-
if (
|
|
165
|
+
if (i === void 0) e = E(this, e, t, 0), o = !R(e) || e !== this._$AH && e !== O, o && (this._$AH = e);
|
|
166
166
|
else {
|
|
167
167
|
const a = e;
|
|
168
168
|
let l, d;
|
|
169
|
-
for (e =
|
|
169
|
+
for (e = i[0], l = 0; l < i.length - 1; l++) d = E(this, a[s + l], t, l), d === O && (d = this._$AH[l]), o ||= !R(d) || d !== this._$AH[l], d === g ? e = g : e !== g && (e += (d ?? "") + i[l + 1]), this._$AH[l] = d;
|
|
170
170
|
}
|
|
171
|
-
o && !
|
|
171
|
+
o && !n && this.j(e);
|
|
172
172
|
}
|
|
173
173
|
j(e) {
|
|
174
|
-
e ===
|
|
174
|
+
e === g ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
class
|
|
177
|
+
class We extends B {
|
|
178
178
|
constructor() {
|
|
179
179
|
super(...arguments), this.type = 3;
|
|
180
180
|
}
|
|
181
181
|
j(e) {
|
|
182
|
-
this.element[this.name] = e ===
|
|
182
|
+
this.element[this.name] = e === g ? void 0 : e;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
class
|
|
185
|
+
class Ve extends B {
|
|
186
186
|
constructor() {
|
|
187
187
|
super(...arguments), this.type = 4;
|
|
188
188
|
}
|
|
189
189
|
j(e) {
|
|
190
|
-
this.element.toggleAttribute(this.name, !!e && e !==
|
|
190
|
+
this.element.toggleAttribute(this.name, !!e && e !== g);
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
class
|
|
194
|
-
constructor(e, t,
|
|
195
|
-
super(e, t,
|
|
193
|
+
class je extends B {
|
|
194
|
+
constructor(e, t, s, n, i) {
|
|
195
|
+
super(e, t, s, n, i), this.type = 5;
|
|
196
196
|
}
|
|
197
197
|
_$AI(e, t = this) {
|
|
198
|
-
if ((e = E(this, e, t, 0) ??
|
|
199
|
-
const
|
|
200
|
-
|
|
198
|
+
if ((e = E(this, e, t, 0) ?? g) === O) return;
|
|
199
|
+
const s = this._$AH, n = e === g && s !== g || e.capture !== s.capture || e.once !== s.once || e.passive !== s.passive, i = e !== g && (s === g || n);
|
|
200
|
+
n && this.element.removeEventListener(this.name, this, s), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
201
201
|
}
|
|
202
202
|
handleEvent(e) {
|
|
203
203
|
typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class
|
|
207
|
-
constructor(e, t,
|
|
208
|
-
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options =
|
|
206
|
+
class Ye {
|
|
207
|
+
constructor(e, t, s) {
|
|
208
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
|
|
209
209
|
}
|
|
210
210
|
get _$AU() {
|
|
211
211
|
return this._$AM._$AU;
|
|
@@ -214,9 +214,9 @@ class je {
|
|
|
214
214
|
E(this, e);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
const ce = (
|
|
217
|
+
const Ge = K.litHtmlPolyfillSupport;
|
|
218
|
+
Ge?.(M, z), (K.litHtmlVersions ??= []).push("3.3.3");
|
|
219
|
+
const ce = (r) => r ?? g, Ke = b`
|
|
220
220
|
:host {
|
|
221
221
|
display: block;
|
|
222
222
|
box-sizing: border-box;
|
|
@@ -240,7 +240,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
240
240
|
position: absolute; width: 1px; height: 1px; overflow: hidden;
|
|
241
241
|
clip: rect(0 0 0 0); white-space: nowrap;
|
|
242
242
|
}
|
|
243
|
-
`,
|
|
243
|
+
`, Qe = b`
|
|
244
244
|
@keyframes pop-in {
|
|
245
245
|
0% { opacity: 0; transform: translateY(16px) scale(0.95); }
|
|
246
246
|
100% { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -253,7 +253,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
253
253
|
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
|
|
254
254
|
30% { transform: translateY(-5px); opacity: 1; }
|
|
255
255
|
}
|
|
256
|
-
.msg, .options, .form-card, .confirm-card
|
|
256
|
+
.msg, .options, .form-card, .confirm-card {
|
|
257
257
|
animation: pop-in 340ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
258
258
|
}
|
|
259
259
|
.chip { animation: chip-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
|
|
@@ -267,11 +267,11 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
267
267
|
.typing span:nth-child(2) { animation-delay: 0.15s; }
|
|
268
268
|
.typing span:nth-child(3) { animation-delay: 0.3s; }
|
|
269
269
|
@media (prefers-reduced-motion: reduce) {
|
|
270
|
-
.msg, .options, .form-card, .confirm-card, .
|
|
270
|
+
.msg, .options, .form-card, .confirm-card, .chip, .typing span {
|
|
271
271
|
animation: none !important;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
`,
|
|
274
|
+
`, Ze = b`
|
|
275
275
|
.msg { max-width: 85%; padding: 12px 16px; border-radius: 14px; font-size: 15px; }
|
|
276
276
|
.msg.bot {
|
|
277
277
|
background: var(--wral-semantic-surface-default, #FFFFFF);
|
|
@@ -293,7 +293,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
293
293
|
.msg .sub { display: block; font-size: 13px; color: var(--wral-semantic-fg-muted, #64748B); margin-top: 4px; }
|
|
294
294
|
.msg.user .sub { color: rgba(255, 255, 255, 0.75); }
|
|
295
295
|
.msg.error { border-left: 3px solid var(--wral-base-red-on-light, #D1232A); }
|
|
296
|
-
`,
|
|
296
|
+
`, Je = b`
|
|
297
297
|
.options { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 92%; padding: 2px 0 6px; }
|
|
298
298
|
.chip {
|
|
299
299
|
font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
|
|
@@ -307,7 +307,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
307
307
|
.chip:hover { background: var(--wral-base-secondary-1, #2594E3); color: #FFFFFF; }
|
|
308
308
|
.chip:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
|
|
309
309
|
.chip:active { transform: scale(0.97); }
|
|
310
|
-
`,
|
|
310
|
+
`, Xe = b`
|
|
311
311
|
.form-card {
|
|
312
312
|
align-self: stretch;
|
|
313
313
|
background: var(--wral-semantic-surface-default, #FFFFFF);
|
|
@@ -372,7 +372,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
372
372
|
.btn-ghost:hover { border-color: var(--wral-base-secondary-1, #2594E3); }
|
|
373
373
|
.btn-ghost:active { transform: scale(0.97); }
|
|
374
374
|
.btn-ghost:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
|
|
375
|
-
`,
|
|
375
|
+
`, et = b`
|
|
376
376
|
.login-card { padding: 28px 26px; }
|
|
377
377
|
.login-card h2 {
|
|
378
378
|
font-family: var(--wral-base-font-display, 'IBM Plex Sans Condensed', sans-serif);
|
|
@@ -459,7 +459,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
459
459
|
.anon-costs .x { flex-shrink: 0; font-weight: 700; color: var(--wral-base-red-on-light, #D1232A); }
|
|
460
460
|
.anon-actions { display: flex; flex-direction: column; gap: 10px; }
|
|
461
461
|
.anon-actions .btn-ghost { width: 100%; }
|
|
462
|
-
`,
|
|
462
|
+
`, tt = b`
|
|
463
463
|
.review-list { margin: 0; padding: 0; list-style: none; font-size: 14px; }
|
|
464
464
|
.review-list li {
|
|
465
465
|
display: grid; grid-template-columns: 130px 1fr; gap: 10px;
|
|
@@ -491,7 +491,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
491
491
|
color: var(--wral-base-primary-1, #001D68);
|
|
492
492
|
}
|
|
493
493
|
@media (max-width: 540px) { .review-list li { grid-template-columns: 1fr; gap: 2px; } }
|
|
494
|
-
`,
|
|
494
|
+
`, st = b`
|
|
495
495
|
.upload-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; }
|
|
496
496
|
.upload-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
497
497
|
.upload-row .state { font-size: 12px; color: var(--wral-semantic-fg-subtle, #64748B); }
|
|
@@ -507,7 +507,7 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
507
507
|
border-radius: 999px; padding: 3px 12px; cursor: pointer;
|
|
508
508
|
}
|
|
509
509
|
.retry-chip:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
|
|
510
|
-
`,
|
|
510
|
+
`, rt = b`
|
|
511
511
|
.confirm-card {
|
|
512
512
|
align-self: stretch;
|
|
513
513
|
background: var(--wral-base-primary-1, #001D68);
|
|
@@ -557,48 +557,23 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
557
557
|
.c-again:hover { background: rgba(255, 255, 255, 0.12); }
|
|
558
558
|
.c-again:focus-visible { outline: 2px solid var(--wral-base-secondary-2, #50A9E8); outline-offset: 2px; }
|
|
559
559
|
.c-again:active { transform: scale(0.97); }
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
background: var(--wral-semantic-surface-default, #FFFFFF);
|
|
564
|
-
border: 1px solid var(--wral-semantic-border-muted, #E2E8F0);
|
|
565
|
-
border-radius: 12px; padding: 20px 22px;
|
|
566
|
-
box-shadow: 0 1px 2px rgba(3, 7, 17, 0.07), 0 6px 16px rgba(3, 7, 17, 0.05);
|
|
567
|
-
}
|
|
568
|
-
.j-eyebrow {
|
|
569
|
-
font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
|
|
570
|
-
font-size: 12px; font-weight: 700; text-transform: uppercase;
|
|
571
|
-
letter-spacing: 0.08em;
|
|
572
|
-
color: var(--wral-base-red-on-light, #D1232A);
|
|
573
|
-
margin-bottom: 2px;
|
|
574
|
-
}
|
|
575
|
-
.j-title {
|
|
576
|
-
font-family: var(--wral-base-font-display, 'IBM Plex Sans Condensed', sans-serif);
|
|
577
|
-
font-size: 18px; font-weight: 700;
|
|
578
|
-
color: var(--wral-base-primary-1, #001D68); margin: 0 0 10px;
|
|
560
|
+
.facts-offer dl {
|
|
561
|
+
display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
|
|
562
|
+
margin: 0 0 14px; font-size: 14.5px;
|
|
579
563
|
}
|
|
580
|
-
.
|
|
581
|
-
.
|
|
582
|
-
|
|
583
|
-
|
|
564
|
+
.facts-offer dt { font-weight: 700; color: var(--wral-semantic-fg-subtle, #64748B); }
|
|
565
|
+
.facts-offer dd { margin: 0; overflow-wrap: anywhere; }
|
|
566
|
+
.facts-offer .facts-note {
|
|
567
|
+
display: flex; gap: 8px; align-items: center;
|
|
568
|
+
margin: 0 0 14px; font-size: 13.5px;
|
|
569
|
+
color: var(--wral-semantic-fg-muted, #475569);
|
|
584
570
|
}
|
|
585
|
-
.
|
|
586
|
-
flex-shrink: 0; width:
|
|
587
|
-
background: var(--wral-semantic-surface-sunken, #F1F5F9);
|
|
588
|
-
border: 1.5px solid var(--wral-base-secondary-1, #2594E3);
|
|
571
|
+
.facts-offer .my-wral-icon {
|
|
572
|
+
flex-shrink: 0; width: 28px; height: 28px;
|
|
589
573
|
color: var(--wral-base-primary-1, #001D68);
|
|
590
|
-
font-family: var(--wral-base-font-mono, 'IBM Plex Mono', monospace);
|
|
591
|
-
font-size: 11px;
|
|
592
|
-
display: flex; align-items: center; justify-content: center;
|
|
593
|
-
position: relative; z-index: 1;
|
|
594
|
-
}
|
|
595
|
-
.j-body .j-t {
|
|
596
|
-
font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
|
|
597
|
-
font-size: 14.5px; font-weight: 700;
|
|
598
|
-
color: var(--wral-base-primary-1, #001D68); margin-bottom: 2px;
|
|
599
574
|
}
|
|
600
|
-
.
|
|
601
|
-
`,
|
|
575
|
+
.facts-offer .actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
576
|
+
`, nt = b`
|
|
602
577
|
.bottom-bar {
|
|
603
578
|
position: sticky; bottom: 0; z-index: 20;
|
|
604
579
|
background: var(--wral-semantic-surface-default, #FFFFFF);
|
|
@@ -611,89 +586,100 @@ const ce = (s) => s ?? m, Ve = y`
|
|
|
611
586
|
}
|
|
612
587
|
.bottom-bar .note { margin-left: auto; font-size: 12px; color: var(--wral-semantic-fg-subtle, #64748B); }
|
|
613
588
|
@media (max-width: 540px) { .bottom-bar .note { display: none; } }
|
|
614
|
-
`,
|
|
615
|
-
function
|
|
589
|
+
`, it = [Ke, Qe, Ze, Je, Xe, et, tt, st, rt, nt];
|
|
590
|
+
function m(r, e, { noAnim: t = !1, error: s = !1 } = {}) {
|
|
616
591
|
return c`
|
|
617
|
-
<div class="msg bot ${t ? "no-anim" : ""} ${
|
|
618
|
-
<span class="lead">${
|
|
592
|
+
<div class="msg bot ${t ? "no-anim" : ""} ${s ? "error" : ""}">
|
|
593
|
+
<span class="lead">${r}</span>
|
|
619
594
|
${e ? c`<span class="sub">${e}</span>` : f}
|
|
620
595
|
</div>
|
|
621
596
|
`;
|
|
622
597
|
}
|
|
623
|
-
function
|
|
624
|
-
return c`<div class="msg user ${e ? "no-anim" : ""}">${
|
|
598
|
+
function v(r, { noAnim: e = !1 } = {}) {
|
|
599
|
+
return c`<div class="msg user ${e ? "no-anim" : ""}">${r}</div>`;
|
|
625
600
|
}
|
|
626
|
-
function
|
|
601
|
+
function W() {
|
|
627
602
|
return c`<div class="msg bot typing"><span></span><span></span><span></span></div>`;
|
|
628
603
|
}
|
|
629
|
-
function
|
|
630
|
-
return
|
|
604
|
+
function ot(r) {
|
|
605
|
+
return r ? c`<span class="flag-pill ${r}">${r === "urgent" ? "Urgent" : "Moderate"}</span>` : f;
|
|
631
606
|
}
|
|
632
|
-
function
|
|
607
|
+
function at() {
|
|
633
608
|
return c`
|
|
634
609
|
<svg viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="3"
|
|
635
610
|
stroke-linecap="round" stroke-linejoin="round" width="20" height="20"
|
|
636
611
|
aria-hidden="true"><path d="M20 6L9 17l-5-5"/></svg>
|
|
637
612
|
`;
|
|
638
613
|
}
|
|
639
|
-
|
|
614
|
+
function lt() {
|
|
615
|
+
return c`
|
|
616
|
+
<svg class="my-wral-icon" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 423 423">
|
|
617
|
+
<rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="#fff"/>
|
|
618
|
+
<path d="M275.54,335.39c-6.35-4.36-6.31-10.09-2.64-8.95,2.38.89,7.28,2.02,12.45.67,28.16-7.34,33.71-60.25,33.4-90.88-8.42,12.43-14.4,23.62-24.46,26.24-6.04,1.57-15.9.23-23.04-3.63-9.31-5.1-13.58-10.91-16.81-23.31-4.04-15.5,1.11-47.55,3.78-60.89.07-.92.86-1.43,1.72-1.65,9.48-2.47,28.53,7.02,28.44,17.28.01,15.35-6.27,38.36-3.41,49.35.81,3.1,2.97,4.34,4.98,3.82,7.76-2.02,21.85-31.58,26.87-46.44,6.59-19.48,6.85-37.3,10.88-38.35,6.89-1.8,22.4,5.9,24.17,13.87,10.85,52.26.88,151.79-51.71,165.48-7.47,1.95-16.82,2.57-24.62-2.62Z" fill="currentColor"/>
|
|
619
|
+
<path d="M77.88,314.03c-4.19-16.07-3.14-35.61-2.89-44.1,1.84-47.14,4.3-84.81,13.75-133.32,1.05-5.39,4.7-9.05,16.15-7.52,10.8,1.4,14.78,6.08,16.1,11.16.66,2.54.97,6.07,2,11.22,12.38,1.59,15.13,5.09,19.64,14.15,4.58,9.34,6.28,17.03,8.04,23.79,2.72,10.43,4.49,18.4,7.34,26.99,11.89-22.67,15.82-55.9,34.99-75.34,6.66-6.25,10.81-9.14,15.41-10.34,3.74-.97,4.31-1.12,7.98-1.17,11.21-2.92,20.44,1.9,21.91,7.54.44,1.69,1.77,7.97,2,10.01,2.08,12.7-1.86,42.33-.69,73.93.66,15.48.93,25.95,2.42,36.4.75,5.22-.23,10.9-9.71,13.37-3.16.82-7.4,2.23-10.42,2.41-6.33.45-8.81-6.73-9.78-12.8-6.74-36.47,1.6-91.63-1.83-101.27-9.11,19.23-13.35,32.38-18.54,45.47-3.41,9.32-6.93,21.67-10.7,30.78-3.69,10.59-4.88,15.42-13.22,17.59-3.45.9-6.39,1.36-9.27,2.11-7.19,1.87-17.92-1.65-20.41-8.83-6.22-19.15-9-27.46-20.28-66.06-5.84,78.88-6.35,118.15.88,140.04,1.83,5.85-9.96,7.71-12.04,7.96-23,3.58-26.87-6.55-28.85-14.16Z" fill="currentColor"/>
|
|
620
|
+
<rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="2"/>
|
|
621
|
+
<rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="10"/>
|
|
622
|
+
</svg>
|
|
623
|
+
`;
|
|
624
|
+
}
|
|
625
|
+
const ct = 15e3;
|
|
640
626
|
class I extends Error {
|
|
641
627
|
constructor(e, t) {
|
|
642
628
|
super(`api-forms request failed with status ${e}`), this.status = e, this.body = t;
|
|
643
629
|
}
|
|
644
630
|
}
|
|
645
631
|
const de = Object.freeze({ enabled: !1, humanCheck: null });
|
|
646
|
-
function
|
|
647
|
-
baseUrl:
|
|
648
|
-
fetchFn: e = (...
|
|
632
|
+
function dt({
|
|
633
|
+
baseUrl: r,
|
|
634
|
+
fetchFn: e = (...n) => fetch(...n),
|
|
649
635
|
xhrFactory: t = () => new XMLHttpRequest(),
|
|
650
|
-
getAuthHeaders:
|
|
636
|
+
getAuthHeaders: s
|
|
651
637
|
}) {
|
|
652
|
-
const
|
|
653
|
-
let
|
|
654
|
-
async function a(l, { method: d = "GET", body:
|
|
655
|
-
const
|
|
656
|
-
u && Object.assign(
|
|
638
|
+
const n = String(r || "").replace(/\/+$/, "");
|
|
639
|
+
let i = de, o = null;
|
|
640
|
+
async function a(l, { method: d = "GET", body: h, auth: u = !1, timeoutMs: p } = {}) {
|
|
641
|
+
const y = { Accept: "application/json" };
|
|
642
|
+
u && Object.assign(y, o ? { Authorization: `Bearer ${o}` } : await s()), h !== void 0 && (y["Content-Type"] = "application/json");
|
|
657
643
|
let w;
|
|
658
644
|
try {
|
|
659
|
-
w = await e(`${
|
|
645
|
+
w = await e(`${n}${l}`, {
|
|
660
646
|
method: d,
|
|
661
|
-
headers:
|
|
662
|
-
...
|
|
663
|
-
...
|
|
647
|
+
headers: y,
|
|
648
|
+
...p ? { signal: AbortSignal.timeout(p) } : {},
|
|
649
|
+
...h !== void 0 ? { body: JSON.stringify(h) } : {}
|
|
664
650
|
});
|
|
665
|
-
} catch (
|
|
666
|
-
throw Object.assign(new I(0, null), { cause:
|
|
651
|
+
} catch (N) {
|
|
652
|
+
throw Object.assign(new I(0, null), { cause: N });
|
|
667
653
|
}
|
|
668
|
-
let
|
|
654
|
+
let $ = null;
|
|
669
655
|
try {
|
|
670
|
-
|
|
656
|
+
$ = await w.json();
|
|
671
657
|
} catch {
|
|
672
658
|
}
|
|
673
659
|
if (!w.ok)
|
|
674
|
-
throw new I(w.status,
|
|
675
|
-
return
|
|
660
|
+
throw new I(w.status, $);
|
|
661
|
+
return $;
|
|
676
662
|
}
|
|
677
663
|
return {
|
|
678
664
|
/** @returns {Promise<Array>} published form documents */
|
|
679
665
|
listForms: async () => {
|
|
680
|
-
const l = await a("/v1/forms", { timeoutMs:
|
|
681
|
-
return
|
|
666
|
+
const l = await a("/v1/forms", { timeoutMs: ct });
|
|
667
|
+
return i = l?.anonymous?.enabled === !0 ? { enabled: !0, humanCheck: l.anonymous.humanCheck || null } : de, (l?.forms || []).filter((d) => d?.formId && d?.start && Array.isArray(d?.nodes));
|
|
682
668
|
},
|
|
683
669
|
/**
|
|
684
670
|
* What the server advertised on the last listForms.
|
|
685
671
|
* @returns {{enabled: boolean, humanCheck: {provider, siteKey}|null}}
|
|
686
672
|
*/
|
|
687
|
-
anonymousCapability: () =>
|
|
673
|
+
anonymousCapability: () => i,
|
|
688
674
|
/**
|
|
689
675
|
* Mint a submission-scoped anonymous session; subsequent auth-bearing
|
|
690
676
|
* calls present it until endAnonSession(). Unauthenticated by design.
|
|
691
677
|
* @returns {Promise<{expiresIn: number}>}
|
|
692
678
|
*/
|
|
693
|
-
createAnonSession: async ({ formId: l, requestId: d, humanToken:
|
|
679
|
+
createAnonSession: async ({ formId: l, requestId: d, humanToken: h }) => {
|
|
694
680
|
const u = await a("/v1/anon/sessions", {
|
|
695
681
|
method: "POST",
|
|
696
|
-
body: { formId: l, requestId: d, ...
|
|
682
|
+
body: { formId: l, requestId: d, ...h ? { humanToken: h } : {} }
|
|
697
683
|
});
|
|
698
684
|
if (o = u?.token || null, !o)
|
|
699
685
|
throw new I(502, { message: "The anonymous session had no token" });
|
|
@@ -713,87 +699,179 @@ function at({
|
|
|
713
699
|
* progress is observable. Resolves on 2xx; rejects with
|
|
714
700
|
* ApiError(status) otherwise. Returns { promise, abort }.
|
|
715
701
|
*/
|
|
716
|
-
uploadFile: ({ url: l, file: d, contentType:
|
|
702
|
+
uploadFile: ({ url: l, file: d, contentType: h, onProgress: u = () => {
|
|
717
703
|
} }) => {
|
|
718
|
-
const
|
|
719
|
-
return { promise: new Promise((w,
|
|
720
|
-
|
|
721
|
-
u({ loaded:
|
|
722
|
-
}),
|
|
723
|
-
|
|
724
|
-
},
|
|
725
|
-
}), abort: () =>
|
|
704
|
+
const p = t();
|
|
705
|
+
return { promise: new Promise((w, $) => {
|
|
706
|
+
p.open("PUT", l), p.setRequestHeader("Content-Type", h || d.type), p.upload && (p.upload.onprogress = (N) => {
|
|
707
|
+
u({ loaded: N.loaded, total: N.total || d.size });
|
|
708
|
+
}), p.onload = () => {
|
|
709
|
+
p.status >= 200 && p.status < 300 ? w({ status: p.status }) : $(new I(p.status, null));
|
|
710
|
+
}, p.onerror = () => $(new I(0, null)), p.onabort = () => $(new I(0, { aborted: !0 })), p.send(d);
|
|
711
|
+
}), abort: () => p.abort() };
|
|
726
712
|
},
|
|
727
713
|
/** @returns {Promise<{requestId,reference,confirmation,routing}>} */
|
|
728
714
|
putRequest: async (l, d) => await a(`/v1/requests/${l}`, { method: "PUT", body: d, auth: !0 })
|
|
729
715
|
};
|
|
730
716
|
}
|
|
731
717
|
const ue = 60 * 1e3;
|
|
732
|
-
async function
|
|
733
|
-
const
|
|
734
|
-
const { token: o, expiry: a } =
|
|
735
|
-
return o && Number(a) -
|
|
718
|
+
async function ut({ read: r, refresh: e, now: t = Date.now }) {
|
|
719
|
+
const s = (i) => {
|
|
720
|
+
const { token: o, expiry: a } = r() || {};
|
|
721
|
+
return o && Number(a) - i > t() ? o : null;
|
|
736
722
|
};
|
|
737
|
-
let
|
|
738
|
-
if (!
|
|
723
|
+
let n = s(ue);
|
|
724
|
+
if (!n) {
|
|
739
725
|
try {
|
|
740
726
|
await e();
|
|
741
727
|
} catch {
|
|
742
728
|
}
|
|
743
|
-
|
|
729
|
+
n = s(ue) || s(0);
|
|
744
730
|
}
|
|
745
|
-
if (!
|
|
731
|
+
if (!n)
|
|
746
732
|
throw Object.assign(new Error("Please sign in again to continue."), { status: 401, body: null });
|
|
747
|
-
return { Authorization: `Bearer ${
|
|
733
|
+
return { Authorization: `Bearer ${n}` };
|
|
748
734
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
735
|
+
const he = (r) => String(r || "").toLowerCase().trim();
|
|
736
|
+
function ht(r) {
|
|
737
|
+
const e = /* @__PURE__ */ new Set();
|
|
752
738
|
return {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
739
|
+
signUpIfNeeded: async (t, ...s) => {
|
|
740
|
+
const n = await r(t, ...s);
|
|
741
|
+
return n?.exists === !1 && !n.error && e.add(he(t)), n;
|
|
742
|
+
},
|
|
743
|
+
isNewAccount: (t) => e.has(he(t))
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
const pt = "wral_user_facts", ft = "1", gt = 100;
|
|
747
|
+
function mt(r, e) {
|
|
748
|
+
let t = "";
|
|
749
|
+
for (const s of r) {
|
|
750
|
+
if (t.length + s.length > e) break;
|
|
751
|
+
t += s;
|
|
752
|
+
}
|
|
753
|
+
return t;
|
|
754
|
+
}
|
|
755
|
+
const yt = [
|
|
756
|
+
{
|
|
757
|
+
autocomplete: "name",
|
|
758
|
+
factName: "preferred_name",
|
|
759
|
+
label: "Name",
|
|
760
|
+
shape: (r) => {
|
|
761
|
+
const e = String(r ?? "").replace(/\s+/g, " ").trim();
|
|
762
|
+
return e ? mt(e, gt).trim() : null;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
autocomplete: "postal-code",
|
|
767
|
+
factName: "zipcode",
|
|
768
|
+
label: "Zip code",
|
|
769
|
+
shape: (r) => String(r ?? "").trim().match(/^(\d{5})(-\d{4})?$/)?.[1] ?? null
|
|
770
|
+
}
|
|
771
|
+
];
|
|
772
|
+
function bt(r = [], e = {}) {
|
|
773
|
+
const t = [];
|
|
774
|
+
for (const s of yt) {
|
|
775
|
+
const n = r.find((i) => i?.kind === "text" && i.autocomplete === s.autocomplete && s.shape(e[i.key]) !== null);
|
|
776
|
+
n && t.push({ factName: s.factName, label: s.label, value: s.shape(e[n.key]) });
|
|
777
|
+
}
|
|
778
|
+
return t;
|
|
779
|
+
}
|
|
780
|
+
async function wt(r, {
|
|
781
|
+
baseUrl: e,
|
|
782
|
+
getAuthHeaders: t,
|
|
783
|
+
fetchFn: s = (...i) => fetch(...i),
|
|
784
|
+
onSaved: n = () => {
|
|
785
|
+
}
|
|
786
|
+
}) {
|
|
787
|
+
const i = String(e).replace(/\/+$/, "");
|
|
788
|
+
let o = !1;
|
|
789
|
+
try {
|
|
790
|
+
for (const { factName: a, value: l } of r) {
|
|
791
|
+
const d = { "Content-Type": "application/json", ...await t() };
|
|
792
|
+
let h;
|
|
793
|
+
try {
|
|
794
|
+
h = await s(
|
|
795
|
+
`${i}/user/${encodeURIComponent(a)}/${ft}`,
|
|
796
|
+
{ method: "PUT", headers: d, body: JSON.stringify({ value: l }) }
|
|
797
|
+
);
|
|
798
|
+
} catch (u) {
|
|
799
|
+
throw Object.assign(new Error("user-facts request failed"), { status: 0, cause: u });
|
|
800
|
+
}
|
|
801
|
+
if (!h.ok)
|
|
802
|
+
throw Object.assign(
|
|
803
|
+
new Error(`user-facts request failed with status ${h.status}`),
|
|
804
|
+
{ status: h.status }
|
|
805
|
+
);
|
|
806
|
+
o = !0;
|
|
807
|
+
}
|
|
808
|
+
} finally {
|
|
809
|
+
o && n();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
function xt({ factsBaseUrl: r } = {}) {
|
|
813
|
+
const { config: e, storage: t } = Re(), s = ht(ze);
|
|
814
|
+
let n = null;
|
|
815
|
+
const i = () => ut({
|
|
816
|
+
read: () => ({
|
|
817
|
+
token: t.get(S.idToken),
|
|
818
|
+
expiry: t.get(S.idTokenExpiry)
|
|
762
819
|
}),
|
|
820
|
+
refresh: () => te()
|
|
821
|
+
});
|
|
822
|
+
return {
|
|
823
|
+
isAuthenticated: () => Ue(),
|
|
824
|
+
signedInEmail: () => t.get(S.userEmail) || null,
|
|
825
|
+
getAuthHeaders: i,
|
|
826
|
+
/* Save mapped answers (../lib/user-facts.mjs) to the viewer's My WRAL user facts. */
|
|
827
|
+
...r ? {
|
|
828
|
+
saveUserFacts: (o) => wt(o, {
|
|
829
|
+
baseUrl: r,
|
|
830
|
+
getAuthHeaders: i,
|
|
831
|
+
onSaved: () => {
|
|
832
|
+
try {
|
|
833
|
+
localStorage.removeItem(pt);
|
|
834
|
+
} catch {
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
})
|
|
838
|
+
} : {},
|
|
763
839
|
/**
|
|
764
840
|
* Email step. Keeps the challenge user in memory for verifyCode.
|
|
765
|
-
*
|
|
841
|
+
* `newAccount` is true when this page load created the account.
|
|
842
|
+
* @returns {{challengeRequired?: boolean, authenticated?: boolean, newAccount: boolean}}
|
|
766
843
|
*/
|
|
767
|
-
sendCode: async (
|
|
768
|
-
const
|
|
769
|
-
s,
|
|
770
|
-
r,
|
|
844
|
+
sendCode: async (o) => {
|
|
845
|
+
const a = await Ne(
|
|
771
846
|
e,
|
|
772
|
-
|
|
847
|
+
o,
|
|
848
|
+
t,
|
|
773
849
|
De,
|
|
850
|
+
s.signUpIfNeeded,
|
|
774
851
|
Pe,
|
|
775
|
-
|
|
852
|
+
J,
|
|
776
853
|
X,
|
|
777
854
|
ee
|
|
778
855
|
);
|
|
779
|
-
return
|
|
780
|
-
challengeRequired: !!
|
|
781
|
-
authenticated: !!
|
|
856
|
+
return n = a.cognitoUser || null, {
|
|
857
|
+
challengeRequired: !!a.challengeRequired,
|
|
858
|
+
authenticated: !!a.authenticated,
|
|
859
|
+
newAccount: s.isNewAccount(o)
|
|
782
860
|
};
|
|
783
861
|
},
|
|
784
862
|
/**
|
|
785
863
|
* Code step; refreshes immediately after verify so the session
|
|
786
864
|
* starts with a full lifetime (house pattern).
|
|
787
865
|
*/
|
|
788
|
-
verifyCode: async (
|
|
789
|
-
if (!
|
|
866
|
+
verifyCode: async (o) => {
|
|
867
|
+
if (!n)
|
|
790
868
|
throw new Error("Please enter your email again to get a new code.");
|
|
791
869
|
try {
|
|
792
|
-
await
|
|
870
|
+
await Me(
|
|
871
|
+
n,
|
|
872
|
+
o,
|
|
793
873
|
t,
|
|
794
|
-
|
|
795
|
-
e,
|
|
796
|
-
Z,
|
|
874
|
+
J,
|
|
797
875
|
X,
|
|
798
876
|
ee
|
|
799
877
|
);
|
|
@@ -804,133 +882,133 @@ function ct() {
|
|
|
804
882
|
},
|
|
805
883
|
/** Local sign-out only ("use a different email"). */
|
|
806
884
|
signOut: () => {
|
|
807
|
-
|
|
885
|
+
n = null, Oe().clear();
|
|
808
886
|
},
|
|
809
887
|
/**
|
|
810
888
|
* Detect a login completed in ANOTHER tab (the storage event
|
|
811
889
|
* never fires in the tab that wrote). Returns an unsubscribe.
|
|
812
890
|
*/
|
|
813
|
-
onCrossTabLogin: (
|
|
814
|
-
const
|
|
815
|
-
(
|
|
891
|
+
onCrossTabLogin: (o) => {
|
|
892
|
+
const a = (l) => {
|
|
893
|
+
(l.key === S.accessToken || l.key === S.idToken) && o();
|
|
816
894
|
};
|
|
817
|
-
return window.addEventListener("storage",
|
|
895
|
+
return window.addEventListener("storage", a), () => window.removeEventListener("storage", a);
|
|
818
896
|
}
|
|
819
897
|
};
|
|
820
898
|
}
|
|
821
|
-
function
|
|
822
|
-
const
|
|
823
|
-
return { ...
|
|
899
|
+
function vt({ baseUrl: r, factsBaseUrl: e }) {
|
|
900
|
+
const t = xt({ factsBaseUrl: e });
|
|
901
|
+
return { ...dt({ baseUrl: r, getAuthHeaders: t.getAuthHeaders }), ...t };
|
|
824
902
|
}
|
|
825
|
-
function x(
|
|
826
|
-
return (
|
|
903
|
+
function x(r, e) {
|
|
904
|
+
return (r?.nodes || []).find((t) => t.id === e);
|
|
827
905
|
}
|
|
828
|
-
function
|
|
829
|
-
return
|
|
906
|
+
function L(r) {
|
|
907
|
+
return r?.form ? { formId: r.form, path: [...r.path || []] } : null;
|
|
830
908
|
}
|
|
831
|
-
function
|
|
909
|
+
function H(r, e = []) {
|
|
832
910
|
const t = [];
|
|
833
|
-
let
|
|
834
|
-
for (const
|
|
835
|
-
const o = x(
|
|
911
|
+
let s = r?.start;
|
|
912
|
+
for (const i of e) {
|
|
913
|
+
const o = x(r, s);
|
|
836
914
|
if (!o)
|
|
837
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
915
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown node: ${s}` } };
|
|
838
916
|
if (o.type === "terminal" || o.type === "redirect")
|
|
839
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
840
|
-
if (
|
|
841
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
917
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `steps continue past ${o.type}` } };
|
|
918
|
+
if (i.nodeId !== s || i.kind !== o.type)
|
|
919
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `step does not match node ${s}` } };
|
|
842
920
|
if (o.type === "choice") {
|
|
843
|
-
const a = (o.options || []).find((l) => l.id ===
|
|
921
|
+
const a = (o.options || []).find((l) => l.id === i.optionId);
|
|
844
922
|
if (!a)
|
|
845
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
846
|
-
if (
|
|
847
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
848
|
-
t.push(...a.flags || []),
|
|
923
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown option: ${i.optionId}` } };
|
|
924
|
+
if (L(a))
|
|
925
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `steps continue past a hand-off: ${i.optionId}` } };
|
|
926
|
+
t.push(...a.flags || []), s = a.next;
|
|
849
927
|
continue;
|
|
850
928
|
}
|
|
851
|
-
|
|
929
|
+
s = o.next;
|
|
852
930
|
}
|
|
853
|
-
const
|
|
854
|
-
return
|
|
931
|
+
const n = x(r, s);
|
|
932
|
+
return n ? { nodeId: s, node: n, flags: Ee(t), error: null } : { nodeId: null, node: null, flags: t, error: { step: null, reason: `unknown node: ${s}` } };
|
|
855
933
|
}
|
|
856
|
-
function
|
|
934
|
+
function Ae(r, e = []) {
|
|
857
935
|
const t = [];
|
|
858
|
-
for (const
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
861
|
-
t.push(...
|
|
936
|
+
for (const s of e) {
|
|
937
|
+
if (s.kind !== "collect") continue;
|
|
938
|
+
const n = x(r, s.nodeId);
|
|
939
|
+
t.push(...n?.fields || []);
|
|
862
940
|
}
|
|
863
941
|
return t;
|
|
864
942
|
}
|
|
865
|
-
function
|
|
943
|
+
function Fe(r = []) {
|
|
866
944
|
const e = {};
|
|
867
|
-
for (const t of
|
|
945
|
+
for (const t of r)
|
|
868
946
|
t.kind === "collect" && Object.assign(e, t.values || {});
|
|
869
947
|
return e;
|
|
870
948
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
949
|
+
function _t(r = []) {
|
|
950
|
+
return r.filter((e) => e.kind === "choice").map((e) => `${e.nodeId}:${e.optionId}`);
|
|
873
951
|
}
|
|
874
|
-
function
|
|
952
|
+
function Ie(r, e = []) {
|
|
875
953
|
const t = [];
|
|
876
|
-
for (const
|
|
877
|
-
if (
|
|
878
|
-
const
|
|
879
|
-
t.push(...
|
|
954
|
+
for (const s of e) {
|
|
955
|
+
if (s.kind !== "choice") continue;
|
|
956
|
+
const i = (x(r, s.nodeId)?.options || []).find((o) => o.id === s.optionId);
|
|
957
|
+
t.push(...i?.flags || []);
|
|
880
958
|
}
|
|
881
|
-
return
|
|
959
|
+
return Ee(t);
|
|
882
960
|
}
|
|
883
|
-
function
|
|
884
|
-
return
|
|
961
|
+
function $t(r = []) {
|
|
962
|
+
return r.includes("urgent") ? "urgent" : r.includes("moderate") ? "moderate" : null;
|
|
885
963
|
}
|
|
886
|
-
function
|
|
887
|
-
return [...new Set(
|
|
964
|
+
function Ee(r) {
|
|
965
|
+
return [...new Set(r)];
|
|
888
966
|
}
|
|
889
|
-
function
|
|
967
|
+
function kt(r, e = []) {
|
|
890
968
|
const t = [];
|
|
891
|
-
for (const
|
|
892
|
-
const [
|
|
969
|
+
for (const n of e) {
|
|
970
|
+
const [i, o] = String(n).split(":"), a = x(r, i), l = a?.type === "choice" ? (a.options || []).find((d) => d.id === o) : null;
|
|
893
971
|
if (!l)
|
|
894
|
-
return { steps: [], error: `unknown preset step: ${
|
|
895
|
-
t.push({ nodeId:
|
|
972
|
+
return { steps: [], error: `unknown preset step: ${n}` };
|
|
973
|
+
t.push({ nodeId: i, kind: "choice", optionId: o, label: l.label, preset: !0 });
|
|
896
974
|
}
|
|
897
|
-
const { error:
|
|
898
|
-
return
|
|
975
|
+
const { error: s } = H(r, t);
|
|
976
|
+
return s ? { steps: [], error: s.reason } : { steps: t, error: null };
|
|
899
977
|
}
|
|
900
|
-
function
|
|
901
|
-
const t =
|
|
978
|
+
function At(r, e) {
|
|
979
|
+
const t = L(e);
|
|
902
980
|
if (!t) return { form: null, steps: [], error: "not a hand-off" };
|
|
903
|
-
const
|
|
904
|
-
if (!
|
|
905
|
-
const { steps:
|
|
906
|
-
return
|
|
981
|
+
const s = (r || []).find((o) => o.formId === t.formId);
|
|
982
|
+
if (!s) return { form: null, steps: [], error: `unknown form: ${t.formId}` };
|
|
983
|
+
const { steps: n, error: i } = kt(s, t.path);
|
|
984
|
+
return i ? { form: null, steps: [], error: i } : { form: s, steps: n, error: null };
|
|
907
985
|
}
|
|
908
|
-
function
|
|
986
|
+
function Ft(r, e, t, s) {
|
|
909
987
|
return {
|
|
910
|
-
form:
|
|
988
|
+
form: r,
|
|
911
989
|
steps: e,
|
|
912
|
-
option: { nodeId: t.id, optionId:
|
|
990
|
+
option: { nodeId: t.id, optionId: s.id, label: s.label }
|
|
913
991
|
};
|
|
914
992
|
}
|
|
915
|
-
function
|
|
916
|
-
return
|
|
993
|
+
function It(r = []) {
|
|
994
|
+
return r.every((e) => e.preset === !0);
|
|
917
995
|
}
|
|
918
|
-
function
|
|
919
|
-
if (!Array.isArray(
|
|
920
|
-
const
|
|
921
|
-
for (let
|
|
922
|
-
const
|
|
996
|
+
function Et(r, e, t) {
|
|
997
|
+
if (!Array.isArray(r) || !r.length) return [];
|
|
998
|
+
const s = [];
|
|
999
|
+
for (let n = 0; n < r.length; n++) {
|
|
1000
|
+
const i = r[n], o = (e || []).find((u) => u.formId === i?.formId);
|
|
923
1001
|
if (!o) return [];
|
|
924
|
-
const { node: a, error: l } =
|
|
925
|
-
if (l || a?.id !==
|
|
926
|
-
const d = (a.options || []).find((u) => u.id ===
|
|
927
|
-
if (
|
|
928
|
-
|
|
1002
|
+
const { node: a, error: l } = H(o, i.steps || []);
|
|
1003
|
+
if (l || a?.id !== i.option?.nodeId) return [];
|
|
1004
|
+
const d = (a.options || []).find((u) => u.id === i.option.optionId), h = n + 1 < r.length ? r[n + 1].formId : t;
|
|
1005
|
+
if (L(d)?.formId !== h) return [];
|
|
1006
|
+
s.push({ form: o, steps: i.steps || [], option: i.option });
|
|
929
1007
|
}
|
|
930
|
-
return
|
|
1008
|
+
return s;
|
|
931
1009
|
}
|
|
932
|
-
function
|
|
933
|
-
const t = String(
|
|
1010
|
+
function St({ attr: r = null, search: e = "" } = {}) {
|
|
1011
|
+
const t = String(r ?? "").trim();
|
|
934
1012
|
if (t) return t;
|
|
935
1013
|
try {
|
|
936
1014
|
return new URLSearchParams(e || "").get("flow")?.trim() || null;
|
|
@@ -938,41 +1016,41 @@ function xt({ attr: s = null, search: e = "" } = {}) {
|
|
|
938
1016
|
return null;
|
|
939
1017
|
}
|
|
940
1018
|
}
|
|
941
|
-
function
|
|
942
|
-
return e && (
|
|
1019
|
+
function Ct(r, e) {
|
|
1020
|
+
return e && (r || []).find((t) => t.formId === e) || null;
|
|
943
1021
|
}
|
|
944
|
-
function
|
|
945
|
-
return !e ||
|
|
1022
|
+
function Tt(r, e) {
|
|
1023
|
+
return !e || r?.form?.formId === e ? !0 : (r?.origins || []).some((t) => t.form?.formId === e);
|
|
946
1024
|
}
|
|
947
|
-
const
|
|
1025
|
+
const Rt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/, pe = {
|
|
948
1026
|
text: 500,
|
|
949
1027
|
textarea: 5e3,
|
|
950
1028
|
url: 2048
|
|
951
|
-
},
|
|
952
|
-
function
|
|
953
|
-
return
|
|
1029
|
+
}, Ot = "Please confirm the rights statement so we can use what you send.";
|
|
1030
|
+
function Se(r, { mediaCount: e = 0 } = {}) {
|
|
1031
|
+
return r.kind === "consent" && r.requiredIf === "media" ? e > 0 : !!r.required;
|
|
954
1032
|
}
|
|
955
|
-
function
|
|
1033
|
+
function Mt(r, e) {
|
|
956
1034
|
try {
|
|
957
|
-
return new RegExp(
|
|
1035
|
+
return new RegExp(r, "u").test(e);
|
|
958
1036
|
} catch {
|
|
959
1037
|
return !0;
|
|
960
1038
|
}
|
|
961
1039
|
}
|
|
962
|
-
function
|
|
963
|
-
return
|
|
1040
|
+
function Nt(r) {
|
|
1041
|
+
return r.key === "zip" ? "Please enter a five-digit zip code." : `Please check the format of ${r.label.toLowerCase()}.`;
|
|
964
1042
|
}
|
|
965
|
-
function
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
968
|
-
return e === !0 || !
|
|
969
|
-
if (e == null || e === "" ||
|
|
970
|
-
return
|
|
971
|
-
switch (
|
|
1043
|
+
function Dt(r, e, { mediaCount: t = 0 } = {}) {
|
|
1044
|
+
const s = Se(r, { mediaCount: t });
|
|
1045
|
+
if (r.kind === "consent")
|
|
1046
|
+
return e === !0 || !s ? null : Ot;
|
|
1047
|
+
if (e == null || e === "" || r.kind === "location" && Pt(e))
|
|
1048
|
+
return s ? `Please fill in: ${r.label.toLowerCase()}.` : null;
|
|
1049
|
+
switch (r.kind) {
|
|
972
1050
|
case "text":
|
|
973
1051
|
case "textarea": {
|
|
974
|
-
const
|
|
975
|
-
return typeof e != "string" ? `Please enter text for ${
|
|
1052
|
+
const i = r.maxLength || pe[r.kind];
|
|
1053
|
+
return typeof e != "string" ? `Please enter text for ${r.label.toLowerCase()}.` : e.length > i ? `Please keep ${r.label.toLowerCase()} under ${i} characters.` : r.kind === "text" && r.pattern && !Mt(r.pattern, e) ? Nt(r) : null;
|
|
976
1054
|
}
|
|
977
1055
|
case "url": {
|
|
978
1056
|
if (typeof e != "string" || e.length > pe.url)
|
|
@@ -984,108 +1062,108 @@ function It(s, e, { mediaCount: t = 0 } = {}) {
|
|
|
984
1062
|
}
|
|
985
1063
|
}
|
|
986
1064
|
case "datetime":
|
|
987
|
-
return
|
|
1065
|
+
return Rt.test(String(e)) ? null : "Please pick a date and time.";
|
|
988
1066
|
case "select":
|
|
989
|
-
return (
|
|
1067
|
+
return (r.options || []).map((o) => o.id).includes(e) ? null : `Please choose one of the options for ${r.label.toLowerCase()}.`;
|
|
990
1068
|
case "location":
|
|
991
|
-
return
|
|
1069
|
+
return Ut(r, e);
|
|
992
1070
|
case "media":
|
|
993
1071
|
return null;
|
|
994
1072
|
default:
|
|
995
|
-
return `Unsupported field: ${
|
|
1073
|
+
return `Unsupported field: ${r.kind}`;
|
|
996
1074
|
}
|
|
997
1075
|
}
|
|
998
|
-
function
|
|
999
|
-
return
|
|
1076
|
+
function Pt(r) {
|
|
1077
|
+
return r == null ? !0 : typeof r != "object" ? !1 : !r.county && !r.where && !(Array.isArray(r.gps) && r.gps.length);
|
|
1000
1078
|
}
|
|
1001
|
-
function
|
|
1002
|
-
return typeof e != "object" || Array.isArray(e) ? "Please tell us where this was." : e.county !== void 0 && (typeof e.county != "string" || e.county.length > 100) ? "Please choose a county." : e.where !== void 0 && (typeof e.where != "string" || e.where.length > 500) ? "Please shorten the location description." : e.gps !== void 0 && !(Array.isArray(e.gps) && e.gps.length === 2 && e.gps.every((
|
|
1079
|
+
function Ut(r, e) {
|
|
1080
|
+
return typeof e != "object" || Array.isArray(e) ? "Please tell us where this was." : e.county !== void 0 && (typeof e.county != "string" || e.county.length > 100) ? "Please choose a county." : e.where !== void 0 && (typeof e.where != "string" || e.where.length > 500) ? "Please shorten the location description." : e.gps !== void 0 && !(Array.isArray(e.gps) && e.gps.length === 2 && e.gps.every((s) => typeof s == "number" && Number.isFinite(s))) ? "Location coordinates look wrong; try re-sharing your location." : r.required && !e.county && !e.where ? `Please fill in: ${r.label.toLowerCase()}.` : null;
|
|
1003
1081
|
}
|
|
1004
|
-
function
|
|
1005
|
-
const
|
|
1006
|
-
for (const
|
|
1007
|
-
if (
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1082
|
+
function fe(r, e = {}, { mediaCount: t = 0 } = {}) {
|
|
1083
|
+
const s = {};
|
|
1084
|
+
for (const n of r) {
|
|
1085
|
+
if (n.kind === "media") continue;
|
|
1086
|
+
const i = Dt(n, e[n.key], { mediaCount: t });
|
|
1087
|
+
i && (s[n.key] = i);
|
|
1010
1088
|
}
|
|
1011
|
-
return { ok: Object.keys(
|
|
1089
|
+
return { ok: Object.keys(s).length === 0, errors: s };
|
|
1012
1090
|
}
|
|
1013
|
-
function Y(
|
|
1091
|
+
function Y(r = [], e = {}, { required: t = !1 } = {}) {
|
|
1014
1092
|
const {
|
|
1015
|
-
maxFiles:
|
|
1016
|
-
maxFileBytes:
|
|
1017
|
-
allowedTypes:
|
|
1093
|
+
maxFiles: s = 5,
|
|
1094
|
+
maxFileBytes: n = 512 * 1024 * 1024,
|
|
1095
|
+
allowedTypes: i = []
|
|
1018
1096
|
} = e, o = [];
|
|
1019
|
-
return t &&
|
|
1097
|
+
return t && r.length === 0 && o.push({ reason: "required", message: "Please attach at least one photo or video." }), r.length > s && o.push({
|
|
1020
1098
|
reason: "count",
|
|
1021
|
-
message: `This form accepts at most ${
|
|
1022
|
-
}),
|
|
1023
|
-
|
|
1099
|
+
message: `This form accepts at most ${s} ${s === 1 ? "file" : "files"}.`
|
|
1100
|
+
}), r.forEach((a, l) => {
|
|
1101
|
+
i.length && !i.includes(a.type) && o.push({
|
|
1024
1102
|
index: l,
|
|
1025
1103
|
reason: "type",
|
|
1026
1104
|
message: `${a.name || "A file"} is a type this form does not accept.`
|
|
1027
|
-
}), a.size >
|
|
1105
|
+
}), a.size > n && o.push({
|
|
1028
1106
|
index: l,
|
|
1029
1107
|
reason: "size",
|
|
1030
1108
|
message: `${a.name || "A file"} is larger than this form allows.`
|
|
1031
1109
|
});
|
|
1032
1110
|
}), { ok: o.length === 0, errors: o };
|
|
1033
1111
|
}
|
|
1034
|
-
function
|
|
1112
|
+
function ge({ formId: r, requestId: e, files: t }) {
|
|
1035
1113
|
return {
|
|
1036
|
-
formId:
|
|
1114
|
+
formId: r,
|
|
1037
1115
|
requestId: e,
|
|
1038
|
-
files: t.map((
|
|
1116
|
+
files: t.map((s) => ({ contentType: s.type, size: s.size }))
|
|
1039
1117
|
};
|
|
1040
1118
|
}
|
|
1041
|
-
function
|
|
1042
|
-
const
|
|
1043
|
-
for (const o of
|
|
1119
|
+
function zt({ form: r, steps: e, media: t = [] }) {
|
|
1120
|
+
const s = Ae(r, e), n = Fe(e), i = {};
|
|
1121
|
+
for (const o of s) {
|
|
1044
1122
|
if (o.kind === "media") continue;
|
|
1045
|
-
const a =
|
|
1123
|
+
const a = n[o.key];
|
|
1046
1124
|
if (!(a == null || a === "") && !(o.kind === "consent" && (a !== !0 || o.requiredIf === "media" && !t.length))) {
|
|
1047
1125
|
if (o.kind === "location") {
|
|
1048
1126
|
const l = {};
|
|
1049
|
-
a.county && (l.county = a.county), a.where && (l.where = a.where), Array.isArray(a.gps) && a.gps.length === 2 && (l.gps = a.gps), Object.keys(l).length && (
|
|
1127
|
+
a.county && (l.county = a.county), a.where && (l.where = a.where), Array.isArray(a.gps) && a.gps.length === 2 && (l.gps = a.gps), Object.keys(l).length && (i[o.key] = l);
|
|
1050
1128
|
continue;
|
|
1051
1129
|
}
|
|
1052
|
-
|
|
1130
|
+
i[o.key] = a;
|
|
1053
1131
|
}
|
|
1054
1132
|
}
|
|
1055
1133
|
return {
|
|
1056
|
-
formId:
|
|
1057
|
-
flowVersion:
|
|
1058
|
-
path:
|
|
1059
|
-
answers:
|
|
1134
|
+
formId: r.formId,
|
|
1135
|
+
flowVersion: r.flowVersion,
|
|
1136
|
+
path: _t(e),
|
|
1137
|
+
answers: i,
|
|
1060
1138
|
media: t.map(({ assetId: o, type: a }) => ({ assetId: o, type: a }))
|
|
1061
1139
|
};
|
|
1062
1140
|
}
|
|
1063
|
-
function me(
|
|
1064
|
-
if (
|
|
1141
|
+
function me(r, e) {
|
|
1142
|
+
if (r === 429)
|
|
1065
1143
|
return {
|
|
1066
1144
|
kind: "throttled",
|
|
1067
1145
|
message: e?.message || "You have reached the submission limit; please try again later.",
|
|
1068
1146
|
limit: e?.limit,
|
|
1069
1147
|
retryAfter: e?.retryAfter
|
|
1070
1148
|
};
|
|
1071
|
-
if (
|
|
1149
|
+
if (r === 401)
|
|
1072
1150
|
return { kind: "auth", message: "Please sign in again to continue." };
|
|
1073
|
-
if (
|
|
1151
|
+
if (r === 403)
|
|
1074
1152
|
return { kind: "forbidden", message: e?.message || "This submission belongs to another account." };
|
|
1075
|
-
if (
|
|
1153
|
+
if (r === 404)
|
|
1076
1154
|
return { kind: "unknown-form", message: "This form is no longer available." };
|
|
1077
|
-
if (
|
|
1155
|
+
if (r === 409)
|
|
1078
1156
|
return {
|
|
1079
1157
|
kind: "stale",
|
|
1080
1158
|
message: e?.message || "The form changed while you were filling it out; please review and resubmit."
|
|
1081
1159
|
};
|
|
1082
|
-
if (
|
|
1160
|
+
if (r === 400 && e?.code === "media-not-verified")
|
|
1083
1161
|
return {
|
|
1084
1162
|
kind: "media",
|
|
1085
1163
|
message: e.message || "An attached file is missing or does not match this submission.",
|
|
1086
1164
|
assetId: e.assetId
|
|
1087
1165
|
};
|
|
1088
|
-
if (
|
|
1166
|
+
if (r === 400 && Array.isArray(e)) {
|
|
1089
1167
|
const t = e[0] || {};
|
|
1090
1168
|
return {
|
|
1091
1169
|
kind: "validation",
|
|
@@ -1093,153 +1171,123 @@ function me(s, e) {
|
|
|
1093
1171
|
fieldKey: String(t.instancePath || "").split("/").filter(Boolean)[0] || null
|
|
1094
1172
|
};
|
|
1095
1173
|
}
|
|
1096
|
-
return
|
|
1174
|
+
return r === 0 ? { kind: "network", message: "We could not reach WRAL; check your connection and try again." } : {
|
|
1097
1175
|
kind: "server",
|
|
1098
1176
|
message: "Something went wrong on our end; please try again."
|
|
1099
1177
|
};
|
|
1100
1178
|
}
|
|
1101
|
-
const
|
|
1102
|
-
function
|
|
1103
|
-
const t = String(
|
|
1179
|
+
const Bt = 34, Lt = 44;
|
|
1180
|
+
function ye(r, e) {
|
|
1181
|
+
const t = String(r);
|
|
1104
1182
|
return t.length > e ? `${t.slice(0, e)}…` : t;
|
|
1105
1183
|
}
|
|
1106
|
-
function
|
|
1107
|
-
const t = (
|
|
1184
|
+
function Ht(r, e) {
|
|
1185
|
+
const t = (r.options || []).find((s) => s.id === e);
|
|
1108
1186
|
return t ? t.label : e;
|
|
1109
1187
|
}
|
|
1110
|
-
function
|
|
1111
|
-
return !
|
|
1188
|
+
function qt(r) {
|
|
1189
|
+
return !r || typeof r != "object" ? "" : [r.county, r.where].filter(Boolean).join(", ");
|
|
1112
1190
|
}
|
|
1113
|
-
function
|
|
1114
|
-
const
|
|
1115
|
-
for (const
|
|
1116
|
-
if (
|
|
1117
|
-
if (
|
|
1118
|
-
t.length &&
|
|
1191
|
+
function Wt(r, e = {}, t = []) {
|
|
1192
|
+
const s = [];
|
|
1193
|
+
for (const n of r) {
|
|
1194
|
+
if (n.kind === "consent") continue;
|
|
1195
|
+
if (n.kind === "media") {
|
|
1196
|
+
t.length && s.push(`${t.length} ${t.length === 1 ? "file" : "files"}`);
|
|
1119
1197
|
continue;
|
|
1120
1198
|
}
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1199
|
+
const i = n.kind === "location" ? qt(e[n.key]) : n.kind === "select" ? Ht(n, e[n.key]) : e[n.key];
|
|
1200
|
+
i == null || i === "" || (n.kind === "textarea" ? s.push(`"${ye(i, Lt)}"`) : s.push(ye(i, Bt)));
|
|
1123
1201
|
}
|
|
1124
|
-
return
|
|
1202
|
+
return s.join(" · ") || "Details provided";
|
|
1125
1203
|
}
|
|
1126
|
-
function
|
|
1127
|
-
const
|
|
1128
|
-
for (const
|
|
1129
|
-
const o = x(
|
|
1130
|
-
|
|
1204
|
+
function Vt(r, e = [], t = null) {
|
|
1205
|
+
const s = [];
|
|
1206
|
+
for (const i of e) {
|
|
1207
|
+
const o = x(r, i.nodeId);
|
|
1208
|
+
i.kind === "choice" && o && s.push({ k: (o.prompt || "").replace(/\?$/, ""), v: i.label || i.optionId }), i.kind === "collect" && s.push({ k: "Details", v: i.summary || "Details provided" }), i.kind === "gate" && (i.anonymous ? s.push({ k: "Contact", v: "Anonymous — we will have no way to reach you" }) : (i.email || t) && s.push({ k: "Verified email", v: i.email || t }));
|
|
1131
1209
|
}
|
|
1132
|
-
const
|
|
1133
|
-
return
|
|
1210
|
+
const n = $t(Ie(r, e));
|
|
1211
|
+
return n && s.push({ k: "Priority", v: n === "urgent" ? "Urgent" : "Moderate", pill: n }), s;
|
|
1134
1212
|
}
|
|
1135
|
-
function
|
|
1136
|
-
const t =
|
|
1213
|
+
function jt(r, e = []) {
|
|
1214
|
+
const t = r?.confirmation || {};
|
|
1137
1215
|
return {
|
|
1138
1216
|
title: t.title || "Report received.",
|
|
1139
1217
|
body: t.body || "Your report is in the review queue.",
|
|
1140
1218
|
urgentNote: e.includes("urgent") ? t.urgentNote : void 0
|
|
1141
1219
|
};
|
|
1142
1220
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
return s?.startsWith("studio+email:") ? `Sent to the Studio review queue; the desk is emailed.${t}` : s?.startsWith("studio:") ? "Sent to the Studio review queue." : s?.startsWith("jsm:") ? `A ticket is opened for tech support with your details as fields, not prose.${t}` : s?.startsWith("email:") ? `Emailed to the owning desk with a link to your report.${t}` : "Routed to the right team.";
|
|
1146
|
-
}
|
|
1147
|
-
function Ut({ routing: s = {}, flags: e = [], reference: t = "", anonymous: r = !1 }) {
|
|
1148
|
-
const i = e.includes("urgent");
|
|
1149
|
-
return [
|
|
1150
|
-
{
|
|
1151
|
-
title: "Received",
|
|
1152
|
-
body: `Report ${t} and its media are written to the dedicated Report It intake store before anything downstream touches them.`
|
|
1153
|
-
},
|
|
1154
|
-
{
|
|
1155
|
-
title: "Routed",
|
|
1156
|
-
body: Ot(s.destination, s.state),
|
|
1157
|
-
pill: i ? "Urgent · pinned first" : void 0
|
|
1158
|
-
},
|
|
1159
|
-
{
|
|
1160
|
-
title: "Reviewed",
|
|
1161
|
-
body: r ? "An editor reviews it in the Report It queue: accept and promote it uncredited, reject, or re-route." : "An editor reviews it in the Report It queue: accept and promote with your credit, reject, or re-route."
|
|
1162
|
-
},
|
|
1163
|
-
{
|
|
1164
|
-
title: "Monitored",
|
|
1165
|
-
body: "The record joins the monitoring stream, which watches for related reports by category, place and symptom."
|
|
1166
|
-
},
|
|
1167
|
-
{
|
|
1168
|
-
title: "Escalation check",
|
|
1169
|
-
body: "Related reports crossing a threshold alert the owning team automatically; below it, we keep monitoring."
|
|
1170
|
-
}
|
|
1171
|
-
];
|
|
1172
|
-
}
|
|
1173
|
-
const J = "wral-report-it:draft:v1", Ie = 1;
|
|
1174
|
-
function Lt(s, e) {
|
|
1221
|
+
const Z = "wral-report-it:draft:v1", Ce = 1;
|
|
1222
|
+
function Yt(r, e) {
|
|
1175
1223
|
try {
|
|
1176
|
-
|
|
1224
|
+
r.setItem(Z, JSON.stringify({ ...e, v: Ce, savedAt: Date.now() }));
|
|
1177
1225
|
} catch {
|
|
1178
1226
|
}
|
|
1179
1227
|
}
|
|
1180
|
-
function
|
|
1228
|
+
function Gt(r) {
|
|
1181
1229
|
try {
|
|
1182
|
-
const e =
|
|
1230
|
+
const e = r.getItem(Z);
|
|
1183
1231
|
if (!e) return null;
|
|
1184
1232
|
const t = JSON.parse(e);
|
|
1185
|
-
return t?.v !==
|
|
1233
|
+
return t?.v !== Ce ? null : t;
|
|
1186
1234
|
} catch {
|
|
1187
1235
|
return null;
|
|
1188
1236
|
}
|
|
1189
1237
|
}
|
|
1190
|
-
function be(
|
|
1238
|
+
function be(r) {
|
|
1191
1239
|
try {
|
|
1192
|
-
|
|
1240
|
+
r.removeItem(Z);
|
|
1193
1241
|
} catch {
|
|
1194
1242
|
}
|
|
1195
1243
|
}
|
|
1196
|
-
function
|
|
1197
|
-
apiOrigin:
|
|
1244
|
+
function Kt({
|
|
1245
|
+
apiOrigin: r,
|
|
1198
1246
|
form: e,
|
|
1199
1247
|
steps: t,
|
|
1200
|
-
requestId:
|
|
1201
|
-
mediaMeta:
|
|
1202
|
-
origins:
|
|
1248
|
+
requestId: s = null,
|
|
1249
|
+
mediaMeta: n = {},
|
|
1250
|
+
origins: i = []
|
|
1203
1251
|
}) {
|
|
1204
1252
|
return {
|
|
1205
|
-
apiOrigin:
|
|
1253
|
+
apiOrigin: r,
|
|
1206
1254
|
formId: e.formId,
|
|
1207
1255
|
flowVersion: e.flowVersion,
|
|
1208
|
-
requestId:
|
|
1256
|
+
requestId: s,
|
|
1209
1257
|
steps: t,
|
|
1210
|
-
media:
|
|
1211
|
-
origins:
|
|
1258
|
+
media: n,
|
|
1259
|
+
origins: i.map(({ form: o, steps: a, option: l }) => ({
|
|
1212
1260
|
formId: o.formId,
|
|
1213
1261
|
steps: a,
|
|
1214
1262
|
option: l
|
|
1215
1263
|
}))
|
|
1216
1264
|
};
|
|
1217
1265
|
}
|
|
1218
|
-
function
|
|
1219
|
-
if (!s) return { status: "discarded" };
|
|
1220
|
-
if (t && s.apiOrigin && s.apiOrigin !== t)
|
|
1221
|
-
return { status: "discarded" };
|
|
1222
|
-
const r = (e || []).find((o) => o.formId === s.formId);
|
|
1266
|
+
function Qt(r, e, { apiOrigin: t } = {}) {
|
|
1223
1267
|
if (!r) return { status: "discarded" };
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
|
|
1268
|
+
if (t && r.apiOrigin && r.apiOrigin !== t)
|
|
1269
|
+
return { status: "discarded" };
|
|
1270
|
+
const s = (e || []).find((o) => o.formId === r.formId);
|
|
1271
|
+
if (!s) return { status: "discarded" };
|
|
1272
|
+
const { error: n } = H(s, r.steps || []);
|
|
1273
|
+
if (n) return { status: "discarded" };
|
|
1274
|
+
const i = {};
|
|
1275
|
+
for (const [o, a] of Object.entries(r.media || {}))
|
|
1276
|
+
a?.length && (i[o] = a.map((l) => ({ ...l, lost: !0 })));
|
|
1229
1277
|
return {
|
|
1230
|
-
status:
|
|
1231
|
-
form:
|
|
1232
|
-
steps:
|
|
1233
|
-
requestId:
|
|
1234
|
-
lostMedia:
|
|
1235
|
-
origins:
|
|
1278
|
+
status: r.flowVersion === s.flowVersion ? "ok" : "review-required",
|
|
1279
|
+
form: s,
|
|
1280
|
+
steps: r.steps || [],
|
|
1281
|
+
requestId: r.requestId || null,
|
|
1282
|
+
lostMedia: i,
|
|
1283
|
+
origins: Et(r.origins, e, s.formId)
|
|
1236
1284
|
};
|
|
1237
1285
|
}
|
|
1238
|
-
function
|
|
1286
|
+
function D(r = []) {
|
|
1239
1287
|
return {
|
|
1240
1288
|
stage: "idle",
|
|
1241
1289
|
resumeStage: null,
|
|
1242
|
-
files:
|
|
1290
|
+
files: r.map((e) => ({
|
|
1243
1291
|
name: e.name,
|
|
1244
1292
|
type: e.type,
|
|
1245
1293
|
size: e.size,
|
|
@@ -1255,82 +1303,82 @@ function z(s = []) {
|
|
|
1255
1303
|
error: null
|
|
1256
1304
|
};
|
|
1257
1305
|
}
|
|
1258
|
-
function
|
|
1306
|
+
function Zt(r, e) {
|
|
1259
1307
|
switch (e.type) {
|
|
1260
1308
|
case "START":
|
|
1261
|
-
return { ...
|
|
1309
|
+
return { ...r, stage: r.files.length ? "minting" : "requesting", error: null };
|
|
1262
1310
|
case "AUTH_REQUIRED":
|
|
1263
|
-
return { ...
|
|
1311
|
+
return { ...r, resumeStage: r.stage === "auth" ? r.resumeStage : r.stage, stage: "auth" };
|
|
1264
1312
|
case "AUTH_OK":
|
|
1265
|
-
return { ...
|
|
1313
|
+
return { ...r, stage: r.resumeStage || "idle", resumeStage: null };
|
|
1266
1314
|
case "MINTED": {
|
|
1267
|
-
const t =
|
|
1268
|
-
...
|
|
1269
|
-
assetId: e.uploads[
|
|
1270
|
-
url: e.uploads[
|
|
1271
|
-
assetUrl: e.uploads[
|
|
1315
|
+
const t = r.files.map((s, n) => ({
|
|
1316
|
+
...s,
|
|
1317
|
+
assetId: e.uploads[n]?.assetId ?? s.assetId,
|
|
1318
|
+
url: e.uploads[n]?.url ?? s.url,
|
|
1319
|
+
assetUrl: e.uploads[n]?.assetUrl ?? s.assetUrl,
|
|
1272
1320
|
status: "uploading",
|
|
1273
1321
|
progress: 0,
|
|
1274
1322
|
error: null
|
|
1275
1323
|
}));
|
|
1276
|
-
return { ...
|
|
1324
|
+
return { ...r, stage: "uploading", files: t };
|
|
1277
1325
|
}
|
|
1278
1326
|
case "FILE_PROGRESS":
|
|
1279
|
-
return T(
|
|
1327
|
+
return T(r, e.i, (t) => ({
|
|
1280
1328
|
...t,
|
|
1281
1329
|
progress: e.total ? e.loaded / e.total : 0
|
|
1282
1330
|
}));
|
|
1283
1331
|
case "FILE_DONE": {
|
|
1284
|
-
const t = T(
|
|
1285
|
-
return
|
|
1332
|
+
const t = T(r, e.i, (s) => ({ ...s, status: "done", progress: 1 }));
|
|
1333
|
+
return Jt(t);
|
|
1286
1334
|
}
|
|
1287
1335
|
case "FILE_FAIL":
|
|
1288
|
-
return { ...T(
|
|
1289
|
-
...
|
|
1336
|
+
return { ...T(r, e.i, (s) => ({
|
|
1337
|
+
...s,
|
|
1290
1338
|
status: "failed",
|
|
1291
1339
|
error: e.error || "upload failed"
|
|
1292
1340
|
})), stage: "uploading-error" };
|
|
1293
1341
|
case "RETRY_FILE":
|
|
1294
|
-
return { ...T(
|
|
1295
|
-
...
|
|
1342
|
+
return { ...T(r, e.i, (s) => ({
|
|
1343
|
+
...s,
|
|
1296
1344
|
status: "uploading",
|
|
1297
1345
|
progress: 0,
|
|
1298
1346
|
error: null
|
|
1299
1347
|
})), stage: "uploading" };
|
|
1300
1348
|
case "REMINT_FILE":
|
|
1301
|
-
return { ...T(
|
|
1302
|
-
...
|
|
1349
|
+
return { ...T(r, e.i, (s) => ({
|
|
1350
|
+
...s,
|
|
1303
1351
|
assetId: e.upload.assetId,
|
|
1304
1352
|
url: e.upload.url,
|
|
1305
|
-
assetUrl: e.upload.assetUrl ??
|
|
1353
|
+
assetUrl: e.upload.assetUrl ?? s.assetUrl,
|
|
1306
1354
|
status: "uploading",
|
|
1307
1355
|
progress: 0,
|
|
1308
1356
|
error: null
|
|
1309
1357
|
})), stage: "uploading" };
|
|
1310
1358
|
case "REQUEST_START":
|
|
1311
|
-
return { ...
|
|
1359
|
+
return { ...r, stage: "requesting", error: null };
|
|
1312
1360
|
case "REQUEST_OK":
|
|
1313
|
-
return { ...
|
|
1361
|
+
return { ...r, stage: "done", result: e.result, error: null };
|
|
1314
1362
|
case "REQUEST_FAIL":
|
|
1315
|
-
return { ...
|
|
1363
|
+
return { ...r, stage: "requesting-error", error: e.error };
|
|
1316
1364
|
case "RESET":
|
|
1317
|
-
return
|
|
1365
|
+
return D([]);
|
|
1318
1366
|
default:
|
|
1319
|
-
return
|
|
1367
|
+
return r;
|
|
1320
1368
|
}
|
|
1321
1369
|
}
|
|
1322
|
-
function T(
|
|
1323
|
-
const
|
|
1324
|
-
return { ...
|
|
1370
|
+
function T(r, e, t) {
|
|
1371
|
+
const s = r.files.map((n, i) => i === e ? t(n) : n);
|
|
1372
|
+
return { ...r, files: s };
|
|
1325
1373
|
}
|
|
1326
|
-
function
|
|
1327
|
-
const e =
|
|
1328
|
-
return e ? { ...
|
|
1374
|
+
function Jt(r) {
|
|
1375
|
+
const e = r.files.every((s) => s.status === "done"), t = r.files.some((s) => s.status === "failed");
|
|
1376
|
+
return e ? { ...r, stage: "requesting" } : t ? { ...r, stage: "uploading-error" } : r;
|
|
1329
1377
|
}
|
|
1330
|
-
function
|
|
1331
|
-
return
|
|
1378
|
+
function we(r) {
|
|
1379
|
+
return r.files.map((e, t) => ({ ...e, i: t })).filter((e) => e.status === "failed");
|
|
1332
1380
|
}
|
|
1333
|
-
const
|
|
1381
|
+
const Xt = [
|
|
1334
1382
|
"Wake",
|
|
1335
1383
|
"Durham",
|
|
1336
1384
|
"Orange",
|
|
@@ -1347,20 +1395,21 @@ const Vt = [
|
|
|
1347
1395
|
"Moore",
|
|
1348
1396
|
"Sampson",
|
|
1349
1397
|
"Other / outside the area"
|
|
1350
|
-
],
|
|
1398
|
+
], xe = "(919) 821-8600", es = "https://www.wral.com/my-wral/", ts = Object.freeze([
|
|
1351
1399
|
"We cannot come back to you for the detail that often turns a tip into a story.",
|
|
1352
1400
|
"We cannot credit you if we use your photos or video.",
|
|
1353
1401
|
"If you lose your reference number, we cannot look it up for you."
|
|
1354
1402
|
]);
|
|
1355
|
-
function
|
|
1356
|
-
const e = String(
|
|
1403
|
+
function ss(r) {
|
|
1404
|
+
const e = String(r).replace(/\D/g, "");
|
|
1357
1405
|
return `tel:+1${e.length === 11 && e.startsWith("1") ? e.slice(1) : e}`;
|
|
1358
1406
|
}
|
|
1359
|
-
const
|
|
1360
|
-
class
|
|
1361
|
-
static styles =
|
|
1407
|
+
const rs = "https://api.wral.com/forms", ns = 480, is = 2, Te = "What would you like to send to WRAL?", V = `Welcome to Report It. ${Te}`, j = "A few quick questions route your report to the right team.", os = 2500, as = "I took or own this material and give WRAL permission to use it on air and online with credit to me.";
|
|
1408
|
+
class fs extends G {
|
|
1409
|
+
static styles = it;
|
|
1362
1410
|
static properties = {
|
|
1363
1411
|
api: { type: String },
|
|
1412
|
+
factsApi: { type: String, attribute: "facts-api" },
|
|
1364
1413
|
flow: { type: String },
|
|
1365
1414
|
_phase: { state: !0 },
|
|
1366
1415
|
_forms: { state: !0 },
|
|
@@ -1376,45 +1425,51 @@ class ar extends G {
|
|
|
1376
1425
|
_submit: { state: !0 },
|
|
1377
1426
|
_banner: { state: !0 },
|
|
1378
1427
|
_notice: { state: !0 },
|
|
1379
|
-
_result: { state: !0 }
|
|
1428
|
+
_result: { state: !0 },
|
|
1429
|
+
_factsOffer: { state: !0 }
|
|
1380
1430
|
};
|
|
1381
1431
|
#c = null;
|
|
1382
1432
|
#l = null;
|
|
1383
1433
|
#u = null;
|
|
1384
1434
|
#t = null;
|
|
1385
|
-
#r = {};
|
|
1386
1435
|
#s = {};
|
|
1387
|
-
#
|
|
1388
|
-
#
|
|
1389
|
-
#
|
|
1390
|
-
#
|
|
1436
|
+
#r = {};
|
|
1437
|
+
#i = /* @__PURE__ */ new Map();
|
|
1438
|
+
#w = null;
|
|
1439
|
+
#h = null;
|
|
1440
|
+
#x = !1;
|
|
1391
1441
|
#d = null;
|
|
1392
|
-
#
|
|
1442
|
+
#I = 0;
|
|
1443
|
+
/* The gate was passed with an account created on this page load; offered once. */
|
|
1444
|
+
#p = !1;
|
|
1393
1445
|
constructor() {
|
|
1394
|
-
super(), this.api =
|
|
1446
|
+
super(), this.api = rs, this.factsApi = null, this.flow = null, this._phase = "loading", this._forms = [], this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this._typing = !1, this._loadingSlow = !1, this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit = D([]), this._banner = null, this._notice = null, this._result = null, this._factsOffer = null;
|
|
1395
1447
|
}
|
|
1396
1448
|
get client() {
|
|
1397
|
-
|
|
1449
|
+
if (this.#c) return this.#c;
|
|
1450
|
+
const e = `${this.api}
|
|
1451
|
+
${this.factsApi || ""}`;
|
|
1452
|
+
return (!this.#l || this.#u !== e) && (this.#l = vt({ baseUrl: this.api, factsBaseUrl: this.factsApi || null }), this.#u = e), this.#l;
|
|
1398
1453
|
}
|
|
1399
1454
|
set client(e) {
|
|
1400
|
-
this.#c = e || null, this.isConnected && this.#
|
|
1455
|
+
this.#c = e || null, this.isConnected && this.#v();
|
|
1401
1456
|
}
|
|
1402
1457
|
connectedCallback() {
|
|
1403
|
-
super.connectedCallback(), this.#
|
|
1458
|
+
super.connectedCallback(), this.#v();
|
|
1404
1459
|
}
|
|
1405
1460
|
disconnectedCallback() {
|
|
1406
|
-
super.disconnectedCallback(), clearTimeout(this.#
|
|
1407
|
-
for (const { abort: e } of this.#
|
|
1408
|
-
this.#
|
|
1461
|
+
super.disconnectedCallback(), clearTimeout(this.#w), clearTimeout(this.#h), this.#d?.();
|
|
1462
|
+
for (const { abort: e } of this.#i.values()) e?.();
|
|
1463
|
+
this.#i.clear();
|
|
1409
1464
|
}
|
|
1410
|
-
get #
|
|
1465
|
+
get #B() {
|
|
1411
1466
|
try {
|
|
1412
1467
|
return matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1413
1468
|
} catch {
|
|
1414
1469
|
return !0;
|
|
1415
1470
|
}
|
|
1416
1471
|
}
|
|
1417
|
-
get #
|
|
1472
|
+
get #f() {
|
|
1418
1473
|
try {
|
|
1419
1474
|
return sessionStorage;
|
|
1420
1475
|
} catch {
|
|
@@ -1429,38 +1484,38 @@ class ar extends G {
|
|
|
1429
1484
|
* submission is enabled on this deployment, and a form whose desk needs
|
|
1430
1485
|
* a way to reach the viewer opts out with allowAnonymous: false.
|
|
1431
1486
|
*/
|
|
1432
|
-
get #
|
|
1487
|
+
get #L() {
|
|
1433
1488
|
return this.client.anonymousCapability?.().enabled === !0 && this._form?.allowAnonymous !== !1;
|
|
1434
1489
|
}
|
|
1435
1490
|
/* Derived from the gate step, so a reload restores the choice. */
|
|
1436
|
-
get #
|
|
1491
|
+
get #g() {
|
|
1437
1492
|
return this._steps.some((e) => e.kind === "gate" && e.anonymous === !0);
|
|
1438
1493
|
}
|
|
1439
1494
|
// ── Loading + draft restore ─────────────────────────────────────
|
|
1440
|
-
async #
|
|
1441
|
-
const e = ++this.#
|
|
1442
|
-
this._phase = "loading", this._banner = null, this._loadingSlow = !1, clearTimeout(this.#
|
|
1495
|
+
async #v() {
|
|
1496
|
+
const e = ++this.#I, t = () => e === this.#I;
|
|
1497
|
+
this._phase = "loading", this._banner = null, this._loadingSlow = !1, clearTimeout(this.#h), this.#h = setTimeout(() => {
|
|
1443
1498
|
this._loadingSlow = !0;
|
|
1444
|
-
},
|
|
1445
|
-
let
|
|
1499
|
+
}, os);
|
|
1500
|
+
let s;
|
|
1446
1501
|
try {
|
|
1447
|
-
|
|
1502
|
+
s = await this.client.listForms();
|
|
1448
1503
|
} catch {
|
|
1449
1504
|
t() && (this._phase = "load-error");
|
|
1450
1505
|
return;
|
|
1451
1506
|
} finally {
|
|
1452
|
-
t() && (clearTimeout(this.#
|
|
1507
|
+
t() && (clearTimeout(this.#h), this._loadingSlow = !1);
|
|
1453
1508
|
}
|
|
1454
1509
|
if (!t()) return;
|
|
1455
|
-
this._forms =
|
|
1456
|
-
const
|
|
1457
|
-
if ((
|
|
1458
|
-
this._form =
|
|
1510
|
+
this._forms = s;
|
|
1511
|
+
const n = St({ attr: this.flow, search: globalThis.location?.search }), i = Qt(Gt(this.#f), this._forms, { apiOrigin: this.api });
|
|
1512
|
+
if ((i.status === "ok" || i.status === "review-required") && Tt(i, n)) {
|
|
1513
|
+
this._form = i.form, this._steps = i.steps, this._origins = i.origins || [], this.#t = i.requestId, this.#r = i.lostMedia || {}, i.status === "review-required" ? this._notice = "This form changed since your last visit — please review your answers." : Object.keys(this.#r).length && (this._notice = "Welcome back — your answers were saved, but attachments need to be re-attached."), this.#n({ animate: !1 });
|
|
1459
1514
|
return;
|
|
1460
1515
|
}
|
|
1461
|
-
const o =
|
|
1516
|
+
const o = Ct(this._forms, n);
|
|
1462
1517
|
if (o) {
|
|
1463
|
-
this.#
|
|
1518
|
+
this.#E(o);
|
|
1464
1519
|
return;
|
|
1465
1520
|
}
|
|
1466
1521
|
this._phase = "pick";
|
|
@@ -1468,9 +1523,9 @@ class ar extends G {
|
|
|
1468
1523
|
#o() {
|
|
1469
1524
|
if (!this._form) return;
|
|
1470
1525
|
const e = {};
|
|
1471
|
-
for (const [t,
|
|
1472
|
-
|
|
1473
|
-
|
|
1526
|
+
for (const [t, s] of Object.entries(this.#s))
|
|
1527
|
+
s.length && (e[t] = s.map(({ name: n, type: i, size: o }) => ({ name: n, type: i, size: o })));
|
|
1528
|
+
Yt(this.#f, Kt({
|
|
1474
1529
|
apiOrigin: this.api,
|
|
1475
1530
|
form: this._form,
|
|
1476
1531
|
steps: this._steps,
|
|
@@ -1480,23 +1535,23 @@ class ar extends G {
|
|
|
1480
1535
|
}));
|
|
1481
1536
|
}
|
|
1482
1537
|
// ── Walk mechanics ──────────────────────────────────────────────
|
|
1483
|
-
#
|
|
1484
|
-
this._phase = "walk", this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, e && !this.#
|
|
1538
|
+
#n({ animate: e = !0 } = {}) {
|
|
1539
|
+
this._phase = "walk", this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, e && !this.#B ? (this._typing = !0, clearTimeout(this.#w), this.#w = setTimeout(() => {
|
|
1485
1540
|
this._typing = !1;
|
|
1486
|
-
},
|
|
1541
|
+
}, ns)) : this._typing = !1;
|
|
1487
1542
|
}
|
|
1488
|
-
get #
|
|
1489
|
-
return this._form ?
|
|
1543
|
+
get #_() {
|
|
1544
|
+
return this._form ? H(this._form, this._steps) : { node: null };
|
|
1490
1545
|
}
|
|
1491
|
-
#
|
|
1492
|
-
this._form = e, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#
|
|
1546
|
+
#E(e) {
|
|
1547
|
+
this._form = e, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#n();
|
|
1493
1548
|
}
|
|
1494
1549
|
#m(e) {
|
|
1495
|
-
this._steps = [...this._steps, e], this.#o(), this.#
|
|
1550
|
+
this._steps = [...this._steps, e], this.#o(), this.#n();
|
|
1496
1551
|
}
|
|
1497
|
-
#
|
|
1498
|
-
if (
|
|
1499
|
-
this.#
|
|
1552
|
+
#H(e, t) {
|
|
1553
|
+
if (L(t)) {
|
|
1554
|
+
this.#q(e, t);
|
|
1500
1555
|
return;
|
|
1501
1556
|
}
|
|
1502
1557
|
this._handoffError = !1, this.#m({
|
|
@@ -1513,97 +1568,97 @@ class ar extends G {
|
|
|
1513
1568
|
* Back can return them. A target that is missing or no longer matches
|
|
1514
1569
|
* its preset path is a config mistake: say so and stay put.
|
|
1515
1570
|
*/
|
|
1516
|
-
#
|
|
1517
|
-
const { form:
|
|
1518
|
-
if (
|
|
1571
|
+
#q(e, t) {
|
|
1572
|
+
const { form: s, steps: n, error: i } = At(this._forms, t);
|
|
1573
|
+
if (i) {
|
|
1519
1574
|
this._handoffError = !0;
|
|
1520
1575
|
return;
|
|
1521
1576
|
}
|
|
1522
1577
|
this._handoffError = !1, this._origins = [...this._origins, {
|
|
1523
|
-
...
|
|
1524
|
-
media: this.#
|
|
1525
|
-
lostMedia: this.#
|
|
1526
|
-
}], this._form =
|
|
1578
|
+
...Ft(this._form, this._steps, e, t),
|
|
1579
|
+
media: this.#s,
|
|
1580
|
+
lostMedia: this.#r
|
|
1581
|
+
}], this._form = s, this._steps = n, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#n();
|
|
1527
1582
|
}
|
|
1528
1583
|
/* Back past a hand-off: the originating form, on the choice card. */
|
|
1529
|
-
#
|
|
1584
|
+
#W() {
|
|
1530
1585
|
const e = this._origins.at(-1);
|
|
1531
|
-
this._origins = this._origins.slice(0, -1), this._form = e.form, this._steps = e.steps, this.#t = null, this.#
|
|
1586
|
+
this._origins = this._origins.slice(0, -1), this._form = e.form, this._steps = e.steps, this.#t = null, this.#s = e.media || {}, this.#r = e.lostMedia || {}, this._handoffError = !1, this.#o(), this.#n({ animate: !1 });
|
|
1532
1587
|
}
|
|
1533
|
-
#
|
|
1588
|
+
#V() {
|
|
1534
1589
|
if (this._phase === "done" || this._phase === "submitting") return;
|
|
1535
1590
|
if (this._phase === "review") {
|
|
1536
|
-
this.#
|
|
1591
|
+
this.#n({ animate: !1 });
|
|
1537
1592
|
return;
|
|
1538
1593
|
}
|
|
1539
|
-
if (this._origins.length &&
|
|
1540
|
-
this.#
|
|
1594
|
+
if (this._origins.length && It(this._steps)) {
|
|
1595
|
+
this.#W();
|
|
1541
1596
|
return;
|
|
1542
1597
|
}
|
|
1543
1598
|
if (!this._steps.length) {
|
|
1544
|
-
this
|
|
1599
|
+
this.#$();
|
|
1545
1600
|
return;
|
|
1546
1601
|
}
|
|
1547
1602
|
const e = this._steps.at(-1);
|
|
1548
|
-
this._steps = this._steps.slice(0, -1), e.kind === "collect" && (this._cardValues = { ...e.values }), this.#o(), this.#
|
|
1603
|
+
this._steps = this._steps.slice(0, -1), e.kind === "collect" && (this._cardValues = { ...e.values }), this.#o(), this.#n({ animate: !1 });
|
|
1549
1604
|
}
|
|
1550
|
-
|
|
1551
|
-
this.client.endAnonSession?.(), this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#
|
|
1605
|
+
#$() {
|
|
1606
|
+
this.client.endAnonSession?.(), this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#s = {}, this.#r = {}, this._result = null, this._banner = null, this._notice = null, this._submit = D([]), this._factsOffer = null, be(this.#f), this._phase = "pick";
|
|
1552
1607
|
}
|
|
1553
1608
|
// ── Collect card ────────────────────────────────────────────────
|
|
1554
|
-
|
|
1609
|
+
#k(e, t) {
|
|
1555
1610
|
this._cardValues = { ...this._cardValues, [e]: t };
|
|
1556
1611
|
}
|
|
1557
1612
|
/* Files attached on the given collect cards (a files-only consent counts them). */
|
|
1558
|
-
#
|
|
1613
|
+
#S(e) {
|
|
1559
1614
|
let t = 0;
|
|
1560
|
-
for (const
|
|
1615
|
+
for (const s of new Set(e)) t += (this.#s[s] || []).length;
|
|
1561
1616
|
return t;
|
|
1562
1617
|
}
|
|
1563
1618
|
/* Files attached so far on this walk, the card being filled in included. */
|
|
1564
|
-
#
|
|
1565
|
-
const t = this._steps.filter((
|
|
1566
|
-
return this.#
|
|
1619
|
+
#C(e) {
|
|
1620
|
+
const t = this._steps.filter((s) => s.kind === "collect").map((s) => s.nodeId);
|
|
1621
|
+
return this.#S([...t, e]);
|
|
1567
1622
|
}
|
|
1568
1623
|
#j(e) {
|
|
1569
|
-
const t = e.fields || [], { ok:
|
|
1570
|
-
mediaCount: this.#
|
|
1571
|
-
}),
|
|
1624
|
+
const t = e.fields || [], { ok: s, errors: n } = fe(t, this._cardValues, {
|
|
1625
|
+
mediaCount: this.#C(e.id)
|
|
1626
|
+
}), i = t.find((l) => l.kind === "media");
|
|
1572
1627
|
let o = !0;
|
|
1573
|
-
if (
|
|
1574
|
-
const l = this.#
|
|
1575
|
-
required: !!
|
|
1628
|
+
if (i) {
|
|
1629
|
+
const l = this.#s[e.id] || [], d = Y(l, this._form.budget, {
|
|
1630
|
+
required: !!i.required
|
|
1576
1631
|
});
|
|
1577
|
-
d.ok ? l.length && (this.#
|
|
1632
|
+
d.ok ? l.length && (this.#r = { ...this.#r, [e.id]: [] }) : (o = !1, n[i.key] = d.errors[0].message);
|
|
1578
1633
|
}
|
|
1579
|
-
if (!
|
|
1580
|
-
this._fieldErrors =
|
|
1634
|
+
if (!s || !o) {
|
|
1635
|
+
this._fieldErrors = n;
|
|
1581
1636
|
return;
|
|
1582
1637
|
}
|
|
1583
|
-
const a = this.#
|
|
1638
|
+
const a = this.#s[e.id] || [];
|
|
1584
1639
|
this.#m({
|
|
1585
1640
|
nodeId: e.id,
|
|
1586
1641
|
kind: "collect",
|
|
1587
1642
|
values: { ...this._cardValues },
|
|
1588
|
-
summary:
|
|
1643
|
+
summary: Wt(t, this._cardValues, a)
|
|
1589
1644
|
});
|
|
1590
1645
|
}
|
|
1591
1646
|
// ── Gate ────────────────────────────────────────────────────────
|
|
1592
|
-
async #
|
|
1593
|
-
if (!(this._gate.stage || this.#
|
|
1594
|
-
this.#
|
|
1647
|
+
async #T() {
|
|
1648
|
+
if (!(this._gate.stage || this.#x)) {
|
|
1649
|
+
this.#x = !0;
|
|
1595
1650
|
try {
|
|
1596
1651
|
const e = await this.client.isAuthenticated();
|
|
1597
1652
|
this._gate = e ? { stage: "signedin", email: this.client.signedInEmail?.() || "", error: "", loading: !1 } : { stage: "email", email: "", error: "", loading: !1 };
|
|
1598
1653
|
} finally {
|
|
1599
|
-
this.#
|
|
1654
|
+
this.#x = !1;
|
|
1600
1655
|
}
|
|
1601
1656
|
this._gate.stage === "email" && this.client.onCrossTabLogin && !this.#d && (this.#d = this.client.onCrossTabLogin(() => {
|
|
1602
|
-
this.#d?.(), this.#d = null, this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#
|
|
1657
|
+
this.#d?.(), this.#d = null, this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#T();
|
|
1603
1658
|
}));
|
|
1604
1659
|
}
|
|
1605
1660
|
}
|
|
1606
|
-
async #
|
|
1661
|
+
async #A() {
|
|
1607
1662
|
const e = this._gate.email.trim();
|
|
1608
1663
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
1609
1664
|
this._gate = { ...this._gate, error: "Please enter a valid email address." };
|
|
@@ -1611,8 +1666,8 @@ class ar extends G {
|
|
|
1611
1666
|
}
|
|
1612
1667
|
this._gate = { ...this._gate, error: "", loading: !0 };
|
|
1613
1668
|
try {
|
|
1614
|
-
const t = await this.client.sendCode(e);
|
|
1615
|
-
this._gate = t.authenticated ? { stage: "signedin", email: e, error: "", loading: !1 } : { ...this._gate, stage: "code", loading: !1 };
|
|
1669
|
+
const t = await this.client.sendCode(e), s = !!t.newAccount;
|
|
1670
|
+
this._gate = t.authenticated ? { stage: "signedin", email: e, error: "", loading: !1, newAccount: s } : { ...this._gate, stage: "code", loading: !1, newAccount: s };
|
|
1616
1671
|
} catch (t) {
|
|
1617
1672
|
this._gate = {
|
|
1618
1673
|
...this._gate,
|
|
@@ -1621,10 +1676,10 @@ class ar extends G {
|
|
|
1621
1676
|
};
|
|
1622
1677
|
}
|
|
1623
1678
|
}
|
|
1624
|
-
async #
|
|
1679
|
+
async #R(e) {
|
|
1625
1680
|
this._gate = { ...this._gate, error: "", loading: !0 };
|
|
1626
1681
|
try {
|
|
1627
|
-
await this.client.verifyCode(e), this.#
|
|
1682
|
+
await this.client.verifyCode(e), this.#O(this._gate.email);
|
|
1628
1683
|
} catch (t) {
|
|
1629
1684
|
this._gate = {
|
|
1630
1685
|
...this._gate,
|
|
@@ -1633,30 +1688,30 @@ class ar extends G {
|
|
|
1633
1688
|
};
|
|
1634
1689
|
}
|
|
1635
1690
|
}
|
|
1636
|
-
#
|
|
1637
|
-
if (this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit.stage === "auth") {
|
|
1691
|
+
#O(e) {
|
|
1692
|
+
if (this.#p = !!this._gate.newAccount, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit.stage === "auth") {
|
|
1638
1693
|
this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
|
|
1639
1694
|
return;
|
|
1640
1695
|
}
|
|
1641
|
-
const { node: t } = this.#
|
|
1696
|
+
const { node: t } = this.#_;
|
|
1642
1697
|
t?.type === "gate" && this.#m({ nodeId: t.id, kind: "gate", email: e });
|
|
1643
1698
|
}
|
|
1644
|
-
#
|
|
1645
|
-
this.client.signOut?.(), this._gate = { stage: "email", email: "", error: "", loading: !1 };
|
|
1699
|
+
#Y() {
|
|
1700
|
+
this.client.signOut?.(), this.#p = !1, this._gate = { stage: "email", email: "", error: "", loading: !1 };
|
|
1646
1701
|
}
|
|
1647
1702
|
// ── Anonymous route ─────────────────────────────────────────────
|
|
1648
|
-
#
|
|
1703
|
+
#G() {
|
|
1649
1704
|
this._gate = { ...this._gate, stage: "anon-confirm", error: "" };
|
|
1650
1705
|
}
|
|
1651
|
-
#
|
|
1706
|
+
#K() {
|
|
1652
1707
|
this._gate = { ...this._gate, stage: "email", error: "" };
|
|
1653
1708
|
}
|
|
1654
1709
|
/*
|
|
1655
1710
|
* Records the choice only. The session is minted at submit, against
|
|
1656
1711
|
* the requestId, so an abandoned form leaves nothing behind.
|
|
1657
1712
|
*/
|
|
1658
|
-
#
|
|
1659
|
-
const { node: e } = this.#
|
|
1713
|
+
#Q() {
|
|
1714
|
+
const { node: e } = this.#_;
|
|
1660
1715
|
e?.type === "gate" && (this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#m({ nodeId: e.id, kind: "gate", anonymous: !0 }));
|
|
1661
1716
|
}
|
|
1662
1717
|
async #M() {
|
|
@@ -1671,7 +1726,7 @@ class ar extends G {
|
|
|
1671
1726
|
}
|
|
1672
1727
|
/* An anonymous session outliving the upload run re-mints in place; there
|
|
1673
1728
|
* is no identity to send back to the sign-in card. */
|
|
1674
|
-
async #
|
|
1729
|
+
async #Z() {
|
|
1675
1730
|
if (await this.#M()) {
|
|
1676
1731
|
this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
|
|
1677
1732
|
return;
|
|
@@ -1679,42 +1734,42 @@ class ar extends G {
|
|
|
1679
1734
|
this.#e({ type: "REQUEST_FAIL", error: this._banner });
|
|
1680
1735
|
}
|
|
1681
1736
|
// ── Submit pipeline ─────────────────────────────────────────────
|
|
1682
|
-
get #
|
|
1737
|
+
get #y() {
|
|
1683
1738
|
const e = [];
|
|
1684
1739
|
for (const t of this._steps)
|
|
1685
1740
|
if (t.kind === "collect")
|
|
1686
|
-
for (const
|
|
1687
|
-
e.push(
|
|
1741
|
+
for (const s of this.#s[t.nodeId] || [])
|
|
1742
|
+
e.push(s);
|
|
1688
1743
|
return e;
|
|
1689
1744
|
}
|
|
1690
1745
|
#e(e) {
|
|
1691
|
-
this._submit =
|
|
1746
|
+
this._submit = Zt(this._submit, e);
|
|
1692
1747
|
}
|
|
1693
|
-
async #
|
|
1748
|
+
async #J() {
|
|
1694
1749
|
this._banner = null;
|
|
1695
1750
|
for (let e = 0; e < this._steps.length; e++) {
|
|
1696
1751
|
const t = this._steps[e];
|
|
1697
1752
|
if (t.kind !== "collect") continue;
|
|
1698
|
-
const
|
|
1699
|
-
mediaCount: this.#
|
|
1700
|
-
}), a = (
|
|
1753
|
+
const s = x(this._form, t.nodeId), n = this._steps.slice(0, e + 1).filter((d) => d.kind === "collect").map((d) => d.nodeId), { ok: i, errors: o } = fe(s?.fields || [], t.values, {
|
|
1754
|
+
mediaCount: this.#S(n)
|
|
1755
|
+
}), a = (s?.fields || []).find((d) => d.kind === "media");
|
|
1701
1756
|
let l = !0;
|
|
1702
1757
|
if (a) {
|
|
1703
|
-
const d = this.#
|
|
1758
|
+
const d = this.#s[t.nodeId] || [], h = Y(d, this._form.budget, {
|
|
1704
1759
|
required: !!a.required
|
|
1705
1760
|
});
|
|
1706
|
-
|
|
1761
|
+
h.ok || (l = !1, o[a.key] = h.errors[0].message);
|
|
1707
1762
|
}
|
|
1708
|
-
if (!
|
|
1709
|
-
this._steps = this._steps.slice(0, e), this._cardValues = { ...t.values }, this._fieldErrors = o, this.#o(), this.#
|
|
1763
|
+
if (!i || !l) {
|
|
1764
|
+
this._steps = this._steps.slice(0, e), this._cardValues = { ...t.values }, this._fieldErrors = o, this.#o(), this.#n({ animate: !1 });
|
|
1710
1765
|
return;
|
|
1711
1766
|
}
|
|
1712
1767
|
}
|
|
1713
|
-
if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#
|
|
1768
|
+
if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#g) {
|
|
1714
1769
|
if (!await this.#M()) return;
|
|
1715
1770
|
} else
|
|
1716
1771
|
this.client.endAnonSession?.();
|
|
1717
|
-
if (this._submit =
|
|
1772
|
+
if (this._submit = D(this.#y), this._phase = "submitting", this.#g) {
|
|
1718
1773
|
this.#e({ type: "START" }), this.#a();
|
|
1719
1774
|
return;
|
|
1720
1775
|
}
|
|
@@ -1726,93 +1781,111 @@ class ar extends G {
|
|
|
1726
1781
|
}
|
|
1727
1782
|
async #a() {
|
|
1728
1783
|
const e = this._submit.stage;
|
|
1729
|
-
if (e === "minting") return this.#
|
|
1730
|
-
if (e === "uploading") return this.#
|
|
1731
|
-
if (e === "requesting") return this.#
|
|
1784
|
+
if (e === "minting") return this.#X();
|
|
1785
|
+
if (e === "uploading") return this.#N();
|
|
1786
|
+
if (e === "requesting") return this.#se();
|
|
1732
1787
|
}
|
|
1733
|
-
async #
|
|
1788
|
+
async #X() {
|
|
1734
1789
|
try {
|
|
1735
|
-
const e = await this.client.createUploads(
|
|
1790
|
+
const e = await this.client.createUploads(ge({
|
|
1736
1791
|
formId: this._form.formId,
|
|
1737
1792
|
requestId: this.#t,
|
|
1738
|
-
files: this.#
|
|
1793
|
+
files: this.#y
|
|
1739
1794
|
}));
|
|
1740
1795
|
this.#e({ type: "MINTED", uploads: e }), this.#a();
|
|
1741
1796
|
} catch (e) {
|
|
1742
|
-
this.#
|
|
1797
|
+
this.#F(e);
|
|
1743
1798
|
}
|
|
1744
1799
|
}
|
|
1745
|
-
#
|
|
1746
|
-
const e = this._submit.files, t = this.#
|
|
1747
|
-
let
|
|
1748
|
-
for (let
|
|
1749
|
-
e[
|
|
1800
|
+
#N() {
|
|
1801
|
+
const e = this._submit.files, t = this.#i.size;
|
|
1802
|
+
let s = 0;
|
|
1803
|
+
for (let n = 0; n < e.length && t + s < is; n++)
|
|
1804
|
+
e[n].status !== "uploading" || this.#i.has(n) || (s += 1, this.#ee(n));
|
|
1750
1805
|
}
|
|
1751
|
-
#
|
|
1752
|
-
const t = this._submit.files[e],
|
|
1806
|
+
#ee(e) {
|
|
1807
|
+
const t = this._submit.files[e], s = this.#y[e], { promise: n, abort: i } = this.client.uploadFile({
|
|
1753
1808
|
url: t.url,
|
|
1754
|
-
file:
|
|
1809
|
+
file: s,
|
|
1755
1810
|
contentType: t.type,
|
|
1756
1811
|
onProgress: ({ loaded: o, total: a }) => {
|
|
1757
1812
|
this.#e({ type: "FILE_PROGRESS", i: e, loaded: o, total: a });
|
|
1758
1813
|
}
|
|
1759
1814
|
});
|
|
1760
|
-
this.#
|
|
1761
|
-
this.#
|
|
1815
|
+
this.#i.set(e, { abort: i }), n.then(() => {
|
|
1816
|
+
this.#i.delete(e), this.#e({ type: "FILE_DONE", i: e }), this.#a();
|
|
1762
1817
|
}).catch((o) => {
|
|
1763
|
-
this.#
|
|
1818
|
+
this.#i.delete(e), this.#e({
|
|
1764
1819
|
type: "FILE_FAIL",
|
|
1765
1820
|
i: e,
|
|
1766
1821
|
error: o?.status === 403 ? "expired" : "failed"
|
|
1767
1822
|
});
|
|
1768
1823
|
});
|
|
1769
1824
|
}
|
|
1770
|
-
async #
|
|
1825
|
+
async #te(e) {
|
|
1771
1826
|
if (this._submit.files[e].error === "expired")
|
|
1772
1827
|
try {
|
|
1773
|
-
const [
|
|
1828
|
+
const [s] = await this.client.createUploads(ge({
|
|
1774
1829
|
formId: this._form.formId,
|
|
1775
1830
|
requestId: this.#t,
|
|
1776
|
-
files: [this.#
|
|
1831
|
+
files: [this.#y[e]]
|
|
1777
1832
|
}));
|
|
1778
|
-
this.#e({ type: "REMINT_FILE", i: e, upload:
|
|
1779
|
-
} catch (
|
|
1780
|
-
this.#
|
|
1833
|
+
this.#e({ type: "REMINT_FILE", i: e, upload: s });
|
|
1834
|
+
} catch (s) {
|
|
1835
|
+
this.#F(s);
|
|
1781
1836
|
return;
|
|
1782
1837
|
}
|
|
1783
1838
|
else
|
|
1784
1839
|
this.#e({ type: "RETRY_FILE", i: e });
|
|
1785
|
-
this.#
|
|
1840
|
+
this.#N();
|
|
1786
1841
|
}
|
|
1787
|
-
async #
|
|
1842
|
+
async #se() {
|
|
1788
1843
|
try {
|
|
1789
|
-
const e = this._submit.files.map(({ assetId:
|
|
1844
|
+
const e = this._submit.files.map(({ assetId: s, type: n }) => ({ assetId: s, type: n })), t = await this.client.putRequest(this.#t, zt({
|
|
1790
1845
|
form: this._form,
|
|
1791
1846
|
steps: this._steps,
|
|
1792
1847
|
media: e
|
|
1793
1848
|
}));
|
|
1794
|
-
this.#e({ type: "REQUEST_OK", result: t }), this._result = t, be(this.#
|
|
1849
|
+
this.#e({ type: "REQUEST_OK", result: t }), this._result = t, be(this.#f), this.client.endAnonSession?.(), this.#re(), this._phase = "done";
|
|
1795
1850
|
} catch (e) {
|
|
1796
|
-
this.#
|
|
1851
|
+
this.#F(e);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
// ── Save to My WRAL (new accounts only) ─────────────────────────
|
|
1855
|
+
#re() {
|
|
1856
|
+
if (!this.#p || this.#g || !this.client.saveUserFacts) return;
|
|
1857
|
+
this.#p = !1;
|
|
1858
|
+
const e = bt(Ae(this._form, this._steps), Fe(this._steps));
|
|
1859
|
+
e.length && (this._factsOffer = { stage: "offer", facts: e });
|
|
1860
|
+
}
|
|
1861
|
+
async #ne() {
|
|
1862
|
+
const e = this._factsOffer;
|
|
1863
|
+
if (!(!e || e.stage === "saving")) {
|
|
1864
|
+
this._factsOffer = { ...e, stage: "saving" };
|
|
1865
|
+
try {
|
|
1866
|
+
await this.client.saveUserFacts(e.facts), this._factsOffer = { ...e, stage: "saved" };
|
|
1867
|
+
} catch {
|
|
1868
|
+
this._factsOffer = { ...e, stage: "error" };
|
|
1869
|
+
}
|
|
1797
1870
|
}
|
|
1798
1871
|
}
|
|
1799
|
-
#
|
|
1872
|
+
#F(e) {
|
|
1800
1873
|
const t = me(e?.status ?? 0, e?.body ?? null);
|
|
1801
1874
|
if (t.kind === "auth") {
|
|
1802
|
-
if (this.#e({ type: "AUTH_REQUIRED" }), this.#
|
|
1803
|
-
this.#
|
|
1875
|
+
if (this.#e({ type: "AUTH_REQUIRED" }), this.#g) {
|
|
1876
|
+
this.#Z();
|
|
1804
1877
|
return;
|
|
1805
1878
|
}
|
|
1806
1879
|
this._gate = { stage: "email", email: "", error: "", loading: !1 };
|
|
1807
1880
|
return;
|
|
1808
1881
|
}
|
|
1809
1882
|
if (t.kind === "stale") {
|
|
1810
|
-
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#
|
|
1883
|
+
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#ie();
|
|
1811
1884
|
return;
|
|
1812
1885
|
}
|
|
1813
1886
|
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t });
|
|
1814
1887
|
}
|
|
1815
|
-
async #
|
|
1888
|
+
async #ie() {
|
|
1816
1889
|
try {
|
|
1817
1890
|
this._forms = await this.client.listForms();
|
|
1818
1891
|
const e = this._forms.find((t) => t.formId === this._form.formId);
|
|
@@ -1820,52 +1893,52 @@ class ar extends G {
|
|
|
1820
1893
|
} catch {
|
|
1821
1894
|
}
|
|
1822
1895
|
}
|
|
1823
|
-
#
|
|
1896
|
+
#oe() {
|
|
1824
1897
|
this._banner = null, this.#e({ type: "REQUEST_START" }), this.#a();
|
|
1825
1898
|
}
|
|
1826
1899
|
// ── Render ──────────────────────────────────────────────────────
|
|
1827
1900
|
render() {
|
|
1828
1901
|
return c`
|
|
1829
1902
|
<div class="chat" aria-live="polite">
|
|
1830
|
-
${this.#
|
|
1903
|
+
${this.#ae()}
|
|
1831
1904
|
</div>
|
|
1832
|
-
${this
|
|
1905
|
+
${this.#$e()}
|
|
1833
1906
|
`;
|
|
1834
1907
|
}
|
|
1835
|
-
#
|
|
1908
|
+
#ae() {
|
|
1836
1909
|
switch (this._phase) {
|
|
1837
1910
|
case "loading":
|
|
1838
|
-
return c`${
|
|
1839
|
-
${
|
|
1911
|
+
return c`${m(V, this._loadingSlow ? "Loading the form list…" : j)}
|
|
1912
|
+
${W()}`;
|
|
1840
1913
|
case "load-error":
|
|
1841
1914
|
return c`
|
|
1842
|
-
${
|
|
1915
|
+
${m("We could not load the forms.", "Check your connection and try again.", { error: !0 })}
|
|
1843
1916
|
<div class="options">
|
|
1844
|
-
<button type="button" class="chip" @click=${() => this.#
|
|
1917
|
+
<button type="button" class="chip" @click=${() => this.#v()}>Try again</button>
|
|
1845
1918
|
</div>
|
|
1846
1919
|
`;
|
|
1847
1920
|
case "pick":
|
|
1848
|
-
return this.#
|
|
1921
|
+
return this.#le();
|
|
1849
1922
|
case "walk":
|
|
1850
|
-
return c`${this.#b()}${this._typing ?
|
|
1923
|
+
return c`${this.#b()}${this._typing ? W() : this.#ce()}`;
|
|
1851
1924
|
case "review":
|
|
1852
|
-
return c`${this.#b()}${this.#
|
|
1925
|
+
return c`${this.#b()}${this.#U()}`;
|
|
1853
1926
|
case "submitting":
|
|
1854
|
-
return c`${this.#b()}${this.#
|
|
1927
|
+
return c`${this.#b()}${this.#be()}`;
|
|
1855
1928
|
case "done":
|
|
1856
|
-
return c`${this.#b()}${this.#
|
|
1929
|
+
return c`${this.#b()}${this.#xe ? this.#_e() : c`${this.#ve()}${this.#we()}`}`;
|
|
1857
1930
|
default:
|
|
1858
1931
|
return f;
|
|
1859
1932
|
}
|
|
1860
1933
|
}
|
|
1861
|
-
#
|
|
1934
|
+
#le() {
|
|
1862
1935
|
const e = this._forms.filter((t) => t.listed !== !1);
|
|
1863
1936
|
return c`
|
|
1864
|
-
${
|
|
1865
|
-
<div class="options" role="group" aria-label=${
|
|
1866
|
-
${e.map((t,
|
|
1867
|
-
<button type="button" class="chip" style="animation-delay: ${60 +
|
|
1868
|
-
@click=${() => this.#
|
|
1937
|
+
${m(V, j, { noAnim: !0 })}
|
|
1938
|
+
<div class="options" role="group" aria-label=${Te}>
|
|
1939
|
+
${e.map((t, s) => c`
|
|
1940
|
+
<button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
|
|
1941
|
+
@click=${() => this.#E(t)}>${t.title}</button>
|
|
1869
1942
|
`)}
|
|
1870
1943
|
</div>
|
|
1871
1944
|
`;
|
|
@@ -1880,48 +1953,48 @@ class ar extends G {
|
|
|
1880
1953
|
const e = [];
|
|
1881
1954
|
if (!this._form) return e;
|
|
1882
1955
|
const t = this._origins[0]?.form || this._form;
|
|
1883
|
-
e.push(
|
|
1884
|
-
let
|
|
1885
|
-
for (const
|
|
1886
|
-
e.push(...this.#
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1956
|
+
e.push(m(V, j, { noAnim: !0 })), e.push(v(t.title, { noAnim: !0 })), this._notice && e.push(m(this._notice, "", { noAnim: !0 }));
|
|
1957
|
+
let s = null;
|
|
1958
|
+
for (const n of this._origins) {
|
|
1959
|
+
e.push(...this.#D(n.form, n.steps, s));
|
|
1960
|
+
const i = x(n.form, n.option.nodeId);
|
|
1961
|
+
i?.prompt && e.push(m(i.prompt, i.help, { noAnim: !0 })), s = n.option.label || n.option.optionId, e.push(v(s, { noAnim: !0 }));
|
|
1889
1962
|
}
|
|
1890
|
-
return e.push(...this.#
|
|
1891
|
-
}
|
|
1892
|
-
#
|
|
1893
|
-
const
|
|
1894
|
-
for (const
|
|
1895
|
-
if (
|
|
1896
|
-
const a =
|
|
1897
|
-
a !==
|
|
1963
|
+
return e.push(...this.#D(this._form, this._steps, s)), e;
|
|
1964
|
+
}
|
|
1965
|
+
#D(e, t, s = null) {
|
|
1966
|
+
const n = [];
|
|
1967
|
+
for (const i of t) {
|
|
1968
|
+
if (i.preset) {
|
|
1969
|
+
const a = i.label || i.optionId;
|
|
1970
|
+
a !== s && n.push(v(a, { noAnim: !0 }));
|
|
1898
1971
|
continue;
|
|
1899
1972
|
}
|
|
1900
|
-
const o = x(e,
|
|
1901
|
-
o?.prompt &&
|
|
1973
|
+
const o = x(e, i.nodeId);
|
|
1974
|
+
o?.prompt && n.push(m(o.prompt, o.help, { noAnim: !0 })), o?.type === "gate" && n.push(i.anonymous ? m(
|
|
1902
1975
|
"Last step: how can we reach you?",
|
|
1903
1976
|
"You chose to send this anonymously.",
|
|
1904
1977
|
{ noAnim: !0 }
|
|
1905
|
-
) :
|
|
1906
|
-
"
|
|
1978
|
+
) : m(
|
|
1979
|
+
"Almost done: verify your email so we can follow up.",
|
|
1907
1980
|
"One address, one code. No password needed.",
|
|
1908
1981
|
{ noAnim: !0 }
|
|
1909
|
-
)),
|
|
1982
|
+
)), i.kind === "choice" && n.push(v(i.label || i.optionId, { noAnim: !0 })), i.kind === "collect" && n.push(v(i.summary || "Details provided", { noAnim: !0 })), i.kind === "gate" && n.push(v(i.anonymous ? "Send anonymously" : i.email, { noAnim: !0 }));
|
|
1910
1983
|
}
|
|
1911
|
-
return
|
|
1984
|
+
return n;
|
|
1912
1985
|
}
|
|
1913
|
-
#
|
|
1914
|
-
const { node: e, error: t } = this.#
|
|
1915
|
-
return t || !e ?
|
|
1986
|
+
#ce() {
|
|
1987
|
+
const { node: e, error: t } = this.#_;
|
|
1988
|
+
return t || !e ? m("Something went sideways with this form.", "Please start over.", { error: !0 }) : e.type === "choice" ? this.#de(e) : e.type === "collect" ? this.#ue(e) : e.type === "gate" ? this.#P(e) : e.type === "redirect" ? this.#ye(e) : e.type === "terminal" ? this.#U() : f;
|
|
1916
1989
|
}
|
|
1917
|
-
#
|
|
1990
|
+
#de(e) {
|
|
1918
1991
|
return c`
|
|
1919
|
-
${
|
|
1920
|
-
${this._handoffError ?
|
|
1992
|
+
${m(e.prompt, e.help)}
|
|
1993
|
+
${this._handoffError ? m("We could not load the forms.", "Check your connection and try again.", { error: !0 }) : f}
|
|
1921
1994
|
<div class="options" role="group" aria-label=${e.prompt || "Choose one"}>
|
|
1922
|
-
${(e.options || []).map((t,
|
|
1923
|
-
<button type="button" class="chip" style="animation-delay: ${60 +
|
|
1924
|
-
@click=${() => this.#
|
|
1995
|
+
${(e.options || []).map((t, s) => c`
|
|
1996
|
+
<button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
|
|
1997
|
+
@click=${() => this.#H(e, t)}>${t.label}</button>
|
|
1925
1998
|
`)}
|
|
1926
1999
|
</div>
|
|
1927
2000
|
`;
|
|
@@ -1932,123 +2005,123 @@ class ar extends G {
|
|
|
1932
2005
|
* novalidate: the card validates itself (native url checks would
|
|
1933
2006
|
* otherwise block the submit silently).
|
|
1934
2007
|
*/
|
|
1935
|
-
#
|
|
2008
|
+
#ue(e) {
|
|
1936
2009
|
const t = e.fields || [];
|
|
1937
2010
|
return c`
|
|
1938
|
-
${
|
|
2011
|
+
${m(e.prompt, e.help)}
|
|
1939
2012
|
<form class="form-card" autocomplete="on" novalidate
|
|
1940
|
-
@submit=${(
|
|
1941
|
-
|
|
2013
|
+
@submit=${(s) => {
|
|
2014
|
+
s.preventDefault(), this.#j(e);
|
|
1942
2015
|
}}>
|
|
1943
|
-
${t.map((
|
|
2016
|
+
${t.map((s) => this.#he(e, s))}
|
|
1944
2017
|
<button type="submit" class="btn-primary">Continue</button>
|
|
1945
2018
|
</form>
|
|
1946
2019
|
`;
|
|
1947
2020
|
}
|
|
1948
|
-
#
|
|
1949
|
-
const
|
|
1950
|
-
if (t.kind === "consent" && t.requiredIf === "media" &&
|
|
2021
|
+
#he(e, t) {
|
|
2022
|
+
const s = this.#C(e.id);
|
|
2023
|
+
if (t.kind === "consent" && t.requiredIf === "media" && s === 0)
|
|
1951
2024
|
return f;
|
|
1952
|
-
const
|
|
2025
|
+
const n = this._cardValues[t.key], i = this._fieldErrors[t.key], o = !Se(t, { mediaCount: s }) && t.kind !== "consent" ? c` <span class="opt">optional</span>` : f, a = t.kind === "consent" ? f : c`
|
|
1953
2026
|
<label for="f-${t.key}">${t.label}${o}</label>
|
|
1954
2027
|
`;
|
|
1955
2028
|
return c`
|
|
1956
2029
|
<div class="field">
|
|
1957
2030
|
${a}
|
|
1958
|
-
${this.#
|
|
1959
|
-
${
|
|
2031
|
+
${this.#pe(e, t, n)}
|
|
2032
|
+
${i ? c`<div class="err" role="alert">${i}</div>` : f}
|
|
1960
2033
|
</div>
|
|
1961
2034
|
`;
|
|
1962
2035
|
}
|
|
1963
|
-
#
|
|
1964
|
-
const
|
|
2036
|
+
#pe(e, t, s) {
|
|
2037
|
+
const n = (i) => (o) => this.#k(i, o.target.value);
|
|
1965
2038
|
switch (t.kind) {
|
|
1966
2039
|
case "text":
|
|
1967
|
-
return c`<input type="text" id="f-${t.key}" name=${t.key} .value=${
|
|
2040
|
+
return c`<input type="text" id="f-${t.key}" name=${t.key} .value=${s || ""}
|
|
1968
2041
|
inputmode=${ce(t.inputMode)} autocomplete=${ce(t.autocomplete)}
|
|
1969
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2042
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
|
|
1970
2043
|
case "url":
|
|
1971
|
-
return c`<input type="url" id="f-${t.key}" .value=${
|
|
1972
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2044
|
+
return c`<input type="url" id="f-${t.key}" .value=${s || ""}
|
|
2045
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
|
|
1973
2046
|
case "textarea":
|
|
1974
|
-
return c`<textarea id="f-${t.key}" .value=${
|
|
1975
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2047
|
+
return c`<textarea id="f-${t.key}" .value=${s || ""}
|
|
2048
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}></textarea>`;
|
|
1976
2049
|
case "datetime":
|
|
1977
|
-
return c`<input type="datetime-local" id="f-${t.key}" .value=${
|
|
1978
|
-
@input=${
|
|
2050
|
+
return c`<input type="datetime-local" id="f-${t.key}" .value=${s || ""}
|
|
2051
|
+
@input=${n(t.key)}>`;
|
|
1979
2052
|
case "select":
|
|
1980
2053
|
return c`
|
|
1981
|
-
<select id="f-${t.key}" @change=${
|
|
2054
|
+
<select id="f-${t.key}" @change=${n(t.key)}>
|
|
1982
2055
|
<option value="">Choose one</option>
|
|
1983
|
-
${(t.options || []).map((
|
|
1984
|
-
<option value=${
|
|
2056
|
+
${(t.options || []).map((i) => c`
|
|
2057
|
+
<option value=${i.id} ?selected=${s === i.id}>${i.label}</option>
|
|
1985
2058
|
`)}
|
|
1986
2059
|
</select>
|
|
1987
2060
|
`;
|
|
1988
2061
|
case "location":
|
|
1989
|
-
return this.#
|
|
2062
|
+
return this.#fe(t, s || {});
|
|
1990
2063
|
case "consent":
|
|
1991
2064
|
return c`
|
|
1992
2065
|
<div class="consent-row">
|
|
1993
|
-
<input type="checkbox" id="f-${t.key}" .checked=${
|
|
1994
|
-
@change=${(
|
|
2066
|
+
<input type="checkbox" id="f-${t.key}" .checked=${s === !0}
|
|
2067
|
+
@change=${(i) => this.#k(t.key, i.target.checked)}>
|
|
1995
2068
|
<label for="f-${t.key}" style="all: unset; cursor: pointer;">
|
|
1996
|
-
${t.text ||
|
|
2069
|
+
${t.text || as}
|
|
1997
2070
|
</label>
|
|
1998
2071
|
</div>
|
|
1999
2072
|
`;
|
|
2000
2073
|
case "media":
|
|
2001
2074
|
return c`
|
|
2002
2075
|
<wral-report-media
|
|
2003
|
-
.files=${this.#
|
|
2004
|
-
.lostMeta=${this.#
|
|
2076
|
+
.files=${this.#s[e.id] || []}
|
|
2077
|
+
.lostMeta=${this.#r[e.id] || []}
|
|
2005
2078
|
.budget=${this._form.budget || {}}
|
|
2006
2079
|
?required=${!!t.required}
|
|
2007
2080
|
label=${t.label}
|
|
2008
|
-
@files-changed=${(
|
|
2009
|
-
this.#
|
|
2081
|
+
@files-changed=${(i) => {
|
|
2082
|
+
this.#s = { ...this.#s, [e.id]: i.detail.files }, this.requestUpdate();
|
|
2010
2083
|
}}></wral-report-media>
|
|
2011
2084
|
`;
|
|
2012
2085
|
default:
|
|
2013
2086
|
return f;
|
|
2014
2087
|
}
|
|
2015
2088
|
}
|
|
2016
|
-
#
|
|
2017
|
-
const
|
|
2089
|
+
#fe(e, t) {
|
|
2090
|
+
const s = e.counties || Xt, n = (i) => this.#k(e.key, { ...t, ...i });
|
|
2018
2091
|
return c`
|
|
2019
2092
|
<select id="f-${e.key}" aria-label="County"
|
|
2020
|
-
@change=${(
|
|
2093
|
+
@change=${(i) => n({ county: i.target.value || void 0 })}>
|
|
2021
2094
|
<option value="">Choose a county</option>
|
|
2022
|
-
${
|
|
2023
|
-
<option value=${
|
|
2095
|
+
${s.map((i) => c`
|
|
2096
|
+
<option value=${i} ?selected=${t.county === i}>${i}</option>
|
|
2024
2097
|
`)}
|
|
2025
2098
|
</select>
|
|
2026
2099
|
<input type="text" style="margin-top: 8px;"
|
|
2027
2100
|
aria-label="Nearest town or crossroads"
|
|
2028
2101
|
placeholder="Nearest town or crossroads"
|
|
2029
2102
|
.value=${t.where || ""}
|
|
2030
|
-
@input=${(
|
|
2103
|
+
@input=${(i) => n({ where: i.target.value || void 0 })}>
|
|
2031
2104
|
`;
|
|
2032
2105
|
}
|
|
2033
|
-
#
|
|
2034
|
-
this.#
|
|
2035
|
-
const t = this._gate,
|
|
2036
|
-
"
|
|
2106
|
+
#P(e) {
|
|
2107
|
+
this.#T();
|
|
2108
|
+
const t = this._gate, s = m(
|
|
2109
|
+
"Almost done: verify your email so we can follow up.",
|
|
2037
2110
|
"One address, one code. No password needed."
|
|
2038
2111
|
);
|
|
2039
2112
|
return t.stage ? t.stage === "signedin" ? c`
|
|
2040
|
-
${
|
|
2113
|
+
${s}
|
|
2041
2114
|
<div class="form-card">
|
|
2042
2115
|
<p style="margin: 0 0 12px; font-size: 14.5px;">
|
|
2043
2116
|
You are signed in as <strong>${t.email || "your My WRAL account"}</strong> on this device.
|
|
2044
2117
|
</p>
|
|
2045
2118
|
<button type="button" class="btn-primary"
|
|
2046
|
-
@click=${() => this.#
|
|
2119
|
+
@click=${() => this.#O(t.email)}>Continue</button>
|
|
2047
2120
|
<button type="button" class="btn-ghost"
|
|
2048
|
-
@click=${() => this.#
|
|
2121
|
+
@click=${() => this.#Y()}>Use a different email</button>
|
|
2049
2122
|
</div>
|
|
2050
2123
|
` : t.stage === "email" ? c`
|
|
2051
|
-
${
|
|
2124
|
+
${s}
|
|
2052
2125
|
<div class="form-card login-card">
|
|
2053
2126
|
<h2>Sign in or create account</h2>
|
|
2054
2127
|
<p class="login-sub">
|
|
@@ -2058,16 +2131,16 @@ class ar extends G {
|
|
|
2058
2131
|
<label for="gate-email">Email address</label>
|
|
2059
2132
|
<input type="email" id="gate-email" autocomplete="email"
|
|
2060
2133
|
placeholder="you@example.com" .value=${t.email}
|
|
2061
|
-
@input=${(
|
|
2062
|
-
this._gate = { ...t, email:
|
|
2134
|
+
@input=${(n) => {
|
|
2135
|
+
this._gate = { ...t, email: n.target.value };
|
|
2063
2136
|
}}
|
|
2064
|
-
@keydown=${(
|
|
2065
|
-
|
|
2137
|
+
@keydown=${(n) => {
|
|
2138
|
+
n.key === "Enter" && this.#A();
|
|
2066
2139
|
}}>
|
|
2067
2140
|
</div>
|
|
2068
2141
|
${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
|
|
2069
2142
|
<button type="button" class="login-btn" ?disabled=${t.loading}
|
|
2070
|
-
@click=${() => this.#
|
|
2143
|
+
@click=${() => this.#A()}>
|
|
2071
2144
|
${t.loading ? "Sending…" : "Continue with email"}
|
|
2072
2145
|
</button>
|
|
2073
2146
|
<div class="login-why">
|
|
@@ -2076,13 +2149,13 @@ class ar extends G {
|
|
|
2076
2149
|
<li>We can follow up on your report</li>
|
|
2077
2150
|
<li>Your contact information fills in automatically next time</li>
|
|
2078
2151
|
<li>You are credited by name when we use your photos or video</li>
|
|
2079
|
-
<li><a href=${
|
|
2152
|
+
<li><a href=${es} target="_blank" rel="noopener">All other My WRAL account benefits</a></li>
|
|
2080
2153
|
</ul>
|
|
2081
2154
|
</div>
|
|
2082
|
-
${this._submit.stage === "auth" ? f : this.#
|
|
2155
|
+
${this._submit.stage === "auth" ? f : this.#ge()}
|
|
2083
2156
|
</div>
|
|
2084
|
-
` : t.stage === "anon-confirm" ? this.#
|
|
2085
|
-
${
|
|
2157
|
+
` : t.stage === "anon-confirm" ? this.#me(s) : c`
|
|
2158
|
+
${s}
|
|
2086
2159
|
<div class="form-card login-card">
|
|
2087
2160
|
<h2>Enter verification code</h2>
|
|
2088
2161
|
<p class="login-sub">We sent a 6-digit code to <strong>${t.email}</strong></p>
|
|
@@ -2095,39 +2168,39 @@ class ar extends G {
|
|
|
2095
2168
|
<div class="field">
|
|
2096
2169
|
<label>Verification code</label>
|
|
2097
2170
|
<wral-code-input
|
|
2098
|
-
@code-complete=${(
|
|
2171
|
+
@code-complete=${(n) => this.#R(n.detail?.code ?? n.detail?.value ?? n.target.value)}>
|
|
2099
2172
|
</wral-code-input>
|
|
2100
2173
|
</div>
|
|
2101
2174
|
${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
|
|
2102
2175
|
<button type="button" class="login-btn" ?disabled=${t.loading}
|
|
2103
2176
|
@click=${() => {
|
|
2104
|
-
const
|
|
2105
|
-
this.#
|
|
2177
|
+
const n = this.renderRoot.querySelector("wral-code-input");
|
|
2178
|
+
this.#R(n?.value || "");
|
|
2106
2179
|
}}>
|
|
2107
2180
|
${t.loading ? "Checking…" : "Sign in"}
|
|
2108
2181
|
</button>
|
|
2109
2182
|
<p class="login-help">
|
|
2110
2183
|
Didn’t receive a code? Check your spam folder or
|
|
2111
|
-
<button type="button" @click=${() => this.#
|
|
2184
|
+
<button type="button" @click=${() => this.#A()}>resend a new code</button>.
|
|
2112
2185
|
</p>
|
|
2113
2186
|
</div>
|
|
2114
|
-
` : c`${
|
|
2187
|
+
` : c`${s}${W()}`;
|
|
2115
2188
|
}
|
|
2116
2189
|
/* Collapsed by default: findable for whoever needs it, never the
|
|
2117
2190
|
* first thing a viewer reaches for. */
|
|
2118
|
-
#
|
|
2191
|
+
#ge() {
|
|
2119
2192
|
return c`
|
|
2120
2193
|
<details class="login-alt">
|
|
2121
2194
|
<summary>Other ways to send this</summary>
|
|
2122
2195
|
<div class="alt-body">
|
|
2123
2196
|
<p class="alt-row">
|
|
2124
2197
|
Call the newsroom desk at
|
|
2125
|
-
<a href=${
|
|
2198
|
+
<a href=${ss(xe)}>${xe}</a>.
|
|
2126
2199
|
</p>
|
|
2127
|
-
${this.#
|
|
2200
|
+
${this.#L ? c`
|
|
2128
2201
|
<p class="alt-row">
|
|
2129
2202
|
<button type="button" class="alt-link"
|
|
2130
|
-
@click=${() => this.#
|
|
2203
|
+
@click=${() => this.#G()}>Send this anonymously</button>
|
|
2131
2204
|
— no follow-up, and no credit if we use your photos or video.
|
|
2132
2205
|
</p>
|
|
2133
2206
|
` : f}
|
|
@@ -2135,7 +2208,7 @@ class ar extends G {
|
|
|
2135
2208
|
</details>
|
|
2136
2209
|
`;
|
|
2137
2210
|
}
|
|
2138
|
-
#
|
|
2211
|
+
#me(e) {
|
|
2139
2212
|
return c`
|
|
2140
2213
|
${e}
|
|
2141
2214
|
<div class="form-card login-card">
|
|
@@ -2144,20 +2217,20 @@ class ar extends G {
|
|
|
2144
2217
|
You can send this report without an account. Here is what it costs you.
|
|
2145
2218
|
</p>
|
|
2146
2219
|
<ul class="anon-costs">
|
|
2147
|
-
${
|
|
2220
|
+
${ts.map((t) => c`
|
|
2148
2221
|
<li><span class="x" aria-hidden="true">✕</span><span>${t}</span></li>
|
|
2149
2222
|
`)}
|
|
2150
2223
|
</ul>
|
|
2151
2224
|
<div class="anon-actions">
|
|
2152
2225
|
<button type="button" class="login-btn"
|
|
2153
|
-
@click=${() => this.#
|
|
2226
|
+
@click=${() => this.#K()}>Sign in instead</button>
|
|
2154
2227
|
<button type="button" class="btn-ghost"
|
|
2155
|
-
@click=${() => this.#
|
|
2228
|
+
@click=${() => this.#Q()}>Continue anonymously</button>
|
|
2156
2229
|
</div>
|
|
2157
2230
|
</div>
|
|
2158
2231
|
`;
|
|
2159
2232
|
}
|
|
2160
|
-
#
|
|
2233
|
+
#ye(e) {
|
|
2161
2234
|
const t = e.redirect || {};
|
|
2162
2235
|
return c`
|
|
2163
2236
|
<div class="form-card">
|
|
@@ -2176,16 +2249,16 @@ class ar extends G {
|
|
|
2176
2249
|
</div>
|
|
2177
2250
|
`;
|
|
2178
2251
|
}
|
|
2179
|
-
#
|
|
2180
|
-
const e =
|
|
2252
|
+
#U() {
|
|
2253
|
+
const e = Vt(this._form, this._steps);
|
|
2181
2254
|
return c`
|
|
2182
|
-
${
|
|
2255
|
+
${m("Here is what you are sending.", "Check it over, then submit.")}
|
|
2183
2256
|
<div class="form-card">
|
|
2184
2257
|
<ul class="review-list">
|
|
2185
2258
|
${e.map((t) => c`
|
|
2186
2259
|
<li>
|
|
2187
2260
|
<span class="k">${t.k}</span>
|
|
2188
|
-
<span>${t.pill ?
|
|
2261
|
+
<span>${t.pill ? ot(t.pill) : t.v}</span>
|
|
2189
2262
|
</li>
|
|
2190
2263
|
`)}
|
|
2191
2264
|
</ul>
|
|
@@ -2193,16 +2266,16 @@ class ar extends G {
|
|
|
2193
2266
|
<div class="err" role="alert" style="margin-top: 12px;">${this._banner.message}</div>
|
|
2194
2267
|
` : f}
|
|
2195
2268
|
<div style="margin-top: 16px;">
|
|
2196
|
-
<button type="button" class="btn-primary" @click=${() => this.#
|
|
2269
|
+
<button type="button" class="btn-primary" @click=${() => this.#J()}>
|
|
2197
2270
|
Submit report
|
|
2198
2271
|
</button>
|
|
2199
2272
|
</div>
|
|
2200
2273
|
</div>
|
|
2201
2274
|
`;
|
|
2202
2275
|
}
|
|
2203
|
-
#
|
|
2276
|
+
#be() {
|
|
2204
2277
|
const e = this._submit;
|
|
2205
|
-
if (e.stage === "auth") return this.#
|
|
2278
|
+
if (e.stage === "auth") return this.#P({ id: null, type: "gate" });
|
|
2206
2279
|
const t = {
|
|
2207
2280
|
minting: "Preparing your uploads…",
|
|
2208
2281
|
uploading: "Uploading your files…",
|
|
@@ -2211,21 +2284,21 @@ class ar extends G {
|
|
|
2211
2284
|
"requesting-error": this._banner?.message || "We could not send your report."
|
|
2212
2285
|
}[e.stage] || "Working…";
|
|
2213
2286
|
return c`
|
|
2214
|
-
${
|
|
2287
|
+
${m("Submitting your report.", t)}
|
|
2215
2288
|
<div class="form-card">
|
|
2216
|
-
${e.files.map((
|
|
2289
|
+
${e.files.map((s, n) => c`
|
|
2217
2290
|
<div class="upload-row">
|
|
2218
|
-
<span class="name">${
|
|
2291
|
+
<span class="name">${s.name}</span>
|
|
2219
2292
|
<div class="upload-bar" role="progressbar"
|
|
2220
2293
|
aria-valuemin="0" aria-valuemax="100"
|
|
2221
|
-
aria-valuenow=${Math.round((
|
|
2222
|
-
<div class="fill" style="width: ${(
|
|
2294
|
+
aria-valuenow=${Math.round((s.status === "done" ? 1 : s.progress) * 100)}>
|
|
2295
|
+
<div class="fill" style="width: ${(s.status === "done" ? 1 : s.progress) * 100}%"></div>
|
|
2223
2296
|
</div>
|
|
2224
|
-
<span class="state ${
|
|
2225
|
-
${
|
|
2297
|
+
<span class="state ${s.status === "failed" ? "failed" : ""}">
|
|
2298
|
+
${s.status === "done" ? "Done" : s.status === "failed" ? "Failed" : "Uploading"}
|
|
2226
2299
|
</span>
|
|
2227
|
-
${
|
|
2228
|
-
<button type="button" class="retry-chip" @click=${() => this.#
|
|
2300
|
+
${s.status === "failed" ? c`
|
|
2301
|
+
<button type="button" class="retry-chip" @click=${() => this.#te(n)}>
|
|
2229
2302
|
Retry
|
|
2230
2303
|
</button>
|
|
2231
2304
|
` : f}
|
|
@@ -2238,26 +2311,21 @@ class ar extends G {
|
|
|
2238
2311
|
${Math.ceil(this._banner.retryAfter / 60)} minutes.</div>
|
|
2239
2312
|
` : f}
|
|
2240
2313
|
<button type="button" class="btn-primary" style="margin-top: 8px;"
|
|
2241
|
-
@click=${() => this.#
|
|
2314
|
+
@click=${() => this.#oe()}>Try again</button>
|
|
2242
2315
|
` : f}
|
|
2243
|
-
${
|
|
2316
|
+
${we(e).length && e.stage === "uploading-error" ? c`
|
|
2244
2317
|
<div class="err" role="alert">Retry the failed
|
|
2245
|
-
${
|
|
2318
|
+
${we(e).length === 1 ? "file" : "files"} to continue.</div>
|
|
2246
2319
|
` : f}
|
|
2247
2320
|
</div>
|
|
2248
2321
|
`;
|
|
2249
2322
|
}
|
|
2250
|
-
#
|
|
2251
|
-
const e =
|
|
2252
|
-
routing: this._result?.routing || {},
|
|
2253
|
-
flags: e,
|
|
2254
|
-
reference: this._result?.reference || "",
|
|
2255
|
-
anonymous: this.#f
|
|
2256
|
-
});
|
|
2323
|
+
#we() {
|
|
2324
|
+
const e = Ie(this._form, this._steps), t = jt(this._result, e);
|
|
2257
2325
|
return c`
|
|
2258
2326
|
<div class="confirm-card">
|
|
2259
2327
|
<div class="c-head">
|
|
2260
|
-
<div class="c-check">${
|
|
2328
|
+
<div class="c-check">${at()}</div>
|
|
2261
2329
|
<div>
|
|
2262
2330
|
<div class="eyebrow">Report received</div>
|
|
2263
2331
|
<h2>${t.title}</h2>
|
|
@@ -2265,39 +2333,72 @@ class ar extends G {
|
|
|
2265
2333
|
</div>
|
|
2266
2334
|
<p>${t.body}</p>
|
|
2267
2335
|
${t.urgentNote ? c`<p>${t.urgentNote}</p>` : f}
|
|
2336
|
+
${this._factsOffer?.stage === "saved" ? c`
|
|
2337
|
+
<p role="status">Your ${this.#z} ${this._factsOffer.facts.length === 1 ? "is" : "are"}
|
|
2338
|
+
saved to your My WRAL account.</p>
|
|
2339
|
+
` : f}
|
|
2268
2340
|
<div class="refs">
|
|
2269
2341
|
<span class="ref"><span class="rk">Reference</span>${this._result?.reference || ""}</span>
|
|
2270
2342
|
</div>
|
|
2271
|
-
<button type="button" class="c-again" @click=${() => this
|
|
2343
|
+
<button type="button" class="c-again" @click=${() => this.#$()}>
|
|
2272
2344
|
Start a new report
|
|
2273
2345
|
</button>
|
|
2274
2346
|
</div>
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2347
|
+
`;
|
|
2348
|
+
}
|
|
2349
|
+
/* The offer is a step of its own: the confirmation waits for Save or No thanks. */
|
|
2350
|
+
get #xe() {
|
|
2351
|
+
return ["offer", "saving", "error"].includes(this._factsOffer?.stage);
|
|
2352
|
+
}
|
|
2353
|
+
get #z() {
|
|
2354
|
+
return (this._factsOffer?.facts || []).map((e) => e.label.toLowerCase()).join(" and ");
|
|
2355
|
+
}
|
|
2356
|
+
#ve() {
|
|
2357
|
+
const e = this._factsOffer?.stage;
|
|
2358
|
+
return e === "saved" ? v("Save to my account", { noAnim: !0 }) : e === "dismissed" ? v("No thanks", { noAnim: !0 }) : f;
|
|
2359
|
+
}
|
|
2360
|
+
#_e() {
|
|
2361
|
+
const e = this._factsOffer, t = e.stage === "saving";
|
|
2362
|
+
return c`
|
|
2363
|
+
${m(
|
|
2364
|
+
`One more step: save your ${this.#z} to your new My WRAL account?`,
|
|
2365
|
+
"Only what is listed here is saved."
|
|
2366
|
+
)}
|
|
2367
|
+
<div class="form-card facts-offer">
|
|
2368
|
+
<dl>
|
|
2369
|
+
${e.facts.map((s) => c`<dt>${s.label}</dt><dd>${s.value}</dd>`)}
|
|
2370
|
+
</dl>
|
|
2371
|
+
<p class="facts-note">
|
|
2372
|
+
${lt()}
|
|
2373
|
+
<span>${e.facts.length === 1 ? "This is saved to your My WRAL dashboard, where you can change it anytime." : "These are saved to your My WRAL dashboard, where you can change them anytime."}</span>
|
|
2374
|
+
</p>
|
|
2375
|
+
${e.stage === "error" ? c`
|
|
2376
|
+
<div class="err" role="alert">We couldn't save these. Please try again.</div>
|
|
2377
|
+
` : f}
|
|
2378
|
+
<div class="actions">
|
|
2379
|
+
<button type="button" class="btn-primary" ?disabled=${t}
|
|
2380
|
+
@click=${() => this.#ne()}>
|
|
2381
|
+
${t ? "Saving…" : e.stage === "error" ? "Try again" : "Save to my account"}
|
|
2382
|
+
</button>
|
|
2383
|
+
<button type="button" class="btn-ghost" ?disabled=${t}
|
|
2384
|
+
@click=${() => {
|
|
2385
|
+
this._factsOffer = { ...e, stage: "dismissed" };
|
|
2386
|
+
}}>
|
|
2387
|
+
No thanks
|
|
2388
|
+
</button>
|
|
2389
|
+
</div>
|
|
2289
2390
|
</div>
|
|
2290
2391
|
`;
|
|
2291
2392
|
}
|
|
2292
|
-
|
|
2393
|
+
#$e() {
|
|
2293
2394
|
const e = this._phase === "submitting" || this._phase === "done" || this._phase === "loading" || this._phase === "load-error";
|
|
2294
2395
|
return c`
|
|
2295
2396
|
<div class="bottom-bar">
|
|
2296
2397
|
<div class="inner">
|
|
2297
2398
|
<button type="button" class="btn-ghost" ?disabled=${e || this._phase === "pick"}
|
|
2298
|
-
@click=${() => this.#
|
|
2399
|
+
@click=${() => this.#V()}>← Back</button>
|
|
2299
2400
|
<button type="button" class="btn-ghost" ?disabled=${this._phase === "submitting"}
|
|
2300
|
-
@click=${() => this
|
|
2401
|
+
@click=${() => this.#$()}>Start over</button>
|
|
2301
2402
|
<span class="note">Your report goes to a person on the right desk.</span>
|
|
2302
2403
|
</div>
|
|
2303
2404
|
</div>
|
|
@@ -2307,7 +2408,7 @@ class ar extends G {
|
|
|
2307
2408
|
this.renderRoot?.querySelector(".chat")?.lastElementChild?.scrollIntoView?.({ block: "nearest" });
|
|
2308
2409
|
}
|
|
2309
2410
|
}
|
|
2310
|
-
class
|
|
2411
|
+
class gs extends G {
|
|
2311
2412
|
static properties = {
|
|
2312
2413
|
files: { attribute: !1 },
|
|
2313
2414
|
lostMeta: { attribute: !1 },
|
|
@@ -2315,7 +2416,7 @@ class lr extends G {
|
|
|
2315
2416
|
required: { type: Boolean },
|
|
2316
2417
|
label: { type: String }
|
|
2317
2418
|
};
|
|
2318
|
-
static styles =
|
|
2419
|
+
static styles = b`
|
|
2319
2420
|
:host { display: block; }
|
|
2320
2421
|
input[type=file] { font-family: inherit; font-size: 14px; }
|
|
2321
2422
|
.file-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
|
|
@@ -2364,13 +2465,13 @@ class lr extends G {
|
|
|
2364
2465
|
@change=${this.#u}>
|
|
2365
2466
|
${e.length ? c`
|
|
2366
2467
|
<ul class="file-list">
|
|
2367
|
-
${e.map((
|
|
2468
|
+
${e.map((s, n) => c`
|
|
2368
2469
|
<li>
|
|
2369
|
-
<span>${
|
|
2370
|
-
<span class="size">${
|
|
2470
|
+
<span>${s.name}</span>
|
|
2471
|
+
<span class="size">${ls(s.size)}</span>
|
|
2371
2472
|
<button type="button" class="remove"
|
|
2372
|
-
aria-label="Remove ${
|
|
2373
|
-
@click=${() => this.#t(
|
|
2473
|
+
aria-label="Remove ${s.name}"
|
|
2474
|
+
@click=${() => this.#t(n)}>✕</button>
|
|
2374
2475
|
</li>
|
|
2375
2476
|
`)}
|
|
2376
2477
|
</ul>
|
|
@@ -2378,47 +2479,47 @@ class lr extends G {
|
|
|
2378
2479
|
${(this.lostMeta || []).length ? c`
|
|
2379
2480
|
<div class="lost">
|
|
2380
2481
|
Please re-attach your ${this.lostMeta.length === 1 ? "file" : "files"}
|
|
2381
|
-
(${this.lostMeta.map((
|
|
2482
|
+
(${this.lostMeta.map((s) => s.name).join(", ")}) —
|
|
2382
2483
|
attachments can't be saved between visits.
|
|
2383
2484
|
</div>
|
|
2384
2485
|
` : f}
|
|
2385
|
-
${t.map((
|
|
2486
|
+
${t.map((s) => c`<div class="err">${s.message}</div>`)}
|
|
2386
2487
|
`;
|
|
2387
2488
|
}
|
|
2388
2489
|
}
|
|
2389
|
-
function
|
|
2390
|
-
return Number.isFinite(
|
|
2490
|
+
function ls(r) {
|
|
2491
|
+
return Number.isFinite(r) ? r >= 1024 * 1024 ? `${(r / (1024 * 1024)).toFixed(1)} MB` : r >= 1024 ? `${Math.round(r / 1024)} KB` : `${r} B` : "";
|
|
2391
2492
|
}
|
|
2392
|
-
const
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2395
|
-
const o =
|
|
2396
|
-
return
|
|
2397
|
-
},
|
|
2493
|
+
const cs = (r, e, t, s) => {
|
|
2494
|
+
const n = e.target.value.replace(/\D/g, "").slice(-1), i = [...t];
|
|
2495
|
+
i[r] = n;
|
|
2496
|
+
const o = i.join(""), a = i.every((l) => l !== "");
|
|
2497
|
+
return s("code-change", { value: o, complete: a }), n && a && s("code-complete", { value: o }), i;
|
|
2498
|
+
}, ds = (r, e, t, s) => {
|
|
2398
2499
|
if (e.key === "Backspace") {
|
|
2399
|
-
const
|
|
2400
|
-
!
|
|
2401
|
-
const
|
|
2402
|
-
return
|
|
2500
|
+
const n = [...t];
|
|
2501
|
+
!n[r] && r > 0 ? n[r - 1] = "" : n[r] && (n[r] = "");
|
|
2502
|
+
const i = n.join("");
|
|
2503
|
+
return s("code-change", { value: i, complete: !1 }), n;
|
|
2403
2504
|
}
|
|
2404
2505
|
return t;
|
|
2405
|
-
},
|
|
2406
|
-
|
|
2407
|
-
const
|
|
2408
|
-
if (
|
|
2409
|
-
const
|
|
2410
|
-
for (let a = 0; a <
|
|
2411
|
-
|
|
2412
|
-
const
|
|
2413
|
-
return t("code-change", { value:
|
|
2506
|
+
}, us = (r, e, t) => {
|
|
2507
|
+
r.preventDefault();
|
|
2508
|
+
const s = r.clipboardData.getData("text").replace(/\D/g, "").slice(0, 6);
|
|
2509
|
+
if (s.length === 0) return e;
|
|
2510
|
+
const n = [...e];
|
|
2511
|
+
for (let a = 0; a < s.length && a < 6; a++)
|
|
2512
|
+
n[a] = s[a];
|
|
2513
|
+
const i = n.join(""), o = n.every((a) => a !== "");
|
|
2514
|
+
return t("code-change", { value: i, complete: o }), s.length === 6 && t("code-complete", { value: i }), n;
|
|
2414
2515
|
};
|
|
2415
|
-
class
|
|
2516
|
+
class ms extends G {
|
|
2416
2517
|
static formAssociated = !0;
|
|
2417
2518
|
static properties = {
|
|
2418
2519
|
_values: { type: Array, state: !0 },
|
|
2419
2520
|
disabled: { type: Boolean, reflect: !0 }
|
|
2420
2521
|
};
|
|
2421
|
-
static styles =
|
|
2522
|
+
static styles = b`
|
|
2422
2523
|
:host {
|
|
2423
2524
|
display: block;
|
|
2424
2525
|
width: 100%;
|
|
@@ -2517,7 +2618,7 @@ class cr extends G {
|
|
|
2517
2618
|
this.getInputs()[e]?.focus();
|
|
2518
2619
|
}
|
|
2519
2620
|
inputHandler(e, t) {
|
|
2520
|
-
this._values =
|
|
2621
|
+
this._values = cs(
|
|
2521
2622
|
e,
|
|
2522
2623
|
t,
|
|
2523
2624
|
this._values,
|
|
@@ -2526,17 +2627,17 @@ class cr extends G {
|
|
|
2526
2627
|
}
|
|
2527
2628
|
keydownHandler(e, t) {
|
|
2528
2629
|
if (t.key === "Backspace") {
|
|
2529
|
-
const
|
|
2530
|
-
this._values =
|
|
2630
|
+
const s = !this._values[e];
|
|
2631
|
+
this._values = ds(
|
|
2531
2632
|
e,
|
|
2532
2633
|
t,
|
|
2533
2634
|
this._values,
|
|
2534
2635
|
this.dispatchCustomEvent.bind(this)
|
|
2535
|
-
),
|
|
2636
|
+
), s && e > 0 && this.focusInput(e - 1);
|
|
2536
2637
|
}
|
|
2537
2638
|
}
|
|
2538
2639
|
pasteHandler(e) {
|
|
2539
|
-
this._values =
|
|
2640
|
+
this._values = us(e, this._values, this.dispatchCustomEvent.bind(this));
|
|
2540
2641
|
}
|
|
2541
2642
|
render() {
|
|
2542
2643
|
return c`
|
|
@@ -2561,10 +2662,10 @@ class cr extends G {
|
|
|
2561
2662
|
}
|
|
2562
2663
|
}
|
|
2563
2664
|
export {
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2665
|
+
ms as W,
|
|
2666
|
+
gs as a,
|
|
2667
|
+
fs as b,
|
|
2668
|
+
xt as c,
|
|
2669
|
+
dt as d,
|
|
2670
|
+
vt as e
|
|
2570
2671
|
};
|