@backmatter/studio 0.0.20 → 0.0.22
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/chunks/{UiKitApp-C269OA8v.js → UiKitApp-CgGyJiC4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-B4B5jjje.js → WorkspaceRoutes-CzCBnhNt.js} +26364 -25362
- package/dist/chunks/dashboard-w-mlsGky.js +1879 -0
- package/dist/chunks/{index-7-TtXaMq.js → index-_XfFuFSU.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +205 -194
- package/dist/site-widget.css +208 -0
- package/dist/site-widget.js +10495 -9947
- package/dist/studio.css +304 -32
- package/package.json +2 -2
- package/src/App.tsx +7 -1
- package/src/api.ts +106 -13
- package/src/chat/ChatFiles.tsx +261 -0
- package/src/chat/ChatMessage.tsx +5 -0
- package/src/chat/ChatPanel.tsx +218 -14
- package/src/chat/ChatProvider.tsx +72 -22
- package/src/chat/Composer.tsx +83 -6
- package/src/chat/PendingFileRow.tsx +188 -0
- package/src/chat/chat-context.ts +7 -1
- package/src/chat/chat-helpers.ts +49 -0
- package/src/chat/chat-state.ts +17 -6
- package/src/chat/icons.tsx +28 -0
- package/src/chat/model-copy.ts +41 -0
- package/src/chat/pending-files.ts +236 -0
- package/src/chat/side-width.ts +48 -0
- package/src/chrome/AppShell.tsx +9 -1
- package/src/chrome/CommandPalette.tsx +7 -0
- package/src/chrome/ContentExplorerSidebar.tsx +43 -74
- package/src/chrome/folder-create-context.ts +56 -11
- package/src/chrome/hotkeys.ts +8 -0
- package/src/fields/FieldControl.tsx +331 -115
- package/src/fields/LinkFieldInput.tsx +185 -29
- package/src/fields/array-item-title.ts +28 -0
- package/src/fields/field-label.ts +8 -0
- package/src/host-pointer.ts +2 -0
- package/src/install-preview-pointer.ts +1 -0
- package/src/pages/BlockPicker.tsx +362 -0
- package/src/pages/BlocksList.tsx +39 -67
- package/src/pages/CliAuthorizePage.tsx +138 -25
- package/src/pages/DocEditorPage.tsx +95 -18
- package/src/pages/EmbedPublishPage.tsx +40 -2
- package/src/pages/LoginPage.tsx +118 -31
- package/src/pages/MediaFieldInput.tsx +1 -1
- package/src/pages/MediaGalleryPage.tsx +36 -3
- package/src/pages/SettingsSchemaPage.tsx +19 -3
- package/src/pages/WorkspaceLayout.tsx +16 -1
- package/src/pages/block-picker.ts +116 -0
- package/src/pages/editor-grab.ts +61 -13
- package/src/pages/preview-split.ts +24 -0
- package/src/pages/session-preview.ts +1 -0
- package/src/replica/types.ts +2 -0
- package/src/sign-in-link.ts +45 -0
- package/src/site-pointer.ts +14 -1
- package/src/site-widget.tsx +12 -1
- package/src/ui/Field.tsx +26 -0
- package/src/ui/Input.tsx +134 -35
- package/src/workspace/schema-source.tsx +126 -0
- package/dist/chunks/dashboard-DeNgythd.js +0 -1779
- package/src/site-devbar-overlay-inject.ts +0 -15
- package/src/site-publish-menu.tsx +0 -33
|
@@ -0,0 +1,1879 @@
|
|
|
1
|
+
var rt = Object.defineProperty;
|
|
2
|
+
var st = (e, t, n) => t in e ? rt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var $ = (e, t, n) => st(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsxs as w, jsx as i, Fragment as re } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as qe, useCallback as it, useSyncExternalStore as at, useState as E, useEffect as W, lazy as ot, Suspense as lt } from "react";
|
|
6
|
+
import { X as Ie, V as R, k as ze, an as Be, ao as be, ap as ct, aq as ut, ar as Fe, as as Me, at as De, au as dt, av as ft, P as He, aw as ht, ax as ae, ah as K, Z as We, ay as xt, az as $e, ai as pt, ak as se, aa as Q, ab as Z, Y as oe, aA as gt, W as F, aB as mt, J as we, aC as ee, aj as yt, aD as vt, aE as bt, aF as wt, aG as kt, aH as St, f as Rt, aI as Et, a6 as _t, aJ as jt, aK as Tt, z as Pt, B as Ot, I as Lt, aL as Nt, aM as Ut, aN as At, K as Ct, aO as qt, R as It, L as zt, M as Bt, N as Ft, O as D, Q as Mt, U as Dt } from "./WorkspaceRoutes-CzCBnhNt.js";
|
|
7
|
+
const te = /* @__PURE__ */ Object.create(null), G = (e) => {
|
|
8
|
+
var t, n;
|
|
9
|
+
return ((t = globalThis.process) == null ? void 0 : t.env) || ((n = globalThis.Deno) == null ? void 0 : n.env.toObject()) || globalThis.__env__ || (e ? te : globalThis);
|
|
10
|
+
}, B = new Proxy(te, {
|
|
11
|
+
get(e, t) {
|
|
12
|
+
return G()[t] ?? te[t];
|
|
13
|
+
},
|
|
14
|
+
has(e, t) {
|
|
15
|
+
return t in G() || t in te;
|
|
16
|
+
},
|
|
17
|
+
set(e, t, n) {
|
|
18
|
+
const r = G(!0);
|
|
19
|
+
return r[t] = n, !0;
|
|
20
|
+
},
|
|
21
|
+
deleteProperty(e, t) {
|
|
22
|
+
if (!t) return !1;
|
|
23
|
+
const n = G(!0);
|
|
24
|
+
return delete n[t], !0;
|
|
25
|
+
},
|
|
26
|
+
ownKeys() {
|
|
27
|
+
const e = G(!0);
|
|
28
|
+
return Object.keys(e);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
B.NODE_ENV;
|
|
32
|
+
var ne = class extends Error {
|
|
33
|
+
constructor(e, t) {
|
|
34
|
+
super(e, t), this.name = "BetterAuthError", this.message = e, this.stack = "";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const Ht = 47;
|
|
38
|
+
function Ge(e) {
|
|
39
|
+
let t = e.length;
|
|
40
|
+
for (; t > 0 && e.charCodeAt(t - 1) === Ht; ) t--;
|
|
41
|
+
return t === e.length ? e : e.slice(0, t);
|
|
42
|
+
}
|
|
43
|
+
function Wt(e) {
|
|
44
|
+
try {
|
|
45
|
+
return (Ge(new URL(e).pathname) || "/") !== "/";
|
|
46
|
+
} catch {
|
|
47
|
+
throw new ne(`Invalid base URL: ${e}. Please provide a valid base URL.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function $t(e) {
|
|
51
|
+
try {
|
|
52
|
+
const t = new URL(e);
|
|
53
|
+
if (t.protocol !== "http:" && t.protocol !== "https:") throw new ne(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`);
|
|
54
|
+
} catch (t) {
|
|
55
|
+
throw t instanceof ne ? t : new ne(`Invalid base URL: ${e}. Please provide a valid base URL.`, { cause: t });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function le(e, t = "/api/auth") {
|
|
59
|
+
if ($t(e), Wt(e)) return e;
|
|
60
|
+
const n = Ge(e);
|
|
61
|
+
return !t || t === "/" ? n : (t = t.startsWith("/") ? t : `/${t}`, `${n}${t}`);
|
|
62
|
+
}
|
|
63
|
+
function Gt(e, t, n, r, s) {
|
|
64
|
+
if (e) return le(e, t);
|
|
65
|
+
{
|
|
66
|
+
const a = B.BETTER_AUTH_URL || B.NEXT_PUBLIC_BETTER_AUTH_URL || B.PUBLIC_BETTER_AUTH_URL || B.NUXT_PUBLIC_BETTER_AUTH_URL || B.NUXT_PUBLIC_AUTH_URL || (B.BASE_URL !== "/" ? B.BASE_URL : void 0);
|
|
67
|
+
if (a) return le(a, t);
|
|
68
|
+
}
|
|
69
|
+
if (typeof window < "u" && window.location) return le(window.location.origin, t);
|
|
70
|
+
}
|
|
71
|
+
const Vt = {
|
|
72
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
73
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
74
|
+
protoShort: /"__proto__"\s*:/,
|
|
75
|
+
constructorShort: /"constructor"\s*:/
|
|
76
|
+
}, Jt = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/, ke = {
|
|
77
|
+
true: !0,
|
|
78
|
+
false: !1,
|
|
79
|
+
null: null,
|
|
80
|
+
undefined: void 0,
|
|
81
|
+
nan: NaN,
|
|
82
|
+
infinity: Number.POSITIVE_INFINITY,
|
|
83
|
+
"-infinity": Number.NEGATIVE_INFINITY
|
|
84
|
+
}, Kt = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
85
|
+
function Xt(e) {
|
|
86
|
+
return e instanceof Date && !isNaN(e.getTime());
|
|
87
|
+
}
|
|
88
|
+
function Yt(e) {
|
|
89
|
+
const t = Kt.exec(e);
|
|
90
|
+
if (!t) return null;
|
|
91
|
+
const [, n, r, s, a, l, d, o, u, c, p] = t, x = new Date(Date.UTC(parseInt(n, 10), parseInt(r, 10) - 1, parseInt(s, 10), parseInt(a, 10), parseInt(l, 10), parseInt(d, 10), o ? parseInt(o.padEnd(3, "0"), 10) : 0));
|
|
92
|
+
if (u) {
|
|
93
|
+
const h = (parseInt(c, 10) * 60 + parseInt(p, 10)) * (u === "+" ? -1 : 1);
|
|
94
|
+
x.setUTCMinutes(x.getUTCMinutes() + h);
|
|
95
|
+
}
|
|
96
|
+
return Xt(x) ? x : null;
|
|
97
|
+
}
|
|
98
|
+
function Qt(e, t = {}) {
|
|
99
|
+
const { strict: n = !1, warnings: r = !1, reviver: s, parseDates: a = !0 } = t;
|
|
100
|
+
if (typeof e != "string") return e;
|
|
101
|
+
const l = e.trim(), d = l.toLowerCase();
|
|
102
|
+
if (d.length <= 9 && d in ke) return ke[d];
|
|
103
|
+
if (!Jt.test(l)) {
|
|
104
|
+
if (n) throw new SyntaxError("[better-json] Invalid JSON");
|
|
105
|
+
return e;
|
|
106
|
+
}
|
|
107
|
+
if (Object.entries(Vt).some(([o, u]) => {
|
|
108
|
+
const c = u.test(l);
|
|
109
|
+
return c && r && console.warn(`[better-json] Detected potential prototype pollution attempt using ${o} pattern`), c;
|
|
110
|
+
}) && n) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
111
|
+
try {
|
|
112
|
+
return JSON.parse(l, (u, c) => {
|
|
113
|
+
if (u === "__proto__" || u === "constructor" && c && typeof c == "object" && "prototype" in c) {
|
|
114
|
+
r && console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (a && typeof c == "string") {
|
|
118
|
+
const p = Yt(c);
|
|
119
|
+
if (p) return p;
|
|
120
|
+
}
|
|
121
|
+
return s ? s(u, c) : c;
|
|
122
|
+
});
|
|
123
|
+
} catch (o) {
|
|
124
|
+
if (n) throw o;
|
|
125
|
+
return e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function Zt(e, t = { strict: !0 }) {
|
|
129
|
+
return Qt(e, t);
|
|
130
|
+
}
|
|
131
|
+
const en = [
|
|
132
|
+
"javascript:",
|
|
133
|
+
"data:",
|
|
134
|
+
"vbscript:"
|
|
135
|
+
];
|
|
136
|
+
function tn(e) {
|
|
137
|
+
let t;
|
|
138
|
+
try {
|
|
139
|
+
t = new URL(e);
|
|
140
|
+
} catch {
|
|
141
|
+
return !0;
|
|
142
|
+
}
|
|
143
|
+
return !en.includes(t.protocol);
|
|
144
|
+
}
|
|
145
|
+
const nn = {
|
|
146
|
+
id: "redirect",
|
|
147
|
+
name: "Redirect",
|
|
148
|
+
hooks: { onSuccess(e) {
|
|
149
|
+
var t, n;
|
|
150
|
+
if ((t = e.data) != null && t.url && ((n = e.data) != null && n.redirect) && tn(e.data.url) && typeof window < "u" && window.location && window.location)
|
|
151
|
+
try {
|
|
152
|
+
window.location.href = e.data.url;
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
} }
|
|
156
|
+
};
|
|
157
|
+
let q = [], V = 0;
|
|
158
|
+
const me = 4, rn = globalThis.nanostoresGlobal || (globalThis.nanostoresGlobal = { epoch: 0 });
|
|
159
|
+
let sn = () => {
|
|
160
|
+
let e, t;
|
|
161
|
+
for (; V < q.length; ) {
|
|
162
|
+
t = V, V += me;
|
|
163
|
+
try {
|
|
164
|
+
q[t](
|
|
165
|
+
q[t + 1].value,
|
|
166
|
+
q[t + 2],
|
|
167
|
+
q[t + 3]
|
|
168
|
+
);
|
|
169
|
+
} catch (n) {
|
|
170
|
+
e = n;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (q.length = V = 0, e) throw e;
|
|
174
|
+
};
|
|
175
|
+
const Se = /* @__NO_SIDE_EFFECTS__ */ (e) => {
|
|
176
|
+
let t = [], n = {
|
|
177
|
+
eq: Object.is,
|
|
178
|
+
get() {
|
|
179
|
+
return n.lc || n.listen(() => {
|
|
180
|
+
})(), n.value;
|
|
181
|
+
},
|
|
182
|
+
init: e,
|
|
183
|
+
lc: 0,
|
|
184
|
+
listen(r) {
|
|
185
|
+
return n.lc = t.push(r), () => {
|
|
186
|
+
for (let a = V; a < q.length; )
|
|
187
|
+
q[a] === r ? q.splice(a, me) : a += me;
|
|
188
|
+
let s = t.indexOf(r);
|
|
189
|
+
~s && (t.splice(s, 1), --n.lc || n.off());
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
notify(r, s) {
|
|
193
|
+
rn.epoch++;
|
|
194
|
+
let a = !q.length && !0;
|
|
195
|
+
for (let l of t)
|
|
196
|
+
q.push(
|
|
197
|
+
l,
|
|
198
|
+
n,
|
|
199
|
+
r,
|
|
200
|
+
s
|
|
201
|
+
);
|
|
202
|
+
a && sn();
|
|
203
|
+
},
|
|
204
|
+
/* It will be called on last listener unsubscribing.
|
|
205
|
+
We will redefine it in onMount and onStop. */
|
|
206
|
+
off() {
|
|
207
|
+
},
|
|
208
|
+
set(r) {
|
|
209
|
+
let s = n.value;
|
|
210
|
+
n.eq(s, r) || (n.value = r, n.notify(s));
|
|
211
|
+
},
|
|
212
|
+
subscribe(r) {
|
|
213
|
+
let s = n.listen(r);
|
|
214
|
+
return r(n.value), s;
|
|
215
|
+
},
|
|
216
|
+
value: e
|
|
217
|
+
};
|
|
218
|
+
return n;
|
|
219
|
+
}, an = 2, on = 5, X = 6, Y = 10;
|
|
220
|
+
let Ve = (e, t, n, r) => (e.events = e.events || {}, e.events[n + Y] || (e.events[n + Y] = r((s) => {
|
|
221
|
+
e.events[n].reduceRight((a, l) => (l(a), a), {
|
|
222
|
+
shared: {},
|
|
223
|
+
...s
|
|
224
|
+
});
|
|
225
|
+
})), e.events[n] = e.events[n] || [], e.events[n].push(t), () => {
|
|
226
|
+
let s = e.events[n], a = s.indexOf(t);
|
|
227
|
+
~a && (s.splice(a, 1), s.length || (e.events[n + Y](), delete e.events[n + Y]));
|
|
228
|
+
}), ln = (e, t) => Ve(e, t, an, (n) => {
|
|
229
|
+
let r = e.set, s = e.setKey;
|
|
230
|
+
return e.setKey && (e.setKey = (a, l) => {
|
|
231
|
+
let d;
|
|
232
|
+
if (n({
|
|
233
|
+
abort: () => {
|
|
234
|
+
d = !0;
|
|
235
|
+
},
|
|
236
|
+
changed: a,
|
|
237
|
+
newValue: { ...e.value, [a]: l }
|
|
238
|
+
}), !d) return s(a, l);
|
|
239
|
+
}), e.set = (a) => {
|
|
240
|
+
let l;
|
|
241
|
+
if (n({ abort: () => {
|
|
242
|
+
l = !0;
|
|
243
|
+
}, newValue: a }), !l) return r(a);
|
|
244
|
+
}, () => {
|
|
245
|
+
e.set = r, e.setKey = s;
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
const Je = 1e3;
|
|
249
|
+
let cn = (e, t) => Ve(e, (r) => {
|
|
250
|
+
let s = t(r);
|
|
251
|
+
s && e.events[X].push(s);
|
|
252
|
+
}, on, (r) => {
|
|
253
|
+
let s = e.listen;
|
|
254
|
+
e.listen = (...l) => (!e.lc && !e.active && (e.active = !0, r()), s(...l));
|
|
255
|
+
let a = e.off;
|
|
256
|
+
return e.events[X] = [], e.off = () => {
|
|
257
|
+
a(), setTimeout(() => {
|
|
258
|
+
if (e.active && !e.lc) {
|
|
259
|
+
e.active = !1;
|
|
260
|
+
for (let l of e.events[X]) l();
|
|
261
|
+
e.events[X] = [];
|
|
262
|
+
}
|
|
263
|
+
}, Je);
|
|
264
|
+
}, () => {
|
|
265
|
+
e.listen = s, e.off = a;
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
function Re(e, t) {
|
|
269
|
+
let n = un(t), r = e;
|
|
270
|
+
for (let s of n) {
|
|
271
|
+
if (r == null)
|
|
272
|
+
return;
|
|
273
|
+
r = r[s];
|
|
274
|
+
}
|
|
275
|
+
return r;
|
|
276
|
+
}
|
|
277
|
+
const Ee = /(.*)\[(\d+)\]/;
|
|
278
|
+
function un(e) {
|
|
279
|
+
return e.split(".").flatMap((t) => Ke(t));
|
|
280
|
+
}
|
|
281
|
+
function Ke(e) {
|
|
282
|
+
if (Ee.test(e)) {
|
|
283
|
+
let [, t, n] = e.match(Ee);
|
|
284
|
+
return [...Ke(t), n];
|
|
285
|
+
}
|
|
286
|
+
return [e];
|
|
287
|
+
}
|
|
288
|
+
function dn(e, t, n) {
|
|
289
|
+
let r = new Set(t);
|
|
290
|
+
return e.listen((s, a, l) => {
|
|
291
|
+
(l === void 0 ? t.some(
|
|
292
|
+
(d) => a === void 0 || // `map` keys are plain properties, but a `deepMap` key is a path into
|
|
293
|
+
// the value, where a plain lookup would compare undefined to undefined
|
|
294
|
+
// and never report a change.
|
|
295
|
+
s[d] !== a[d] || Re(s, d) !== Re(a, d)
|
|
296
|
+
) : r.has(l) || r.has(l.split(/\.|\[/)[0])) && n(s, a, l);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function _e(e) {
|
|
300
|
+
if (typeof e != "object" || e === null) return !1;
|
|
301
|
+
const t = Object.getPrototypeOf(e);
|
|
302
|
+
return t === Object.prototype || t === null;
|
|
303
|
+
}
|
|
304
|
+
function ie(e, t) {
|
|
305
|
+
if (e === t) return !0;
|
|
306
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
307
|
+
if (e.length !== t.length) return !1;
|
|
308
|
+
for (let n = 0; n < e.length; n++) if (!ie(e[n], t[n])) return !1;
|
|
309
|
+
return !0;
|
|
310
|
+
}
|
|
311
|
+
if (_e(e) && _e(t)) {
|
|
312
|
+
const n = Object.keys(e), r = Object.keys(t);
|
|
313
|
+
if (n.length !== r.length) return !1;
|
|
314
|
+
for (const s of n) if (!(s in t) || !ie(e[s], t[s])) return !1;
|
|
315
|
+
return !0;
|
|
316
|
+
}
|
|
317
|
+
return !1;
|
|
318
|
+
}
|
|
319
|
+
function fn(e, t) {
|
|
320
|
+
return ln(e, ({ newValue: n, abort: r }) => {
|
|
321
|
+
t(e.value, n) && r();
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const ce = Symbol.for("better-auth:broadcast-channel"), hn = () => Math.floor(Date.now() / 1e3);
|
|
325
|
+
var xn = class {
|
|
326
|
+
constructor(e = "better-auth.message") {
|
|
327
|
+
$(this, "listeners", /* @__PURE__ */ new Set());
|
|
328
|
+
$(this, "name");
|
|
329
|
+
this.name = e;
|
|
330
|
+
}
|
|
331
|
+
subscribe(e) {
|
|
332
|
+
return this.listeners.add(e), () => {
|
|
333
|
+
this.listeners.delete(e);
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
post(e) {
|
|
337
|
+
if (!(typeof window > "u"))
|
|
338
|
+
try {
|
|
339
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
340
|
+
...e,
|
|
341
|
+
timestamp: hn()
|
|
342
|
+
}));
|
|
343
|
+
} catch {
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
setup() {
|
|
347
|
+
if (typeof window > "u" || typeof window.addEventListener > "u") return () => {
|
|
348
|
+
};
|
|
349
|
+
const e = (t) => {
|
|
350
|
+
if (t.key !== this.name) return;
|
|
351
|
+
const n = JSON.parse(t.newValue ?? "{}");
|
|
352
|
+
(n == null ? void 0 : n.event) !== "session" || !(n != null && n.data) || this.listeners.forEach((r) => r(n));
|
|
353
|
+
};
|
|
354
|
+
return window.addEventListener("storage", e), () => {
|
|
355
|
+
window.removeEventListener("storage", e);
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
function ue(e = "better-auth.message") {
|
|
360
|
+
return globalThis[ce] || (globalThis[ce] = new xn(e)), globalThis[ce];
|
|
361
|
+
}
|
|
362
|
+
const de = Symbol.for("better-auth:focus-manager");
|
|
363
|
+
var pn = class {
|
|
364
|
+
constructor() {
|
|
365
|
+
$(this, "listeners", /* @__PURE__ */ new Set());
|
|
366
|
+
}
|
|
367
|
+
subscribe(e) {
|
|
368
|
+
return this.listeners.add(e), () => {
|
|
369
|
+
this.listeners.delete(e);
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
setFocused(e) {
|
|
373
|
+
this.listeners.forEach((t) => t(e));
|
|
374
|
+
}
|
|
375
|
+
setup() {
|
|
376
|
+
if (typeof window > "u" || typeof document > "u" || typeof window.addEventListener > "u") return () => {
|
|
377
|
+
};
|
|
378
|
+
const e = () => {
|
|
379
|
+
document.visibilityState === "visible" && this.setFocused(!0);
|
|
380
|
+
};
|
|
381
|
+
return document.addEventListener("visibilitychange", e, !1), () => {
|
|
382
|
+
document.removeEventListener("visibilitychange", e, !1);
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
function je() {
|
|
387
|
+
return globalThis[de] || (globalThis[de] = new pn()), globalThis[de];
|
|
388
|
+
}
|
|
389
|
+
const fe = Symbol.for("better-auth:online-manager");
|
|
390
|
+
var gn = class {
|
|
391
|
+
constructor() {
|
|
392
|
+
$(this, "listeners", /* @__PURE__ */ new Set());
|
|
393
|
+
$(this, "isOnline", typeof navigator < "u" ? navigator.onLine : !0);
|
|
394
|
+
}
|
|
395
|
+
subscribe(e) {
|
|
396
|
+
return this.listeners.add(e), () => {
|
|
397
|
+
this.listeners.delete(e);
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
setOnline(e) {
|
|
401
|
+
this.isOnline = e, this.listeners.forEach((t) => t(e));
|
|
402
|
+
}
|
|
403
|
+
setup() {
|
|
404
|
+
if (typeof window > "u" || typeof window.addEventListener > "u") return () => {
|
|
405
|
+
};
|
|
406
|
+
const e = () => this.setOnline(!0), t = () => this.setOnline(!1);
|
|
407
|
+
return window.addEventListener("online", e, !1), window.addEventListener("offline", t, !1), () => {
|
|
408
|
+
window.removeEventListener("online", e, !1), window.removeEventListener("offline", t, !1);
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
function he() {
|
|
413
|
+
return globalThis[fe] || (globalThis[fe] = new gn()), globalThis[fe];
|
|
414
|
+
}
|
|
415
|
+
const xe = () => Math.floor(Date.now() / 1e3), mn = 5;
|
|
416
|
+
function yn(e) {
|
|
417
|
+
var j, b, _;
|
|
418
|
+
const { fetchSession: t, shouldPollSession: n = () => !0, sessionSignal: r, options: s = {} } = e, a = ((j = s.sessionOptions) == null ? void 0 : j.refetchInterval) ?? 0, l = ((b = s.sessionOptions) == null ? void 0 : b.refetchOnWindowFocus) ?? !0, d = ((_ = s.sessionOptions) == null ? void 0 : _.refetchWhenOffline) ?? !1, o = {
|
|
419
|
+
isInitialized: !1,
|
|
420
|
+
lastSessionRequest: 0
|
|
421
|
+
}, u = () => d || he().isOnline, c = (m) => {
|
|
422
|
+
if (u()) {
|
|
423
|
+
if ((m == null ? void 0 : m.event) === "storage") {
|
|
424
|
+
t();
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if ((m == null ? void 0 : m.event) === "poll") {
|
|
428
|
+
o.lastSessionRequest = xe(), t();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if ((m == null ? void 0 : m.event) === "visibilitychange") {
|
|
432
|
+
if (xe() - o.lastSessionRequest < mn) return;
|
|
433
|
+
o.lastSessionRequest = xe(), t();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
t();
|
|
437
|
+
}
|
|
438
|
+
}, p = (m) => {
|
|
439
|
+
ue().post({
|
|
440
|
+
event: "session",
|
|
441
|
+
data: { trigger: m },
|
|
442
|
+
clientId: Math.random().toString(36).substring(7)
|
|
443
|
+
});
|
|
444
|
+
}, x = () => {
|
|
445
|
+
a && a > 0 && (o.pollInterval = setInterval(() => {
|
|
446
|
+
n() && c({ event: "poll" });
|
|
447
|
+
}, a * 1e3));
|
|
448
|
+
}, h = () => {
|
|
449
|
+
o.unsubscribeBroadcast = ue().subscribe(() => {
|
|
450
|
+
c({ event: "storage" });
|
|
451
|
+
});
|
|
452
|
+
}, g = () => {
|
|
453
|
+
l && (o.unsubscribeFocus = je().subscribe(() => {
|
|
454
|
+
c({ event: "visibilitychange" });
|
|
455
|
+
}));
|
|
456
|
+
}, v = () => {
|
|
457
|
+
o.unsubscribeOnline = he().subscribe((m) => {
|
|
458
|
+
m && c({ event: "visibilitychange" });
|
|
459
|
+
});
|
|
460
|
+
}, y = () => {
|
|
461
|
+
o.unsubscribeSignal = r.listen(() => {
|
|
462
|
+
t();
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
return {
|
|
466
|
+
init: () => {
|
|
467
|
+
o.isInitialized || (o.isInitialized = !0, x(), h(), g(), v(), y(), o.cleanupBroadcastSetup = ue().setup(), o.cleanupFocusSetup = je().setup(), o.cleanupOnlineSetup = he().setup());
|
|
468
|
+
},
|
|
469
|
+
cleanup: () => {
|
|
470
|
+
o.isInitialized && (o.pollInterval && (clearInterval(o.pollInterval), o.pollInterval = void 0), o.unsubscribeBroadcast && (o.unsubscribeBroadcast(), o.unsubscribeBroadcast = void 0), o.unsubscribeFocus && (o.unsubscribeFocus(), o.unsubscribeFocus = void 0), o.unsubscribeOnline && (o.unsubscribeOnline(), o.unsubscribeOnline = void 0), o.unsubscribeSignal && (o.unsubscribeSignal(), o.unsubscribeSignal = void 0), o.cleanupBroadcastSetup && (o.cleanupBroadcastSetup(), o.cleanupBroadcastSetup = void 0), o.cleanupFocusSetup && (o.cleanupFocusSetup(), o.cleanupFocusSetup = void 0), o.cleanupOnlineSetup && (o.cleanupOnlineSetup(), o.cleanupOnlineSetup = void 0), o.isInitialized = !1, o.lastSessionRequest = 0);
|
|
471
|
+
},
|
|
472
|
+
triggerRefetch: c,
|
|
473
|
+
broadcastSessionUpdate: p
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const vn = () => typeof window > "u", bn = Je;
|
|
477
|
+
function wn(e, t) {
|
|
478
|
+
if (typeof window > "u") return;
|
|
479
|
+
const n = e.get();
|
|
480
|
+
n.data !== null || t === null || e.set({
|
|
481
|
+
...n,
|
|
482
|
+
data: t,
|
|
483
|
+
error: null,
|
|
484
|
+
isPending: !1
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
function Te(e) {
|
|
488
|
+
return typeof e == "object" && e !== null && "data" in e && "error" in e ? e : {
|
|
489
|
+
data: e,
|
|
490
|
+
error: null
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function kn(e) {
|
|
494
|
+
return !e || e.session === null && e.user === null ? null : e;
|
|
495
|
+
}
|
|
496
|
+
function Sn(e, t) {
|
|
497
|
+
return ie(e.data, t.data) && e.error === t.error && e.isPending === t.isPending && e.isRefetching === t.isRefetching && e.refetch === t.refetch;
|
|
498
|
+
}
|
|
499
|
+
function Rn(e, t) {
|
|
500
|
+
const n = /* @__PURE__ */ Se(!1);
|
|
501
|
+
let r, s = 0, a = 0;
|
|
502
|
+
n.listen(() => {
|
|
503
|
+
a++, s = 0;
|
|
504
|
+
});
|
|
505
|
+
const l = (h) => c(h), d = /* @__PURE__ */ Se({
|
|
506
|
+
data: null,
|
|
507
|
+
error: null,
|
|
508
|
+
isPending: !0,
|
|
509
|
+
isRefetching: !1,
|
|
510
|
+
refetch: l
|
|
511
|
+
});
|
|
512
|
+
fn(d, Sn);
|
|
513
|
+
const o = async (h, g) => {
|
|
514
|
+
const v = d.value;
|
|
515
|
+
if (d.set({
|
|
516
|
+
...v,
|
|
517
|
+
isPending: v.data === null,
|
|
518
|
+
isRefetching: !0,
|
|
519
|
+
error: null,
|
|
520
|
+
refetch: l
|
|
521
|
+
}), h.aborted) return "aborted";
|
|
522
|
+
try {
|
|
523
|
+
const y = await e("/get-session", {
|
|
524
|
+
method: "GET",
|
|
525
|
+
query: g == null ? void 0 : g.query,
|
|
526
|
+
signal: h
|
|
527
|
+
});
|
|
528
|
+
if (h.aborted) return "aborted";
|
|
529
|
+
let { data: k, error: P } = Te(y), j = "fresh";
|
|
530
|
+
if (k != null && k.needsRefresh) try {
|
|
531
|
+
const T = await e("/get-session", {
|
|
532
|
+
method: "POST",
|
|
533
|
+
signal: h
|
|
534
|
+
});
|
|
535
|
+
if (h.aborted) return "aborted";
|
|
536
|
+
({ data: k, error: P } = Te(T));
|
|
537
|
+
} catch {
|
|
538
|
+
if (h.aborted) return "aborted";
|
|
539
|
+
j = "stale";
|
|
540
|
+
}
|
|
541
|
+
if (P) {
|
|
542
|
+
const T = d.value, N = (P == null ? void 0 : P.status) === 401;
|
|
543
|
+
return d.set({
|
|
544
|
+
data: N ? null : T.data,
|
|
545
|
+
error: P,
|
|
546
|
+
isPending: !1,
|
|
547
|
+
isRefetching: !1,
|
|
548
|
+
refetch: l
|
|
549
|
+
}), "failed";
|
|
550
|
+
}
|
|
551
|
+
const b = kn(k), _ = d.value, m = _.data != null && b != null && ie(_.data, b) ? _.data : b;
|
|
552
|
+
return d.set({
|
|
553
|
+
data: m,
|
|
554
|
+
error: null,
|
|
555
|
+
isPending: !1,
|
|
556
|
+
isRefetching: !1,
|
|
557
|
+
refetch: l
|
|
558
|
+
}), j;
|
|
559
|
+
} catch (y) {
|
|
560
|
+
if (h.aborted) return "aborted";
|
|
561
|
+
const k = d.value;
|
|
562
|
+
return d.set({
|
|
563
|
+
data: k.data,
|
|
564
|
+
error: y,
|
|
565
|
+
isPending: !1,
|
|
566
|
+
isRefetching: !1,
|
|
567
|
+
refetch: l
|
|
568
|
+
}), "failed";
|
|
569
|
+
}
|
|
570
|
+
}, u = () => {
|
|
571
|
+
var v, y;
|
|
572
|
+
const h = (y = (v = d.value.data) == null ? void 0 : v.session) == null ? void 0 : y.expiresAt, g = h instanceof Date ? h.getTime() : Number.POSITIVE_INFINITY;
|
|
573
|
+
return Math.min(Date.now() + bn, g);
|
|
574
|
+
}, c = (h) => {
|
|
575
|
+
s = 0, r == null || r.cancel();
|
|
576
|
+
const g = new AbortController(), v = {
|
|
577
|
+
cancel: () => g.abort(),
|
|
578
|
+
promise: Promise.resolve().then(() => g.signal.aborted ? "aborted" : o(g.signal, h)),
|
|
579
|
+
revision: a
|
|
580
|
+
};
|
|
581
|
+
r = v;
|
|
582
|
+
const y = (k) => {
|
|
583
|
+
r === v && (r = void 0, k === "fresh" && v.revision === a && (s = u()));
|
|
584
|
+
};
|
|
585
|
+
return v.promise.then(y, () => y("failed")), v.promise.then(() => {
|
|
586
|
+
});
|
|
587
|
+
}, p = () => (r == null ? void 0 : r.revision) === a ? r.promise.then(() => {
|
|
588
|
+
}) : Date.now() < s ? Promise.resolve() : c();
|
|
589
|
+
let x = () => {
|
|
590
|
+
};
|
|
591
|
+
return cn(d, () => {
|
|
592
|
+
let h;
|
|
593
|
+
vn() || (h = setTimeout(() => {
|
|
594
|
+
p();
|
|
595
|
+
}, 0));
|
|
596
|
+
const g = yn({
|
|
597
|
+
fetchSession: c,
|
|
598
|
+
shouldPollSession: () => d.value.data != null,
|
|
599
|
+
sessionSignal: n,
|
|
600
|
+
options: t
|
|
601
|
+
});
|
|
602
|
+
return g.init(), x = g.broadcastSessionUpdate, () => {
|
|
603
|
+
h && clearTimeout(h), g.cleanup();
|
|
604
|
+
};
|
|
605
|
+
}), {
|
|
606
|
+
session: d,
|
|
607
|
+
$sessionSignal: n,
|
|
608
|
+
broadcastSessionUpdate: (h) => x(h)
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function pe(e) {
|
|
612
|
+
if (e === null || typeof e != "object")
|
|
613
|
+
return !1;
|
|
614
|
+
const t = Object.getPrototypeOf(e);
|
|
615
|
+
return t !== null && t !== Object.prototype && Object.getPrototypeOf(t) !== null || Symbol.iterator in e ? !1 : Symbol.toStringTag in e ? Object.prototype.toString.call(e) === "[object Module]" : !0;
|
|
616
|
+
}
|
|
617
|
+
function ye(e, t, n = ".", r) {
|
|
618
|
+
if (!pe(t))
|
|
619
|
+
return ye(e, {}, n, r);
|
|
620
|
+
const s = { ...t };
|
|
621
|
+
for (const a of Object.keys(e)) {
|
|
622
|
+
if (a === "__proto__" || a === "constructor")
|
|
623
|
+
continue;
|
|
624
|
+
const l = e[a];
|
|
625
|
+
l != null && (r && r(s, a, l, n) || (Array.isArray(l) && Array.isArray(s[a]) ? s[a] = [...l, ...s[a]] : pe(l) && pe(s[a]) ? s[a] = ye(
|
|
626
|
+
l,
|
|
627
|
+
s[a],
|
|
628
|
+
(n ? `${n}.` : "") + a.toString(),
|
|
629
|
+
r
|
|
630
|
+
) : s[a] = l));
|
|
631
|
+
}
|
|
632
|
+
return s;
|
|
633
|
+
}
|
|
634
|
+
function En(e) {
|
|
635
|
+
return (...t) => (
|
|
636
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
637
|
+
t.reduce((n, r) => ye(n, r, "", e), {})
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
const _n = En();
|
|
641
|
+
var jn = Object.defineProperty, Tn = Object.defineProperties, Pn = Object.getOwnPropertyDescriptors, Pe = Object.getOwnPropertySymbols, On = Object.prototype.hasOwnProperty, Ln = Object.prototype.propertyIsEnumerable, Oe = (e, t, n) => t in e ? jn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t) => {
|
|
642
|
+
for (var n in t || (t = {}))
|
|
643
|
+
On.call(t, n) && Oe(e, n, t[n]);
|
|
644
|
+
if (Pe)
|
|
645
|
+
for (var n of Pe(t))
|
|
646
|
+
Ln.call(t, n) && Oe(e, n, t[n]);
|
|
647
|
+
return e;
|
|
648
|
+
}, I = (e, t) => Tn(e, Pn(t)), Nn = class extends Error {
|
|
649
|
+
constructor(e, t, n) {
|
|
650
|
+
super(t || e.toString(), {
|
|
651
|
+
cause: n
|
|
652
|
+
}), this.status = e, this.statusText = t, this.error = n, Error.captureStackTrace(this, this.constructor);
|
|
653
|
+
}
|
|
654
|
+
}, Un = async (e, t) => {
|
|
655
|
+
var n, r, s, a, l, d;
|
|
656
|
+
let o = t || {};
|
|
657
|
+
const u = {
|
|
658
|
+
onRequest: [t == null ? void 0 : t.onRequest],
|
|
659
|
+
onResponse: [t == null ? void 0 : t.onResponse],
|
|
660
|
+
onSuccess: [t == null ? void 0 : t.onSuccess],
|
|
661
|
+
onError: [t == null ? void 0 : t.onError],
|
|
662
|
+
onRetry: [t == null ? void 0 : t.onRetry]
|
|
663
|
+
};
|
|
664
|
+
if (!t || !(t != null && t.plugins))
|
|
665
|
+
return {
|
|
666
|
+
url: e,
|
|
667
|
+
options: o,
|
|
668
|
+
hooks: u
|
|
669
|
+
};
|
|
670
|
+
for (const c of (t == null ? void 0 : t.plugins) || []) {
|
|
671
|
+
if (c.init) {
|
|
672
|
+
const p = await ((n = c.init) == null ? void 0 : n.call(c, e.toString(), t));
|
|
673
|
+
o = p.options || o, e = p.url;
|
|
674
|
+
}
|
|
675
|
+
u.onRequest.push((r = c.hooks) == null ? void 0 : r.onRequest), u.onResponse.push((s = c.hooks) == null ? void 0 : s.onResponse), u.onSuccess.push((a = c.hooks) == null ? void 0 : a.onSuccess), u.onError.push((l = c.hooks) == null ? void 0 : l.onError), u.onRetry.push((d = c.hooks) == null ? void 0 : d.onRetry);
|
|
676
|
+
}
|
|
677
|
+
return {
|
|
678
|
+
url: e,
|
|
679
|
+
options: o,
|
|
680
|
+
hooks: u
|
|
681
|
+
};
|
|
682
|
+
}, Le = class {
|
|
683
|
+
constructor(e) {
|
|
684
|
+
this.options = e;
|
|
685
|
+
}
|
|
686
|
+
shouldAttemptRetry(e, t) {
|
|
687
|
+
return this.options.shouldRetry ? Promise.resolve(
|
|
688
|
+
e < this.options.attempts && this.options.shouldRetry(t)
|
|
689
|
+
) : Promise.resolve(e < this.options.attempts);
|
|
690
|
+
}
|
|
691
|
+
getDelay() {
|
|
692
|
+
return this.options.delay;
|
|
693
|
+
}
|
|
694
|
+
}, An = class {
|
|
695
|
+
constructor(e) {
|
|
696
|
+
this.options = e;
|
|
697
|
+
}
|
|
698
|
+
shouldAttemptRetry(e, t) {
|
|
699
|
+
return this.options.shouldRetry ? Promise.resolve(
|
|
700
|
+
e < this.options.attempts && this.options.shouldRetry(t)
|
|
701
|
+
) : Promise.resolve(e < this.options.attempts);
|
|
702
|
+
}
|
|
703
|
+
getDelay(e) {
|
|
704
|
+
return Math.min(
|
|
705
|
+
this.options.maxDelay,
|
|
706
|
+
this.options.baseDelay * 2 ** e
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
function Cn(e) {
|
|
711
|
+
if (typeof e == "number")
|
|
712
|
+
return new Le({
|
|
713
|
+
type: "linear",
|
|
714
|
+
attempts: e,
|
|
715
|
+
delay: 1e3
|
|
716
|
+
});
|
|
717
|
+
switch (e.type) {
|
|
718
|
+
case "linear":
|
|
719
|
+
return new Le(e);
|
|
720
|
+
case "exponential":
|
|
721
|
+
return new An(e);
|
|
722
|
+
default:
|
|
723
|
+
throw new Error("Invalid retry strategy");
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
var qn = async (e) => {
|
|
727
|
+
const t = {}, n = async (r) => typeof r == "function" ? await r() : r;
|
|
728
|
+
if (e != null && e.auth) {
|
|
729
|
+
if (e.auth.type === "Bearer") {
|
|
730
|
+
const r = await n(e.auth.token);
|
|
731
|
+
if (!r)
|
|
732
|
+
return t;
|
|
733
|
+
t.authorization = `Bearer ${r}`;
|
|
734
|
+
} else if (e.auth.type === "Basic") {
|
|
735
|
+
const [r, s] = await Promise.all([
|
|
736
|
+
n(e.auth.username),
|
|
737
|
+
n(e.auth.password)
|
|
738
|
+
]);
|
|
739
|
+
if (!r || !s)
|
|
740
|
+
return t;
|
|
741
|
+
t.authorization = `Basic ${btoa(`${r}:${s}`)}`;
|
|
742
|
+
} else if (e.auth.type === "Custom") {
|
|
743
|
+
const [r, s] = await Promise.all([
|
|
744
|
+
n(e.auth.prefix),
|
|
745
|
+
n(e.auth.value)
|
|
746
|
+
]);
|
|
747
|
+
if (!s)
|
|
748
|
+
return t;
|
|
749
|
+
t.authorization = `${r ?? ""} ${s}`;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return t;
|
|
753
|
+
}, In = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
754
|
+
function zn(e) {
|
|
755
|
+
const t = e.headers.get("content-type"), n = /* @__PURE__ */ new Set([
|
|
756
|
+
"image/svg",
|
|
757
|
+
"application/xml",
|
|
758
|
+
"application/xhtml",
|
|
759
|
+
"application/html"
|
|
760
|
+
]);
|
|
761
|
+
if (!t)
|
|
762
|
+
return "json";
|
|
763
|
+
const r = t.split(";").shift() || "";
|
|
764
|
+
return In.test(r) ? "json" : n.has(r) || r.startsWith("text/") ? "text" : "blob";
|
|
765
|
+
}
|
|
766
|
+
function Bn(e) {
|
|
767
|
+
try {
|
|
768
|
+
return JSON.parse(e), !0;
|
|
769
|
+
} catch {
|
|
770
|
+
return !1;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function Xe(e) {
|
|
774
|
+
if (e === void 0)
|
|
775
|
+
return !1;
|
|
776
|
+
const t = typeof e;
|
|
777
|
+
return t === "string" || t === "number" || t === "boolean" || t === null ? !0 : t !== "object" ? !1 : Array.isArray(e) ? !0 : e.buffer ? !1 : e.constructor && e.constructor.name === "Object" || typeof e.toJSON == "function";
|
|
778
|
+
}
|
|
779
|
+
function Ne(e) {
|
|
780
|
+
try {
|
|
781
|
+
return JSON.parse(e);
|
|
782
|
+
} catch {
|
|
783
|
+
return e;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function Ue(e) {
|
|
787
|
+
return typeof e == "function";
|
|
788
|
+
}
|
|
789
|
+
function Fn(e) {
|
|
790
|
+
if (e != null && e.customFetchImpl)
|
|
791
|
+
return e.customFetchImpl;
|
|
792
|
+
if (typeof globalThis < "u" && Ue(globalThis.fetch))
|
|
793
|
+
return globalThis.fetch;
|
|
794
|
+
if (typeof window < "u" && Ue(window.fetch))
|
|
795
|
+
return window.fetch;
|
|
796
|
+
throw new Error("No fetch implementation found");
|
|
797
|
+
}
|
|
798
|
+
function Ye(...e) {
|
|
799
|
+
const t = {};
|
|
800
|
+
for (const n of e)
|
|
801
|
+
if (n)
|
|
802
|
+
if (n instanceof Headers)
|
|
803
|
+
n.forEach((r, s) => {
|
|
804
|
+
t[s] = r;
|
|
805
|
+
});
|
|
806
|
+
else {
|
|
807
|
+
const r = Array.isArray(n) ? n : Object.entries(n);
|
|
808
|
+
for (const [s, a] of r)
|
|
809
|
+
a != null && (t[s] = a);
|
|
810
|
+
}
|
|
811
|
+
return t;
|
|
812
|
+
}
|
|
813
|
+
async function Mn(e) {
|
|
814
|
+
const t = new Headers(Ye(e == null ? void 0 : e.headers, await qn(e)));
|
|
815
|
+
if (!t.has("content-type")) {
|
|
816
|
+
const n = Dn(e == null ? void 0 : e.body);
|
|
817
|
+
n && t.set("content-type", n);
|
|
818
|
+
}
|
|
819
|
+
return t;
|
|
820
|
+
}
|
|
821
|
+
function Dn(e) {
|
|
822
|
+
return Xe(e) ? "application/json" : null;
|
|
823
|
+
}
|
|
824
|
+
function Hn(e) {
|
|
825
|
+
const t = e.get("content-type");
|
|
826
|
+
return t ? t.split(";")[0].trim().toLowerCase() : null;
|
|
827
|
+
}
|
|
828
|
+
function Wn(e, t) {
|
|
829
|
+
const { body: n } = e;
|
|
830
|
+
return n ? !Xe(n) || typeof n == "string" ? n : Hn(t) === "application/x-www-form-urlencoded" ? new URLSearchParams(n).toString() : JSON.stringify(n) : null;
|
|
831
|
+
}
|
|
832
|
+
function $n(e, t) {
|
|
833
|
+
var n;
|
|
834
|
+
if (t != null && t.method)
|
|
835
|
+
return t.method.toUpperCase();
|
|
836
|
+
if (e.startsWith("@")) {
|
|
837
|
+
const r = (n = e.split("@")[1]) == null ? void 0 : n.split("/")[0];
|
|
838
|
+
return Ze.includes(r) ? r.toUpperCase() : t != null && t.body ? "POST" : "GET";
|
|
839
|
+
}
|
|
840
|
+
return t != null && t.body ? "POST" : "GET";
|
|
841
|
+
}
|
|
842
|
+
function Gn(e, t) {
|
|
843
|
+
let n;
|
|
844
|
+
return !(e != null && e.signal) && (e != null && e.timeout) && (n = setTimeout(() => t == null ? void 0 : t.abort(), e == null ? void 0 : e.timeout)), {
|
|
845
|
+
abortTimeout: n,
|
|
846
|
+
clearTimeout: () => {
|
|
847
|
+
n && clearTimeout(n);
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
var Vn = class Qe extends Error {
|
|
852
|
+
constructor(t, n) {
|
|
853
|
+
super(n || JSON.stringify(t, null, 2)), this.issues = t, Object.setPrototypeOf(this, Qe.prototype);
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
async function J(e, t) {
|
|
857
|
+
const n = await e["~standard"].validate(t);
|
|
858
|
+
if (n.issues)
|
|
859
|
+
throw new Vn(n.issues);
|
|
860
|
+
return n.value;
|
|
861
|
+
}
|
|
862
|
+
var Ze = ["get", "post", "put", "patch", "delete"], Jn = (e) => ({
|
|
863
|
+
id: "apply-schema",
|
|
864
|
+
name: "Apply Schema",
|
|
865
|
+
version: "1.0.0",
|
|
866
|
+
async init(t, n) {
|
|
867
|
+
var r, s, a, l;
|
|
868
|
+
const d = ((s = (r = e.plugins) == null ? void 0 : r.find(
|
|
869
|
+
(o) => {
|
|
870
|
+
var u;
|
|
871
|
+
return (u = o.schema) != null && u.config ? t.startsWith(o.schema.config.baseURL || "") || t.startsWith(o.schema.config.prefix || "") : !1;
|
|
872
|
+
}
|
|
873
|
+
)) == null ? void 0 : s.schema) || e.schema;
|
|
874
|
+
if (d) {
|
|
875
|
+
let o = t;
|
|
876
|
+
(a = d.config) != null && a.prefix && o.startsWith(d.config.prefix) && (o = o.replace(d.config.prefix, ""), d.config.baseURL && (t = t.replace(d.config.prefix, d.config.baseURL))), (l = d.config) != null && l.baseURL && o.startsWith(d.config.baseURL) && (o = o.replace(d.config.baseURL, "")), o.startsWith("/") && o.charAt(1) === "@" && (o = o.substring(1));
|
|
877
|
+
const u = d.schema[o];
|
|
878
|
+
if (u) {
|
|
879
|
+
let c = n == null ? void 0 : n.headers;
|
|
880
|
+
if (u.headers && !(n != null && n.disableValidation)) {
|
|
881
|
+
const x = {};
|
|
882
|
+
if (n != null && n.headers) {
|
|
883
|
+
if (n.headers instanceof Headers)
|
|
884
|
+
n.headers.forEach((v, y) => {
|
|
885
|
+
x[y.toLowerCase()] = v;
|
|
886
|
+
});
|
|
887
|
+
else if (typeof n.headers == "object")
|
|
888
|
+
for (const [v, y] of Object.entries(n.headers))
|
|
889
|
+
y != null && (x[v.toLowerCase()] = y);
|
|
890
|
+
}
|
|
891
|
+
const h = await J(
|
|
892
|
+
u.headers,
|
|
893
|
+
x
|
|
894
|
+
), g = {};
|
|
895
|
+
for (const [v, y] of Object.entries(h))
|
|
896
|
+
g[v.toLowerCase()] = y;
|
|
897
|
+
c = g;
|
|
898
|
+
}
|
|
899
|
+
let p = I(C({}, n), {
|
|
900
|
+
method: u.method,
|
|
901
|
+
output: u.output,
|
|
902
|
+
headers: c
|
|
903
|
+
});
|
|
904
|
+
return n != null && n.disableValidation || (p = I(C({}, p), {
|
|
905
|
+
body: u.input ? await J(u.input, n == null ? void 0 : n.body) : n == null ? void 0 : n.body,
|
|
906
|
+
params: u.params ? await J(u.params, n == null ? void 0 : n.params) : n == null ? void 0 : n.params,
|
|
907
|
+
query: u.query ? await J(u.query, n == null ? void 0 : n.query) : n == null ? void 0 : n.query
|
|
908
|
+
})), {
|
|
909
|
+
url: t,
|
|
910
|
+
options: p
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
url: t,
|
|
916
|
+
options: n
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
}), Kn = (e) => {
|
|
920
|
+
async function t(n, r) {
|
|
921
|
+
const s = I(C(C({}, e), r), {
|
|
922
|
+
headers: Ye(e == null ? void 0 : e.headers, r == null ? void 0 : r.headers),
|
|
923
|
+
plugins: [...(e == null ? void 0 : e.plugins) || [], Jn(e || {}), ...(r == null ? void 0 : r.plugins) || []]
|
|
924
|
+
});
|
|
925
|
+
if (e != null && e.catchAllError)
|
|
926
|
+
try {
|
|
927
|
+
return await ve(n, s);
|
|
928
|
+
} catch (a) {
|
|
929
|
+
return {
|
|
930
|
+
data: null,
|
|
931
|
+
error: {
|
|
932
|
+
status: 500,
|
|
933
|
+
statusText: "Fetch Error",
|
|
934
|
+
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
935
|
+
error: a
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
return await ve(n, s);
|
|
940
|
+
}
|
|
941
|
+
return t;
|
|
942
|
+
}, Xn = (e) => e === "." || e === "..";
|
|
943
|
+
function Yn(e, t) {
|
|
944
|
+
let n = e;
|
|
945
|
+
for (const [r, s] of t)
|
|
946
|
+
n = n.replace(r, s);
|
|
947
|
+
if (Xn(n))
|
|
948
|
+
throw new TypeError("Path parameters cannot be reserved path segments");
|
|
949
|
+
return encodeURIComponent(n);
|
|
950
|
+
}
|
|
951
|
+
function Qn(e, t) {
|
|
952
|
+
const { baseURL: n, params: r, query: s } = t || {
|
|
953
|
+
query: {},
|
|
954
|
+
params: {},
|
|
955
|
+
baseURL: ""
|
|
956
|
+
};
|
|
957
|
+
let a = e.startsWith("http") ? e.split("/").slice(0, 3).join("/") : n || "";
|
|
958
|
+
if (e.startsWith("@")) {
|
|
959
|
+
const x = e.toString().split("@")[1].split("/")[0];
|
|
960
|
+
Ze.includes(x) && (e = e.replace(`@${x}/`, "/"));
|
|
961
|
+
}
|
|
962
|
+
a.endsWith("/") || (a += "/");
|
|
963
|
+
let [l, d] = e.replace(a, "").split("?");
|
|
964
|
+
const o = new URLSearchParams(d);
|
|
965
|
+
for (const [x, h] of Object.entries(s || {})) {
|
|
966
|
+
if (h == null) continue;
|
|
967
|
+
let g;
|
|
968
|
+
if (typeof h == "string")
|
|
969
|
+
g = h;
|
|
970
|
+
else if (Array.isArray(h)) {
|
|
971
|
+
for (const v of h)
|
|
972
|
+
o.append(x, v);
|
|
973
|
+
continue;
|
|
974
|
+
} else
|
|
975
|
+
g = JSON.stringify(h);
|
|
976
|
+
o.set(x, g);
|
|
977
|
+
}
|
|
978
|
+
const u = /* @__PURE__ */ new Map();
|
|
979
|
+
if (r)
|
|
980
|
+
if (Array.isArray(r)) {
|
|
981
|
+
const x = l.split("/").filter((h) => h.startsWith(":"));
|
|
982
|
+
for (const [h, g] of x.entries()) {
|
|
983
|
+
const v = r[h];
|
|
984
|
+
u.set(g, String(v));
|
|
985
|
+
}
|
|
986
|
+
} else
|
|
987
|
+
for (const [x, h] of Object.entries(r))
|
|
988
|
+
u.set(`:${x}`, String(h));
|
|
989
|
+
l = l.split("/").map((x) => Yn(x, u)).join("/"), l = l.replace(/^\/+/, "");
|
|
990
|
+
let c = o.toString();
|
|
991
|
+
return c = c.length > 0 ? `?${c}`.replace(/\+/g, "%20") : "", a.startsWith("http") ? new URL(`${l}${c}`, a) : `${a}${l}${c}`;
|
|
992
|
+
}
|
|
993
|
+
var ve = async (e, t) => {
|
|
994
|
+
var n, r, s, a, l, d, o, u;
|
|
995
|
+
const {
|
|
996
|
+
hooks: c,
|
|
997
|
+
url: p,
|
|
998
|
+
options: x
|
|
999
|
+
} = await Un(e, t), h = Fn(x), g = new AbortController(), v = (n = x.signal) != null ? n : g.signal, y = Qn(p, x), k = await Mn(x), P = Wn(x, k), j = $n(p, x), b = I(C({}, x), {
|
|
1000
|
+
url: y,
|
|
1001
|
+
headers: k,
|
|
1002
|
+
body: P,
|
|
1003
|
+
method: j,
|
|
1004
|
+
signal: v
|
|
1005
|
+
});
|
|
1006
|
+
for (const O of c.onRequest)
|
|
1007
|
+
if (O) {
|
|
1008
|
+
const f = await O(b);
|
|
1009
|
+
typeof f == "object" && f !== null && Object.assign(b, f);
|
|
1010
|
+
}
|
|
1011
|
+
("pipeTo" in b && typeof b.pipeTo == "function" || typeof ((r = t == null ? void 0 : t.body) == null ? void 0 : r.pipe) == "function") && ("duplex" in b || (b.duplex = "half"));
|
|
1012
|
+
const { clearTimeout: _ } = Gn(x, g);
|
|
1013
|
+
let m = await h(b.url, b);
|
|
1014
|
+
_();
|
|
1015
|
+
const T = {
|
|
1016
|
+
response: m,
|
|
1017
|
+
request: b
|
|
1018
|
+
};
|
|
1019
|
+
for (const O of c.onResponse)
|
|
1020
|
+
if (O) {
|
|
1021
|
+
const f = await O(I(C({}, T), {
|
|
1022
|
+
response: (s = t == null ? void 0 : t.hookOptions) != null && s.cloneResponse ? m.clone() : m
|
|
1023
|
+
}));
|
|
1024
|
+
f instanceof Response ? m = f : typeof f == "object" && f !== null && (m = f.response);
|
|
1025
|
+
}
|
|
1026
|
+
if (m.ok) {
|
|
1027
|
+
if (!(b.method !== "HEAD"))
|
|
1028
|
+
return {
|
|
1029
|
+
data: "",
|
|
1030
|
+
error: null
|
|
1031
|
+
};
|
|
1032
|
+
const f = zn(m), A = {
|
|
1033
|
+
data: null,
|
|
1034
|
+
response: m,
|
|
1035
|
+
request: b
|
|
1036
|
+
};
|
|
1037
|
+
if (f === "json" || f === "text") {
|
|
1038
|
+
const z = await m.text(), nt = (a = b.jsonParser) != null ? a : Ne;
|
|
1039
|
+
A.data = await nt(z);
|
|
1040
|
+
} else
|
|
1041
|
+
A.data = await m[f]();
|
|
1042
|
+
b != null && b.output && b.output && !b.disableValidation && (A.data = await J(
|
|
1043
|
+
b.output,
|
|
1044
|
+
A.data
|
|
1045
|
+
));
|
|
1046
|
+
for (const z of c.onSuccess)
|
|
1047
|
+
z && await z(I(C({}, A), {
|
|
1048
|
+
response: (l = t == null ? void 0 : t.hookOptions) != null && l.cloneResponse ? m.clone() : m
|
|
1049
|
+
}));
|
|
1050
|
+
return t != null && t.throw ? A.data : {
|
|
1051
|
+
data: A.data,
|
|
1052
|
+
error: null
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
const N = (d = t == null ? void 0 : t.jsonParser) != null ? d : Ne, U = await m.text(), S = Bn(U), L = S ? await N(U) : null, M = {
|
|
1056
|
+
response: m,
|
|
1057
|
+
responseText: U,
|
|
1058
|
+
request: b,
|
|
1059
|
+
error: I(C({}, L), {
|
|
1060
|
+
status: m.status,
|
|
1061
|
+
statusText: m.statusText
|
|
1062
|
+
})
|
|
1063
|
+
};
|
|
1064
|
+
for (const O of c.onError)
|
|
1065
|
+
O && await O(I(C({}, M), {
|
|
1066
|
+
response: (o = t == null ? void 0 : t.hookOptions) != null && o.cloneResponse ? m.clone() : m
|
|
1067
|
+
}));
|
|
1068
|
+
if (t != null && t.retry) {
|
|
1069
|
+
const O = Cn(t.retry), f = (u = t.retryAttempt) != null ? u : 0;
|
|
1070
|
+
if (await O.shouldAttemptRetry(f, m)) {
|
|
1071
|
+
for (const z of c.onRetry)
|
|
1072
|
+
z && await z(T);
|
|
1073
|
+
const A = O.getDelay(f);
|
|
1074
|
+
return await new Promise((z) => setTimeout(z, A)), await ve(e, I(C({}, t), {
|
|
1075
|
+
retryAttempt: f + 1
|
|
1076
|
+
}));
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (t != null && t.throw)
|
|
1080
|
+
throw new Nn(
|
|
1081
|
+
m.status,
|
|
1082
|
+
m.statusText,
|
|
1083
|
+
S ? L : U
|
|
1084
|
+
);
|
|
1085
|
+
return {
|
|
1086
|
+
data: null,
|
|
1087
|
+
error: I(C({}, L), {
|
|
1088
|
+
status: m.status,
|
|
1089
|
+
statusText: m.statusText
|
|
1090
|
+
})
|
|
1091
|
+
};
|
|
1092
|
+
};
|
|
1093
|
+
const Zn = (e) => {
|
|
1094
|
+
if (typeof process > "u") return;
|
|
1095
|
+
const t = e ?? "/api/auth";
|
|
1096
|
+
if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
|
|
1097
|
+
if (typeof window > "u") {
|
|
1098
|
+
if (process.env.NEXTAUTH_URL) try {
|
|
1099
|
+
return process.env.NEXTAUTH_URL;
|
|
1100
|
+
} catch {
|
|
1101
|
+
}
|
|
1102
|
+
if (process.env.VERCEL_URL) try {
|
|
1103
|
+
const n = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
|
|
1104
|
+
return `${new URL(`${n}${process.env.VERCEL_URL}`).origin}${t}`;
|
|
1105
|
+
} catch {
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}, er = (e, t) => {
|
|
1109
|
+
var T, N, U, S, L, M, O;
|
|
1110
|
+
const n = "credentials" in Request.prototype, r = Gt(e == null ? void 0 : e.baseURL, e == null ? void 0 : e.basePath) ?? Zn(e == null ? void 0 : e.basePath) ?? "/api/auth", s = ((T = e == null ? void 0 : e.plugins) == null ? void 0 : T.flatMap((f) => f.fetchPlugins).filter((f) => f !== void 0)) || [], a = {
|
|
1111
|
+
id: "lifecycle-hooks",
|
|
1112
|
+
name: "lifecycle-hooks",
|
|
1113
|
+
hooks: {
|
|
1114
|
+
onSuccess: (N = e == null ? void 0 : e.fetchOptions) == null ? void 0 : N.onSuccess,
|
|
1115
|
+
onError: (U = e == null ? void 0 : e.fetchOptions) == null ? void 0 : U.onError,
|
|
1116
|
+
onRequest: (S = e == null ? void 0 : e.fetchOptions) == null ? void 0 : S.onRequest,
|
|
1117
|
+
onResponse: (L = e == null ? void 0 : e.fetchOptions) == null ? void 0 : L.onResponse
|
|
1118
|
+
}
|
|
1119
|
+
}, { onSuccess: l, onError: d, onRequest: o, onResponse: u, ...c } = (e == null ? void 0 : e.fetchOptions) || {}, p = Kn({
|
|
1120
|
+
baseURL: r,
|
|
1121
|
+
...n ? { credentials: "include" } : {},
|
|
1122
|
+
method: "GET",
|
|
1123
|
+
jsonParser(f) {
|
|
1124
|
+
return f ? Zt(f, { strict: !1 }) : null;
|
|
1125
|
+
},
|
|
1126
|
+
customFetchImpl: fetch,
|
|
1127
|
+
...c,
|
|
1128
|
+
plugins: [
|
|
1129
|
+
a,
|
|
1130
|
+
...c.plugins || [],
|
|
1131
|
+
...e != null && e.disableDefaultFetchPlugins ? [] : [nn],
|
|
1132
|
+
...s
|
|
1133
|
+
]
|
|
1134
|
+
}), { $sessionSignal: x, session: h, broadcastSessionUpdate: g } = Rn(p, e);
|
|
1135
|
+
let v = !1;
|
|
1136
|
+
const y = (f) => {
|
|
1137
|
+
v || f === null || (v = !0, wn(h, f));
|
|
1138
|
+
}, k = (e == null ? void 0 : e.plugins) || [];
|
|
1139
|
+
let P = {};
|
|
1140
|
+
const j = {
|
|
1141
|
+
$sessionSignal: x,
|
|
1142
|
+
session: h
|
|
1143
|
+
}, b = {
|
|
1144
|
+
"/sign-out": "POST",
|
|
1145
|
+
"/revoke-sessions": "POST",
|
|
1146
|
+
"/revoke-other-sessions": "POST",
|
|
1147
|
+
"/delete-user": "POST"
|
|
1148
|
+
}, _ = [{
|
|
1149
|
+
signal: "$sessionSignal",
|
|
1150
|
+
matcher(f) {
|
|
1151
|
+
return f === "/sign-out" || f === "/update-user" || f === "/update-session" || f === "/sign-up/email" || f === "/sign-in/email" || f === "/delete-user" || f === "/verify-email" || f === "/revoke-sessions" || f === "/revoke-session" || f === "/revoke-other-sessions" || f === "/change-email" || f === "/change-password";
|
|
1152
|
+
},
|
|
1153
|
+
callback(f) {
|
|
1154
|
+
f === "/sign-out" ? g("signout") : (f === "/update-user" || f === "/update-session") && g("updateUser");
|
|
1155
|
+
}
|
|
1156
|
+
}];
|
|
1157
|
+
for (const f of k)
|
|
1158
|
+
f.getAtoms && Object.assign(j, (M = f.getAtoms) == null ? void 0 : M.call(f, p)), f.pathMethods && Object.assign(b, f.pathMethods), f.atomListeners && _.push(...f.atomListeners);
|
|
1159
|
+
const m = {
|
|
1160
|
+
notify: (f) => {
|
|
1161
|
+
j[f].set(!j[f].get());
|
|
1162
|
+
},
|
|
1163
|
+
listen: (f, A) => {
|
|
1164
|
+
j[f].subscribe(A);
|
|
1165
|
+
},
|
|
1166
|
+
atoms: j
|
|
1167
|
+
};
|
|
1168
|
+
for (const f of k) f.getActions && (P = _n(((O = f.getActions) == null ? void 0 : O.call(f, p, m, e)) ?? {}, P));
|
|
1169
|
+
return {
|
|
1170
|
+
get baseURL() {
|
|
1171
|
+
return r;
|
|
1172
|
+
},
|
|
1173
|
+
pluginsActions: P,
|
|
1174
|
+
pluginsAtoms: j,
|
|
1175
|
+
pluginPathMethods: b,
|
|
1176
|
+
atomListeners: _,
|
|
1177
|
+
hydrateSession: y,
|
|
1178
|
+
$sessionSignal: x,
|
|
1179
|
+
$fetch: p,
|
|
1180
|
+
$store: m
|
|
1181
|
+
};
|
|
1182
|
+
};
|
|
1183
|
+
function tr(e) {
|
|
1184
|
+
return typeof e == "object" && e !== null && "get" in e && typeof e.get == "function" && "lc" in e && typeof e.lc == "number";
|
|
1185
|
+
}
|
|
1186
|
+
function nr(e) {
|
|
1187
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1188
|
+
}
|
|
1189
|
+
const rr = new RegExp("[\\p{Ll}\\d]+|\\p{Lu}+(?!\\p{Ll})|\\p{Lu}[\\p{Ll}\\d]+|\\p{Lo}+", "gu"), sr = /['\u2019]/g;
|
|
1190
|
+
function ir(e) {
|
|
1191
|
+
return e.replace(sr, "").match(rr) ?? [];
|
|
1192
|
+
}
|
|
1193
|
+
function ar(e) {
|
|
1194
|
+
return ir(e).map((t) => t.toLowerCase()).join("-");
|
|
1195
|
+
}
|
|
1196
|
+
function or(e, t, n) {
|
|
1197
|
+
const r = t[e], { fetchOptions: s, query: a, ...l } = n || {};
|
|
1198
|
+
return r || (s != null && s.method ? s.method : l && Object.keys(l).length > 0 ? "POST" : "GET");
|
|
1199
|
+
}
|
|
1200
|
+
function lr(e, t, n, r, s) {
|
|
1201
|
+
function a(l = []) {
|
|
1202
|
+
return new Proxy(function() {
|
|
1203
|
+
}, {
|
|
1204
|
+
get(d, o) {
|
|
1205
|
+
if (typeof o != "string" || o === "then" || o === "catch" || o === "finally") return;
|
|
1206
|
+
const u = [...l, o];
|
|
1207
|
+
let c = e;
|
|
1208
|
+
for (const p of u) if (c && typeof c == "object" && p in c) c = c[p];
|
|
1209
|
+
else {
|
|
1210
|
+
c = void 0;
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
return typeof c == "function" || tr(c) ? c : a(u);
|
|
1214
|
+
},
|
|
1215
|
+
apply: async (d, o, u) => {
|
|
1216
|
+
const c = "/" + l.map(ar).join("/"), p = u[0] || {}, x = u[1] || {}, { query: h, fetchOptions: g, ...v } = p, y = {
|
|
1217
|
+
...x,
|
|
1218
|
+
...g
|
|
1219
|
+
}, k = or(c, n, p);
|
|
1220
|
+
return await t(c, {
|
|
1221
|
+
...y,
|
|
1222
|
+
body: k === "GET" ? void 0 : {
|
|
1223
|
+
...v,
|
|
1224
|
+
...(y == null ? void 0 : y.body) || {}
|
|
1225
|
+
},
|
|
1226
|
+
query: h || (y == null ? void 0 : y.query),
|
|
1227
|
+
method: k,
|
|
1228
|
+
async onSuccess(P) {
|
|
1229
|
+
var _, m;
|
|
1230
|
+
if (await ((_ = y == null ? void 0 : y.onSuccess) == null ? void 0 : _.call(y, P)), !s || y.disableSignal) return;
|
|
1231
|
+
const j = s.filter((T) => T.matcher(c));
|
|
1232
|
+
if (!j.length) return;
|
|
1233
|
+
const b = /* @__PURE__ */ new Set();
|
|
1234
|
+
for (const T of j) {
|
|
1235
|
+
const N = r[T.signal];
|
|
1236
|
+
if (!N) return;
|
|
1237
|
+
if (b.has(T.signal)) continue;
|
|
1238
|
+
b.add(T.signal);
|
|
1239
|
+
const U = N.get();
|
|
1240
|
+
setTimeout(() => {
|
|
1241
|
+
N.set(!U);
|
|
1242
|
+
}, 10), (m = T.callback) == null || m.call(T, c);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
return a();
|
|
1250
|
+
}
|
|
1251
|
+
function cr(e, t = {}) {
|
|
1252
|
+
const n = qe(e.get()), { keys: r, deps: s = [e, r] } = t, a = it((d) => {
|
|
1253
|
+
const o = (u) => {
|
|
1254
|
+
n.current !== u && (n.current = u, d());
|
|
1255
|
+
};
|
|
1256
|
+
return o(e.value), r != null && r.length ? dn(e, r, o) : e.listen(o);
|
|
1257
|
+
}, s), l = () => n.current;
|
|
1258
|
+
return at(a, l, l);
|
|
1259
|
+
}
|
|
1260
|
+
function ur(e) {
|
|
1261
|
+
return `use${nr(e)}`;
|
|
1262
|
+
}
|
|
1263
|
+
function dr(e) {
|
|
1264
|
+
const { pluginPathMethods: t, pluginsActions: n, pluginsAtoms: r, hydrateSession: s, $fetch: a, $store: l, atomListeners: d } = er(e), o = {};
|
|
1265
|
+
for (const [u, c] of Object.entries(r)) o[ur(u)] = () => cr(c);
|
|
1266
|
+
return lr({
|
|
1267
|
+
...n,
|
|
1268
|
+
...o,
|
|
1269
|
+
hydrateSession: s,
|
|
1270
|
+
$fetch: a,
|
|
1271
|
+
$store: l
|
|
1272
|
+
}, a, t, r, d);
|
|
1273
|
+
}
|
|
1274
|
+
var fr = "1.7.3";
|
|
1275
|
+
const hr = fr, xr = () => ({
|
|
1276
|
+
id: "magic-link",
|
|
1277
|
+
version: hr,
|
|
1278
|
+
$InferServerPlugin: {}
|
|
1279
|
+
});
|
|
1280
|
+
let Ae = null;
|
|
1281
|
+
function H() {
|
|
1282
|
+
return Ae ?? (Ae = dr({
|
|
1283
|
+
baseURL: Ie(),
|
|
1284
|
+
plugins: [xr()]
|
|
1285
|
+
})), Ae;
|
|
1286
|
+
}
|
|
1287
|
+
function pr(e) {
|
|
1288
|
+
return e.replace(/\/$/, "") === "/sign-in/link";
|
|
1289
|
+
}
|
|
1290
|
+
function gr(e, t, n) {
|
|
1291
|
+
const r = new URLSearchParams(t), s = r.get("token");
|
|
1292
|
+
if (!s) return null;
|
|
1293
|
+
const a = new URL(`${e}/api/auth/magic-link/verify`);
|
|
1294
|
+
a.searchParams.set("token", s), a.searchParams.set("callbackURL", r.get("callbackURL") || `${n}/`);
|
|
1295
|
+
for (const l of ["newUserCallbackURL", "errorCallbackURL"]) {
|
|
1296
|
+
const d = r.get(l);
|
|
1297
|
+
d && a.searchParams.set(l, d);
|
|
1298
|
+
}
|
|
1299
|
+
return a.toString();
|
|
1300
|
+
}
|
|
1301
|
+
function mr(e) {
|
|
1302
|
+
return e ? e === "INVALID_TOKEN" ? "This sign-in link has expired or was already used. Send yourself a new one." : "That sign-in link did not work. Send yourself a new one." : null;
|
|
1303
|
+
}
|
|
1304
|
+
function Ce(e) {
|
|
1305
|
+
const t = new URL(e);
|
|
1306
|
+
return t.searchParams.delete("error"), t.searchParams.delete("error_description"), t.toString();
|
|
1307
|
+
}
|
|
1308
|
+
const ge = {
|
|
1309
|
+
terms: "https://backmatter.app/legal/terms",
|
|
1310
|
+
privacy: "https://backmatter.app/legal/privacy",
|
|
1311
|
+
dpa: "https://backmatter.app/legal/dpa"
|
|
1312
|
+
};
|
|
1313
|
+
function yr() {
|
|
1314
|
+
const [e] = be(), [t, n] = E(() => mr(e.get("error"))), [r, s] = E(null), [a, l] = E(!1), [d, o] = E(null), u = e.get("token") ? e.get("email") ?? "" : "", c = qe(null), [p, x] = E(u || (e.get("email") ?? "")), [h, g] = E(""), [v, y] = E(""), [k, P] = E("signin"), [j, b] = E(!1), _ = k === "signup" && !j;
|
|
1315
|
+
W(() => {
|
|
1316
|
+
e.has("error") && window.history.replaceState(null, "", Ce(window.location.href));
|
|
1317
|
+
}, [e]), W(() => {
|
|
1318
|
+
ct().then((S) => o(S.github)).catch(() => o(!1));
|
|
1319
|
+
}, []);
|
|
1320
|
+
const m = Ce(window.location.href);
|
|
1321
|
+
async function T() {
|
|
1322
|
+
l(!0), n(null);
|
|
1323
|
+
try {
|
|
1324
|
+
await H().signIn.social({
|
|
1325
|
+
provider: "github",
|
|
1326
|
+
callbackURL: m
|
|
1327
|
+
});
|
|
1328
|
+
} catch (S) {
|
|
1329
|
+
n(S instanceof Error ? S.message : "GitHub sign-in failed"), l(!1);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
async function N() {
|
|
1333
|
+
const S = c.current, L = ((S == null ? void 0 : S.value) || p).trim();
|
|
1334
|
+
if (n(null), s(null), !L || S && !S.checkValidity()) {
|
|
1335
|
+
n("Enter your email address first."), S == null || S.focus();
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
x(L), l(!0);
|
|
1339
|
+
const M = await H().signIn.magicLink({
|
|
1340
|
+
email: L,
|
|
1341
|
+
callbackURL: m
|
|
1342
|
+
});
|
|
1343
|
+
if (l(!1), M.error) {
|
|
1344
|
+
n(M.error.message ?? "Could not send the magic link");
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
s("Check your email for a sign-in link.");
|
|
1348
|
+
}
|
|
1349
|
+
async function U(S) {
|
|
1350
|
+
S.preventDefault(), l(!0), n(null), s(null);
|
|
1351
|
+
const L = k === "signup" ? await H().signUp.email({
|
|
1352
|
+
email: p,
|
|
1353
|
+
password: h,
|
|
1354
|
+
name: v,
|
|
1355
|
+
callbackURL: m
|
|
1356
|
+
}) : await H().signIn.email({
|
|
1357
|
+
email: p,
|
|
1358
|
+
password: h,
|
|
1359
|
+
callbackURL: m
|
|
1360
|
+
});
|
|
1361
|
+
if (L.error) {
|
|
1362
|
+
n(L.error.message ?? "Sign-in failed"), l(!1);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
window.location.assign(m);
|
|
1366
|
+
}
|
|
1367
|
+
return /* @__PURE__ */ w("main", { ...ze(Be, tt.main), children: [
|
|
1368
|
+
/* @__PURE__ */ i("div", { className: "x10l6tqk x10a8y8t x47corl x87ps6o xlxt4rd", "aria-hidden": !0 }),
|
|
1369
|
+
/* @__PURE__ */ w("div", { className: "x1n2onr6 x78zum5 xh8yej3 xxc7z9f xdt5ytf x6s0dn4 x2b8uid", children: [
|
|
1370
|
+
/* @__PURE__ */ i("div", { className: "xrvj5dj x1ku5rj1 x1useyqa xsdox4t x1y5o9j5 x1n0nidx", children: /* @__PURE__ */ i(et, {}) }),
|
|
1371
|
+
/* @__PURE__ */ i("h1", { className: "x1ghz6dp xqjzbou xneq65o x1s688f x1b4dsll x1u7k74 x1w2vvpw", children: u ? "Join this workspace" : "Welcome back" }),
|
|
1372
|
+
/* @__PURE__ */ i("div", { className: "x1g7u8ds", children: /* @__PURE__ */ i(R, { tone: "muted", children: u ? `Sign in as ${u}. A password or GitHub stays on this page. A magic link sends one more email.` : "Sign in with email or GitHub." }) }),
|
|
1373
|
+
/* @__PURE__ */ w("div", { className: "x78zum5 xh8yej3 x1tfhste xdt5ytf x6s0dn4 x11cgr9k", children: [
|
|
1374
|
+
t ? /* @__PURE__ */ i(R, { tone: "danger", children: t }) : null,
|
|
1375
|
+
r ? /* @__PURE__ */ i(R, { tone: "muted", children: r }) : null,
|
|
1376
|
+
/* @__PURE__ */ w("form", { onSubmit: (S) => void U(S), className: "x78zum5 xh8yej3 xdt5ytf x1ndbd79", children: [
|
|
1377
|
+
k === "signup" ? /* @__PURE__ */ i("input", { required: !0, value: v, onChange: (S) => y(S.target.value), placeholder: "Name", autoComplete: "name", className: "x9f619 xh8yej3 x1gg8mnh x173sf5p xmkeg23 x1y0btm7 x198m1os x4pepcl xf6xdpg x17ia0ru x1l3a84d" }) : null,
|
|
1378
|
+
/* @__PURE__ */ i("input", { required: !0, ref: c, type: "email", value: p, onChange: (S) => x(S.target.value), placeholder: "Email", autoComplete: "email", readOnly: !!u, ...{
|
|
1379
|
+
0: {
|
|
1380
|
+
className: "x9f619 xh8yej3 x1gg8mnh x173sf5p xmkeg23 x1y0btm7 x198m1os x4pepcl xf6xdpg x17ia0ru x1l3a84d"
|
|
1381
|
+
},
|
|
1382
|
+
1: {
|
|
1383
|
+
className: "x9f619 xh8yej3 x1gg8mnh x173sf5p xmkeg23 x1y0btm7 x198m1os x4pepcl xf6xdpg x1l3a84d x10jjolp"
|
|
1384
|
+
}
|
|
1385
|
+
}[!!u << 0] }),
|
|
1386
|
+
/* @__PURE__ */ i("input", { required: !0, type: "password", value: h, onChange: (S) => g(S.target.value), placeholder: "Password", autoComplete: k === "signup" ? "new-password" : "current-password", className: "x9f619 xh8yej3 x1gg8mnh x173sf5p xmkeg23 x1y0btm7 x198m1os x4pepcl xf6xdpg x17ia0ru x1l3a84d" }),
|
|
1387
|
+
k === "signup" ? /* @__PURE__ */ w("label", { className: "x78zum5 xh8yej3 x3smv4v x1cy8zhl x1gg8mnh xdpxx8g x1vrk1b5 x1evy7pa xqjzbou x1ypdohk", children: [
|
|
1388
|
+
/* @__PURE__ */ i("input", { type: "checkbox", checked: j, onChange: (S) => b(S.target.checked), className: "x1xp8n7a xmix8c7 xr9ek0c x2lah0s x1kb3qnp" }),
|
|
1389
|
+
/* @__PURE__ */ i("span", { children: "I agree, and I ask Backmatter to start the service now." })
|
|
1390
|
+
] }) : null,
|
|
1391
|
+
/* @__PURE__ */ i("button", { type: "submit", disabled: a || _, ...{
|
|
1392
|
+
0: {
|
|
1393
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig"
|
|
1394
|
+
},
|
|
1395
|
+
1: {
|
|
1396
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig xwq05k6 x1h6gzvc x47corl"
|
|
1397
|
+
}
|
|
1398
|
+
}[!!(a || _) << 0], children: k === "signup" ? "Create account" : "Sign in" })
|
|
1399
|
+
] }),
|
|
1400
|
+
/* @__PURE__ */ i("button", { type: "button", disabled: a || _, onClick: () => void N(), ...{
|
|
1401
|
+
0: {
|
|
1402
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k xc342km x1e6avla xjbqb8w x1n0nidx x1vrk1b5 x1ypdohk"
|
|
1403
|
+
},
|
|
1404
|
+
1: {
|
|
1405
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k xc342km x1e6avla xjbqb8w x1n0nidx x1vrk1b5 xwq05k6 x1h6gzvc x47corl"
|
|
1406
|
+
}
|
|
1407
|
+
}[!!(a || _) << 0], children: "Email me a magic link" }),
|
|
1408
|
+
/* @__PURE__ */ i("button", { type: "button", disabled: a, onClick: () => P(k === "signup" ? "signin" : "signup"), className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k xc342km x1e6avla xjbqb8w x1n0nidx x1vrk1b5 x1ypdohk", children: k === "signup" ? "I already have an account" : "Create an account" }),
|
|
1409
|
+
/* @__PURE__ */ w("button", { type: "button", disabled: a || d !== !0 || _, onClick: () => void T(), ...{
|
|
1410
|
+
0: {
|
|
1411
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig"
|
|
1412
|
+
},
|
|
1413
|
+
1: {
|
|
1414
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig xwq05k6 x1h6gzvc x47corl"
|
|
1415
|
+
}
|
|
1416
|
+
}[!!(a || d !== !0 || _) << 0], children: [
|
|
1417
|
+
/* @__PURE__ */ i(ut, { size: 18 }),
|
|
1418
|
+
"Continue with GitHub"
|
|
1419
|
+
] })
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ w("p", { className: "x1va8c73 x1ghz6dp xg87l8a x10qp4ay x1dbl2gt x111yfic x2b8uid x1fzhlzt", children: [
|
|
1422
|
+
"By continuing you agree to the",
|
|
1423
|
+
" ",
|
|
1424
|
+
/* @__PURE__ */ i("a", { href: ge.terms, className: "x1heor9g x1smjwyo xrys4gj x1r72jz", children: "Terms" }),
|
|
1425
|
+
" and the",
|
|
1426
|
+
" ",
|
|
1427
|
+
/* @__PURE__ */ i("a", { href: ge.dpa, className: "x1heor9g x1smjwyo xrys4gj x1r72jz", children: "Data Processing Agreement" }),
|
|
1428
|
+
", and you acknowledge the",
|
|
1429
|
+
" ",
|
|
1430
|
+
/* @__PURE__ */ i("a", { href: ge.privacy, className: "x1heor9g x1smjwyo xrys4gj x1r72jz", children: "Privacy policy" }),
|
|
1431
|
+
". A consumer who asks us to start the service now loses the 14-day right of withdrawal once it has begun."
|
|
1432
|
+
] })
|
|
1433
|
+
] })
|
|
1434
|
+
] });
|
|
1435
|
+
}
|
|
1436
|
+
function vr() {
|
|
1437
|
+
const [e, t] = E(!1), n = gr(Ie(), window.location.search, window.location.origin);
|
|
1438
|
+
return /* @__PURE__ */ w("main", { ...ze(Be, tt.main), children: [
|
|
1439
|
+
/* @__PURE__ */ i("div", { className: "x10l6tqk x10a8y8t x47corl x87ps6o xlxt4rd", "aria-hidden": !0 }),
|
|
1440
|
+
/* @__PURE__ */ w("div", { className: "x1n2onr6 x78zum5 xh8yej3 xxc7z9f xdt5ytf x6s0dn4 x2b8uid", children: [
|
|
1441
|
+
/* @__PURE__ */ i("div", { className: "xrvj5dj x1ku5rj1 x1useyqa xsdox4t x1y5o9j5 x1n0nidx", children: /* @__PURE__ */ i(et, {}) }),
|
|
1442
|
+
/* @__PURE__ */ i("h1", { className: "x1ghz6dp xqjzbou xneq65o x1s688f x1b4dsll x1u7k74 x1w2vvpw", children: "Finish signing in" }),
|
|
1443
|
+
/* @__PURE__ */ i("div", { className: "x1g7u8ds", children: /* @__PURE__ */ i(R, { tone: "muted", children: n ? "Sign in to Backmatter in this browser." : "This sign-in link is incomplete. Send yourself a new one." }) }),
|
|
1444
|
+
/* @__PURE__ */ i("div", { className: "x78zum5 xh8yej3 x1tfhste xdt5ytf x6s0dn4 x11cgr9k", children: n ? /* @__PURE__ */ i("button", { type: "button", disabled: e, onClick: () => {
|
|
1445
|
+
t(!0), window.location.assign(n);
|
|
1446
|
+
}, ...{
|
|
1447
|
+
0: {
|
|
1448
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig"
|
|
1449
|
+
},
|
|
1450
|
+
1: {
|
|
1451
|
+
className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig xwq05k6 x1h6gzvc x47corl"
|
|
1452
|
+
}
|
|
1453
|
+
}[!!e << 0], children: "Sign in" }) : /* @__PURE__ */ i("button", { type: "button", onClick: () => window.location.assign("/"), className: "x3nfvp2 x9f619 xh8yej3 x1gg8mnh x6s0dn4 xl56j7k x3smv4v x161b3w3 xc342km x1e6avla xj4hn0o x1wt99x4 x1l3a84d xk50ysn x1u7k74 xggy1nq xr1c510 xx6bhzk xwji4o3 xq3txz7 xd3so5o x12w9bfk xb93eig", children: "Back to sign in" }) })
|
|
1454
|
+
] })
|
|
1455
|
+
] });
|
|
1456
|
+
}
|
|
1457
|
+
function et() {
|
|
1458
|
+
return /* @__PURE__ */ w("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", "aria-hidden": !0, children: [
|
|
1459
|
+
/* @__PURE__ */ i("circle", { cx: "24", cy: "24", r: "18.25", stroke: "currentColor", strokeWidth: "1.25", opacity: "0.28" }),
|
|
1460
|
+
/* @__PURE__ */ i("circle", { cx: "24", cy: "24", r: "11.25", stroke: "currentColor", strokeWidth: "1.25", opacity: "0.55" }),
|
|
1461
|
+
/* @__PURE__ */ i("circle", { cx: "24", cy: "24", r: "4", fill: "currentColor" })
|
|
1462
|
+
] });
|
|
1463
|
+
}
|
|
1464
|
+
const tt = {
|
|
1465
|
+
main: {
|
|
1466
|
+
kVAEAm: "x1n2onr6",
|
|
1467
|
+
k1xSpc: "x78zum5",
|
|
1468
|
+
kVQacm: "xb3r6kr",
|
|
1469
|
+
kB7OPa: "x9f619",
|
|
1470
|
+
kAzted: "x1ov3xa9",
|
|
1471
|
+
kGNEyG: "x6s0dn4",
|
|
1472
|
+
kjj79g: "xl56j7k",
|
|
1473
|
+
kg3NbH: "xm8shrt",
|
|
1474
|
+
kLKAdn: "x1dmhkuj",
|
|
1475
|
+
kGO01o: "xwlwngp",
|
|
1476
|
+
kWkggS: "xemx7gx",
|
|
1477
|
+
kMwMTN: "xqjzbou",
|
|
1478
|
+
$$css: !0
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1481
|
+
function br() {
|
|
1482
|
+
var s;
|
|
1483
|
+
const { userId: e } = Fe(), t = Me(), n = De(e), r = dt(n, ((s = t.control) == null ? void 0 : s.workspaces) ?? []);
|
|
1484
|
+
return r === "/workspaces" && n && ft(e), /* @__PURE__ */ i(He, { to: r, replace: !0 });
|
|
1485
|
+
}
|
|
1486
|
+
function wr({
|
|
1487
|
+
to: e,
|
|
1488
|
+
title: t,
|
|
1489
|
+
meta: n,
|
|
1490
|
+
trailing: r
|
|
1491
|
+
}) {
|
|
1492
|
+
const s = /* @__PURE__ */ w(re, { children: [
|
|
1493
|
+
/* @__PURE__ */ w("span", { className: "x78zum5 xeuugli xdt5ytf x195vfkc", children: [
|
|
1494
|
+
/* @__PURE__ */ i("span", { className: "x17tv04q xk50ysn", children: t }),
|
|
1495
|
+
n ? /* @__PURE__ */ i("span", { className: "x1vrk1b5 x111yfic", children: n }) : null
|
|
1496
|
+
] }),
|
|
1497
|
+
r ? /* @__PURE__ */ i("span", { className: "x2lah0s x1vrk1b5 x111yfic", children: r }) : null
|
|
1498
|
+
] });
|
|
1499
|
+
return e ? /* @__PURE__ */ i(ht, { to: e, className: "x78zum5 x6s0dn4 x1qughib x11cgr9k x21xpn4 x173sf5p x15jjofa x1hl2dhg xqjzbou xso031l x1q0q8m5 x4b2zrn x1t1lzn6 x1xcxyqb", children: s }) : /* @__PURE__ */ i("div", { className: "x78zum5 x6s0dn4 x1qughib x11cgr9k x21xpn4 x173sf5p x15jjofa x1hl2dhg xqjzbou xso031l x1q0q8m5 x4b2zrn x1t1lzn6 x1xcxyqb xt0e3qv", children: s });
|
|
1500
|
+
}
|
|
1501
|
+
function kr({
|
|
1502
|
+
children: e
|
|
1503
|
+
}) {
|
|
1504
|
+
return /* @__PURE__ */ i("div", { className: "x78zum5 xdt5ytf xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xb3r6kr", children: e });
|
|
1505
|
+
}
|
|
1506
|
+
function Sr() {
|
|
1507
|
+
var t;
|
|
1508
|
+
const e = ((t = Me().control) == null ? void 0 : t.workspaces) ?? [];
|
|
1509
|
+
return /* @__PURE__ */ w(ae, { centered: !0, children: [
|
|
1510
|
+
/* @__PURE__ */ i(
|
|
1511
|
+
K,
|
|
1512
|
+
{
|
|
1513
|
+
title: "Workspaces",
|
|
1514
|
+
description: "Each workspace is a site and a team.",
|
|
1515
|
+
action: /* @__PURE__ */ i(We, { to: "/workspaces/new", children: "New workspace" })
|
|
1516
|
+
}
|
|
1517
|
+
),
|
|
1518
|
+
e.length === 0 ? /* @__PURE__ */ i(R, { tone: "muted", children: "No workspaces yet." }) : /* @__PURE__ */ i(kr, { children: e.map((n) => /* @__PURE__ */ i(
|
|
1519
|
+
wr,
|
|
1520
|
+
{
|
|
1521
|
+
to: xt(n.slug),
|
|
1522
|
+
title: n.name,
|
|
1523
|
+
meta: n.role
|
|
1524
|
+
},
|
|
1525
|
+
n.id
|
|
1526
|
+
)) })
|
|
1527
|
+
] });
|
|
1528
|
+
}
|
|
1529
|
+
function Rr() {
|
|
1530
|
+
const e = $e(), [t, n] = E(""), [r, s] = E(null), [a, l] = E(!1);
|
|
1531
|
+
async function d(o) {
|
|
1532
|
+
o.preventDefault(), l(!0), s(null);
|
|
1533
|
+
try {
|
|
1534
|
+
const { workspace: u } = await gt(t), c = F.getState().control;
|
|
1535
|
+
c && F.applyControl({
|
|
1536
|
+
...c,
|
|
1537
|
+
workspaces: [
|
|
1538
|
+
...c.workspaces,
|
|
1539
|
+
{
|
|
1540
|
+
id: u.id,
|
|
1541
|
+
name: u.name,
|
|
1542
|
+
slug: u.slug,
|
|
1543
|
+
role: u.role
|
|
1544
|
+
}
|
|
1545
|
+
]
|
|
1546
|
+
}), e(`/${u.slug}`);
|
|
1547
|
+
} catch (u) {
|
|
1548
|
+
s(u instanceof Error ? u.message : "Failed to create workspace");
|
|
1549
|
+
} finally {
|
|
1550
|
+
l(!1);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return /* @__PURE__ */ w(ae, { children: [
|
|
1554
|
+
/* @__PURE__ */ i(
|
|
1555
|
+
K,
|
|
1556
|
+
{
|
|
1557
|
+
kicker: /* @__PURE__ */ i(pt, { to: "/workspaces", children: "← Workspaces" }),
|
|
1558
|
+
title: "Create workspace"
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
/* @__PURE__ */ i("form", { onSubmit: d, children: /* @__PURE__ */ w(se, { children: [
|
|
1562
|
+
/* @__PURE__ */ i(Q, { label: "Name", children: /* @__PURE__ */ i(
|
|
1563
|
+
Z,
|
|
1564
|
+
{
|
|
1565
|
+
required: !0,
|
|
1566
|
+
value: t,
|
|
1567
|
+
onChange: (o) => n(o.target.value),
|
|
1568
|
+
placeholder: "Docs site"
|
|
1569
|
+
}
|
|
1570
|
+
) }),
|
|
1571
|
+
r ? /* @__PURE__ */ i(R, { tone: "danger", children: r }) : null,
|
|
1572
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(oe, { type: "submit", disabled: a, children: a ? "Creating…" : "Create workspace" }) })
|
|
1573
|
+
] }) })
|
|
1574
|
+
] });
|
|
1575
|
+
}
|
|
1576
|
+
function Er(e, t) {
|
|
1577
|
+
switch (e) {
|
|
1578
|
+
case "invite_expired":
|
|
1579
|
+
return "This invite has expired. Ask for a new one.";
|
|
1580
|
+
case "invite_revoked":
|
|
1581
|
+
return "This invite was revoked.";
|
|
1582
|
+
case "not_found":
|
|
1583
|
+
return "This invite link is not valid.";
|
|
1584
|
+
case "last_admin":
|
|
1585
|
+
return "Accepting this invite would remove the last admin.";
|
|
1586
|
+
case "email_unverified":
|
|
1587
|
+
return "Verify this email before joining. Sign out, then choose “Email me a magic link” on the sign-in screen.";
|
|
1588
|
+
default:
|
|
1589
|
+
return t;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
function _r() {
|
|
1593
|
+
const [e] = be(), t = $e(), n = e.get("token") ?? "", r = e.get("email") ?? "", [s, a] = E(null), [l, d] = E(null), [o, u] = E(!1);
|
|
1594
|
+
W(() => {
|
|
1595
|
+
if (!n) {
|
|
1596
|
+
a("This invite link is missing a token.");
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
let p = !1;
|
|
1600
|
+
return mt(n).then((x) => {
|
|
1601
|
+
p || t(`/${x.slug}`, { replace: !0 });
|
|
1602
|
+
}).catch(async (x) => {
|
|
1603
|
+
if (p) return;
|
|
1604
|
+
const h = x && typeof x == "object" && "code" in x ? x.code : void 0;
|
|
1605
|
+
if (h === "invite_email_mismatch" || h === "unauthorized") {
|
|
1606
|
+
const v = await we().catch(() => null);
|
|
1607
|
+
if (p) return;
|
|
1608
|
+
d((v == null ? void 0 : v.user.email) ?? null), u(!0);
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1611
|
+
const g = x instanceof Error ? x.message : "Could not accept invite";
|
|
1612
|
+
a(Er(h, g));
|
|
1613
|
+
}), () => {
|
|
1614
|
+
p = !0;
|
|
1615
|
+
};
|
|
1616
|
+
}, [t, n]);
|
|
1617
|
+
async function c() {
|
|
1618
|
+
await H().signOut().catch(() => {
|
|
1619
|
+
}), ee(), F.wipe(), window.location.assign(window.location.href);
|
|
1620
|
+
}
|
|
1621
|
+
return /* @__PURE__ */ w(ae, { centered: !0, children: [
|
|
1622
|
+
/* @__PURE__ */ i(K, { title: "Accept invite" }),
|
|
1623
|
+
o ? /* @__PURE__ */ w(se, { children: [
|
|
1624
|
+
/* @__PURE__ */ i(R, { children: l ? `You're signed in as ${l}. This invite is for ${r || "someone else"}.` : `Sign in as ${r || "the invited email"} to join.` }),
|
|
1625
|
+
/* @__PURE__ */ i(R, { size: "sm", tone: "muted", children: "Password and GitHub stay on the next screen. A magic link sends one more email to that address." }),
|
|
1626
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(oe, { type: "button", variant: "secondary", onClick: () => void c(), children: r ? `Sign in as ${r}` : "Sign in to continue" }) })
|
|
1627
|
+
] }) : s ? /* @__PURE__ */ i(R, { tone: "danger", children: s }) : /* @__PURE__ */ i(R, { tone: "muted", children: "Joining workspace…" })
|
|
1628
|
+
] });
|
|
1629
|
+
}
|
|
1630
|
+
function jr() {
|
|
1631
|
+
const { email: e, userId: t } = Fe(), [n, r] = E(""), [s, a] = E(null), [l, d] = E(null), [o, u] = E(!1);
|
|
1632
|
+
W(() => {
|
|
1633
|
+
we().then((p) => {
|
|
1634
|
+
p != null && p.user.name && r(p.user.name);
|
|
1635
|
+
});
|
|
1636
|
+
}, []);
|
|
1637
|
+
async function c(p) {
|
|
1638
|
+
p.preventDefault(), u(!0), d(null), a(null);
|
|
1639
|
+
const x = await H().updateUser({ name: n });
|
|
1640
|
+
if (u(!1), x.error) {
|
|
1641
|
+
d(x.error.message ?? "Could not save name");
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
a("Name saved. New publishes will use it.");
|
|
1645
|
+
}
|
|
1646
|
+
return /* @__PURE__ */ w(ae, { children: [
|
|
1647
|
+
/* @__PURE__ */ i(
|
|
1648
|
+
K,
|
|
1649
|
+
{
|
|
1650
|
+
title: "User settings",
|
|
1651
|
+
description: "Your account on this Backmatter instance."
|
|
1652
|
+
}
|
|
1653
|
+
),
|
|
1654
|
+
/* @__PURE__ */ w(se, { gap: "lg", children: [
|
|
1655
|
+
/* @__PURE__ */ i(yt, { children: /* @__PURE__ */ i("form", { onSubmit: (p) => void c(p), children: /* @__PURE__ */ w(se, { children: [
|
|
1656
|
+
/* @__PURE__ */ i(R, { as: "h2", size: "lg", weight: "medium", children: "Account" }),
|
|
1657
|
+
/* @__PURE__ */ i(Q, { label: "Name", children: /* @__PURE__ */ i(Z, { value: n, onChange: (p) => r(p.target.value), autoComplete: "name" }) }),
|
|
1658
|
+
/* @__PURE__ */ i(Q, { label: "Email", children: /* @__PURE__ */ i(
|
|
1659
|
+
Z,
|
|
1660
|
+
{
|
|
1661
|
+
type: "email",
|
|
1662
|
+
value: e,
|
|
1663
|
+
readOnly: !0,
|
|
1664
|
+
autoComplete: "off",
|
|
1665
|
+
spellCheck: !1
|
|
1666
|
+
}
|
|
1667
|
+
) }),
|
|
1668
|
+
/* @__PURE__ */ i(Q, { label: "User ID", hint: "Stable id for this account.", children: /* @__PURE__ */ i(
|
|
1669
|
+
Z,
|
|
1670
|
+
{
|
|
1671
|
+
value: t,
|
|
1672
|
+
readOnly: !0,
|
|
1673
|
+
autoComplete: "off",
|
|
1674
|
+
spellCheck: !1
|
|
1675
|
+
}
|
|
1676
|
+
) }),
|
|
1677
|
+
l ? /* @__PURE__ */ i(R, { tone: "danger", children: l }) : null,
|
|
1678
|
+
s ? /* @__PURE__ */ i(R, { tone: "muted", children: s }) : null,
|
|
1679
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(oe, { type: "submit", disabled: o, children: o ? "Saving…" : "Save name" }) })
|
|
1680
|
+
] }) }) }),
|
|
1681
|
+
/* @__PURE__ */ w("div", { children: [
|
|
1682
|
+
/* @__PURE__ */ i(
|
|
1683
|
+
K,
|
|
1684
|
+
{
|
|
1685
|
+
title: "Connectors",
|
|
1686
|
+
description: "Personal MCP servers that follow you across workspaces.",
|
|
1687
|
+
compact: !0
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
/* @__PURE__ */ i(vt, { scope: "user", canEdit: !0 })
|
|
1691
|
+
] })
|
|
1692
|
+
] })
|
|
1693
|
+
] });
|
|
1694
|
+
}
|
|
1695
|
+
function Tr({
|
|
1696
|
+
email: e
|
|
1697
|
+
}) {
|
|
1698
|
+
const [t] = be(), n = t.get("id") ?? "", [r, s] = E(null), [a, l] = E(null), [d, o] = E(""), [u, c] = E("idle"), [p, x] = E(null);
|
|
1699
|
+
W(() => {
|
|
1700
|
+
if (!n) {
|
|
1701
|
+
l("This link has no login id. Run backmatter login again.");
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
let g = !0;
|
|
1705
|
+
return Promise.all([bt(n), wt()]).then(([v, {
|
|
1706
|
+
workspaces: y
|
|
1707
|
+
}]) => {
|
|
1708
|
+
var k;
|
|
1709
|
+
g && (s({
|
|
1710
|
+
request: v,
|
|
1711
|
+
workspaces: y
|
|
1712
|
+
}), o(((k = v.workspace) == null ? void 0 : k.id) ?? (y.length === 1 ? y[0].id : "")));
|
|
1713
|
+
}).catch(() => {
|
|
1714
|
+
g && l("This login has expired or was already used. Run backmatter login again.");
|
|
1715
|
+
}), () => {
|
|
1716
|
+
g = !1;
|
|
1717
|
+
};
|
|
1718
|
+
}, [n]);
|
|
1719
|
+
const h = (r == null ? void 0 : r.workspaces.find((g) => g.id === d)) ?? null;
|
|
1720
|
+
return /* @__PURE__ */ i("main", { className: "x78zum5 x9f619 xh8yej3 x1ov3xa9 x6s0dn4 xl56j7k x1y5dg2c x86kjsi xqjzbou", children: /* @__PURE__ */ w("div", { className: "x78zum5 xh8yej3 xxc7z9f xdt5ytf x1cy8zhl x11cgr9k x9f619 xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb x1y5dg2c x1vrk1b5", children: [
|
|
1721
|
+
/* @__PURE__ */ i(R, { as: "h1", size: "xl", weight: "medium", children: "Allow the CLI" }),
|
|
1722
|
+
a ? /* @__PURE__ */ i(R, { tone: "danger", children: a }) : null,
|
|
1723
|
+
!r && !a ? /* @__PURE__ */ i(R, { tone: "muted", children: "Loading…" }) : null,
|
|
1724
|
+
r && u === "done" ? /* @__PURE__ */ w(R, { children: [
|
|
1725
|
+
"The CLI is signed in to ",
|
|
1726
|
+
(h == null ? void 0 : h.name) ?? "the workspace",
|
|
1727
|
+
". You can return to the terminal."
|
|
1728
|
+
] }) : null,
|
|
1729
|
+
r && u !== "done" ? /* @__PURE__ */ w(re, { children: [
|
|
1730
|
+
/* @__PURE__ */ w("div", { className: "x78zum5 xdt5ytf xpw8yq9 xh8yej3 x9f619 xk7greg x13oidi x1d0qn7y", children: [
|
|
1731
|
+
/* @__PURE__ */ w(R, { tone: "muted", size: "sm", children: [
|
|
1732
|
+
"Confirm this code matches your terminal",
|
|
1733
|
+
r.request.client ? ` on ${r.request.client}` : "",
|
|
1734
|
+
":"
|
|
1735
|
+
] }),
|
|
1736
|
+
/* @__PURE__ */ i(R, { mono: !0, size: "display", weight: "semibold", children: r.request.userCode })
|
|
1737
|
+
] }),
|
|
1738
|
+
/* @__PURE__ */ i(R, { tone: "muted", children: "If you did not just run backmatter login, close this page." }),
|
|
1739
|
+
r.request.workspace ? /* @__PURE__ */ w(R, { children: [
|
|
1740
|
+
"The CLI can act as ",
|
|
1741
|
+
e,
|
|
1742
|
+
" in ",
|
|
1743
|
+
/* @__PURE__ */ i("strong", { children: r.request.workspace.name }),
|
|
1744
|
+
", and only there."
|
|
1745
|
+
] }) : r.workspaces.length === 0 ? /* @__PURE__ */ i(R, { tone: "danger", children: "You are not a member of any workspace yet." }) : /* @__PURE__ */ w("fieldset", { className: "x78zum5 xdt5ytf x3smv4v xh8yej3 x1ghz6dp x1717udv xc342km", children: [
|
|
1746
|
+
/* @__PURE__ */ w("legend", { className: "x1717udv x48x4vj x17tv04q", children: [
|
|
1747
|
+
"The CLI can act as ",
|
|
1748
|
+
e,
|
|
1749
|
+
" in one workspace. Which one?"
|
|
1750
|
+
] }),
|
|
1751
|
+
r.workspaces.map((g) => /* @__PURE__ */ w("label", { className: "x78zum5 x6s0dn4 x1ndbd79 x17tv04q x1ypdohk", children: [
|
|
1752
|
+
/* @__PURE__ */ i("input", { type: "radio", name: "workspace", value: g.id, checked: d === g.id, onChange: () => o(g.id) }),
|
|
1753
|
+
/* @__PURE__ */ i("span", { children: g.name }),
|
|
1754
|
+
/* @__PURE__ */ i("span", { className: "x111yfic x1ar5oo6 x10qp4ay", children: g.slug })
|
|
1755
|
+
] }, g.id))
|
|
1756
|
+
] }),
|
|
1757
|
+
p ? /* @__PURE__ */ i(R, { tone: "danger", children: p }) : null,
|
|
1758
|
+
/* @__PURE__ */ i(oe, { disabled: !d || u === "busy", onClick: () => {
|
|
1759
|
+
x(null), c("busy"), kt(n, d).then(() => c("done")).catch((g) => {
|
|
1760
|
+
c("idle"), x(g instanceof Error ? g.message : "Could not approve");
|
|
1761
|
+
});
|
|
1762
|
+
}, children: h ? `Allow in ${h.name}` : "Allow" })
|
|
1763
|
+
] }) : null
|
|
1764
|
+
] }) });
|
|
1765
|
+
}
|
|
1766
|
+
function Pr({
|
|
1767
|
+
userId: e
|
|
1768
|
+
}) {
|
|
1769
|
+
const [t, n] = E({
|
|
1770
|
+
kind: "working"
|
|
1771
|
+
});
|
|
1772
|
+
return W(() => {
|
|
1773
|
+
const r = St(window.location.search);
|
|
1774
|
+
if (!r) {
|
|
1775
|
+
n({
|
|
1776
|
+
kind: "error",
|
|
1777
|
+
message: "This link is missing the workspace or the page to return to."
|
|
1778
|
+
});
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
let s = !1;
|
|
1782
|
+
return (async () => {
|
|
1783
|
+
try {
|
|
1784
|
+
const {
|
|
1785
|
+
workspace: a
|
|
1786
|
+
} = await Rt(r.workspaceId), l = Et(r.returnUrl, a.siteUrls);
|
|
1787
|
+
if (!l) {
|
|
1788
|
+
n({
|
|
1789
|
+
kind: "error",
|
|
1790
|
+
message: "That site is not listed under this workspace. Add its origin in Settings → General first."
|
|
1791
|
+
});
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
const {
|
|
1795
|
+
ticket: d
|
|
1796
|
+
} = await _t(a.id, {
|
|
1797
|
+
redirect: l.redirect,
|
|
1798
|
+
tree: e
|
|
1799
|
+
});
|
|
1800
|
+
if (s) return;
|
|
1801
|
+
window.location.replace(jt(l.origin, d));
|
|
1802
|
+
} catch (a) {
|
|
1803
|
+
if (s) return;
|
|
1804
|
+
n({
|
|
1805
|
+
kind: "error",
|
|
1806
|
+
message: a instanceof Error ? a.message : "Could not open the site."
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
})(), () => {
|
|
1810
|
+
s = !0;
|
|
1811
|
+
};
|
|
1812
|
+
}, [e]), /* @__PURE__ */ i("div", { className: "x1ov3xa9 xrvj5dj x1ku5rj1 x1t7e3gq", children: /* @__PURE__ */ i("div", { className: "x78zum5 xdt5ytf x1ndbd79 x1lr1uin x1t7e3gq x4pepcl x1d0qn7y", children: t.kind === "working" ? /* @__PURE__ */ w(re, { children: [
|
|
1813
|
+
/* @__PURE__ */ i(R, { size: "lg", weight: "medium", children: "Opening your site…" }),
|
|
1814
|
+
/* @__PURE__ */ i(R, { tone: "muted", children: "Setting up editing on the site and sending you back." })
|
|
1815
|
+
] }) : /* @__PURE__ */ w(re, { children: [
|
|
1816
|
+
/* @__PURE__ */ i(R, { size: "lg", weight: "medium", children: "Could not open the site" }),
|
|
1817
|
+
/* @__PURE__ */ i(R, { tone: "muted", children: t.message }),
|
|
1818
|
+
/* @__PURE__ */ i(We, { to: "/", variant: "secondary", children: "Back to the dashboard" })
|
|
1819
|
+
] }) }) });
|
|
1820
|
+
}
|
|
1821
|
+
function Or(e) {
|
|
1822
|
+
if (!Tt()) return !1;
|
|
1823
|
+
const t = e.replace(/\/$/, "") || "/";
|
|
1824
|
+
return t === "/__ui" || /^\/__ui\/[^/]+$/.test(t);
|
|
1825
|
+
}
|
|
1826
|
+
const Lr = ot(() => import("./UiKitApp-CgGyJiC4.js").then((e) => ({
|
|
1827
|
+
default: e.UiKitApp
|
|
1828
|
+
})));
|
|
1829
|
+
function Ir() {
|
|
1830
|
+
return /* @__PURE__ */ i(Pt, { children: /* @__PURE__ */ i(Ot, { children: /* @__PURE__ */ i(Nr, {}) }) });
|
|
1831
|
+
}
|
|
1832
|
+
function Nr() {
|
|
1833
|
+
const e = Lt(), [t, n] = E(() => {
|
|
1834
|
+
const r = Nt();
|
|
1835
|
+
return r ? {
|
|
1836
|
+
user: r
|
|
1837
|
+
} : "loading";
|
|
1838
|
+
});
|
|
1839
|
+
return W(() => {
|
|
1840
|
+
we().then((r) => {
|
|
1841
|
+
if (!(r != null && r.user)) {
|
|
1842
|
+
ee(), F.wipe(), n(null);
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
if (Ut(r.user), n({
|
|
1846
|
+
user: {
|
|
1847
|
+
id: r.user.id,
|
|
1848
|
+
email: r.user.email
|
|
1849
|
+
}
|
|
1850
|
+
}), F.getState().sessionUserId !== r.user.id) {
|
|
1851
|
+
const s = At(window.location.pathname);
|
|
1852
|
+
F.hydrate(r.user.id, s ?? De(r.user.id));
|
|
1853
|
+
}
|
|
1854
|
+
}).catch(() => {
|
|
1855
|
+
ee(), F.wipe(), n(null);
|
|
1856
|
+
});
|
|
1857
|
+
}, []), Or(e.pathname) ? /* @__PURE__ */ i(lt, { fallback: /* @__PURE__ */ i("div", { className: "x1y5dg2c", children: /* @__PURE__ */ i(R, { tone: "muted", children: "Loading kit…" }) }), children: /* @__PURE__ */ i(Lr, {}) }) : pr(e.pathname) ? /* @__PURE__ */ i(vr, {}) : t === "loading" ? /* @__PURE__ */ i(Ct, {}) : t ? e.pathname.replace(/\/$/, "") === "/enter" ? /* @__PURE__ */ i(Pr, { userId: t.user.id }) : qt(e.pathname) ? /* @__PURE__ */ i(Tr, { email: t.user.email }) : /* @__PURE__ */ i(It, { user: t.user, children: /* @__PURE__ */ i(zt, { children: /* @__PURE__ */ i(Bt, { userId: t.user.id, email: t.user.email, onLogout: () => {
|
|
1858
|
+
ee(), F.wipe(), H().signOut().then(() => {
|
|
1859
|
+
n(null);
|
|
1860
|
+
}).catch(() => {
|
|
1861
|
+
n(null);
|
|
1862
|
+
});
|
|
1863
|
+
}, children: /* @__PURE__ */ w(Ft, { children: [
|
|
1864
|
+
/* @__PURE__ */ i(D, { path: "/", element: /* @__PURE__ */ i(br, {}) }),
|
|
1865
|
+
/* @__PURE__ */ i(D, { path: "/workspaces", element: /* @__PURE__ */ i(Sr, {}) }),
|
|
1866
|
+
/* @__PURE__ */ i(D, { path: "/workspaces/new", element: /* @__PURE__ */ i(Rr, {}) }),
|
|
1867
|
+
/* @__PURE__ */ i(D, { path: "/invite", element: /* @__PURE__ */ i(_r, {}) }),
|
|
1868
|
+
/* @__PURE__ */ i(D, { path: "/account", element: /* @__PURE__ */ i(jr, {}) }),
|
|
1869
|
+
/* @__PURE__ */ i(D, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ i(Mt, {}) }),
|
|
1870
|
+
Dt(),
|
|
1871
|
+
/* @__PURE__ */ i(D, { path: "*", element: /* @__PURE__ */ i(He, { to: "/", replace: !0 }) })
|
|
1872
|
+
] }) }) }) }) : /* @__PURE__ */ i(yr, {});
|
|
1873
|
+
}
|
|
1874
|
+
export {
|
|
1875
|
+
Ir as A,
|
|
1876
|
+
kr as L,
|
|
1877
|
+
wr as a,
|
|
1878
|
+
Or as i
|
|
1879
|
+
};
|