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