@wral/report-it 0.2.1 → 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 +1 -3
- package/dist/define.mjs +1 -1
- package/dist/define.standalone.js +421 -512
- package/dist/index.mjs +1 -1
- package/dist/{wral-code-input-BH_1EP8b.js → wral-code-input-BA1oCHMu.js} +499 -590
- package/package.json +1 -1
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { css as b, html as c, nothing as
|
|
2
|
-
import { getAuthContext as Re, createStorage as
|
|
3
|
-
const K = globalThis, se = (r) => r,
|
|
4
|
-
\f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
5
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g, $e = /^(?:script|style|textarea|title)$/i,
|
|
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
6
|
function ke(r, e) {
|
|
7
7
|
if (!Q(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
8
8
|
return re !== void 0 ? re.createHTML(e) : e;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const He = (r, e) => {
|
|
11
11
|
const t = r.length - 1, s = [];
|
|
12
|
-
let
|
|
12
|
+
let n, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", o = C;
|
|
13
13
|
for (let a = 0; a < t; a++) {
|
|
14
14
|
const l = r[a];
|
|
15
|
-
let d,
|
|
16
|
-
for (;
|
|
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
17
|
const y = o === k && r[a + 1].startsWith("/>") ? " " : "";
|
|
18
|
-
|
|
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 [ke(r,
|
|
20
|
+
return [ke(r, i + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
|
|
21
21
|
};
|
|
22
|
-
class
|
|
22
|
+
class M {
|
|
23
23
|
constructor({ strings: e, _$litType$: t }, s) {
|
|
24
|
-
let
|
|
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(_) && (l.push({ type: 6, index:
|
|
38
|
-
if ($e.test(
|
|
39
|
-
const u =
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
for (let y = 0; y <
|
|
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) {
|
|
@@ -57,12 +57,12 @@ class O {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function E(r, e, t = r, s) {
|
|
60
|
-
if (e ===
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
return
|
|
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 He {
|
|
|
73
73
|
return this._$AM._$AU;
|
|
74
74
|
}
|
|
75
75
|
u(e) {
|
|
76
|
-
const { el: { content: t }, parts: s } = this._$AD,
|
|
77
|
-
A.currentNode =
|
|
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 A.currentNode = F,
|
|
86
|
+
return A.currentNode = F, n;
|
|
87
87
|
}
|
|
88
88
|
p(e) {
|
|
89
89
|
let t = 0;
|
|
90
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, s,
|
|
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 B {
|
|
|
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,26 +118,26 @@ class B {
|
|
|
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$: s } = e,
|
|
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 s,
|
|
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; ) {
|
|
@@ -149,55 +149,55 @@ class B {
|
|
|
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, s,
|
|
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, s,
|
|
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, s,
|
|
195
|
-
super(e, t, s,
|
|
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 s = this._$AH,
|
|
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);
|
|
@@ -215,8 +215,8 @@ class Ye {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
const Ge = K.litHtmlPolyfillSupport;
|
|
218
|
-
Ge?.(
|
|
219
|
-
const ce = (r) => r ??
|
|
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;
|
|
@@ -253,7 +253,7 @@ const ce = (r) => r ?? m, Ke = b`
|
|
|
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,7 +267,7 @@ const ce = (r) => r ?? m, Ke = b`
|
|
|
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
|
}
|
|
@@ -573,47 +573,6 @@ const ce = (r) => r ?? m, Ke = b`
|
|
|
573
573
|
color: var(--wral-base-primary-1, #001D68);
|
|
574
574
|
}
|
|
575
575
|
.facts-offer .actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
576
|
-
`, it = b`
|
|
577
|
-
.journey {
|
|
578
|
-
align-self: stretch;
|
|
579
|
-
background: var(--wral-semantic-surface-default, #FFFFFF);
|
|
580
|
-
border: 1px solid var(--wral-semantic-border-muted, #E2E8F0);
|
|
581
|
-
border-radius: 12px; padding: 20px 22px;
|
|
582
|
-
box-shadow: 0 1px 2px rgba(3, 7, 17, 0.07), 0 6px 16px rgba(3, 7, 17, 0.05);
|
|
583
|
-
}
|
|
584
|
-
.j-eyebrow {
|
|
585
|
-
font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
|
|
586
|
-
font-size: 12px; font-weight: 700; text-transform: uppercase;
|
|
587
|
-
letter-spacing: 0.08em;
|
|
588
|
-
color: var(--wral-base-red-on-light, #D1232A);
|
|
589
|
-
margin-bottom: 2px;
|
|
590
|
-
}
|
|
591
|
-
.j-title {
|
|
592
|
-
font-family: var(--wral-base-font-display, 'IBM Plex Sans Condensed', sans-serif);
|
|
593
|
-
font-size: 18px; font-weight: 700;
|
|
594
|
-
color: var(--wral-base-primary-1, #001D68); margin: 0 0 10px;
|
|
595
|
-
}
|
|
596
|
-
.j-step { position: relative; display: flex; gap: 12px; padding: 9px 0; }
|
|
597
|
-
.j-step:not(:last-child)::before {
|
|
598
|
-
content: ''; position: absolute; left: 12px; top: 38px; bottom: -6px;
|
|
599
|
-
width: 1.5px; background: var(--wral-semantic-border-default, #CBD5E1);
|
|
600
|
-
}
|
|
601
|
-
.j-dot {
|
|
602
|
-
flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
|
|
603
|
-
background: var(--wral-semantic-surface-sunken, #F1F5F9);
|
|
604
|
-
border: 1.5px solid var(--wral-base-secondary-1, #2594E3);
|
|
605
|
-
color: var(--wral-base-primary-1, #001D68);
|
|
606
|
-
font-family: var(--wral-base-font-mono, 'IBM Plex Mono', monospace);
|
|
607
|
-
font-size: 11px;
|
|
608
|
-
display: flex; align-items: center; justify-content: center;
|
|
609
|
-
position: relative; z-index: 1;
|
|
610
|
-
}
|
|
611
|
-
.j-body .j-t {
|
|
612
|
-
font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
|
|
613
|
-
font-size: 14.5px; font-weight: 700;
|
|
614
|
-
color: var(--wral-base-primary-1, #001D68); margin-bottom: 2px;
|
|
615
|
-
}
|
|
616
|
-
.j-body .j-d { font-size: 13.5px; color: var(--wral-semantic-fg-muted, #475569); line-height: 1.55; }
|
|
617
576
|
`, nt = b`
|
|
618
577
|
.bottom-bar {
|
|
619
578
|
position: sticky; bottom: 0; z-index: 20;
|
|
@@ -627,32 +586,32 @@ const ce = (r) => r ?? m, Ke = b`
|
|
|
627
586
|
}
|
|
628
587
|
.bottom-bar .note { margin-left: auto; font-size: 12px; color: var(--wral-semantic-fg-subtle, #64748B); }
|
|
629
588
|
@media (max-width: 540px) { .bottom-bar .note { display: none; } }
|
|
630
|
-
`,
|
|
631
|
-
function
|
|
589
|
+
`, it = [Ke, Qe, Ze, Je, Xe, et, tt, st, rt, nt];
|
|
590
|
+
function m(r, e, { noAnim: t = !1, error: s = !1 } = {}) {
|
|
632
591
|
return c`
|
|
633
592
|
<div class="msg bot ${t ? "no-anim" : ""} ${s ? "error" : ""}">
|
|
634
593
|
<span class="lead">${r}</span>
|
|
635
|
-
${e ? c`<span class="sub">${e}</span>` :
|
|
594
|
+
${e ? c`<span class="sub">${e}</span>` : f}
|
|
636
595
|
</div>
|
|
637
596
|
`;
|
|
638
597
|
}
|
|
639
598
|
function v(r, { noAnim: e = !1 } = {}) {
|
|
640
599
|
return c`<div class="msg user ${e ? "no-anim" : ""}">${r}</div>`;
|
|
641
600
|
}
|
|
642
|
-
function
|
|
601
|
+
function W() {
|
|
643
602
|
return c`<div class="msg bot typing"><span></span><span></span><span></span></div>`;
|
|
644
603
|
}
|
|
645
|
-
function
|
|
646
|
-
return r ? c`<span class="flag-pill ${r}">${r === "urgent" ? "Urgent" : "Moderate"}</span>` :
|
|
604
|
+
function ot(r) {
|
|
605
|
+
return r ? c`<span class="flag-pill ${r}">${r === "urgent" ? "Urgent" : "Moderate"}</span>` : f;
|
|
647
606
|
}
|
|
648
|
-
function
|
|
607
|
+
function at() {
|
|
649
608
|
return c`
|
|
650
609
|
<svg viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="3"
|
|
651
610
|
stroke-linecap="round" stroke-linejoin="round" width="20" height="20"
|
|
652
611
|
aria-hidden="true"><path d="M20 6L9 17l-5-5"/></svg>
|
|
653
612
|
`;
|
|
654
613
|
}
|
|
655
|
-
function
|
|
614
|
+
function lt() {
|
|
656
615
|
return c`
|
|
657
616
|
<svg class="my-wral-icon" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 423 423">
|
|
658
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"/>
|
|
@@ -663,34 +622,34 @@ function ct() {
|
|
|
663
622
|
</svg>
|
|
664
623
|
`;
|
|
665
624
|
}
|
|
666
|
-
const
|
|
625
|
+
const ct = 15e3;
|
|
667
626
|
class I extends Error {
|
|
668
627
|
constructor(e, t) {
|
|
669
628
|
super(`api-forms request failed with status ${e}`), this.status = e, this.body = t;
|
|
670
629
|
}
|
|
671
630
|
}
|
|
672
631
|
const de = Object.freeze({ enabled: !1, humanCheck: null });
|
|
673
|
-
function
|
|
632
|
+
function dt({
|
|
674
633
|
baseUrl: r,
|
|
675
|
-
fetchFn: e = (...
|
|
634
|
+
fetchFn: e = (...n) => fetch(...n),
|
|
676
635
|
xhrFactory: t = () => new XMLHttpRequest(),
|
|
677
636
|
getAuthHeaders: s
|
|
678
637
|
}) {
|
|
679
|
-
const
|
|
680
|
-
let
|
|
681
|
-
async function a(l, { method: d = "GET", body:
|
|
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 } = {}) {
|
|
682
641
|
const y = { Accept: "application/json" };
|
|
683
|
-
u && Object.assign(y, o ? { Authorization: `Bearer ${o}` } : await s()),
|
|
642
|
+
u && Object.assign(y, o ? { Authorization: `Bearer ${o}` } : await s()), h !== void 0 && (y["Content-Type"] = "application/json");
|
|
684
643
|
let w;
|
|
685
644
|
try {
|
|
686
|
-
w = await e(`${
|
|
645
|
+
w = await e(`${n}${l}`, {
|
|
687
646
|
method: d,
|
|
688
647
|
headers: y,
|
|
689
|
-
...
|
|
690
|
-
...
|
|
648
|
+
...p ? { signal: AbortSignal.timeout(p) } : {},
|
|
649
|
+
...h !== void 0 ? { body: JSON.stringify(h) } : {}
|
|
691
650
|
});
|
|
692
|
-
} catch (
|
|
693
|
-
throw Object.assign(new I(0, null), { cause:
|
|
651
|
+
} catch (N) {
|
|
652
|
+
throw Object.assign(new I(0, null), { cause: N });
|
|
694
653
|
}
|
|
695
654
|
let $ = null;
|
|
696
655
|
try {
|
|
@@ -704,23 +663,23 @@ function ut({
|
|
|
704
663
|
return {
|
|
705
664
|
/** @returns {Promise<Array>} published form documents */
|
|
706
665
|
listForms: async () => {
|
|
707
|
-
const l = await a("/v1/forms", { timeoutMs:
|
|
708
|
-
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));
|
|
709
668
|
},
|
|
710
669
|
/**
|
|
711
670
|
* What the server advertised on the last listForms.
|
|
712
671
|
* @returns {{enabled: boolean, humanCheck: {provider, siteKey}|null}}
|
|
713
672
|
*/
|
|
714
|
-
anonymousCapability: () =>
|
|
673
|
+
anonymousCapability: () => i,
|
|
715
674
|
/**
|
|
716
675
|
* Mint a submission-scoped anonymous session; subsequent auth-bearing
|
|
717
676
|
* calls present it until endAnonSession(). Unauthenticated by design.
|
|
718
677
|
* @returns {Promise<{expiresIn: number}>}
|
|
719
678
|
*/
|
|
720
|
-
createAnonSession: async ({ formId: l, requestId: d, humanToken:
|
|
679
|
+
createAnonSession: async ({ formId: l, requestId: d, humanToken: h }) => {
|
|
721
680
|
const u = await a("/v1/anon/sessions", {
|
|
722
681
|
method: "POST",
|
|
723
|
-
body: { formId: l, requestId: d, ...
|
|
682
|
+
body: { formId: l, requestId: d, ...h ? { humanToken: h } : {} }
|
|
724
683
|
});
|
|
725
684
|
if (o = u?.token || null, !o)
|
|
726
685
|
throw new I(502, { message: "The anonymous session had no token" });
|
|
@@ -740,52 +699,52 @@ function ut({
|
|
|
740
699
|
* progress is observable. Resolves on 2xx; rejects with
|
|
741
700
|
* ApiError(status) otherwise. Returns { promise, abort }.
|
|
742
701
|
*/
|
|
743
|
-
uploadFile: ({ url: l, file: d, contentType:
|
|
702
|
+
uploadFile: ({ url: l, file: d, contentType: h, onProgress: u = () => {
|
|
744
703
|
} }) => {
|
|
745
|
-
const
|
|
704
|
+
const p = t();
|
|
746
705
|
return { promise: new Promise((w, $) => {
|
|
747
|
-
|
|
748
|
-
u({ loaded:
|
|
749
|
-
}),
|
|
750
|
-
|
|
751
|
-
},
|
|
752
|
-
}), abort: () =>
|
|
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() };
|
|
753
712
|
},
|
|
754
713
|
/** @returns {Promise<{requestId,reference,confirmation,routing}>} */
|
|
755
714
|
putRequest: async (l, d) => await a(`/v1/requests/${l}`, { method: "PUT", body: d, auth: !0 })
|
|
756
715
|
};
|
|
757
716
|
}
|
|
758
717
|
const ue = 60 * 1e3;
|
|
759
|
-
async function
|
|
760
|
-
const s = (
|
|
718
|
+
async function ut({ read: r, refresh: e, now: t = Date.now }) {
|
|
719
|
+
const s = (i) => {
|
|
761
720
|
const { token: o, expiry: a } = r() || {};
|
|
762
|
-
return o && Number(a) -
|
|
721
|
+
return o && Number(a) - i > t() ? o : null;
|
|
763
722
|
};
|
|
764
|
-
let
|
|
765
|
-
if (!
|
|
723
|
+
let n = s(ue);
|
|
724
|
+
if (!n) {
|
|
766
725
|
try {
|
|
767
726
|
await e();
|
|
768
727
|
} catch {
|
|
769
728
|
}
|
|
770
|
-
|
|
729
|
+
n = s(ue) || s(0);
|
|
771
730
|
}
|
|
772
|
-
if (!
|
|
731
|
+
if (!n)
|
|
773
732
|
throw Object.assign(new Error("Please sign in again to continue."), { status: 401, body: null });
|
|
774
|
-
return { Authorization: `Bearer ${
|
|
733
|
+
return { Authorization: `Bearer ${n}` };
|
|
775
734
|
}
|
|
776
|
-
const
|
|
735
|
+
const he = (r) => String(r || "").toLowerCase().trim();
|
|
777
736
|
function ht(r) {
|
|
778
737
|
const e = /* @__PURE__ */ new Set();
|
|
779
738
|
return {
|
|
780
739
|
signUpIfNeeded: async (t, ...s) => {
|
|
781
|
-
const
|
|
782
|
-
return
|
|
740
|
+
const n = await r(t, ...s);
|
|
741
|
+
return n?.exists === !1 && !n.error && e.add(he(t)), n;
|
|
783
742
|
},
|
|
784
|
-
isNewAccount: (t) => e.has(
|
|
743
|
+
isNewAccount: (t) => e.has(he(t))
|
|
785
744
|
};
|
|
786
745
|
}
|
|
787
|
-
const
|
|
788
|
-
function
|
|
746
|
+
const pt = "wral_user_facts", ft = "1", gt = 100;
|
|
747
|
+
function mt(r, e) {
|
|
789
748
|
let t = "";
|
|
790
749
|
for (const s of r) {
|
|
791
750
|
if (t.length + s.length > e) break;
|
|
@@ -793,14 +752,14 @@ function yt(r, e) {
|
|
|
793
752
|
}
|
|
794
753
|
return t;
|
|
795
754
|
}
|
|
796
|
-
const
|
|
755
|
+
const yt = [
|
|
797
756
|
{
|
|
798
757
|
autocomplete: "name",
|
|
799
758
|
factName: "preferred_name",
|
|
800
759
|
label: "Name",
|
|
801
760
|
shape: (r) => {
|
|
802
761
|
const e = String(r ?? "").replace(/\s+/g, " ").trim();
|
|
803
|
-
return e ?
|
|
762
|
+
return e ? mt(e, gt).trim() : null;
|
|
804
763
|
}
|
|
805
764
|
},
|
|
806
765
|
{
|
|
@@ -810,50 +769,50 @@ const bt = [
|
|
|
810
769
|
shape: (r) => String(r ?? "").trim().match(/^(\d{5})(-\d{4})?$/)?.[1] ?? null
|
|
811
770
|
}
|
|
812
771
|
];
|
|
813
|
-
function
|
|
772
|
+
function bt(r = [], e = {}) {
|
|
814
773
|
const t = [];
|
|
815
|
-
for (const s of
|
|
816
|
-
const
|
|
817
|
-
|
|
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]) });
|
|
818
777
|
}
|
|
819
778
|
return t;
|
|
820
779
|
}
|
|
821
|
-
async function
|
|
780
|
+
async function wt(r, {
|
|
822
781
|
baseUrl: e,
|
|
823
782
|
getAuthHeaders: t,
|
|
824
|
-
fetchFn: s = (...
|
|
825
|
-
onSaved:
|
|
783
|
+
fetchFn: s = (...i) => fetch(...i),
|
|
784
|
+
onSaved: n = () => {
|
|
826
785
|
}
|
|
827
786
|
}) {
|
|
828
|
-
const
|
|
787
|
+
const i = String(e).replace(/\/+$/, "");
|
|
829
788
|
let o = !1;
|
|
830
789
|
try {
|
|
831
790
|
for (const { factName: a, value: l } of r) {
|
|
832
791
|
const d = { "Content-Type": "application/json", ...await t() };
|
|
833
|
-
let
|
|
792
|
+
let h;
|
|
834
793
|
try {
|
|
835
|
-
|
|
836
|
-
`${
|
|
794
|
+
h = await s(
|
|
795
|
+
`${i}/user/${encodeURIComponent(a)}/${ft}`,
|
|
837
796
|
{ method: "PUT", headers: d, body: JSON.stringify({ value: l }) }
|
|
838
797
|
);
|
|
839
798
|
} catch (u) {
|
|
840
799
|
throw Object.assign(new Error("user-facts request failed"), { status: 0, cause: u });
|
|
841
800
|
}
|
|
842
|
-
if (!
|
|
801
|
+
if (!h.ok)
|
|
843
802
|
throw Object.assign(
|
|
844
|
-
new Error(`user-facts request failed with status ${
|
|
845
|
-
{ status:
|
|
803
|
+
new Error(`user-facts request failed with status ${h.status}`),
|
|
804
|
+
{ status: h.status }
|
|
846
805
|
);
|
|
847
806
|
o = !0;
|
|
848
807
|
}
|
|
849
808
|
} finally {
|
|
850
|
-
o &&
|
|
809
|
+
o && n();
|
|
851
810
|
}
|
|
852
811
|
}
|
|
853
|
-
function
|
|
854
|
-
const { config: e, storage: t } = Re(), s = ht(
|
|
855
|
-
let
|
|
856
|
-
const
|
|
812
|
+
function xt({ factsBaseUrl: r } = {}) {
|
|
813
|
+
const { config: e, storage: t } = Re(), s = ht(ze);
|
|
814
|
+
let n = null;
|
|
815
|
+
const i = () => ut({
|
|
857
816
|
read: () => ({
|
|
858
817
|
token: t.get(S.idToken),
|
|
859
818
|
expiry: t.get(S.idTokenExpiry)
|
|
@@ -861,17 +820,17 @@ function vt({ factsBaseUrl: r } = {}) {
|
|
|
861
820
|
refresh: () => te()
|
|
862
821
|
});
|
|
863
822
|
return {
|
|
864
|
-
isAuthenticated: () =>
|
|
823
|
+
isAuthenticated: () => Ue(),
|
|
865
824
|
signedInEmail: () => t.get(S.userEmail) || null,
|
|
866
|
-
getAuthHeaders:
|
|
825
|
+
getAuthHeaders: i,
|
|
867
826
|
/* Save mapped answers (../lib/user-facts.mjs) to the viewer's My WRAL user facts. */
|
|
868
827
|
...r ? {
|
|
869
|
-
saveUserFacts: (o) =>
|
|
828
|
+
saveUserFacts: (o) => wt(o, {
|
|
870
829
|
baseUrl: r,
|
|
871
|
-
getAuthHeaders:
|
|
830
|
+
getAuthHeaders: i,
|
|
872
831
|
onSaved: () => {
|
|
873
832
|
try {
|
|
874
|
-
localStorage.removeItem(
|
|
833
|
+
localStorage.removeItem(pt);
|
|
875
834
|
} catch {
|
|
876
835
|
}
|
|
877
836
|
}
|
|
@@ -883,18 +842,18 @@ function vt({ factsBaseUrl: r } = {}) {
|
|
|
883
842
|
* @returns {{challengeRequired?: boolean, authenticated?: boolean, newAccount: boolean}}
|
|
884
843
|
*/
|
|
885
844
|
sendCode: async (o) => {
|
|
886
|
-
const a = await
|
|
845
|
+
const a = await Ne(
|
|
887
846
|
e,
|
|
888
847
|
o,
|
|
889
848
|
t,
|
|
890
|
-
|
|
849
|
+
De,
|
|
891
850
|
s.signUpIfNeeded,
|
|
892
|
-
|
|
851
|
+
Pe,
|
|
893
852
|
J,
|
|
894
853
|
X,
|
|
895
854
|
ee
|
|
896
855
|
);
|
|
897
|
-
return
|
|
856
|
+
return n = a.cognitoUser || null, {
|
|
898
857
|
challengeRequired: !!a.challengeRequired,
|
|
899
858
|
authenticated: !!a.authenticated,
|
|
900
859
|
newAccount: s.isNewAccount(o)
|
|
@@ -905,11 +864,11 @@ function vt({ factsBaseUrl: r } = {}) {
|
|
|
905
864
|
* starts with a full lifetime (house pattern).
|
|
906
865
|
*/
|
|
907
866
|
verifyCode: async (o) => {
|
|
908
|
-
if (!
|
|
867
|
+
if (!n)
|
|
909
868
|
throw new Error("Please enter your email again to get a new code.");
|
|
910
869
|
try {
|
|
911
|
-
await
|
|
912
|
-
|
|
870
|
+
await Me(
|
|
871
|
+
n,
|
|
913
872
|
o,
|
|
914
873
|
t,
|
|
915
874
|
J,
|
|
@@ -923,7 +882,7 @@ function vt({ factsBaseUrl: r } = {}) {
|
|
|
923
882
|
},
|
|
924
883
|
/** Local sign-out only ("use a different email"). */
|
|
925
884
|
signOut: () => {
|
|
926
|
-
|
|
885
|
+
n = null, Oe().clear();
|
|
927
886
|
},
|
|
928
887
|
/**
|
|
929
888
|
* Detect a login completed in ANOTHER tab (the storage event
|
|
@@ -937,9 +896,9 @@ function vt({ factsBaseUrl: r } = {}) {
|
|
|
937
896
|
}
|
|
938
897
|
};
|
|
939
898
|
}
|
|
940
|
-
function
|
|
941
|
-
const t =
|
|
942
|
-
return { ...
|
|
899
|
+
function vt({ baseUrl: r, factsBaseUrl: e }) {
|
|
900
|
+
const t = xt({ factsBaseUrl: e });
|
|
901
|
+
return { ...dt({ baseUrl: r, getAuthHeaders: t.getAuthHeaders }), ...t };
|
|
943
902
|
}
|
|
944
903
|
function x(r, e) {
|
|
945
904
|
return (r?.nodes || []).find((t) => t.id === e);
|
|
@@ -947,37 +906,37 @@ function x(r, e) {
|
|
|
947
906
|
function L(r) {
|
|
948
907
|
return r?.form ? { formId: r.form, path: [...r.path || []] } : null;
|
|
949
908
|
}
|
|
950
|
-
function
|
|
909
|
+
function H(r, e = []) {
|
|
951
910
|
const t = [];
|
|
952
911
|
let s = r?.start;
|
|
953
|
-
for (const
|
|
912
|
+
for (const i of e) {
|
|
954
913
|
const o = x(r, s);
|
|
955
914
|
if (!o)
|
|
956
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
915
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown node: ${s}` } };
|
|
957
916
|
if (o.type === "terminal" || o.type === "redirect")
|
|
958
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
959
|
-
if (
|
|
960
|
-
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}` } };
|
|
961
920
|
if (o.type === "choice") {
|
|
962
|
-
const a = (o.options || []).find((l) => l.id ===
|
|
921
|
+
const a = (o.options || []).find((l) => l.id === i.optionId);
|
|
963
922
|
if (!a)
|
|
964
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
923
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown option: ${i.optionId}` } };
|
|
965
924
|
if (L(a))
|
|
966
|
-
return { nodeId: null, node: null, flags: t, error: { step:
|
|
925
|
+
return { nodeId: null, node: null, flags: t, error: { step: i, reason: `steps continue past a hand-off: ${i.optionId}` } };
|
|
967
926
|
t.push(...a.flags || []), s = a.next;
|
|
968
927
|
continue;
|
|
969
928
|
}
|
|
970
929
|
s = o.next;
|
|
971
930
|
}
|
|
972
|
-
const
|
|
973
|
-
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}` } };
|
|
974
933
|
}
|
|
975
934
|
function Ae(r, e = []) {
|
|
976
935
|
const t = [];
|
|
977
936
|
for (const s of e) {
|
|
978
937
|
if (s.kind !== "collect") continue;
|
|
979
|
-
const
|
|
980
|
-
t.push(...
|
|
938
|
+
const n = x(r, s.nodeId);
|
|
939
|
+
t.push(...n?.fields || []);
|
|
981
940
|
}
|
|
982
941
|
return t;
|
|
983
942
|
}
|
|
@@ -987,68 +946,68 @@ function Fe(r = []) {
|
|
|
987
946
|
t.kind === "collect" && Object.assign(e, t.values || {});
|
|
988
947
|
return e;
|
|
989
948
|
}
|
|
990
|
-
function
|
|
949
|
+
function _t(r = []) {
|
|
991
950
|
return r.filter((e) => e.kind === "choice").map((e) => `${e.nodeId}:${e.optionId}`);
|
|
992
951
|
}
|
|
993
952
|
function Ie(r, e = []) {
|
|
994
953
|
const t = [];
|
|
995
954
|
for (const s of e) {
|
|
996
955
|
if (s.kind !== "choice") continue;
|
|
997
|
-
const
|
|
998
|
-
t.push(...
|
|
956
|
+
const i = (x(r, s.nodeId)?.options || []).find((o) => o.id === s.optionId);
|
|
957
|
+
t.push(...i?.flags || []);
|
|
999
958
|
}
|
|
1000
959
|
return Ee(t);
|
|
1001
960
|
}
|
|
1002
|
-
function
|
|
961
|
+
function $t(r = []) {
|
|
1003
962
|
return r.includes("urgent") ? "urgent" : r.includes("moderate") ? "moderate" : null;
|
|
1004
963
|
}
|
|
1005
964
|
function Ee(r) {
|
|
1006
965
|
return [...new Set(r)];
|
|
1007
966
|
}
|
|
1008
|
-
function
|
|
967
|
+
function kt(r, e = []) {
|
|
1009
968
|
const t = [];
|
|
1010
|
-
for (const
|
|
1011
|
-
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;
|
|
1012
971
|
if (!l)
|
|
1013
|
-
return { steps: [], error: `unknown preset step: ${
|
|
1014
|
-
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 });
|
|
1015
974
|
}
|
|
1016
|
-
const { error: s } =
|
|
975
|
+
const { error: s } = H(r, t);
|
|
1017
976
|
return s ? { steps: [], error: s.reason } : { steps: t, error: null };
|
|
1018
977
|
}
|
|
1019
|
-
function
|
|
978
|
+
function At(r, e) {
|
|
1020
979
|
const t = L(e);
|
|
1021
980
|
if (!t) return { form: null, steps: [], error: "not a hand-off" };
|
|
1022
981
|
const s = (r || []).find((o) => o.formId === t.formId);
|
|
1023
982
|
if (!s) return { form: null, steps: [], error: `unknown form: ${t.formId}` };
|
|
1024
|
-
const { steps:
|
|
1025
|
-
return
|
|
983
|
+
const { steps: n, error: i } = kt(s, t.path);
|
|
984
|
+
return i ? { form: null, steps: [], error: i } : { form: s, steps: n, error: null };
|
|
1026
985
|
}
|
|
1027
|
-
function
|
|
986
|
+
function Ft(r, e, t, s) {
|
|
1028
987
|
return {
|
|
1029
988
|
form: r,
|
|
1030
989
|
steps: e,
|
|
1031
990
|
option: { nodeId: t.id, optionId: s.id, label: s.label }
|
|
1032
991
|
};
|
|
1033
992
|
}
|
|
1034
|
-
function
|
|
993
|
+
function It(r = []) {
|
|
1035
994
|
return r.every((e) => e.preset === !0);
|
|
1036
995
|
}
|
|
1037
|
-
function
|
|
996
|
+
function Et(r, e, t) {
|
|
1038
997
|
if (!Array.isArray(r) || !r.length) return [];
|
|
1039
998
|
const s = [];
|
|
1040
|
-
for (let
|
|
1041
|
-
const
|
|
999
|
+
for (let n = 0; n < r.length; n++) {
|
|
1000
|
+
const i = r[n], o = (e || []).find((u) => u.formId === i?.formId);
|
|
1042
1001
|
if (!o) return [];
|
|
1043
|
-
const { node: a, error: l } =
|
|
1044
|
-
if (l || a?.id !==
|
|
1045
|
-
const d = (a.options || []).find((u) => u.id ===
|
|
1046
|
-
if (L(d)?.formId !==
|
|
1047
|
-
s.push({ form: o, steps:
|
|
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 });
|
|
1048
1007
|
}
|
|
1049
1008
|
return s;
|
|
1050
1009
|
}
|
|
1051
|
-
function
|
|
1010
|
+
function St({ attr: r = null, search: e = "" } = {}) {
|
|
1052
1011
|
const t = String(r ?? "").trim();
|
|
1053
1012
|
if (t) return t;
|
|
1054
1013
|
try {
|
|
@@ -1057,13 +1016,13 @@ function Ct({ attr: r = null, search: e = "" } = {}) {
|
|
|
1057
1016
|
return null;
|
|
1058
1017
|
}
|
|
1059
1018
|
}
|
|
1060
|
-
function
|
|
1019
|
+
function Ct(r, e) {
|
|
1061
1020
|
return e && (r || []).find((t) => t.formId === e) || null;
|
|
1062
1021
|
}
|
|
1063
|
-
function
|
|
1022
|
+
function Tt(r, e) {
|
|
1064
1023
|
return !e || r?.form?.formId === e ? !0 : (r?.origins || []).some((t) => t.form?.formId === e);
|
|
1065
1024
|
}
|
|
1066
|
-
const
|
|
1025
|
+
const Rt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/, pe = {
|
|
1067
1026
|
text: 500,
|
|
1068
1027
|
textarea: 5e3,
|
|
1069
1028
|
url: 2048
|
|
@@ -1071,30 +1030,30 @@ const Mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$
|
|
|
1071
1030
|
function Se(r, { mediaCount: e = 0 } = {}) {
|
|
1072
1031
|
return r.kind === "consent" && r.requiredIf === "media" ? e > 0 : !!r.required;
|
|
1073
1032
|
}
|
|
1074
|
-
function
|
|
1033
|
+
function Mt(r, e) {
|
|
1075
1034
|
try {
|
|
1076
1035
|
return new RegExp(r, "u").test(e);
|
|
1077
1036
|
} catch {
|
|
1078
1037
|
return !0;
|
|
1079
1038
|
}
|
|
1080
1039
|
}
|
|
1081
|
-
function
|
|
1040
|
+
function Nt(r) {
|
|
1082
1041
|
return r.key === "zip" ? "Please enter a five-digit zip code." : `Please check the format of ${r.label.toLowerCase()}.`;
|
|
1083
1042
|
}
|
|
1084
|
-
function
|
|
1043
|
+
function Dt(r, e, { mediaCount: t = 0 } = {}) {
|
|
1085
1044
|
const s = Se(r, { mediaCount: t });
|
|
1086
1045
|
if (r.kind === "consent")
|
|
1087
1046
|
return e === !0 || !s ? null : Ot;
|
|
1088
|
-
if (e == null || e === "" || r.kind === "location" &&
|
|
1047
|
+
if (e == null || e === "" || r.kind === "location" && Pt(e))
|
|
1089
1048
|
return s ? `Please fill in: ${r.label.toLowerCase()}.` : null;
|
|
1090
1049
|
switch (r.kind) {
|
|
1091
1050
|
case "text":
|
|
1092
1051
|
case "textarea": {
|
|
1093
|
-
const
|
|
1094
|
-
return typeof e != "string" ? `Please enter text for ${r.label.toLowerCase()}.` : e.length >
|
|
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;
|
|
1095
1054
|
}
|
|
1096
1055
|
case "url": {
|
|
1097
|
-
if (typeof e != "string" || e.length >
|
|
1056
|
+
if (typeof e != "string" || e.length > pe.url)
|
|
1098
1057
|
return "Please enter a valid link.";
|
|
1099
1058
|
try {
|
|
1100
1059
|
return new URL(e), null;
|
|
@@ -1103,83 +1062,83 @@ function zt(r, e, { mediaCount: t = 0 } = {}) {
|
|
|
1103
1062
|
}
|
|
1104
1063
|
}
|
|
1105
1064
|
case "datetime":
|
|
1106
|
-
return
|
|
1065
|
+
return Rt.test(String(e)) ? null : "Please pick a date and time.";
|
|
1107
1066
|
case "select":
|
|
1108
1067
|
return (r.options || []).map((o) => o.id).includes(e) ? null : `Please choose one of the options for ${r.label.toLowerCase()}.`;
|
|
1109
1068
|
case "location":
|
|
1110
|
-
return
|
|
1069
|
+
return Ut(r, e);
|
|
1111
1070
|
case "media":
|
|
1112
1071
|
return null;
|
|
1113
1072
|
default:
|
|
1114
1073
|
return `Unsupported field: ${r.kind}`;
|
|
1115
1074
|
}
|
|
1116
1075
|
}
|
|
1117
|
-
function
|
|
1076
|
+
function Pt(r) {
|
|
1118
1077
|
return r == null ? !0 : typeof r != "object" ? !1 : !r.county && !r.where && !(Array.isArray(r.gps) && r.gps.length);
|
|
1119
1078
|
}
|
|
1120
|
-
function
|
|
1079
|
+
function Ut(r, e) {
|
|
1121
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;
|
|
1122
1081
|
}
|
|
1123
1082
|
function fe(r, e = {}, { mediaCount: t = 0 } = {}) {
|
|
1124
1083
|
const s = {};
|
|
1125
|
-
for (const
|
|
1126
|
-
if (
|
|
1127
|
-
const
|
|
1128
|
-
|
|
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);
|
|
1129
1088
|
}
|
|
1130
1089
|
return { ok: Object.keys(s).length === 0, errors: s };
|
|
1131
1090
|
}
|
|
1132
1091
|
function Y(r = [], e = {}, { required: t = !1 } = {}) {
|
|
1133
1092
|
const {
|
|
1134
1093
|
maxFiles: s = 5,
|
|
1135
|
-
maxFileBytes:
|
|
1136
|
-
allowedTypes:
|
|
1094
|
+
maxFileBytes: n = 512 * 1024 * 1024,
|
|
1095
|
+
allowedTypes: i = []
|
|
1137
1096
|
} = e, o = [];
|
|
1138
1097
|
return t && r.length === 0 && o.push({ reason: "required", message: "Please attach at least one photo or video." }), r.length > s && o.push({
|
|
1139
1098
|
reason: "count",
|
|
1140
1099
|
message: `This form accepts at most ${s} ${s === 1 ? "file" : "files"}.`
|
|
1141
1100
|
}), r.forEach((a, l) => {
|
|
1142
|
-
|
|
1101
|
+
i.length && !i.includes(a.type) && o.push({
|
|
1143
1102
|
index: l,
|
|
1144
1103
|
reason: "type",
|
|
1145
1104
|
message: `${a.name || "A file"} is a type this form does not accept.`
|
|
1146
|
-
}), a.size >
|
|
1105
|
+
}), a.size > n && o.push({
|
|
1147
1106
|
index: l,
|
|
1148
1107
|
reason: "size",
|
|
1149
1108
|
message: `${a.name || "A file"} is larger than this form allows.`
|
|
1150
1109
|
});
|
|
1151
1110
|
}), { ok: o.length === 0, errors: o };
|
|
1152
1111
|
}
|
|
1153
|
-
function
|
|
1112
|
+
function ge({ formId: r, requestId: e, files: t }) {
|
|
1154
1113
|
return {
|
|
1155
1114
|
formId: r,
|
|
1156
1115
|
requestId: e,
|
|
1157
1116
|
files: t.map((s) => ({ contentType: s.type, size: s.size }))
|
|
1158
1117
|
};
|
|
1159
1118
|
}
|
|
1160
|
-
function
|
|
1161
|
-
const s = Ae(r, e),
|
|
1119
|
+
function zt({ form: r, steps: e, media: t = [] }) {
|
|
1120
|
+
const s = Ae(r, e), n = Fe(e), i = {};
|
|
1162
1121
|
for (const o of s) {
|
|
1163
1122
|
if (o.kind === "media") continue;
|
|
1164
|
-
const a =
|
|
1123
|
+
const a = n[o.key];
|
|
1165
1124
|
if (!(a == null || a === "") && !(o.kind === "consent" && (a !== !0 || o.requiredIf === "media" && !t.length))) {
|
|
1166
1125
|
if (o.kind === "location") {
|
|
1167
1126
|
const l = {};
|
|
1168
|
-
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);
|
|
1169
1128
|
continue;
|
|
1170
1129
|
}
|
|
1171
|
-
|
|
1130
|
+
i[o.key] = a;
|
|
1172
1131
|
}
|
|
1173
1132
|
}
|
|
1174
1133
|
return {
|
|
1175
1134
|
formId: r.formId,
|
|
1176
1135
|
flowVersion: r.flowVersion,
|
|
1177
|
-
path:
|
|
1178
|
-
answers:
|
|
1136
|
+
path: _t(e),
|
|
1137
|
+
answers: i,
|
|
1179
1138
|
media: t.map(({ assetId: o, type: a }) => ({ assetId: o, type: a }))
|
|
1180
1139
|
};
|
|
1181
1140
|
}
|
|
1182
|
-
function
|
|
1141
|
+
function me(r, e) {
|
|
1183
1142
|
if (r === 429)
|
|
1184
1143
|
return {
|
|
1185
1144
|
kind: "throttled",
|
|
@@ -1217,7 +1176,7 @@ function ge(r, e) {
|
|
|
1217
1176
|
message: "Something went wrong on our end; please try again."
|
|
1218
1177
|
};
|
|
1219
1178
|
}
|
|
1220
|
-
const
|
|
1179
|
+
const Bt = 34, Lt = 44;
|
|
1221
1180
|
function ye(r, e) {
|
|
1222
1181
|
const t = String(r);
|
|
1223
1182
|
return t.length > e ? `${t.slice(0, e)}…` : t;
|
|
@@ -1226,32 +1185,32 @@ function Ht(r, e) {
|
|
|
1226
1185
|
const t = (r.options || []).find((s) => s.id === e);
|
|
1227
1186
|
return t ? t.label : e;
|
|
1228
1187
|
}
|
|
1229
|
-
function
|
|
1188
|
+
function qt(r) {
|
|
1230
1189
|
return !r || typeof r != "object" ? "" : [r.county, r.where].filter(Boolean).join(", ");
|
|
1231
1190
|
}
|
|
1232
1191
|
function Wt(r, e = {}, t = []) {
|
|
1233
1192
|
const s = [];
|
|
1234
|
-
for (const
|
|
1235
|
-
if (
|
|
1236
|
-
if (
|
|
1193
|
+
for (const n of r) {
|
|
1194
|
+
if (n.kind === "consent") continue;
|
|
1195
|
+
if (n.kind === "media") {
|
|
1237
1196
|
t.length && s.push(`${t.length} ${t.length === 1 ? "file" : "files"}`);
|
|
1238
1197
|
continue;
|
|
1239
1198
|
}
|
|
1240
|
-
const
|
|
1241
|
-
|
|
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)));
|
|
1242
1201
|
}
|
|
1243
1202
|
return s.join(" · ") || "Details provided";
|
|
1244
1203
|
}
|
|
1245
1204
|
function Vt(r, e = [], t = null) {
|
|
1246
1205
|
const s = [];
|
|
1247
|
-
for (const
|
|
1248
|
-
const o = x(r,
|
|
1249
|
-
|
|
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 }));
|
|
1250
1209
|
}
|
|
1251
|
-
const
|
|
1252
|
-
return
|
|
1210
|
+
const n = $t(Ie(r, e));
|
|
1211
|
+
return n && s.push({ k: "Priority", v: n === "urgent" ? "Urgent" : "Moderate", pill: n }), s;
|
|
1253
1212
|
}
|
|
1254
|
-
function
|
|
1213
|
+
function jt(r, e = []) {
|
|
1255
1214
|
const t = r?.confirmation || {};
|
|
1256
1215
|
return {
|
|
1257
1216
|
title: t.title || "Report received.",
|
|
@@ -1259,44 +1218,14 @@ function Yt(r, e = []) {
|
|
|
1259
1218
|
urgentNote: e.includes("urgent") ? t.urgentNote : void 0
|
|
1260
1219
|
};
|
|
1261
1220
|
}
|
|
1262
|
-
function Gt(r, e) {
|
|
1263
|
-
const t = e === "failed" ? " The notification is queued for a delivery retry." : "";
|
|
1264
|
-
return r?.startsWith("studio+email:") ? `Sent to the Studio review queue; the desk is emailed.${t}` : r?.startsWith("studio:") ? "Sent to the Studio review queue." : r?.startsWith("jsm:") ? `A ticket is opened for tech support with your details as fields, not prose.${t}` : r?.startsWith("email:") ? `Emailed to the owning desk with a link to your report.${t}` : "Routed to the right team.";
|
|
1265
|
-
}
|
|
1266
|
-
function Kt({ routing: r = {}, flags: e = [], reference: t = "", anonymous: s = !1 }) {
|
|
1267
|
-
const i = e.includes("urgent");
|
|
1268
|
-
return [
|
|
1269
|
-
{
|
|
1270
|
-
title: "Received",
|
|
1271
|
-
body: `Report ${t} and its media are written to the dedicated Report It intake store before anything downstream touches them.`
|
|
1272
|
-
},
|
|
1273
|
-
{
|
|
1274
|
-
title: "Routed",
|
|
1275
|
-
body: Gt(r.destination, r.state),
|
|
1276
|
-
pill: i ? "Urgent · pinned first" : void 0
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
title: "Reviewed",
|
|
1280
|
-
body: s ? "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."
|
|
1281
|
-
},
|
|
1282
|
-
{
|
|
1283
|
-
title: "Monitored",
|
|
1284
|
-
body: "The record joins the monitoring stream, which watches for related reports by category, place and symptom."
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
title: "Escalation check",
|
|
1288
|
-
body: "Related reports crossing a threshold alert the owning team automatically; below it, we keep monitoring."
|
|
1289
|
-
}
|
|
1290
|
-
];
|
|
1291
|
-
}
|
|
1292
1221
|
const Z = "wral-report-it:draft:v1", Ce = 1;
|
|
1293
|
-
function
|
|
1222
|
+
function Yt(r, e) {
|
|
1294
1223
|
try {
|
|
1295
1224
|
r.setItem(Z, JSON.stringify({ ...e, v: Ce, savedAt: Date.now() }));
|
|
1296
1225
|
} catch {
|
|
1297
1226
|
}
|
|
1298
1227
|
}
|
|
1299
|
-
function
|
|
1228
|
+
function Gt(r) {
|
|
1300
1229
|
try {
|
|
1301
1230
|
const e = r.getItem(Z);
|
|
1302
1231
|
if (!e) return null;
|
|
@@ -1312,13 +1241,13 @@ function be(r) {
|
|
|
1312
1241
|
} catch {
|
|
1313
1242
|
}
|
|
1314
1243
|
}
|
|
1315
|
-
function
|
|
1244
|
+
function Kt({
|
|
1316
1245
|
apiOrigin: r,
|
|
1317
1246
|
form: e,
|
|
1318
1247
|
steps: t,
|
|
1319
1248
|
requestId: s = null,
|
|
1320
|
-
mediaMeta:
|
|
1321
|
-
origins:
|
|
1249
|
+
mediaMeta: n = {},
|
|
1250
|
+
origins: i = []
|
|
1322
1251
|
}) {
|
|
1323
1252
|
return {
|
|
1324
1253
|
apiOrigin: r,
|
|
@@ -1326,35 +1255,35 @@ function Jt({
|
|
|
1326
1255
|
flowVersion: e.flowVersion,
|
|
1327
1256
|
requestId: s,
|
|
1328
1257
|
steps: t,
|
|
1329
|
-
media:
|
|
1330
|
-
origins:
|
|
1258
|
+
media: n,
|
|
1259
|
+
origins: i.map(({ form: o, steps: a, option: l }) => ({
|
|
1331
1260
|
formId: o.formId,
|
|
1332
1261
|
steps: a,
|
|
1333
1262
|
option: l
|
|
1334
1263
|
}))
|
|
1335
1264
|
};
|
|
1336
1265
|
}
|
|
1337
|
-
function
|
|
1266
|
+
function Qt(r, e, { apiOrigin: t } = {}) {
|
|
1338
1267
|
if (!r) return { status: "discarded" };
|
|
1339
1268
|
if (t && r.apiOrigin && r.apiOrigin !== t)
|
|
1340
1269
|
return { status: "discarded" };
|
|
1341
1270
|
const s = (e || []).find((o) => o.formId === r.formId);
|
|
1342
1271
|
if (!s) return { status: "discarded" };
|
|
1343
|
-
const { error:
|
|
1344
|
-
if (
|
|
1345
|
-
const
|
|
1272
|
+
const { error: n } = H(s, r.steps || []);
|
|
1273
|
+
if (n) return { status: "discarded" };
|
|
1274
|
+
const i = {};
|
|
1346
1275
|
for (const [o, a] of Object.entries(r.media || {}))
|
|
1347
|
-
a?.length && (
|
|
1276
|
+
a?.length && (i[o] = a.map((l) => ({ ...l, lost: !0 })));
|
|
1348
1277
|
return {
|
|
1349
1278
|
status: r.flowVersion === s.flowVersion ? "ok" : "review-required",
|
|
1350
1279
|
form: s,
|
|
1351
1280
|
steps: r.steps || [],
|
|
1352
1281
|
requestId: r.requestId || null,
|
|
1353
|
-
lostMedia:
|
|
1354
|
-
origins:
|
|
1282
|
+
lostMedia: i,
|
|
1283
|
+
origins: Et(r.origins, e, s.formId)
|
|
1355
1284
|
};
|
|
1356
1285
|
}
|
|
1357
|
-
function
|
|
1286
|
+
function D(r = []) {
|
|
1358
1287
|
return {
|
|
1359
1288
|
stage: "idle",
|
|
1360
1289
|
resumeStage: null,
|
|
@@ -1374,7 +1303,7 @@ function P(r = []) {
|
|
|
1374
1303
|
error: null
|
|
1375
1304
|
};
|
|
1376
1305
|
}
|
|
1377
|
-
function
|
|
1306
|
+
function Zt(r, e) {
|
|
1378
1307
|
switch (e.type) {
|
|
1379
1308
|
case "START":
|
|
1380
1309
|
return { ...r, stage: r.files.length ? "minting" : "requesting", error: null };
|
|
@@ -1383,11 +1312,11 @@ function es(r, e) {
|
|
|
1383
1312
|
case "AUTH_OK":
|
|
1384
1313
|
return { ...r, stage: r.resumeStage || "idle", resumeStage: null };
|
|
1385
1314
|
case "MINTED": {
|
|
1386
|
-
const t = r.files.map((s,
|
|
1315
|
+
const t = r.files.map((s, n) => ({
|
|
1387
1316
|
...s,
|
|
1388
|
-
assetId: e.uploads[
|
|
1389
|
-
url: e.uploads[
|
|
1390
|
-
assetUrl: e.uploads[
|
|
1317
|
+
assetId: e.uploads[n]?.assetId ?? s.assetId,
|
|
1318
|
+
url: e.uploads[n]?.url ?? s.url,
|
|
1319
|
+
assetUrl: e.uploads[n]?.assetUrl ?? s.assetUrl,
|
|
1391
1320
|
status: "uploading",
|
|
1392
1321
|
progress: 0,
|
|
1393
1322
|
error: null
|
|
@@ -1401,7 +1330,7 @@ function es(r, e) {
|
|
|
1401
1330
|
}));
|
|
1402
1331
|
case "FILE_DONE": {
|
|
1403
1332
|
const t = T(r, e.i, (s) => ({ ...s, status: "done", progress: 1 }));
|
|
1404
|
-
return
|
|
1333
|
+
return Jt(t);
|
|
1405
1334
|
}
|
|
1406
1335
|
case "FILE_FAIL":
|
|
1407
1336
|
return { ...T(r, e.i, (s) => ({
|
|
@@ -1433,23 +1362,23 @@ function es(r, e) {
|
|
|
1433
1362
|
case "REQUEST_FAIL":
|
|
1434
1363
|
return { ...r, stage: "requesting-error", error: e.error };
|
|
1435
1364
|
case "RESET":
|
|
1436
|
-
return
|
|
1365
|
+
return D([]);
|
|
1437
1366
|
default:
|
|
1438
1367
|
return r;
|
|
1439
1368
|
}
|
|
1440
1369
|
}
|
|
1441
1370
|
function T(r, e, t) {
|
|
1442
|
-
const s = r.files.map((
|
|
1371
|
+
const s = r.files.map((n, i) => i === e ? t(n) : n);
|
|
1443
1372
|
return { ...r, files: s };
|
|
1444
1373
|
}
|
|
1445
|
-
function
|
|
1374
|
+
function Jt(r) {
|
|
1446
1375
|
const e = r.files.every((s) => s.status === "done"), t = r.files.some((s) => s.status === "failed");
|
|
1447
1376
|
return e ? { ...r, stage: "requesting" } : t ? { ...r, stage: "uploading-error" } : r;
|
|
1448
1377
|
}
|
|
1449
1378
|
function we(r) {
|
|
1450
1379
|
return r.files.map((e, t) => ({ ...e, i: t })).filter((e) => e.status === "failed");
|
|
1451
1380
|
}
|
|
1452
|
-
const
|
|
1381
|
+
const Xt = [
|
|
1453
1382
|
"Wake",
|
|
1454
1383
|
"Durham",
|
|
1455
1384
|
"Orange",
|
|
@@ -1466,18 +1395,18 @@ const ss = [
|
|
|
1466
1395
|
"Moore",
|
|
1467
1396
|
"Sampson",
|
|
1468
1397
|
"Other / outside the area"
|
|
1469
|
-
], xe = "(919) 821-8600",
|
|
1398
|
+
], xe = "(919) 821-8600", es = "https://www.wral.com/my-wral/", ts = Object.freeze([
|
|
1470
1399
|
"We cannot come back to you for the detail that often turns a tip into a story.",
|
|
1471
1400
|
"We cannot credit you if we use your photos or video.",
|
|
1472
1401
|
"If you lose your reference number, we cannot look it up for you."
|
|
1473
1402
|
]);
|
|
1474
|
-
function
|
|
1403
|
+
function ss(r) {
|
|
1475
1404
|
const e = String(r).replace(/\D/g, "");
|
|
1476
1405
|
return `tel:+1${e.length === 11 && e.startsWith("1") ? e.slice(1) : e}`;
|
|
1477
1406
|
}
|
|
1478
|
-
const
|
|
1479
|
-
class
|
|
1480
|
-
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;
|
|
1481
1410
|
static properties = {
|
|
1482
1411
|
api: { type: String },
|
|
1483
1412
|
factsApi: { type: String, attribute: "facts-api" },
|
|
@@ -1501,26 +1430,26 @@ class ys extends G {
|
|
|
1501
1430
|
};
|
|
1502
1431
|
#c = null;
|
|
1503
1432
|
#l = null;
|
|
1504
|
-
#
|
|
1433
|
+
#u = null;
|
|
1505
1434
|
#t = null;
|
|
1506
1435
|
#s = {};
|
|
1507
1436
|
#r = {};
|
|
1508
|
-
#
|
|
1437
|
+
#i = /* @__PURE__ */ new Map();
|
|
1509
1438
|
#w = null;
|
|
1510
1439
|
#h = null;
|
|
1511
1440
|
#x = !1;
|
|
1512
1441
|
#d = null;
|
|
1513
1442
|
#I = 0;
|
|
1514
1443
|
/* The gate was passed with an account created on this page load; offered once. */
|
|
1515
|
-
#
|
|
1444
|
+
#p = !1;
|
|
1516
1445
|
constructor() {
|
|
1517
|
-
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;
|
|
1518
1447
|
}
|
|
1519
1448
|
get client() {
|
|
1520
1449
|
if (this.#c) return this.#c;
|
|
1521
1450
|
const e = `${this.api}
|
|
1522
1451
|
${this.factsApi || ""}`;
|
|
1523
|
-
return (!this.#l || this.#
|
|
1452
|
+
return (!this.#l || this.#u !== e) && (this.#l = vt({ baseUrl: this.api, factsBaseUrl: this.factsApi || null }), this.#u = e), this.#l;
|
|
1524
1453
|
}
|
|
1525
1454
|
set client(e) {
|
|
1526
1455
|
this.#c = e || null, this.isConnected && this.#v();
|
|
@@ -1530,17 +1459,17 @@ ${this.factsApi || ""}`;
|
|
|
1530
1459
|
}
|
|
1531
1460
|
disconnectedCallback() {
|
|
1532
1461
|
super.disconnectedCallback(), clearTimeout(this.#w), clearTimeout(this.#h), this.#d?.();
|
|
1533
|
-
for (const { abort: e } of this.#
|
|
1534
|
-
this.#
|
|
1462
|
+
for (const { abort: e } of this.#i.values()) e?.();
|
|
1463
|
+
this.#i.clear();
|
|
1535
1464
|
}
|
|
1536
|
-
get #
|
|
1465
|
+
get #B() {
|
|
1537
1466
|
try {
|
|
1538
1467
|
return matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1539
1468
|
} catch {
|
|
1540
1469
|
return !0;
|
|
1541
1470
|
}
|
|
1542
1471
|
}
|
|
1543
|
-
get #
|
|
1472
|
+
get #f() {
|
|
1544
1473
|
try {
|
|
1545
1474
|
return sessionStorage;
|
|
1546
1475
|
} catch {
|
|
@@ -1559,7 +1488,7 @@ ${this.factsApi || ""}`;
|
|
|
1559
1488
|
return this.client.anonymousCapability?.().enabled === !0 && this._form?.allowAnonymous !== !1;
|
|
1560
1489
|
}
|
|
1561
1490
|
/* Derived from the gate step, so a reload restores the choice. */
|
|
1562
|
-
get #
|
|
1491
|
+
get #g() {
|
|
1563
1492
|
return this._steps.some((e) => e.kind === "gate" && e.anonymous === !0);
|
|
1564
1493
|
}
|
|
1565
1494
|
// ── Loading + draft restore ─────────────────────────────────────
|
|
@@ -1567,7 +1496,7 @@ ${this.factsApi || ""}`;
|
|
|
1567
1496
|
const e = ++this.#I, t = () => e === this.#I;
|
|
1568
1497
|
this._phase = "loading", this._banner = null, this._loadingSlow = !1, clearTimeout(this.#h), this.#h = setTimeout(() => {
|
|
1569
1498
|
this._loadingSlow = !0;
|
|
1570
|
-
},
|
|
1499
|
+
}, os);
|
|
1571
1500
|
let s;
|
|
1572
1501
|
try {
|
|
1573
1502
|
s = await this.client.listForms();
|
|
@@ -1579,12 +1508,12 @@ ${this.factsApi || ""}`;
|
|
|
1579
1508
|
}
|
|
1580
1509
|
if (!t()) return;
|
|
1581
1510
|
this._forms = s;
|
|
1582
|
-
const
|
|
1583
|
-
if ((
|
|
1584
|
-
this._form =
|
|
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 });
|
|
1585
1514
|
return;
|
|
1586
1515
|
}
|
|
1587
|
-
const o =
|
|
1516
|
+
const o = Ct(this._forms, n);
|
|
1588
1517
|
if (o) {
|
|
1589
1518
|
this.#E(o);
|
|
1590
1519
|
return;
|
|
@@ -1595,8 +1524,8 @@ ${this.factsApi || ""}`;
|
|
|
1595
1524
|
if (!this._form) return;
|
|
1596
1525
|
const e = {};
|
|
1597
1526
|
for (const [t, s] of Object.entries(this.#s))
|
|
1598
|
-
s.length && (e[t] = s.map(({ name:
|
|
1599
|
-
|
|
1527
|
+
s.length && (e[t] = s.map(({ name: n, type: i, size: o }) => ({ name: n, type: i, size: o })));
|
|
1528
|
+
Yt(this.#f, Kt({
|
|
1600
1529
|
apiOrigin: this.api,
|
|
1601
1530
|
form: this._form,
|
|
1602
1531
|
steps: this._steps,
|
|
@@ -1606,26 +1535,26 @@ ${this.factsApi || ""}`;
|
|
|
1606
1535
|
}));
|
|
1607
1536
|
}
|
|
1608
1537
|
// ── Walk mechanics ──────────────────────────────────────────────
|
|
1609
|
-
#
|
|
1610
|
-
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(() => {
|
|
1611
1540
|
this._typing = !1;
|
|
1612
|
-
},
|
|
1541
|
+
}, ns)) : this._typing = !1;
|
|
1613
1542
|
}
|
|
1614
1543
|
get #_() {
|
|
1615
|
-
return this._form ?
|
|
1544
|
+
return this._form ? H(this._form, this._steps) : { node: null };
|
|
1616
1545
|
}
|
|
1617
1546
|
#E(e) {
|
|
1618
|
-
this._form = e, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#
|
|
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();
|
|
1619
1548
|
}
|
|
1620
|
-
#
|
|
1621
|
-
this._steps = [...this._steps, e], this.#o(), this.#
|
|
1549
|
+
#m(e) {
|
|
1550
|
+
this._steps = [...this._steps, e], this.#o(), this.#n();
|
|
1622
1551
|
}
|
|
1623
|
-
#
|
|
1552
|
+
#H(e, t) {
|
|
1624
1553
|
if (L(t)) {
|
|
1625
|
-
this.#
|
|
1554
|
+
this.#q(e, t);
|
|
1626
1555
|
return;
|
|
1627
1556
|
}
|
|
1628
|
-
this._handoffError = !1, this.#
|
|
1557
|
+
this._handoffError = !1, this.#m({
|
|
1629
1558
|
nodeId: e.id,
|
|
1630
1559
|
kind: "choice",
|
|
1631
1560
|
optionId: t.id,
|
|
@@ -1639,31 +1568,31 @@ ${this.factsApi || ""}`;
|
|
|
1639
1568
|
* Back can return them. A target that is missing or no longer matches
|
|
1640
1569
|
* its preset path is a config mistake: say so and stay put.
|
|
1641
1570
|
*/
|
|
1642
|
-
#
|
|
1643
|
-
const { form: s, steps:
|
|
1644
|
-
if (
|
|
1571
|
+
#q(e, t) {
|
|
1572
|
+
const { form: s, steps: n, error: i } = At(this._forms, t);
|
|
1573
|
+
if (i) {
|
|
1645
1574
|
this._handoffError = !0;
|
|
1646
1575
|
return;
|
|
1647
1576
|
}
|
|
1648
1577
|
this._handoffError = !1, this._origins = [...this._origins, {
|
|
1649
|
-
...
|
|
1578
|
+
...Ft(this._form, this._steps, e, t),
|
|
1650
1579
|
media: this.#s,
|
|
1651
1580
|
lostMedia: this.#r
|
|
1652
|
-
}], this._form = s, this._steps =
|
|
1581
|
+
}], this._form = s, this._steps = n, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#n();
|
|
1653
1582
|
}
|
|
1654
1583
|
/* Back past a hand-off: the originating form, on the choice card. */
|
|
1655
|
-
#
|
|
1584
|
+
#W() {
|
|
1656
1585
|
const e = this._origins.at(-1);
|
|
1657
|
-
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.#
|
|
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 });
|
|
1658
1587
|
}
|
|
1659
|
-
#
|
|
1588
|
+
#V() {
|
|
1660
1589
|
if (this._phase === "done" || this._phase === "submitting") return;
|
|
1661
1590
|
if (this._phase === "review") {
|
|
1662
|
-
this.#
|
|
1591
|
+
this.#n({ animate: !1 });
|
|
1663
1592
|
return;
|
|
1664
1593
|
}
|
|
1665
|
-
if (this._origins.length &&
|
|
1666
|
-
this.#
|
|
1594
|
+
if (this._origins.length && It(this._steps)) {
|
|
1595
|
+
this.#W();
|
|
1667
1596
|
return;
|
|
1668
1597
|
}
|
|
1669
1598
|
if (!this._steps.length) {
|
|
@@ -1671,10 +1600,10 @@ ${this.factsApi || ""}`;
|
|
|
1671
1600
|
return;
|
|
1672
1601
|
}
|
|
1673
1602
|
const e = this._steps.at(-1);
|
|
1674
|
-
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 });
|
|
1675
1604
|
}
|
|
1676
1605
|
#$() {
|
|
1677
|
-
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 =
|
|
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";
|
|
1678
1607
|
}
|
|
1679
1608
|
// ── Collect card ────────────────────────────────────────────────
|
|
1680
1609
|
#k(e, t) {
|
|
@@ -1691,23 +1620,23 @@ ${this.factsApi || ""}`;
|
|
|
1691
1620
|
const t = this._steps.filter((s) => s.kind === "collect").map((s) => s.nodeId);
|
|
1692
1621
|
return this.#S([...t, e]);
|
|
1693
1622
|
}
|
|
1694
|
-
#
|
|
1695
|
-
const t = e.fields || [], { ok: s, errors:
|
|
1623
|
+
#j(e) {
|
|
1624
|
+
const t = e.fields || [], { ok: s, errors: n } = fe(t, this._cardValues, {
|
|
1696
1625
|
mediaCount: this.#C(e.id)
|
|
1697
|
-
}),
|
|
1626
|
+
}), i = t.find((l) => l.kind === "media");
|
|
1698
1627
|
let o = !0;
|
|
1699
|
-
if (
|
|
1628
|
+
if (i) {
|
|
1700
1629
|
const l = this.#s[e.id] || [], d = Y(l, this._form.budget, {
|
|
1701
|
-
required: !!
|
|
1630
|
+
required: !!i.required
|
|
1702
1631
|
});
|
|
1703
|
-
d.ok ? l.length && (this.#r = { ...this.#r, [e.id]: [] }) : (o = !1, i
|
|
1632
|
+
d.ok ? l.length && (this.#r = { ...this.#r, [e.id]: [] }) : (o = !1, n[i.key] = d.errors[0].message);
|
|
1704
1633
|
}
|
|
1705
1634
|
if (!s || !o) {
|
|
1706
|
-
this._fieldErrors =
|
|
1635
|
+
this._fieldErrors = n;
|
|
1707
1636
|
return;
|
|
1708
1637
|
}
|
|
1709
1638
|
const a = this.#s[e.id] || [];
|
|
1710
|
-
this.#
|
|
1639
|
+
this.#m({
|
|
1711
1640
|
nodeId: e.id,
|
|
1712
1641
|
kind: "collect",
|
|
1713
1642
|
values: { ...this._cardValues },
|
|
@@ -1750,7 +1679,7 @@ ${this.factsApi || ""}`;
|
|
|
1750
1679
|
async #R(e) {
|
|
1751
1680
|
this._gate = { ...this._gate, error: "", loading: !0 };
|
|
1752
1681
|
try {
|
|
1753
|
-
await this.client.verifyCode(e), this.#
|
|
1682
|
+
await this.client.verifyCode(e), this.#O(this._gate.email);
|
|
1754
1683
|
} catch (t) {
|
|
1755
1684
|
this._gate = {
|
|
1756
1685
|
...this._gate,
|
|
@@ -1759,16 +1688,16 @@ ${this.factsApi || ""}`;
|
|
|
1759
1688
|
};
|
|
1760
1689
|
}
|
|
1761
1690
|
}
|
|
1762
|
-
#
|
|
1763
|
-
if (this.#
|
|
1691
|
+
#O(e) {
|
|
1692
|
+
if (this.#p = !!this._gate.newAccount, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit.stage === "auth") {
|
|
1764
1693
|
this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
|
|
1765
1694
|
return;
|
|
1766
1695
|
}
|
|
1767
1696
|
const { node: t } = this.#_;
|
|
1768
|
-
t?.type === "gate" && this.#
|
|
1697
|
+
t?.type === "gate" && this.#m({ nodeId: t.id, kind: "gate", email: e });
|
|
1769
1698
|
}
|
|
1770
1699
|
#Y() {
|
|
1771
|
-
this.client.signOut?.(), this.#
|
|
1700
|
+
this.client.signOut?.(), this.#p = !1, this._gate = { stage: "email", email: "", error: "", loading: !1 };
|
|
1772
1701
|
}
|
|
1773
1702
|
// ── Anonymous route ─────────────────────────────────────────────
|
|
1774
1703
|
#G() {
|
|
@@ -1783,22 +1712,22 @@ ${this.factsApi || ""}`;
|
|
|
1783
1712
|
*/
|
|
1784
1713
|
#Q() {
|
|
1785
1714
|
const { node: e } = this.#_;
|
|
1786
|
-
e?.type === "gate" && (this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#
|
|
1715
|
+
e?.type === "gate" && (this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#m({ nodeId: e.id, kind: "gate", anonymous: !0 }));
|
|
1787
1716
|
}
|
|
1788
|
-
async #
|
|
1717
|
+
async #M() {
|
|
1789
1718
|
try {
|
|
1790
1719
|
return await this.client.createAnonSession({
|
|
1791
1720
|
formId: this._form.formId,
|
|
1792
1721
|
requestId: this.#t
|
|
1793
1722
|
}), !0;
|
|
1794
1723
|
} catch (e) {
|
|
1795
|
-
return this._banner =
|
|
1724
|
+
return this._banner = me(e?.status ?? 0, e?.body ?? null), !1;
|
|
1796
1725
|
}
|
|
1797
1726
|
}
|
|
1798
1727
|
/* An anonymous session outliving the upload run re-mints in place; there
|
|
1799
1728
|
* is no identity to send back to the sign-in card. */
|
|
1800
1729
|
async #Z() {
|
|
1801
|
-
if (await this.#
|
|
1730
|
+
if (await this.#M()) {
|
|
1802
1731
|
this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
|
|
1803
1732
|
return;
|
|
1804
1733
|
}
|
|
@@ -1814,33 +1743,33 @@ ${this.factsApi || ""}`;
|
|
|
1814
1743
|
return e;
|
|
1815
1744
|
}
|
|
1816
1745
|
#e(e) {
|
|
1817
|
-
this._submit =
|
|
1746
|
+
this._submit = Zt(this._submit, e);
|
|
1818
1747
|
}
|
|
1819
1748
|
async #J() {
|
|
1820
1749
|
this._banner = null;
|
|
1821
1750
|
for (let e = 0; e < this._steps.length; e++) {
|
|
1822
1751
|
const t = this._steps[e];
|
|
1823
1752
|
if (t.kind !== "collect") continue;
|
|
1824
|
-
const s = x(this._form, t.nodeId),
|
|
1825
|
-
mediaCount: this.#S(
|
|
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)
|
|
1826
1755
|
}), a = (s?.fields || []).find((d) => d.kind === "media");
|
|
1827
1756
|
let l = !0;
|
|
1828
1757
|
if (a) {
|
|
1829
|
-
const d = this.#s[t.nodeId] || [],
|
|
1758
|
+
const d = this.#s[t.nodeId] || [], h = Y(d, this._form.budget, {
|
|
1830
1759
|
required: !!a.required
|
|
1831
1760
|
});
|
|
1832
|
-
|
|
1761
|
+
h.ok || (l = !1, o[a.key] = h.errors[0].message);
|
|
1833
1762
|
}
|
|
1834
|
-
if (!
|
|
1835
|
-
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 });
|
|
1836
1765
|
return;
|
|
1837
1766
|
}
|
|
1838
1767
|
}
|
|
1839
|
-
if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#
|
|
1840
|
-
if (!await this.#
|
|
1768
|
+
if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#g) {
|
|
1769
|
+
if (!await this.#M()) return;
|
|
1841
1770
|
} else
|
|
1842
1771
|
this.client.endAnonSession?.();
|
|
1843
|
-
if (this._submit =
|
|
1772
|
+
if (this._submit = D(this.#y), this._phase = "submitting", this.#g) {
|
|
1844
1773
|
this.#e({ type: "START" }), this.#a();
|
|
1845
1774
|
return;
|
|
1846
1775
|
}
|
|
@@ -1853,12 +1782,12 @@ ${this.factsApi || ""}`;
|
|
|
1853
1782
|
async #a() {
|
|
1854
1783
|
const e = this._submit.stage;
|
|
1855
1784
|
if (e === "minting") return this.#X();
|
|
1856
|
-
if (e === "uploading") return this.#
|
|
1785
|
+
if (e === "uploading") return this.#N();
|
|
1857
1786
|
if (e === "requesting") return this.#se();
|
|
1858
1787
|
}
|
|
1859
1788
|
async #X() {
|
|
1860
1789
|
try {
|
|
1861
|
-
const e = await this.client.createUploads(
|
|
1790
|
+
const e = await this.client.createUploads(ge({
|
|
1862
1791
|
formId: this._form.formId,
|
|
1863
1792
|
requestId: this.#t,
|
|
1864
1793
|
files: this.#y
|
|
@@ -1868,14 +1797,14 @@ ${this.factsApi || ""}`;
|
|
|
1868
1797
|
this.#F(e);
|
|
1869
1798
|
}
|
|
1870
1799
|
}
|
|
1871
|
-
#
|
|
1872
|
-
const e = this._submit.files, t = this.#
|
|
1800
|
+
#N() {
|
|
1801
|
+
const e = this._submit.files, t = this.#i.size;
|
|
1873
1802
|
let s = 0;
|
|
1874
|
-
for (let
|
|
1875
|
-
e[
|
|
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));
|
|
1876
1805
|
}
|
|
1877
1806
|
#ee(e) {
|
|
1878
|
-
const t = this._submit.files[e], s = this.#y[e], { promise:
|
|
1807
|
+
const t = this._submit.files[e], s = this.#y[e], { promise: n, abort: i } = this.client.uploadFile({
|
|
1879
1808
|
url: t.url,
|
|
1880
1809
|
file: s,
|
|
1881
1810
|
contentType: t.type,
|
|
@@ -1883,10 +1812,10 @@ ${this.factsApi || ""}`;
|
|
|
1883
1812
|
this.#e({ type: "FILE_PROGRESS", i: e, loaded: o, total: a });
|
|
1884
1813
|
}
|
|
1885
1814
|
});
|
|
1886
|
-
this.#
|
|
1887
|
-
this.#
|
|
1815
|
+
this.#i.set(e, { abort: i }), n.then(() => {
|
|
1816
|
+
this.#i.delete(e), this.#e({ type: "FILE_DONE", i: e }), this.#a();
|
|
1888
1817
|
}).catch((o) => {
|
|
1889
|
-
this.#
|
|
1818
|
+
this.#i.delete(e), this.#e({
|
|
1890
1819
|
type: "FILE_FAIL",
|
|
1891
1820
|
i: e,
|
|
1892
1821
|
error: o?.status === 403 ? "expired" : "failed"
|
|
@@ -1896,7 +1825,7 @@ ${this.factsApi || ""}`;
|
|
|
1896
1825
|
async #te(e) {
|
|
1897
1826
|
if (this._submit.files[e].error === "expired")
|
|
1898
1827
|
try {
|
|
1899
|
-
const [s] = await this.client.createUploads(
|
|
1828
|
+
const [s] = await this.client.createUploads(ge({
|
|
1900
1829
|
formId: this._form.formId,
|
|
1901
1830
|
requestId: this.#t,
|
|
1902
1831
|
files: [this.#y[e]]
|
|
@@ -1908,28 +1837,28 @@ ${this.factsApi || ""}`;
|
|
|
1908
1837
|
}
|
|
1909
1838
|
else
|
|
1910
1839
|
this.#e({ type: "RETRY_FILE", i: e });
|
|
1911
|
-
this.#
|
|
1840
|
+
this.#N();
|
|
1912
1841
|
}
|
|
1913
1842
|
async #se() {
|
|
1914
1843
|
try {
|
|
1915
|
-
const e = this._submit.files.map(({ assetId: s, type:
|
|
1844
|
+
const e = this._submit.files.map(({ assetId: s, type: n }) => ({ assetId: s, type: n })), t = await this.client.putRequest(this.#t, zt({
|
|
1916
1845
|
form: this._form,
|
|
1917
1846
|
steps: this._steps,
|
|
1918
1847
|
media: e
|
|
1919
1848
|
}));
|
|
1920
|
-
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";
|
|
1921
1850
|
} catch (e) {
|
|
1922
1851
|
this.#F(e);
|
|
1923
1852
|
}
|
|
1924
1853
|
}
|
|
1925
1854
|
// ── Save to My WRAL (new accounts only) ─────────────────────────
|
|
1926
1855
|
#re() {
|
|
1927
|
-
if (!this.#
|
|
1928
|
-
this.#
|
|
1929
|
-
const e =
|
|
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));
|
|
1930
1859
|
e.length && (this._factsOffer = { stage: "offer", facts: e });
|
|
1931
1860
|
}
|
|
1932
|
-
async #
|
|
1861
|
+
async #ne() {
|
|
1933
1862
|
const e = this._factsOffer;
|
|
1934
1863
|
if (!(!e || e.stage === "saving")) {
|
|
1935
1864
|
this._factsOffer = { ...e, stage: "saving" };
|
|
@@ -1941,9 +1870,9 @@ ${this.factsApi || ""}`;
|
|
|
1941
1870
|
}
|
|
1942
1871
|
}
|
|
1943
1872
|
#F(e) {
|
|
1944
|
-
const t =
|
|
1873
|
+
const t = me(e?.status ?? 0, e?.body ?? null);
|
|
1945
1874
|
if (t.kind === "auth") {
|
|
1946
|
-
if (this.#e({ type: "AUTH_REQUIRED" }), this.#
|
|
1875
|
+
if (this.#e({ type: "AUTH_REQUIRED" }), this.#g) {
|
|
1947
1876
|
this.#Z();
|
|
1948
1877
|
return;
|
|
1949
1878
|
}
|
|
@@ -1951,12 +1880,12 @@ ${this.factsApi || ""}`;
|
|
|
1951
1880
|
return;
|
|
1952
1881
|
}
|
|
1953
1882
|
if (t.kind === "stale") {
|
|
1954
|
-
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#
|
|
1883
|
+
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#ie();
|
|
1955
1884
|
return;
|
|
1956
1885
|
}
|
|
1957
1886
|
this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t });
|
|
1958
1887
|
}
|
|
1959
|
-
async #
|
|
1888
|
+
async #ie() {
|
|
1960
1889
|
try {
|
|
1961
1890
|
this._forms = await this.client.listForms();
|
|
1962
1891
|
const e = this._forms.find((t) => t.formId === this._form.formId);
|
|
@@ -1979,11 +1908,11 @@ ${this.factsApi || ""}`;
|
|
|
1979
1908
|
#ae() {
|
|
1980
1909
|
switch (this._phase) {
|
|
1981
1910
|
case "loading":
|
|
1982
|
-
return c`${
|
|
1983
|
-
${
|
|
1911
|
+
return c`${m(V, this._loadingSlow ? "Loading the form list…" : j)}
|
|
1912
|
+
${W()}`;
|
|
1984
1913
|
case "load-error":
|
|
1985
1914
|
return c`
|
|
1986
|
-
${
|
|
1915
|
+
${m("We could not load the forms.", "Check your connection and try again.", { error: !0 })}
|
|
1987
1916
|
<div class="options">
|
|
1988
1917
|
<button type="button" class="chip" @click=${() => this.#v()}>Try again</button>
|
|
1989
1918
|
</div>
|
|
@@ -1991,21 +1920,21 @@ ${this.factsApi || ""}`;
|
|
|
1991
1920
|
case "pick":
|
|
1992
1921
|
return this.#le();
|
|
1993
1922
|
case "walk":
|
|
1994
|
-
return c`${this.#b()}${this._typing ?
|
|
1923
|
+
return c`${this.#b()}${this._typing ? W() : this.#ce()}`;
|
|
1995
1924
|
case "review":
|
|
1996
|
-
return c`${this.#b()}${this.#
|
|
1925
|
+
return c`${this.#b()}${this.#U()}`;
|
|
1997
1926
|
case "submitting":
|
|
1998
1927
|
return c`${this.#b()}${this.#be()}`;
|
|
1999
1928
|
case "done":
|
|
2000
1929
|
return c`${this.#b()}${this.#xe ? this.#_e() : c`${this.#ve()}${this.#we()}`}`;
|
|
2001
1930
|
default:
|
|
2002
|
-
return
|
|
1931
|
+
return f;
|
|
2003
1932
|
}
|
|
2004
1933
|
}
|
|
2005
1934
|
#le() {
|
|
2006
1935
|
const e = this._forms.filter((t) => t.listed !== !1);
|
|
2007
1936
|
return c`
|
|
2008
|
-
${
|
|
1937
|
+
${m(V, j, { noAnim: !0 })}
|
|
2009
1938
|
<div class="options" role="group" aria-label=${Te}>
|
|
2010
1939
|
${e.map((t, s) => c`
|
|
2011
1940
|
<button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
|
|
@@ -2024,48 +1953,48 @@ ${this.factsApi || ""}`;
|
|
|
2024
1953
|
const e = [];
|
|
2025
1954
|
if (!this._form) return e;
|
|
2026
1955
|
const t = this._origins[0]?.form || this._form;
|
|
2027
|
-
e.push(
|
|
1956
|
+
e.push(m(V, j, { noAnim: !0 })), e.push(v(t.title, { noAnim: !0 })), this._notice && e.push(m(this._notice, "", { noAnim: !0 }));
|
|
2028
1957
|
let s = null;
|
|
2029
|
-
for (const
|
|
2030
|
-
e.push(...this.#
|
|
2031
|
-
const
|
|
2032
|
-
|
|
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 }));
|
|
2033
1962
|
}
|
|
2034
|
-
return e.push(...this.#
|
|
2035
|
-
}
|
|
2036
|
-
#
|
|
2037
|
-
const
|
|
2038
|
-
for (const
|
|
2039
|
-
if (
|
|
2040
|
-
const a =
|
|
2041
|
-
a !== s &&
|
|
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 }));
|
|
2042
1971
|
continue;
|
|
2043
1972
|
}
|
|
2044
|
-
const o = x(e,
|
|
2045
|
-
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(
|
|
2046
1975
|
"Last step: how can we reach you?",
|
|
2047
1976
|
"You chose to send this anonymously.",
|
|
2048
1977
|
{ noAnim: !0 }
|
|
2049
|
-
) :
|
|
1978
|
+
) : m(
|
|
2050
1979
|
"Almost done: verify your email so we can follow up.",
|
|
2051
1980
|
"One address, one code. No password needed.",
|
|
2052
1981
|
{ noAnim: !0 }
|
|
2053
|
-
)),
|
|
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 }));
|
|
2054
1983
|
}
|
|
2055
|
-
return
|
|
1984
|
+
return n;
|
|
2056
1985
|
}
|
|
2057
1986
|
#ce() {
|
|
2058
1987
|
const { node: e, error: t } = this.#_;
|
|
2059
|
-
return t || !e ?
|
|
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;
|
|
2060
1989
|
}
|
|
2061
1990
|
#de(e) {
|
|
2062
1991
|
return c`
|
|
2063
|
-
${
|
|
2064
|
-
${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}
|
|
2065
1994
|
<div class="options" role="group" aria-label=${e.prompt || "Choose one"}>
|
|
2066
1995
|
${(e.options || []).map((t, s) => c`
|
|
2067
1996
|
<button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
|
|
2068
|
-
@click=${() => this.#
|
|
1997
|
+
@click=${() => this.#H(e, t)}>${t.label}</button>
|
|
2069
1998
|
`)}
|
|
2070
1999
|
</div>
|
|
2071
2000
|
`;
|
|
@@ -2079,53 +2008,53 @@ ${this.factsApi || ""}`;
|
|
|
2079
2008
|
#ue(e) {
|
|
2080
2009
|
const t = e.fields || [];
|
|
2081
2010
|
return c`
|
|
2082
|
-
${
|
|
2011
|
+
${m(e.prompt, e.help)}
|
|
2083
2012
|
<form class="form-card" autocomplete="on" novalidate
|
|
2084
2013
|
@submit=${(s) => {
|
|
2085
|
-
s.preventDefault(), this.#
|
|
2014
|
+
s.preventDefault(), this.#j(e);
|
|
2086
2015
|
}}>
|
|
2087
|
-
${t.map((s) => this.#
|
|
2016
|
+
${t.map((s) => this.#he(e, s))}
|
|
2088
2017
|
<button type="submit" class="btn-primary">Continue</button>
|
|
2089
2018
|
</form>
|
|
2090
2019
|
`;
|
|
2091
2020
|
}
|
|
2092
|
-
#
|
|
2021
|
+
#he(e, t) {
|
|
2093
2022
|
const s = this.#C(e.id);
|
|
2094
2023
|
if (t.kind === "consent" && t.requiredIf === "media" && s === 0)
|
|
2095
|
-
return
|
|
2096
|
-
const
|
|
2024
|
+
return f;
|
|
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`
|
|
2097
2026
|
<label for="f-${t.key}">${t.label}${o}</label>
|
|
2098
2027
|
`;
|
|
2099
2028
|
return c`
|
|
2100
2029
|
<div class="field">
|
|
2101
2030
|
${a}
|
|
2102
|
-
${this.#
|
|
2103
|
-
${
|
|
2031
|
+
${this.#pe(e, t, n)}
|
|
2032
|
+
${i ? c`<div class="err" role="alert">${i}</div>` : f}
|
|
2104
2033
|
</div>
|
|
2105
2034
|
`;
|
|
2106
2035
|
}
|
|
2107
|
-
#
|
|
2108
|
-
const
|
|
2036
|
+
#pe(e, t, s) {
|
|
2037
|
+
const n = (i) => (o) => this.#k(i, o.target.value);
|
|
2109
2038
|
switch (t.kind) {
|
|
2110
2039
|
case "text":
|
|
2111
2040
|
return c`<input type="text" id="f-${t.key}" name=${t.key} .value=${s || ""}
|
|
2112
2041
|
inputmode=${ce(t.inputMode)} autocomplete=${ce(t.autocomplete)}
|
|
2113
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2042
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
|
|
2114
2043
|
case "url":
|
|
2115
2044
|
return c`<input type="url" id="f-${t.key}" .value=${s || ""}
|
|
2116
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2045
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
|
|
2117
2046
|
case "textarea":
|
|
2118
2047
|
return c`<textarea id="f-${t.key}" .value=${s || ""}
|
|
2119
|
-
placeholder=${t.placeholder || ""} @input=${
|
|
2048
|
+
placeholder=${t.placeholder || ""} @input=${n(t.key)}></textarea>`;
|
|
2120
2049
|
case "datetime":
|
|
2121
2050
|
return c`<input type="datetime-local" id="f-${t.key}" .value=${s || ""}
|
|
2122
|
-
@input=${
|
|
2051
|
+
@input=${n(t.key)}>`;
|
|
2123
2052
|
case "select":
|
|
2124
2053
|
return c`
|
|
2125
|
-
<select id="f-${t.key}" @change=${
|
|
2054
|
+
<select id="f-${t.key}" @change=${n(t.key)}>
|
|
2126
2055
|
<option value="">Choose one</option>
|
|
2127
|
-
${(t.options || []).map((
|
|
2128
|
-
<option value=${
|
|
2056
|
+
${(t.options || []).map((i) => c`
|
|
2057
|
+
<option value=${i.id} ?selected=${s === i.id}>${i.label}</option>
|
|
2129
2058
|
`)}
|
|
2130
2059
|
</select>
|
|
2131
2060
|
`;
|
|
@@ -2135,9 +2064,9 @@ ${this.factsApi || ""}`;
|
|
|
2135
2064
|
return c`
|
|
2136
2065
|
<div class="consent-row">
|
|
2137
2066
|
<input type="checkbox" id="f-${t.key}" .checked=${s === !0}
|
|
2138
|
-
@change=${(
|
|
2067
|
+
@change=${(i) => this.#k(t.key, i.target.checked)}>
|
|
2139
2068
|
<label for="f-${t.key}" style="all: unset; cursor: pointer;">
|
|
2140
|
-
${t.text ||
|
|
2069
|
+
${t.text || as}
|
|
2141
2070
|
</label>
|
|
2142
2071
|
</div>
|
|
2143
2072
|
`;
|
|
@@ -2149,34 +2078,34 @@ ${this.factsApi || ""}`;
|
|
|
2149
2078
|
.budget=${this._form.budget || {}}
|
|
2150
2079
|
?required=${!!t.required}
|
|
2151
2080
|
label=${t.label}
|
|
2152
|
-
@files-changed=${(
|
|
2153
|
-
this.#s = { ...this.#s, [e.id]:
|
|
2081
|
+
@files-changed=${(i) => {
|
|
2082
|
+
this.#s = { ...this.#s, [e.id]: i.detail.files }, this.requestUpdate();
|
|
2154
2083
|
}}></wral-report-media>
|
|
2155
2084
|
`;
|
|
2156
2085
|
default:
|
|
2157
|
-
return
|
|
2086
|
+
return f;
|
|
2158
2087
|
}
|
|
2159
2088
|
}
|
|
2160
2089
|
#fe(e, t) {
|
|
2161
|
-
const s = e.counties ||
|
|
2090
|
+
const s = e.counties || Xt, n = (i) => this.#k(e.key, { ...t, ...i });
|
|
2162
2091
|
return c`
|
|
2163
2092
|
<select id="f-${e.key}" aria-label="County"
|
|
2164
|
-
@change=${(
|
|
2093
|
+
@change=${(i) => n({ county: i.target.value || void 0 })}>
|
|
2165
2094
|
<option value="">Choose a county</option>
|
|
2166
|
-
${s.map((
|
|
2167
|
-
<option value=${
|
|
2095
|
+
${s.map((i) => c`
|
|
2096
|
+
<option value=${i} ?selected=${t.county === i}>${i}</option>
|
|
2168
2097
|
`)}
|
|
2169
2098
|
</select>
|
|
2170
2099
|
<input type="text" style="margin-top: 8px;"
|
|
2171
2100
|
aria-label="Nearest town or crossroads"
|
|
2172
2101
|
placeholder="Nearest town or crossroads"
|
|
2173
2102
|
.value=${t.where || ""}
|
|
2174
|
-
@input=${(
|
|
2103
|
+
@input=${(i) => n({ where: i.target.value || void 0 })}>
|
|
2175
2104
|
`;
|
|
2176
2105
|
}
|
|
2177
|
-
#
|
|
2106
|
+
#P(e) {
|
|
2178
2107
|
this.#T();
|
|
2179
|
-
const t = this._gate, s =
|
|
2108
|
+
const t = this._gate, s = m(
|
|
2180
2109
|
"Almost done: verify your email so we can follow up.",
|
|
2181
2110
|
"One address, one code. No password needed."
|
|
2182
2111
|
);
|
|
@@ -2187,7 +2116,7 @@ ${this.factsApi || ""}`;
|
|
|
2187
2116
|
You are signed in as <strong>${t.email || "your My WRAL account"}</strong> on this device.
|
|
2188
2117
|
</p>
|
|
2189
2118
|
<button type="button" class="btn-primary"
|
|
2190
|
-
@click=${() => this.#
|
|
2119
|
+
@click=${() => this.#O(t.email)}>Continue</button>
|
|
2191
2120
|
<button type="button" class="btn-ghost"
|
|
2192
2121
|
@click=${() => this.#Y()}>Use a different email</button>
|
|
2193
2122
|
</div>
|
|
@@ -2202,14 +2131,14 @@ ${this.factsApi || ""}`;
|
|
|
2202
2131
|
<label for="gate-email">Email address</label>
|
|
2203
2132
|
<input type="email" id="gate-email" autocomplete="email"
|
|
2204
2133
|
placeholder="you@example.com" .value=${t.email}
|
|
2205
|
-
@input=${(
|
|
2206
|
-
this._gate = { ...t, email:
|
|
2134
|
+
@input=${(n) => {
|
|
2135
|
+
this._gate = { ...t, email: n.target.value };
|
|
2207
2136
|
}}
|
|
2208
|
-
@keydown=${(
|
|
2209
|
-
|
|
2137
|
+
@keydown=${(n) => {
|
|
2138
|
+
n.key === "Enter" && this.#A();
|
|
2210
2139
|
}}>
|
|
2211
2140
|
</div>
|
|
2212
|
-
${t.error ? c`<div class="err" role="alert">${t.error}</div>` :
|
|
2141
|
+
${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
|
|
2213
2142
|
<button type="button" class="login-btn" ?disabled=${t.loading}
|
|
2214
2143
|
@click=${() => this.#A()}>
|
|
2215
2144
|
${t.loading ? "Sending…" : "Continue with email"}
|
|
@@ -2220,12 +2149,12 @@ ${this.factsApi || ""}`;
|
|
|
2220
2149
|
<li>We can follow up on your report</li>
|
|
2221
2150
|
<li>Your contact information fills in automatically next time</li>
|
|
2222
2151
|
<li>You are credited by name when we use your photos or video</li>
|
|
2223
|
-
<li><a href=${
|
|
2152
|
+
<li><a href=${es} target="_blank" rel="noopener">All other My WRAL account benefits</a></li>
|
|
2224
2153
|
</ul>
|
|
2225
2154
|
</div>
|
|
2226
|
-
${this._submit.stage === "auth" ?
|
|
2155
|
+
${this._submit.stage === "auth" ? f : this.#ge()}
|
|
2227
2156
|
</div>
|
|
2228
|
-
` : t.stage === "anon-confirm" ? this.#
|
|
2157
|
+
` : t.stage === "anon-confirm" ? this.#me(s) : c`
|
|
2229
2158
|
${s}
|
|
2230
2159
|
<div class="form-card login-card">
|
|
2231
2160
|
<h2>Enter verification code</h2>
|
|
@@ -2239,14 +2168,14 @@ ${this.factsApi || ""}`;
|
|
|
2239
2168
|
<div class="field">
|
|
2240
2169
|
<label>Verification code</label>
|
|
2241
2170
|
<wral-code-input
|
|
2242
|
-
@code-complete=${(
|
|
2171
|
+
@code-complete=${(n) => this.#R(n.detail?.code ?? n.detail?.value ?? n.target.value)}>
|
|
2243
2172
|
</wral-code-input>
|
|
2244
2173
|
</div>
|
|
2245
|
-
${t.error ? c`<div class="err" role="alert">${t.error}</div>` :
|
|
2174
|
+
${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
|
|
2246
2175
|
<button type="button" class="login-btn" ?disabled=${t.loading}
|
|
2247
2176
|
@click=${() => {
|
|
2248
|
-
const
|
|
2249
|
-
this.#R(
|
|
2177
|
+
const n = this.renderRoot.querySelector("wral-code-input");
|
|
2178
|
+
this.#R(n?.value || "");
|
|
2250
2179
|
}}>
|
|
2251
2180
|
${t.loading ? "Checking…" : "Sign in"}
|
|
2252
2181
|
</button>
|
|
@@ -2255,18 +2184,18 @@ ${this.factsApi || ""}`;
|
|
|
2255
2184
|
<button type="button" @click=${() => this.#A()}>resend a new code</button>.
|
|
2256
2185
|
</p>
|
|
2257
2186
|
</div>
|
|
2258
|
-
` : c`${s}${
|
|
2187
|
+
` : c`${s}${W()}`;
|
|
2259
2188
|
}
|
|
2260
2189
|
/* Collapsed by default: findable for whoever needs it, never the
|
|
2261
2190
|
* first thing a viewer reaches for. */
|
|
2262
|
-
#
|
|
2191
|
+
#ge() {
|
|
2263
2192
|
return c`
|
|
2264
2193
|
<details class="login-alt">
|
|
2265
2194
|
<summary>Other ways to send this</summary>
|
|
2266
2195
|
<div class="alt-body">
|
|
2267
2196
|
<p class="alt-row">
|
|
2268
2197
|
Call the newsroom desk at
|
|
2269
|
-
<a href=${
|
|
2198
|
+
<a href=${ss(xe)}>${xe}</a>.
|
|
2270
2199
|
</p>
|
|
2271
2200
|
${this.#L ? c`
|
|
2272
2201
|
<p class="alt-row">
|
|
@@ -2274,12 +2203,12 @@ ${this.factsApi || ""}`;
|
|
|
2274
2203
|
@click=${() => this.#G()}>Send this anonymously</button>
|
|
2275
2204
|
— no follow-up, and no credit if we use your photos or video.
|
|
2276
2205
|
</p>
|
|
2277
|
-
` :
|
|
2206
|
+
` : f}
|
|
2278
2207
|
</div>
|
|
2279
2208
|
</details>
|
|
2280
2209
|
`;
|
|
2281
2210
|
}
|
|
2282
|
-
#
|
|
2211
|
+
#me(e) {
|
|
2283
2212
|
return c`
|
|
2284
2213
|
${e}
|
|
2285
2214
|
<div class="form-card login-card">
|
|
@@ -2288,7 +2217,7 @@ ${this.factsApi || ""}`;
|
|
|
2288
2217
|
You can send this report without an account. Here is what it costs you.
|
|
2289
2218
|
</p>
|
|
2290
2219
|
<ul class="anon-costs">
|
|
2291
|
-
${
|
|
2220
|
+
${ts.map((t) => c`
|
|
2292
2221
|
<li><span class="x" aria-hidden="true">✕</span><span>${t}</span></li>
|
|
2293
2222
|
`)}
|
|
2294
2223
|
</ul>
|
|
@@ -2320,22 +2249,22 @@ ${this.factsApi || ""}`;
|
|
|
2320
2249
|
</div>
|
|
2321
2250
|
`;
|
|
2322
2251
|
}
|
|
2323
|
-
#
|
|
2252
|
+
#U() {
|
|
2324
2253
|
const e = Vt(this._form, this._steps);
|
|
2325
2254
|
return c`
|
|
2326
|
-
${
|
|
2255
|
+
${m("Here is what you are sending.", "Check it over, then submit.")}
|
|
2327
2256
|
<div class="form-card">
|
|
2328
2257
|
<ul class="review-list">
|
|
2329
2258
|
${e.map((t) => c`
|
|
2330
2259
|
<li>
|
|
2331
2260
|
<span class="k">${t.k}</span>
|
|
2332
|
-
<span>${t.pill ?
|
|
2261
|
+
<span>${t.pill ? ot(t.pill) : t.v}</span>
|
|
2333
2262
|
</li>
|
|
2334
2263
|
`)}
|
|
2335
2264
|
</ul>
|
|
2336
2265
|
${this._banner ? c`
|
|
2337
2266
|
<div class="err" role="alert" style="margin-top: 12px;">${this._banner.message}</div>
|
|
2338
|
-
` :
|
|
2267
|
+
` : f}
|
|
2339
2268
|
<div style="margin-top: 16px;">
|
|
2340
2269
|
<button type="button" class="btn-primary" @click=${() => this.#J()}>
|
|
2341
2270
|
Submit report
|
|
@@ -2346,7 +2275,7 @@ ${this.factsApi || ""}`;
|
|
|
2346
2275
|
}
|
|
2347
2276
|
#be() {
|
|
2348
2277
|
const e = this._submit;
|
|
2349
|
-
if (e.stage === "auth") return this.#
|
|
2278
|
+
if (e.stage === "auth") return this.#P({ id: null, type: "gate" });
|
|
2350
2279
|
const t = {
|
|
2351
2280
|
minting: "Preparing your uploads…",
|
|
2352
2281
|
uploading: "Uploading your files…",
|
|
@@ -2355,9 +2284,9 @@ ${this.factsApi || ""}`;
|
|
|
2355
2284
|
"requesting-error": this._banner?.message || "We could not send your report."
|
|
2356
2285
|
}[e.stage] || "Working…";
|
|
2357
2286
|
return c`
|
|
2358
|
-
${
|
|
2287
|
+
${m("Submitting your report.", t)}
|
|
2359
2288
|
<div class="form-card">
|
|
2360
|
-
${e.files.map((s,
|
|
2289
|
+
${e.files.map((s, n) => c`
|
|
2361
2290
|
<div class="upload-row">
|
|
2362
2291
|
<span class="name">${s.name}</span>
|
|
2363
2292
|
<div class="upload-bar" role="progressbar"
|
|
@@ -2369,10 +2298,10 @@ ${this.factsApi || ""}`;
|
|
|
2369
2298
|
${s.status === "done" ? "Done" : s.status === "failed" ? "Failed" : "Uploading"}
|
|
2370
2299
|
</span>
|
|
2371
2300
|
${s.status === "failed" ? c`
|
|
2372
|
-
<button type="button" class="retry-chip" @click=${() => this.#te(
|
|
2301
|
+
<button type="button" class="retry-chip" @click=${() => this.#te(n)}>
|
|
2373
2302
|
Retry
|
|
2374
2303
|
</button>
|
|
2375
|
-
` :
|
|
2304
|
+
` : f}
|
|
2376
2305
|
</div>
|
|
2377
2306
|
`)}
|
|
2378
2307
|
${e.stage === "requesting-error" ? c`
|
|
@@ -2380,39 +2309,34 @@ ${this.factsApi || ""}`;
|
|
|
2380
2309
|
${this._banner?.retryAfter ? c`
|
|
2381
2310
|
<div class="file-note">You can try again in about
|
|
2382
2311
|
${Math.ceil(this._banner.retryAfter / 60)} minutes.</div>
|
|
2383
|
-
` :
|
|
2312
|
+
` : f}
|
|
2384
2313
|
<button type="button" class="btn-primary" style="margin-top: 8px;"
|
|
2385
2314
|
@click=${() => this.#oe()}>Try again</button>
|
|
2386
|
-
` :
|
|
2315
|
+
` : f}
|
|
2387
2316
|
${we(e).length && e.stage === "uploading-error" ? c`
|
|
2388
2317
|
<div class="err" role="alert">Retry the failed
|
|
2389
2318
|
${we(e).length === 1 ? "file" : "files"} to continue.</div>
|
|
2390
|
-
` :
|
|
2319
|
+
` : f}
|
|
2391
2320
|
</div>
|
|
2392
2321
|
`;
|
|
2393
2322
|
}
|
|
2394
2323
|
#we() {
|
|
2395
|
-
const e = Ie(this._form, this._steps), t =
|
|
2396
|
-
routing: this._result?.routing || {},
|
|
2397
|
-
flags: e,
|
|
2398
|
-
reference: this._result?.reference || "",
|
|
2399
|
-
anonymous: this.#u
|
|
2400
|
-
});
|
|
2324
|
+
const e = Ie(this._form, this._steps), t = jt(this._result, e);
|
|
2401
2325
|
return c`
|
|
2402
2326
|
<div class="confirm-card">
|
|
2403
2327
|
<div class="c-head">
|
|
2404
|
-
<div class="c-check">${
|
|
2328
|
+
<div class="c-check">${at()}</div>
|
|
2405
2329
|
<div>
|
|
2406
2330
|
<div class="eyebrow">Report received</div>
|
|
2407
2331
|
<h2>${t.title}</h2>
|
|
2408
2332
|
</div>
|
|
2409
2333
|
</div>
|
|
2410
2334
|
<p>${t.body}</p>
|
|
2411
|
-
${t.urgentNote ? c`<p>${t.urgentNote}</p>` :
|
|
2335
|
+
${t.urgentNote ? c`<p>${t.urgentNote}</p>` : f}
|
|
2412
2336
|
${this._factsOffer?.stage === "saved" ? c`
|
|
2413
|
-
<p role="status">Your ${this.#
|
|
2337
|
+
<p role="status">Your ${this.#z} ${this._factsOffer.facts.length === 1 ? "is" : "are"}
|
|
2414
2338
|
saved to your My WRAL account.</p>
|
|
2415
|
-
` :
|
|
2339
|
+
` : f}
|
|
2416
2340
|
<div class="refs">
|
|
2417
2341
|
<span class="ref"><span class="rk">Reference</span>${this._result?.reference || ""}</span>
|
|
2418
2342
|
</div>
|
|
@@ -2420,39 +2344,24 @@ ${this.factsApi || ""}`;
|
|
|
2420
2344
|
Start a new report
|
|
2421
2345
|
</button>
|
|
2422
2346
|
</div>
|
|
2423
|
-
<div class="journey">
|
|
2424
|
-
<div class="j-eyebrow">Behind the scenes</div>
|
|
2425
|
-
<div class="j-title">What happens to your report now</div>
|
|
2426
|
-
${s.map((i, n) => c`
|
|
2427
|
-
<div class="j-step">
|
|
2428
|
-
<div class="j-dot">${n + 1}</div>
|
|
2429
|
-
<div class="j-body">
|
|
2430
|
-
<div class="j-t">${i.title}
|
|
2431
|
-
${i.pill ? c` <span class="flag-pill urgent">${i.pill}</span>` : h}
|
|
2432
|
-
</div>
|
|
2433
|
-
<div class="j-d">${i.body}</div>
|
|
2434
|
-
</div>
|
|
2435
|
-
</div>
|
|
2436
|
-
`)}
|
|
2437
|
-
</div>
|
|
2438
2347
|
`;
|
|
2439
2348
|
}
|
|
2440
2349
|
/* The offer is a step of its own: the confirmation waits for Save or No thanks. */
|
|
2441
2350
|
get #xe() {
|
|
2442
2351
|
return ["offer", "saving", "error"].includes(this._factsOffer?.stage);
|
|
2443
2352
|
}
|
|
2444
|
-
get #
|
|
2353
|
+
get #z() {
|
|
2445
2354
|
return (this._factsOffer?.facts || []).map((e) => e.label.toLowerCase()).join(" and ");
|
|
2446
2355
|
}
|
|
2447
2356
|
#ve() {
|
|
2448
2357
|
const e = this._factsOffer?.stage;
|
|
2449
|
-
return e === "saved" ? v("Save to my account", { noAnim: !0 }) : e === "dismissed" ? v("No thanks", { noAnim: !0 }) :
|
|
2358
|
+
return e === "saved" ? v("Save to my account", { noAnim: !0 }) : e === "dismissed" ? v("No thanks", { noAnim: !0 }) : f;
|
|
2450
2359
|
}
|
|
2451
2360
|
#_e() {
|
|
2452
2361
|
const e = this._factsOffer, t = e.stage === "saving";
|
|
2453
2362
|
return c`
|
|
2454
|
-
${
|
|
2455
|
-
`One more step: save your ${this.#
|
|
2363
|
+
${m(
|
|
2364
|
+
`One more step: save your ${this.#z} to your new My WRAL account?`,
|
|
2456
2365
|
"Only what is listed here is saved."
|
|
2457
2366
|
)}
|
|
2458
2367
|
<div class="form-card facts-offer">
|
|
@@ -2460,15 +2369,15 @@ ${this.factsApi || ""}`;
|
|
|
2460
2369
|
${e.facts.map((s) => c`<dt>${s.label}</dt><dd>${s.value}</dd>`)}
|
|
2461
2370
|
</dl>
|
|
2462
2371
|
<p class="facts-note">
|
|
2463
|
-
${
|
|
2372
|
+
${lt()}
|
|
2464
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>
|
|
2465
2374
|
</p>
|
|
2466
2375
|
${e.stage === "error" ? c`
|
|
2467
2376
|
<div class="err" role="alert">We couldn't save these. Please try again.</div>
|
|
2468
|
-
` :
|
|
2377
|
+
` : f}
|
|
2469
2378
|
<div class="actions">
|
|
2470
2379
|
<button type="button" class="btn-primary" ?disabled=${t}
|
|
2471
|
-
@click=${() => this.#
|
|
2380
|
+
@click=${() => this.#ne()}>
|
|
2472
2381
|
${t ? "Saving…" : e.stage === "error" ? "Try again" : "Save to my account"}
|
|
2473
2382
|
</button>
|
|
2474
2383
|
<button type="button" class="btn-ghost" ?disabled=${t}
|
|
@@ -2487,7 +2396,7 @@ ${this.factsApi || ""}`;
|
|
|
2487
2396
|
<div class="bottom-bar">
|
|
2488
2397
|
<div class="inner">
|
|
2489
2398
|
<button type="button" class="btn-ghost" ?disabled=${e || this._phase === "pick"}
|
|
2490
|
-
@click=${() => this.#
|
|
2399
|
+
@click=${() => this.#V()}>← Back</button>
|
|
2491
2400
|
<button type="button" class="btn-ghost" ?disabled=${this._phase === "submitting"}
|
|
2492
2401
|
@click=${() => this.#$()}>Start over</button>
|
|
2493
2402
|
<span class="note">Your report goes to a person on the right desk.</span>
|
|
@@ -2499,7 +2408,7 @@ ${this.factsApi || ""}`;
|
|
|
2499
2408
|
this.renderRoot?.querySelector(".chat")?.lastElementChild?.scrollIntoView?.({ block: "nearest" });
|
|
2500
2409
|
}
|
|
2501
2410
|
}
|
|
2502
|
-
class
|
|
2411
|
+
class gs extends G {
|
|
2503
2412
|
static properties = {
|
|
2504
2413
|
files: { attribute: !1 },
|
|
2505
2414
|
lostMeta: { attribute: !1 },
|
|
@@ -2539,7 +2448,7 @@ class bs extends G {
|
|
|
2539
2448
|
composed: !0
|
|
2540
2449
|
}));
|
|
2541
2450
|
}
|
|
2542
|
-
#
|
|
2451
|
+
#u(e) {
|
|
2543
2452
|
const t = [...e.target.files || []];
|
|
2544
2453
|
this.#l([...this.files || [], ...t]), e.target.value = "";
|
|
2545
2454
|
}
|
|
@@ -2551,60 +2460,60 @@ class bs extends G {
|
|
|
2551
2460
|
const e = this.files || [], { errors: t } = Y(e, this.budget, { required: !1 });
|
|
2552
2461
|
return c`
|
|
2553
2462
|
<input type="file" multiple
|
|
2554
|
-
accept=${this.#c ||
|
|
2463
|
+
accept=${this.#c || f}
|
|
2555
2464
|
aria-label=${this.label}
|
|
2556
|
-
@change=${this.#
|
|
2465
|
+
@change=${this.#u}>
|
|
2557
2466
|
${e.length ? c`
|
|
2558
2467
|
<ul class="file-list">
|
|
2559
|
-
${e.map((s,
|
|
2468
|
+
${e.map((s, n) => c`
|
|
2560
2469
|
<li>
|
|
2561
2470
|
<span>${s.name}</span>
|
|
2562
|
-
<span class="size">${
|
|
2471
|
+
<span class="size">${ls(s.size)}</span>
|
|
2563
2472
|
<button type="button" class="remove"
|
|
2564
2473
|
aria-label="Remove ${s.name}"
|
|
2565
|
-
@click=${() => this.#t(
|
|
2474
|
+
@click=${() => this.#t(n)}>✕</button>
|
|
2566
2475
|
</li>
|
|
2567
2476
|
`)}
|
|
2568
2477
|
</ul>
|
|
2569
|
-
` :
|
|
2478
|
+
` : f}
|
|
2570
2479
|
${(this.lostMeta || []).length ? c`
|
|
2571
2480
|
<div class="lost">
|
|
2572
2481
|
Please re-attach your ${this.lostMeta.length === 1 ? "file" : "files"}
|
|
2573
2482
|
(${this.lostMeta.map((s) => s.name).join(", ")}) —
|
|
2574
2483
|
attachments can't be saved between visits.
|
|
2575
2484
|
</div>
|
|
2576
|
-
` :
|
|
2485
|
+
` : f}
|
|
2577
2486
|
${t.map((s) => c`<div class="err">${s.message}</div>`)}
|
|
2578
2487
|
`;
|
|
2579
2488
|
}
|
|
2580
2489
|
}
|
|
2581
|
-
function
|
|
2490
|
+
function ls(r) {
|
|
2582
2491
|
return Number.isFinite(r) ? r >= 1024 * 1024 ? `${(r / (1024 * 1024)).toFixed(1)} MB` : r >= 1024 ? `${Math.round(r / 1024)} KB` : `${r} B` : "";
|
|
2583
2492
|
}
|
|
2584
|
-
const
|
|
2585
|
-
const
|
|
2586
|
-
|
|
2587
|
-
const o =
|
|
2588
|
-
return s("code-change", { value: o, complete: a }),
|
|
2589
|
-
},
|
|
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) => {
|
|
2590
2499
|
if (e.key === "Backspace") {
|
|
2591
|
-
const
|
|
2592
|
-
!
|
|
2593
|
-
const
|
|
2594
|
-
return s("code-change", { value:
|
|
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;
|
|
2595
2504
|
}
|
|
2596
2505
|
return t;
|
|
2597
|
-
},
|
|
2506
|
+
}, us = (r, e, t) => {
|
|
2598
2507
|
r.preventDefault();
|
|
2599
2508
|
const s = r.clipboardData.getData("text").replace(/\D/g, "").slice(0, 6);
|
|
2600
2509
|
if (s.length === 0) return e;
|
|
2601
|
-
const
|
|
2510
|
+
const n = [...e];
|
|
2602
2511
|
for (let a = 0; a < s.length && a < 6; a++)
|
|
2603
|
-
|
|
2604
|
-
const
|
|
2605
|
-
return t("code-change", { value:
|
|
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;
|
|
2606
2515
|
};
|
|
2607
|
-
class
|
|
2516
|
+
class ms extends G {
|
|
2608
2517
|
static formAssociated = !0;
|
|
2609
2518
|
static properties = {
|
|
2610
2519
|
_values: { type: Array, state: !0 },
|
|
@@ -2709,7 +2618,7 @@ class ws extends G {
|
|
|
2709
2618
|
this.getInputs()[e]?.focus();
|
|
2710
2619
|
}
|
|
2711
2620
|
inputHandler(e, t) {
|
|
2712
|
-
this._values =
|
|
2621
|
+
this._values = cs(
|
|
2713
2622
|
e,
|
|
2714
2623
|
t,
|
|
2715
2624
|
this._values,
|
|
@@ -2719,7 +2628,7 @@ class ws extends G {
|
|
|
2719
2628
|
keydownHandler(e, t) {
|
|
2720
2629
|
if (t.key === "Backspace") {
|
|
2721
2630
|
const s = !this._values[e];
|
|
2722
|
-
this._values =
|
|
2631
|
+
this._values = ds(
|
|
2723
2632
|
e,
|
|
2724
2633
|
t,
|
|
2725
2634
|
this._values,
|
|
@@ -2728,7 +2637,7 @@ class ws extends G {
|
|
|
2728
2637
|
}
|
|
2729
2638
|
}
|
|
2730
2639
|
pasteHandler(e) {
|
|
2731
|
-
this._values =
|
|
2640
|
+
this._values = us(e, this._values, this.dispatchCustomEvent.bind(this));
|
|
2732
2641
|
}
|
|
2733
2642
|
render() {
|
|
2734
2643
|
return c`
|
|
@@ -2753,10 +2662,10 @@ class ws extends G {
|
|
|
2753
2662
|
}
|
|
2754
2663
|
}
|
|
2755
2664
|
export {
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2665
|
+
ms as W,
|
|
2666
|
+
gs as a,
|
|
2667
|
+
fs as b,
|
|
2668
|
+
xt as c,
|
|
2669
|
+
dt as d,
|
|
2670
|
+
vt as e
|
|
2762
2671
|
};
|