@hiai-gg/docsmint 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -23
- package/{packages/sdk/dist → dist}/client.d.ts +16 -1
- package/{packages/sdk/dist → dist}/client.js +25 -1
- package/dist/frontend/DatePicker-BcMD49PV.js +275 -0
- package/dist/frontend/SettingsDialog-DiAyhzw0.js +4852 -0
- package/dist/frontend/ShareDialog-DaZf1raY.js +1317 -0
- package/dist/frontend/api/categories.d.ts +10 -0
- package/dist/frontend/api/categories.js +2 -0
- package/dist/frontend/api/documents.d.ts +10 -0
- package/dist/frontend/api/documents.js +2 -0
- package/dist/frontend/api/folders.d.ts +10 -0
- package/dist/frontend/api/folders.js +2 -0
- package/dist/frontend/api/settings.d.ts +8 -0
- package/dist/frontend/api/settings.js +2 -0
- package/dist/frontend/api/tags.d.ts +11 -0
- package/dist/frontend/api/tags.js +2 -0
- package/dist/frontend/categories-BE6ZpZl8.js +61 -0
- package/dist/frontend/client-B9hzI0W8.js +76 -0
- package/dist/frontend/client-C6QQGb0e.js +2766 -0
- package/dist/frontend/components/settings.d.ts +2 -0
- package/dist/frontend/components/settings.js +2 -0
- package/dist/frontend/components/sidebar.d.ts +2 -0
- package/dist/frontend/components/sidebar.js +4569 -0
- package/dist/frontend/context-DbnW5yib.js +31 -0
- package/dist/frontend/dashboard.d.ts +2 -0
- package/dist/frontend/dashboard.js +2152 -0
- package/dist/frontend/documents-DFVS9SsL.js +83 -0
- package/dist/frontend/extension.d.ts +2 -0
- package/dist/frontend/extension.js +10 -0
- package/dist/frontend/folders-CGe9diAG.js +91 -0
- package/dist/frontend/frontend.css +2 -0
- package/dist/frontend/i18n.d.ts +5 -0
- package/dist/frontend/i18n.js +8 -0
- package/dist/frontend/input-ieWIt8I7.js +257 -0
- package/dist/frontend/messages-CTGAsqFu.js +1106 -0
- package/dist/frontend/resolve-Bl6xmJl_.js +2068 -0
- package/dist/frontend/schemas-DwtKylCJ.js +3002 -0
- package/dist/frontend/search.d.ts +2 -0
- package/dist/frontend/search.js +1001 -0
- package/dist/frontend/settings-PCrOtied.js +1313 -0
- package/dist/frontend/shared-document.d.ts +3 -0
- package/dist/frontend/shared-document.js +193 -0
- package/dist/frontend/tag-C5xrg-bb.js +53 -0
- package/dist/frontend/tag-store.svelte-B3839FYq.js +6152 -0
- package/dist/frontend/tags-DVXTut0p.js +48 -0
- package/dist/frontend/theme.d.ts +4 -0
- package/dist/frontend/theme.js +8 -0
- package/dist/frontend/theme.svelte-ei0QxXa8.js +49 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/lifecycle.d.ts +90 -0
- package/dist/lifecycle.js +99 -0
- package/{packages/sdk/dist → dist}/types.d.ts +5 -0
- package/dist/workspace.d.ts +21 -0
- package/dist/workspace.js +66 -0
- package/package.json +70 -36
- package/packages/cli/src/index.ts +1 -1
- package/packages/db/src/schema.ts +41 -0
- package/packages/mcp-server/src/index.ts +1 -1
- package/frontend/src/lib/components/editor/shared-document.ts +0 -237
- package/frontend/src/lib/extensions/context.ts +0 -60
- package/frontend/src/lib/extensions/doc-tabs.ts +0 -18
- package/frontend/src/lib/extensions/resolve.ts +0 -48
- package/frontend/src/lib/extensions/types.ts +0 -202
- package/frontend/src/lib/hosts/DocsmintSharedDocumentHost.svelte +0 -65
- package/frontend/src/lib/hosts/HiaiDocsDashboardHost.svelte +0 -1007
- package/frontend/src/lib/hosts/HiaiDocsExtensionProvider.svelte +0 -20
- package/frontend/src/lib/hosts/HiaiDocsSearchHost.svelte +0 -996
- package/frontend/src/lib/hosts/index.ts +0 -25
- package/frontend/src/lib/index.ts +0 -65
- package/frontend/src/lib/stores/doc-tab-registry.svelte.ts +0 -68
- package/packages/sdk/dist/index.d.ts +0 -3
- package/packages/sdk/dist/index.js +0 -1
- /package/{packages/sdk/dist → dist}/types.js +0 -0
|
@@ -0,0 +1,1313 @@
|
|
|
1
|
+
import { t as e } from "./client-B9hzI0W8.js";
|
|
2
|
+
//#region ../node_modules/.bun/@better-auth+core@1.6.22+97ef1a25343ecf7e/node_modules/@better-auth/core/dist/env/env-impl.mjs
|
|
3
|
+
var t = Object.create(null), n = (e) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? t : globalThis), r = new Proxy(t, {
|
|
4
|
+
get(e, r) {
|
|
5
|
+
return n()[r] ?? t[r];
|
|
6
|
+
},
|
|
7
|
+
has(e, r) {
|
|
8
|
+
return r in n() || r in t;
|
|
9
|
+
},
|
|
10
|
+
set(e, t, r) {
|
|
11
|
+
let i = n(!0);
|
|
12
|
+
return i[t] = r, !0;
|
|
13
|
+
},
|
|
14
|
+
deleteProperty(e, t) {
|
|
15
|
+
if (!t) return !1;
|
|
16
|
+
let r = n(!0);
|
|
17
|
+
return delete r[t], !0;
|
|
18
|
+
},
|
|
19
|
+
ownKeys() {
|
|
20
|
+
let e = n(!0);
|
|
21
|
+
return Object.keys(e);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
r.NODE_ENV;
|
|
25
|
+
function i(e, t) {
|
|
26
|
+
return typeof process < "u" && process.env ? process.env[e] ?? t : typeof Deno < "u" ? Deno.env.get(e) ?? t : typeof Bun < "u" ? Bun.env[e] ?? t : t;
|
|
27
|
+
}
|
|
28
|
+
Object.freeze({
|
|
29
|
+
get BETTER_AUTH_SECRET() {
|
|
30
|
+
return i("BETTER_AUTH_SECRET");
|
|
31
|
+
},
|
|
32
|
+
get AUTH_SECRET() {
|
|
33
|
+
return i("AUTH_SECRET");
|
|
34
|
+
},
|
|
35
|
+
get BETTER_AUTH_TELEMETRY() {
|
|
36
|
+
return i("BETTER_AUTH_TELEMETRY");
|
|
37
|
+
},
|
|
38
|
+
get BETTER_AUTH_TELEMETRY_ID() {
|
|
39
|
+
return i("BETTER_AUTH_TELEMETRY_ID");
|
|
40
|
+
},
|
|
41
|
+
get NODE_ENV() {
|
|
42
|
+
return i("NODE_ENV", "development");
|
|
43
|
+
},
|
|
44
|
+
get PACKAGE_VERSION() {
|
|
45
|
+
return i("PACKAGE_VERSION", "0.0.0");
|
|
46
|
+
},
|
|
47
|
+
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
48
|
+
return i("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../node_modules/.bun/better-call@1.3.7+68a1e3a0c4588df3/node_modules/better-call/dist/error.mjs
|
|
53
|
+
function a() {
|
|
54
|
+
let e = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
55
|
+
return e === void 0 ? Object.isExtensible(Error) : Object.prototype.hasOwnProperty.call(e, "writable") ? e.writable : e.set !== void 0;
|
|
56
|
+
}
|
|
57
|
+
function o(e) {
|
|
58
|
+
let t = e.split("\n at ");
|
|
59
|
+
return t.length <= 1 ? e : (t.splice(1, 1), t.join("\n at "));
|
|
60
|
+
}
|
|
61
|
+
function s(e, t) {
|
|
62
|
+
class n extends e {
|
|
63
|
+
#e;
|
|
64
|
+
constructor(...e) {
|
|
65
|
+
if (a()) {
|
|
66
|
+
let t = Error.stackTraceLimit;
|
|
67
|
+
Error.stackTraceLimit = 0, super(...e), Error.stackTraceLimit = t;
|
|
68
|
+
} else super(...e);
|
|
69
|
+
let t = (/* @__PURE__ */ Error()).stack;
|
|
70
|
+
t && (this.#e = o(t.replace(/^Error/, this.name)));
|
|
71
|
+
}
|
|
72
|
+
get errorStack() {
|
|
73
|
+
return this.#e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return Object.defineProperty(n.prototype, "constructor", {
|
|
77
|
+
get() {
|
|
78
|
+
return t;
|
|
79
|
+
},
|
|
80
|
+
enumerable: !1,
|
|
81
|
+
configurable: !0
|
|
82
|
+
}), n;
|
|
83
|
+
}
|
|
84
|
+
var c = {
|
|
85
|
+
OK: 200,
|
|
86
|
+
CREATED: 201,
|
|
87
|
+
ACCEPTED: 202,
|
|
88
|
+
NO_CONTENT: 204,
|
|
89
|
+
MULTIPLE_CHOICES: 300,
|
|
90
|
+
MOVED_PERMANENTLY: 301,
|
|
91
|
+
FOUND: 302,
|
|
92
|
+
SEE_OTHER: 303,
|
|
93
|
+
NOT_MODIFIED: 304,
|
|
94
|
+
TEMPORARY_REDIRECT: 307,
|
|
95
|
+
BAD_REQUEST: 400,
|
|
96
|
+
UNAUTHORIZED: 401,
|
|
97
|
+
PAYMENT_REQUIRED: 402,
|
|
98
|
+
FORBIDDEN: 403,
|
|
99
|
+
NOT_FOUND: 404,
|
|
100
|
+
METHOD_NOT_ALLOWED: 405,
|
|
101
|
+
NOT_ACCEPTABLE: 406,
|
|
102
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
103
|
+
REQUEST_TIMEOUT: 408,
|
|
104
|
+
CONFLICT: 409,
|
|
105
|
+
GONE: 410,
|
|
106
|
+
LENGTH_REQUIRED: 411,
|
|
107
|
+
PRECONDITION_FAILED: 412,
|
|
108
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
109
|
+
URI_TOO_LONG: 414,
|
|
110
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
111
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
112
|
+
EXPECTATION_FAILED: 417,
|
|
113
|
+
"I'M_A_TEAPOT": 418,
|
|
114
|
+
MISDIRECTED_REQUEST: 421,
|
|
115
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
116
|
+
LOCKED: 423,
|
|
117
|
+
FAILED_DEPENDENCY: 424,
|
|
118
|
+
TOO_EARLY: 425,
|
|
119
|
+
UPGRADE_REQUIRED: 426,
|
|
120
|
+
PRECONDITION_REQUIRED: 428,
|
|
121
|
+
TOO_MANY_REQUESTS: 429,
|
|
122
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
123
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
124
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
125
|
+
NOT_IMPLEMENTED: 501,
|
|
126
|
+
BAD_GATEWAY: 502,
|
|
127
|
+
SERVICE_UNAVAILABLE: 503,
|
|
128
|
+
GATEWAY_TIMEOUT: 504,
|
|
129
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
130
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
131
|
+
INSUFFICIENT_STORAGE: 507,
|
|
132
|
+
LOOP_DETECTED: 508,
|
|
133
|
+
NOT_EXTENDED: 510,
|
|
134
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
135
|
+
};
|
|
136
|
+
s(class extends Error {
|
|
137
|
+
constructor(e = "INTERNAL_SERVER_ERROR", t = void 0, n = {}, r = typeof e == "number" ? e : c[e]) {
|
|
138
|
+
super(t?.message, t?.cause ? { cause: t.cause } : void 0), this.status = e, this.body = t, this.headers = n, this.statusCode = r, this.name = "APIError", this.status = e, this.headers = n, this.statusCode = r, this.body = t;
|
|
139
|
+
}
|
|
140
|
+
}, Error);
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region ../node_modules/.bun/@better-auth+core@1.6.22+97ef1a25343ecf7e/node_modules/@better-auth/core/dist/error/index.mjs
|
|
143
|
+
var l = class extends Error {
|
|
144
|
+
constructor(e, t) {
|
|
145
|
+
super(e, t), this.name = "BetterAuthError", this.message = e, this.stack = "";
|
|
146
|
+
}
|
|
147
|
+
}, u = 47;
|
|
148
|
+
function d(e) {
|
|
149
|
+
let t = e.length;
|
|
150
|
+
for (; t > 0 && e.charCodeAt(t - 1) === u;) t--;
|
|
151
|
+
return t === e.length ? e : e.slice(0, t);
|
|
152
|
+
}
|
|
153
|
+
function f(e) {
|
|
154
|
+
try {
|
|
155
|
+
return (d(new URL(e).pathname) || "/") !== "/";
|
|
156
|
+
} catch {
|
|
157
|
+
throw new l(`Invalid base URL: ${e}. Please provide a valid base URL.`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function p(e) {
|
|
161
|
+
try {
|
|
162
|
+
let t = new URL(e);
|
|
163
|
+
if (t.protocol !== "http:" && t.protocol !== "https:") throw new l(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`);
|
|
164
|
+
} catch (t) {
|
|
165
|
+
throw t instanceof l ? t : new l(`Invalid base URL: ${e}. Please provide a valid base URL.`, { cause: t });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function m(e, t = "/api/auth") {
|
|
169
|
+
if (p(e), f(e)) return e;
|
|
170
|
+
let n = d(e);
|
|
171
|
+
return !t || t === "/" ? n : (t = t.startsWith("/") ? t : `/${t}`, `${n}${t}`);
|
|
172
|
+
}
|
|
173
|
+
function h(e, t) {
|
|
174
|
+
return !e || e.trim() === "" ? !1 : t === "proto" ? e === "http" || e === "https" : t === "host" ? [
|
|
175
|
+
/\.\./,
|
|
176
|
+
/\0/,
|
|
177
|
+
/[\s]/,
|
|
178
|
+
/^[.]/,
|
|
179
|
+
/[<>'"]/,
|
|
180
|
+
/javascript:/i,
|
|
181
|
+
/file:/i,
|
|
182
|
+
/data:/i
|
|
183
|
+
].some((t) => t.test(e)) ? !1 : /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e) || /^localhost(:[0-9]{1,5})?$/i.test(e) : !1;
|
|
184
|
+
}
|
|
185
|
+
function g(e, t, n, i, a) {
|
|
186
|
+
if (e) return m(e, t);
|
|
187
|
+
if (i !== !1) {
|
|
188
|
+
let e = r.BETTER_AUTH_URL || r.NEXT_PUBLIC_BETTER_AUTH_URL || r.PUBLIC_BETTER_AUTH_URL || r.NUXT_PUBLIC_BETTER_AUTH_URL || r.NUXT_PUBLIC_AUTH_URL || (r.BASE_URL === "/" ? void 0 : r.BASE_URL);
|
|
189
|
+
if (e) return m(e, t);
|
|
190
|
+
}
|
|
191
|
+
let o = n?.headers.get("x-forwarded-host"), s = n?.headers.get("x-forwarded-proto");
|
|
192
|
+
if (o && s && a && h(s, "proto") && h(o, "host")) try {
|
|
193
|
+
return m(`${s}://${o}`, t);
|
|
194
|
+
} catch {}
|
|
195
|
+
if (n) {
|
|
196
|
+
let e = _(n.url);
|
|
197
|
+
if (!e) throw new l("Could not get origin from request. Please provide a valid base URL.");
|
|
198
|
+
return m(e, t);
|
|
199
|
+
}
|
|
200
|
+
if (typeof window < "u" && window.location) return m(window.location.origin, t);
|
|
201
|
+
}
|
|
202
|
+
function _(e) {
|
|
203
|
+
try {
|
|
204
|
+
let t = new URL(e);
|
|
205
|
+
return t.origin === "null" ? null : t.origin;
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/parser.mjs
|
|
212
|
+
var v = {
|
|
213
|
+
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*:/,
|
|
214
|
+
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*:/,
|
|
215
|
+
protoShort: /"__proto__"\s*:/,
|
|
216
|
+
constructorShort: /"constructor"\s*:/
|
|
217
|
+
}, y = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/, b = {
|
|
218
|
+
true: !0,
|
|
219
|
+
false: !1,
|
|
220
|
+
null: null,
|
|
221
|
+
undefined: void 0,
|
|
222
|
+
nan: NaN,
|
|
223
|
+
infinity: Infinity,
|
|
224
|
+
"-infinity": -Infinity
|
|
225
|
+
}, x = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
226
|
+
function ee(e) {
|
|
227
|
+
return e instanceof Date && !isNaN(e.getTime());
|
|
228
|
+
}
|
|
229
|
+
function te(e) {
|
|
230
|
+
let t = x.exec(e);
|
|
231
|
+
if (!t) return null;
|
|
232
|
+
let [, n, r, i, a, o, s, c, l, u, d] = t, f = new Date(Date.UTC(parseInt(n, 10), parseInt(r, 10) - 1, parseInt(i, 10), parseInt(a, 10), parseInt(o, 10), parseInt(s, 10), c ? parseInt(c.padEnd(3, "0"), 10) : 0));
|
|
233
|
+
if (l) {
|
|
234
|
+
let e = (parseInt(u, 10) * 60 + parseInt(d, 10)) * (l === "+" ? -1 : 1);
|
|
235
|
+
f.setUTCMinutes(f.getUTCMinutes() + e);
|
|
236
|
+
}
|
|
237
|
+
return ee(f) ? f : null;
|
|
238
|
+
}
|
|
239
|
+
function ne(e, t = {}) {
|
|
240
|
+
let { strict: n = !1, warnings: r = !1, reviver: i, parseDates: a = !0 } = t;
|
|
241
|
+
if (typeof e != "string") return e;
|
|
242
|
+
let o = e.trim(), s = o.toLowerCase();
|
|
243
|
+
if (s.length <= 9 && s in b) return b[s];
|
|
244
|
+
if (!y.test(o)) {
|
|
245
|
+
if (n) throw SyntaxError("[better-json] Invalid JSON");
|
|
246
|
+
return e;
|
|
247
|
+
}
|
|
248
|
+
if (Object.entries(v).some(([e, t]) => {
|
|
249
|
+
let n = t.test(o);
|
|
250
|
+
return n && r && console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`), n;
|
|
251
|
+
}) && n) throw Error("[better-json] Potential prototype pollution attempt detected");
|
|
252
|
+
try {
|
|
253
|
+
return JSON.parse(o, (e, t) => {
|
|
254
|
+
if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) {
|
|
255
|
+
r && console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (a && typeof t == "string") {
|
|
259
|
+
let e = te(t);
|
|
260
|
+
if (e) return e;
|
|
261
|
+
}
|
|
262
|
+
return i ? i(e, t) : t;
|
|
263
|
+
});
|
|
264
|
+
} catch (t) {
|
|
265
|
+
if (n) throw t;
|
|
266
|
+
return e;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function re(e, t = { strict: !0 }) {
|
|
270
|
+
return ne(e, t);
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region ../node_modules/.bun/@better-auth+core@1.6.22+97ef1a25343ecf7e/node_modules/@better-auth/core/dist/utils/url.mjs
|
|
274
|
+
var ie = [
|
|
275
|
+
"javascript:",
|
|
276
|
+
"data:",
|
|
277
|
+
"vbscript:"
|
|
278
|
+
];
|
|
279
|
+
function ae(e) {
|
|
280
|
+
let t;
|
|
281
|
+
try {
|
|
282
|
+
t = new URL(e);
|
|
283
|
+
} catch {
|
|
284
|
+
return !0;
|
|
285
|
+
}
|
|
286
|
+
return !ie.includes(t.protocol);
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
290
|
+
var oe = {
|
|
291
|
+
id: "redirect",
|
|
292
|
+
name: "Redirect",
|
|
293
|
+
hooks: { onSuccess(e) {
|
|
294
|
+
if (e.data?.url && e.data?.redirect && ae(e.data.url) && typeof window < "u" && window.location && window.location) try {
|
|
295
|
+
window.location.href = e.data.url;
|
|
296
|
+
} catch {}
|
|
297
|
+
} }
|
|
298
|
+
}, S = Symbol("clean"), C = [], w = 0, T = 4, se = globalThis.nanostoresGlobal ||= { epoch: 0 }, E = /* @__NO_SIDE_EFFECTS__ */ (e) => {
|
|
299
|
+
let t = [], n = {
|
|
300
|
+
get() {
|
|
301
|
+
return n.lc || n.listen(() => {})(), n.value;
|
|
302
|
+
},
|
|
303
|
+
init: e,
|
|
304
|
+
lc: 0,
|
|
305
|
+
listen(e) {
|
|
306
|
+
return n.lc = t.push(e), () => {
|
|
307
|
+
for (let t = w + T; t < C.length;) C[t] === e ? C.splice(t, T) : t += T;
|
|
308
|
+
let r = t.indexOf(e);
|
|
309
|
+
~r && (t.splice(r, 1), --n.lc || n.off());
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
notify(e, r) {
|
|
313
|
+
se.epoch++;
|
|
314
|
+
let i = !C.length;
|
|
315
|
+
for (let i of t) C.push(i, n.value, e, r);
|
|
316
|
+
if (i) {
|
|
317
|
+
for (w = 0; w < C.length; w += T) C[w](C[w + 1], C[w + 2], C[w + 3]);
|
|
318
|
+
C.length = 0;
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
off() {},
|
|
322
|
+
set(e) {
|
|
323
|
+
let t = n.value;
|
|
324
|
+
t !== e && (n.value = e, n.notify(t));
|
|
325
|
+
},
|
|
326
|
+
subscribe(e) {
|
|
327
|
+
let t = n.listen(e);
|
|
328
|
+
return e(n.value), t;
|
|
329
|
+
},
|
|
330
|
+
value: e
|
|
331
|
+
};
|
|
332
|
+
return process.env.NODE_ENV !== "production" && (n[S] = () => {
|
|
333
|
+
t = [], n.lc = 0, n.off();
|
|
334
|
+
}), n;
|
|
335
|
+
}, ce = 2, le = 5, D = 6, O = 10, k = (e, t, n, r) => (e.events = e.events || {}, e.events[n + O] || (e.events[n + O] = r((t) => {
|
|
336
|
+
e.events[n].reduceRight((e, t) => (t(e), e), {
|
|
337
|
+
shared: {},
|
|
338
|
+
...t
|
|
339
|
+
});
|
|
340
|
+
})), e.events[n] = e.events[n] || [], e.events[n].push(t), () => {
|
|
341
|
+
let r = e.events[n], i = r.indexOf(t);
|
|
342
|
+
r.splice(i, 1), r.length || (delete e.events[n], e.events[n + O](), delete e.events[n + O]);
|
|
343
|
+
}), ue = (e, t) => k(e, t, ce, (t) => {
|
|
344
|
+
let n = e.set, r = e.setKey;
|
|
345
|
+
return e.setKey &&= (n, i) => {
|
|
346
|
+
let a;
|
|
347
|
+
if (t({
|
|
348
|
+
abort: () => {
|
|
349
|
+
a = !0;
|
|
350
|
+
},
|
|
351
|
+
changed: n,
|
|
352
|
+
newValue: {
|
|
353
|
+
...e.value,
|
|
354
|
+
[n]: i
|
|
355
|
+
}
|
|
356
|
+
}), !a) return r(n, i);
|
|
357
|
+
}, e.set = (e) => {
|
|
358
|
+
let r;
|
|
359
|
+
if (t({
|
|
360
|
+
abort: () => {
|
|
361
|
+
r = !0;
|
|
362
|
+
},
|
|
363
|
+
newValue: e
|
|
364
|
+
}), !r) return n(e);
|
|
365
|
+
}, () => {
|
|
366
|
+
e.set = n, e.setKey = r;
|
|
367
|
+
};
|
|
368
|
+
}), de = 1e3, fe = (e, t) => k(e, (n) => {
|
|
369
|
+
let r = t(n);
|
|
370
|
+
r && e.events[D].push(r);
|
|
371
|
+
}, le, (t) => {
|
|
372
|
+
let n = e.listen;
|
|
373
|
+
e.listen = (...r) => (!e.lc && !e.active && (e.active = !0, t()), n(...r));
|
|
374
|
+
let r = e.off;
|
|
375
|
+
if (e.events[D] = [], e.off = () => {
|
|
376
|
+
r(), setTimeout(() => {
|
|
377
|
+
if (e.active && !e.lc) {
|
|
378
|
+
e.active = !1;
|
|
379
|
+
for (let t of e.events[D]) t();
|
|
380
|
+
e.events[D] = [];
|
|
381
|
+
}
|
|
382
|
+
}, de);
|
|
383
|
+
}, process.env.NODE_ENV !== "production") {
|
|
384
|
+
let t = e[S];
|
|
385
|
+
e[S] = () => {
|
|
386
|
+
for (let t of e.events[D]) t();
|
|
387
|
+
e.events[D] = [], e.active = !1, t();
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return () => {
|
|
391
|
+
e.listen = n, e.off = r;
|
|
392
|
+
};
|
|
393
|
+
});
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/equality.mjs
|
|
396
|
+
function A(e) {
|
|
397
|
+
if (typeof e != "object" || !e) return !1;
|
|
398
|
+
let t = Object.getPrototypeOf(e);
|
|
399
|
+
return t === Object.prototype || t === null;
|
|
400
|
+
}
|
|
401
|
+
function j(e, t) {
|
|
402
|
+
if (e === t) return !0;
|
|
403
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
404
|
+
if (e.length !== t.length) return !1;
|
|
405
|
+
for (let n = 0; n < e.length; n++) if (!j(e[n], t[n])) return !1;
|
|
406
|
+
return !0;
|
|
407
|
+
}
|
|
408
|
+
if (A(e) && A(t)) {
|
|
409
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
410
|
+
if (n.length !== r.length) return !1;
|
|
411
|
+
for (let r of n) if (!(r in t) || !j(e[r], t[r])) return !1;
|
|
412
|
+
return !0;
|
|
413
|
+
}
|
|
414
|
+
return !1;
|
|
415
|
+
}
|
|
416
|
+
function pe(e, t) {
|
|
417
|
+
return ue(e, ({ newValue: n, abort: r }) => {
|
|
418
|
+
t(e.value, n) && r();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
423
|
+
var M = Symbol.for("better-auth:broadcast-channel"), me = () => Math.floor(Date.now() / 1e3), he = class {
|
|
424
|
+
listeners = /* @__PURE__ */ new Set();
|
|
425
|
+
name;
|
|
426
|
+
constructor(e = "better-auth.message") {
|
|
427
|
+
this.name = e;
|
|
428
|
+
}
|
|
429
|
+
subscribe(e) {
|
|
430
|
+
return this.listeners.add(e), () => {
|
|
431
|
+
this.listeners.delete(e);
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
post(e) {
|
|
435
|
+
if (!(typeof window > "u")) try {
|
|
436
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
437
|
+
...e,
|
|
438
|
+
timestamp: me()
|
|
439
|
+
}));
|
|
440
|
+
} catch {}
|
|
441
|
+
}
|
|
442
|
+
setup() {
|
|
443
|
+
if (typeof window > "u" || window.addEventListener === void 0) return () => {};
|
|
444
|
+
let e = (e) => {
|
|
445
|
+
if (e.key !== this.name) return;
|
|
446
|
+
let t = JSON.parse(e.newValue ?? "{}");
|
|
447
|
+
t?.event !== "session" || !t?.data || this.listeners.forEach((e) => e(t));
|
|
448
|
+
};
|
|
449
|
+
return window.addEventListener("storage", e), () => {
|
|
450
|
+
window.removeEventListener("storage", e);
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
function N(e = "better-auth.message") {
|
|
455
|
+
return globalThis[M] || (globalThis[M] = new he(e)), globalThis[M];
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
459
|
+
var P = Symbol.for("better-auth:focus-manager"), ge = class {
|
|
460
|
+
listeners = /* @__PURE__ */ new Set();
|
|
461
|
+
subscribe(e) {
|
|
462
|
+
return this.listeners.add(e), () => {
|
|
463
|
+
this.listeners.delete(e);
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
setFocused(e) {
|
|
467
|
+
this.listeners.forEach((t) => t(e));
|
|
468
|
+
}
|
|
469
|
+
setup() {
|
|
470
|
+
if (typeof window > "u" || typeof document > "u" || window.addEventListener === void 0) return () => {};
|
|
471
|
+
let e = () => {
|
|
472
|
+
document.visibilityState === "visible" && this.setFocused(!0);
|
|
473
|
+
};
|
|
474
|
+
return document.addEventListener("visibilitychange", e, !1), () => {
|
|
475
|
+
document.removeEventListener("visibilitychange", e, !1);
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
function F() {
|
|
480
|
+
return globalThis[P] || (globalThis[P] = new ge()), globalThis[P];
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/online-manager.mjs
|
|
484
|
+
var I = Symbol.for("better-auth:online-manager"), _e = class {
|
|
485
|
+
listeners = /* @__PURE__ */ new Set();
|
|
486
|
+
isOnline = typeof navigator < "u" ? navigator.onLine : !0;
|
|
487
|
+
subscribe(e) {
|
|
488
|
+
return this.listeners.add(e), () => {
|
|
489
|
+
this.listeners.delete(e);
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
setOnline(e) {
|
|
493
|
+
this.isOnline = e, this.listeners.forEach((t) => t(e));
|
|
494
|
+
}
|
|
495
|
+
setup() {
|
|
496
|
+
if (typeof window > "u" || window.addEventListener === void 0) return () => {};
|
|
497
|
+
let e = () => this.setOnline(!0), t = () => this.setOnline(!1);
|
|
498
|
+
return window.addEventListener("online", e, !1), window.addEventListener("offline", t, !1), () => {
|
|
499
|
+
window.removeEventListener("online", e, !1), window.removeEventListener("offline", t, !1);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
function L() {
|
|
504
|
+
return globalThis[I] || (globalThis[I] = new _e()), globalThis[I];
|
|
505
|
+
}
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
508
|
+
var R = () => Math.floor(Date.now() / 1e3), ve = 5;
|
|
509
|
+
function ye(e) {
|
|
510
|
+
let { fetchSession: t, shouldPollSession: n = () => !0, sessionSignal: r, options: i = {} } = e, a = i.sessionOptions?.refetchInterval ?? 0, o = i.sessionOptions?.refetchOnWindowFocus ?? !0, s = i.sessionOptions?.refetchWhenOffline ?? !1, c = {
|
|
511
|
+
isInitialized: !1,
|
|
512
|
+
lastSessionRequest: 0
|
|
513
|
+
}, l = () => s || L().isOnline, u = (e) => {
|
|
514
|
+
if (l()) {
|
|
515
|
+
if (e?.event === "storage") {
|
|
516
|
+
t();
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (e?.event === "poll") {
|
|
520
|
+
c.lastSessionRequest = R(), t();
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (e?.event === "visibilitychange") {
|
|
524
|
+
if (R() - c.lastSessionRequest < ve) return;
|
|
525
|
+
c.lastSessionRequest = R(), t();
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
t();
|
|
529
|
+
}
|
|
530
|
+
}, d = (e) => {
|
|
531
|
+
N().post({
|
|
532
|
+
event: "session",
|
|
533
|
+
data: { trigger: e },
|
|
534
|
+
clientId: Math.random().toString(36).substring(7)
|
|
535
|
+
});
|
|
536
|
+
}, f = () => {
|
|
537
|
+
a && a > 0 && (c.pollInterval = setInterval(() => {
|
|
538
|
+
n() && u({ event: "poll" });
|
|
539
|
+
}, a * 1e3));
|
|
540
|
+
}, p = () => {
|
|
541
|
+
c.unsubscribeBroadcast = N().subscribe(() => {
|
|
542
|
+
u({ event: "storage" });
|
|
543
|
+
});
|
|
544
|
+
}, m = () => {
|
|
545
|
+
o && (c.unsubscribeFocus = F().subscribe(() => {
|
|
546
|
+
u({ event: "visibilitychange" });
|
|
547
|
+
}));
|
|
548
|
+
}, h = () => {
|
|
549
|
+
c.unsubscribeOnline = L().subscribe((e) => {
|
|
550
|
+
e && u({ event: "visibilitychange" });
|
|
551
|
+
});
|
|
552
|
+
}, g = () => {
|
|
553
|
+
c.unsubscribeSignal = r.listen(() => {
|
|
554
|
+
t();
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
return {
|
|
558
|
+
init: () => {
|
|
559
|
+
c.isInitialized || (c.isInitialized = !0, f(), p(), m(), h(), g(), c.cleanupBroadcastSetup = N().setup(), c.cleanupFocusSetup = F().setup(), c.cleanupOnlineSetup = L().setup());
|
|
560
|
+
},
|
|
561
|
+
cleanup: () => {
|
|
562
|
+
c.isInitialized && (c.pollInterval &&= (clearInterval(c.pollInterval), void 0), c.unsubscribeBroadcast &&= (c.unsubscribeBroadcast(), void 0), c.unsubscribeFocus &&= (c.unsubscribeFocus(), void 0), c.unsubscribeOnline &&= (c.unsubscribeOnline(), void 0), c.unsubscribeSignal &&= (c.unsubscribeSignal(), void 0), c.cleanupBroadcastSetup &&= (c.cleanupBroadcastSetup(), void 0), c.cleanupFocusSetup &&= (c.cleanupFocusSetup(), void 0), c.cleanupOnlineSetup &&= (c.cleanupOnlineSetup(), void 0), c.isInitialized = !1, c.lastSessionRequest = 0);
|
|
563
|
+
},
|
|
564
|
+
triggerRefetch: u,
|
|
565
|
+
broadcastSessionUpdate: d
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/session-atom.mjs
|
|
570
|
+
var be = () => typeof window > "u";
|
|
571
|
+
function z(e) {
|
|
572
|
+
return typeof e == "object" && e && "data" in e && "error" in e ? e : {
|
|
573
|
+
data: e,
|
|
574
|
+
error: null
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function xe(e) {
|
|
578
|
+
return !e || e.session === null && e.user === null ? null : e;
|
|
579
|
+
}
|
|
580
|
+
function Se(e, t) {
|
|
581
|
+
return j(e.data, t.data) && e.error === t.error && e.isPending === t.isPending && e.isRefetching === t.isRefetching && e.refetch === t.refetch;
|
|
582
|
+
}
|
|
583
|
+
function Ce(e, t) {
|
|
584
|
+
let n = /* @__PURE__ */ E(!1), r, i = (e) => s(e), a = /* @__PURE__ */ E({
|
|
585
|
+
data: null,
|
|
586
|
+
error: null,
|
|
587
|
+
isPending: !0,
|
|
588
|
+
isRefetching: !1,
|
|
589
|
+
refetch: i
|
|
590
|
+
});
|
|
591
|
+
pe(a, Se);
|
|
592
|
+
let o = (e) => {
|
|
593
|
+
if (r !== e) return;
|
|
594
|
+
let t = a.get();
|
|
595
|
+
r = void 0, !(!t.isPending && !t.isRefetching) && a.set({
|
|
596
|
+
...t,
|
|
597
|
+
isPending: !1,
|
|
598
|
+
isRefetching: !1,
|
|
599
|
+
refetch: i
|
|
600
|
+
});
|
|
601
|
+
}, s = async (t) => {
|
|
602
|
+
r?.abort();
|
|
603
|
+
let n = new AbortController();
|
|
604
|
+
r = n;
|
|
605
|
+
let s = a.get();
|
|
606
|
+
a.set({
|
|
607
|
+
...s,
|
|
608
|
+
isPending: s.data === null,
|
|
609
|
+
isRefetching: !0,
|
|
610
|
+
error: null,
|
|
611
|
+
refetch: i
|
|
612
|
+
});
|
|
613
|
+
try {
|
|
614
|
+
let r = await e("/get-session", {
|
|
615
|
+
method: "GET",
|
|
616
|
+
query: t?.query,
|
|
617
|
+
signal: n.signal
|
|
618
|
+
});
|
|
619
|
+
if (n.signal.aborted) {
|
|
620
|
+
o(n);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
let { data: s, error: c } = z(r);
|
|
624
|
+
if (s?.needsRefresh) try {
|
|
625
|
+
let t = await e("/get-session", {
|
|
626
|
+
method: "POST",
|
|
627
|
+
signal: n.signal
|
|
628
|
+
});
|
|
629
|
+
if (n.signal.aborted) {
|
|
630
|
+
o(n);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
({data: s, error: c} = z(t));
|
|
634
|
+
} catch {
|
|
635
|
+
if (n.signal.aborted) {
|
|
636
|
+
o(n);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (c) {
|
|
641
|
+
let e = a.get(), t = c?.status === 401;
|
|
642
|
+
a.set({
|
|
643
|
+
data: t ? null : e.data,
|
|
644
|
+
error: c,
|
|
645
|
+
isPending: !1,
|
|
646
|
+
isRefetching: !1,
|
|
647
|
+
refetch: i
|
|
648
|
+
});
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
let l = xe(s), u = a.get(), d = u.data != null && l != null && j(u.data, l) ? u.data : l;
|
|
652
|
+
a.set({
|
|
653
|
+
data: d,
|
|
654
|
+
error: null,
|
|
655
|
+
isPending: !1,
|
|
656
|
+
isRefetching: !1,
|
|
657
|
+
refetch: i
|
|
658
|
+
});
|
|
659
|
+
} catch (e) {
|
|
660
|
+
if (n.signal.aborted) {
|
|
661
|
+
o(n);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
let t = a.get();
|
|
665
|
+
a.set({
|
|
666
|
+
data: t.data,
|
|
667
|
+
error: e,
|
|
668
|
+
isPending: !1,
|
|
669
|
+
isRefetching: !1,
|
|
670
|
+
refetch: i
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}, c = () => {};
|
|
674
|
+
return fe(a, () => {
|
|
675
|
+
let e;
|
|
676
|
+
be() || (e = setTimeout(() => {
|
|
677
|
+
s();
|
|
678
|
+
}, 0));
|
|
679
|
+
let i = ye({
|
|
680
|
+
fetchSession: s,
|
|
681
|
+
shouldPollSession: () => a.get().data != null,
|
|
682
|
+
sessionSignal: n,
|
|
683
|
+
options: t
|
|
684
|
+
});
|
|
685
|
+
return i.init(), c = i.broadcastSessionUpdate, () => {
|
|
686
|
+
e && clearTimeout(e);
|
|
687
|
+
let t = r;
|
|
688
|
+
t?.abort(), t && o(t), i.cleanup();
|
|
689
|
+
};
|
|
690
|
+
}), {
|
|
691
|
+
session: a,
|
|
692
|
+
$sessionSignal: n,
|
|
693
|
+
broadcastSessionUpdate: (e) => c(e)
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region ../node_modules/.bun/defu@6.1.7/node_modules/defu/dist/defu.mjs
|
|
698
|
+
function B(e) {
|
|
699
|
+
if (typeof e != "object" || !e) return !1;
|
|
700
|
+
let t = Object.getPrototypeOf(e);
|
|
701
|
+
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;
|
|
702
|
+
}
|
|
703
|
+
function V(e, t, n = ".", r) {
|
|
704
|
+
if (!B(t)) return V(e, {}, n, r);
|
|
705
|
+
let i = { ...t };
|
|
706
|
+
for (let t of Object.keys(e)) {
|
|
707
|
+
if (t === "__proto__" || t === "constructor") continue;
|
|
708
|
+
let a = e[t];
|
|
709
|
+
a != null && (r && r(i, t, a, n) || (Array.isArray(a) && Array.isArray(i[t]) ? i[t] = [...a, ...i[t]] : B(a) && B(i[t]) ? i[t] = V(a, i[t], (n ? `${n}.` : "") + t.toString(), r) : i[t] = a));
|
|
710
|
+
}
|
|
711
|
+
return i;
|
|
712
|
+
}
|
|
713
|
+
function we(e) {
|
|
714
|
+
return (...t) => t.reduce((t, n) => V(t, n, "", e), {});
|
|
715
|
+
}
|
|
716
|
+
var Te = we(), Ee = Object.defineProperty, De = Object.defineProperties, Oe = Object.getOwnPropertyDescriptors, H = Object.getOwnPropertySymbols, ke = Object.prototype.hasOwnProperty, Ae = Object.prototype.propertyIsEnumerable, je = (e, t, n) => t in e ? Ee(e, t, {
|
|
717
|
+
enumerable: !0,
|
|
718
|
+
configurable: !0,
|
|
719
|
+
writable: !0,
|
|
720
|
+
value: n
|
|
721
|
+
}) : e[t] = n, U = (e, t) => {
|
|
722
|
+
for (var n in t ||= {}) ke.call(t, n) && je(e, n, t[n]);
|
|
723
|
+
if (H) for (var n of H(t)) Ae.call(t, n) && je(e, n, t[n]);
|
|
724
|
+
return e;
|
|
725
|
+
}, W = (e, t) => De(e, Oe(t)), Me = class extends Error {
|
|
726
|
+
constructor(e, t, n) {
|
|
727
|
+
super(t || e.toString(), { cause: n }), this.status = e, this.statusText = t, this.error = n, Error.captureStackTrace(this, this.constructor);
|
|
728
|
+
}
|
|
729
|
+
}, Ne = async (e, t) => {
|
|
730
|
+
let n = t || {}, r = {
|
|
731
|
+
onRequest: [t?.onRequest],
|
|
732
|
+
onResponse: [t?.onResponse],
|
|
733
|
+
onSuccess: [t?.onSuccess],
|
|
734
|
+
onError: [t?.onError],
|
|
735
|
+
onRetry: [t?.onRetry]
|
|
736
|
+
};
|
|
737
|
+
if (!t || !t?.plugins) return {
|
|
738
|
+
url: e,
|
|
739
|
+
options: n,
|
|
740
|
+
hooks: r
|
|
741
|
+
};
|
|
742
|
+
for (let i of t?.plugins || []) {
|
|
743
|
+
if (i.init) {
|
|
744
|
+
let r = await i.init?.call(i, e.toString(), t);
|
|
745
|
+
n = r.options || n, e = r.url;
|
|
746
|
+
}
|
|
747
|
+
r.onRequest.push(i.hooks?.onRequest), r.onResponse.push(i.hooks?.onResponse), r.onSuccess.push(i.hooks?.onSuccess), r.onError.push(i.hooks?.onError), r.onRetry.push(i.hooks?.onRetry);
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
url: e,
|
|
751
|
+
options: n,
|
|
752
|
+
hooks: r
|
|
753
|
+
};
|
|
754
|
+
}, G = class {
|
|
755
|
+
constructor(e) {
|
|
756
|
+
this.options = e;
|
|
757
|
+
}
|
|
758
|
+
shouldAttemptRetry(e, t) {
|
|
759
|
+
return this.options.shouldRetry ? Promise.resolve(e < this.options.attempts && this.options.shouldRetry(t)) : Promise.resolve(e < this.options.attempts);
|
|
760
|
+
}
|
|
761
|
+
getDelay() {
|
|
762
|
+
return this.options.delay;
|
|
763
|
+
}
|
|
764
|
+
}, Pe = class {
|
|
765
|
+
constructor(e) {
|
|
766
|
+
this.options = e;
|
|
767
|
+
}
|
|
768
|
+
shouldAttemptRetry(e, t) {
|
|
769
|
+
return this.options.shouldRetry ? Promise.resolve(e < this.options.attempts && this.options.shouldRetry(t)) : Promise.resolve(e < this.options.attempts);
|
|
770
|
+
}
|
|
771
|
+
getDelay(e) {
|
|
772
|
+
return Math.min(this.options.maxDelay, this.options.baseDelay * 2 ** e);
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
function Fe(e) {
|
|
776
|
+
if (typeof e == "number") return new G({
|
|
777
|
+
type: "linear",
|
|
778
|
+
attempts: e,
|
|
779
|
+
delay: 1e3
|
|
780
|
+
});
|
|
781
|
+
switch (e.type) {
|
|
782
|
+
case "linear": return new G(e);
|
|
783
|
+
case "exponential": return new Pe(e);
|
|
784
|
+
default: throw Error("Invalid retry strategy");
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
var Ie = async (e) => {
|
|
788
|
+
let t = {}, n = async (e) => typeof e == "function" ? await e() : e;
|
|
789
|
+
if (e?.auth) {
|
|
790
|
+
if (e.auth.type === "Bearer") {
|
|
791
|
+
let r = await n(e.auth.token);
|
|
792
|
+
if (!r) return t;
|
|
793
|
+
t.authorization = `Bearer ${r}`;
|
|
794
|
+
} else if (e.auth.type === "Basic") {
|
|
795
|
+
let [r, i] = await Promise.all([n(e.auth.username), n(e.auth.password)]);
|
|
796
|
+
if (!r || !i) return t;
|
|
797
|
+
t.authorization = `Basic ${btoa(`${r}:${i}`)}`;
|
|
798
|
+
} else if (e.auth.type === "Custom") {
|
|
799
|
+
let [r, i] = await Promise.all([n(e.auth.prefix), n(e.auth.value)]);
|
|
800
|
+
if (!i) return t;
|
|
801
|
+
t.authorization = `${r ?? ""} ${i}`;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return t;
|
|
805
|
+
}, Le = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
806
|
+
function Re(e) {
|
|
807
|
+
let t = e.headers.get("content-type"), n = /* @__PURE__ */ new Set([
|
|
808
|
+
"image/svg",
|
|
809
|
+
"application/xml",
|
|
810
|
+
"application/xhtml",
|
|
811
|
+
"application/html"
|
|
812
|
+
]);
|
|
813
|
+
if (!t) return "json";
|
|
814
|
+
let r = t.split(";").shift() || "";
|
|
815
|
+
return Le.test(r) ? "json" : n.has(r) || r.startsWith("text/") ? "text" : "blob";
|
|
816
|
+
}
|
|
817
|
+
function ze(e) {
|
|
818
|
+
try {
|
|
819
|
+
return JSON.parse(e), !0;
|
|
820
|
+
} catch {
|
|
821
|
+
return !1;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function K(e) {
|
|
825
|
+
if (e === void 0) return !1;
|
|
826
|
+
let t = typeof e;
|
|
827
|
+
return t === "string" || t === "number" || t === "boolean" || t === null ? !0 : t === "object" ? Array.isArray(e) ? !0 : e.buffer ? !1 : e.constructor && e.constructor.name === "Object" || typeof e.toJSON == "function" : !1;
|
|
828
|
+
}
|
|
829
|
+
function q(e) {
|
|
830
|
+
try {
|
|
831
|
+
return JSON.parse(e);
|
|
832
|
+
} catch {
|
|
833
|
+
return e;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
function J(e) {
|
|
837
|
+
return typeof e == "function";
|
|
838
|
+
}
|
|
839
|
+
function Be(e) {
|
|
840
|
+
if (e?.customFetchImpl) return e.customFetchImpl;
|
|
841
|
+
if (typeof globalThis < "u" && J(globalThis.fetch)) return globalThis.fetch;
|
|
842
|
+
if (typeof window < "u" && J(window.fetch)) return window.fetch;
|
|
843
|
+
throw Error("No fetch implementation found");
|
|
844
|
+
}
|
|
845
|
+
function Y(...e) {
|
|
846
|
+
let t = {};
|
|
847
|
+
for (let n of e) if (n) if (n instanceof Headers) n.forEach((e, n) => {
|
|
848
|
+
t[n] = e;
|
|
849
|
+
});
|
|
850
|
+
else {
|
|
851
|
+
let e = Array.isArray(n) ? n : Object.entries(n);
|
|
852
|
+
for (let [n, r] of e) r != null && (t[n] = r);
|
|
853
|
+
}
|
|
854
|
+
return t;
|
|
855
|
+
}
|
|
856
|
+
async function Ve(e) {
|
|
857
|
+
let t = new Headers(Y(e?.headers, await Ie(e)));
|
|
858
|
+
if (!t.has("content-type")) {
|
|
859
|
+
let n = He(e?.body);
|
|
860
|
+
n && t.set("content-type", n);
|
|
861
|
+
}
|
|
862
|
+
return t;
|
|
863
|
+
}
|
|
864
|
+
function He(e) {
|
|
865
|
+
return K(e) ? "application/json" : null;
|
|
866
|
+
}
|
|
867
|
+
function Ue(e) {
|
|
868
|
+
let t = e.get("content-type");
|
|
869
|
+
return t ? t.split(";")[0].trim().toLowerCase() : null;
|
|
870
|
+
}
|
|
871
|
+
function We(e, t) {
|
|
872
|
+
let { body: n } = e;
|
|
873
|
+
return n ? !K(n) || typeof n == "string" ? n : Ue(t) === "application/x-www-form-urlencoded" ? new URLSearchParams(n).toString() : JSON.stringify(n) : null;
|
|
874
|
+
}
|
|
875
|
+
function Ge(e, t) {
|
|
876
|
+
if (t?.method) return t.method.toUpperCase();
|
|
877
|
+
if (e.startsWith("@")) {
|
|
878
|
+
let n = e.split("@")[1]?.split("/")[0];
|
|
879
|
+
return Z.includes(n) ? n.toUpperCase() : t?.body ? "POST" : "GET";
|
|
880
|
+
}
|
|
881
|
+
return t?.body ? "POST" : "GET";
|
|
882
|
+
}
|
|
883
|
+
function Ke(e, t) {
|
|
884
|
+
let n;
|
|
885
|
+
return !e?.signal && e?.timeout && (n = setTimeout(() => t?.abort(), e?.timeout)), {
|
|
886
|
+
abortTimeout: n,
|
|
887
|
+
clearTimeout: () => {
|
|
888
|
+
n && clearTimeout(n);
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
var qe = class e extends Error {
|
|
893
|
+
constructor(t, n) {
|
|
894
|
+
super(n || JSON.stringify(t, null, 2)), this.issues = t, Object.setPrototypeOf(this, e.prototype);
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
async function X(e, t) {
|
|
898
|
+
let n = await e["~standard"].validate(t);
|
|
899
|
+
if (n.issues) throw new qe(n.issues);
|
|
900
|
+
return n.value;
|
|
901
|
+
}
|
|
902
|
+
var Z = [
|
|
903
|
+
"get",
|
|
904
|
+
"post",
|
|
905
|
+
"put",
|
|
906
|
+
"patch",
|
|
907
|
+
"delete"
|
|
908
|
+
], Je = (e) => ({
|
|
909
|
+
id: "apply-schema",
|
|
910
|
+
name: "Apply Schema",
|
|
911
|
+
version: "1.0.0",
|
|
912
|
+
async init(t, n) {
|
|
913
|
+
let r = e.plugins?.find((e) => e.schema?.config ? t.startsWith(e.schema.config.baseURL || "") || t.startsWith(e.schema.config.prefix || "") : !1)?.schema || e.schema;
|
|
914
|
+
if (r) {
|
|
915
|
+
let e = t;
|
|
916
|
+
r.config?.prefix && e.startsWith(r.config.prefix) && (e = e.replace(r.config.prefix, ""), r.config.baseURL && (t = t.replace(r.config.prefix, r.config.baseURL))), r.config?.baseURL && e.startsWith(r.config.baseURL) && (e = e.replace(r.config.baseURL, "")), e.startsWith("/") && e.charAt(1) === "@" && (e = e.substring(1));
|
|
917
|
+
let i = r.schema[e];
|
|
918
|
+
if (i) {
|
|
919
|
+
let e = n?.headers;
|
|
920
|
+
if (i.headers && !n?.disableValidation) {
|
|
921
|
+
let t = {};
|
|
922
|
+
if (n?.headers) {
|
|
923
|
+
if (n.headers instanceof Headers) n.headers.forEach((e, n) => {
|
|
924
|
+
t[n.toLowerCase()] = e;
|
|
925
|
+
});
|
|
926
|
+
else if (typeof n.headers == "object") for (let [e, r] of Object.entries(n.headers)) r != null && (t[e.toLowerCase()] = r);
|
|
927
|
+
}
|
|
928
|
+
let r = await X(i.headers, t), a = {};
|
|
929
|
+
for (let [e, t] of Object.entries(r)) a[e.toLowerCase()] = t;
|
|
930
|
+
e = a;
|
|
931
|
+
}
|
|
932
|
+
let r = W(U({}, n), {
|
|
933
|
+
method: i.method,
|
|
934
|
+
output: i.output,
|
|
935
|
+
headers: e
|
|
936
|
+
});
|
|
937
|
+
return n?.disableValidation || (r = W(U({}, r), {
|
|
938
|
+
body: i.input ? await X(i.input, n?.body) : n?.body,
|
|
939
|
+
params: i.params ? await X(i.params, n?.params) : n?.params,
|
|
940
|
+
query: i.query ? await X(i.query, n?.query) : n?.query
|
|
941
|
+
})), {
|
|
942
|
+
url: t,
|
|
943
|
+
options: r
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
url: t,
|
|
949
|
+
options: n
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
}), Ye = (e) => {
|
|
953
|
+
async function t(t, n) {
|
|
954
|
+
let r = W(U(U({}, e), n), {
|
|
955
|
+
headers: Y(e?.headers, n?.headers),
|
|
956
|
+
plugins: [
|
|
957
|
+
...e?.plugins || [],
|
|
958
|
+
Je(e || {}),
|
|
959
|
+
...n?.plugins || []
|
|
960
|
+
]
|
|
961
|
+
});
|
|
962
|
+
if (e?.catchAllError) try {
|
|
963
|
+
return await Q(t, r);
|
|
964
|
+
} catch (e) {
|
|
965
|
+
return {
|
|
966
|
+
data: null,
|
|
967
|
+
error: {
|
|
968
|
+
status: 500,
|
|
969
|
+
statusText: "Fetch Error",
|
|
970
|
+
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
971
|
+
error: e
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
return await Q(t, r);
|
|
976
|
+
}
|
|
977
|
+
return t;
|
|
978
|
+
}, Xe = (e) => e === "." || e === "..";
|
|
979
|
+
function Ze(e, t) {
|
|
980
|
+
let n = e;
|
|
981
|
+
for (let [e, r] of t) n = n.replace(e, r);
|
|
982
|
+
if (Xe(n)) throw TypeError("Path parameters cannot be reserved path segments");
|
|
983
|
+
return encodeURIComponent(n);
|
|
984
|
+
}
|
|
985
|
+
function Qe(e, t) {
|
|
986
|
+
let { baseURL: n, params: r, query: i } = t || {
|
|
987
|
+
query: {},
|
|
988
|
+
params: {},
|
|
989
|
+
baseURL: ""
|
|
990
|
+
}, a = e.startsWith("http") ? e.split("/").slice(0, 3).join("/") : n || "";
|
|
991
|
+
if (e.startsWith("@")) {
|
|
992
|
+
let t = e.toString().split("@")[1].split("/")[0];
|
|
993
|
+
Z.includes(t) && (e = e.replace(`@${t}/`, "/"));
|
|
994
|
+
}
|
|
995
|
+
a.endsWith("/") || (a += "/");
|
|
996
|
+
let [o, s] = e.replace(a, "").split("?"), c = new URLSearchParams(s);
|
|
997
|
+
for (let [e, t] of Object.entries(i || {})) {
|
|
998
|
+
if (t == null) continue;
|
|
999
|
+
let n;
|
|
1000
|
+
if (typeof t == "string") n = t;
|
|
1001
|
+
else if (Array.isArray(t)) {
|
|
1002
|
+
for (let n of t) c.append(e, n);
|
|
1003
|
+
continue;
|
|
1004
|
+
} else n = JSON.stringify(t);
|
|
1005
|
+
c.set(e, n);
|
|
1006
|
+
}
|
|
1007
|
+
let l = /* @__PURE__ */ new Map();
|
|
1008
|
+
if (r) if (Array.isArray(r)) {
|
|
1009
|
+
let e = o.split("/").filter((e) => e.startsWith(":"));
|
|
1010
|
+
for (let [t, n] of e.entries()) {
|
|
1011
|
+
let e = r[t];
|
|
1012
|
+
l.set(n, String(e));
|
|
1013
|
+
}
|
|
1014
|
+
} else for (let [e, t] of Object.entries(r)) l.set(`:${e}`, String(t));
|
|
1015
|
+
o = o.split("/").map((e) => Ze(e, l)).join("/"), o = o.replace(/^\/+/, "");
|
|
1016
|
+
let u = c.toString();
|
|
1017
|
+
return u = u.length > 0 ? `?${u}`.replace(/\+/g, "%20") : "", a.startsWith("http") ? new URL(`${o}${u}`, a) : `${a}${o}${u}`;
|
|
1018
|
+
}
|
|
1019
|
+
var Q = async (e, t) => {
|
|
1020
|
+
let { hooks: n, url: r, options: i } = await Ne(e, t), a = Be(i), o = new AbortController(), s = i.signal ?? o.signal, c = Qe(r, i), l = await Ve(i), u = We(i, l), d = Ge(r, i), f = W(U({}, i), {
|
|
1021
|
+
url: c,
|
|
1022
|
+
headers: l,
|
|
1023
|
+
body: u,
|
|
1024
|
+
method: d,
|
|
1025
|
+
signal: s
|
|
1026
|
+
});
|
|
1027
|
+
for (let e of n.onRequest) if (e) {
|
|
1028
|
+
let t = await e(f);
|
|
1029
|
+
typeof t == "object" && t && Object.assign(f, t);
|
|
1030
|
+
}
|
|
1031
|
+
("pipeTo" in f && typeof f.pipeTo == "function" || typeof t?.body?.pipe == "function") && ("duplex" in f || (f.duplex = "half"));
|
|
1032
|
+
let { clearTimeout: p } = Ke(i, o), m = await a(f.url, f);
|
|
1033
|
+
p();
|
|
1034
|
+
let h = {
|
|
1035
|
+
response: m,
|
|
1036
|
+
request: f
|
|
1037
|
+
};
|
|
1038
|
+
for (let e of n.onResponse) if (e) {
|
|
1039
|
+
let n = await e(W(U({}, h), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1040
|
+
n instanceof Response ? m = n : typeof n == "object" && n && (m = n.response);
|
|
1041
|
+
}
|
|
1042
|
+
if (m.ok) {
|
|
1043
|
+
if (f.method === "HEAD") return {
|
|
1044
|
+
data: "",
|
|
1045
|
+
error: null
|
|
1046
|
+
};
|
|
1047
|
+
let e = Re(m), r = {
|
|
1048
|
+
data: null,
|
|
1049
|
+
response: m,
|
|
1050
|
+
request: f
|
|
1051
|
+
};
|
|
1052
|
+
if (e === "json" || e === "text") {
|
|
1053
|
+
let e = await m.text();
|
|
1054
|
+
r.data = await (f.jsonParser ?? q)(e);
|
|
1055
|
+
} else r.data = await m[e]();
|
|
1056
|
+
f?.output && f.output && !f.disableValidation && (r.data = await X(f.output, r.data));
|
|
1057
|
+
for (let e of n.onSuccess) e && await e(W(U({}, r), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1058
|
+
return t?.throw ? r.data : {
|
|
1059
|
+
data: r.data,
|
|
1060
|
+
error: null
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
let g = t?.jsonParser ?? q, _ = await m.text(), v = ze(_), y = v ? await g(_) : null, b = {
|
|
1064
|
+
response: m,
|
|
1065
|
+
responseText: _,
|
|
1066
|
+
request: f,
|
|
1067
|
+
error: W(U({}, y), {
|
|
1068
|
+
status: m.status,
|
|
1069
|
+
statusText: m.statusText
|
|
1070
|
+
})
|
|
1071
|
+
};
|
|
1072
|
+
for (let e of n.onError) e && await e(W(U({}, b), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1073
|
+
if (t?.retry) {
|
|
1074
|
+
let r = Fe(t.retry), i = t.retryAttempt ?? 0;
|
|
1075
|
+
if (await r.shouldAttemptRetry(i, m)) {
|
|
1076
|
+
for (let e of n.onRetry) e && await e(h);
|
|
1077
|
+
let a = r.getDelay(i);
|
|
1078
|
+
return await new Promise((e) => setTimeout(e, a)), await Q(e, W(U({}, t), { retryAttempt: i + 1 }));
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
if (t?.throw) throw new Me(m.status, m.statusText, v ? y : _);
|
|
1082
|
+
return {
|
|
1083
|
+
data: null,
|
|
1084
|
+
error: W(U({}, y), {
|
|
1085
|
+
status: m.status,
|
|
1086
|
+
statusText: m.statusText
|
|
1087
|
+
})
|
|
1088
|
+
};
|
|
1089
|
+
}, $e = (e) => {
|
|
1090
|
+
if (typeof process > "u") return;
|
|
1091
|
+
let t = e ?? "/api/auth";
|
|
1092
|
+
if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
|
|
1093
|
+
if (typeof window > "u") {
|
|
1094
|
+
if (process.env.NEXTAUTH_URL) try {
|
|
1095
|
+
return process.env.NEXTAUTH_URL;
|
|
1096
|
+
} catch {}
|
|
1097
|
+
if (process.env.VERCEL_URL) try {
|
|
1098
|
+
let e = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
|
|
1099
|
+
return `${new URL(`${e}${process.env.VERCEL_URL}`).origin}${t}`;
|
|
1100
|
+
} catch {}
|
|
1101
|
+
}
|
|
1102
|
+
}, et = (e, t) => {
|
|
1103
|
+
let n = "credentials" in Request.prototype, r = g(e?.baseURL, e?.basePath, void 0, t) ?? $e(e?.basePath) ?? "/api/auth", i = e?.plugins?.flatMap((e) => e.fetchPlugins).filter((e) => e !== void 0) || [], a = {
|
|
1104
|
+
id: "lifecycle-hooks",
|
|
1105
|
+
name: "lifecycle-hooks",
|
|
1106
|
+
hooks: {
|
|
1107
|
+
onSuccess: e?.fetchOptions?.onSuccess,
|
|
1108
|
+
onError: e?.fetchOptions?.onError,
|
|
1109
|
+
onRequest: e?.fetchOptions?.onRequest,
|
|
1110
|
+
onResponse: e?.fetchOptions?.onResponse
|
|
1111
|
+
}
|
|
1112
|
+
}, { onSuccess: o, onError: s, onRequest: c, onResponse: l, ...u } = e?.fetchOptions || {}, d = Ye({
|
|
1113
|
+
baseURL: r,
|
|
1114
|
+
...n ? { credentials: "include" } : {},
|
|
1115
|
+
method: "GET",
|
|
1116
|
+
jsonParser(e) {
|
|
1117
|
+
return e ? re(e, { strict: !1 }) : null;
|
|
1118
|
+
},
|
|
1119
|
+
customFetchImpl: fetch,
|
|
1120
|
+
...u,
|
|
1121
|
+
plugins: [
|
|
1122
|
+
a,
|
|
1123
|
+
...u.plugins || [],
|
|
1124
|
+
...e?.disableDefaultFetchPlugins ? [] : [oe],
|
|
1125
|
+
...i
|
|
1126
|
+
]
|
|
1127
|
+
}), { $sessionSignal: f, session: p, broadcastSessionUpdate: m } = Ce(d, e), h = e?.plugins || [], _ = {}, v = {
|
|
1128
|
+
$sessionSignal: f,
|
|
1129
|
+
session: p
|
|
1130
|
+
}, y = {
|
|
1131
|
+
"/sign-out": "POST",
|
|
1132
|
+
"/revoke-sessions": "POST",
|
|
1133
|
+
"/revoke-other-sessions": "POST",
|
|
1134
|
+
"/delete-user": "POST"
|
|
1135
|
+
}, b = [{
|
|
1136
|
+
signal: "$sessionSignal",
|
|
1137
|
+
matcher(e) {
|
|
1138
|
+
return e === "/sign-out" || e === "/update-user" || e === "/update-session" || e === "/sign-up/email" || e === "/sign-in/email" || e === "/delete-user" || e === "/verify-email" || e === "/revoke-sessions" || e === "/revoke-session" || e === "/revoke-other-sessions" || e === "/change-email" || e === "/change-password";
|
|
1139
|
+
},
|
|
1140
|
+
callback(e) {
|
|
1141
|
+
e === "/sign-out" ? m("signout") : (e === "/update-user" || e === "/update-session") && m("updateUser");
|
|
1142
|
+
}
|
|
1143
|
+
}];
|
|
1144
|
+
for (let e of h) e.getAtoms && Object.assign(v, e.getAtoms?.(d)), e.pathMethods && Object.assign(y, e.pathMethods), e.atomListeners && b.push(...e.atomListeners);
|
|
1145
|
+
let x = {
|
|
1146
|
+
notify: (e) => {
|
|
1147
|
+
v[e].set(!v[e].get());
|
|
1148
|
+
},
|
|
1149
|
+
listen: (e, t) => {
|
|
1150
|
+
v[e].subscribe(t);
|
|
1151
|
+
},
|
|
1152
|
+
atoms: v
|
|
1153
|
+
};
|
|
1154
|
+
for (let t of h) t.getActions && (_ = Te(t.getActions?.(d, x, e) ?? {}, _));
|
|
1155
|
+
return {
|
|
1156
|
+
get baseURL() {
|
|
1157
|
+
return r;
|
|
1158
|
+
},
|
|
1159
|
+
pluginsActions: _,
|
|
1160
|
+
pluginsAtoms: v,
|
|
1161
|
+
pluginPathMethods: y,
|
|
1162
|
+
atomListeners: b,
|
|
1163
|
+
$fetch: d,
|
|
1164
|
+
$store: x
|
|
1165
|
+
};
|
|
1166
|
+
};
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1169
|
+
function tt(e) {
|
|
1170
|
+
return typeof e == "object" && !!e && "get" in e && typeof e.get == "function" && "lc" in e && typeof e.lc == "number";
|
|
1171
|
+
}
|
|
1172
|
+
//#endregion
|
|
1173
|
+
//#region ../node_modules/.bun/@better-auth+core@1.6.22+97ef1a25343ecf7e/node_modules/@better-auth/core/dist/utils/string.mjs
|
|
1174
|
+
function nt(e) {
|
|
1175
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1176
|
+
}
|
|
1177
|
+
var rt = /[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu, it = /['\u2019]/g;
|
|
1178
|
+
function at(e) {
|
|
1179
|
+
return e.replace(it, "").match(rt) ?? [];
|
|
1180
|
+
}
|
|
1181
|
+
function ot(e) {
|
|
1182
|
+
return at(e).map((e) => e.toLowerCase()).join("-");
|
|
1183
|
+
}
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/proxy.mjs
|
|
1186
|
+
function st(e, t, n) {
|
|
1187
|
+
let r = t[e], { fetchOptions: i, query: a, ...o } = n || {};
|
|
1188
|
+
return r || (i?.method ? i.method : o && Object.keys(o).length > 0 ? "POST" : "GET");
|
|
1189
|
+
}
|
|
1190
|
+
function ct(e, t, n, r, i) {
|
|
1191
|
+
function a(o = []) {
|
|
1192
|
+
return new Proxy(function() {}, {
|
|
1193
|
+
get(t, n) {
|
|
1194
|
+
if (typeof n != "string" || n === "then" || n === "catch" || n === "finally") return;
|
|
1195
|
+
let r = [...o, n], i = e;
|
|
1196
|
+
for (let e of r) if (i && typeof i == "object" && e in i) i = i[e];
|
|
1197
|
+
else {
|
|
1198
|
+
i = void 0;
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
return typeof i == "function" || tt(i) ? i : a(r);
|
|
1202
|
+
},
|
|
1203
|
+
apply: async (e, a, s) => {
|
|
1204
|
+
let c = "/" + o.map(ot).join("/"), l = s[0] || {}, u = s[1] || {}, { query: d, fetchOptions: f, ...p } = l, m = {
|
|
1205
|
+
...u,
|
|
1206
|
+
...f
|
|
1207
|
+
}, h = st(c, n, l);
|
|
1208
|
+
return await t(c, {
|
|
1209
|
+
...m,
|
|
1210
|
+
body: h === "GET" ? void 0 : {
|
|
1211
|
+
...p,
|
|
1212
|
+
...m?.body || {}
|
|
1213
|
+
},
|
|
1214
|
+
query: d || m?.query,
|
|
1215
|
+
method: h,
|
|
1216
|
+
async onSuccess(e) {
|
|
1217
|
+
if (await m?.onSuccess?.(e), !i || m.disableSignal) return;
|
|
1218
|
+
let t = i.filter((e) => e.matcher(c));
|
|
1219
|
+
if (!t.length) return;
|
|
1220
|
+
let n = /* @__PURE__ */ new Set();
|
|
1221
|
+
for (let e of t) {
|
|
1222
|
+
let t = r[e.signal];
|
|
1223
|
+
if (!t) return;
|
|
1224
|
+
if (n.has(e.signal)) continue;
|
|
1225
|
+
n.add(e.signal);
|
|
1226
|
+
let i = t.get();
|
|
1227
|
+
setTimeout(() => {
|
|
1228
|
+
t.set(!i);
|
|
1229
|
+
}, 10), e.callback?.(c);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
return a();
|
|
1237
|
+
}
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region ../node_modules/.bun/better-auth@1.6.22+bb1208860964dff1/node_modules/better-auth/dist/client/vanilla.mjs
|
|
1240
|
+
function lt(e) {
|
|
1241
|
+
let { pluginPathMethods: t, pluginsActions: n, pluginsAtoms: r, $fetch: i, atomListeners: a, $store: o } = et(e), s = {};
|
|
1242
|
+
for (let [e, t] of Object.entries(r)) s[`use${nt(e)}`] = t;
|
|
1243
|
+
return ct({
|
|
1244
|
+
...n,
|
|
1245
|
+
...s,
|
|
1246
|
+
$fetch: i,
|
|
1247
|
+
$store: o
|
|
1248
|
+
}, i, t, r, a);
|
|
1249
|
+
}
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region src/lib/auth-client.ts
|
|
1252
|
+
var $ = lt({ baseURL: typeof window < "u" ? window.location.origin : "" }), { signIn: ut, signUp: dt, signOut: ft, getSession: pt } = $;
|
|
1253
|
+
//#endregion
|
|
1254
|
+
//#region src/lib/api/settings.ts
|
|
1255
|
+
async function mt() {
|
|
1256
|
+
try {
|
|
1257
|
+
let t = await e("/api/auth/get-session");
|
|
1258
|
+
if (t.user?.name || t.user?.email) return t.user;
|
|
1259
|
+
} catch {}
|
|
1260
|
+
let { data: t } = await $.getSession();
|
|
1261
|
+
return t?.user ? {
|
|
1262
|
+
id: t.user.id ?? "",
|
|
1263
|
+
name: t.user.name ?? "User",
|
|
1264
|
+
email: t.user.email ?? "",
|
|
1265
|
+
avatar: null
|
|
1266
|
+
} : {
|
|
1267
|
+
id: "",
|
|
1268
|
+
name: "User",
|
|
1269
|
+
email: "",
|
|
1270
|
+
avatar: null
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
async function ht(t) {
|
|
1274
|
+
return e("/api/auth/update-user", {
|
|
1275
|
+
method: "POST",
|
|
1276
|
+
body: JSON.stringify({ name: t.name })
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
var gt = "hiai-docs:embedding-config";
|
|
1280
|
+
function _t() {
|
|
1281
|
+
if (typeof window > "u") return {
|
|
1282
|
+
baseUrl: "",
|
|
1283
|
+
apiKey: "",
|
|
1284
|
+
model: "",
|
|
1285
|
+
fallbackBaseUrl: null,
|
|
1286
|
+
fallbackApiKey: null,
|
|
1287
|
+
fallbackModel: null
|
|
1288
|
+
};
|
|
1289
|
+
try {
|
|
1290
|
+
let e = localStorage.getItem(gt);
|
|
1291
|
+
if (e) return JSON.parse(e);
|
|
1292
|
+
} catch {}
|
|
1293
|
+
return {
|
|
1294
|
+
baseUrl: "",
|
|
1295
|
+
apiKey: "",
|
|
1296
|
+
model: "",
|
|
1297
|
+
fallbackBaseUrl: null,
|
|
1298
|
+
fallbackApiKey: null,
|
|
1299
|
+
fallbackModel: null
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
function vt(e) {
|
|
1303
|
+
let t = {
|
|
1304
|
+
..._t(),
|
|
1305
|
+
...e
|
|
1306
|
+
};
|
|
1307
|
+
return localStorage.setItem(gt, JSON.stringify(t)), t;
|
|
1308
|
+
}
|
|
1309
|
+
async function yt() {
|
|
1310
|
+
await e("/api/auth/delete-user", { method: "POST" });
|
|
1311
|
+
}
|
|
1312
|
+
//#endregion
|
|
1313
|
+
export { ht as a, ft as c, vt as i, _t as n, $ as o, mt as r, pt as s, yt as t };
|