@graffiticode/l0000-view 0.1.4 → 0.2.0
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/dist/index.d.ts +24 -1
- package/dist/index.js +275 -810
- package/dist/index.js.map +1 -1
- package/dist/style.css +2 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,817 +1,282 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
|
-
var ze;
|
|
14
|
-
function Dt() {
|
|
15
|
-
if (ze) return ve;
|
|
16
|
-
ze = 1;
|
|
17
|
-
var e = ce;
|
|
18
|
-
function t(u, l) {
|
|
19
|
-
return u === l && (u !== 0 || 1 / u === 1 / l) || u !== u && l !== l;
|
|
20
|
-
}
|
|
21
|
-
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, s = e.useEffect, a = e.useLayoutEffect, o = e.useDebugValue;
|
|
22
|
-
function f(u, l) {
|
|
23
|
-
var c = l(), p = r({ inst: { value: c, getSnapshot: l } }), m = p[0].inst, g = p[1];
|
|
24
|
-
return a(
|
|
25
|
-
function() {
|
|
26
|
-
m.value = c, m.getSnapshot = l, h(m) && g({ inst: m });
|
|
27
|
-
},
|
|
28
|
-
[u, c, l]
|
|
29
|
-
), s(
|
|
30
|
-
function() {
|
|
31
|
-
return h(m) && g({ inst: m }), u(function() {
|
|
32
|
-
h(m) && g({ inst: m });
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
[u]
|
|
36
|
-
), o(c), c;
|
|
37
|
-
}
|
|
38
|
-
function h(u) {
|
|
39
|
-
var l = u.getSnapshot;
|
|
40
|
-
u = u.value;
|
|
41
|
-
try {
|
|
42
|
-
var c = l();
|
|
43
|
-
return !n(u, c);
|
|
44
|
-
} catch {
|
|
45
|
-
return !0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function A(u, l) {
|
|
49
|
-
return l();
|
|
50
|
-
}
|
|
51
|
-
var y = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? A : f;
|
|
52
|
-
return ve.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : y, ve;
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useReducer as r, useRef as i, useState as a } from "react";
|
|
2
|
+
import o from "swr";
|
|
3
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
|
+
//#region src/lib/api.ts
|
|
5
|
+
function u() {
|
|
6
|
+
return window.document.location.host.indexOf("localhost") === 0 ? "http://localhost:3100" : "https://api.graffiticode.org";
|
|
53
7
|
}
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return n(T) && i({ inst: T }), c(function() {
|
|
93
|
-
n(T) && i({ inst: T });
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
[c]
|
|
97
|
-
), A(m), m;
|
|
98
|
-
}
|
|
99
|
-
function n(c) {
|
|
100
|
-
var p = c.getSnapshot;
|
|
101
|
-
c = c.value;
|
|
102
|
-
try {
|
|
103
|
-
var m = p();
|
|
104
|
-
return !a(c, m);
|
|
105
|
-
} catch {
|
|
106
|
-
return !0;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function r(c, p) {
|
|
110
|
-
return p();
|
|
111
|
-
}
|
|
112
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
113
|
-
var s = ce, a = typeof Object.is == "function" ? Object.is : e, o = s.useState, f = s.useEffect, h = s.useLayoutEffect, A = s.useDebugValue, y = !1, u = !1, l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : t;
|
|
114
|
-
Oe.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : l, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
115
|
-
}()), Oe;
|
|
8
|
+
var d = async ({ accessToken: e, id: t }) => {
|
|
9
|
+
let { status: n, error: r, data: i } = await (await fetch(`${u()}/data?id=${t}`, { headers: { Authorization: e || "" } })).json();
|
|
10
|
+
if (n !== "success") throw Error(`failed to get data ${t}: ${r?.message}`);
|
|
11
|
+
return i;
|
|
12
|
+
}, f = async ({ accessToken: e, id: t, data: n }) => {
|
|
13
|
+
let r = await (await fetch(`${u()}/compile`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
authorization: e || "",
|
|
18
|
+
"x-graffiticode-storage-type": "persistent"
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
id: t,
|
|
22
|
+
data: n
|
|
23
|
+
})
|
|
24
|
+
})).json();
|
|
25
|
+
if (r.status !== "success") throw Error(`failed to post compile ${t}: ${r.error?.message}`);
|
|
26
|
+
return r.data;
|
|
27
|
+
}, p = async ({ accessToken: e, id: t, data: n }) => {
|
|
28
|
+
let r = Object.keys(n).length > 0 ? 1 : 2;
|
|
29
|
+
return t = t.split("+").slice(0, r).join("+"), await f({
|
|
30
|
+
accessToken: e,
|
|
31
|
+
id: t,
|
|
32
|
+
data: n
|
|
33
|
+
});
|
|
34
|
+
}, m = async ({ accessToken: e, id: t }) => await d({
|
|
35
|
+
accessToken: e,
|
|
36
|
+
id: t
|
|
37
|
+
}), h = /* @__PURE__ */ new Set(["update", "response"]), g = /* @__PURE__ */ new Set(["init", "loaded"]);
|
|
38
|
+
function _(e) {
|
|
39
|
+
return e && typeof e == "object" && Array.isArray(e.errors) ? {
|
|
40
|
+
data: e.data ?? null,
|
|
41
|
+
errors: e.errors
|
|
42
|
+
} : {
|
|
43
|
+
data: e,
|
|
44
|
+
errors: []
|
|
45
|
+
};
|
|
116
46
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const it = 0, at = 1, ct = 2, Xe = 3;
|
|
120
|
-
var Qe = Object.prototype.hasOwnProperty;
|
|
121
|
-
function be(e, t) {
|
|
122
|
-
var n, r;
|
|
123
|
-
if (e === t) return !0;
|
|
124
|
-
if (e && t && (n = e.constructor) === t.constructor) {
|
|
125
|
-
if (n === Date) return e.getTime() === t.getTime();
|
|
126
|
-
if (n === RegExp) return e.toString() === t.toString();
|
|
127
|
-
if (n === Array) {
|
|
128
|
-
if ((r = e.length) === t.length)
|
|
129
|
-
for (; r-- && be(e[r], t[r]); ) ;
|
|
130
|
-
return r === -1;
|
|
131
|
-
}
|
|
132
|
-
if (!n || typeof e == "object") {
|
|
133
|
-
r = 0;
|
|
134
|
-
for (n in e)
|
|
135
|
-
if (Qe.call(e, n) && ++r && !Qe.call(t, n) || !(n in t) || !be(e[n], t[n])) return !1;
|
|
136
|
-
return Object.keys(t).length === r;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return e !== e && t !== t;
|
|
47
|
+
function v(e, t) {
|
|
48
|
+
return t.length > 0 || !(e == null || typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0);
|
|
140
49
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
// Subscriber
|
|
161
|
-
n[6],
|
|
162
|
-
// Get server cache snapshot
|
|
163
|
-
() => !d(t) && t in de ? de[t] : !d(t) && e.get(t) || we
|
|
164
|
-
];
|
|
165
|
-
};
|
|
166
|
-
let Ne = !0;
|
|
167
|
-
const Ct = () => Ne, [Ve, je] = ue && window.addEventListener ? [
|
|
168
|
-
window.addEventListener.bind(window),
|
|
169
|
-
window.removeEventListener.bind(window)
|
|
170
|
-
] : [
|
|
171
|
-
$,
|
|
172
|
-
$
|
|
173
|
-
], bt = () => {
|
|
174
|
-
const e = Ie && document.visibilityState;
|
|
175
|
-
return d(e) || e !== "hidden";
|
|
176
|
-
}, xt = (e) => (Ie && document.addEventListener("visibilitychange", e), Ve("focus", e), () => {
|
|
177
|
-
Ie && document.removeEventListener("visibilitychange", e), je("focus", e);
|
|
178
|
-
}), It = (e) => {
|
|
179
|
-
const t = () => {
|
|
180
|
-
Ne = !0, e();
|
|
181
|
-
}, n = () => {
|
|
182
|
-
Ne = !1;
|
|
183
|
-
};
|
|
184
|
-
return Ve("online", t), Ve("offline", n), () => {
|
|
185
|
-
je("online", t), je("offline", n);
|
|
186
|
-
};
|
|
187
|
-
}, Nt = {
|
|
188
|
-
isOnline: Ct,
|
|
189
|
-
isVisible: bt
|
|
190
|
-
}, Vt = {
|
|
191
|
-
initFocus: xt,
|
|
192
|
-
initReconnect: It
|
|
193
|
-
}, Ze = !ce.useId, ne = !ue || At, jt = (e) => Lt() ? window.requestAnimationFrame(e) : setTimeout(e, 1), _e = ne ? te : Ot, Re = typeof navigator < "u" && navigator.connection, et = !ne && Re && ([
|
|
194
|
-
"slow-2g",
|
|
195
|
-
"2g"
|
|
196
|
-
].includes(Re.effectiveType) || Re.saveData), pe = /* @__PURE__ */ new WeakMap(), Ft = (e) => xe.prototype.toString.call(e), De = (e, t) => e === `[object ${t}]`;
|
|
197
|
-
let Mt = 0;
|
|
198
|
-
const Fe = (e) => {
|
|
199
|
-
const t = typeof e, n = Ft(e), r = De(n, "Date"), s = De(n, "RegExp"), a = De(n, "Object");
|
|
200
|
-
let o, f;
|
|
201
|
-
if (xe(e) === e && !r && !s) {
|
|
202
|
-
if (o = pe.get(e), o) return o;
|
|
203
|
-
if (o = ++Mt + "~", pe.set(e, o), Array.isArray(e)) {
|
|
204
|
-
for (o = "@", f = 0; f < e.length; f++)
|
|
205
|
-
o += Fe(e[f]) + ",";
|
|
206
|
-
pe.set(e, o);
|
|
207
|
-
}
|
|
208
|
-
if (a) {
|
|
209
|
-
o = "#";
|
|
210
|
-
const h = xe.keys(e).sort();
|
|
211
|
-
for (; !d(f = h.pop()); )
|
|
212
|
-
d(e[f]) || (o += f + ":" + Fe(e[f]) + ",");
|
|
213
|
-
pe.set(e, o);
|
|
214
|
-
}
|
|
215
|
-
} else
|
|
216
|
-
o = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
|
|
217
|
-
return o;
|
|
218
|
-
}, qe = (e) => {
|
|
219
|
-
if (M(e))
|
|
220
|
-
try {
|
|
221
|
-
e = e();
|
|
222
|
-
} catch {
|
|
223
|
-
e = "";
|
|
224
|
-
}
|
|
225
|
-
const t = e;
|
|
226
|
-
return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Fe(e) : "", [
|
|
227
|
-
e,
|
|
228
|
-
t
|
|
229
|
-
];
|
|
230
|
-
};
|
|
231
|
-
let Pt = 0;
|
|
232
|
-
const Me = () => ++Pt;
|
|
233
|
-
async function ft(...e) {
|
|
234
|
-
const [t, n, r, s] = e, a = k({
|
|
235
|
-
populateCache: !0,
|
|
236
|
-
throwOnError: !0
|
|
237
|
-
}, typeof s == "boolean" ? {
|
|
238
|
-
revalidate: s
|
|
239
|
-
} : s || {});
|
|
240
|
-
let o = a.populateCache;
|
|
241
|
-
const f = a.rollbackOnError;
|
|
242
|
-
let h = a.optimisticData;
|
|
243
|
-
const A = (l) => typeof f == "function" ? f(l) : f !== !1, y = a.throwOnError;
|
|
244
|
-
if (M(n)) {
|
|
245
|
-
const l = n, c = [], p = t.keys();
|
|
246
|
-
for (const m of p)
|
|
247
|
-
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
248
|
-
!/^\$(inf|sub)\$/.test(m) && l(t.get(m)._k) && c.push(m);
|
|
249
|
-
return Promise.all(c.map(u));
|
|
250
|
-
}
|
|
251
|
-
return u(n);
|
|
252
|
-
async function u(l) {
|
|
253
|
-
const [c] = qe(l);
|
|
254
|
-
if (!c) return;
|
|
255
|
-
const [p, m] = lt(t, c), [g, T, i, z] = U.get(t), H = () => {
|
|
256
|
-
const N = g[c];
|
|
257
|
-
return (M(a.revalidate) ? a.revalidate(p().data, l) : a.revalidate !== !1) && (delete i[c], delete z[c], N && N[0]) ? N[0](ct).then(() => p().data) : p().data;
|
|
258
|
-
};
|
|
259
|
-
if (e.length < 3)
|
|
260
|
-
return H();
|
|
261
|
-
let _ = r, R, C = !1;
|
|
262
|
-
const b = Me();
|
|
263
|
-
T[c] = [
|
|
264
|
-
b,
|
|
265
|
-
0
|
|
266
|
-
];
|
|
267
|
-
const S = !d(h), Y = p(), j = Y.data, J = Y._c, G = d(J) ? j : J;
|
|
268
|
-
if (S && (h = M(h) ? h(G, j) : h, m({
|
|
269
|
-
data: h,
|
|
270
|
-
_c: G
|
|
271
|
-
})), M(_))
|
|
272
|
-
try {
|
|
273
|
-
_ = _(G);
|
|
274
|
-
} catch (N) {
|
|
275
|
-
R = N, C = !0;
|
|
276
|
-
}
|
|
277
|
-
if (_ && ut(_))
|
|
278
|
-
if (_ = await _.catch((N) => {
|
|
279
|
-
R = N, C = !0;
|
|
280
|
-
}), b !== T[c][0]) {
|
|
281
|
-
if (C) throw R;
|
|
282
|
-
return _;
|
|
283
|
-
} else C && S && A(R) && (o = !0, m({
|
|
284
|
-
data: G,
|
|
285
|
-
_c: L
|
|
286
|
-
}));
|
|
287
|
-
if (o && !C)
|
|
288
|
-
if (M(o)) {
|
|
289
|
-
const N = o(_, G);
|
|
290
|
-
m({
|
|
291
|
-
data: N,
|
|
292
|
-
error: L,
|
|
293
|
-
_c: L
|
|
294
|
-
});
|
|
295
|
-
} else
|
|
296
|
-
m({
|
|
297
|
-
data: _,
|
|
298
|
-
error: L,
|
|
299
|
-
_c: L
|
|
300
|
-
});
|
|
301
|
-
if (T[c][1] = Me(), Promise.resolve(H()).then(() => {
|
|
302
|
-
m({
|
|
303
|
-
_c: L
|
|
304
|
-
});
|
|
305
|
-
}), C) {
|
|
306
|
-
if (y) throw R;
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
return _;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const tt = (e, t) => {
|
|
313
|
-
for (const n in e)
|
|
314
|
-
e[n][0] && e[n][0](t);
|
|
315
|
-
}, Wt = (e, t) => {
|
|
316
|
-
if (!U.has(e)) {
|
|
317
|
-
const n = k(Vt, t), r = /* @__PURE__ */ Object.create(null), s = ft.bind(L, e);
|
|
318
|
-
let a = $;
|
|
319
|
-
const o = /* @__PURE__ */ Object.create(null), f = (y, u) => {
|
|
320
|
-
const l = o[y] || [];
|
|
321
|
-
return o[y] = l, l.push(u), () => l.splice(l.indexOf(u), 1);
|
|
322
|
-
}, h = (y, u, l) => {
|
|
323
|
-
e.set(y, u);
|
|
324
|
-
const c = o[y];
|
|
325
|
-
if (c)
|
|
326
|
-
for (const p of c)
|
|
327
|
-
p(u, l);
|
|
328
|
-
}, A = () => {
|
|
329
|
-
if (!U.has(e) && (U.set(e, [
|
|
330
|
-
r,
|
|
331
|
-
/* @__PURE__ */ Object.create(null),
|
|
332
|
-
/* @__PURE__ */ Object.create(null),
|
|
333
|
-
/* @__PURE__ */ Object.create(null),
|
|
334
|
-
s,
|
|
335
|
-
h,
|
|
336
|
-
f
|
|
337
|
-
]), !ne)) {
|
|
338
|
-
const y = n.initFocus(setTimeout.bind(L, tt.bind(L, r, it))), u = n.initReconnect(setTimeout.bind(L, tt.bind(L, r, at)));
|
|
339
|
-
a = () => {
|
|
340
|
-
y && y(), u && u(), U.delete(e);
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
return A(), [
|
|
345
|
-
e,
|
|
346
|
-
s,
|
|
347
|
-
A,
|
|
348
|
-
a
|
|
349
|
-
];
|
|
350
|
-
}
|
|
351
|
-
return [
|
|
352
|
-
e,
|
|
353
|
-
U.get(e)[4]
|
|
354
|
-
];
|
|
355
|
-
}, qt = (e, t, n, r, s) => {
|
|
356
|
-
const a = n.errorRetryCount, o = s.retryCount, f = ~~((Math.random() + 0.5) * (1 << (o < 8 ? o : 8))) * n.errorRetryInterval;
|
|
357
|
-
!d(a) && o > a || setTimeout(r, f, s);
|
|
358
|
-
}, Ut = be, [dt, $t] = Wt(/* @__PURE__ */ new Map()), Ht = k(
|
|
359
|
-
{
|
|
360
|
-
// events
|
|
361
|
-
onLoadingSlow: $,
|
|
362
|
-
onSuccess: $,
|
|
363
|
-
onError: $,
|
|
364
|
-
onErrorRetry: qt,
|
|
365
|
-
onDiscarded: $,
|
|
366
|
-
// switches
|
|
367
|
-
revalidateOnFocus: !0,
|
|
368
|
-
revalidateOnReconnect: !0,
|
|
369
|
-
revalidateIfStale: !0,
|
|
370
|
-
shouldRetryOnError: !0,
|
|
371
|
-
// timeouts
|
|
372
|
-
errorRetryInterval: et ? 1e4 : 5e3,
|
|
373
|
-
focusThrottleInterval: 5 * 1e3,
|
|
374
|
-
dedupingInterval: 2 * 1e3,
|
|
375
|
-
loadingTimeout: et ? 5e3 : 3e3,
|
|
376
|
-
// providers
|
|
377
|
-
compare: Ut,
|
|
378
|
-
isPaused: () => !1,
|
|
379
|
-
cache: dt,
|
|
380
|
-
mutate: $t,
|
|
381
|
-
fallback: {}
|
|
382
|
-
},
|
|
383
|
-
// use web preset by default
|
|
384
|
-
Nt
|
|
385
|
-
), kt = (e, t) => {
|
|
386
|
-
const n = k(e, t);
|
|
387
|
-
if (t) {
|
|
388
|
-
const { use: r, fallback: s } = e, { use: a, fallback: o } = t;
|
|
389
|
-
r && a && (n.use = r.concat(a)), s && o && (n.fallback = k(s, o));
|
|
390
|
-
}
|
|
391
|
-
return n;
|
|
392
|
-
}, Gt = vt({}), Kt = "$inf$", pt = ue && window.__SWR_DEVTOOLS_USE__, Bt = pt ? window.__SWR_DEVTOOLS_USE__ : [], zt = () => {
|
|
393
|
-
pt && (window.__SWR_DEVTOOLS_REACT__ = ce);
|
|
394
|
-
}, Yt = (e) => M(e[1]) ? [
|
|
395
|
-
e[0],
|
|
396
|
-
e[1],
|
|
397
|
-
e[2] || {}
|
|
398
|
-
] : [
|
|
399
|
-
e[0],
|
|
400
|
-
null,
|
|
401
|
-
(e[1] === null ? e[2] : e[1]) || {}
|
|
402
|
-
], Jt = () => {
|
|
403
|
-
const e = wt(Gt);
|
|
404
|
-
return me(() => k(Ht, e), [
|
|
405
|
-
e
|
|
406
|
-
]);
|
|
407
|
-
}, Xt = (e) => (t, n, r) => e(t, n && ((...a) => {
|
|
408
|
-
const [o] = qe(t), [, , , f] = U.get(dt);
|
|
409
|
-
if (o.startsWith(Kt))
|
|
410
|
-
return n(...a);
|
|
411
|
-
const h = f[o];
|
|
412
|
-
return d(h) ? n(...a) : (delete f[o], h);
|
|
413
|
-
}), r), Qt = Bt.concat(Xt), Zt = (e) => function(...n) {
|
|
414
|
-
const r = Jt(), [s, a, o] = Yt(n), f = kt(r, o);
|
|
415
|
-
let h = e;
|
|
416
|
-
const { use: A } = f, y = (A || []).concat(Qt);
|
|
417
|
-
for (let u = y.length; u--; )
|
|
418
|
-
h = y[u](h);
|
|
419
|
-
return h(s, a || f.fetcher || null, f);
|
|
420
|
-
}, en = (e, t, n) => {
|
|
421
|
-
const r = t[e] || (t[e] = []);
|
|
422
|
-
return r.push(n), () => {
|
|
423
|
-
const s = r.indexOf(n);
|
|
424
|
-
s >= 0 && (r[s] = r[r.length - 1], r.pop());
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
zt();
|
|
428
|
-
const Te = ce.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
429
|
-
// and emitting an error.
|
|
430
|
-
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
431
|
-
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
432
|
-
((e) => {
|
|
433
|
-
switch (e.status) {
|
|
434
|
-
case "pending":
|
|
435
|
-
throw e;
|
|
436
|
-
case "fulfilled":
|
|
437
|
-
return e.value;
|
|
438
|
-
case "rejected":
|
|
439
|
-
throw e.reason;
|
|
440
|
-
default:
|
|
441
|
-
throw e.status = "pending", e.then((t) => {
|
|
442
|
-
e.status = "fulfilled", e.value = t;
|
|
443
|
-
}, (t) => {
|
|
444
|
-
e.status = "rejected", e.reason = t;
|
|
445
|
-
}), e;
|
|
446
|
-
}
|
|
447
|
-
}), Ae = {
|
|
448
|
-
dedupe: !0
|
|
449
|
-
}, nt = Promise.resolve(L), tn = () => $, nn = (e, t, n) => {
|
|
450
|
-
const { cache: r, compare: s, suspense: a, fallbackData: o, revalidateOnMount: f, revalidateIfStale: h, refreshInterval: A, refreshWhenHidden: y, refreshWhenOffline: u, keepPreviousData: l, strictServerPrefetchWarning: c } = n, [p, m, g, T] = U.get(r), [i, z] = qe(e), H = W(!1), _ = W(!1), R = W(i), C = W(t), b = W(n), S = () => b.current, Y = () => S().isVisible() && S().isOnline(), [j, J, G, N] = lt(r, i), X = W({}).current, Q = d(o) ? d(n.fallback) ? L : n.fallback[i] : o, Ue = (E, v) => {
|
|
451
|
-
for (const O in X) {
|
|
452
|
-
const w = O;
|
|
453
|
-
if (w === "data") {
|
|
454
|
-
if (!s(E[w], v[w]) && (!d(E[w]) || !s(fe, v[w])))
|
|
455
|
-
return !1;
|
|
456
|
-
} else if (v[w] !== E[w])
|
|
457
|
-
return !1;
|
|
458
|
-
}
|
|
459
|
-
return !0;
|
|
460
|
-
}, ge = !H.current, $e = me(() => {
|
|
461
|
-
const E = j(), v = N(), O = (D) => {
|
|
462
|
-
const V = k(D);
|
|
463
|
-
return delete V._k, (() => {
|
|
464
|
-
if (!i || !t || S().isPaused()) return !1;
|
|
465
|
-
if (ge && !d(f)) return f;
|
|
466
|
-
const ie = d(Q) ? V.data : Q;
|
|
467
|
-
return d(ie) || h;
|
|
468
|
-
})() ? {
|
|
469
|
-
isValidating: !0,
|
|
470
|
-
isLoading: !0,
|
|
471
|
-
...V
|
|
472
|
-
} : V;
|
|
473
|
-
}, w = O(E), F = E === v ? w : O(v);
|
|
474
|
-
let x = w;
|
|
475
|
-
return [
|
|
476
|
-
() => {
|
|
477
|
-
const D = O(j());
|
|
478
|
-
return Ue(D, x) ? (x.data = D.data, x.isLoading = D.isLoading, x.isValidating = D.isValidating, x.error = D.error, x) : (x = D, D);
|
|
479
|
-
},
|
|
480
|
-
() => F
|
|
481
|
-
];
|
|
482
|
-
}, [
|
|
483
|
-
r,
|
|
484
|
-
i
|
|
485
|
-
]), Z = Je.useSyncExternalStore(he(
|
|
486
|
-
(E) => G(i, (v, O) => {
|
|
487
|
-
Ue(O, v) || E();
|
|
488
|
-
}),
|
|
489
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
490
|
-
[
|
|
491
|
-
r,
|
|
492
|
-
i
|
|
493
|
-
]
|
|
494
|
-
), $e[0], $e[1]), mt = p[i] && p[i].length > 0, ee = Z.data, K = d(ee) ? Q && ut(Q) ? Te(Q) : Q : ee, le = Z.error, Ee = W(K), fe = l ? d(ee) ? d(Ee.current) ? K : Ee.current : ee : K, B = i && d(K), re = W(null);
|
|
495
|
-
!ne && // getServerSnapshot is only called during hydration
|
|
496
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
497
|
-
Je.useSyncExternalStore(tn, () => (re.current = !1, re), () => (re.current = !0, re));
|
|
498
|
-
const gt = re.current;
|
|
499
|
-
c && gt && !a && B && console.warn(`Missing pre-initiated data for serialized key "${i}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);
|
|
500
|
-
const He = !i || !t || S().isPaused() || mt && !d(le) ? !1 : ge && !d(f) ? f : a ? d(K) ? !1 : h : d(K) || h, ke = ge && He, Et = d(Z.isValidating) ? ke : Z.isValidating, St = d(Z.isLoading) ? ke : Z.isLoading, se = he(
|
|
501
|
-
async (E) => {
|
|
502
|
-
const v = C.current;
|
|
503
|
-
if (!i || !v || _.current || S().isPaused())
|
|
504
|
-
return !1;
|
|
505
|
-
let O, w, F = !0;
|
|
506
|
-
const x = E || {}, D = !g[i] || !x.dedupe, V = () => Ze ? !_.current && i === R.current && H.current : i === R.current, oe = {
|
|
507
|
-
isValidating: !1,
|
|
508
|
-
isLoading: !1
|
|
509
|
-
}, ie = () => {
|
|
510
|
-
J(oe);
|
|
511
|
-
}, Ke = () => {
|
|
512
|
-
const I = g[i];
|
|
513
|
-
I && I[1] === w && delete g[i];
|
|
514
|
-
}, Be = {
|
|
515
|
-
isValidating: !0
|
|
516
|
-
};
|
|
517
|
-
d(j().data) && (Be.isLoading = !0);
|
|
518
|
-
try {
|
|
519
|
-
if (D && (J(Be), n.loadingTimeout && d(j().data) && setTimeout(() => {
|
|
520
|
-
F && V() && S().onLoadingSlow(i, n);
|
|
521
|
-
}, n.loadingTimeout), g[i] = [
|
|
522
|
-
v(z),
|
|
523
|
-
Me()
|
|
524
|
-
]), [O, w] = g[i], O = await O, D && setTimeout(Ke, n.dedupingInterval), !g[i] || g[i][1] !== w)
|
|
525
|
-
return D && V() && S().onDiscarded(i), !1;
|
|
526
|
-
oe.error = L;
|
|
527
|
-
const I = m[i];
|
|
528
|
-
if (!d(I) && // case 1
|
|
529
|
-
(w <= I[0] || // case 2
|
|
530
|
-
w <= I[1] || // case 3
|
|
531
|
-
I[1] === 0))
|
|
532
|
-
return ie(), D && V() && S().onDiscarded(i), !1;
|
|
533
|
-
const P = j().data;
|
|
534
|
-
oe.data = s(P, O) ? P : O, D && V() && S().onSuccess(O, i, n);
|
|
535
|
-
} catch (I) {
|
|
536
|
-
Ke();
|
|
537
|
-
const P = S(), { shouldRetryOnError: Se } = P;
|
|
538
|
-
P.isPaused() || (oe.error = I, D && V() && (P.onError(I, i, P), (Se === !0 || M(Se) && Se(I)) && (!S().revalidateOnFocus || !S().revalidateOnReconnect || Y()) && P.onErrorRetry(I, i, P, (yt) => {
|
|
539
|
-
const ye = p[i];
|
|
540
|
-
ye && ye[0] && ye[0](Xe, yt);
|
|
541
|
-
}, {
|
|
542
|
-
retryCount: (x.retryCount || 0) + 1,
|
|
543
|
-
dedupe: !0
|
|
544
|
-
})));
|
|
545
|
-
}
|
|
546
|
-
return F = !1, ie(), !0;
|
|
547
|
-
},
|
|
548
|
-
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
549
|
-
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
550
|
-
// the deps array.
|
|
551
|
-
//
|
|
552
|
-
// FIXME:
|
|
553
|
-
// `fn` and `config` might be changed during the lifecycle,
|
|
554
|
-
// but they might be changed every render like this.
|
|
555
|
-
// `useSWR('key', () => fetch('/api/'), { suspense: true })`
|
|
556
|
-
// So we omit the values from the deps array
|
|
557
|
-
// even though it might cause unexpected behaviors.
|
|
558
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
559
|
-
[
|
|
560
|
-
i,
|
|
561
|
-
r
|
|
562
|
-
]
|
|
563
|
-
), Ge = he(
|
|
564
|
-
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
565
|
-
(...E) => ft(r, R.current, ...E),
|
|
566
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
567
|
-
[]
|
|
568
|
-
);
|
|
569
|
-
if (_e(() => {
|
|
570
|
-
C.current = t, b.current = n, d(ee) || (Ee.current = ee);
|
|
571
|
-
}), _e(() => {
|
|
572
|
-
if (!i) return;
|
|
573
|
-
const E = se.bind(L, Ae);
|
|
574
|
-
let v = 0;
|
|
575
|
-
S().revalidateOnFocus && (v = Date.now() + S().focusThrottleInterval);
|
|
576
|
-
const w = en(i, p, (F, x = {}) => {
|
|
577
|
-
if (F == it) {
|
|
578
|
-
const D = Date.now();
|
|
579
|
-
S().revalidateOnFocus && D > v && Y() && (v = D + S().focusThrottleInterval, E());
|
|
580
|
-
} else if (F == at)
|
|
581
|
-
S().revalidateOnReconnect && Y() && E();
|
|
582
|
-
else {
|
|
583
|
-
if (F == ct)
|
|
584
|
-
return se();
|
|
585
|
-
if (F == Xe)
|
|
586
|
-
return se(x);
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
return _.current = !1, R.current = i, H.current = !0, J({
|
|
590
|
-
_k: z
|
|
591
|
-
}), He && (g[i] || (d(K) || ne ? E() : jt(E))), () => {
|
|
592
|
-
_.current = !0, w();
|
|
593
|
-
};
|
|
594
|
-
}, [
|
|
595
|
-
i
|
|
596
|
-
]), _e(() => {
|
|
597
|
-
let E;
|
|
598
|
-
function v() {
|
|
599
|
-
const w = M(A) ? A(j().data) : A;
|
|
600
|
-
w && E !== -1 && (E = setTimeout(O, w));
|
|
601
|
-
}
|
|
602
|
-
function O() {
|
|
603
|
-
!j().error && (y || S().isVisible()) && (u || S().isOnline()) ? se(Ae).then(v) : v();
|
|
604
|
-
}
|
|
605
|
-
return v(), () => {
|
|
606
|
-
E && (clearTimeout(E), E = -1);
|
|
607
|
-
};
|
|
608
|
-
}, [
|
|
609
|
-
A,
|
|
610
|
-
y,
|
|
611
|
-
u,
|
|
612
|
-
i
|
|
613
|
-
]), _t(fe), a) {
|
|
614
|
-
if (!Ze && ne && B)
|
|
615
|
-
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
616
|
-
B && (C.current = t, b.current = n, _.current = !1);
|
|
617
|
-
const E = T[i], v = !d(E) && B ? Ge(E) : nt;
|
|
618
|
-
if (Te(v), !d(le) && B)
|
|
619
|
-
throw le;
|
|
620
|
-
const O = B ? se(Ae) : nt;
|
|
621
|
-
!d(fe) && B && (O.status = "fulfilled", O.value = !0), Te(O);
|
|
622
|
-
}
|
|
623
|
-
return {
|
|
624
|
-
mutate: Ge,
|
|
625
|
-
get data() {
|
|
626
|
-
return X.data = !0, fe;
|
|
627
|
-
},
|
|
628
|
-
get error() {
|
|
629
|
-
return X.error = !0, le;
|
|
630
|
-
},
|
|
631
|
-
get isValidating() {
|
|
632
|
-
return X.isValidating = !0, Et;
|
|
633
|
-
},
|
|
634
|
-
get isLoading() {
|
|
635
|
-
return X.isLoading = !0, St;
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
}, rn = Zt(nn);
|
|
639
|
-
function ht() {
|
|
640
|
-
return window.document.location.host.indexOf("localhost") === 0 ? "http://localhost:3100" : "https://api.graffiticode.org";
|
|
50
|
+
var y = (e) => typeof e == "object" && !!e && !Array.isArray(e), b = (e, t) => t == null ? e : y(e) && y(t) ? {
|
|
51
|
+
...e,
|
|
52
|
+
...t
|
|
53
|
+
} : t;
|
|
54
|
+
function x(e, { type: t, args: n }) {
|
|
55
|
+
switch (t) {
|
|
56
|
+
case "init": return y(n) ? { ...n } : n;
|
|
57
|
+
case "compiled":
|
|
58
|
+
case "loaded":
|
|
59
|
+
case "update":
|
|
60
|
+
case "response": return b(e, n);
|
|
61
|
+
case "focus": return {
|
|
62
|
+
...e,
|
|
63
|
+
focus: n
|
|
64
|
+
};
|
|
65
|
+
default: return console.error(`Unimplemented action type: ${t}`), e;
|
|
66
|
+
}
|
|
641
67
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}) => {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}) => {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}) => {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
68
|
+
var S = (e, t) => {
|
|
69
|
+
if (e === t) return !0;
|
|
70
|
+
if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
71
|
+
if (Array.isArray(e)) return e.length === t.length && e.every((e, n) => S(e, t[n]));
|
|
72
|
+
let n = Object.keys(e);
|
|
73
|
+
return n.length === Object.keys(t).length && n.every((n) => Object.prototype.hasOwnProperty.call(t, n) && S(e[n], t[n]));
|
|
74
|
+
}, C = (e, t) => (n, r) => {
|
|
75
|
+
let i = e ? e(n.data, r) : void 0, a = i === void 0 ? x(n.data, r) : i;
|
|
76
|
+
return a === n.data || S(a, n.data) ? n : {
|
|
77
|
+
data: a,
|
|
78
|
+
renderData: t === "live" || g.has(r.type) ? a : n.renderData,
|
|
79
|
+
compileSeq: n.compileSeq + +!!h.has(r.type),
|
|
80
|
+
version: n.version + 1
|
|
81
|
+
};
|
|
82
|
+
}, w = ({ Form: u, reduce: d, formModel: f = "live", score: g }) => {
|
|
83
|
+
let [b] = a(() => new URLSearchParams(window.location.search)), [x] = a(b.get("id") ?? void 0), [S] = a(b.get("access_token") ?? void 0), [w] = a(b.get("origin") ?? void 0), [E, D] = a([]), A = n(() => C(d, f), [d, f]), [j, M] = r(A, void 0, () => ({
|
|
84
|
+
data: {},
|
|
85
|
+
renderData: {},
|
|
86
|
+
compileSeq: 0,
|
|
87
|
+
version: 0
|
|
88
|
+
})), { data: N, renderData: P, compileSeq: F, version: I } = j;
|
|
89
|
+
t(() => {
|
|
90
|
+
let e = b.get("data");
|
|
91
|
+
e && M({
|
|
92
|
+
type: "init",
|
|
93
|
+
args: JSON.parse(e)
|
|
94
|
+
});
|
|
95
|
+
}, []), t(() => {
|
|
96
|
+
w && window.parent.postMessage({
|
|
97
|
+
type: "onload",
|
|
98
|
+
data: N
|
|
99
|
+
}, w);
|
|
100
|
+
}, []), t(() => {
|
|
101
|
+
w && window.parent.postMessage({
|
|
102
|
+
type: "data-updated",
|
|
103
|
+
data: N
|
|
104
|
+
}, w);
|
|
105
|
+
}, [I]);
|
|
106
|
+
let L = o(x ? {
|
|
107
|
+
accessToken: S,
|
|
108
|
+
id: x
|
|
109
|
+
} : null, m, {
|
|
110
|
+
revalidateOnFocus: !1,
|
|
111
|
+
revalidateOnReconnect: !1,
|
|
112
|
+
revalidateIfStale: !1
|
|
113
|
+
});
|
|
114
|
+
t(() => {
|
|
115
|
+
if (L.data === void 0) return;
|
|
116
|
+
let e = _(L.data);
|
|
117
|
+
M({
|
|
118
|
+
type: "loaded",
|
|
119
|
+
args: e.data
|
|
120
|
+
}), D(e.errors);
|
|
121
|
+
}, [L.data]);
|
|
122
|
+
let R = i(0);
|
|
123
|
+
t(() => {
|
|
124
|
+
if (F === 0 || !x) return;
|
|
125
|
+
let e = ++R.current;
|
|
126
|
+
w && window.parent.postMessage({ focus: {
|
|
127
|
+
type: "update",
|
|
128
|
+
value: N
|
|
129
|
+
} }, w);
|
|
130
|
+
let t = !1;
|
|
131
|
+
return (async () => {
|
|
132
|
+
try {
|
|
133
|
+
let n = await p({
|
|
134
|
+
accessToken: S,
|
|
135
|
+
id: x,
|
|
136
|
+
data: N
|
|
137
|
+
});
|
|
138
|
+
if (t || e !== R.current) return;
|
|
139
|
+
let r = _(n);
|
|
140
|
+
M({
|
|
141
|
+
type: "compiled",
|
|
142
|
+
args: r.data
|
|
143
|
+
}), D(r.errors);
|
|
144
|
+
} catch (n) {
|
|
145
|
+
!t && e === R.current && D([{ message: String(n?.message ?? n) }]);
|
|
146
|
+
}
|
|
147
|
+
})(), () => {
|
|
148
|
+
t = !0;
|
|
149
|
+
};
|
|
150
|
+
}, [F]);
|
|
151
|
+
let z = v(P, []) ? P : N, [B, V] = a(!1), H = e((e) => {
|
|
152
|
+
h.has(e.type) && V(!1), M(e);
|
|
153
|
+
}, []), U = n(() => g && E.length === 0 ? g(N) : void 0, [
|
|
154
|
+
g,
|
|
155
|
+
N,
|
|
156
|
+
E
|
|
157
|
+
]), W = B && U && y(z) ? {
|
|
158
|
+
...z,
|
|
159
|
+
showValidationUI: !0
|
|
160
|
+
} : z, G = n(() => ({
|
|
161
|
+
data: W,
|
|
162
|
+
errors: E,
|
|
163
|
+
apply: H
|
|
164
|
+
}), [
|
|
165
|
+
W,
|
|
166
|
+
E,
|
|
167
|
+
H
|
|
168
|
+
]), K = e(() => L.mutate(), [L]);
|
|
169
|
+
return v(N, E) ? U ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(u, { state: G }), /* @__PURE__ */ c(T, {
|
|
170
|
+
result: U,
|
|
171
|
+
checked: B,
|
|
172
|
+
onCheck: () => V(!0)
|
|
173
|
+
})] }) : /* @__PURE__ */ c(u, { state: G }) : L.error ? /* @__PURE__ */ l("div", {
|
|
174
|
+
role: "alert",
|
|
175
|
+
style: O,
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ c("p", {
|
|
178
|
+
style: {
|
|
179
|
+
margin: 0,
|
|
180
|
+
fontWeight: 600
|
|
181
|
+
},
|
|
182
|
+
children: "Couldn’t load this form."
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ c("p", {
|
|
185
|
+
style: {
|
|
186
|
+
margin: "4px 0 12px",
|
|
187
|
+
color: "#555"
|
|
188
|
+
},
|
|
189
|
+
children: String(L.error?.message ?? L.error)
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ c("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
style: k,
|
|
194
|
+
onClick: K,
|
|
195
|
+
children: "Retry"
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
}) : L.isLoading ? /* @__PURE__ */ c("div", {
|
|
199
|
+
role: "status",
|
|
200
|
+
"aria-live": "polite",
|
|
201
|
+
style: O,
|
|
202
|
+
children: "Loading…"
|
|
203
|
+
}) : /* @__PURE__ */ c("div", {});
|
|
204
|
+
}, T = ({ result: e, checked: t, onCheck: n }) => /* @__PURE__ */ l("div", {
|
|
205
|
+
style: E,
|
|
206
|
+
children: [/* @__PURE__ */ c("button", {
|
|
207
|
+
type: "button",
|
|
208
|
+
style: D,
|
|
209
|
+
onClick: n,
|
|
210
|
+
disabled: t,
|
|
211
|
+
children: "Check"
|
|
212
|
+
}), /* @__PURE__ */ c("span", {
|
|
213
|
+
"aria-live": "polite",
|
|
214
|
+
style: {
|
|
215
|
+
color: "#52525b",
|
|
216
|
+
minWidth: "8em"
|
|
217
|
+
},
|
|
218
|
+
children: t ? `${e.score} of ${e.max} points` : ""
|
|
219
|
+
})]
|
|
220
|
+
}), E = {
|
|
221
|
+
display: "flex",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
justifyContent: "center",
|
|
224
|
+
gap: "12px",
|
|
225
|
+
padding: "12px",
|
|
226
|
+
font: "14px/1.4 system-ui, sans-serif"
|
|
227
|
+
}, D = {
|
|
228
|
+
padding: "8px 16px",
|
|
229
|
+
border: "none",
|
|
230
|
+
borderRadius: "6px",
|
|
231
|
+
background: "#18181b",
|
|
232
|
+
color: "#fff",
|
|
233
|
+
fontWeight: 500,
|
|
234
|
+
cursor: "pointer"
|
|
235
|
+
}, O = {
|
|
236
|
+
display: "flex",
|
|
237
|
+
flexDirection: "column",
|
|
238
|
+
alignItems: "center",
|
|
239
|
+
justifyContent: "center",
|
|
240
|
+
height: "100%",
|
|
241
|
+
padding: "24px",
|
|
242
|
+
textAlign: "center",
|
|
243
|
+
font: "14px/1.4 system-ui, sans-serif"
|
|
244
|
+
}, k = {
|
|
245
|
+
padding: "6px 14px",
|
|
246
|
+
border: "1px solid #888",
|
|
247
|
+
borderRadius: "4px",
|
|
248
|
+
background: "#fff",
|
|
249
|
+
cursor: "pointer"
|
|
787
250
|
};
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/components/form/Form.tsx
|
|
253
|
+
function A({ errors: e }) {
|
|
254
|
+
return /* @__PURE__ */ c("div", {
|
|
255
|
+
className: "flex flex-col gap-2 font-mono text-xs",
|
|
256
|
+
children: e.map((e, t) => /* @__PURE__ */ l("div", {
|
|
257
|
+
className: "rounded-md border border-red-200 bg-red-50 p-3 text-red-800",
|
|
258
|
+
children: [e.message, typeof e.from == "number" && e.from >= 0 && /* @__PURE__ */ l("span", {
|
|
259
|
+
className: "ml-2 text-red-400",
|
|
260
|
+
children: [
|
|
261
|
+
"[",
|
|
262
|
+
e.from,
|
|
263
|
+
typeof e.to == "number" && e.to >= 0 ? `–${e.to}` : "",
|
|
264
|
+
"]"
|
|
265
|
+
]
|
|
266
|
+
})]
|
|
267
|
+
}, t))
|
|
268
|
+
});
|
|
805
269
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
yn as Form,
|
|
815
|
-
Sn as View
|
|
270
|
+
var j = ({ state: e }) => {
|
|
271
|
+
let t = e.errors ?? [];
|
|
272
|
+
if (t.length > 0) return /* @__PURE__ */ c(A, { errors: t });
|
|
273
|
+
let n = e.data;
|
|
274
|
+
return /* @__PURE__ */ c("pre", {
|
|
275
|
+
className: "rounded-md bg-zinc-50 text-zinc-900 text-xs font-mono p-4 overflow-auto",
|
|
276
|
+
children: JSON.stringify(n, null, 2)
|
|
277
|
+
});
|
|
816
278
|
};
|
|
817
|
-
//#
|
|
279
|
+
//#endregion
|
|
280
|
+
export { T as CheckBar, j as Form, w as View };
|
|
281
|
+
|
|
282
|
+
//# sourceMappingURL=index.js.map
|