@pixelmatters/markup 1.1.0 → 1.3.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/react.js DELETED
@@ -1,4792 +0,0 @@
1
- import { useEffect as e } from "react";
2
- //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/dist/preact.module.js
3
- var t, n, r, i, a, o, s, c, l, u, d, f, p, m, h = {}, g = [], _ = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, v = Array.isArray;
4
- function y(e, t) {
5
- for (var n in t) e[n] = t[n];
6
- return e;
7
- }
8
- function b(e) {
9
- e && e.parentNode && e.parentNode.removeChild(e);
10
- }
11
- function x(e, n, r) {
12
- var i, a, o, s = {};
13
- for (o in n) o == "key" ? i = n[o] : o == "ref" ? a = n[o] : s[o] = n[o];
14
- if (arguments.length > 2 && (s.children = arguments.length > 3 ? t.call(arguments, 2) : r), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
15
- return S(e, s, i, a, null);
16
- }
17
- function S(e, t, i, a, o) {
18
- var s = {
19
- type: e,
20
- props: t,
21
- key: i,
22
- ref: a,
23
- __k: null,
24
- __: null,
25
- __b: 0,
26
- __e: null,
27
- __c: null,
28
- constructor: void 0,
29
- __v: o ?? ++r,
30
- __i: -1,
31
- __u: 0
32
- };
33
- return o == null && n.vnode != null && n.vnode(s), s;
34
- }
35
- function C(e) {
36
- return e.children;
37
- }
38
- function w(e, t) {
39
- this.props = e, this.context = t;
40
- }
41
- function T(e, t) {
42
- if (t == null) return e.__ ? T(e.__, e.__i + 1) : null;
43
- for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
44
- return typeof e.type == "function" ? T(e) : null;
45
- }
46
- function E(e) {
47
- if (e.__P && e.__d) {
48
- var t = e.__v, r = t.__e, i = [], a = [], o = y({}, t);
49
- o.__v = t.__v + 1, n.vnode && n.vnode(o), re(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [r] : null, i, r ?? T(t), !!(32 & t.__u), a), o.__v = t.__v, o.__.__k[o.__i] = o, ae(i, o, a), t.__e = t.__ = null, o.__e != r && D(o);
50
- }
51
- }
52
- function D(e) {
53
- if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
54
- if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
55
- }), D(e);
56
- }
57
- function O(e) {
58
- (!e.__d && (e.__d = !0) && i.push(e) && !k.__r++ || a != n.debounceRendering) && ((a = n.debounceRendering) || o)(k);
59
- }
60
- function k() {
61
- try {
62
- for (var e, t = 1; i.length;) i.length > t && i.sort(s), e = i.shift(), t = i.length, E(e);
63
- } finally {
64
- i.length = k.__r = 0;
65
- }
66
- }
67
- function A(e, t, n, r, i, a, o, s, c, l, u) {
68
- var d, f, p, m, _, v, y, b = r && r.__k || g, x = t.length;
69
- for (c = ee(n, t, b, c, x), d = 0; d < x; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && b[p.__i] || h, p.__i = d, v = re(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && se(f.ref, null, p), u.push(p.ref, p.__c || m, p)), _ == null && m != null && (_ = m), (y = !!(4 & p.__u)) || f.__k === p.__k ? (c = j(p, c, e, y), y && f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), p.__u &= -7);
70
- return n.__e = _, c;
71
- }
72
- function ee(e, t, n, r, i) {
73
- var a, o, s, c, l, u = n.length, d = u, f = 0;
74
- for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = S(null, o, null, null, null) : v(o) ? o = e.__k[a] = S(C, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = S(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = M(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
75
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), ce(s, s));
76
- return r;
77
- }
78
- function j(e, t, n, r) {
79
- var i, a;
80
- if (typeof e.type == "function") {
81
- for (i = e.__k, a = 0; i && a < i.length; a++) i[a] && (i[a].__ = e, t = j(i[a], t, n, r));
82
- return t;
83
- }
84
- e.__e != t && (r && (t && e.type && !t.parentNode && (t = T(e)), n.insertBefore(e.__e, t || null)), t = e.__e);
85
- do
86
- t &&= t.nextSibling;
87
- while (t != null && t.nodeType == 8);
88
- return t;
89
- }
90
- function M(e, t, n, r) {
91
- var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && (2 & l.__u) == 0;
92
- if (l === null && s == null || u && s == l.key && c == l.type) return n;
93
- if (r > +!!u) {
94
- for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o;
95
- }
96
- return -1;
97
- }
98
- function te(e, t, n) {
99
- t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || _.test(t) ? n : n + "px";
100
- }
101
- function N(e, t, n, r, i) {
102
- var a, o;
103
- n: if (t == "style") if (typeof n == "string") e.style.cssText = n;
104
- else {
105
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || te(e.style, t, "");
106
- if (n) for (t in n) r && n[t] == r[t] || te(e.style, t, n[t]);
107
- }
108
- else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(d, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[u] = r[u] : (n[u] = f, e.addEventListener(t, a ? m : p, a)) : e.removeEventListener(t, a ? m : p, a);
109
- else {
110
- if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
111
- else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
112
- e[t] = n ?? "";
113
- break n;
114
- } catch {}
115
- typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
116
- }
117
- }
118
- function ne(e) {
119
- return function(t) {
120
- if (this.l) {
121
- var r = this.l[t.type + e];
122
- if (t[l] == null) t[l] = f++;
123
- else if (t[l] < r[u]) return;
124
- return r(n.event ? n.event(t) : t);
125
- }
126
- };
127
- }
128
- function re(e, t, r, i, a, o, s, c, l, u) {
129
- var d, f, p, m, h, _, x, S, T, E, D, O, k, ee, j, M = t.type;
130
- if (t.constructor !== void 0) return null;
131
- 128 & r.__u && (l = !!(32 & r.__u), o = [c = t.__e = r.__e]), (d = n.__b) && d(t);
132
- n: if (typeof M == "function") try {
133
- if (S = t.props, T = M.prototype && M.prototype.render, E = (d = M.contextType) && i[d.__c], D = d ? E ? E.props.value : d.__ : i, r.__c ? x = (f = t.__c = r.__c).__ = f.__E : (T ? t.__c = f = new M(S, D) : (t.__c = f = new w(S, D), f.constructor = M, f.render = le), E && E.sub(f), f.state ||= {}, f.__n = i, p = f.__d = !0, f.__h = [], f._sb = []), T && f.__s == null && (f.__s = f.state), T && M.getDerivedStateFromProps != null && (f.__s == f.state && (f.__s = y({}, f.__s)), y(f.__s, M.getDerivedStateFromProps(S, f.__s))), m = f.props, h = f.state, f.__v = t, p) T && M.getDerivedStateFromProps == null && f.componentWillMount != null && f.componentWillMount(), T && f.componentDidMount != null && f.__h.push(f.componentDidMount);
134
- else {
135
- if (T && M.getDerivedStateFromProps == null && S !== m && f.componentWillReceiveProps != null && f.componentWillReceiveProps(S, D), t.__v == r.__v || !f.__e && f.shouldComponentUpdate != null && !1 === f.shouldComponentUpdate(S, f.__s, D)) {
136
- t.__v != r.__v && (f.props = S, f.state = f.__s, f.__d = !1), t.__e = r.__e, t.__k = r.__k, t.__k.some(function(e) {
137
- e && (e.__ = t);
138
- }), g.push.apply(f.__h, f._sb), f._sb = [], f.__h.length && s.push(f);
139
- break n;
140
- }
141
- f.componentWillUpdate != null && f.componentWillUpdate(S, f.__s, D), T && f.componentDidUpdate != null && f.__h.push(function() {
142
- f.componentDidUpdate(m, h, _);
143
- });
144
- }
145
- if (f.context = D, f.props = S, f.__P = e, f.__e = !1, O = n.__r, k = 0, T) f.state = f.__s, f.__d = !1, O && O(t), d = f.render(f.props, f.state, f.context), g.push.apply(f.__h, f._sb), f._sb = [];
146
- else do
147
- f.__d = !1, O && O(t), d = f.render(f.props, f.state, f.context), f.state = f.__s;
148
- while (f.__d && ++k < 25);
149
- f.state = f.__s, f.getChildContext != null && (i = y(y({}, i), f.getChildContext())), T && !p && f.getSnapshotBeforeUpdate != null && (_ = f.getSnapshotBeforeUpdate(m, h)), ee = d != null && d.type === C && d.key == null ? oe(d.props.children) : d, c = A(e, v(ee) ? ee : [ee], t, r, i, a, o, s, c, l, u), f.base = t.__e, t.__u &= -161, f.__h.length && s.push(f), x && (f.__E = f.__ = null);
150
- } catch (e) {
151
- if (t.__v = null, l || o != null) if (e.then) {
152
- for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
153
- o[o.indexOf(c)] = null, t.__e = c;
154
- } else {
155
- for (j = o.length; j--;) b(o[j]);
156
- ie(t);
157
- }
158
- else t.__e = r.__e, t.__k = r.__k, e.then || ie(t);
159
- n.__e(e, t, r);
160
- }
161
- else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e = P(r.__e, t, r, i, a, o, s, l, u);
162
- return (d = n.diffed) && d(t), 128 & t.__u ? void 0 : c;
163
- }
164
- function ie(e) {
165
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ie));
166
- }
167
- function ae(e, t, r) {
168
- for (var i = 0; i < r.length; i++) se(r[i], r[++i], r[++i]);
169
- n.__c && n.__c(t, e), e.some(function(t) {
170
- try {
171
- e = t.__h, t.__h = [], e.some(function(e) {
172
- e.call(t);
173
- });
174
- } catch (e) {
175
- n.__e(e, t.__v);
176
- }
177
- });
178
- }
179
- function oe(e) {
180
- return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(oe) : y({}, e);
181
- }
182
- function P(e, r, i, a, o, s, c, l, u) {
183
- var d, f, p, m, g, _, y, x = i.props || h, S = r.props, C = r.type;
184
- if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
185
- for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
186
- e = g, s[d] = null;
187
- break;
188
- }
189
- }
190
- if (e == null) {
191
- if (C == null) return document.createTextNode(S);
192
- e = document.createElementNS(o, C, S.is && S), l &&= (n.__m && n.__m(r, s), !1), s = null;
193
- }
194
- if (C == null) x === S || l && e.data == S || (e.data = S);
195
- else {
196
- if (s &&= t.call(e.childNodes), !l && s != null) for (x = {}, d = 0; d < e.attributes.length; d++) x[(g = e.attributes[d]).name] = g.value;
197
- for (d in x) g = x[d], d == "dangerouslySetInnerHTML" ? p = g : d == "children" || d in S || d == "value" && "defaultValue" in S || d == "checked" && "defaultChecked" in S || N(e, d, null, g, o);
198
- for (d in S) g = S[d], d == "children" ? m = g : d == "dangerouslySetInnerHTML" ? f = g : d == "value" ? _ = g : d == "checked" ? y = g : l && typeof g != "function" || x[d] === g || N(e, d, g, x[d], o);
199
- if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), r.__k = [];
200
- else if (p && (e.innerHTML = ""), A(r.type == "template" ? e.content : e, v(m) ? m : [m], r, i, a, C == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : i.__k && T(i, 0), l, u), s != null) for (d = s.length; d--;) b(s[d]);
201
- l || (d = "value", C == "progress" && _ == null ? e.removeAttribute("value") : _ != null && (_ !== e[d] || C == "progress" && !_ || C == "option" && _ != x[d]) && N(e, d, _, x[d], o), d = "checked", y != null && y != e[d] && N(e, d, y, x[d], o));
202
- }
203
- return e;
204
- }
205
- function se(e, t, r) {
206
- try {
207
- if (typeof e == "function") {
208
- var i = typeof e.__u == "function";
209
- i && e.__u(), i && t == null || (e.__u = e(t));
210
- } else e.current = t;
211
- } catch (e) {
212
- n.__e(e, r);
213
- }
214
- }
215
- function ce(e, t, r) {
216
- var i, a;
217
- if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || se(i, null, t)), (i = e.__c) != null) {
218
- if (i.componentWillUnmount) try {
219
- i.componentWillUnmount();
220
- } catch (e) {
221
- n.__e(e, t);
222
- }
223
- i.base = i.__P = null;
224
- }
225
- if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && ce(i[a], t, r || typeof e.type != "function");
226
- r || b(e.__e), e.__c = e.__ = e.__e = void 0;
227
- }
228
- function le(e, t, n) {
229
- return this.constructor(e, n);
230
- }
231
- function ue(e, r, i) {
232
- var a, o, s, c;
233
- r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], re(r, e = (!a && i || r).__k = x(C, null, [e]), o || h, h, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? t.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ae(s, e, c);
234
- }
235
- t = g.slice, n = { __e: function(e, t, n, r) {
236
- for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
237
- if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
238
- } catch (t) {
239
- e = t;
240
- }
241
- throw e;
242
- } }, r = 0, w.prototype.setState = function(e, t) {
243
- var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = y({}, this.state);
244
- typeof e == "function" && (e = e(y({}, n), this.props)), e && y(n, e), e != null && this.__v && (t && this._sb.push(t), O(this));
245
- }, w.prototype.forceUpdate = function(e) {
246
- this.__v && (this.__e = !0, e && this.__h.push(e), O(this));
247
- }, w.prototype.render = C, i = [], o = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, s = function(e, t) {
248
- return e.__v.__b - t.__v.__b;
249
- }, k.__r = 0, c = Math.random().toString(8), l = "__d" + c, u = "__a" + c, d = /(PointerCapture)$|Capture$/i, f = 0, p = ne(!1), m = ne(!0);
250
- //#endregion
251
- //#region src/styles.css?inline
252
- var de = ":host{--markup-paper:#fdfcfa;--markup-ink:#1a1614;--markup-muted:#6b6661;--markup-border:#1a16141a;--markup-border-strong:#1a16142e;--markup-brand:#e35d2a;--markup-brand-hover:#c84d20;--markup-team:#2a4ac8;--markup-shadow:0 1px 2px #1a16140f, 0 8px 28px #1a16141f;--markup-overlay-tint:#1a16140a;--markup-danger:#dc2626;--markup-radius:6px;--markup-radius-sm:4px;--markup-font:\"Geist Variable\", \"Geist\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", system-ui, sans-serif;--markup-font-mono:\"Geist Mono Variable\", \"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;all:initial;font-family:var(--markup-font);color:var(--markup-ink);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:14px;line-height:1.5}:host([data-theme=dark]){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}@media (prefers-color-scheme:dark){:host(:not([data-theme=light])){--markup-paper:#1a1614;--markup-ink:#fdfcfa;--markup-muted:#a8a39e;--markup-border:#fdfcfa1f;--markup-border-strong:#fdfcfa38;--markup-team:#7b99f0;--markup-shadow:0 1px 2px #00000059, 0 12px 40px #00000073;--markup-overlay-tint:#fdfcfa0d;--markup-danger:#f87171}}.markup-shadow-root{font-family:var(--markup-font)}.markup-shadow-root *,.markup-shadow-root :before,.markup-shadow-root :after{box-sizing:border-box}:where(.markup-shadow-root button,.markup-shadow-root input,.markup-shadow-root textarea){font:inherit;color:inherit}.markup-eyebrow{font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--markup-muted);font-size:10px;font-weight:500}.markup-fab{z-index:10;background:var(--markup-ink);color:var(--markup-paper);cursor:pointer;letter-spacing:-.01em;pointer-events:auto;box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:999px;align-items:center;gap:8px;padding:9px 14px;font-size:13px;font-weight:500;transition:background .15s,box-shadow .15s,transform .15s;display:inline-flex;position:fixed;bottom:24px}.markup-fab:hover{background:var(--markup-brand);box-shadow:0 0 0 1px color-mix(in srgb, var(--markup-brand) 0%, transparent), var(--markup-shadow)}.markup-fab:active{transform:translateY(1px)}.markup-fab.is-active{background:var(--markup-brand);box-shadow:var(--markup-shadow)}.markup-fab.is-active:hover{background:var(--markup-brand-hover)}.markup-fab .markup-fab-icon{color:var(--markup-brand);transition:color .15s}.markup-fab:hover .markup-fab-icon,.markup-fab.is-active .markup-fab-icon{color:var(--markup-paper)}.markup-fab-right{right:24px}.markup-fab-left{left:24px}.markup-fab-icon{align-items:center;display:inline-flex}.markup-fab-label{font-family:var(--markup-font)}.markup-hud-hidden-toast{z-index:10;background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;align-items:center;gap:6px;padding:8px 14px;font-size:12px;font-weight:500;animation:.22s ease-out markup-hud-hidden-in,.32s ease-in 4.6s forwards markup-hud-hidden-out;display:inline-flex;position:fixed;bottom:24px}.markup-hud-hidden-toast-right{right:24px}.markup-hud-hidden-toast-left{left:24px}.markup-kbd{background:color-mix(in srgb, var(--markup-paper) 14%, transparent);min-width:18px;height:18px;color:var(--markup-paper);font-family:var(--markup-font);border-radius:4px;justify-content:center;align-items:center;padding:0 5px;font-size:10px;font-weight:600;line-height:1;display:inline-flex}@keyframes markup-hud-hidden-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes markup-hud-hidden-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(4px)}}.markup-pins-layer{pointer-events:none;position:fixed;inset:0}.markup-pin{background:var(--markup-ink);width:28px;height:28px;color:var(--markup-brand);cursor:pointer;pointer-events:auto;box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 3px color-mix(in srgb, var(--markup-brand) 35%, transparent), var(--markup-shadow);border:none;border-radius:50% 50% 50% 4px;justify-content:center;align-items:center;margin-top:-28px;padding:0;transition:transform .15s,background .15s,color .15s;display:inline-flex;position:absolute}.markup-pin:hover,.markup-pin.is-active{background:var(--markup-brand);color:var(--markup-paper)}.markup-pin.is-anchor{anchor-name:--markup-active-anchor}.markup-pin-ghost{background:var(--markup-brand);color:var(--markup-paper);cursor:default;pointer-events:none;animation:1.2s ease-in-out infinite markup-ghost-pulse}.markup-pin-dot{background:currentColor;border-radius:50%;width:6px;height:6px;display:inline-block}.markup-pin-count{background:var(--markup-brand);min-width:16px;height:16px;color:var(--markup-paper);font-family:var(--markup-font-mono);text-align:center;box-shadow:0 0 0 2px var(--markup-paper);border-radius:999px;padding:0 4px;font-size:9px;font-weight:600;line-height:16px;position:absolute;top:-4px;left:50%;transform:translate(-50%,-50%)}@keyframes markup-ghost-pulse{0%,to{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 0 #e35d2a66}50%{box-shadow:0 0 0 2px var(--markup-paper), 0 0 0 10px #e35d2a00}}.markup-placement-overlay{background:var(--markup-overlay-tint);cursor:crosshair;pointer-events:auto;z-index:1;animation:.18s ease-out markup-overlay-in;position:fixed;inset:0}.markup-placement-cursor-help{background:var(--markup-ink);color:var(--markup-paper);letter-spacing:-.01em;box-shadow:var(--markup-shadow);pointer-events:none;border-radius:999px;padding:10px 16px;font-size:12px;font-weight:500;animation:.22s ease-out 60ms backwards markup-help-in;position:fixed;top:24px;left:50%;transform:translate(-50%)}@keyframes markup-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes markup-help-in{0%{opacity:0;transform:translate(-50%,-8px)}to{opacity:1;transform:translate(-50%)}}.markup-popover{width:320px;max-width:calc(100vw - 24px);height:auto;max-height:calc(100dvh - 24px);inset:auto;left:var(--markup-pop-x,0);top:var(--markup-pop-y,0);background:var(--markup-paper);color:var(--markup-ink);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);box-shadow:var(--markup-shadow);pointer-events:auto;flex-direction:column;gap:0;margin:0;padding:0;animation:.16s ease-out markup-popover-in;display:flex;position:fixed;overflow:hidden}@supports (anchor-name:--x){.markup-popover{position-anchor:--markup-active-anchor;left:calc(anchor(right) + 8px);top:calc(anchor(top) - 9px);position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline;position-try-order:most-block-size}}@keyframes markup-popover-in{0%{opacity:0;transform:translateY(-4px)scale(.98)}to{opacity:1;transform:translateY(0)scale(1)}}.markup-popover-header{border-bottom:1px solid var(--markup-border);justify-content:space-between;align-items:center;padding:10px 12px;display:flex}.markup-popover-header-actions{align-items:center;gap:4px;display:flex}.markup-thread-menu{display:flex;position:relative}.markup-thread-menu-list{z-index:10;background:var(--markup-paper);border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius);min-width:160px;box-shadow:var(--markup-shadow);padding:4px;animation:.12s ease-out markup-menu-in;position:absolute;top:calc(100% + 6px);right:0}.markup-thread-menu-item{border-radius:var(--markup-radius-sm);width:100%;color:var(--markup-ink);text-align:left;cursor:pointer;background:0 0;border:none;padding:7px 10px;font-size:13px;transition:background .1s,color .1s;display:block}.markup-thread-menu-item:hover{background:var(--markup-border)}.markup-thread-menu-item.is-danger{color:var(--markup-danger,#dc2626)}.markup-thread-menu-item.is-danger:hover{background:color-mix(in srgb, var(--markup-danger,#dc2626) 10%, transparent)}.markup-thread-menu-item:disabled{opacity:.5;cursor:default}@keyframes markup-menu-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.markup-popover-body{padding:12px}.markup-popover-byline{color:var(--markup-muted);align-items:center;gap:4px;margin:0 0 8px;font-size:12px;display:flex}.markup-popover-name{color:var(--markup-ink);font-weight:500}.markup-icon-btn{border-radius:var(--markup-radius-sm);width:24px;height:24px;color:var(--markup-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;transition:background .12s,color .12s;display:inline-flex}.markup-icon-btn:hover,.markup-icon-btn.is-open{background:var(--markup-border);color:var(--markup-ink)}.markup-comments{border-bottom:1px solid var(--markup-border);background:linear-gradient(var(--markup-paper), transparent) top / 100% 20px no-repeat local, linear-gradient(transparent, var(--markup-paper)) bottom / 100% 20px no-repeat local, radial-gradient(farthest-side at 50% 0%, #1a16141a, transparent) top / 100% 10px no-repeat scroll, radial-gradient(farthest-side at 50% 100%, #1a16141a, transparent) bottom / 100% 10px no-repeat scroll;flex-direction:column;gap:12px;max-height:280px;margin:0;padding:8px 12px 4px;list-style:none;display:flex;overflow-y:auto}.markup-comment{flex-direction:column;gap:4px;display:flex}.markup-comment-meta{align-items:center;gap:6px;font-size:11px;display:flex}.markup-comment-author{color:var(--markup-ink);font-weight:600}.markup-comment.is-team .markup-comment-author{color:var(--markup-team)}.markup-comment-badge{background:color-mix(in srgb, var(--markup-team) 12%, transparent);height:14px;color:var(--markup-team);font-family:var(--markup-font-mono);letter-spacing:.12em;text-transform:uppercase;border-radius:999px;align-items:center;padding:0 5px;font-size:9px;font-weight:500;line-height:1;display:inline-flex}.markup-comment-time{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.04em;font-size:10px}.markup-comment-body{white-space:pre-wrap;word-break:break-word;margin:0;font-size:13px;line-height:1.5}.markup-comment-edited{color:var(--markup-muted);font-size:11px}.markup-thread-actions{align-items:center;gap:4px;display:flex}.markup-comment-meta .markup-reaction-picker-wrap,.markup-thread-actions{margin-left:auto}.markup-comment-meta .markup-reaction-add{width:22px;height:22px;margin-top:-4px;margin-bottom:-4px}.markup-reaction-picker-wrap>.markup-icon-btn,.markup-comment-menu>.markup-icon-btn{margin-top:-4px;margin-bottom:-4px}.markup-comment-menu.is-up .markup-thread-menu-list{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}@keyframes markup-menu-in-up{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.markup-comment{position:relative}.markup-reactions{flex-wrap:wrap;align-items:center;gap:4px;margin-top:2px;display:flex}.markup-reaction-chip{border:1px solid var(--markup-border);height:22px;color:var(--markup-ink);font:inherit;cursor:pointer;background:0 0;border-radius:999px;align-items:center;gap:4px;padding:0 7px 0 6px;font-size:11px;line-height:1;transition:background .12s,border-color .12s;display:inline-flex}.markup-reaction-chip:hover:not(:disabled){background:color-mix(in srgb, var(--markup-ink) 5%, transparent)}.markup-reaction-chip.is-mine{border-color:color-mix(in srgb, var(--markup-brand) 45%, transparent);background:color-mix(in srgb, var(--markup-brand) 10%, transparent)}.markup-reaction-chip.is-mine:hover:not(:disabled){background:color-mix(in srgb, var(--markup-brand) 16%, transparent)}.markup-reaction-chip:disabled{cursor:default;opacity:.6}.markup-reaction-emoji{font-size:13px;line-height:1}.markup-reaction-count{font-family:var(--markup-font-mono);letter-spacing:.04em;color:var(--markup-muted);font-size:10px}.markup-reaction-chip.is-mine .markup-reaction-count{color:var(--markup-brand)}.markup-reaction-picker-wrap{opacity:0;flex:none;transition:opacity .12s;display:inline-flex;position:relative}.markup-comment:hover .markup-reaction-picker-wrap,.markup-comment:focus-within .markup-reaction-picker-wrap,.markup-reaction-picker-wrap.is-open{opacity:1}.markup-reaction-add{border:1px dashed var(--markup-border-strong);width:22px;height:22px;color:var(--markup-muted);font:inherit;cursor:pointer;background:0 0;border-radius:999px;justify-content:center;align-items:center;font-size:13px;line-height:1;transition:background .12s,color .12s,border-color .12s;display:inline-flex}.markup-reaction-add:hover,.markup-reaction-add.is-open{background:color-mix(in srgb, var(--markup-ink) 5%, transparent);color:var(--markup-ink);border-style:solid}.markup-reaction-picker{z-index:1;border:1px solid var(--markup-border-strong);background:var(--markup-paper);border-radius:8px;gap:2px;padding:4px;animation:.12s markup-menu-in;display:flex;position:absolute;top:calc(100% + 6px);right:0;box-shadow:0 1px 2px #1a16140f,0 8px 28px #1a16141a}.markup-reaction-picker-wrap.is-up .markup-reaction-picker{animation-name:markup-menu-in-up;top:auto;bottom:calc(100% + 6px)}.markup-reaction-picker-item{cursor:pointer;background:0 0;border:0;border-radius:6px;justify-content:center;align-items:center;width:28px;height:28px;font-size:16px;line-height:1;transition:background .12s;display:inline-flex}.markup-reaction-picker-item:hover{background:color-mix(in srgb, var(--markup-ink) 8%, transparent)}.markup-reaction-picker-item.is-mine{background:color-mix(in srgb, var(--markup-brand) 14%, transparent)}.markup-comment-edit-form{flex-direction:column;gap:6px;display:flex}.markup-comment-edit-form .markup-textarea{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;color:var(--markup-ink);resize:vertical;font:inherit;outline:none;padding:8px 10px;font-size:13px;line-height:1.5}.markup-comment-edit-form .markup-textarea:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-comment-edit-actions{justify-content:flex-end;gap:6px;display:flex}.markup-composer{flex-direction:column;display:flex;position:relative}.markup-composer-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;min-height:36px;max-height:96px;color:var(--markup-ink);resize:none;font-family:var(--markup-font);outline:none;padding:8px 10px;font-size:13px;line-height:1.5;transition:border-color .12s,box-shadow .12s,border-bottom-left-radius .15s,border-bottom-right-radius .15s}.markup-composer-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-composer-input:disabled{opacity:.6}.markup-composer-input::placeholder{color:var(--markup-muted)}.markup-composer.is-filled .markup-composer-input{border-bottom-right-radius:0;border-bottom-left-radius:0}.markup-composer-footer-wrap{grid-template-rows:0fr;transition:grid-template-rows .15s;display:grid}.markup-composer.is-filled .markup-composer-footer-wrap{grid-template-rows:1fr}.markup-composer-footer{border:1px solid var(--markup-border-strong);border-radius:0 0 var(--markup-radius-sm) var(--markup-radius-sm);opacity:0;border-top:none;justify-content:space-between;align-items:center;gap:8px;padding:2px 2px 2px 10px;transition:opacity .1s;display:flex;overflow:hidden}.markup-composer.is-filled .markup-composer-footer{opacity:1;transition-delay:60ms}.markup-composer-hint{font-family:var(--markup-font-mono);letter-spacing:.06em;color:var(--markup-muted);font-size:10px}.markup-composer-error{color:var(--markup-brand)}.markup-composer-actions{align-items:center;gap:6px;display:flex}.markup-composer-actions-empty{transition:opacity .12s;position:absolute;top:3px;right:3px}.markup-composer.is-filled .markup-composer-actions-empty{opacity:0;pointer-events:none}.markup-author-prompt{flex-direction:column;gap:10px;padding:12px;display:flex}.markup-input{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);background:var(--markup-paper);width:100%;height:36px;color:var(--markup-ink);outline:none;padding:0 10px;font-size:14px;transition:border-color .12s,box-shadow .12s}.markup-input:focus-visible{border-color:var(--markup-brand);box-shadow:0 0 0 3px #e35d2a2e}.markup-btn{border-radius:var(--markup-radius-sm);height:30px;color:var(--markup-ink);cursor:pointer;letter-spacing:-.01em;white-space:nowrap;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;gap:6px;padding:0 8px;font-size:12px;font-weight:500;transition:background .12s,border-color .12s,color .12s,opacity .12s;display:inline-flex}.markup-btn:disabled{opacity:.5;cursor:not-allowed}.markup-btn-primary{background:var(--markup-ink);color:var(--markup-paper)}.markup-btn-primary:hover:not(:disabled){background:var(--markup-brand)}.markup-btn-ghost{color:var(--markup-muted)}.markup-btn-ghost:hover:not(:disabled){background:var(--markup-border);color:var(--markup-ink)}.markup-screenshot-row{border-top:1px solid var(--markup-border);margin-top:8px;padding-top:8px}.markup-screenshot-status{color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;display:flex}.markup-screenshot-toggle{cursor:pointer;color:var(--markup-muted);font-family:var(--markup-font-mono);letter-spacing:.06em;align-items:center;gap:5px;font-size:10px;transition:color .12s;display:flex}.markup-screenshot-toggle:hover{color:var(--markup-ink)}.markup-screenshot-checkbox{width:12px;height:12px;accent-color:var(--markup-brand);cursor:pointer;margin:0}.markup-screenshot-thumb{border:1px solid var(--markup-border-strong);object-fit:cover;border-radius:3px;flex-shrink:0;width:auto;height:25px;margin:-5px 0 -5px auto;display:block}.markup-comment-screenshot{border:1px solid var(--markup-border-strong);border-radius:var(--markup-radius-sm);cursor:pointer;background:0 0;margin-top:8px;padding:0;transition:border-color .12s,opacity .12s;display:block;overflow:hidden}.markup-comment-screenshot:hover{border-color:var(--markup-brand);opacity:.9}.markup-comment-screenshot img{object-fit:cover;object-position:top;width:100%;height:auto;max-height:120px;display:block}.markup-lightbox{background:#1a1614e0;border:none;width:100%;max-width:100%;height:100%;max-height:100%;margin:0;padding:24px;position:fixed;inset:0}.markup-lightbox[open]{justify-content:center;align-items:center;display:flex}.markup-lightbox::backdrop{display:none}.markup-lightbox-img{border-radius:var(--markup-radius);object-fit:contain;max-width:100%;max-height:100%;box-shadow:var(--markup-shadow);animation:.16s ease-out markup-lightbox-in}.markup-lightbox-close{color:#fdfcfa;background:#1a161499;position:absolute;top:16px;right:16px}.markup-lightbox-close:hover{color:#fdfcfa;background:#1a1614d9}@keyframes markup-lightbox-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){.markup-fab,.markup-pin,.markup-icon-btn,.markup-btn,.markup-popover,.markup-pin-ghost,.markup-placement-overlay,.markup-placement-cursor-help,.markup-lightbox-img{transition:none;animation:none}}", fe, F, pe, me, he = 0, ge = [], I = n, _e = I.__b, ve = I.__r, ye = I.diffed, be = I.__c, xe = I.unmount, Se = I.__;
253
- function Ce(e, t) {
254
- I.__h && I.__h(F, e, he || t), he = 0;
255
- var n = F.__H ||= {
256
- __: [],
257
- __h: []
258
- };
259
- return e >= n.__.length && n.__.push({}), n.__[e];
260
- }
261
- function L(e) {
262
- return he = 1, we(Me, e);
263
- }
264
- function we(e, t, n) {
265
- var r = Ce(fe++, 2);
266
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Me(void 0, t), function(e) {
267
- var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
268
- t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
269
- }], r.__c = F, !F.__f)) {
270
- var i = function(e, t, n) {
271
- if (!r.__c.__H) return !0;
272
- var i = r.__c.__H.__.filter(function(e) {
273
- return e.__c;
274
- });
275
- if (i.every(function(e) {
276
- return !e.__N;
277
- })) return !a || a.call(this, e, t, n);
278
- var o = r.__c.props !== e;
279
- return i.some(function(e) {
280
- if (e.__N) {
281
- var t = e.__[0];
282
- e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0);
283
- }
284
- }), a && a.call(this, e, t, n) || o;
285
- };
286
- F.__f = !0;
287
- var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
288
- F.componentWillUpdate = function(e, t, n) {
289
- if (this.__e) {
290
- var r = a;
291
- a = void 0, i(e, t, n), a = r;
292
- }
293
- o && o.call(this, e, t, n);
294
- }, F.shouldComponentUpdate = i;
295
- }
296
- return r.__N || r.__;
297
- }
298
- function R(e, t) {
299
- var n = Ce(fe++, 3);
300
- !I.__s && je(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
301
- }
302
- function z(e) {
303
- return he = 5, Te(function() {
304
- return { current: e };
305
- }, []);
306
- }
307
- function Te(e, t) {
308
- var n = Ce(fe++, 7);
309
- return je(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
310
- }
311
- function B(e, t) {
312
- return he = 8, Te(function() {
313
- return e;
314
- }, t);
315
- }
316
- function Ee() {
317
- for (var e; e = ge.shift();) {
318
- var t = e.__H;
319
- if (e.__P && t) try {
320
- t.__h.some(ke), t.__h.some(Ae), t.__h = [];
321
- } catch (n) {
322
- t.__h = [], I.__e(n, e.__v);
323
- }
324
- }
325
- }
326
- I.__b = function(e) {
327
- F = null, _e && _e(e);
328
- }, I.__ = function(e, t) {
329
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Se && Se(e, t);
330
- }, I.__r = function(e) {
331
- ve && ve(e), fe = 0;
332
- var t = (F = e.__c).__H;
333
- t && (pe === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
334
- e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
335
- })) : (t.__h.some(ke), t.__h.some(Ae), t.__h = [], fe = 0)), pe = F;
336
- }, I.diffed = function(e) {
337
- ye && ye(e);
338
- var t = e.__c;
339
- t && t.__H && (t.__H.__h.length && (ge.push(t) !== 1 && me === I.requestAnimationFrame || ((me = I.requestAnimationFrame) || Oe)(Ee)), t.__H.__.some(function(e) {
340
- e.u && (e.__H = e.u), e.u = void 0;
341
- })), pe = F = null;
342
- }, I.__c = function(e, t) {
343
- t.some(function(e) {
344
- try {
345
- e.__h.some(ke), e.__h = e.__h.filter(function(e) {
346
- return !e.__ || Ae(e);
347
- });
348
- } catch (n) {
349
- t.some(function(e) {
350
- e.__h &&= [];
351
- }), t = [], I.__e(n, e.__v);
352
- }
353
- }), be && be(e, t);
354
- }, I.unmount = function(e) {
355
- xe && xe(e);
356
- var t, n = e.__c;
357
- n && n.__H && (n.__H.__.some(function(e) {
358
- try {
359
- ke(e);
360
- } catch (e) {
361
- t = e;
362
- }
363
- }), n.__H = void 0, t && I.__e(t, n.__v));
364
- };
365
- var De = typeof requestAnimationFrame == "function";
366
- function Oe(e) {
367
- var t, n = function() {
368
- clearTimeout(r), De && cancelAnimationFrame(t), setTimeout(e);
369
- }, r = setTimeout(n, 35);
370
- De && (t = requestAnimationFrame(n));
371
- }
372
- function ke(e) {
373
- var t = F, n = e.__c;
374
- typeof n == "function" && (e.__c = void 0, n()), F = t;
375
- }
376
- function Ae(e) {
377
- var t = F;
378
- e.__c = e.__(), F = t;
379
- }
380
- function je(e, t) {
381
- return !e || e.length !== t.length || t.some(function(t, n) {
382
- return t !== e[n];
383
- });
384
- }
385
- function Me(e, t) {
386
- return typeof t == "function" ? t(e) : t;
387
- }
388
- for (var Ne = "1.37.0", V = [], H = [], Pe = Uint8Array, Fe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ie = 0, Le = Fe.length; Ie < Le; ++Ie) V[Ie] = Fe[Ie], H[Fe.charCodeAt(Ie)] = Ie;
389
- H[45] = 62, H[95] = 63;
390
- function Re(e) {
391
- var t = e.length;
392
- if (t % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4");
393
- var n = e.indexOf("=");
394
- n === -1 && (n = t);
395
- var r = n === t ? 0 : 4 - n % 4;
396
- return [n, r];
397
- }
398
- function ze(e, t, n) {
399
- return (t + n) * 3 / 4 - n;
400
- }
401
- function Be(e) {
402
- var t, n = Re(e), r = n[0], i = n[1], a = new Pe(ze(e, r, i)), o = 0, s = i > 0 ? r - 4 : r, c;
403
- for (c = 0; c < s; c += 4) t = H[e.charCodeAt(c)] << 18 | H[e.charCodeAt(c + 1)] << 12 | H[e.charCodeAt(c + 2)] << 6 | H[e.charCodeAt(c + 3)], a[o++] = t >> 16 & 255, a[o++] = t >> 8 & 255, a[o++] = t & 255;
404
- return i === 2 && (t = H[e.charCodeAt(c)] << 2 | H[e.charCodeAt(c + 1)] >> 4, a[o++] = t & 255), i === 1 && (t = H[e.charCodeAt(c)] << 10 | H[e.charCodeAt(c + 1)] << 4 | H[e.charCodeAt(c + 2)] >> 2, a[o++] = t >> 8 & 255, a[o++] = t & 255), a;
405
- }
406
- function Ve(e) {
407
- return V[e >> 18 & 63] + V[e >> 12 & 63] + V[e >> 6 & 63] + V[e & 63];
408
- }
409
- function He(e, t, n) {
410
- for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(Ve(r));
411
- return i.join("");
412
- }
413
- function Ue(e) {
414
- for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(He(e, o, o + a > s ? s : o + a));
415
- return r === 1 ? (t = e[n - 1], i.push(V[t >> 2] + V[t << 4 & 63] + "==")) : r === 2 && (t = (e[n - 2] << 8) + e[n - 1], i.push(V[t >> 10] + V[t >> 4 & 63] + V[t << 2 & 63] + "=")), i.join("");
416
- }
417
- //#endregion
418
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/common/index.js
419
- function U(e) {
420
- if (e === void 0) return {};
421
- if (!Ge(e)) throw Error(`The arguments to a Convex function must be an object. Received: ${e}`);
422
- return e;
423
- }
424
- function We(e) {
425
- if (e === void 0) throw Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");
426
- if (typeof e != "string") throw Error(`Invalid deployment address: found ${e}".`);
427
- if (!(e.startsWith("http:") || e.startsWith("https:"))) throw Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${e}".`);
428
- try {
429
- new URL(e);
430
- } catch {
431
- throw Error(`Invalid deployment address: "${e}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
432
- }
433
- if (e.endsWith(".convex.site")) throw Error(`Invalid deployment address: "${e}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
434
- }
435
- function Ge(e) {
436
- let t = typeof e == "object", n = Object.getPrototypeOf(e), r = n === null || n === Object.prototype || n?.constructor?.name === "Object";
437
- return t && r;
438
- }
439
- //#endregion
440
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/value.js
441
- var Ke = !0, qe = BigInt("-9223372036854775808"), Je = BigInt("9223372036854775807"), Ye = BigInt("0"), Xe = BigInt("8"), Ze = BigInt("256");
442
- function Qe(e) {
443
- return Number.isNaN(e) || !Number.isFinite(e) || Object.is(e, -0);
444
- }
445
- function $e(e) {
446
- e < Ye && (e -= qe + qe);
447
- let t = e.toString(16);
448
- t.length % 2 == 1 && (t = "0" + t);
449
- let n = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(8)), r = 0;
450
- for (let i of t.match(/.{2}/g).reverse()) n.set([parseInt(i, 16)], r++), e >>= Xe;
451
- return Ue(n);
452
- }
453
- function et(e) {
454
- let t = Be(e);
455
- if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
456
- let n = Ye, r = Ye;
457
- for (let e of t) n += BigInt(e) * Ze ** r, r++;
458
- return n > Je && (n += qe + qe), n;
459
- }
460
- function tt(e) {
461
- if (e < qe || Je < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
462
- let t = /* @__PURE__ */ new ArrayBuffer(8);
463
- return new DataView(t).setBigInt64(0, e, !0), Ue(new Uint8Array(t));
464
- }
465
- function nt(e) {
466
- let t = Be(e);
467
- if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);
468
- return new DataView(t.buffer).getBigInt64(0, !0);
469
- }
470
- var rt = DataView.prototype.setBigInt64 ? tt : $e, it = DataView.prototype.getBigInt64 ? nt : et, at = 1024;
471
- function ot(e) {
472
- if (e.length > at) throw Error(`Field name ${e} exceeds maximum field name length ${at}.`);
473
- if (e.startsWith("$")) throw Error(`Field name ${e} starts with a '$', which is reserved.`);
474
- for (let t = 0; t < e.length; t += 1) {
475
- let n = e.charCodeAt(t);
476
- if (n < 32 || n >= 127) throw Error(`Field name ${e} has invalid character '${e[t]}': Field names can only contain non-control ASCII characters`);
477
- }
478
- }
479
- function st(e) {
480
- if (e === null || typeof e == "boolean" || typeof e == "number" || typeof e == "string") return e;
481
- if (Array.isArray(e)) return e.map((e) => st(e));
482
- if (typeof e != "object") throw Error(`Unexpected type of ${e}`);
483
- let t = Object.entries(e);
484
- if (t.length === 1) {
485
- let n = t[0][0];
486
- if (n === "$bytes") {
487
- if (typeof e.$bytes != "string") throw Error(`Malformed $bytes field on ${e}`);
488
- return Be(e.$bytes).buffer;
489
- }
490
- if (n === "$integer") {
491
- if (typeof e.$integer != "string") throw Error(`Malformed $integer field on ${e}`);
492
- return it(e.$integer);
493
- }
494
- if (n === "$float") {
495
- if (typeof e.$float != "string") throw Error(`Malformed $float field on ${e}`);
496
- let t = Be(e.$float);
497
- if (t.byteLength !== 8) throw Error(`Received ${t.byteLength} bytes, expected 8 for $float`);
498
- let n = new DataView(t.buffer).getFloat64(0, Ke);
499
- if (!Qe(n)) throw Error(`Float ${n} should be encoded as a number`);
500
- return n;
501
- }
502
- if (n === "$set") throw Error("Received a Set which is no longer supported as a Convex type.");
503
- if (n === "$map") throw Error("Received a Map which is no longer supported as a Convex type.");
504
- }
505
- let n = {};
506
- for (let [t, r] of Object.entries(e)) ot(t), n[t] = st(r);
507
- return n;
508
- }
509
- var ct = 16384;
510
- function lt(e) {
511
- let t = JSON.stringify(e, (e, t) => t === void 0 ? "undefined" : typeof t == "bigint" ? `${t.toString()}n` : t);
512
- if (t.length > ct) {
513
- let e = ct - 14, n = t.codePointAt(e - 1);
514
- return n !== void 0 && n > 65535 && --e, t.substring(0, e) + "[...truncated]";
515
- }
516
- return t;
517
- }
518
- function ut(e, t, n, r) {
519
- if (e === void 0) {
520
- let e = n && ` (present at path ${n} in original object ${lt(t)})`;
521
- throw Error(`undefined is not a valid Convex value${e}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
522
- }
523
- if (e === null) return e;
524
- if (typeof e == "bigint") {
525
- if (e < qe || Je < e) throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);
526
- return { $integer: rt(e) };
527
- }
528
- if (typeof e == "number") if (Qe(e)) {
529
- let t = /* @__PURE__ */ new ArrayBuffer(8);
530
- return new DataView(t).setFloat64(0, e, Ke), { $float: Ue(new Uint8Array(t)) };
531
- } else return e;
532
- if (typeof e == "boolean" || typeof e == "string") return e;
533
- if (e instanceof ArrayBuffer) return { $bytes: Ue(new Uint8Array(e)) };
534
- if (Array.isArray(e)) return e.map((e, r) => ut(e, t, n + `[${r}]`, !1));
535
- if (e instanceof Set) throw Error(dt(n, "Set", [...e], t));
536
- if (e instanceof Map) throw Error(dt(n, "Map", [...e], t));
537
- if (!Ge(e)) {
538
- let r = e?.constructor?.name, i = r ? `${r} ` : "";
539
- throw Error(dt(n, i, e, t));
540
- }
541
- let i = {}, a = Object.entries(e);
542
- a.sort(([e, t], [n, r]) => e === n ? 0 : e < n ? -1 : 1);
543
- for (let [e, o] of a) o === void 0 ? r && (ot(e), i[e] = ft(o, t, n + `.${e}`)) : (ot(e), i[e] = ut(o, t, n + `.${e}`, !1));
544
- return i;
545
- }
546
- function dt(e, t, n, r) {
547
- return e ? `${t}${lt(n)} is not a supported Convex type (present at path ${e} in original object ${lt(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.` : `${t}${lt(n)} is not a supported Convex type.`;
548
- }
549
- function ft(e, t, n) {
550
- if (e === void 0) return { $undefined: null };
551
- if (t === void 0) throw Error(`Programming error. Current value is ${lt(e)} but original value is undefined`);
552
- return ut(e, t, n, !1);
553
- }
554
- function pt(e) {
555
- return ut(e, e, "", !1);
556
- }
557
- //#endregion
558
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/values/errors.js
559
- var mt = Object.defineProperty, ht = (e, t, n) => t in e ? mt(e, t, {
560
- enumerable: !0,
561
- configurable: !0,
562
- writable: !0,
563
- value: n
564
- }) : e[t] = n, gt = (e, t, n) => ht(e, typeof t == "symbol" ? t : t + "", n), _t, vt, yt = Symbol.for("ConvexError"), bt = class extends (vt = Error, _t = yt, vt) {
565
- constructor(e) {
566
- super(typeof e == "string" ? e : lt(e)), gt(this, "name", "ConvexError"), gt(this, "data"), gt(this, _t, !0), this.data = e;
567
- }
568
- }, xt = Object.defineProperty, St = (e, t, n) => t in e ? xt(e, t, {
569
- enumerable: !0,
570
- configurable: !0,
571
- writable: !0,
572
- value: n
573
- }) : e[t] = n, Ct = (e, t, n) => St(e, typeof t == "symbol" ? t : t + "", n), wt = "color:rgb(0, 145, 255)";
574
- function Tt(e) {
575
- switch (e) {
576
- case "query": return "Q";
577
- case "mutation": return "M";
578
- case "action": return "A";
579
- case "any": return "?";
580
- }
581
- }
582
- var Et = class {
583
- constructor(e) {
584
- Ct(this, "_onLogLineFuncs"), Ct(this, "_verbose"), this._onLogLineFuncs = {}, this._verbose = e.verbose;
585
- }
586
- addLogLineListener(e) {
587
- let t = Math.random().toString(36).substring(2, 15);
588
- for (let e = 0; e < 10 && this._onLogLineFuncs[t] !== void 0; e++) t = Math.random().toString(36).substring(2, 15);
589
- return this._onLogLineFuncs[t] = e, () => {
590
- delete this._onLogLineFuncs[t];
591
- };
592
- }
593
- logVerbose(...e) {
594
- if (this._verbose) for (let t of Object.values(this._onLogLineFuncs)) t("debug", `${(/* @__PURE__ */ new Date()).toISOString()}`, ...e);
595
- }
596
- log(...e) {
597
- for (let t of Object.values(this._onLogLineFuncs)) t("info", ...e);
598
- }
599
- warn(...e) {
600
- for (let t of Object.values(this._onLogLineFuncs)) t("warn", ...e);
601
- }
602
- error(...e) {
603
- for (let t of Object.values(this._onLogLineFuncs)) t("error", ...e);
604
- }
605
- };
606
- function Dt(e) {
607
- let t = new Et(e);
608
- return t.addLogLineListener((e, ...t) => {
609
- switch (e) {
610
- case "debug":
611
- console.debug(...t);
612
- break;
613
- case "info":
614
- console.log(...t);
615
- break;
616
- case "warn":
617
- console.warn(...t);
618
- break;
619
- case "error":
620
- console.error(...t);
621
- break;
622
- default: console.log(...t);
623
- }
624
- }), t;
625
- }
626
- function Ot(e) {
627
- return new Et(e);
628
- }
629
- function kt(e, t, n, r, i) {
630
- let a = Tt(n);
631
- if (typeof i == "object" && (i = `ConvexError ${JSON.stringify(i.errorData, null, 2)}`), t === "info") {
632
- let t = i.match(/^\[.*?\] /);
633
- if (t === null) {
634
- e.error(`[CONVEX ${a}(${r})] Could not parse console.log`);
635
- return;
636
- }
637
- let n = i.slice(1, t[0].length - 2), o = i.slice(t[0].length);
638
- e.log(`%c[CONVEX ${a}(${r})] [${n}]`, wt, o);
639
- } else e.error(`[CONVEX ${a}(${r})] ${i}`);
640
- }
641
- function At(e, t) {
642
- let n = `[CONVEX FATAL ERROR] ${t}`;
643
- return e.error(n), Error(n);
644
- }
645
- function jt(e, t, n) {
646
- return `[CONVEX ${Tt(e)}(${t})] ${n.errorMessage}
647
- Called by client`;
648
- }
649
- function Mt(e, t) {
650
- return t.data = e.errorData, t;
651
- }
652
- //#endregion
653
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/udf_path_utils.js
654
- function Nt(e) {
655
- let t = e.split(":"), n, r;
656
- return t.length === 1 ? (n = t[0], r = "default") : (n = t.slice(0, t.length - 1).join(":"), r = t[t.length - 1]), n.endsWith(".js") && (n = n.slice(0, -3)), `${n}:${r}`;
657
- }
658
- function Pt(e, t) {
659
- return JSON.stringify({
660
- udfPath: Nt(e),
661
- args: pt(t)
662
- });
663
- }
664
- function Ft(e, t, n) {
665
- let { initialNumItems: r, id: i } = n;
666
- return JSON.stringify({
667
- type: "paginated",
668
- udfPath: Nt(e),
669
- args: pt(t),
670
- options: pt({
671
- initialNumItems: r,
672
- id: i
673
- })
674
- });
675
- }
676
- function It(e) {
677
- return JSON.parse(e).type === "paginated";
678
- }
679
- //#endregion
680
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/local_state.js
681
- var Lt = Object.defineProperty, Rt = (e, t, n) => t in e ? Lt(e, t, {
682
- enumerable: !0,
683
- configurable: !0,
684
- writable: !0,
685
- value: n
686
- }) : e[t] = n, W = (e, t, n) => Rt(e, typeof t == "symbol" ? t : t + "", n), zt = class {
687
- constructor() {
688
- W(this, "nextQueryId"), W(this, "querySetVersion"), W(this, "querySet"), W(this, "queryIdToToken"), W(this, "identityVersion"), W(this, "auth"), W(this, "outstandingQueriesOlderThanRestart"), W(this, "outstandingAuthOlderThanRestart"), W(this, "paused"), W(this, "pendingQuerySetModifications"), this.nextQueryId = 0, this.querySetVersion = 0, this.identityVersion = 0, this.querySet = /* @__PURE__ */ new Map(), this.queryIdToToken = /* @__PURE__ */ new Map(), this.outstandingQueriesOlderThanRestart = /* @__PURE__ */ new Set(), this.outstandingAuthOlderThanRestart = !1, this.paused = !1, this.pendingQuerySetModifications = /* @__PURE__ */ new Map();
689
- }
690
- hasSyncedPastLastReconnect() {
691
- return this.outstandingQueriesOlderThanRestart.size === 0 && !this.outstandingAuthOlderThanRestart;
692
- }
693
- markAuthCompletion() {
694
- this.outstandingAuthOlderThanRestart = !1;
695
- }
696
- subscribe(e, t, n, r) {
697
- let i = Nt(e), a = Pt(i, t), o = this.querySet.get(a);
698
- if (o !== void 0) return o.numSubscribers += 1, {
699
- queryToken: a,
700
- modification: null,
701
- unsubscribe: () => this.removeSubscriber(a)
702
- };
703
- {
704
- let e = this.nextQueryId++, o = {
705
- id: e,
706
- canonicalizedUdfPath: i,
707
- args: t,
708
- numSubscribers: 1,
709
- journal: n,
710
- componentPath: r
711
- };
712
- this.querySet.set(a, o), this.queryIdToToken.set(e, a);
713
- let s = this.querySetVersion, c = this.querySetVersion + 1, l = {
714
- type: "Add",
715
- queryId: e,
716
- udfPath: i,
717
- args: [pt(t)],
718
- journal: n,
719
- componentPath: r
720
- };
721
- return this.paused ? this.pendingQuerySetModifications.set(e, l) : this.querySetVersion = c, {
722
- queryToken: a,
723
- modification: {
724
- type: "ModifyQuerySet",
725
- baseVersion: s,
726
- newVersion: c,
727
- modifications: [l]
728
- },
729
- unsubscribe: () => this.removeSubscriber(a)
730
- };
731
- }
732
- }
733
- transition(e) {
734
- for (let t of e.modifications) switch (t.type) {
735
- case "QueryUpdated":
736
- case "QueryFailed": {
737
- this.outstandingQueriesOlderThanRestart.delete(t.queryId);
738
- let e = t.journal;
739
- if (e !== void 0) {
740
- let n = this.queryIdToToken.get(t.queryId);
741
- n !== void 0 && (this.querySet.get(n).journal = e);
742
- }
743
- break;
744
- }
745
- case "QueryRemoved":
746
- this.outstandingQueriesOlderThanRestart.delete(t.queryId);
747
- break;
748
- default: throw Error(`Invalid modification ${t.type}`);
749
- }
750
- }
751
- queryId(e, t) {
752
- let n = Pt(Nt(e), t), r = this.querySet.get(n);
753
- return r === void 0 ? null : r.id;
754
- }
755
- isCurrentOrNewerAuthVersion(e) {
756
- return e >= this.identityVersion;
757
- }
758
- getAuth() {
759
- return this.auth;
760
- }
761
- setAuth(e) {
762
- this.auth = {
763
- tokenType: "User",
764
- value: e
765
- };
766
- let t = this.identityVersion;
767
- return this.paused || (this.identityVersion = t + 1), {
768
- type: "Authenticate",
769
- baseVersion: t,
770
- ...this.auth
771
- };
772
- }
773
- setAdminAuth(e, t) {
774
- let n = {
775
- tokenType: "Admin",
776
- value: e,
777
- impersonating: t
778
- };
779
- this.auth = n;
780
- let r = this.identityVersion;
781
- return this.paused || (this.identityVersion = r + 1), {
782
- type: "Authenticate",
783
- baseVersion: r,
784
- ...n
785
- };
786
- }
787
- clearAuth() {
788
- this.auth = void 0, this.markAuthCompletion();
789
- let e = this.identityVersion;
790
- return this.paused || (this.identityVersion = e + 1), {
791
- type: "Authenticate",
792
- tokenType: "None",
793
- baseVersion: e
794
- };
795
- }
796
- hasAuth() {
797
- return !!this.auth;
798
- }
799
- isNewAuth(e) {
800
- return this.auth?.value !== e;
801
- }
802
- queryPath(e) {
803
- let t = this.queryIdToToken.get(e);
804
- return t ? this.querySet.get(t).canonicalizedUdfPath : null;
805
- }
806
- queryArgs(e) {
807
- let t = this.queryIdToToken.get(e);
808
- return t ? this.querySet.get(t).args : null;
809
- }
810
- queryToken(e) {
811
- return this.queryIdToToken.get(e) ?? null;
812
- }
813
- queryJournal(e) {
814
- return this.querySet.get(e)?.journal;
815
- }
816
- restart() {
817
- this.unpause(), this.outstandingQueriesOlderThanRestart.clear();
818
- let e = [];
819
- for (let t of this.querySet.values()) {
820
- let n = {
821
- type: "Add",
822
- queryId: t.id,
823
- udfPath: t.canonicalizedUdfPath,
824
- args: [pt(t.args)],
825
- journal: t.journal,
826
- componentPath: t.componentPath
827
- };
828
- e.push(n), this.outstandingQueriesOlderThanRestart.add(t.id);
829
- }
830
- this.querySetVersion = 1;
831
- let t = {
832
- type: "ModifyQuerySet",
833
- baseVersion: 0,
834
- newVersion: 1,
835
- modifications: e
836
- };
837
- if (!this.auth) return this.identityVersion = 0, [t, void 0];
838
- this.outstandingAuthOlderThanRestart = !0;
839
- let n = {
840
- type: "Authenticate",
841
- baseVersion: 0,
842
- ...this.auth
843
- };
844
- return this.identityVersion = 1, [t, n];
845
- }
846
- pause() {
847
- this.paused = !0;
848
- }
849
- resume() {
850
- let e = this.pendingQuerySetModifications.size > 0 ? {
851
- type: "ModifyQuerySet",
852
- baseVersion: this.querySetVersion,
853
- newVersion: ++this.querySetVersion,
854
- modifications: Array.from(this.pendingQuerySetModifications.values())
855
- } : void 0, t = this.auth === void 0 ? void 0 : {
856
- type: "Authenticate",
857
- baseVersion: this.identityVersion++,
858
- ...this.auth
859
- };
860
- return this.unpause(), [e, t];
861
- }
862
- unpause() {
863
- this.paused = !1, this.pendingQuerySetModifications.clear();
864
- }
865
- removeSubscriber(e) {
866
- let t = this.querySet.get(e);
867
- if (t.numSubscribers > 1) return --t.numSubscribers, null;
868
- {
869
- this.querySet.delete(e), this.queryIdToToken.delete(t.id), this.outstandingQueriesOlderThanRestart.delete(t.id);
870
- let n = this.querySetVersion, r = this.querySetVersion + 1, i = {
871
- type: "Remove",
872
- queryId: t.id
873
- };
874
- return this.paused ? this.pendingQuerySetModifications.has(t.id) ? this.pendingQuerySetModifications.delete(t.id) : this.pendingQuerySetModifications.set(t.id, i) : this.querySetVersion = r, {
875
- type: "ModifyQuerySet",
876
- baseVersion: n,
877
- newVersion: r,
878
- modifications: [i]
879
- };
880
- }
881
- }
882
- }, Bt = Object.defineProperty, Vt = (e, t, n) => t in e ? Bt(e, t, {
883
- enumerable: !0,
884
- configurable: !0,
885
- writable: !0,
886
- value: n
887
- }) : e[t] = n, Ht = (e, t, n) => Vt(e, typeof t == "symbol" ? t : t + "", n), Ut = class {
888
- constructor(e, t) {
889
- this.logger = e, this.markConnectionStateDirty = t, Ht(this, "inflightRequests"), Ht(this, "requestsOlderThanRestart"), Ht(this, "inflightMutationsCount", 0), Ht(this, "inflightActionsCount", 0), this.inflightRequests = /* @__PURE__ */ new Map(), this.requestsOlderThanRestart = /* @__PURE__ */ new Set();
890
- }
891
- request(e, t) {
892
- let n = new Promise((n) => {
893
- let r = t ? "Requested" : "NotSent";
894
- this.inflightRequests.set(e.requestId, {
895
- message: e,
896
- status: {
897
- status: r,
898
- requestedAt: /* @__PURE__ */ new Date(),
899
- onResult: n
900
- }
901
- }), e.type === "Mutation" ? this.inflightMutationsCount++ : e.type === "Action" && this.inflightActionsCount++;
902
- });
903
- return this.markConnectionStateDirty(), n;
904
- }
905
- onResponse(e) {
906
- let t = this.inflightRequests.get(e.requestId);
907
- if (t === void 0 || t.status.status === "Completed") return null;
908
- let n = t.message.type === "Mutation" ? "mutation" : "action", r = t.message.udfPath;
909
- for (let t of e.logLines) kt(this.logger, "info", n, r, t);
910
- let i = t.status, a, o;
911
- if (e.success) a = {
912
- success: !0,
913
- logLines: e.logLines,
914
- value: st(e.result)
915
- }, o = () => i.onResult(a);
916
- else {
917
- let t = e.result, { errorData: s } = e;
918
- kt(this.logger, "error", n, r, t), a = {
919
- success: !1,
920
- errorMessage: t,
921
- errorData: s === void 0 ? void 0 : st(s),
922
- logLines: e.logLines
923
- }, o = () => i.onResult(a);
924
- }
925
- return e.type === "ActionResponse" || !e.success ? (o(), this.inflightRequests.delete(e.requestId), this.requestsOlderThanRestart.delete(e.requestId), t.message.type === "Action" ? this.inflightActionsCount-- : t.message.type === "Mutation" && this.inflightMutationsCount--, this.markConnectionStateDirty(), {
926
- requestId: e.requestId,
927
- result: a
928
- }) : (t.status = {
929
- status: "Completed",
930
- result: a,
931
- ts: e.ts,
932
- onResolve: o
933
- }, null);
934
- }
935
- removeCompleted(e) {
936
- let t = /* @__PURE__ */ new Map();
937
- for (let [n, r] of this.inflightRequests.entries()) {
938
- let i = r.status;
939
- i.status === "Completed" && i.ts.lessThanOrEqual(e) && (i.onResolve(), t.set(n, i.result), r.message.type === "Mutation" ? this.inflightMutationsCount-- : r.message.type === "Action" && this.inflightActionsCount--, this.inflightRequests.delete(n), this.requestsOlderThanRestart.delete(n));
940
- }
941
- return t.size > 0 && this.markConnectionStateDirty(), t;
942
- }
943
- restart() {
944
- this.requestsOlderThanRestart = new Set(this.inflightRequests.keys());
945
- let e = [];
946
- for (let [t, n] of this.inflightRequests) {
947
- if (n.status.status === "NotSent") {
948
- n.status.status = "Requested", e.push(n.message);
949
- continue;
950
- }
951
- if (n.message.type === "Mutation") e.push(n.message);
952
- else if (n.message.type === "Action") {
953
- if (this.inflightRequests.delete(t), this.requestsOlderThanRestart.delete(t), this.inflightActionsCount--, n.status.status === "Completed") throw Error("Action should never be in 'Completed' state");
954
- n.status.onResult({
955
- success: !1,
956
- errorMessage: "Connection lost while action was in flight",
957
- logLines: []
958
- });
959
- }
960
- }
961
- return this.markConnectionStateDirty(), e;
962
- }
963
- resume() {
964
- let e = [];
965
- for (let [, t] of this.inflightRequests) if (t.status.status === "NotSent") {
966
- t.status.status = "Requested", e.push(t.message);
967
- continue;
968
- }
969
- return e;
970
- }
971
- hasIncompleteRequests() {
972
- for (let e of this.inflightRequests.values()) if (e.status.status === "Requested") return !0;
973
- return !1;
974
- }
975
- hasInflightRequests() {
976
- return this.inflightRequests.size > 0;
977
- }
978
- hasSyncedPastLastReconnect() {
979
- return this.requestsOlderThanRestart.size === 0;
980
- }
981
- timeOfOldestInflightRequest() {
982
- if (this.inflightRequests.size === 0) return null;
983
- let e = Date.now();
984
- for (let t of this.inflightRequests.values()) t.status.status !== "Completed" && t.status.requestedAt.getTime() < e && (e = t.status.requestedAt.getTime());
985
- return new Date(e);
986
- }
987
- inflightMutations() {
988
- return this.inflightMutationsCount;
989
- }
990
- inflightActions() {
991
- return this.inflightActionsCount;
992
- }
993
- }, Wt = Symbol.for("functionName"), Gt = Symbol.for("toReferencePath");
994
- function Kt(e) {
995
- return e[Gt] ?? null;
996
- }
997
- function qt(e) {
998
- return e.startsWith("function://");
999
- }
1000
- function Jt(e) {
1001
- let t;
1002
- if (typeof e == "string") t = qt(e) ? { functionHandle: e } : { name: e };
1003
- else if (e[Wt]) t = { name: e[Wt] };
1004
- else {
1005
- let n = Kt(e);
1006
- if (!n) throw Error(`${e} is not a functionReference`);
1007
- t = { reference: n };
1008
- }
1009
- return t;
1010
- }
1011
- //#endregion
1012
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/server/api.js
1013
- function G(e) {
1014
- let t = Jt(e);
1015
- if (t.name === void 0) throw t.functionHandle === void 0 ? t.reference === void 0 ? Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(t)}`) : Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${t.reference}`) : Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${t.functionHandle}`);
1016
- if (typeof e == "string") return e;
1017
- let n = e[Wt];
1018
- if (!n) throw Error(`${e} is not a functionReference`);
1019
- return n;
1020
- }
1021
- function Yt(e) {
1022
- return { [Wt]: e };
1023
- }
1024
- function Xt(e = []) {
1025
- return new Proxy({}, { get(t, n) {
1026
- if (typeof n == "string") return Xt([...e, n]);
1027
- if (n === Wt) {
1028
- if (e.length < 2) {
1029
- let t = ["api", ...e].join(".");
1030
- throw Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${t}\``);
1031
- }
1032
- let t = e.slice(0, -1).join("/"), n = e[e.length - 1];
1033
- return n === "default" ? t : t + ":" + n;
1034
- } else if (n === Symbol.toStringTag) return "FunctionReference";
1035
- else return;
1036
- } });
1037
- }
1038
- Xt();
1039
- //#endregion
1040
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/optimistic_updates_impl.js
1041
- var Zt = Object.defineProperty, Qt = (e, t, n) => t in e ? Zt(e, t, {
1042
- enumerable: !0,
1043
- configurable: !0,
1044
- writable: !0,
1045
- value: n
1046
- }) : e[t] = n, $t = (e, t, n) => Qt(e, typeof t == "symbol" ? t : t + "", n), en = class e {
1047
- constructor(e) {
1048
- $t(this, "queryResults"), $t(this, "modifiedQueries"), this.queryResults = e, this.modifiedQueries = [];
1049
- }
1050
- getQuery(t, ...n) {
1051
- let r = U(n[0]), i = G(t), a = this.queryResults.get(Pt(i, r));
1052
- if (a !== void 0) return e.queryValue(a.result);
1053
- }
1054
- getAllQueries(t) {
1055
- let n = [], r = G(t);
1056
- for (let t of this.queryResults.values()) t.udfPath === Nt(r) && n.push({
1057
- args: t.args,
1058
- value: e.queryValue(t.result)
1059
- });
1060
- return n;
1061
- }
1062
- setQuery(e, t, n) {
1063
- let r = U(t), i = G(e), a = Pt(i, r), o;
1064
- o = n === void 0 ? void 0 : {
1065
- success: !0,
1066
- value: n,
1067
- logLines: []
1068
- };
1069
- let s = {
1070
- udfPath: i,
1071
- args: r,
1072
- result: o
1073
- };
1074
- this.queryResults.set(a, s), this.modifiedQueries.push(a);
1075
- }
1076
- static queryValue(e) {
1077
- if (e !== void 0 && e.success) return e.value;
1078
- }
1079
- }, tn = class {
1080
- constructor() {
1081
- $t(this, "queryResults"), $t(this, "optimisticUpdates"), this.queryResults = /* @__PURE__ */ new Map(), this.optimisticUpdates = [];
1082
- }
1083
- ingestQueryResultsFromServer(e, t) {
1084
- this.optimisticUpdates = this.optimisticUpdates.filter((e) => !t.has(e.mutationId));
1085
- let n = this.queryResults;
1086
- this.queryResults = new Map(e);
1087
- let r = new en(this.queryResults);
1088
- for (let e of this.optimisticUpdates) e.update(r);
1089
- let i = [];
1090
- for (let [e, t] of this.queryResults) {
1091
- let r = n.get(e);
1092
- (r === void 0 || r.result !== t.result) && i.push(e);
1093
- }
1094
- return i;
1095
- }
1096
- applyOptimisticUpdate(e, t) {
1097
- this.optimisticUpdates.push({
1098
- update: e,
1099
- mutationId: t
1100
- });
1101
- let n = new en(this.queryResults);
1102
- return e(n), n.modifiedQueries;
1103
- }
1104
- rawQueryResult(e) {
1105
- let t = this.queryResults.get(e);
1106
- if (t !== void 0) return t.result;
1107
- }
1108
- queryResult(e) {
1109
- let t = this.queryResults.get(e);
1110
- if (t === void 0) return;
1111
- let n = t.result;
1112
- if (n !== void 0) {
1113
- if (n.success) return n.value;
1114
- throw n.errorData === void 0 ? Error(jt("query", t.udfPath, n)) : Mt(n, new bt(jt("query", t.udfPath, n)));
1115
- }
1116
- }
1117
- hasQueryResult(e) {
1118
- return this.queryResults.get(e) !== void 0;
1119
- }
1120
- queryLogs(e) {
1121
- return this.queryResults.get(e)?.result?.logLines;
1122
- }
1123
- }, nn = Object.defineProperty, rn = (e, t, n) => t in e ? nn(e, t, {
1124
- enumerable: !0,
1125
- configurable: !0,
1126
- writable: !0,
1127
- value: n
1128
- }) : e[t] = n, an = (e, t, n) => rn(e, typeof t == "symbol" ? t : t + "", n), on = class e {
1129
- constructor(e, t) {
1130
- an(this, "low"), an(this, "high"), an(this, "__isUnsignedLong__"), this.low = e | 0, this.high = t | 0, this.__isUnsignedLong__ = !0;
1131
- }
1132
- static isLong(e) {
1133
- return (e && e.__isUnsignedLong__) === !0;
1134
- }
1135
- static fromBytesLE(t) {
1136
- return new e(t[0] | t[1] << 8 | t[2] << 16 | t[3] << 24, t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24);
1137
- }
1138
- toBytesLE() {
1139
- let e = this.high, t = this.low;
1140
- return [
1141
- t & 255,
1142
- t >>> 8 & 255,
1143
- t >>> 16 & 255,
1144
- t >>> 24,
1145
- e & 255,
1146
- e >>> 8 & 255,
1147
- e >>> 16 & 255,
1148
- e >>> 24
1149
- ];
1150
- }
1151
- static fromNumber(t) {
1152
- return isNaN(t) || t < 0 ? sn : t >= un ? dn : new e(t % ln | 0, t / ln | 0);
1153
- }
1154
- toString() {
1155
- return (BigInt(this.high) * BigInt(ln) + BigInt(this.low)).toString();
1156
- }
1157
- equals(t) {
1158
- return e.isLong(t) || (t = e.fromValue(t)), this.high >>> 31 == 1 && t.high >>> 31 == 1 ? !1 : this.high === t.high && this.low === t.low;
1159
- }
1160
- notEquals(e) {
1161
- return !this.equals(e);
1162
- }
1163
- comp(t) {
1164
- return e.isLong(t) || (t = e.fromValue(t)), this.equals(t) ? 0 : t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1;
1165
- }
1166
- lessThanOrEqual(e) {
1167
- return this.comp(e) <= 0;
1168
- }
1169
- static fromValue(t) {
1170
- return typeof t == "number" ? e.fromNumber(t) : new e(t.low, t.high);
1171
- }
1172
- }, sn = new on(0, 0), cn = 65536, ln = cn * cn, un = ln * ln, dn = new on(-1, -1), fn = Object.defineProperty, pn = (e, t, n) => t in e ? fn(e, t, {
1173
- enumerable: !0,
1174
- configurable: !0,
1175
- writable: !0,
1176
- value: n
1177
- }) : e[t] = n, mn = (e, t, n) => pn(e, typeof t == "symbol" ? t : t + "", n), hn = class {
1178
- constructor(e, t) {
1179
- mn(this, "version"), mn(this, "remoteQuerySet"), mn(this, "queryPath"), mn(this, "logger"), this.version = {
1180
- querySet: 0,
1181
- ts: on.fromNumber(0),
1182
- identity: 0
1183
- }, this.remoteQuerySet = /* @__PURE__ */ new Map(), this.queryPath = e, this.logger = t;
1184
- }
1185
- transition(e) {
1186
- let t = e.startVersion;
1187
- if (this.version.querySet !== t.querySet || this.version.ts.notEquals(t.ts) || this.version.identity !== t.identity) throw Error(`Invalid start version: ${t.ts.toString()}:${t.querySet}:${t.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);
1188
- for (let t of e.modifications) switch (t.type) {
1189
- case "QueryUpdated": {
1190
- let e = this.queryPath(t.queryId);
1191
- if (e) for (let n of t.logLines) kt(this.logger, "info", "query", e, n);
1192
- let n = st(t.value ?? null);
1193
- this.remoteQuerySet.set(t.queryId, {
1194
- success: !0,
1195
- value: n,
1196
- logLines: t.logLines
1197
- });
1198
- break;
1199
- }
1200
- case "QueryFailed": {
1201
- let e = this.queryPath(t.queryId);
1202
- if (e) for (let n of t.logLines) kt(this.logger, "info", "query", e, n);
1203
- let { errorData: n } = t;
1204
- this.remoteQuerySet.set(t.queryId, {
1205
- success: !1,
1206
- errorMessage: t.errorMessage,
1207
- errorData: n === void 0 ? void 0 : st(n),
1208
- logLines: t.logLines
1209
- });
1210
- break;
1211
- }
1212
- case "QueryRemoved":
1213
- this.remoteQuerySet.delete(t.queryId);
1214
- break;
1215
- default: throw Error(`Invalid modification ${t.type}`);
1216
- }
1217
- this.version = e.endVersion;
1218
- }
1219
- remoteQueryResults() {
1220
- return this.remoteQuerySet;
1221
- }
1222
- timestamp() {
1223
- return this.version.ts;
1224
- }
1225
- };
1226
- //#endregion
1227
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/protocol.js
1228
- function gn(e) {
1229
- let t = Be(e);
1230
- return on.fromBytesLE(Array.from(t));
1231
- }
1232
- function _n(e) {
1233
- return Ue(new Uint8Array(e.toBytesLE()));
1234
- }
1235
- function vn(e) {
1236
- switch (e.type) {
1237
- case "FatalError":
1238
- case "AuthError":
1239
- case "ActionResponse":
1240
- case "TransitionChunk":
1241
- case "Ping": return { ...e };
1242
- case "MutationResponse": return e.success ? {
1243
- ...e,
1244
- ts: gn(e.ts)
1245
- } : { ...e };
1246
- case "Transition": return {
1247
- ...e,
1248
- startVersion: {
1249
- ...e.startVersion,
1250
- ts: gn(e.startVersion.ts)
1251
- },
1252
- endVersion: {
1253
- ...e.endVersion,
1254
- ts: gn(e.endVersion.ts)
1255
- }
1256
- };
1257
- default:
1258
- }
1259
- }
1260
- function yn(e) {
1261
- switch (e.type) {
1262
- case "Authenticate":
1263
- case "ModifyQuerySet":
1264
- case "Mutation":
1265
- case "Action":
1266
- case "Event": return { ...e };
1267
- case "Connect": return e.maxObservedTimestamp === void 0 ? {
1268
- ...e,
1269
- maxObservedTimestamp: void 0
1270
- } : {
1271
- ...e,
1272
- maxObservedTimestamp: _n(e.maxObservedTimestamp)
1273
- };
1274
- default:
1275
- }
1276
- }
1277
- //#endregion
1278
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/web_socket_manager.js
1279
- var bn = Object.defineProperty, xn = (e, t, n) => t in e ? bn(e, t, {
1280
- enumerable: !0,
1281
- configurable: !0,
1282
- writable: !0,
1283
- value: n
1284
- }) : e[t] = n, K = (e, t, n) => xn(e, typeof t == "symbol" ? t : t + "", n), Sn = 1e3, Cn = 1001, wn = 1005, Tn = 4040, En;
1285
- function Dn() {
1286
- return En === void 0 && (En = Date.now()), typeof performance > "u" || !performance.now ? Date.now() : Math.round(En + performance.now());
1287
- }
1288
- function On() {
1289
- return `t=${Math.round((Dn() - En) / 100) / 10}s`;
1290
- }
1291
- var kn = {
1292
- InternalServerError: { timeout: 1e3 },
1293
- SubscriptionsWorkerFullError: { timeout: 3e3 },
1294
- TooManyConcurrentRequests: { timeout: 3e3 },
1295
- CommitterFullError: { timeout: 3e3 },
1296
- AwsTooManyRequestsException: { timeout: 3e3 },
1297
- ExecuteFullError: { timeout: 3e3 },
1298
- SystemTimeoutError: { timeout: 3e3 },
1299
- ExpiredInQueue: { timeout: 3e3 },
1300
- VectorIndexesUnavailable: { timeout: 1e3 },
1301
- SearchIndexesUnavailable: { timeout: 1e3 },
1302
- TableSummariesUnavailable: { timeout: 1e3 },
1303
- VectorIndexTooLarge: { timeout: 3e3 },
1304
- SearchIndexTooLarge: { timeout: 3e3 },
1305
- TooManyWritesInTimePeriod: { timeout: 3e3 }
1306
- };
1307
- function An(e) {
1308
- if (e === void 0) return "Unknown";
1309
- for (let t of Object.keys(kn)) if (e.startsWith(t)) return t;
1310
- return "Unknown";
1311
- }
1312
- var jn = class {
1313
- constructor(e, t, n, r, i, a) {
1314
- this.markConnectionStateDirty = i, this.debug = a, K(this, "socket"), K(this, "connectionCount"), K(this, "_hasEverConnected", !1), K(this, "lastCloseReason"), K(this, "transitionChunkBuffer", null), K(this, "defaultInitialBackoff"), K(this, "maxBackoff"), K(this, "retries"), K(this, "serverInactivityThreshold"), K(this, "reconnectDueToServerInactivityTimeout"), K(this, "scheduledReconnect", null), K(this, "networkOnlineHandler", null), K(this, "pendingNetworkRecoveryInfo", null), K(this, "uri"), K(this, "onOpen"), K(this, "onResume"), K(this, "onMessage"), K(this, "webSocketConstructor"), K(this, "logger"), K(this, "onServerDisconnectError"), this.webSocketConstructor = n, this.socket = { state: "disconnected" }, this.connectionCount = 0, this.lastCloseReason = "InitialConnect", this.defaultInitialBackoff = 1e3, this.maxBackoff = 16e3, this.retries = 0, this.serverInactivityThreshold = 6e4, this.reconnectDueToServerInactivityTimeout = null, this.uri = e, this.onOpen = t.onOpen, this.onResume = t.onResume, this.onMessage = t.onMessage, this.onServerDisconnectError = t.onServerDisconnectError, this.logger = r, this.setupNetworkListener(), this.connect();
1315
- }
1316
- setSocketState(e) {
1317
- this.socket = e, this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}`), this.markConnectionStateDirty();
1318
- }
1319
- setupNetworkListener() {
1320
- typeof window > "u" || typeof window.addEventListener != "function" || this.networkOnlineHandler === null && (this.networkOnlineHandler = () => {
1321
- this._logVerbose("network online event detected"), this.tryReconnectImmediately();
1322
- }, window.addEventListener("online", this.networkOnlineHandler), this._logVerbose("network online event listener registered"));
1323
- }
1324
- cleanupNetworkListener() {
1325
- this.networkOnlineHandler && typeof window < "u" && typeof window.removeEventListener == "function" && (window.removeEventListener("online", this.networkOnlineHandler), this.networkOnlineHandler = null, this._logVerbose("network online event listener removed"));
1326
- }
1327
- assembleTransition(e) {
1328
- if (e.partNumber < 0 || e.partNumber >= e.totalParts || e.totalParts === 0 || this.transitionChunkBuffer && (this.transitionChunkBuffer.totalParts !== e.totalParts || this.transitionChunkBuffer.transitionId !== e.transitionId)) throw this.transitionChunkBuffer = null, Error("Invalid TransitionChunk");
1329
- if (this.transitionChunkBuffer === null && (this.transitionChunkBuffer = {
1330
- chunks: [],
1331
- totalParts: e.totalParts,
1332
- transitionId: e.transitionId
1333
- }), e.partNumber !== this.transitionChunkBuffer.chunks.length) {
1334
- let t = this.transitionChunkBuffer.chunks.length;
1335
- throw this.transitionChunkBuffer = null, Error(`TransitionChunk received out of order: expected part ${t}, got ${e.partNumber}`);
1336
- }
1337
- if (this.transitionChunkBuffer.chunks.push(e.chunk), this.transitionChunkBuffer.chunks.length === e.totalParts) {
1338
- let e = this.transitionChunkBuffer.chunks.join("");
1339
- this.transitionChunkBuffer = null;
1340
- let t = vn(JSON.parse(e));
1341
- if (t.type !== "Transition") throw Error(`Expected Transition, got ${t.type} after assembling chunks`);
1342
- return t;
1343
- }
1344
- return null;
1345
- }
1346
- connect() {
1347
- if (this.socket.state === "terminated") return;
1348
- if (this.socket.state !== "disconnected" && this.socket.state !== "stopped") throw Error("Didn't start connection from disconnected state: " + this.socket.state);
1349
- let e = new this.webSocketConstructor(this.uri);
1350
- this._logVerbose("constructed WebSocket"), this.setSocketState({
1351
- state: "connecting",
1352
- ws: e,
1353
- paused: "no"
1354
- }), this.resetServerInactivityTimeout(), e.onopen = () => {
1355
- if (this.logger.logVerbose("begin ws.onopen"), this.socket.state !== "connecting") throw Error("onopen called with socket not in connecting state");
1356
- if (this.setSocketState({
1357
- state: "ready",
1358
- ws: e,
1359
- paused: this.socket.paused === "yes" ? "uninitialized" : "no"
1360
- }), this.resetServerInactivityTimeout(), this.socket.paused === "no" && (this._hasEverConnected = !0, this.onOpen({
1361
- connectionCount: this.connectionCount,
1362
- lastCloseReason: this.lastCloseReason,
1363
- clientTs: Dn()
1364
- })), this.lastCloseReason !== "InitialConnect" && (this.lastCloseReason ? this.logger.log("WebSocket reconnected at", On(), "after disconnect due to", this.lastCloseReason) : this.logger.log("WebSocket reconnected at", On())), this.connectionCount += 1, this.lastCloseReason = null, this.pendingNetworkRecoveryInfo !== null) {
1365
- let { timeSavedMs: e } = this.pendingNetworkRecoveryInfo;
1366
- this.pendingNetworkRecoveryInfo = null, this.sendMessage({
1367
- type: "Event",
1368
- eventType: "NetworkRecoveryReconnect",
1369
- event: { timeSavedMs: e }
1370
- }), this.logger.log(`Network recovery reconnect saved ~${Math.round(e / 1e3)}s of waiting`);
1371
- }
1372
- }, e.onerror = (e) => {
1373
- this.transitionChunkBuffer = null;
1374
- let t = e.message;
1375
- t && this.logger.log(`WebSocket error message: ${t}`);
1376
- }, e.onmessage = (e) => {
1377
- this.resetServerInactivityTimeout();
1378
- let t = e.data.length, n = vn(JSON.parse(e.data));
1379
- if (this._logVerbose(`received ws message with type ${n.type}`), n.type !== "Ping") {
1380
- if (n.type === "TransitionChunk") {
1381
- let e = this.assembleTransition(n);
1382
- if (!e) return;
1383
- n = e, this._logVerbose(`assembled full ws message of type ${n.type}`);
1384
- }
1385
- this.transitionChunkBuffer !== null && (this.transitionChunkBuffer = null, this.logger.log(`Received unexpected ${n.type} while buffering TransitionChunks`)), n.type === "Transition" && this.reportLargeTransition({
1386
- messageLength: t,
1387
- transition: n
1388
- }), this.onMessage(n).hasSyncedPastLastReconnect && (this.retries = 0, this.markConnectionStateDirty());
1389
- }
1390
- }, e.onclose = (e) => {
1391
- if (this._logVerbose("begin ws.onclose"), this.transitionChunkBuffer = null, this.lastCloseReason === null && (this.lastCloseReason = e.reason || `closed with code ${e.code}`), e.code !== Sn && e.code !== Cn && e.code !== wn && e.code !== Tn) {
1392
- let t = `WebSocket closed with code ${e.code}`;
1393
- e.reason && (t += `: ${e.reason}`), this.logger.log(t), this.onServerDisconnectError && e.reason && this.onServerDisconnectError(t);
1394
- }
1395
- let t = An(e.reason);
1396
- this.scheduleReconnect(t);
1397
- };
1398
- }
1399
- socketState() {
1400
- return this.socket.state;
1401
- }
1402
- sendMessage(e) {
1403
- let t = {
1404
- type: e.type,
1405
- ...e.type === "Authenticate" && e.tokenType === "User" ? { value: `...${e.value.slice(-7)}` } : {}
1406
- };
1407
- if (this.socket.state === "ready" && this.socket.paused === "no") {
1408
- let n = yn(e), r = JSON.stringify(n), i = !1;
1409
- try {
1410
- this.socket.ws.send(r), i = !0;
1411
- } catch (e) {
1412
- this.logger.log(`Failed to send message on WebSocket, reconnecting: ${e}`), this.closeAndReconnect("FailedToSendMessage");
1413
- }
1414
- return this._logVerbose(`${i ? "sent" : "failed to send"} message with type ${e.type}: ${JSON.stringify(t)}`), !0;
1415
- }
1416
- return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused" in this.socket ? this.socket.paused : void 0}): ${JSON.stringify(t)}`), !1;
1417
- }
1418
- resetServerInactivityTimeout() {
1419
- this.socket.state !== "terminated" && (this.reconnectDueToServerInactivityTimeout !== null && (clearTimeout(this.reconnectDueToServerInactivityTimeout), this.reconnectDueToServerInactivityTimeout = null), this.reconnectDueToServerInactivityTimeout = setTimeout(() => {
1420
- this.closeAndReconnect("InactiveServer");
1421
- }, this.serverInactivityThreshold));
1422
- }
1423
- scheduleReconnect(e) {
1424
- this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.socket = { state: "disconnected" };
1425
- let t = this.nextBackoff(e);
1426
- this.markConnectionStateDirty(), this.logger.log(`Attempting reconnect in ${Math.round(t)}ms`);
1427
- let n = Dn(), r = setTimeout(() => {
1428
- this.scheduledReconnect?.timeout === r && (this.scheduledReconnect = null, this.connect());
1429
- }, t);
1430
- this.scheduledReconnect = {
1431
- timeout: r,
1432
- scheduledAt: n,
1433
- backoffMs: t
1434
- };
1435
- }
1436
- closeAndReconnect(e) {
1437
- switch (this._logVerbose(`begin closeAndReconnect with reason ${e}`), this.socket.state) {
1438
- case "disconnected":
1439
- case "terminated":
1440
- case "stopped": return;
1441
- case "connecting":
1442
- case "ready":
1443
- this.lastCloseReason = e, this.close(), this.scheduleReconnect("client");
1444
- return;
1445
- default: this.socket;
1446
- }
1447
- }
1448
- close() {
1449
- switch (this.transitionChunkBuffer = null, this.socket.state) {
1450
- case "disconnected":
1451
- case "terminated":
1452
- case "stopped": return Promise.resolve();
1453
- case "connecting": {
1454
- let e = this.socket.ws;
1455
- return e.onmessage = (e) => {
1456
- this._logVerbose("Ignoring message received after close");
1457
- }, new Promise((t) => {
1458
- e.onclose = () => {
1459
- this._logVerbose("Closed after connecting"), t();
1460
- }, e.onopen = () => {
1461
- this._logVerbose("Opened after connecting"), e.close();
1462
- };
1463
- });
1464
- }
1465
- case "ready": {
1466
- this._logVerbose("ws.close called");
1467
- let e = this.socket.ws;
1468
- e.onmessage = (e) => {
1469
- this._logVerbose("Ignoring message received after close");
1470
- };
1471
- let t = new Promise((t) => {
1472
- e.onclose = () => {
1473
- t();
1474
- };
1475
- });
1476
- return e.close(), t;
1477
- }
1478
- default: return this.socket, Promise.resolve();
1479
- }
1480
- }
1481
- terminate() {
1482
- switch (this.reconnectDueToServerInactivityTimeout && clearTimeout(this.reconnectDueToServerInactivityTimeout), this.scheduledReconnect &&= (clearTimeout(this.scheduledReconnect.timeout), null), this.cleanupNetworkListener(), this.socket.state) {
1483
- case "terminated":
1484
- case "stopped":
1485
- case "disconnected":
1486
- case "connecting":
1487
- case "ready": {
1488
- let e = this.close();
1489
- return this.setSocketState({ state: "terminated" }), e;
1490
- }
1491
- default: throw this.socket, Error(`Invalid websocket state: ${this.socket.state}`);
1492
- }
1493
- }
1494
- stop() {
1495
- switch (this.socket.state) {
1496
- case "terminated": return Promise.resolve();
1497
- case "connecting":
1498
- case "stopped":
1499
- case "disconnected":
1500
- case "ready": {
1501
- this.cleanupNetworkListener();
1502
- let e = this.close();
1503
- return this.socket = { state: "stopped" }, e;
1504
- }
1505
- default: return this.socket, Promise.resolve();
1506
- }
1507
- }
1508
- tryRestart() {
1509
- switch (this.socket.state) {
1510
- case "stopped": break;
1511
- case "terminated":
1512
- case "connecting":
1513
- case "ready":
1514
- case "disconnected":
1515
- this.logger.logVerbose("Restart called without stopping first");
1516
- return;
1517
- default: this.socket;
1518
- }
1519
- this.setupNetworkListener(), this.connect();
1520
- }
1521
- pause() {
1522
- switch (this.socket.state) {
1523
- case "disconnected":
1524
- case "stopped":
1525
- case "terminated": return;
1526
- case "connecting":
1527
- case "ready":
1528
- this.socket = {
1529
- ...this.socket,
1530
- paused: "yes"
1531
- };
1532
- return;
1533
- default:
1534
- this.socket;
1535
- return;
1536
- }
1537
- }
1538
- tryReconnectImmediately() {
1539
- if (this._logVerbose("tryReconnectImmediately called"), this.socket.state !== "disconnected") {
1540
- this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);
1541
- return;
1542
- }
1543
- let e = null;
1544
- if (this.scheduledReconnect) {
1545
- let t = Dn() - this.scheduledReconnect.scheduledAt;
1546
- e = Math.max(0, this.scheduledReconnect.backoffMs - t), this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(t)}ms)`), clearTimeout(this.scheduledReconnect.timeout), this.scheduledReconnect = null, this._logVerbose("canceled scheduled reconnect");
1547
- }
1548
- this.logger.log("Network recovery detected, reconnecting immediately"), this.pendingNetworkRecoveryInfo = e === null ? null : { timeSavedMs: e }, this.connect();
1549
- }
1550
- resume() {
1551
- switch (this.socket.state) {
1552
- case "connecting":
1553
- this.socket = {
1554
- ...this.socket,
1555
- paused: "no"
1556
- };
1557
- return;
1558
- case "ready":
1559
- this.socket.paused === "uninitialized" ? (this.socket = {
1560
- ...this.socket,
1561
- paused: "no"
1562
- }, this._hasEverConnected = !0, this.onOpen({
1563
- connectionCount: this.connectionCount,
1564
- lastCloseReason: this.lastCloseReason,
1565
- clientTs: Dn()
1566
- })) : this.socket.paused === "yes" && (this.socket = {
1567
- ...this.socket,
1568
- paused: "no"
1569
- }, this.onResume());
1570
- return;
1571
- case "terminated":
1572
- case "stopped":
1573
- case "disconnected": return;
1574
- default: this.socket;
1575
- }
1576
- this.connect();
1577
- }
1578
- connectionState() {
1579
- return {
1580
- isConnected: this.socket.state === "ready",
1581
- hasEverConnected: this._hasEverConnected,
1582
- connectionCount: this.connectionCount,
1583
- connectionRetries: this.retries
1584
- };
1585
- }
1586
- _logVerbose(e) {
1587
- this.logger.logVerbose(e);
1588
- }
1589
- nextBackoff(e) {
1590
- let t = (e === "client" ? 100 : e === "Unknown" ? this.defaultInitialBackoff : kn[e].timeout) * 2 ** this.retries;
1591
- this.retries += 1;
1592
- let n = Math.min(t, this.maxBackoff);
1593
- return n + n * (Math.random() - .5);
1594
- }
1595
- reportLargeTransition({ transition: e, messageLength: t }) {
1596
- if (e.clientClockSkew === void 0 || e.serverTs === void 0) return;
1597
- let n = Dn() - e.clientClockSkew - e.serverTs / 1e6, r = `${Math.round(n)}ms`, i = `${Math.round(t / 1e4) / 100}MB`, a = t / (n / 1e3), o = `${Math.round(a / 1e4) / 100}MB per second`;
1598
- this._logVerbose(`received ${i} transition in ${r} at ${o}`), t > 2e7 ? this.logger.log(`received query results totaling more that 20MB (${i}) which will take a long time to download on slower connections`) : n > 2e4 && this.logger.log(`received query results totaling ${i} which took more than 20s to arrive (${r})`), this.debug && this.sendMessage({
1599
- type: "Event",
1600
- eventType: "ClientReceivedTransition",
1601
- event: {
1602
- transitionTransitTime: n,
1603
- messageLength: t
1604
- }
1605
- });
1606
- }
1607
- };
1608
- //#endregion
1609
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/session.js
1610
- function Mn() {
1611
- return Nn();
1612
- }
1613
- function Nn() {
1614
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
1615
- let t = Math.random() * 16 | 0;
1616
- return (e === "x" ? t : t & 3 | 8).toString(16);
1617
- });
1618
- }
1619
- //#endregion
1620
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/vendor/jwt-decode/index.js
1621
- var Pn = class extends Error {};
1622
- Pn.prototype.name = "InvalidTokenError";
1623
- function Fn(e) {
1624
- return decodeURIComponent(atob(e).replace(/(.)/g, (e, t) => {
1625
- let n = t.charCodeAt(0).toString(16).toUpperCase();
1626
- return n.length < 2 && (n = "0" + n), "%" + n;
1627
- }));
1628
- }
1629
- function In(e) {
1630
- let t = e.replace(/-/g, "+").replace(/_/g, "/");
1631
- switch (t.length % 4) {
1632
- case 0: break;
1633
- case 2:
1634
- t += "==";
1635
- break;
1636
- case 3:
1637
- t += "=";
1638
- break;
1639
- default: throw Error("base64 string is not of the correct length");
1640
- }
1641
- try {
1642
- return Fn(t);
1643
- } catch {
1644
- return atob(t);
1645
- }
1646
- }
1647
- function Ln(e, t) {
1648
- if (typeof e != "string") throw new Pn("Invalid token specified: must be a string");
1649
- t ||= {};
1650
- let n = t.header === !0 ? 0 : 1, r = e.split(".")[n];
1651
- if (typeof r != "string") throw new Pn(`Invalid token specified: missing part #${n + 1}`);
1652
- let i;
1653
- try {
1654
- i = In(r);
1655
- } catch (e) {
1656
- throw new Pn(`Invalid token specified: invalid base64 for part #${n + 1} (${e.message})`);
1657
- }
1658
- try {
1659
- return JSON.parse(i);
1660
- } catch (e) {
1661
- throw new Pn(`Invalid token specified: invalid json for part #${n + 1} (${e.message})`);
1662
- }
1663
- }
1664
- //#endregion
1665
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/authentication_manager.js
1666
- var Rn = Object.defineProperty, zn = (e, t, n) => t in e ? Rn(e, t, {
1667
- enumerable: !0,
1668
- configurable: !0,
1669
- writable: !0,
1670
- value: n
1671
- }) : e[t] = n, q = (e, t, n) => zn(e, typeof t == "symbol" ? t : t + "", n), Bn = 480 * 60 * 60 * 1e3, Vn = 2, Hn = class {
1672
- constructor(e, t, n) {
1673
- q(this, "authState", { state: "noAuth" }), q(this, "configVersion", 0), q(this, "syncState"), q(this, "authenticate"), q(this, "stopSocket"), q(this, "tryRestartSocket"), q(this, "pauseSocket"), q(this, "resumeSocket"), q(this, "clearAuth"), q(this, "logger"), q(this, "refreshTokenLeewaySeconds"), q(this, "tokenConfirmationAttempts", 0), this.syncState = e, this.authenticate = t.authenticate, this.stopSocket = t.stopSocket, this.tryRestartSocket = t.tryRestartSocket, this.pauseSocket = t.pauseSocket, this.resumeSocket = t.resumeSocket, this.clearAuth = t.clearAuth, this.logger = n.logger, this.refreshTokenLeewaySeconds = n.refreshTokenLeewaySeconds;
1674
- }
1675
- async setConfig(e, t) {
1676
- this.resetAuthState(), this._logVerbose("pausing WS for auth token fetch"), this.pauseSocket();
1677
- let n = await this.fetchTokenAndGuardAgainstRace(e, { forceRefreshToken: !1 });
1678
- n.isFromOutdatedConfig || (n.value ? (this.setAuthState({
1679
- state: "waitingForServerConfirmationOfCachedToken",
1680
- config: {
1681
- fetchToken: e,
1682
- onAuthChange: t
1683
- },
1684
- hasRetried: !1
1685
- }), this.authenticate(n.value)) : (this.setAuthState({
1686
- state: "initialRefetch",
1687
- config: {
1688
- fetchToken: e,
1689
- onAuthChange: t
1690
- }
1691
- }), await this.refetchToken()), this._logVerbose("resuming WS after auth token fetch"), this.resumeSocket());
1692
- }
1693
- onTransition(e) {
1694
- if (this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity) && !(e.endVersion.identity <= e.startVersion.identity)) {
1695
- if (this._logVerbose(`auth state is ${this.authState.state} when handling transition`), this.syncState.markAuthCompletion(), this.authState.state === "waitingForServerConfirmationOfCachedToken") {
1696
- this._logVerbose("server confirmed auth token is valid"), this.refetchToken(), this.authState.config.onAuthChange(!0);
1697
- return;
1698
- }
1699
- this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this._logVerbose("server confirmed new auth token is valid"), this.scheduleTokenRefetch(this.authState.token), this.tokenConfirmationAttempts = 0, this.authState.hadAuth || this.authState.config.onAuthChange(!0));
1700
- }
1701
- }
1702
- onAuthError(e) {
1703
- if (e.authUpdateAttempted === !1 && (this.authState.state === "waitingForServerConfirmationOfFreshToken" || this.authState.state === "waitingForServerConfirmationOfCachedToken")) {
1704
- this._logVerbose("ignoring non-auth token expired error");
1705
- return;
1706
- }
1707
- let { baseVersion: t } = e;
1708
- if (!this.syncState.isCurrentOrNewerAuthVersion(t + 1)) {
1709
- this._logVerbose("ignoring auth error for previous auth attempt");
1710
- return;
1711
- }
1712
- this.tryToReauthenticate(e);
1713
- }
1714
- async tryToReauthenticate(e) {
1715
- if (this._logVerbose(`attempting to reauthenticate: ${e.error}`), this.authState.state === "noAuth" || this.authState.state === "waitingForServerConfirmationOfFreshToken" && this.tokenConfirmationAttempts >= Vn) {
1716
- this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`), this.syncState.hasAuth() && this.syncState.clearAuth(), this.authState.state !== "noAuth" && this.setAndReportAuthFailed(this.authState.config.onAuthChange);
1717
- return;
1718
- }
1719
- this.authState.state === "waitingForServerConfirmationOfFreshToken" && (this.tokenConfirmationAttempts++, this._logVerbose(`retrying reauthentication, ${Vn - this.tokenConfirmationAttempts} attempts remaining`)), await this.stopSocket();
1720
- let t = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1721
- t.isFromOutdatedConfig || (t.value && this.syncState.isNewAuth(t.value) ? (this.authenticate(t.value), this.setAuthState({
1722
- state: "waitingForServerConfirmationOfFreshToken",
1723
- config: this.authState.config,
1724
- token: t.value,
1725
- hadAuth: this.authState.state === "notRefetching" || this.authState.state === "waitingForScheduledRefetch"
1726
- })) : (this._logVerbose("reauthentication failed, could not fetch a new token"), this.syncState.hasAuth() && this.syncState.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this.tryRestartSocket());
1727
- }
1728
- async refetchToken() {
1729
- if (this.authState.state === "noAuth") return;
1730
- this._logVerbose("refetching auth token");
1731
- let e = await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken, { forceRefreshToken: !0 });
1732
- e.isFromOutdatedConfig || (e.value ? this.syncState.isNewAuth(e.value) ? (this.setAuthState({
1733
- state: "waitingForServerConfirmationOfFreshToken",
1734
- hadAuth: this.syncState.hasAuth(),
1735
- token: e.value,
1736
- config: this.authState.config
1737
- }), this.authenticate(e.value)) : this.setAuthState({
1738
- state: "notRefetching",
1739
- config: this.authState.config
1740
- }) : (this._logVerbose("refetching token failed"), this.syncState.hasAuth() && this.clearAuth(), this.setAndReportAuthFailed(this.authState.config.onAuthChange)), this._logVerbose("restarting WS after auth token fetch (if currently stopped)"), this.tryRestartSocket());
1741
- }
1742
- scheduleTokenRefetch(e) {
1743
- if (this.authState.state === "noAuth") return;
1744
- let t = this.decodeToken(e);
1745
- if (!t) {
1746
- this.logger.error("Auth token is not a valid JWT, cannot refetch the token");
1747
- return;
1748
- }
1749
- let { iat: n, exp: r } = t;
1750
- if (!n || !r) {
1751
- this.logger.error("Auth token does not have required fields, cannot refetch the token");
1752
- return;
1753
- }
1754
- let i = r - n;
1755
- if (i <= 2) {
1756
- this.logger.error("Auth token does not live long enough, cannot refetch the token");
1757
- return;
1758
- }
1759
- let a = Math.min(Bn, (i - this.refreshTokenLeewaySeconds) * 1e3);
1760
- a <= 0 && (this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${i}s`), a = 0);
1761
- let o = setTimeout(() => {
1762
- this._logVerbose("running scheduled token refetch"), this.refetchToken();
1763
- }, a);
1764
- this.setAuthState({
1765
- state: "waitingForScheduledRefetch",
1766
- refetchTokenTimeoutId: o,
1767
- config: this.authState.config
1768
- }), this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`);
1769
- }
1770
- async fetchTokenAndGuardAgainstRace(e, t) {
1771
- let n = ++this.configVersion;
1772
- this._logVerbose(`fetching token with config version ${n}`);
1773
- let r = await e(t);
1774
- return this.configVersion === n ? {
1775
- isFromOutdatedConfig: !1,
1776
- value: r
1777
- } : (this._logVerbose(`stale config version, expected ${n}, got ${this.configVersion}`), { isFromOutdatedConfig: !0 });
1778
- }
1779
- stop() {
1780
- this.resetAuthState(), this.configVersion++, this._logVerbose(`config version bumped to ${this.configVersion}`);
1781
- }
1782
- setAndReportAuthFailed(e) {
1783
- e(!1), this.resetAuthState();
1784
- }
1785
- resetAuthState() {
1786
- this.setAuthState({ state: "noAuth" });
1787
- }
1788
- setAuthState(e) {
1789
- let t = e.state === "waitingForServerConfirmationOfFreshToken" ? {
1790
- hadAuth: e.hadAuth,
1791
- state: e.state,
1792
- token: `...${e.token.slice(-7)}`
1793
- } : { state: e.state };
1794
- switch (this._logVerbose(`setting auth state to ${JSON.stringify(t)}`), e.state) {
1795
- case "waitingForScheduledRefetch":
1796
- case "notRefetching":
1797
- case "noAuth":
1798
- this.tokenConfirmationAttempts = 0;
1799
- break;
1800
- case "waitingForServerConfirmationOfFreshToken":
1801
- case "waitingForServerConfirmationOfCachedToken":
1802
- case "initialRefetch": break;
1803
- default:
1804
- }
1805
- this.authState.state === "waitingForScheduledRefetch" && clearTimeout(this.authState.refetchTokenTimeoutId), this.authState = e;
1806
- }
1807
- decodeToken(e) {
1808
- try {
1809
- return Ln(e);
1810
- } catch (e) {
1811
- return this._logVerbose(`Error decoding token: ${e instanceof Error ? e.message : "Unknown error"}`), null;
1812
- }
1813
- }
1814
- _logVerbose(e) {
1815
- this.logger.logVerbose(`${e} [v${this.configVersion}]`);
1816
- }
1817
- }, Un = [
1818
- "convexClientConstructed",
1819
- "convexWebSocketOpen",
1820
- "convexFirstMessageReceived"
1821
- ];
1822
- function Wn(e, t) {
1823
- let n = { sessionId: t };
1824
- typeof performance > "u" || !performance.mark || performance.mark(e, { detail: n });
1825
- }
1826
- function Gn(e) {
1827
- let t = e.name.slice(6);
1828
- return t = t.charAt(0).toLowerCase() + t.slice(1), {
1829
- name: t,
1830
- startTime: e.startTime
1831
- };
1832
- }
1833
- function Kn(e) {
1834
- if (typeof performance > "u" || !performance.getEntriesByName) return [];
1835
- let t = [];
1836
- for (let n of Un) {
1837
- let r = performance.getEntriesByName(n).filter((e) => e.entryType === "mark").filter((t) => t.detail.sessionId === e);
1838
- t.push(...r);
1839
- }
1840
- return t.map(Gn);
1841
- }
1842
- //#endregion
1843
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/client.js
1844
- var qn = Object.defineProperty, Jn = (e, t, n) => t in e ? qn(e, t, {
1845
- enumerable: !0,
1846
- configurable: !0,
1847
- writable: !0,
1848
- value: n
1849
- }) : e[t] = n, J = (e, t, n) => Jn(e, typeof t == "symbol" ? t : t + "", n), Yn = class {
1850
- constructor(e, t, n) {
1851
- if (J(this, "address"), J(this, "state"), J(this, "requestManager"), J(this, "webSocketManager"), J(this, "authenticationManager"), J(this, "remoteQuerySet"), J(this, "optimisticQueryResults"), J(this, "_transitionHandlerCounter", 0), J(this, "_nextRequestId"), J(this, "_onTransitionFns", /* @__PURE__ */ new Map()), J(this, "_sessionId"), J(this, "firstMessageReceived", !1), J(this, "debug"), J(this, "logger"), J(this, "maxObservedTimestamp"), J(this, "connectionStateSubscribers", /* @__PURE__ */ new Map()), J(this, "nextConnectionStateSubscriberId", 0), J(this, "_lastPublishedConnectionState"), J(this, "markConnectionStateDirty", () => {
1852
- Promise.resolve().then(() => {
1853
- let e = this.connectionState();
1854
- if (JSON.stringify(e) !== JSON.stringify(this._lastPublishedConnectionState)) {
1855
- this._lastPublishedConnectionState = e;
1856
- for (let t of this.connectionStateSubscribers.values()) t(e);
1857
- }
1858
- });
1859
- }), J(this, "mark", (e) => {
1860
- this.debug && Wn(e, this.sessionId);
1861
- }), typeof e == "object") throw Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");
1862
- n?.skipConvexDeploymentUrlCheck !== !0 && We(e), n = { ...n };
1863
- let r = n.authRefreshTokenLeewaySeconds ?? 10, i = n.webSocketConstructor;
1864
- if (!i && typeof WebSocket > "u") throw Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");
1865
- i ||= WebSocket, this.debug = n.reportDebugInfoToConvex ?? !1, this.address = e, this.logger = n.logger === !1 ? Ot({ verbose: n.verbose ?? !1 }) : n.logger !== !0 && n.logger ? n.logger : Dt({ verbose: n.verbose ?? !1 });
1866
- let a = e.search("://");
1867
- if (a === -1) throw Error("Provided address was not an absolute URL.");
1868
- let o = e.substring(a + 3), s = e.substring(0, a), c;
1869
- if (s === "http") c = "ws";
1870
- else if (s === "https") c = "wss";
1871
- else throw Error(`Unknown parent protocol ${s}`);
1872
- let l = `${c}://${o}/api/${Ne}/sync`;
1873
- this.state = new zt(), this.remoteQuerySet = new hn((e) => this.state.queryPath(e), this.logger), this.requestManager = new Ut(this.logger, this.markConnectionStateDirty);
1874
- let u = () => {
1875
- this.webSocketManager.pause(), this.state.pause();
1876
- };
1877
- this.authenticationManager = new Hn(this.state, {
1878
- authenticate: (e) => {
1879
- let t = this.state.setAuth(e);
1880
- return this.webSocketManager.sendMessage(t), t.baseVersion;
1881
- },
1882
- stopSocket: () => this.webSocketManager.stop(),
1883
- tryRestartSocket: () => this.webSocketManager.tryRestart(),
1884
- pauseSocket: u,
1885
- resumeSocket: () => this.webSocketManager.resume(),
1886
- clearAuth: () => {
1887
- this.clearAuth();
1888
- }
1889
- }, {
1890
- logger: this.logger,
1891
- refreshTokenLeewaySeconds: r
1892
- }), this.optimisticQueryResults = new tn(), this.addOnTransitionHandler((e) => {
1893
- t(e.queries.map((e) => e.token));
1894
- }), this._nextRequestId = 0, this._sessionId = Mn();
1895
- let { unsavedChangesWarning: d } = n;
1896
- if (typeof window > "u" || window.addEventListener === void 0) {
1897
- if (d === !0) throw Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.");
1898
- } else d !== !1 && window.addEventListener("beforeunload", (e) => {
1899
- if (this.requestManager.hasIncompleteRequests()) {
1900
- e.preventDefault();
1901
- let t = "Are you sure you want to leave? Your changes may not be saved.";
1902
- return (e || window.event).returnValue = t, t;
1903
- }
1904
- });
1905
- this.webSocketManager = new jn(l, {
1906
- onOpen: (e) => {
1907
- this.mark("convexWebSocketOpen"), this.webSocketManager.sendMessage({
1908
- ...e,
1909
- type: "Connect",
1910
- sessionId: this._sessionId,
1911
- maxObservedTimestamp: this.maxObservedTimestamp
1912
- }), this.remoteQuerySet = new hn((e) => this.state.queryPath(e), this.logger);
1913
- let [t, n] = this.state.restart();
1914
- n && this.webSocketManager.sendMessage(n), this.webSocketManager.sendMessage(t);
1915
- for (let e of this.requestManager.restart()) this.webSocketManager.sendMessage(e);
1916
- },
1917
- onResume: () => {
1918
- let [e, t] = this.state.resume();
1919
- t && this.webSocketManager.sendMessage(t), e && this.webSocketManager.sendMessage(e);
1920
- for (let e of this.requestManager.resume()) this.webSocketManager.sendMessage(e);
1921
- },
1922
- onMessage: (e) => {
1923
- switch (this.firstMessageReceived || (this.firstMessageReceived = !0, this.mark("convexFirstMessageReceived"), this.reportMarks()), e.type) {
1924
- case "Transition": {
1925
- this.observedTimestamp(e.endVersion.ts), this.authenticationManager.onTransition(e), this.remoteQuerySet.transition(e), this.state.transition(e);
1926
- let t = this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());
1927
- this.notifyOnQueryResultChanges(t);
1928
- break;
1929
- }
1930
- case "MutationResponse": {
1931
- e.success && this.observedTimestamp(e.ts);
1932
- let t = this.requestManager.onResponse(e);
1933
- t !== null && this.notifyOnQueryResultChanges(/* @__PURE__ */ new Map([[t.requestId, t.result]]));
1934
- break;
1935
- }
1936
- case "ActionResponse":
1937
- this.requestManager.onResponse(e);
1938
- break;
1939
- case "AuthError":
1940
- this.authenticationManager.onAuthError(e);
1941
- break;
1942
- case "FatalError": {
1943
- let t = At(this.logger, e.error);
1944
- throw this.webSocketManager.terminate(), t;
1945
- }
1946
- default:
1947
- }
1948
- return { hasSyncedPastLastReconnect: this.hasSyncedPastLastReconnect() };
1949
- },
1950
- onServerDisconnectError: n.onServerDisconnectError
1951
- }, i, this.logger, this.markConnectionStateDirty, this.debug), this.mark("convexClientConstructed"), n.expectAuth && u();
1952
- }
1953
- hasSyncedPastLastReconnect() {
1954
- return this.requestManager.hasSyncedPastLastReconnect() && this.state.hasSyncedPastLastReconnect();
1955
- }
1956
- observedTimestamp(e) {
1957
- (this.maxObservedTimestamp === void 0 || this.maxObservedTimestamp.lessThanOrEqual(e)) && (this.maxObservedTimestamp = e);
1958
- }
1959
- getMaxObservedTimestamp() {
1960
- return this.maxObservedTimestamp;
1961
- }
1962
- notifyOnQueryResultChanges(e) {
1963
- let t = this.remoteQuerySet.remoteQueryResults(), n = /* @__PURE__ */ new Map();
1964
- for (let [e, r] of t) {
1965
- let t = this.state.queryToken(e);
1966
- if (t !== null) {
1967
- let i = {
1968
- result: r,
1969
- udfPath: this.state.queryPath(e),
1970
- args: this.state.queryArgs(e)
1971
- };
1972
- n.set(t, i);
1973
- }
1974
- }
1975
- let r = this.optimisticQueryResults.ingestQueryResultsFromServer(n, new Set(e.keys()));
1976
- this.handleTransition({
1977
- queries: r.map((e) => ({
1978
- token: e,
1979
- modification: {
1980
- kind: "Updated",
1981
- result: this.optimisticQueryResults.rawQueryResult(e)
1982
- }
1983
- })),
1984
- reflectedMutations: Array.from(e).map(([e, t]) => ({
1985
- requestId: e,
1986
- result: t
1987
- })),
1988
- timestamp: this.remoteQuerySet.timestamp()
1989
- });
1990
- }
1991
- handleTransition(e) {
1992
- for (let t of this._onTransitionFns.values()) t(e);
1993
- }
1994
- addOnTransitionHandler(e) {
1995
- let t = this._transitionHandlerCounter++;
1996
- return this._onTransitionFns.set(t, e), () => this._onTransitionFns.delete(t);
1997
- }
1998
- getCurrentAuthClaims() {
1999
- let e = this.state.getAuth(), t = {};
2000
- if (e && e.tokenType === "User") try {
2001
- t = e ? Ln(e.value) : {};
2002
- } catch {
2003
- t = {};
2004
- }
2005
- else return;
2006
- return {
2007
- token: e.value,
2008
- decoded: t
2009
- };
2010
- }
2011
- setAuth(e, t) {
2012
- this.authenticationManager.setConfig(e, t);
2013
- }
2014
- hasAuth() {
2015
- return this.state.hasAuth();
2016
- }
2017
- setAdminAuth(e, t) {
2018
- let n = this.state.setAdminAuth(e, t);
2019
- this.webSocketManager.sendMessage(n);
2020
- }
2021
- clearAuth() {
2022
- let e = this.state.clearAuth();
2023
- this.webSocketManager.sendMessage(e);
2024
- }
2025
- subscribe(e, t, n) {
2026
- let r = U(t), { modification: i, queryToken: a, unsubscribe: o } = this.state.subscribe(e, r, n?.journal, n?.componentPath);
2027
- return i !== null && this.webSocketManager.sendMessage(i), {
2028
- queryToken: a,
2029
- unsubscribe: () => {
2030
- let e = o();
2031
- e && this.webSocketManager.sendMessage(e);
2032
- }
2033
- };
2034
- }
2035
- localQueryResult(e, t) {
2036
- let n = Pt(e, U(t));
2037
- return this.optimisticQueryResults.queryResult(n);
2038
- }
2039
- localQueryResultByToken(e) {
2040
- return this.optimisticQueryResults.queryResult(e);
2041
- }
2042
- hasLocalQueryResultByToken(e) {
2043
- return this.optimisticQueryResults.hasQueryResult(e);
2044
- }
2045
- localQueryLogs(e, t) {
2046
- let n = Pt(e, U(t));
2047
- return this.optimisticQueryResults.queryLogs(n);
2048
- }
2049
- queryJournal(e, t) {
2050
- let n = Pt(e, U(t));
2051
- return this.state.queryJournal(n);
2052
- }
2053
- connectionState() {
2054
- let e = this.webSocketManager.connectionState();
2055
- return {
2056
- hasInflightRequests: this.requestManager.hasInflightRequests(),
2057
- isWebSocketConnected: e.isConnected,
2058
- hasEverConnected: e.hasEverConnected,
2059
- connectionCount: e.connectionCount,
2060
- connectionRetries: e.connectionRetries,
2061
- timeOfOldestInflightRequest: this.requestManager.timeOfOldestInflightRequest(),
2062
- inflightMutations: this.requestManager.inflightMutations(),
2063
- inflightActions: this.requestManager.inflightActions()
2064
- };
2065
- }
2066
- subscribeToConnectionState(e) {
2067
- let t = this.nextConnectionStateSubscriberId++;
2068
- return this.connectionStateSubscribers.set(t, e), () => {
2069
- this.connectionStateSubscribers.delete(t);
2070
- };
2071
- }
2072
- async mutation(e, t, n) {
2073
- let r = await this.mutationInternal(e, t, n);
2074
- if (!r.success) throw r.errorData === void 0 ? Error(jt("mutation", e, r)) : Mt(r, new bt(jt("mutation", e, r)));
2075
- return r.value;
2076
- }
2077
- async mutationInternal(e, t, n, r) {
2078
- let { mutationPromise: i } = this.enqueueMutation(e, t, n, r);
2079
- return i;
2080
- }
2081
- enqueueMutation(e, t, n, r) {
2082
- let i = U(t);
2083
- this.tryReportLongDisconnect();
2084
- let a = this.nextRequestId;
2085
- if (this._nextRequestId++, n !== void 0) {
2086
- let e = n.optimisticUpdate;
2087
- if (e !== void 0) {
2088
- let t = this.optimisticQueryResults.applyOptimisticUpdate((t) => {
2089
- e(t, i) instanceof Promise && this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.");
2090
- }, a).map((e) => {
2091
- let t = this.localQueryResultByToken(e);
2092
- return {
2093
- token: e,
2094
- modification: {
2095
- kind: "Updated",
2096
- result: t === void 0 ? void 0 : {
2097
- success: !0,
2098
- value: t,
2099
- logLines: []
2100
- }
2101
- }
2102
- };
2103
- });
2104
- this.handleTransition({
2105
- queries: t,
2106
- reflectedMutations: [],
2107
- timestamp: this.remoteQuerySet.timestamp()
2108
- });
2109
- }
2110
- }
2111
- let o = {
2112
- type: "Mutation",
2113
- requestId: a,
2114
- udfPath: e,
2115
- componentPath: r,
2116
- args: [pt(i)]
2117
- }, s = this.webSocketManager.sendMessage(o);
2118
- return {
2119
- requestId: a,
2120
- mutationPromise: this.requestManager.request(o, s)
2121
- };
2122
- }
2123
- async action(e, t) {
2124
- let n = await this.actionInternal(e, t);
2125
- if (!n.success) throw n.errorData === void 0 ? Error(jt("action", e, n)) : Mt(n, new bt(jt("action", e, n)));
2126
- return n.value;
2127
- }
2128
- async actionInternal(e, t, n) {
2129
- let r = U(t), i = this.nextRequestId;
2130
- this._nextRequestId++, this.tryReportLongDisconnect();
2131
- let a = {
2132
- type: "Action",
2133
- requestId: i,
2134
- udfPath: e,
2135
- componentPath: n,
2136
- args: [pt(r)]
2137
- }, o = this.webSocketManager.sendMessage(a);
2138
- return this.requestManager.request(a, o);
2139
- }
2140
- async close() {
2141
- return this.authenticationManager.stop(), this.webSocketManager.terminate();
2142
- }
2143
- get url() {
2144
- return this.address;
2145
- }
2146
- get nextRequestId() {
2147
- return this._nextRequestId;
2148
- }
2149
- get sessionId() {
2150
- return this._sessionId;
2151
- }
2152
- reportMarks() {
2153
- if (this.debug) {
2154
- let e = Kn(this.sessionId);
2155
- this.webSocketManager.sendMessage({
2156
- type: "Event",
2157
- eventType: "ClientConnect",
2158
- event: e
2159
- });
2160
- }
2161
- }
2162
- tryReportLongDisconnect() {
2163
- if (!this.debug) return;
2164
- let e = this.connectionState().timeOfOldestInflightRequest;
2165
- if (e === null || Date.now() - e.getTime() <= 60 * 1e3) return;
2166
- let t = `${this.address}/api/debug_event`;
2167
- fetch(t, {
2168
- method: "POST",
2169
- headers: {
2170
- "Content-Type": "application/json",
2171
- "Convex-Client": `npm-${Ne}`
2172
- },
2173
- body: JSON.stringify({ event: "LongWebsocketDisconnect" })
2174
- }).then((e) => {
2175
- e.ok || this.logger.warn("Analytics request failed with response:", e.body);
2176
- }).catch((e) => {
2177
- this.logger.warn("Analytics response failed with error:", e);
2178
- });
2179
- }
2180
- };
2181
- //#endregion
2182
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/pagination.js
2183
- function Xn(e) {
2184
- if (typeof e != "object" || !e || !Array.isArray(e.page) || typeof e.isDone != "boolean" || typeof e.continueCursor != "string") throw Error(`Not a valid paginated query result: ${e?.toString()}`);
2185
- return e;
2186
- }
2187
- //#endregion
2188
- //#region ../../node_modules/.pnpm/convex@1.37.0_react@19.2.6/node_modules/convex/dist/esm/browser/sync/paginated_query_client.js
2189
- var Zn = Object.defineProperty, Qn = (e, t, n) => t in e ? Zn(e, t, {
2190
- enumerable: !0,
2191
- configurable: !0,
2192
- writable: !0,
2193
- value: n
2194
- }) : e[t] = n, $n = (e, t, n) => Qn(e, typeof t == "symbol" ? t : t + "", n), er = class {
2195
- constructor(e, t) {
2196
- this.client = e, this.onTransition = t, $n(this, "paginatedQuerySet", /* @__PURE__ */ new Map()), $n(this, "lastTransitionTs"), this.lastTransitionTs = on.fromNumber(0), this.client.addOnTransitionHandler((e) => this.onBaseTransition(e));
2197
- }
2198
- subscribe(e, t, n) {
2199
- let r = Nt(e), i = Ft(r, t, n), a = () => this.removePaginatedQuerySubscriber(i), o = this.paginatedQuerySet.get(i);
2200
- return o ? (o.numSubscribers += 1, {
2201
- paginatedQueryToken: i,
2202
- unsubscribe: a
2203
- }) : (this.paginatedQuerySet.set(i, {
2204
- token: i,
2205
- canonicalizedUdfPath: r,
2206
- args: t,
2207
- numSubscribers: 1,
2208
- options: { initialNumItems: n.initialNumItems },
2209
- nextPageKey: 0,
2210
- pageKeys: [],
2211
- pageKeyToQuery: /* @__PURE__ */ new Map(),
2212
- ongoingSplits: /* @__PURE__ */ new Map(),
2213
- skip: !1,
2214
- id: n.id
2215
- }), this.addPageToPaginatedQuery(i, null, n.initialNumItems), {
2216
- paginatedQueryToken: i,
2217
- unsubscribe: a
2218
- });
2219
- }
2220
- localQueryResult(e, t, n) {
2221
- let r = Ft(Nt(e), t, n);
2222
- return this.localQueryResultByToken(r);
2223
- }
2224
- localQueryResultByToken(e) {
2225
- let t = this.paginatedQuerySet.get(e);
2226
- if (!t) return;
2227
- let n = this.activePageQueryTokens(t);
2228
- if (n.length === 0) return {
2229
- results: [],
2230
- status: "LoadingFirstPage",
2231
- loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2232
- };
2233
- let r = [], i = !1, a = !1;
2234
- for (let e of n) {
2235
- let t = this.client.localQueryResultByToken(e);
2236
- if (t === void 0) {
2237
- i = !0, a = !1;
2238
- continue;
2239
- }
2240
- let n = Xn(t);
2241
- r = r.concat(n.page), a = !!n.isDone;
2242
- }
2243
- let o;
2244
- return o = i ? r.length === 0 ? "LoadingFirstPage" : "LoadingMore" : a ? "Exhausted" : "CanLoadMore", {
2245
- results: r,
2246
- status: o,
2247
- loadMore: (t) => this.loadMoreOfPaginatedQuery(e, t)
2248
- };
2249
- }
2250
- onBaseTransition(e) {
2251
- let t = e.queries.map((e) => e.token), n = this.queriesContainingTokens(t), r = [];
2252
- n.length > 0 && (this.processPaginatedQuerySplits(n, (e) => this.client.localQueryResultByToken(e)), r = n.map((e) => ({
2253
- token: e,
2254
- modification: {
2255
- kind: "Updated",
2256
- result: this.localQueryResultByToken(e)
2257
- }
2258
- })));
2259
- let i = {
2260
- ...e,
2261
- paginatedQueries: r
2262
- };
2263
- this.onTransition(i);
2264
- }
2265
- loadMoreOfPaginatedQuery(e, t) {
2266
- this.mustGetPaginatedQuery(e);
2267
- let n = this.queryTokenForLastPageOfPaginatedQuery(e), r = this.client.localQueryResultByToken(n);
2268
- if (!r) return !1;
2269
- let i = Xn(r);
2270
- if (i.isDone) return !1;
2271
- this.addPageToPaginatedQuery(e, i.continueCursor, t);
2272
- let a = {
2273
- timestamp: this.lastTransitionTs,
2274
- reflectedMutations: [],
2275
- queries: [],
2276
- paginatedQueries: [{
2277
- token: e,
2278
- modification: {
2279
- kind: "Updated",
2280
- result: this.localQueryResultByToken(e)
2281
- }
2282
- }]
2283
- };
2284
- return this.onTransition(a), !0;
2285
- }
2286
- queriesContainingTokens(e) {
2287
- if (e.length === 0) return [];
2288
- let t = [], n = new Set(e);
2289
- for (let [e, r] of this.paginatedQuerySet) for (let i of this.allQueryTokens(r)) if (n.has(i)) {
2290
- t.push(e);
2291
- break;
2292
- }
2293
- return t;
2294
- }
2295
- processPaginatedQuerySplits(e, t) {
2296
- for (let n of e) {
2297
- let e = this.mustGetPaginatedQuery(n), { ongoingSplits: r, pageKeyToQuery: i, pageKeys: a } = e;
2298
- for (let [n, [a, o]] of r) t(i.get(a).queryToken) !== void 0 && t(i.get(o).queryToken) !== void 0 && this.completePaginatedQuerySplit(e, n, a, o);
2299
- for (let n of a) {
2300
- if (r.has(n)) continue;
2301
- let a = i.get(n).queryToken, o = t(a);
2302
- if (!o) continue;
2303
- let s = Xn(o);
2304
- s.splitCursor && (s.pageStatus === "SplitRecommended" || s.pageStatus === "SplitRequired" || s.page.length > e.options.initialNumItems * 2) && this.splitPaginatedQueryPage(e, n, s.splitCursor, s.continueCursor);
2305
- }
2306
- }
2307
- }
2308
- splitPaginatedQueryPage(e, t, n, r) {
2309
- let i = e.nextPageKey++, a = e.nextPageKey++, o = {
2310
- cursor: r,
2311
- numItems: e.options.initialNumItems,
2312
- id: e.id
2313
- }, s = this.client.subscribe(e.canonicalizedUdfPath, {
2314
- ...e.args,
2315
- paginationOpts: {
2316
- ...o,
2317
- cursor: null,
2318
- endCursor: n
2319
- }
2320
- });
2321
- e.pageKeyToQuery.set(i, s);
2322
- let c = this.client.subscribe(e.canonicalizedUdfPath, {
2323
- ...e.args,
2324
- paginationOpts: {
2325
- ...o,
2326
- cursor: n,
2327
- endCursor: r
2328
- }
2329
- });
2330
- e.pageKeyToQuery.set(a, c), e.ongoingSplits.set(t, [i, a]);
2331
- }
2332
- addPageToPaginatedQuery(e, t, n) {
2333
- let r = this.mustGetPaginatedQuery(e), i = r.nextPageKey++, a = {
2334
- cursor: t,
2335
- numItems: n,
2336
- id: r.id
2337
- }, o = {
2338
- ...r.args,
2339
- paginationOpts: a
2340
- }, s = this.client.subscribe(r.canonicalizedUdfPath, o);
2341
- return r.pageKeys.push(i), r.pageKeyToQuery.set(i, s), s;
2342
- }
2343
- removePaginatedQuerySubscriber(e) {
2344
- let t = this.paginatedQuerySet.get(e);
2345
- if (t && (--t.numSubscribers, !(t.numSubscribers > 0))) {
2346
- for (let e of t.pageKeyToQuery.values()) e.unsubscribe();
2347
- this.paginatedQuerySet.delete(e);
2348
- }
2349
- }
2350
- completePaginatedQuerySplit(e, t, n, r) {
2351
- let i = e.pageKeyToQuery.get(t);
2352
- e.pageKeyToQuery.delete(t);
2353
- let a = e.pageKeys.indexOf(t);
2354
- e.pageKeys.splice(a, 1, n, r), e.ongoingSplits.delete(t), i.unsubscribe();
2355
- }
2356
- activePageQueryTokens(e) {
2357
- return e.pageKeys.map((t) => e.pageKeyToQuery.get(t).queryToken);
2358
- }
2359
- allQueryTokens(e) {
2360
- return Array.from(e.pageKeyToQuery.values()).map((e) => e.queryToken);
2361
- }
2362
- queryTokenForLastPageOfPaginatedQuery(e) {
2363
- let t = this.mustGetPaginatedQuery(e), n = t.pageKeys[t.pageKeys.length - 1];
2364
- if (n === void 0) throw Error(`No pages for paginated query ${e}`);
2365
- return t.pageKeyToQuery.get(n).queryToken;
2366
- }
2367
- mustGetPaginatedQuery(e) {
2368
- let t = this.paginatedQuerySet.get(e);
2369
- if (!t) throw Error("paginated query no longer exists for token " + e);
2370
- return t;
2371
- }
2372
- }, tr = Object.defineProperty, nr = (e, t, n) => t in e ? tr(e, t, {
2373
- enumerable: !0,
2374
- configurable: !0,
2375
- writable: !0,
2376
- value: n
2377
- }) : e[t] = n, rr = (e, t, n) => nr(e, typeof t == "symbol" ? t : t + "", n), ir, ar = class {
2378
- constructor(e, t = {}) {
2379
- rr(this, "listeners"), rr(this, "_client"), rr(this, "_paginatedClient"), rr(this, "callNewListenersWithCurrentValuesTimer"), rr(this, "_closed"), rr(this, "_disabled"), t.skipConvexDeploymentUrlCheck !== !0 && We(e);
2380
- let { disabled: n, ...r } = t;
2381
- this._closed = !1, this._disabled = !!n, ir && !("webSocketConstructor" in r) && typeof WebSocket > "u" && (r.webSocketConstructor = ir), typeof window > "u" && !("unsavedChangesWarning" in r) && (r.unsavedChangesWarning = !1), this.disabled || (this._client = new Yn(e, () => {}, r), this._paginatedClient = new er(this._client, (e) => this._transition(e))), this.listeners = /* @__PURE__ */ new Set();
2382
- }
2383
- get closed() {
2384
- return this._closed;
2385
- }
2386
- get client() {
2387
- if (this._client) return this._client;
2388
- throw Error("ConvexClient is disabled");
2389
- }
2390
- get paginatedClient() {
2391
- if (this._paginatedClient) return this._paginatedClient;
2392
- throw Error("ConvexClient is disabled");
2393
- }
2394
- get disabled() {
2395
- return this._disabled;
2396
- }
2397
- onUpdate(e, t, n, r) {
2398
- if (this.disabled) return this.createDisabledUnsubscribe();
2399
- let { queryToken: i, unsubscribe: a } = this.client.subscribe(G(e), t), o = {
2400
- queryToken: i,
2401
- callback: n,
2402
- onError: r,
2403
- unsubscribe: a,
2404
- hasEverRun: !1,
2405
- query: e,
2406
- args: t,
2407
- paginationOptions: void 0
2408
- };
2409
- this.listeners.add(o), this.queryResultReady(i) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2410
- let s = {
2411
- unsubscribe: () => {
2412
- this.closed || (this.listeners.delete(o), a());
2413
- },
2414
- getCurrentValue: () => this.client.localQueryResultByToken(i),
2415
- getQueryLogs: () => this.client.localQueryLogs(i)
2416
- }, c = s.unsubscribe;
2417
- return Object.assign(c, s), c;
2418
- }
2419
- onPaginatedUpdate_experimental(e, t, n, r, i) {
2420
- if (this.disabled) return this.createDisabledUnsubscribe();
2421
- let a = {
2422
- initialNumItems: n.initialNumItems,
2423
- id: -1
2424
- }, { paginatedQueryToken: o, unsubscribe: s } = this.paginatedClient.subscribe(G(e), t, a), c = {
2425
- queryToken: o,
2426
- callback: r,
2427
- onError: i,
2428
- unsubscribe: s,
2429
- hasEverRun: !1,
2430
- query: e,
2431
- args: t,
2432
- paginationOptions: a
2433
- };
2434
- this.listeners.add(c), this.paginatedClient.localQueryResultByToken(o) && this.callNewListenersWithCurrentValuesTimer === void 0 && (this.callNewListenersWithCurrentValuesTimer = setTimeout(() => this.callNewListenersWithCurrentValues(), 0));
2435
- let l = {
2436
- unsubscribe: () => {
2437
- this.closed || (this.listeners.delete(c), s());
2438
- },
2439
- getCurrentValue: () => this.paginatedClient.localQueryResult(G(e), t, a),
2440
- getQueryLogs: () => []
2441
- }, u = l.unsubscribe;
2442
- return Object.assign(u, l), u;
2443
- }
2444
- callNewListenersWithCurrentValues() {
2445
- this.callNewListenersWithCurrentValuesTimer = void 0, this._transition({
2446
- queries: [],
2447
- paginatedQueries: []
2448
- }, !0);
2449
- }
2450
- queryResultReady(e) {
2451
- return this.client.hasLocalQueryResultByToken(e);
2452
- }
2453
- createDisabledUnsubscribe() {
2454
- let e = (() => {});
2455
- return Object.assign(e, {
2456
- unsubscribe: e,
2457
- getCurrentValue: () => void 0,
2458
- getQueryLogs: () => void 0
2459
- }), e;
2460
- }
2461
- async close() {
2462
- if (!this.disabled) return this.listeners.clear(), this._closed = !0, this._paginatedClient &&= void 0, this.client.close();
2463
- }
2464
- getAuth() {
2465
- if (!this.disabled) return this.client.getCurrentAuthClaims();
2466
- }
2467
- setAuth(e, t) {
2468
- this.disabled || this.client.setAuth(e, t ?? (() => {}));
2469
- }
2470
- setAdminAuth(e, t) {
2471
- if (this.closed) throw Error("ConvexClient has already been closed.");
2472
- this.disabled || this.client.setAdminAuth(e, t);
2473
- }
2474
- _transition({ queries: e, paginatedQueries: t }, n = !1) {
2475
- let r = [...e.map((e) => e.token), ...t.map((e) => e.token)];
2476
- for (let e of this.listeners) {
2477
- let { callback: t, queryToken: i, onError: a, hasEverRun: o } = e, s = It(i), c = s ? !!this.paginatedClient.localQueryResultByToken(i) : this.client.hasLocalQueryResultByToken(i);
2478
- if (r.includes(i) || n && !o && c) {
2479
- e.hasEverRun = !0;
2480
- let n;
2481
- try {
2482
- n = s ? this.paginatedClient.localQueryResultByToken(i) : this.client.localQueryResultByToken(i);
2483
- } catch (e) {
2484
- if (!(e instanceof Error)) throw e;
2485
- a ? a(e, "Second argument to onUpdate onError is reserved for later use") : Promise.reject(e);
2486
- continue;
2487
- }
2488
- t(n, "Second argument to onUpdate callback is reserved for later use");
2489
- }
2490
- }
2491
- }
2492
- async mutation(e, t, n) {
2493
- if (this.disabled) throw Error("ConvexClient is disabled");
2494
- return await this.client.mutation(G(e), t, n);
2495
- }
2496
- async action(e, t) {
2497
- if (this.disabled) throw Error("ConvexClient is disabled");
2498
- return await this.client.action(G(e), t);
2499
- }
2500
- async query(e, t) {
2501
- if (this.disabled) throw Error("ConvexClient is disabled");
2502
- let n = this.client.localQueryResult(G(e), t);
2503
- return n === void 0 ? new Promise((n, r) => {
2504
- let { unsubscribe: i } = this.onUpdate(e, t, (e) => {
2505
- i(), n(e);
2506
- }, (e) => {
2507
- i(), r(e);
2508
- });
2509
- }) : Promise.resolve(n);
2510
- }
2511
- connectionState() {
2512
- if (this.disabled) throw Error("ConvexClient is disabled");
2513
- return this.client.connectionState();
2514
- }
2515
- subscribeToConnectionState(e) {
2516
- return this.disabled ? () => {} : this.client.subscribeToConnectionState(e);
2517
- }
2518
- }, or = new Set([
2519
- "role",
2520
- "name",
2521
- "aria-label",
2522
- "rel",
2523
- "href"
2524
- ]);
2525
- function sr(e, t) {
2526
- let n = or.has(e);
2527
- n ||= e.startsWith("data-") && pr(e);
2528
- let r = pr(t) && t.length < 100;
2529
- return r ||= t.startsWith("#") && pr(t.slice(1)), n && r;
2530
- }
2531
- function cr(e) {
2532
- return pr(e);
2533
- }
2534
- function lr(e) {
2535
- return pr(e);
2536
- }
2537
- function ur(e) {
2538
- return !0;
2539
- }
2540
- function dr(e, t) {
2541
- if (e.nodeType !== Node.ELEMENT_NODE) throw Error("Can't generate CSS selector for non-element node type.");
2542
- if (e.tagName.toLowerCase() === "html") return "html";
2543
- let n = {
2544
- root: document.body,
2545
- idName: cr,
2546
- className: lr,
2547
- tagName: ur,
2548
- attr: sr,
2549
- timeoutMs: 1e3,
2550
- seedMinLength: 3,
2551
- optimizedMinLength: 2,
2552
- maxNumberOfPathChecks: Infinity
2553
- }, r = /* @__PURE__ */ new Date(), i = {
2554
- ...n,
2555
- ...t
2556
- }, a = Cr(i.root, n), o, s = 0;
2557
- for (let t of fr(e, i, a)) {
2558
- if ((/* @__PURE__ */ new Date()).getTime() - r.getTime() > i.timeoutMs || s >= i.maxNumberOfPathChecks) {
2559
- let t = yr(e, a);
2560
- if (!t) throw Error(`Timeout: Can't find a unique selector after ${i.timeoutMs}ms`);
2561
- return hr(t);
2562
- }
2563
- if (s++, wr(t, a)) {
2564
- o = t;
2565
- break;
2566
- }
2567
- }
2568
- if (!o) throw Error("Selector was not found.");
2569
- let c = [...Tr(o, e, i, a, r)];
2570
- return c.sort(_r), c.length > 0 ? hr(c[0]) : hr(o);
2571
- }
2572
- function* fr(e, t, n) {
2573
- let r = [], i = [], a = e, o = 0;
2574
- for (; a && a !== n;) {
2575
- let e = mr(a, t);
2576
- for (let t of e) t.level = o;
2577
- if (r.push(e), a = a.parentElement, o++, i.push(...Sr(r)), o >= t.seedMinLength) {
2578
- i.sort(_r);
2579
- for (let e of i) yield e;
2580
- i = [];
2581
- }
2582
- }
2583
- i.sort(_r);
2584
- for (let e of i) yield e;
2585
- }
2586
- function pr(e) {
2587
- if (/^[a-z\-]{3,}$/i.test(e)) {
2588
- let t = e.split(/-|[A-Z]/);
2589
- for (let e of t) if (e.length <= 2 || /[^aeiou]{4,}/i.test(e)) return !1;
2590
- return !0;
2591
- }
2592
- return !1;
2593
- }
2594
- function mr(e, t) {
2595
- let n = [], r = e.getAttribute("id");
2596
- r && t.idName(r) && n.push({
2597
- name: "#" + CSS.escape(r),
2598
- penalty: 0
2599
- });
2600
- for (let r = 0; r < e.classList.length; r++) {
2601
- let i = e.classList[r];
2602
- t.className(i) && n.push({
2603
- name: "." + CSS.escape(i),
2604
- penalty: 1
2605
- });
2606
- }
2607
- for (let r = 0; r < e.attributes.length; r++) {
2608
- let i = e.attributes[r];
2609
- t.attr(i.name, i.value) && n.push({
2610
- name: `[${CSS.escape(i.name)}="${CSS.escape(i.value)}"]`,
2611
- penalty: 2
2612
- });
2613
- }
2614
- let i = e.tagName.toLowerCase();
2615
- if (t.tagName(i)) {
2616
- n.push({
2617
- name: i,
2618
- penalty: 5
2619
- });
2620
- let t = vr(e, i);
2621
- t !== void 0 && n.push({
2622
- name: xr(i, t),
2623
- penalty: 10
2624
- });
2625
- }
2626
- let a = vr(e);
2627
- return a !== void 0 && n.push({
2628
- name: br(i, a),
2629
- penalty: 50
2630
- }), n;
2631
- }
2632
- function hr(e) {
2633
- let t = e[0], n = t.name;
2634
- for (let r = 1; r < e.length; r++) {
2635
- let i = e[r].level || 0;
2636
- n = t.level === i - 1 ? `${e[r].name} > ${n}` : `${e[r].name} ${n}`, t = e[r];
2637
- }
2638
- return n;
2639
- }
2640
- function gr(e) {
2641
- return e.map((e) => e.penalty).reduce((e, t) => e + t, 0);
2642
- }
2643
- function _r(e, t) {
2644
- return gr(e) - gr(t);
2645
- }
2646
- function vr(e, t) {
2647
- let n = e.parentNode;
2648
- if (!n) return;
2649
- let r = n.firstChild;
2650
- if (!r) return;
2651
- let i = 0;
2652
- for (; r && (r.nodeType === Node.ELEMENT_NODE && (t === void 0 || r.tagName.toLowerCase() === t) && i++, r !== e);) r = r.nextSibling;
2653
- return i;
2654
- }
2655
- function yr(e, t) {
2656
- let n = 0, r = e, i = [];
2657
- for (; r && r !== t;) {
2658
- let e = r.tagName.toLowerCase(), t = vr(r, e);
2659
- if (t === void 0) return;
2660
- i.push({
2661
- name: xr(e, t),
2662
- penalty: NaN,
2663
- level: n
2664
- }), r = r.parentElement, n++;
2665
- }
2666
- if (wr(i, t)) return i;
2667
- }
2668
- function br(e, t) {
2669
- return e === "html" ? "html" : `${e}:nth-child(${t})`;
2670
- }
2671
- function xr(e, t) {
2672
- return e === "html" ? "html" : `${e}:nth-of-type(${t})`;
2673
- }
2674
- function* Sr(e, t = []) {
2675
- if (e.length > 0) for (let n of e[0]) yield* Sr(e.slice(1, e.length), t.concat(n));
2676
- else yield t;
2677
- }
2678
- function Cr(e, t) {
2679
- return e.nodeType === Node.DOCUMENT_NODE ? e : e === t.root ? e.ownerDocument : e;
2680
- }
2681
- function wr(e, t) {
2682
- let n = hr(e);
2683
- switch (t.querySelectorAll(n).length) {
2684
- case 0: throw Error(`Can't select any node with this selector: ${n}`);
2685
- case 1: return !0;
2686
- default: return !1;
2687
- }
2688
- }
2689
- function* Tr(e, t, n, r, i) {
2690
- if (e.length > 2 && e.length > n.optimizedMinLength) for (let a = 1; a < e.length - 1; a++) {
2691
- if ((/* @__PURE__ */ new Date()).getTime() - i.getTime() > n.timeoutMs) return;
2692
- let o = [...e];
2693
- o.splice(a, 1), wr(o, r) && r.querySelector(hr(o)) === t && (yield o, yield* Tr(o, t, n, r, i));
2694
- }
2695
- }
2696
- //#endregion
2697
- //#region src/runtime/anchor.ts
2698
- function Er(e, t) {
2699
- let n = document.documentElement, r = Math.max(n.scrollWidth, n.clientWidth), i = Math.max(n.scrollHeight, n.clientHeight), a = e.clientX + window.scrollX, o = e.clientY + window.scrollY, s = t === void 0 ? e.target instanceof Element ? e.target : null : t, c = s ? Or(s) : void 0, l, u;
2700
- if (s) {
2701
- let t = s.getBoundingClientRect();
2702
- t.width > 0 && t.height > 0 && (l = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)), u = Math.max(0, Math.min(1, (e.clientY - t.top) / t.height)));
2703
- }
2704
- return {
2705
- anchorX: r > 0 ? a / r : 0,
2706
- anchorY: i > 0 ? o / i : 0,
2707
- viewportW: window.innerWidth,
2708
- viewportY: window.scrollY,
2709
- anchorSelector: c,
2710
- anchorOffsetX: l,
2711
- anchorOffsetY: u
2712
- };
2713
- }
2714
- function Dr(e) {
2715
- if (e.anchorSelector) try {
2716
- let t = document.querySelector(e.anchorSelector);
2717
- if (t) {
2718
- let n = t.getBoundingClientRect();
2719
- return {
2720
- pageX: n.left + window.scrollX + (e.anchorOffsetX ?? .5) * n.width,
2721
- pageY: n.top + window.scrollY + (e.anchorOffsetY ?? .5) * n.height
2722
- };
2723
- }
2724
- } catch {}
2725
- let t = document.documentElement, n = Math.max(t.scrollWidth, t.clientWidth), r = Math.max(t.scrollHeight, t.clientHeight);
2726
- return {
2727
- pageX: e.anchorX * n,
2728
- pageY: e.anchorY * r
2729
- };
2730
- }
2731
- function Or(e) {
2732
- try {
2733
- return dr(e, { timeoutMs: 1e3 });
2734
- } catch {
2735
- return;
2736
- }
2737
- }
2738
- //#endregion
2739
- //#region src/runtime/api.ts
2740
- var kr = class extends Error {
2741
- status;
2742
- constructor(e, t) {
2743
- super(e), this.name = "WidgetApiError", this.status = t;
2744
- }
2745
- };
2746
- function Ar(e) {
2747
- let t = e.apiUrl.replace(/\/+$/, "");
2748
- async function n(n, r = {}) {
2749
- let i = {
2750
- "content-type": "application/json",
2751
- "x-markup-api-key": e.apiKey,
2752
- ...r.headers ?? {}
2753
- }, a = e.getToken?.() ?? null, o = a != null && a.token.length > 0 && a.expiresAt > Date.now();
2754
- o && a && (i.authorization = `Bearer ${a.token}`);
2755
- let s = e.getAnonToken?.() ?? null;
2756
- s && (i["x-markup-anon-token"] = s);
2757
- let c = await fetch(`${t}${n}`, {
2758
- ...r,
2759
- headers: i
2760
- }), l = await c.text(), u = l ? jr(l) : null;
2761
- if (!c.ok) throw c.status === 401 && o && e.onUnauthorized?.(), new kr((u && typeof u == "object" && "error" in u && typeof u.error == "string" ? u.error : null) ?? `Request failed with ${c.status}`, c.status);
2762
- return u;
2763
- }
2764
- return {
2765
- mintAnonIdentity() {
2766
- return n("/widget/anon-identity", { method: "POST" });
2767
- },
2768
- getSubscriptionToken() {
2769
- return n("/widget/subscription-token", { method: "POST" });
2770
- },
2771
- getScreenshotUploadUrl() {
2772
- return n("/widget/screenshots/upload-url", { method: "POST" });
2773
- },
2774
- listThreads(e) {
2775
- return n(`/widget/threads?route=${encodeURIComponent(e)}`, { method: "GET" });
2776
- },
2777
- createThread(e) {
2778
- return n("/widget/threads", {
2779
- method: "POST",
2780
- body: JSON.stringify(e)
2781
- });
2782
- },
2783
- deleteThread(e) {
2784
- return n(`/widget/threads/${encodeURIComponent(e)}`, { method: "DELETE" });
2785
- },
2786
- resolveThread(e, t) {
2787
- return n(`/widget/threads/${encodeURIComponent(e)}`, {
2788
- method: "PATCH",
2789
- body: JSON.stringify({ resolvedBy: t })
2790
- });
2791
- },
2792
- addComment(e, t) {
2793
- return n(`/widget/threads/${encodeURIComponent(e)}/comments`, {
2794
- method: "POST",
2795
- body: JSON.stringify(t)
2796
- });
2797
- },
2798
- editComment(e, t, r) {
2799
- return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2800
- method: "PATCH",
2801
- body: JSON.stringify(r)
2802
- });
2803
- },
2804
- deleteComment(e, t) {
2805
- return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, { method: "DELETE" });
2806
- },
2807
- toggleReaction(e, t) {
2808
- return n(`/widget/comments/${encodeURIComponent(e)}/reactions`, {
2809
- method: "POST",
2810
- body: JSON.stringify(t)
2811
- });
2812
- }
2813
- };
2814
- }
2815
- function jr(e) {
2816
- try {
2817
- return JSON.parse(e);
2818
- } catch {
2819
- return null;
2820
- }
2821
- }
2822
- //#endregion
2823
- //#region src/runtime/identity-store.ts
2824
- var Mr = "markup.identity";
2825
- function Nr() {
2826
- try {
2827
- let e = localStorage.getItem(Mr);
2828
- if (!e) return null;
2829
- let t = JSON.parse(e);
2830
- return typeof t?.clientId == "string" ? t : null;
2831
- } catch {
2832
- return null;
2833
- }
2834
- }
2835
- function Pr(e) {
2836
- try {
2837
- localStorage.setItem(Mr, JSON.stringify(e));
2838
- } catch {}
2839
- }
2840
- //#endregion
2841
- //#region src/runtime/popup-auth.ts
2842
- async function Fr(e, t) {
2843
- let n = new URL(e).origin, r;
2844
- try {
2845
- let n = await fetch(`${e.replace(/\/+$/, "")}/widget/popup-exchange`, {
2846
- method: "POST",
2847
- headers: {
2848
- "content-type": "application/json",
2849
- "x-markup-api-key": t
2850
- },
2851
- body: "{}"
2852
- });
2853
- if (!n.ok) throw Error(`popup-exchange responded with ${n.status}`);
2854
- let { code: i } = await n.json(), a = new URL("/widget/auth", e);
2855
- a.searchParams.set("code", i), r = a.toString();
2856
- } catch (e) {
2857
- return Promise.reject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to start popup exchange"));
2858
- }
2859
- let i = Math.max(0, window.screenX + (window.outerWidth - 420) / 2), a = Math.max(0, window.screenY + (window.outerHeight - 560) / 2), o = window.open(r, "markup-auth", `width=420,height=560,left=${i},top=${a}`);
2860
- return o ? new Promise((e, t) => {
2861
- function r() {
2862
- window.removeEventListener("message", i), clearInterval(a);
2863
- }
2864
- function i(i) {
2865
- if (i.origin !== n) return;
2866
- let a = i.data;
2867
- a?.type === "MARKUP_AUTH_RESULT" && (r(), a.identity?.id && a.identity?.name ? e({
2868
- identity: a.identity,
2869
- token: typeof a.token == "string" ? a.token : null,
2870
- tokenExpiresAt: typeof a.tokenExpiresAt == "number" ? a.tokenExpiresAt : null
2871
- }) : t(/* @__PURE__ */ Error("Sign-in cancelled")));
2872
- }
2873
- let a = window.setInterval(() => {
2874
- o.closed && (r(), t(/* @__PURE__ */ Error("Sign-in cancelled")));
2875
- }, 500);
2876
- window.addEventListener("message", i);
2877
- }) : Promise.reject(/* @__PURE__ */ Error("Popup blocked — allow popups for this site to sign in"));
2878
- }
2879
- //#endregion
2880
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/util.js
2881
- function Ir(e, t) {
2882
- if (e.match(/^[a-z]+:\/\//i)) return e;
2883
- if (e.match(/^\/\//)) return window.location.protocol + e;
2884
- if (e.match(/^[a-z]+:/i)) return e;
2885
- let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
2886
- return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
2887
- }
2888
- var Lr = (() => {
2889
- let e = 0, t = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
2890
- return () => (e += 1, `u${t()}${e}`);
2891
- })();
2892
- function Y(e) {
2893
- let t = [];
2894
- for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
2895
- return t;
2896
- }
2897
- var Rr = null;
2898
- function zr(e = {}) {
2899
- return Rr || (e.includeStyleProperties ? (Rr = e.includeStyleProperties, Rr) : (Rr = Y(window.getComputedStyle(document.documentElement)), Rr));
2900
- }
2901
- function Br(e, t) {
2902
- let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
2903
- return n ? parseFloat(n.replace("px", "")) : 0;
2904
- }
2905
- function Vr(e) {
2906
- let t = Br(e, "border-left-width"), n = Br(e, "border-right-width");
2907
- return e.clientWidth + t + n;
2908
- }
2909
- function Hr(e) {
2910
- let t = Br(e, "border-top-width"), n = Br(e, "border-bottom-width");
2911
- return e.clientHeight + t + n;
2912
- }
2913
- function Ur(e, t = {}) {
2914
- return {
2915
- width: t.width || Vr(e),
2916
- height: t.height || Hr(e)
2917
- };
2918
- }
2919
- function Wr() {
2920
- let e, t;
2921
- try {
2922
- t = process;
2923
- } catch {}
2924
- let n = t && t.env ? t.env.devicePixelRatio : null;
2925
- return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
2926
- }
2927
- var X = 16384;
2928
- function Gr(e) {
2929
- (e.width > X || e.height > X) && (e.width > X && e.height > X ? e.width > e.height ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X) : e.width > X ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X));
2930
- }
2931
- function Kr(e) {
2932
- return new Promise((t, n) => {
2933
- let r = new Image();
2934
- r.onload = () => {
2935
- r.decode().then(() => {
2936
- requestAnimationFrame(() => t(r));
2937
- });
2938
- }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
2939
- });
2940
- }
2941
- async function qr(e) {
2942
- return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
2943
- }
2944
- async function Jr(e, t, n) {
2945
- let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
2946
- return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), qr(i);
2947
- }
2948
- var Z = (e, t) => {
2949
- if (e instanceof t) return !0;
2950
- let n = Object.getPrototypeOf(e);
2951
- return n === null ? !1 : n.constructor.name === t.name || Z(n, t);
2952
- };
2953
- //#endregion
2954
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-pseudos.js
2955
- function Yr(e) {
2956
- let t = e.getPropertyValue("content");
2957
- return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
2958
- }
2959
- function Xr(e, t) {
2960
- return zr(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
2961
- }
2962
- function Zr(e, t, n, r) {
2963
- let i = `.${e}:${t}`, a = n.cssText ? Yr(n) : Xr(n, r);
2964
- return document.createTextNode(`${i}{${a}}`);
2965
- }
2966
- function Qr(e, t, n, r) {
2967
- let i = window.getComputedStyle(e, n), a = i.getPropertyValue("content");
2968
- if (a === "" || a === "none") return;
2969
- let o = Lr();
2970
- try {
2971
- t.className = `${t.className} ${o}`;
2972
- } catch {
2973
- return;
2974
- }
2975
- let s = document.createElement("style");
2976
- s.appendChild(Zr(o, n, i, r)), t.appendChild(s);
2977
- }
2978
- function $r(e, t, n) {
2979
- Qr(e, t, ":before", n), Qr(e, t, ":after", n);
2980
- }
2981
- //#endregion
2982
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/mimes.js
2983
- var ei = "application/font-woff", ti = "image/jpeg", ni = {
2984
- woff: ei,
2985
- woff2: ei,
2986
- ttf: "application/font-truetype",
2987
- eot: "application/vnd.ms-fontobject",
2988
- png: "image/png",
2989
- jpg: ti,
2990
- jpeg: ti,
2991
- gif: "image/gif",
2992
- tiff: "image/tiff",
2993
- svg: "image/svg+xml",
2994
- webp: "image/webp"
2995
- };
2996
- function ri(e) {
2997
- let t = /\.([^./]*?)$/g.exec(e);
2998
- return t ? t[1] : "";
2999
- }
3000
- function ii(e) {
3001
- return ni[ri(e).toLowerCase()] || "";
3002
- }
3003
- //#endregion
3004
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/dataurl.js
3005
- function ai(e) {
3006
- return e.split(/,/)[1];
3007
- }
3008
- function oi(e) {
3009
- return e.search(/^(data:)/) !== -1;
3010
- }
3011
- function si(e, t) {
3012
- return `data:${t};base64,${e}`;
3013
- }
3014
- async function ci(e, t, n) {
3015
- let r = await fetch(e, t);
3016
- if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
3017
- let i = await r.blob();
3018
- return new Promise((e, t) => {
3019
- let a = new FileReader();
3020
- a.onerror = t, a.onloadend = () => {
3021
- try {
3022
- e(n({
3023
- res: r,
3024
- result: a.result
3025
- }));
3026
- } catch (e) {
3027
- t(e);
3028
- }
3029
- }, a.readAsDataURL(i);
3030
- });
3031
- }
3032
- var li = {};
3033
- function ui(e, t, n) {
3034
- let r = e.replace(/\?.*/, "");
3035
- return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
3036
- }
3037
- async function di(e, t, n) {
3038
- let r = ui(e, t, n.includeQueryParams);
3039
- if (li[r] != null) return li[r];
3040
- n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
3041
- let i;
3042
- try {
3043
- i = si(await ci(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", ai(n))), t);
3044
- } catch (t) {
3045
- i = n.imagePlaceholder || "";
3046
- let r = `Failed to fetch resource: ${e}`;
3047
- t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
3048
- }
3049
- return li[r] = i, i;
3050
- }
3051
- //#endregion
3052
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-node.js
3053
- async function fi(e) {
3054
- let t = e.toDataURL();
3055
- return t === "data:," ? e.cloneNode(!1) : Kr(t);
3056
- }
3057
- async function pi(e, t) {
3058
- if (e.currentSrc) {
3059
- let t = document.createElement("canvas"), n = t.getContext("2d");
3060
- return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), Kr(t.toDataURL());
3061
- }
3062
- let n = e.poster;
3063
- return Kr(await di(n, ii(n), t));
3064
- }
3065
- async function mi(e, t) {
3066
- try {
3067
- if (e?.contentDocument?.body) return await wi(e.contentDocument.body, t, !0);
3068
- } catch {}
3069
- return e.cloneNode(!1);
3070
- }
3071
- async function hi(e, t) {
3072
- return Z(e, HTMLCanvasElement) ? fi(e) : Z(e, HTMLVideoElement) ? pi(e, t) : Z(e, HTMLIFrameElement) ? mi(e, t) : e.cloneNode(_i(e));
3073
- }
3074
- var gi = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", _i = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
3075
- async function vi(e, t, n) {
3076
- if (_i(t)) return t;
3077
- let r = [];
3078
- return r = gi(e) && e.assignedNodes ? Y(e.assignedNodes()) : Z(e, HTMLIFrameElement) && e.contentDocument?.body ? Y(e.contentDocument.body.childNodes) : Y((e.shadowRoot ?? e).childNodes), r.length === 0 || Z(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => wi(r, n)).then((e) => {
3079
- e && t.appendChild(e);
3080
- }), Promise.resolve()), t;
3081
- }
3082
- function yi(e, t, n) {
3083
- let r = t.style;
3084
- if (!r) return;
3085
- let i = window.getComputedStyle(e);
3086
- i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : zr(n).forEach((n) => {
3087
- let a = i.getPropertyValue(n);
3088
- n === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), Z(e, HTMLIFrameElement) && n === "display" && a === "inline" && (a = "block"), n === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), r.setProperty(n, a, i.getPropertyPriority(n));
3089
- });
3090
- }
3091
- function bi(e, t) {
3092
- Z(e, HTMLTextAreaElement) && (t.innerHTML = e.value), Z(e, HTMLInputElement) && t.setAttribute("value", e.value);
3093
- }
3094
- function xi(e, t) {
3095
- if (Z(e, HTMLSelectElement)) {
3096
- let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
3097
- r && r.setAttribute("selected", "");
3098
- }
3099
- }
3100
- function Si(e, t, n) {
3101
- return Z(t, Element) && (yi(e, t, n), $r(e, t, n), bi(e, t), xi(e, t)), t;
3102
- }
3103
- async function Ci(e, t) {
3104
- let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
3105
- if (n.length === 0) return e;
3106
- let r = {};
3107
- for (let i = 0; i < n.length; i++) {
3108
- let a = n[i].getAttribute("xlink:href");
3109
- if (a) {
3110
- let n = e.querySelector(a), i = document.querySelector(a);
3111
- !n && i && !r[a] && (r[a] = await wi(i, t, !0));
3112
- }
3113
- }
3114
- let i = Object.values(r);
3115
- if (i.length) {
3116
- let t = "http://www.w3.org/1999/xhtml", n = document.createElementNS(t, "svg");
3117
- n.setAttribute("xmlns", t), n.style.position = "absolute", n.style.width = "0", n.style.height = "0", n.style.overflow = "hidden", n.style.display = "none";
3118
- let r = document.createElementNS(t, "defs");
3119
- n.appendChild(r);
3120
- for (let e = 0; e < i.length; e++) r.appendChild(i[e]);
3121
- e.appendChild(n);
3122
- }
3123
- return e;
3124
- }
3125
- async function wi(e, t, n) {
3126
- return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => hi(e, t)).then((n) => vi(e, n, t)).then((n) => Si(e, n, t)).then((e) => Ci(e, t));
3127
- }
3128
- //#endregion
3129
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-resources.js
3130
- var Ti = /url\((['"]?)([^'"]+?)\1\)/g, Ei = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Di = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
3131
- function Oi(e) {
3132
- let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
3133
- return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
3134
- }
3135
- function ki(e) {
3136
- let t = [];
3137
- return e.replace(Ti, (e, n, r) => (t.push(r), e)), t.filter((e) => !oi(e));
3138
- }
3139
- async function Ai(e, t, n, r, i) {
3140
- try {
3141
- let a = n ? Ir(t, n) : t, o = ii(t), s;
3142
- return s = i ? si(await i(a), o) : await di(a, o, r), e.replace(Oi(t), `$1${s}$3`);
3143
- } catch {}
3144
- return e;
3145
- }
3146
- function ji(e, { preferredFontFormat: t }) {
3147
- return t ? e.replace(Di, (e) => {
3148
- for (;;) {
3149
- let [n, , r] = Ei.exec(e) || [];
3150
- if (!r) return "";
3151
- if (r === t) return `src: ${n};`;
3152
- }
3153
- }) : e;
3154
- }
3155
- function Mi(e) {
3156
- return e.search(Ti) !== -1;
3157
- }
3158
- async function Ni(e, t, n) {
3159
- if (!Mi(e)) return e;
3160
- let r = ji(e, n);
3161
- return ki(r).reduce((e, r) => e.then((e) => Ai(e, r, t, n)), Promise.resolve(r));
3162
- }
3163
- //#endregion
3164
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-images.js
3165
- async function Pi(e, t, n) {
3166
- let r = t.style?.getPropertyValue(e);
3167
- if (r) {
3168
- let i = await Ni(r, null, n);
3169
- return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
3170
- }
3171
- return !1;
3172
- }
3173
- async function Fi(e, t) {
3174
- await Pi("background", e, t) || await Pi("background-image", e, t), await Pi("mask", e, t) || await Pi("-webkit-mask", e, t) || await Pi("mask-image", e, t) || await Pi("-webkit-mask-image", e, t);
3175
- }
3176
- async function Ii(e, t) {
3177
- let n = Z(e, HTMLImageElement);
3178
- if (!(n && !oi(e.src)) && !(Z(e, SVGImageElement) && !oi(e.href.baseVal))) return;
3179
- let r = n ? e.src : e.href.baseVal, i = await di(r, ii(r), t);
3180
- await new Promise((r, a) => {
3181
- e.onload = r, e.onerror = t.onImageErrorHandler ? (...e) => {
3182
- try {
3183
- r(t.onImageErrorHandler(...e));
3184
- } catch (e) {
3185
- a(e);
3186
- }
3187
- } : a;
3188
- let o = e;
3189
- o.decode &&= r, o.loading === "lazy" && (o.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
3190
- });
3191
- }
3192
- async function Li(e, t) {
3193
- let n = Y(e.childNodes).map((e) => Ri(e, t));
3194
- await Promise.all(n).then(() => e);
3195
- }
3196
- async function Ri(e, t) {
3197
- Z(e, Element) && (await Fi(e, t), await Ii(e, t), await Li(e, t));
3198
- }
3199
- //#endregion
3200
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/apply-style.js
3201
- function zi(e, t) {
3202
- let { style: n } = e;
3203
- t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
3204
- let r = t.style;
3205
- return r != null && Object.keys(r).forEach((e) => {
3206
- n[e] = r[e];
3207
- }), e;
3208
- }
3209
- //#endregion
3210
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-webfonts.js
3211
- var Bi = {};
3212
- async function Vi(e) {
3213
- let t = Bi[e];
3214
- return t ?? (t = {
3215
- url: e,
3216
- cssText: await (await fetch(e)).text()
3217
- }, Bi[e] = t, t);
3218
- }
3219
- async function Hi(e, t) {
3220
- let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
3221
- let a = i.replace(r, "$1");
3222
- return a.startsWith("https://") || (a = new URL(a, e.url).href), ci(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
3223
- });
3224
- return Promise.all(i).then(() => n);
3225
- }
3226
- function Ui(e) {
3227
- if (e == null) return [];
3228
- let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
3229
- for (;;) {
3230
- let e = r.exec(n);
3231
- if (e === null) break;
3232
- t.push(e[0]);
3233
- }
3234
- n = n.replace(r, "");
3235
- let i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
3236
- for (;;) {
3237
- let e = i.exec(n);
3238
- if (e === null) {
3239
- if (e = a.exec(n), e === null) break;
3240
- i.lastIndex = a.lastIndex;
3241
- } else a.lastIndex = i.lastIndex;
3242
- t.push(e[0]);
3243
- }
3244
- return t;
3245
- }
3246
- async function Wi(e, t) {
3247
- let n = [], r = [];
3248
- return e.forEach((n) => {
3249
- if ("cssRules" in n) try {
3250
- Y(n.cssRules || []).forEach((e, i) => {
3251
- if (e.type === CSSRule.IMPORT_RULE) {
3252
- let a = i + 1, o = e.href, s = Vi(o).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3253
- try {
3254
- n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
3255
- } catch (t) {
3256
- console.error("Error inserting rule from remote css", {
3257
- rule: e,
3258
- error: t
3259
- });
3260
- }
3261
- })).catch((e) => {
3262
- console.error("Error loading remote css", e.toString());
3263
- });
3264
- r.push(s);
3265
- }
3266
- });
3267
- } catch (i) {
3268
- let a = e.find((e) => e.href == null) || document.styleSheets[0];
3269
- n.href != null && r.push(Vi(n.href).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3270
- a.insertRule(e, a.cssRules.length);
3271
- })).catch((e) => {
3272
- console.error("Error loading remote stylesheet", e);
3273
- })), console.error("Error inlining remote css file", i);
3274
- }
3275
- }), Promise.all(r).then(() => (e.forEach((e) => {
3276
- if ("cssRules" in e) try {
3277
- Y(e.cssRules || []).forEach((e) => {
3278
- n.push(e);
3279
- });
3280
- } catch (t) {
3281
- console.error(`Error while reading CSS rules from ${e.href}`, t);
3282
- }
3283
- }), n));
3284
- }
3285
- function Gi(e) {
3286
- return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => Mi(e.style.getPropertyValue("src")));
3287
- }
3288
- async function Ki(e, t) {
3289
- if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
3290
- return Gi(await Wi(Y(e.ownerDocument.styleSheets), t));
3291
- }
3292
- function qi(e) {
3293
- return e.trim().replace(/["']/g, "");
3294
- }
3295
- function Ji(e) {
3296
- let t = /* @__PURE__ */ new Set();
3297
- function n(e) {
3298
- (e.style.fontFamily || getComputedStyle(e).fontFamily).split(",").forEach((e) => {
3299
- t.add(qi(e));
3300
- }), Array.from(e.children).forEach((e) => {
3301
- e instanceof HTMLElement && n(e);
3302
- });
3303
- }
3304
- return n(e), t;
3305
- }
3306
- async function Yi(e, t) {
3307
- let n = await Ki(e, t), r = Ji(e);
3308
- return (await Promise.all(n.filter((e) => r.has(qi(e.style.fontFamily))).map((e) => {
3309
- let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
3310
- return Ni(e.cssText, n, t);
3311
- }))).join("\n");
3312
- }
3313
- async function Xi(e, t) {
3314
- let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await Yi(e, t) : t.fontEmbedCSS;
3315
- if (n) {
3316
- let t = document.createElement("style"), r = document.createTextNode(n);
3317
- t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
3318
- }
3319
- }
3320
- //#endregion
3321
- //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/index.js
3322
- async function Zi(e, t = {}) {
3323
- let { width: n, height: r } = Ur(e, t), i = await wi(e, t, !0);
3324
- return await Xi(i, t), await Ri(i, t), zi(i, t), await Jr(i, n, r);
3325
- }
3326
- async function Qi(e, t = {}) {
3327
- let { width: n, height: r } = Ur(e, t), i = await Kr(await Zi(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || Wr(), c = t.canvasWidth || n, l = t.canvasHeight || r;
3328
- return a.width = c * s, a.height = l * s, t.skipAutoScale || Gr(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
3329
- }
3330
- //#endregion
3331
- //#region src/runtime/screenshot.ts
3332
- var $i = 2 * 1024 * 1024;
3333
- async function ea(e, t) {
3334
- try {
3335
- function n(t) {
3336
- return !(e && (t === e || e.contains(t)));
3337
- }
3338
- let r = window.innerWidth, i = window.innerHeight, a = Math.min(window.devicePixelRatio, 2), o = await Qi(document.documentElement, {
3339
- width: r,
3340
- height: i,
3341
- cacheBust: !0,
3342
- backgroundColor: "#ffffff",
3343
- pixelRatio: a,
3344
- filter: n,
3345
- style: {
3346
- transform: `translateY(-${window.scrollY}px)`,
3347
- transformOrigin: "top left"
3348
- }
3349
- });
3350
- if (t) {
3351
- let e = o.getContext("2d");
3352
- e && na(e, t.x, t.y, a);
3353
- }
3354
- let s = await ta(o, .85);
3355
- if (!s) return null;
3356
- if (s.size <= $i) return s;
3357
- let c = await ta(o, .5);
3358
- return !c || c.size > $i ? null : c;
3359
- } catch {
3360
- return null;
3361
- }
3362
- }
3363
- function ta(e, t) {
3364
- return new Promise((n) => e.toBlob(n, "image/jpeg", t));
3365
- }
3366
- function na(e, t, n, r) {
3367
- let i = r, a = 28 * i, o = a / 2, s = t * i, c = n * i;
3368
- e.save(), e.translate(s, c), e.rotate(-Math.PI / 4);
3369
- let l = 2 * i;
3370
- e.beginPath(), e.roundRect(-o - l, -o - l, a + l * 2, a + l * 2, [
3371
- 14 * i + l,
3372
- 14 * i + l,
3373
- 14 * i + l,
3374
- 4 * i + l
3375
- ]), e.fillStyle = "#ffffff", e.fill(), e.beginPath(), e.roundRect(-o, -o, a, a, [
3376
- 14 * i,
3377
- 14 * i,
3378
- 14 * i,
3379
- 4 * i
3380
- ]), e.fillStyle = "#1a1614", e.fill(), e.rotate(Math.PI / 4), e.beginPath(), e.arc(0, 0, 3 * i, 0, Math.PI * 2), e.fillStyle = "rgba(255, 255, 255, 0.85)", e.fill(), e.restore();
3381
- }
3382
- //#endregion
3383
- //#region src/runtime/utils.ts
3384
- function Q(...e) {
3385
- return e.filter(Boolean).join(" ");
3386
- }
3387
- //#endregion
3388
- //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
3389
- var ra = 0;
3390
- Array.isArray;
3391
- function $(e, t, r, i, a, o) {
3392
- t ||= {};
3393
- var s, c, l = t;
3394
- if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
3395
- var u = {
3396
- type: e,
3397
- props: l,
3398
- key: r,
3399
- ref: s,
3400
- __k: null,
3401
- __: null,
3402
- __b: 0,
3403
- __e: null,
3404
- __c: null,
3405
- constructor: void 0,
3406
- __v: --ra,
3407
- __i: -1,
3408
- __u: 0,
3409
- __source: a,
3410
- __self: o
3411
- };
3412
- if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
3413
- return n.vnode && n.vnode(u), u;
3414
- }
3415
- //#endregion
3416
- //#region src/runtime/ui/icons.tsx
3417
- function ia({ size: e = 16 }) {
3418
- return /* @__PURE__ */ $("svg", {
3419
- width: e,
3420
- height: e,
3421
- viewBox: "0 0 126 126",
3422
- fill: "currentColor",
3423
- "aria-hidden": !0,
3424
- children: /* @__PURE__ */ $("path", { d: "M63.4561 0.00557731C70.6277 -0.0175584 76.9025 1.04088 83.5898 3.71066C97.7952 9.43043 109.186 20.5001 115.311 34.5359C119.708 44.8002 120.746 54.7869 119.156 65.8171C116.857 82.7956 105.129 98.8382 90.0566 106.846C83.4394 110.362 74.7336 113.029 67.2051 113.271C62.4204 113.425 61.1274 113.32 56.6807 115.204C50.2035 117.858 43.6874 120.417 37.1348 122.879C34.8442 123.763 32.3203 124.902 29.9404 125.51C29.4023 125.648 28.1978 125.009 27.7598 124.646C26.9046 123.951 27.0582 122.505 27.0264 121.484C26.8123 114.646 27.3302 107.458 26.8604 100.656C25.1578 98.6714 22.4026 96.603 20.3086 94.1989C12.1853 84.8731 7.05334 73.9949 6.18164 61.6101C4.95583 46.292 9.97176 31.1285 20.0908 19.5632C29.989 8.13202 44.0369 1.11921 59.1221 0.0788195C60.2694 -0.0356049 62.2637 0.00944821 63.4561 0.00557731ZM92.2676 55.7497C91.5754 39.5314 77.8207 26.9725 61.6064 27.7536C45.5175 28.5287 33.0758 42.1537 33.7627 58.2468C34.4496 74.3398 48.007 86.8553 64.1035 86.2566C80.3254 85.6533 92.9599 71.968 92.2676 55.7497Z" })
3425
- });
3426
- }
3427
- function aa({ size: e = 16 }) {
3428
- return /* @__PURE__ */ $("svg", {
3429
- width: e,
3430
- height: e,
3431
- viewBox: "0 0 20 20",
3432
- fill: "currentColor",
3433
- children: /* @__PURE__ */ $("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
3434
- });
3435
- }
3436
- function oa({ size: e = 16 }) {
3437
- return /* @__PURE__ */ $("svg", {
3438
- width: e,
3439
- height: e,
3440
- viewBox: "0 0 20 20",
3441
- fill: "currentColor",
3442
- children: /* @__PURE__ */ $("path", { d: "M3 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM8.5 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM15.5 8.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z" })
3443
- });
3444
- }
3445
- function sa({ size: e = 16 }) {
3446
- return /* @__PURE__ */ $("svg", {
3447
- width: e,
3448
- height: e,
3449
- viewBox: "0 0 16 16",
3450
- fill: "currentColor",
3451
- children: /* @__PURE__ */ $("path", {
3452
- fillRule: "evenodd",
3453
- d: "M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z",
3454
- clipRule: "evenodd"
3455
- })
3456
- });
3457
- }
3458
- function ca({ size: e = 16 }) {
3459
- return /* @__PURE__ */ $("svg", {
3460
- width: e,
3461
- height: e,
3462
- viewBox: "0 0 20 20",
3463
- fill: "currentColor",
3464
- "aria-hidden": !0,
3465
- children: /* @__PURE__ */ $("path", {
3466
- "fill-rule": "evenodd",
3467
- d: "M1 8a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 8.07 3h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 16.07 6H17a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8Zm13.5 3a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM10 14a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",
3468
- "clip-rule": "evenodd"
3469
- })
3470
- });
3471
- }
3472
- function la({ size: e = 16 }) {
3473
- return /* @__PURE__ */ $("svg", {
3474
- width: e,
3475
- height: e,
3476
- viewBox: "0 0 16 16",
3477
- fill: "currentColor",
3478
- children: /* @__PURE__ */ $("path", { d: "M2.87 2.298a.75.75 0 0 0-.812 1.021L3.39 6.624a1 1 0 0 0 .928.626H8.25a.75.75 0 0 1 0 1.5H4.318a1 1 0 0 0-.927.626l-1.333 3.305a.75.75 0 0 0 .811 1.022 24.89 24.89 0 0 0 11.668-5.115.75.75 0 0 0 0-1.175A24.89 24.89 0 0 0 2.869 2.298Z" })
3479
- });
3480
- }
3481
- function ua({ size: e = 16 }) {
3482
- return /* @__PURE__ */ $("svg", {
3483
- width: e,
3484
- height: e,
3485
- viewBox: "0 0 256 256",
3486
- fill: "currentColor",
3487
- "aria-hidden": !0,
3488
- children: /* @__PURE__ */ $("path", { d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM80,108a12,12,0,1,1,12,12A12,12,0,0,1,80,108Zm96,0a12,12,0,1,1-12-12A12,12,0,0,1,176,108Zm-1.07,48c-10.29,17.79-27.4,28-46.93,28s-36.63-10.2-46.92-28a8,8,0,1,1,13.84-8c7.47,12.91,19.21,20,33.08,20s25.61-7.1,33.07-20a8,8,0,0,1,13.86,8Z" })
3489
- });
3490
- }
3491
- //#endregion
3492
- //#region src/runtime/ui/fab.tsx
3493
- function da({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" }) {
3494
- return /* @__PURE__ */ $("button", {
3495
- type: "button",
3496
- class: Q("markup-fab", r === "bottom-left" ? "markup-fab-left" : "markup-fab-right", e && "is-active"),
3497
- onClick: (e) => {
3498
- if (e.preventDefault(), e.stopPropagation(), (e.metaKey || e.ctrlKey) && n) {
3499
- n();
3500
- return;
3501
- }
3502
- t();
3503
- },
3504
- onPointerDown: (e) => {
3505
- e.preventDefault(), e.stopPropagation();
3506
- },
3507
- "aria-label": e ? "Cancel placing markup" : "Leave a markup",
3508
- "aria-pressed": e,
3509
- children: [/* @__PURE__ */ $("span", {
3510
- class: "markup-fab-icon",
3511
- children: $(e ? aa : ia, { size: 16 })
3512
- }), /* @__PURE__ */ $("span", {
3513
- class: "markup-fab-label",
3514
- children: e ? "Cancel" : "Markup"
3515
- })]
3516
- });
3517
- }
3518
- //#endregion
3519
- //#region src/runtime/use-focus-trap.ts
3520
- var fa = [
3521
- "a[href]",
3522
- "button:not([disabled])",
3523
- "input:not([disabled])",
3524
- "select:not([disabled])",
3525
- "textarea:not([disabled])",
3526
- "[tabindex]:not([tabindex=\"-1\"])"
3527
- ].join(",");
3528
- function pa(e, t) {
3529
- R(() => {
3530
- if (!t) return;
3531
- let n = e.current;
3532
- if (!n) return;
3533
- function r(e) {
3534
- if (e.key !== "Tab") return;
3535
- let t = Array.from(n.querySelectorAll(fa)), r = t[0], i = t[t.length - 1];
3536
- if (!r || !i) return;
3537
- let a = n.getRootNode(), o = a instanceof ShadowRoot ? a.activeElement : document.activeElement;
3538
- (e.shiftKey ? o === r : o === i) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
3539
- }
3540
- return n.addEventListener("keydown", r), () => n.removeEventListener("keydown", r);
3541
- }, [e, t]);
3542
- }
3543
- //#endregion
3544
- //#region src/runtime/ui/author-prompt.tsx
3545
- function ma({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3546
- let [i, a] = L(""), [o, s] = L(""), c = z(null);
3547
- R(() => {
3548
- c.current?.focus();
3549
- }, []);
3550
- function l(n) {
3551
- n?.preventDefault();
3552
- let r = i.trim();
3553
- !r || e || t(r, o.trim() || void 0);
3554
- }
3555
- return /* @__PURE__ */ $("form", {
3556
- class: "markup-author-prompt",
3557
- onSubmit: l,
3558
- children: [
3559
- r ? /* @__PURE__ */ $(C, { children: [/* @__PURE__ */ $("button", {
3560
- type: "button",
3561
- class: "markup-btn markup-btn-primary",
3562
- onClick: r,
3563
- disabled: e,
3564
- children: "Sign in with Markup"
3565
- }), /* @__PURE__ */ $("p", {
3566
- class: "markup-author-divider",
3567
- children: "or continue as a guest"
3568
- })] }) : /* @__PURE__ */ $("p", {
3569
- class: "markup-eyebrow",
3570
- children: "who's leaving feedback?"
3571
- }),
3572
- /* @__PURE__ */ $("input", {
3573
- ref: c,
3574
- class: "markup-input",
3575
- type: "text",
3576
- name: "name",
3577
- placeholder: "Your name",
3578
- value: i,
3579
- maxLength: 80,
3580
- autoComplete: "name",
3581
- onInput: (e) => a(e.currentTarget.value),
3582
- disabled: e,
3583
- "data-1p-ignore": !0
3584
- }),
3585
- /* @__PURE__ */ $("input", {
3586
- class: "markup-input",
3587
- type: "email",
3588
- name: "email",
3589
- placeholder: "Email (optional)",
3590
- value: o,
3591
- maxLength: 254,
3592
- autoComplete: "email",
3593
- onInput: (e) => s(e.currentTarget.value),
3594
- disabled: e,
3595
- "data-1p-ignore": !0
3596
- }),
3597
- /* @__PURE__ */ $("div", {
3598
- class: "markup-composer-actions",
3599
- children: [/* @__PURE__ */ $("button", {
3600
- type: "button",
3601
- class: "markup-btn markup-btn-ghost",
3602
- onClick: n,
3603
- disabled: e,
3604
- children: "Cancel"
3605
- }), /* @__PURE__ */ $("button", {
3606
- type: "submit",
3607
- class: "markup-btn markup-btn-primary",
3608
- disabled: !i.trim() || e,
3609
- children: "Continue"
3610
- })]
3611
- })
3612
- ]
3613
- });
3614
- }
3615
- //#endregion
3616
- //#region src/runtime/ui/composer.tsx
3617
- var ha = 4e3;
3618
- function ga({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "Post", initialFocus: r = !0, pending: i, error: a, onSubmit: o }) {
3619
- let [s, c] = L(""), l = z(null), u = z(!1);
3620
- R(() => {
3621
- r && l.current?.focus();
3622
- }, [r]), R(() => {
3623
- let e = l.current;
3624
- e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 160)}px`);
3625
- }, [s]), R(() => {
3626
- u.current && !i && !a && (c(""), l.current?.focus()), u.current = i;
3627
- }, [i, a]);
3628
- function d(e) {
3629
- e?.preventDefault();
3630
- let t = s.trim();
3631
- !t || i || o(t);
3632
- }
3633
- function f(e) {
3634
- (e.metaKey || e.ctrlKey) && e.key === "Enter" && d(e);
3635
- }
3636
- let p = ha - s.length, m = p < 0, h = s.length > 0;
3637
- function g(e) {
3638
- return /* @__PURE__ */ $("button", {
3639
- type: "submit",
3640
- class: "markup-btn markup-btn-primary",
3641
- disabled: i || !s.trim() || m,
3642
- "aria-label": i ? "Sending…" : n,
3643
- title: i ? "Sending…" : n,
3644
- tabIndex: e,
3645
- children: /* @__PURE__ */ $(la, { size: 14 })
3646
- });
3647
- }
3648
- return /* @__PURE__ */ $("form", {
3649
- class: Q("markup-composer", h && "is-filled"),
3650
- onSubmit: d,
3651
- children: [
3652
- /* @__PURE__ */ $("textarea", {
3653
- ref: l,
3654
- name: "reply",
3655
- class: "markup-composer-input",
3656
- placeholder: t,
3657
- rows: h ? 2 : 1,
3658
- maxLength: ha + 100,
3659
- value: s,
3660
- onInput: (e) => c(e.currentTarget.value),
3661
- onKeyDown: f,
3662
- disabled: i,
3663
- "aria-label": e
3664
- }),
3665
- /* @__PURE__ */ $("div", {
3666
- class: "markup-composer-footer-wrap",
3667
- children: /* @__PURE__ */ $("div", {
3668
- class: "markup-composer-footer",
3669
- children: [/* @__PURE__ */ $("span", {
3670
- class: "markup-composer-hint",
3671
- children: a ? /* @__PURE__ */ $("span", {
3672
- class: "markup-composer-error",
3673
- children: a
3674
- }) : m ? /* @__PURE__ */ $("span", {
3675
- class: "markup-composer-error",
3676
- children: [Math.abs(p), " too long"]
3677
- }) : /* @__PURE__ */ $("span", { children: "⌘↵ to send" })
3678
- }), /* @__PURE__ */ $("div", {
3679
- class: "markup-composer-actions",
3680
- children: g(h ? void 0 : -1)
3681
- })]
3682
- })
3683
- }),
3684
- /* @__PURE__ */ $("span", {
3685
- class: "markup-composer-actions-empty",
3686
- "aria-hidden": h || void 0,
3687
- children: g(h ? -1 : void 0)
3688
- })
3689
- ]
3690
- });
3691
- }
3692
- //#endregion
3693
- //#region src/runtime/ui/new-thread-popover.tsx
3694
- function _a({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, error: a, screenshot: o, screenshotCapturing: s, onAuthor: c, onSignIn: l, onSubmit: u, onClose: d }) {
3695
- let f = z(null);
3696
- pa(f, !0);
3697
- let [p, m] = L(!1), [h, g] = L(null);
3698
- R(() => {
3699
- if (!o) return;
3700
- let e = URL.createObjectURL(o);
3701
- return g(e), () => URL.revokeObjectURL(e);
3702
- }, [o]), R(() => {
3703
- let e = f.current;
3704
- if (!e) return;
3705
- if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3706
- e.showPopover();
3707
- } catch {}
3708
- function t(e) {
3709
- e.newState === "closed" && d();
3710
- }
3711
- return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3712
- }, [d]);
3713
- let _ = va(e - window.scrollX + 16, 12, window.innerWidth - 320 - 12), v = va(t - window.scrollY - 16, 12, window.innerHeight - 220), y = o != null, b = s || y;
3714
- return /* @__PURE__ */ $("div", {
3715
- ref: f,
3716
- class: "markup-popover",
3717
- popover: "auto",
3718
- style: {
3719
- "--markup-pop-x": `${_}px`,
3720
- "--markup-pop-y": `${v}px`
3721
- },
3722
- role: "dialog",
3723
- "aria-label": "New markup",
3724
- children: [/* @__PURE__ */ $("header", {
3725
- class: "markup-popover-header",
3726
- children: [/* @__PURE__ */ $("span", {
3727
- class: "markup-eyebrow",
3728
- children: "new · markup"
3729
- }), /* @__PURE__ */ $("button", {
3730
- type: "button",
3731
- class: "markup-icon-btn",
3732
- "aria-label": "Discard pin",
3733
- onClick: d,
3734
- children: /* @__PURE__ */ $(aa, { size: 16 })
3735
- })]
3736
- }), n == null ? /* @__PURE__ */ $(ma, {
3737
- pending: i,
3738
- onSubmit: c,
3739
- onCancel: d,
3740
- onSignIn: l
3741
- }) : /* @__PURE__ */ $("div", {
3742
- class: "markup-popover-body",
3743
- children: [
3744
- /* @__PURE__ */ $("p", {
3745
- class: "markup-popover-byline",
3746
- children: [
3747
- "posting as ",
3748
- /* @__PURE__ */ $("span", {
3749
- class: "markup-popover-name",
3750
- children: n
3751
- }),
3752
- r ? /* @__PURE__ */ $("span", {
3753
- class: "markup-comment-badge",
3754
- children: "team"
3755
- }) : null
3756
- ]
3757
- }),
3758
- /* @__PURE__ */ $(ga, {
3759
- label: "Feedback",
3760
- placeholder: "What's wrong, missing, or worth noting?",
3761
- submitLabel: "Post markup",
3762
- pending: i,
3763
- error: a,
3764
- onSubmit: (e) => u(e, p && y)
3765
- }),
3766
- b ? /* @__PURE__ */ $("div", {
3767
- class: "markup-screenshot-row",
3768
- children: s ? /* @__PURE__ */ $("span", {
3769
- class: "markup-screenshot-status",
3770
- children: [
3771
- /* @__PURE__ */ $("input", {
3772
- type: "checkbox",
3773
- class: "markup-screenshot-checkbox",
3774
- disabled: !0
3775
- }),
3776
- /* @__PURE__ */ $(ca, { size: 12 }),
3777
- /* @__PURE__ */ $("span", { children: "Capturing…" })
3778
- ]
3779
- }) : /* @__PURE__ */ $("label", {
3780
- class: "markup-screenshot-toggle",
3781
- children: [
3782
- /* @__PURE__ */ $("input", {
3783
- type: "checkbox",
3784
- class: "markup-screenshot-checkbox",
3785
- checked: p,
3786
- onChange: (e) => m(e.currentTarget.checked)
3787
- }),
3788
- /* @__PURE__ */ $(ca, { size: 12 }),
3789
- /* @__PURE__ */ $("span", { children: "Attach screenshot" }),
3790
- h && p ? /* @__PURE__ */ $("img", {
3791
- class: "markup-screenshot-thumb",
3792
- src: h,
3793
- alt: "Screenshot preview"
3794
- }) : null
3795
- ]
3796
- })
3797
- }) : null
3798
- ]
3799
- })]
3800
- });
3801
- }
3802
- function va(e, t, n) {
3803
- return Math.max(t, Math.min(n, e));
3804
- }
3805
- //#endregion
3806
- //#region src/runtime/ui/pin.tsx
3807
- function ya({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3808
- let a = t - window.scrollY, o = e - window.scrollX;
3809
- return /* @__PURE__ */ $("button", {
3810
- type: "button",
3811
- class: Q("markup-pin", r && "is-active is-anchor"),
3812
- style: {
3813
- top: `${a}px`,
3814
- left: `${o}px`
3815
- },
3816
- popovertarget: "markup-thread-popover",
3817
- popovertargetaction: "show",
3818
- onClick: i,
3819
- "aria-label": `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3820
- title: `Open feedback thread (${n} comment${n === 1 ? "" : "s"})`,
3821
- children: [/* @__PURE__ */ $("span", {
3822
- class: "markup-pin-dot",
3823
- "aria-hidden": !0
3824
- }), n > 1 ? /* @__PURE__ */ $("span", {
3825
- class: "markup-pin-count",
3826
- children: n
3827
- }) : null]
3828
- });
3829
- }
3830
- function ba({ pageX: e, pageY: t }) {
3831
- let n = t - window.scrollY, r = e - window.scrollX;
3832
- return /* @__PURE__ */ $("div", {
3833
- class: "markup-pin markup-pin-ghost is-anchor",
3834
- style: {
3835
- top: `${n}px`,
3836
- left: `${r}px`
3837
- },
3838
- children: /* @__PURE__ */ $("span", {
3839
- class: "markup-pin-dot",
3840
- "aria-hidden": !0
3841
- })
3842
- });
3843
- }
3844
- //#endregion
3845
- //#region src/runtime/ui/placement-overlay.tsx
3846
- function xa({ onPlace: e, onCancel: t }) {
3847
- R(() => {
3848
- function e(e) {
3849
- e.key === "Escape" && t();
3850
- }
3851
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3852
- }, [t]);
3853
- function n(t) {
3854
- t.stopPropagation(), t.preventDefault(), e(Er(t, document.elementsFromPoint(t.clientX, t.clientY).find((e) => !e.shadowRoot) ?? null), t.clientX, t.clientY);
3855
- }
3856
- function r(e) {
3857
- e.preventDefault(), e.stopPropagation();
3858
- }
3859
- return /* @__PURE__ */ $("div", {
3860
- class: "markup-placement-overlay",
3861
- onPointerDown: r,
3862
- onClick: n,
3863
- role: "presentation",
3864
- children: /* @__PURE__ */ $("div", {
3865
- class: "markup-placement-cursor-help",
3866
- children: /* @__PURE__ */ $("span", { children: "Click anywhere to drop a pin · ESC to cancel" })
3867
- })
3868
- });
3869
- }
3870
- //#endregion
3871
- //#region src/runtime/ui/thread-popover.tsx
3872
- var Sa = [
3873
- "👍",
3874
- "❤️",
3875
- "🎉",
3876
- "😮",
3877
- "😄",
3878
- "❓"
3879
- ];
3880
- function Ca({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDelete: i, pending: a, error: o, onAuthor: s, onSignIn: c, onClose: l, onReply: u, onEditComment: d, onDeleteComment: f, onToggleReaction: p, onResolve: m, onDelete: h }) {
3881
- let g = z(null), _ = z(null), v = z(null), y = z(null), b = z(null), [x, S] = L(!1), [C, w] = L(!1), [T, E] = L(null), [D, O] = L(""), [k, A] = L(null), [ee, j] = L("down"), [M, te] = L(null), [N, ne] = L(null), [re, ie] = L("down"), ae = z(null);
3882
- pa(g, !0);
3883
- let oe = e.resolvedAt != null, P = Te(() => e.comments.filter((e) => !e.deleted), [e.comments]);
3884
- function se(e, t) {
3885
- E(e), O(t);
3886
- }
3887
- function ce() {
3888
- E(null), O("");
3889
- }
3890
- R(() => {
3891
- if (!T) return;
3892
- let t = e.comments.find((e) => e._id === T);
3893
- (!t || t.deleted) && ce();
3894
- }, [e.comments, T]);
3895
- let le = z(!0);
3896
- R(() => {
3897
- let e = y.current;
3898
- if (e) {
3899
- if (le.current) {
3900
- le.current = !1, e.scrollTop = e.scrollHeight;
3901
- return;
3902
- }
3903
- e.scrollHeight - e.scrollTop - e.clientHeight < 80 && (e.scrollTop = e.scrollHeight);
3904
- }
3905
- }, [P.length]), R(() => {
3906
- if (!x) {
3907
- w(!1);
3908
- return;
3909
- }
3910
- function e(e) {
3911
- _.current && !e.composedPath().includes(_.current) && S(!1);
3912
- }
3913
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3914
- }, [x]), R(() => {
3915
- if (!k) {
3916
- te(null);
3917
- return;
3918
- }
3919
- function e(e) {
3920
- v.current && !e.composedPath().includes(v.current) && A(null);
3921
- }
3922
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3923
- }, [k]), R(() => {
3924
- if (!N) return;
3925
- function e(e) {
3926
- ae.current && !e.composedPath().includes(ae.current) && ne(null);
3927
- }
3928
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3929
- }, [N]), R(() => {
3930
- let e = g.current;
3931
- if (!e) return;
3932
- if (typeof e.showPopover == "function" && !e.matches(":popover-open")) try {
3933
- e.showPopover();
3934
- } catch {}
3935
- function t(e) {
3936
- e.newState === "closed" && l();
3937
- }
3938
- return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3939
- }, [l]);
3940
- let ue = Te(() => {
3941
- let t = Dr({
3942
- anchorX: e.anchorX,
3943
- anchorY: e.anchorY,
3944
- anchorSelector: e.anchorSelector
3945
- });
3946
- return {
3947
- left: Da(t.pageX - window.scrollX + 16, 12, window.innerWidth - 320 - 12),
3948
- top: Da(t.pageY - window.scrollY - 16, 12, window.innerHeight - 200)
3949
- };
3950
- }, [
3951
- e.anchorX,
3952
- e.anchorY,
3953
- e.anchorSelector
3954
- ]);
3955
- return /* @__PURE__ */ $("div", {
3956
- ref: g,
3957
- id: "markup-thread-popover",
3958
- class: "markup-popover",
3959
- popover: "auto",
3960
- style: {
3961
- "--markup-pop-x": `${ue.left}px`,
3962
- "--markup-pop-y": `${ue.top}px`
3963
- },
3964
- role: "dialog",
3965
- "aria-label": "Markup thread",
3966
- children: [
3967
- /* @__PURE__ */ $("header", {
3968
- class: "markup-popover-header",
3969
- children: [/* @__PURE__ */ $("span", {
3970
- class: "markup-eyebrow",
3971
- children: [
3972
- "thread · ",
3973
- P.length,
3974
- " ",
3975
- P.length === 1 ? "comment" : "comments"
3976
- ]
3977
- }), /* @__PURE__ */ $("div", {
3978
- class: "markup-popover-header-actions",
3979
- children: [
3980
- /* @__PURE__ */ $("div", {
3981
- class: "markup-thread-menu",
3982
- ref: _,
3983
- children: [/* @__PURE__ */ $("button", {
3984
- type: "button",
3985
- class: Q("markup-icon-btn", x && "is-open"),
3986
- title: "More options",
3987
- onClick: () => S((e) => !e),
3988
- children: /* @__PURE__ */ $(oa, { size: 16 })
3989
- }), x ? /* @__PURE__ */ $("div", {
3990
- class: "markup-thread-menu-list",
3991
- children: [/* @__PURE__ */ $("button", {
3992
- type: "button",
3993
- class: "markup-thread-menu-item",
3994
- onClick: () => {
3995
- let t = new URL(e.url);
3996
- t.hash = `markup-thread=${e._id}`, navigator.clipboard.writeText(t.toString()).catch(() => {}), S(!1);
3997
- },
3998
- children: "Copy link"
3999
- }), i ? /* @__PURE__ */ $("button", {
4000
- type: "button",
4001
- class: Q("markup-thread-menu-item", C && "is-danger"),
4002
- disabled: a,
4003
- onClick: () => {
4004
- C ? (S(!1), h()) : w(!0);
4005
- },
4006
- children: C ? "Confirm delete" : "Delete thread…"
4007
- }) : null]
4008
- }) : null]
4009
- }),
4010
- r ? /* @__PURE__ */ $("button", {
4011
- type: "button",
4012
- class: "markup-icon-btn",
4013
- title: "Mark as resolved",
4014
- disabled: a,
4015
- onClick: m,
4016
- children: /* @__PURE__ */ $(sa, { size: 16 })
4017
- }) : null,
4018
- /* @__PURE__ */ $("button", {
4019
- type: "button",
4020
- class: "markup-icon-btn",
4021
- title: "Close thread",
4022
- onClick: l,
4023
- children: /* @__PURE__ */ $(aa, { size: 16 })
4024
- })
4025
- ]
4026
- })]
4027
- }),
4028
- /* @__PURE__ */ $("ol", {
4029
- ref: y,
4030
- class: "markup-comments",
4031
- children: P.map((t, r) => {
4032
- let i = !t.fromDashboard && n != null && t.authorClientId === n, o = r === 0, s = i && !oe && !t.deleted, c = i && !oe && !t.deleted && !o, l = T === t._id, u = (s || c) && !l && !t.deleted, m = k === t._id, h = M === t._id;
4033
- return /* @__PURE__ */ $("li", {
4034
- class: Q("markup-comment", t.fromDashboard && "is-team"),
4035
- children: [
4036
- /* @__PURE__ */ $("div", {
4037
- class: "markup-comment-meta",
4038
- children: [
4039
- /* @__PURE__ */ $("span", {
4040
- class: "markup-comment-author",
4041
- children: t.authorName
4042
- }),
4043
- t.fromDashboard ? /* @__PURE__ */ $("span", {
4044
- class: "markup-comment-badge",
4045
- children: "team"
4046
- }) : null,
4047
- /* @__PURE__ */ $("time", {
4048
- class: "markup-comment-time",
4049
- datetime: new Date(t.createdAt).toISOString(),
4050
- title: ka(t.createdAt),
4051
- children: Oa(t.createdAt)
4052
- }),
4053
- /* @__PURE__ */ $("div", {
4054
- class: "markup-thread-actions",
4055
- children: [!oe && !l ? /* @__PURE__ */ $(wa, {
4056
- comment: t,
4057
- pickerOpen: N === t._id,
4058
- pickerDirection: re,
4059
- pickerRef: (e) => {
4060
- N === t._id && (ae.current = e);
4061
- },
4062
- onPickerClick: (e) => {
4063
- if (N === t._id) {
4064
- ne(null);
4065
- return;
4066
- }
4067
- let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect();
4068
- ie((r ? r.bottom - n.bottom : Infinity) < 44 ? "up" : "down"), ne(t._id);
4069
- },
4070
- onPickerSelect: (e) => {
4071
- ne(null), p(t._id, e);
4072
- }
4073
- }) : null, u ? /* @__PURE__ */ $("div", {
4074
- class: Q("markup-thread-menu markup-comment-menu", m && "is-open", m && ee === "up" && "is-up"),
4075
- ref: (e) => {
4076
- m && (v.current = e);
4077
- },
4078
- children: [/* @__PURE__ */ $("button", {
4079
- type: "button",
4080
- class: Q("markup-icon-btn", m && "is-open"),
4081
- title: "More options",
4082
- onClick: (e) => {
4083
- if (k === t._id) {
4084
- A(null);
4085
- return;
4086
- }
4087
- let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect(), i = (+!!s + +!!c) * 32 + 8 + 6;
4088
- j((r ? r.bottom - n.bottom : Infinity) < i ? "up" : "down"), A(t._id);
4089
- },
4090
- children: /* @__PURE__ */ $(oa, { size: 16 })
4091
- }), m ? /* @__PURE__ */ $("div", {
4092
- class: "markup-thread-menu-list",
4093
- children: [s ? /* @__PURE__ */ $("button", {
4094
- type: "button",
4095
- class: "markup-thread-menu-item",
4096
- onClick: () => {
4097
- A(null), se(t._id, t.body);
4098
- },
4099
- children: "Edit"
4100
- }) : null, c ? /* @__PURE__ */ $("button", {
4101
- type: "button",
4102
- class: Q("markup-thread-menu-item", h && "is-danger"),
4103
- onClick: () => {
4104
- h ? (A(null), f(t._id)) : te(t._id);
4105
- },
4106
- children: h ? "Confirm delete" : "Delete…"
4107
- }) : null]
4108
- }) : null]
4109
- }) : null]
4110
- })
4111
- ]
4112
- }),
4113
- l ? /* @__PURE__ */ $("form", {
4114
- class: "markup-comment-edit-form",
4115
- onSubmit: async (e) => {
4116
- e.preventDefault();
4117
- let n = D.trim();
4118
- if (!n || n === t.body) {
4119
- ce();
4120
- return;
4121
- }
4122
- try {
4123
- await d(t._id, n), ce();
4124
- } catch {}
4125
- },
4126
- children: [/* @__PURE__ */ $("textarea", {
4127
- class: "markup-textarea",
4128
- value: D,
4129
- onInput: (e) => O(e.currentTarget.value),
4130
- rows: 3,
4131
- autoFocus: !0,
4132
- disabled: a
4133
- }), /* @__PURE__ */ $("div", {
4134
- class: "markup-comment-edit-actions",
4135
- children: [/* @__PURE__ */ $("button", {
4136
- type: "button",
4137
- class: "markup-btn markup-btn-ghost",
4138
- onClick: ce,
4139
- disabled: a,
4140
- children: "Cancel"
4141
- }), /* @__PURE__ */ $("button", {
4142
- type: "submit",
4143
- class: "markup-btn markup-btn-primary",
4144
- disabled: a || D.trim().length === 0,
4145
- children: "Save"
4146
- })]
4147
- })]
4148
- }) : /* @__PURE__ */ $("p", {
4149
- class: "markup-comment-body",
4150
- children: [t.body, t.editedAt == null ? null : /* @__PURE__ */ $("time", {
4151
- class: "markup-comment-edited",
4152
- datetime: new Date(t.editedAt).toISOString(),
4153
- title: ka(t.editedAt),
4154
- children: [" ", "(edited)"]
4155
- })]
4156
- }),
4157
- !l && t.reactions.length > 0 ? /* @__PURE__ */ $(Ta, {
4158
- comment: t,
4159
- isResolved: oe,
4160
- onToggle: (e) => p(t._id, e)
4161
- }) : null,
4162
- r === 0 && e.screenshotUrl ? /* @__PURE__ */ $("button", {
4163
- type: "button",
4164
- class: "markup-comment-screenshot",
4165
- onClick: () => b.current?.showModal(),
4166
- children: /* @__PURE__ */ $("img", {
4167
- src: e.screenshotUrl,
4168
- alt: "Screenshot"
4169
- })
4170
- }) : null
4171
- ]
4172
- }, t._id);
4173
- })
4174
- }),
4175
- e.screenshotUrl ? /* @__PURE__ */ $("dialog", {
4176
- ref: b,
4177
- class: "markup-lightbox",
4178
- onClick: () => b.current?.close(),
4179
- children: [/* @__PURE__ */ $("button", {
4180
- type: "button",
4181
- class: "markup-lightbox-close markup-icon-btn",
4182
- "aria-label": "Close screenshot",
4183
- onClick: (e) => {
4184
- e.stopPropagation(), b.current?.close();
4185
- },
4186
- children: /* @__PURE__ */ $(aa, { size: 16 })
4187
- }), /* @__PURE__ */ $("img", {
4188
- class: "markup-lightbox-img",
4189
- src: e.screenshotUrl,
4190
- alt: "Screenshot",
4191
- onClick: (e) => e.stopPropagation()
4192
- })]
4193
- }) : null,
4194
- t == null ? /* @__PURE__ */ $(ma, {
4195
- pending: a,
4196
- onSubmit: s,
4197
- onCancel: l,
4198
- onSignIn: c
4199
- }) : /* @__PURE__ */ $("div", {
4200
- class: "markup-popover-body",
4201
- children: [/* @__PURE__ */ $("p", {
4202
- class: "markup-popover-byline",
4203
- children: [
4204
- "replying as ",
4205
- /* @__PURE__ */ $("span", {
4206
- class: "markup-popover-name",
4207
- children: t
4208
- }),
4209
- r ? /* @__PURE__ */ $("span", {
4210
- class: "markup-comment-badge",
4211
- children: "team"
4212
- }) : null
4213
- ]
4214
- }), /* @__PURE__ */ $(ga, {
4215
- label: "Reply",
4216
- placeholder: "Write a reply…",
4217
- submitLabel: "Reply",
4218
- initialFocus: !1,
4219
- pending: a,
4220
- error: o,
4221
- onSubmit: u
4222
- })]
4223
- })
4224
- ]
4225
- });
4226
- }
4227
- function wa({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPickerClick: i, onPickerSelect: a }) {
4228
- return /* @__PURE__ */ $("div", {
4229
- class: Q("markup-reaction-picker-wrap", t && "is-open", t && n === "up" && "is-up"),
4230
- ref: r,
4231
- children: [/* @__PURE__ */ $("button", {
4232
- type: "button",
4233
- class: Q("markup-icon-btn", t && "is-open"),
4234
- title: "Add reaction",
4235
- "aria-label": "Add reaction",
4236
- onClick: i,
4237
- children: /* @__PURE__ */ $(ua, { size: 16 })
4238
- }), t ? /* @__PURE__ */ $("div", {
4239
- class: "markup-reaction-picker",
4240
- role: "menu",
4241
- children: Sa.map((t) => /* @__PURE__ */ $("button", {
4242
- type: "button",
4243
- role: "menuitem",
4244
- class: Q("markup-reaction-picker-item", (e.reactions.find((e) => e.emoji === t)?.mine ?? !1) && "is-mine"),
4245
- onClick: () => a(t),
4246
- children: t
4247
- }, t))
4248
- }) : null]
4249
- });
4250
- }
4251
- function Ta({ comment: e, isResolved: t, onToggle: n }) {
4252
- return /* @__PURE__ */ $("div", {
4253
- class: "markup-reactions",
4254
- children: e.reactions.map((e) => {
4255
- let r = Ea(e.reactors, e.mine, e.count, e.emoji);
4256
- return /* @__PURE__ */ $("button", {
4257
- type: "button",
4258
- class: Q("markup-reaction-chip", e.mine && "is-mine"),
4259
- disabled: t,
4260
- onClick: () => n(e.emoji),
4261
- "aria-pressed": e.mine,
4262
- "aria-label": r,
4263
- title: r,
4264
- children: [/* @__PURE__ */ $("span", {
4265
- class: "markup-reaction-emoji",
4266
- "aria-hidden": !0,
4267
- children: e.emoji
4268
- }), /* @__PURE__ */ $("span", {
4269
- class: "markup-reaction-count",
4270
- children: e.count
4271
- })]
4272
- }, e.emoji);
4273
- })
4274
- });
4275
- }
4276
- function Ea(e, t, n, r) {
4277
- let i = e.slice(), a = i.length + +!!t, o = Math.max(0, n - a);
4278
- return o > 0 && i.push(`${o} other${o === 1 ? "" : "s"}`), t && i.push("you"), i.length === 0 ? `${n} reacted with ${r}` : `${i.length === 1 ? i[0] : `${i.slice(0, -1).join(", ")} and ${i[i.length - 1]}`} reacted with ${r}`;
4279
- }
4280
- function Da(e, t, n) {
4281
- return Math.max(t, Math.min(n, e));
4282
- }
4283
- function Oa(e) {
4284
- let t = Date.now() - e, n = Math.floor(t / 1e3);
4285
- if (n < 60) return "just now";
4286
- let r = Math.floor(n / 60);
4287
- if (r < 60) return `${r} minute${r === 1 ? "" : "s"} ago`;
4288
- let i = Math.floor(r / 60);
4289
- if (i < 24) return `${i} hour${i === 1 ? "" : "s"} ago`;
4290
- let a = Math.floor(i / 24);
4291
- return a < 30 ? `${a} day${a === 1 ? "" : "s"} ago` : new Date(e).getFullYear() === (/* @__PURE__ */ new Date()).getFullYear() ? new Date(e).toLocaleDateString([], {
4292
- month: "long",
4293
- day: "numeric"
4294
- }) : new Date(e).toLocaleDateString([], {
4295
- month: "long",
4296
- day: "numeric",
4297
- year: "numeric"
4298
- });
4299
- }
4300
- function ka(e) {
4301
- return new Date(e).toLocaleDateString([], {
4302
- month: "long",
4303
- day: "numeric",
4304
- year: "numeric",
4305
- hour: "numeric",
4306
- minute: "numeric"
4307
- });
4308
- }
4309
- //#endregion
4310
- //#region src/runtime/ui/app.tsx
4311
- function Aa(e) {
4312
- return {
4313
- clientId: `markup_user_${e.identity.id}`,
4314
- name: e.identity.name,
4315
- email: e.identity.email,
4316
- isVerified: !0,
4317
- token: e.token ?? void 0,
4318
- tokenExpiresAt: e.tokenExpiresAt ?? void 0
4319
- };
4320
- }
4321
- function ja({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4322
- let [r, i] = L(() => window.location.pathname), [a, o] = L([]), [s, c] = L(null), l = z(null);
4323
- l.current = s;
4324
- let u = Te(() => Ar({
4325
- apiUrl: e,
4326
- apiKey: t,
4327
- getToken: () => {
4328
- let e = l.current;
4329
- return e?.token && e.tokenExpiresAt ? {
4330
- token: e.token,
4331
- expiresAt: e.tokenExpiresAt
4332
- } : null;
4333
- },
4334
- getAnonToken: () => {
4335
- let e = l.current;
4336
- return e?.token && e.tokenExpiresAt ? null : e?.anonToken ?? null;
4337
- },
4338
- onUnauthorized: () => {
4339
- let e = l.current;
4340
- if (!e) return;
4341
- let t = {
4342
- clientId: e.clientId,
4343
- name: e.name,
4344
- email: e.email,
4345
- anonToken: e.anonToken
4346
- };
4347
- l.current = t, c(t), Pr(t);
4348
- }
4349
- }), [e, t]), [d, f] = L({ kind: "idle" }), [p, m] = L(!1), [h, g] = L(null), [_, v] = L(!1), [y, b] = L(!1), [, x] = L(0), S = z(null), C = s?.name ?? null, w = s?.isVerified ?? !1;
4350
- R(() => {
4351
- let e = Nr();
4352
- if (e?.anonToken || e?.isVerified) {
4353
- c(e);
4354
- return;
4355
- }
4356
- let t = !1, n = null, r = 1e3;
4357
- function i() {
4358
- u.mintAnonIdentity().then(({ clientId: n, token: r }) => {
4359
- if (t) return;
4360
- let i = {
4361
- ...e ?? {},
4362
- clientId: n,
4363
- anonToken: r
4364
- };
4365
- Pr(i), c(i);
4366
- }).catch(() => {
4367
- t || (n = setTimeout(i, Math.min(r, 3e4)), r = Math.min(r * 2, 3e4));
4368
- });
4369
- }
4370
- return i(), () => {
4371
- t = !0, n && clearTimeout(n);
4372
- };
4373
- }, [u]);
4374
- let [T, E] = L(null);
4375
- R(() => {
4376
- let e = !1, t = null;
4377
- async function n() {
4378
- try {
4379
- let r = await u.getSubscriptionToken();
4380
- if (e) return;
4381
- E(r.token);
4382
- let i = Math.max(6e4, r.expiresAt - Date.now() - 30 * 6e4);
4383
- t = setTimeout(n, i);
4384
- } catch {
4385
- if (e) return;
4386
- t = setTimeout(n, 6e4);
4387
- }
4388
- }
4389
- return n(), () => {
4390
- e = !0, t && clearTimeout(t);
4391
- };
4392
- }, [u]);
4393
- let D = z(null);
4394
- R(() => {
4395
- let t = new ar(e.replace(/\.convex\.site(\/.*)?$/, ".convex.cloud"));
4396
- return D.current = t, () => {
4397
- t.close(), D.current = null;
4398
- };
4399
- }, [e]);
4400
- let O = z(!1);
4401
- R(() => {
4402
- let e = D.current;
4403
- if (!(!e || !T)) return O.current = !1, g(null), e.onUpdate(Yt("widget/queries:subscribeThreadsForRoute"), {
4404
- subscriptionToken: T,
4405
- route: r,
4406
- viewerClientId: s?.clientId ?? void 0
4407
- }, (e) => {
4408
- e !== void 0 && o(e);
4409
- });
4410
- }, [
4411
- T,
4412
- r,
4413
- s?.clientId
4414
- ]), R(() => {
4415
- if (O.current) return;
4416
- let e = window.location.hash.match(/^#markup-thread=(.+)$/);
4417
- if (!e) {
4418
- O.current = !0;
4419
- return;
4420
- }
4421
- let t = decodeURIComponent(e[1] ?? "");
4422
- a.find((e) => e._id === t) && (O.current = !0, f({
4423
- kind: "thread",
4424
- threadId: t
4425
- }), history.replaceState(null, "", window.location.pathname + window.location.search));
4426
- }, [a]), R(() => {
4427
- function e() {
4428
- i(window.location.pathname);
4429
- }
4430
- window.addEventListener("popstate", e);
4431
- let t = history.pushState, n = history.replaceState;
4432
- return history.pushState = function(...n) {
4433
- t.apply(this, n), e();
4434
- }, history.replaceState = function(...t) {
4435
- n.apply(this, t), e();
4436
- }, () => {
4437
- window.removeEventListener("popstate", e), history.pushState = t, history.replaceState = n;
4438
- };
4439
- }, []), R(() => {
4440
- function e(e) {
4441
- e.key === "." && (e.metaKey || e.ctrlKey) && (e.altKey || e.shiftKey || (e.preventDefault(), v((e) => !e)));
4442
- }
4443
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
4444
- }, []), R(() => {
4445
- if (!y) return;
4446
- if (!_) {
4447
- b(!1);
4448
- return;
4449
- }
4450
- let e = window.setTimeout(() => b(!1), 5e3);
4451
- return () => window.clearTimeout(e);
4452
- }, [y, _]), R(() => {
4453
- function e() {
4454
- x((e) => e + 1);
4455
- }
4456
- window.addEventListener("scroll", e, { passive: !0 }), window.addEventListener("resize", e);
4457
- let t = new ResizeObserver(e);
4458
- return t.observe(document.body), () => {
4459
- window.removeEventListener("scroll", e), window.removeEventListener("resize", e), t.disconnect();
4460
- };
4461
- }, []);
4462
- let k = B(() => {
4463
- g(null), f({ kind: "placing" });
4464
- }, []), A = B(() => {
4465
- f({ kind: "idle" }), g(null);
4466
- }, []), ee = B((e, t, n) => {
4467
- f({
4468
- kind: "composing-new",
4469
- coords: e,
4470
- pageX: t + window.scrollX,
4471
- pageY: n + window.scrollY,
4472
- screenshot: null,
4473
- screenshotCapturing: !0
4474
- }), ea(S.current != null && S.current.getRootNode() instanceof ShadowRoot ? S.current.getRootNode().host : null, {
4475
- x: t,
4476
- y: n
4477
- }).then((e) => {
4478
- f((t) => t.kind === "composing-new" ? {
4479
- ...t,
4480
- screenshot: e,
4481
- screenshotCapturing: !1
4482
- } : t);
4483
- });
4484
- }, []), j = B((e, t) => {
4485
- if (!s) return;
4486
- let n = {
4487
- ...s,
4488
- name: e,
4489
- email: t
4490
- };
4491
- Pr(n), c(n);
4492
- }, [s]), M = B(async () => {
4493
- g(null);
4494
- try {
4495
- let n = Aa(await Fr(e, t));
4496
- Pr(n), c(n);
4497
- } catch (e) {
4498
- g(e instanceof Error ? e.message : "Sign-in failed");
4499
- }
4500
- }, [e, t]), te = B(async (e, t) => {
4501
- if (!(d.kind !== "composing-new" || !s?.name)) {
4502
- m(!0), g(null);
4503
- try {
4504
- let n;
4505
- if (t && d.screenshot) {
4506
- let { uploadUrl: e } = await u.getScreenshotUploadUrl(), t = await fetch(e, {
4507
- method: "POST",
4508
- headers: { "Content-Type": d.screenshot.type || "image/png" },
4509
- body: d.screenshot
4510
- });
4511
- if (t.ok) {
4512
- let { storageId: e } = await t.json();
4513
- n = e;
4514
- }
4515
- }
4516
- let i = await u.createThread({
4517
- url: window.location.href,
4518
- route: r,
4519
- anchorSelector: d.coords.anchorSelector,
4520
- anchorX: d.coords.anchorX,
4521
- anchorY: d.coords.anchorY,
4522
- anchorOffsetX: d.coords.anchorOffsetX,
4523
- anchorOffsetY: d.coords.anchorOffsetY,
4524
- viewportW: d.coords.viewportW,
4525
- viewportY: d.coords.viewportY,
4526
- userAgent: navigator.userAgent,
4527
- authorName: s.name,
4528
- authorEmail: s.email,
4529
- body: e,
4530
- screenshotStorageId: n
4531
- });
4532
- o((e) => [...e, i.thread]), f({
4533
- kind: "thread",
4534
- threadId: i.thread._id
4535
- });
4536
- } catch (e) {
4537
- g(e instanceof Error ? e.message : "Failed to post");
4538
- } finally {
4539
- m(!1);
4540
- }
4541
- }
4542
- }, [
4543
- u,
4544
- s,
4545
- d,
4546
- r
4547
- ]), N = B(async () => {
4548
- if (d.kind !== "thread") return;
4549
- let e = d.threadId;
4550
- m(!0), g(null);
4551
- try {
4552
- await u.deleteThread(e), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4553
- } catch (e) {
4554
- g(e instanceof Error ? e.message : "Failed to delete");
4555
- } finally {
4556
- m(!1);
4557
- }
4558
- }, [u, d]), ne = B(async () => {
4559
- if (d.kind !== "thread") return;
4560
- let e = d.threadId;
4561
- m(!0), g(null);
4562
- try {
4563
- await u.resolveThread(e, s?.clientId), o((t) => t.filter((t) => t._id !== e)), f({ kind: "idle" });
4564
- } catch (e) {
4565
- g(e instanceof Error ? e.message : "Failed to resolve");
4566
- } finally {
4567
- m(!1);
4568
- }
4569
- }, [
4570
- u,
4571
- d,
4572
- s?.clientId
4573
- ]), re = B(async (e) => {
4574
- if (d.kind !== "thread" || !s?.name) return;
4575
- let t = d.threadId;
4576
- m(!0), g(null);
4577
- try {
4578
- let n = await u.addComment(t, {
4579
- body: e,
4580
- authorName: s.name,
4581
- authorEmail: s.email
4582
- });
4583
- o((e) => e.map((e) => e._id === t ? n.thread : e));
4584
- } catch (e) {
4585
- g(e instanceof Error ? e.message : "Failed to reply");
4586
- } finally {
4587
- m(!1);
4588
- }
4589
- }, [
4590
- u,
4591
- s,
4592
- d
4593
- ]), ie = B(async (e, t) => {
4594
- if (d.kind !== "thread" || !s) return;
4595
- let n = d.threadId;
4596
- m(!0), g(null);
4597
- try {
4598
- let r = await u.editComment(n, e, { body: t });
4599
- o((e) => e.map((e) => e._id === n ? r.thread : e));
4600
- } catch (e) {
4601
- throw g(e instanceof Error ? e.message : "Failed to edit"), e;
4602
- } finally {
4603
- m(!1);
4604
- }
4605
- }, [
4606
- u,
4607
- s,
4608
- d
4609
- ]), ae = B(async (e) => {
4610
- if (d.kind !== "thread" || !s) return;
4611
- let t = d.threadId;
4612
- m(!0), g(null);
4613
- try {
4614
- let n = await u.deleteComment(t, e);
4615
- o((e) => e.map((e) => e._id === t ? n.thread : e));
4616
- } catch (e) {
4617
- g(e instanceof Error ? e.message : "Failed to delete");
4618
- } finally {
4619
- m(!1);
4620
- }
4621
- }, [
4622
- u,
4623
- s,
4624
- d
4625
- ]), oe = B(async (e, t) => {
4626
- if (d.kind !== "thread" || !s) return;
4627
- let n = d.threadId;
4628
- g(null);
4629
- try {
4630
- let r = await u.toggleReaction(e, {
4631
- emoji: t,
4632
- authorName: s.name
4633
- });
4634
- o((e) => e.map((e) => e._id === n ? r.thread : e));
4635
- } catch (e) {
4636
- g(e instanceof Error ? e.message : "Failed to react");
4637
- }
4638
- }, [
4639
- u,
4640
- s,
4641
- d
4642
- ]), P = d.kind === "thread" ? a.find((e) => e._id === d.threadId) ?? null : null, se = w || s?.clientId != null && s.clientId === P?.authorClientId;
4643
- return /* @__PURE__ */ $("div", {
4644
- class: "markup-root",
4645
- ref: S,
4646
- children: [
4647
- d.kind === "placing" ? null : /* @__PURE__ */ $("div", {
4648
- class: "markup-pins-layer",
4649
- children: [_ ? null : a.map((e) => {
4650
- let t = d.kind === "thread" && d.threadId === e._id, n = Dr({
4651
- anchorX: e.anchorX,
4652
- anchorY: e.anchorY,
4653
- anchorSelector: e.anchorSelector,
4654
- anchorOffsetX: e.anchorOffsetX,
4655
- anchorOffsetY: e.anchorOffsetY
4656
- }), r = e.comments.reduce((e, t) => e + +!t.deleted, 0);
4657
- return /* @__PURE__ */ $(ya, {
4658
- pageX: n.pageX,
4659
- pageY: n.pageY,
4660
- count: r,
4661
- active: t,
4662
- onClick: () => f({
4663
- kind: "thread",
4664
- threadId: e._id
4665
- })
4666
- }, e._id);
4667
- }), d.kind === "composing-new" ? /* @__PURE__ */ $(ba, {
4668
- pageX: d.pageX,
4669
- pageY: d.pageY
4670
- }) : null]
4671
- }),
4672
- d.kind === "placing" ? /* @__PURE__ */ $(xa, {
4673
- onPlace: ee,
4674
- onCancel: A
4675
- }) : null,
4676
- d.kind === "thread" && P && !_ ? /* @__PURE__ */ $(Ca, {
4677
- thread: P,
4678
- authorName: C,
4679
- currentClientId: s?.clientId ?? null,
4680
- isVerified: w,
4681
- canDelete: se,
4682
- pending: p,
4683
- error: h,
4684
- onAuthor: j,
4685
- onSignIn: M,
4686
- onClose: A,
4687
- onReply: re,
4688
- onEditComment: ie,
4689
- onDeleteComment: ae,
4690
- onToggleReaction: oe,
4691
- onDelete: N,
4692
- onResolve: ne
4693
- }) : null,
4694
- d.kind === "composing-new" ? /* @__PURE__ */ $(_a, {
4695
- pageX: d.pageX,
4696
- pageY: d.pageY,
4697
- authorName: C,
4698
- isVerified: w,
4699
- pending: p,
4700
- error: h,
4701
- screenshot: d.screenshot,
4702
- screenshotCapturing: d.screenshotCapturing,
4703
- onAuthor: j,
4704
- onSignIn: M,
4705
- onSubmit: te,
4706
- onClose: A
4707
- }) : null,
4708
- !_ || d.kind === "placing" || d.kind === "composing-new" ? /* @__PURE__ */ $(da, {
4709
- active: d.kind === "placing",
4710
- onToggle: () => d.kind === "placing" ? A() : k(),
4711
- onHide: () => {
4712
- v(!0), b(!0);
4713
- },
4714
- position: n
4715
- }) : null,
4716
- _ && y ? /* @__PURE__ */ $(Ma, { position: n }) : null
4717
- ]
4718
- });
4719
- }
4720
- function Ma({ position: e }) {
4721
- let t = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
4722
- return /* @__PURE__ */ $("div", {
4723
- class: Q("markup-hud-hidden-toast", e === "bottom-left" ? "markup-hud-hidden-toast-left" : "markup-hud-hidden-toast-right"),
4724
- role: "status",
4725
- "aria-live": "polite",
4726
- children: [
4727
- "Markup hidden — press ",
4728
- /* @__PURE__ */ $("kbd", {
4729
- class: "markup-kbd",
4730
- children: t
4731
- }),
4732
- /* @__PURE__ */ $("kbd", {
4733
- class: "markup-kbd",
4734
- children: "."
4735
- }),
4736
- " or refresh to bring it back."
4737
- ]
4738
- });
4739
- }
4740
- //#endregion
4741
- //#region src/runtime/mount.tsx
4742
- function Na(e, t) {
4743
- e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "2147483647", e.style.pointerEvents = "none";
4744
- let n = t.theme ?? "auto";
4745
- n !== "auto" && (e.dataset.theme = n);
4746
- let r = e.attachShadow({ mode: "open" }), i = document.createElement("style");
4747
- i.textContent = de, r.appendChild(i);
4748
- let a = document.createElement("div");
4749
- a.className = "markup-shadow-root", r.appendChild(a);
4750
- let { theme: o, ...s } = t;
4751
- return ue(/* @__PURE__ */ $(ja, { ...s }), a), () => ue(null, a);
4752
- }
4753
- //#endregion
4754
- //#region src/widget.ts
4755
- var Pa = null, Fa = null;
4756
- function Ia(e) {
4757
- La();
4758
- let t = document.createElement("div");
4759
- return t.id = "markup-widget", document.body.appendChild(t), Fa = t, Pa = Na(t, e), La;
4760
- }
4761
- function La() {
4762
- Pa &&= (Pa(), null), Fa?.parentNode && Fa.parentNode.removeChild(Fa), Fa = null;
4763
- }
4764
- if (typeof document < "u") {
4765
- let e = document.currentScript ?? document.querySelector("script[data-markup-widget=\"true\"]"), t = e?.dataset.apiUrl, n = e?.dataset.apiKey;
4766
- if (t && n) {
4767
- let r = e?.dataset.position, i = e?.dataset.theme, a = () => Ia({
4768
- apiUrl: t,
4769
- apiKey: n,
4770
- position: r,
4771
- theme: i
4772
- });
4773
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a, { once: !0 }) : a();
4774
- }
4775
- }
4776
- //#endregion
4777
- //#region src/react.tsx
4778
- function Ra(t) {
4779
- return e(() => (Ia({
4780
- apiUrl: t.apiUrl,
4781
- apiKey: t.apiKey,
4782
- position: t.position,
4783
- theme: t.theme
4784
- }), () => La()), [
4785
- t.apiUrl,
4786
- t.apiKey,
4787
- t.position,
4788
- t.theme
4789
- ]), null;
4790
- }
4791
- //#endregion
4792
- export { Ra as MarkupWidget };