@vuetify/one 2.13.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,703 @@
1
+ import { ref as S, shallowRef as L, computed as f, readonly as q, reactive as G, watch as j, toRefs as Z, toRef as P, nextTick as D } from "vue";
2
+ import { defineStore as $ } from "pinia";
3
+ import { merge as x, debounce as ee } from "lodash-es";
4
+ import { useRoute as te, useRouter as Q } from "vue-router";
5
+ const J = $("queue", () => {
6
+ const e = S([]);
7
+ function i(r) {
8
+ const n = typeof r == "string" ? { text: r } : r;
9
+ e.value.push(n);
10
+ }
11
+ function t(r) {
12
+ i({
13
+ color: "error",
14
+ text: r,
15
+ location: "top end",
16
+ timeout: -1
17
+ });
18
+ }
19
+ function s(r) {
20
+ i({
21
+ color: "success",
22
+ text: r,
23
+ location: "top end"
24
+ });
25
+ }
26
+ return {
27
+ queue: e,
28
+ show: i,
29
+ showError: t,
30
+ showSuccess: s
31
+ };
32
+ }), U = $("http", {
33
+ state: () => ({ url: "" }),
34
+ actions: {
35
+ async fetch(e, i = {}) {
36
+ const t = await fetch(`${this.url}${e}`, {
37
+ credentials: "include",
38
+ ...i
39
+ });
40
+ if (!t.ok) {
41
+ const s = await t.text();
42
+ let r = s || `HTTP ${t.status}`;
43
+ try {
44
+ const n = JSON.parse(s);
45
+ r = n.message || n.error || s;
46
+ } catch {
47
+ }
48
+ throw new Error(r);
49
+ }
50
+ return t.status === 204 ? {} : t.json();
51
+ },
52
+ async post(e, i, t = {}) {
53
+ return this.fetch(e, {
54
+ method: "POST",
55
+ headers: { "Content-Type": "application/json" },
56
+ body: JSON.stringify(i),
57
+ ...t
58
+ });
59
+ },
60
+ async get(e, i = {}) {
61
+ return this.fetch(e, i);
62
+ },
63
+ async delete(e, i = {}) {
64
+ return this.fetch(e, {
65
+ method: "DELETE",
66
+ ...i
67
+ });
68
+ }
69
+ }
70
+ }), he = $("auth-api-key", () => {
71
+ const e = U(), i = S(null), t = L(!1), s = f(() => i.value?.apiKey || ""), r = f(() => {
72
+ if (!s.value) return "";
73
+ const a = s.value;
74
+ return `${a.slice(0, 6)}...${a.slice(-6)}`;
75
+ });
76
+ async function n(a = !1) {
77
+ !t.value && a && (t.value = !0);
78
+ const d = a ? "regenerate" : "generate", g = a ? await e.post(`/one/mcp/${d}`) : await e.fetch(`/one/mcp/${d}`);
79
+ return i.value = g, g;
80
+ }
81
+ async function c() {
82
+ try {
83
+ const a = await e.fetch("/one/mcp/getToken");
84
+ return a?.apiKey ? (i.value = a, a) : null;
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
89
+ return {
90
+ accessToken: q(i),
91
+ key: q(s),
92
+ regenerated: q(t),
93
+ trim: q(r),
94
+ generate: n,
95
+ fetch: c
96
+ };
97
+ }), ne = typeof window < "u";
98
+ function se() {
99
+ return document.cookie.split(";").some((e) => e.trim().startsWith("sx="));
100
+ }
101
+ const V = $("auth-core", () => {
102
+ const e = U(), i = S(!1), t = S(null), s = L(!1), r = L({}), n = L(null), c = f(() => !!t.value), a = f(() => t.value?.role === "super"), d = f(() => ["super", "admin"].includes(t.value?.role ?? "")), g = f(() => [
103
+ "super",
104
+ "admin",
105
+ "editor"
106
+ ].includes(t.value?.role ?? ""));
107
+ function R(l) {
108
+ r.value = l;
109
+ }
110
+ async function O(l = !1) {
111
+ if (n.value) return n.value;
112
+ if (!e.url || !l && !se() && location.hostname?.match(/([^.]+\.[^.]+)$/)?.[1] === new URL(e.url).hostname.match(/([^.]+\.[^.]+)$/)?.[1])
113
+ return t.value = null, null;
114
+ s.value = !0;
115
+ const p = fetch(`${e.url}/auth/verify`, {
116
+ credentials: "include",
117
+ cache: l ? "reload" : void 0
118
+ });
119
+ return !p || typeof p.then != "function" ? (s.value = !1, t.value = null, null) : (n.value = p.then(async (h) => {
120
+ if (h.ok || h.status === 401) {
121
+ const b = await h.json();
122
+ return t.value = b.user, r.value.onAuth?.(b), b;
123
+ } else {
124
+ const b = new Error(h.statusText || `HTTP ${h.status}`);
125
+ return r.value.onError?.(b), null;
126
+ }
127
+ }, (h) => (r.value.onError?.(h), null)).finally(() => {
128
+ s.value = !1, n.value = null;
129
+ }), n.value);
130
+ }
131
+ async function I(l = "github") {
132
+ s.value = !0;
133
+ const p = `${e.url}/auth/${l}/redirect`;
134
+ if (l === "shopify") {
135
+ window.location.assign(p + "?next=" + encodeURIComponent(window.location.href));
136
+ return;
137
+ }
138
+ const h = 400, b = 600, W = window.screenX + (window.innerWidth - h) / 2, _ = window.screenY + (window.innerHeight - b) / 2, u = window.open("", "vuetify:authorize:popup", `popup,left=${W},top=${_},width=${h},height=${b},resizable`);
139
+ if (!u) {
140
+ const E = /* @__PURE__ */ new Error("Failed to open popup");
141
+ r.value.onError?.(E), s.value = !1;
142
+ return;
143
+ }
144
+ u.location.href = p;
145
+ let y = -1, A = -1;
146
+ function N(E) {
147
+ if (E.origin === e.url && E.data?.type === "auth-response") {
148
+ if (E.data.status === "success")
149
+ t.value || (localStorage.setItem("vuetify@lastLoginProvider", l), i.value = !1), t.value = E.data.body.user, r.value.onAuth?.({
150
+ user: E.data.body.user,
151
+ access: E.data.body.access ?? []
152
+ });
153
+ else {
154
+ const H = new Error(E.data.message || "Authentication failed");
155
+ r.value.onError?.(H);
156
+ }
157
+ z();
158
+ }
159
+ }
160
+ function z() {
161
+ window.removeEventListener("message", N), window.clearInterval(y), window.clearTimeout(A), u?.close(), s.value = !1;
162
+ }
163
+ window.addEventListener("message", N), y = window.setInterval(() => {
164
+ !u || u.closed ? (r.value.onError?.(/* @__PURE__ */ new Error("Auth popup closed")), z()) : u.postMessage({ type: "auth-request" }, e.url);
165
+ }, 1e3), A = window.setTimeout(() => {
166
+ z(), r.value.onError?.(/* @__PURE__ */ new Error("Auth timed out"));
167
+ }, 120 * 1e3);
168
+ }
169
+ async function v(l) {
170
+ s.value = !0;
171
+ const p = l ? `/auth/${l}/logout` : "/auth/logout";
172
+ try {
173
+ await e.post(p), t.value = null;
174
+ } catch (h) {
175
+ r.value.onError?.(h);
176
+ } finally {
177
+ s.value = !1;
178
+ }
179
+ }
180
+ function T(l) {
181
+ return t.value?.identities.find((p) => p.provider === l);
182
+ }
183
+ function m() {
184
+ return ne ? localStorage.getItem("vuetify@lastLoginProvider") : null;
185
+ }
186
+ return {
187
+ user: t,
188
+ dialog: i,
189
+ isLoading: s,
190
+ isAuthenticated: c,
191
+ isSuper: a,
192
+ isAdmin: d,
193
+ isEditor: g,
194
+ setCallbacks: R,
195
+ verify: O,
196
+ login: I,
197
+ logout: v,
198
+ findIdentity: T,
199
+ lastLoginProvider: m
200
+ };
201
+ }), ve = $("auth-device", () => {
202
+ const e = U(), i = V(), t = S(null), s = L("idle"), r = S(null);
203
+ async function n(d) {
204
+ if (!i.isAuthenticated)
205
+ return r.value = "Must be authenticated to authorize device", !1;
206
+ try {
207
+ return s.value = "pending", await e.post(`/auth/device/${d}/authorize`), s.value = "authorized", !0;
208
+ } catch (g) {
209
+ return s.value = "error", r.value = g.message, !1;
210
+ }
211
+ }
212
+ async function c(d) {
213
+ try {
214
+ return (await e.get(`/auth/device/${d}/status`)).status;
215
+ } catch {
216
+ return "error";
217
+ }
218
+ }
219
+ function a() {
220
+ t.value = null, s.value = "idle", r.value = null;
221
+ }
222
+ return {
223
+ deviceCode: q(t),
224
+ status: q(s),
225
+ error: q(r),
226
+ authorize: n,
227
+ getStatus: c,
228
+ reset: a
229
+ };
230
+ }), re = [
231
+ (e) => (e.v || (e.pwaRefresh = !0, typeof e.api == "boolean" && (e.api = e.api ? "inline" : "link-only"), typeof e.rtl == "boolean" && (e.direction = e.rtl ? "rtl" : "ltr", delete e.rtl), typeof e.theme == "object" && (e.mixedTheme = e.theme.mixed, e.theme = e.theme.system ? "system" : e.theme.dark ? "dark" : "light"), Array.isArray(e.notifications) && (e.notifications = { read: e.notifications }), typeof e.last == "object" && (e.notifications = e.notifications || {}, e.notifications.last = e.last, delete e.last), e.v = 1), e),
232
+ (e) => (e.v === 1 && (Array.isArray(e.composition) && (e.composition = "composition"), Array.isArray(e.notifications?.last?.banner) || (e.notifications = e.notifications || {}, e.notifications.last = e.notifications.last || {}, e.notifications.last.banner = []), e.v = 2), e),
233
+ (e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
234
+ (e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
235
+ (e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
236
+ ];
237
+ function oe(e) {
238
+ return {
239
+ version: 6,
240
+ ecosystem: {
241
+ bin: {
242
+ wordWrap: !1
243
+ },
244
+ play: {
245
+ showErrors: !0,
246
+ wordWrap: !1
247
+ },
248
+ studio: {},
249
+ link: {},
250
+ docs: {
251
+ api: e.api || "link-only",
252
+ composition: e.composition || "composition",
253
+ pins: {
254
+ enabled: e.pins || !1,
255
+ pinned: Array.isArray(e.pinned) ? e.pinned.map((i) => i.name || i).filter(Boolean) : []
256
+ },
257
+ mixedTheme: e.mixedTheme ?? !0,
258
+ favorites: [],
259
+ slashSearch: e.slashSearch || !1,
260
+ railDrawer: e.railDrawer || !1
261
+ }
262
+ },
263
+ one: {
264
+ avatar: e.avatar || "",
265
+ ads: {
266
+ enabled: !e.disableAds,
267
+ house: e.showHouseAds || !1
268
+ },
269
+ command: {},
270
+ theme: e.theme || "system",
271
+ direction: e.direction || "ltr",
272
+ colors: {
273
+ primary: e.colors?.one || "surface-light"
274
+ },
275
+ suits: {
276
+ enabled: e.suits?.show || !1,
277
+ elements: e.suits?.elements || ["app-bar"],
278
+ suit: e.suits?.suit || ""
279
+ },
280
+ notifications: {
281
+ enabled: e.notifications?.show ?? !0,
282
+ read: e.notifications?.read || [],
283
+ last: ""
284
+ },
285
+ banners: {
286
+ enabled: e.notifications?.banners ?? !0,
287
+ read: e.notifications?.last?.banner || [],
288
+ last: ""
289
+ },
290
+ quicklinks: e.quickbar || !1,
291
+ sync: e.syncSettings ?? !0,
292
+ devmode: e.dev || !1
293
+ }
294
+ };
295
+ }
296
+ function F(e) {
297
+ return {
298
+ ...e,
299
+ version: 7,
300
+ ecosystem: {
301
+ ...e.ecosystem,
302
+ mcp: {
303
+ seen: !1
304
+ }
305
+ }
306
+ };
307
+ }
308
+ function ie(e) {
309
+ const i = re.reduce((s, r) => r(s), e), t = oe(i);
310
+ return F(t);
311
+ }
312
+ const B = typeof window < "u", C = {
313
+ version: 7,
314
+ ecosystem: {
315
+ bin: {
316
+ wordWrap: !0
317
+ },
318
+ play: {
319
+ showErrors: !0,
320
+ wordWrap: !1
321
+ },
322
+ studio: {},
323
+ link: {},
324
+ docs: {
325
+ api: "link-only",
326
+ composition: "composition",
327
+ pins: {
328
+ enabled: !1,
329
+ pinned: []
330
+ },
331
+ mixedTheme: !0,
332
+ favorites: [],
333
+ slashSearch: !1,
334
+ railDrawer: !1
335
+ },
336
+ mcp: {
337
+ seen: !1
338
+ }
339
+ },
340
+ one: {
341
+ avatar: "",
342
+ ads: {
343
+ enabled: !0,
344
+ house: !1
345
+ },
346
+ command: {},
347
+ theme: "system",
348
+ direction: "ltr",
349
+ colors: {
350
+ primary: "surface-light"
351
+ },
352
+ suits: {
353
+ enabled: !1,
354
+ elements: ["app-bar"],
355
+ suit: ""
356
+ },
357
+ notifications: {
358
+ enabled: !0,
359
+ read: [],
360
+ last: ""
361
+ },
362
+ banners: {
363
+ enabled: !0,
364
+ read: [],
365
+ last: ""
366
+ },
367
+ quicklinks: !1,
368
+ ecosystem: {
369
+ pinned: [],
370
+ seen: !1
371
+ },
372
+ sync: !0,
373
+ devmode: !1
374
+ }
375
+ }, ae = $("user", () => {
376
+ const e = G(structuredClone(C));
377
+ j(e, t, { deep: !0 });
378
+ function i() {
379
+ if (!B)
380
+ return;
381
+ const r = localStorage.getItem("vuetify@user");
382
+ if (r)
383
+ try {
384
+ const n = JSON.parse(r);
385
+ if (n.version >= 7) {
386
+ const c = {
387
+ version: 7,
388
+ ecosystem: x(structuredClone(C.ecosystem), n.ecosystem || {}),
389
+ one: x(structuredClone(C.one), n.one || {})
390
+ };
391
+ Object.assign(e, c);
392
+ } else if (n.version === 6) {
393
+ const c = F(n), a = {
394
+ version: 7,
395
+ ecosystem: x(structuredClone(C.ecosystem), c.ecosystem || {}),
396
+ one: x(structuredClone(C.one), c.one || {})
397
+ };
398
+ Object.assign(e, a);
399
+ } else {
400
+ const c = ie(n);
401
+ Object.assign(e, c);
402
+ }
403
+ t();
404
+ } catch (n) {
405
+ console.error("Failed to load user settings:", n);
406
+ }
407
+ }
408
+ function t() {
409
+ B && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
410
+ }
411
+ function s() {
412
+ B && (Object.assign(e, structuredClone(C)), t());
413
+ }
414
+ return i(), {
415
+ ...Z(e),
416
+ load: i,
417
+ save: t,
418
+ reset: s
419
+ };
420
+ });
421
+ function M() {
422
+ const e = te();
423
+ return f(
424
+ () => e.query
425
+ );
426
+ }
427
+ const X = $("one", () => {
428
+ const e = M(), i = Q(), t = Y(), s = U(), r = J(), n = L(!1), c = L(!1), a = S(null), d = S([]), g = f(() => e.value.session_id), R = f(() => a.value?.items[0].plan.interval), O = f(() => a.value?.items[0].plan.type), I = S([]), v = f(() => t.user?.sponsorships.find((o) => o.platform === "stripe" && o.tierName.startsWith("sub_"))), T = f(() => !!v.value?.tierName), m = f(() => t.user?.sponsorships.reduce((o, w) => {
429
+ if (!w.isActive || w.interval === "once")
430
+ return o;
431
+ const k = w.interval === "month" ? w.amount : w.amount / 12;
432
+ return o + k / 100;
433
+ }, 0) ?? 0), l = f(() => t.user?.sponsorships.find((o) => o.tierName.startsWith("sub_") && o.isActive)), p = f(() => t.user?.sponsorships.find((o) => o.platform === "github" && o.isActive)), h = f(() => t.user?.sponsorships.find((o) => o.platform === "discord" && o.isActive)), b = f(() => t.user?.sponsorships.find((o) => o.platform === "opencollective" && o.isActive)), W = f(() => t.user?.identities.find((o) => o.provider === "shopify")), _ = f(() => !s.url || t.isAdmin || v.value?.isActive || I.value.some((o) => ["one", "one/team"].includes(o)));
434
+ j(c, K), j(g, async (o) => {
435
+ o && await u();
436
+ }, { immediate: !0 }), j(e, (o) => {
437
+ if (o.one !== "subscribe" || t.user)
438
+ return;
439
+ t.dialog = !0;
440
+ const w = j(() => t.user, (k) => {
441
+ k && (t.dialog = !1, w());
442
+ });
443
+ }, { immediate: !0 });
444
+ async function u() {
445
+ try {
446
+ n.value = !0, await s.post("/one/activate", { sessionId: g.value }), await t.verify(!0), await E();
447
+ const o = new URL(window.location.href), w = o.searchParams;
448
+ w.delete("session_id"), w.delete("team"), history.pushState(null, "", o.toString());
449
+ } catch (o) {
450
+ r.showError(o?.message ?? "Error activating subscription, Please contact support");
451
+ } finally {
452
+ n.value = !1;
453
+ }
454
+ }
455
+ async function y() {
456
+ window.open(`${s.url}/one/manage`, "_blank");
457
+ }
458
+ async function A(o, w) {
459
+ n.value = !0;
460
+ const k = new URL("/one/subscribe", s.url);
461
+ k.searchParams.set("interval", o), k.searchParams.set("type", w), window.location.href = k.toString();
462
+ }
463
+ async function N() {
464
+ if (v.value)
465
+ try {
466
+ n.value = !0, await s.post(
467
+ `/one/cancel?subscriptionId=${v.value?.tierName}`
468
+ ), await t.verify(!0);
469
+ } catch (o) {
470
+ r.showError(o?.message ?? "Error cancelling subscription, Please contact support");
471
+ } finally {
472
+ n.value = !1;
473
+ }
474
+ }
475
+ async function z(o, w) {
476
+ if (v.value)
477
+ try {
478
+ n.value = !0, await s.post("/one/modify", {
479
+ subscriptionId: v.value.tierName,
480
+ interval: o,
481
+ type: w
482
+ }), await t.verify(!0);
483
+ } catch (k) {
484
+ r.showError(k?.message ?? "Error modifying subscription");
485
+ } finally {
486
+ n.value = !1;
487
+ }
488
+ }
489
+ async function E() {
490
+ try {
491
+ n.value = !0;
492
+ const o = await s.get("/one/info");
493
+ return a.value = o.subscription, d.value = o.invoices, o;
494
+ } catch (o) {
495
+ r.showError(o?.message ?? "Error fetching subscription info");
496
+ } finally {
497
+ n.value = !1;
498
+ }
499
+ }
500
+ async function H() {
501
+ try {
502
+ return n.value = !0, (await s.get("/one/activity")).items;
503
+ } catch (o) {
504
+ r.showError(o?.message ?? "Error fetching recent activity");
505
+ } finally {
506
+ n.value = !1;
507
+ }
508
+ }
509
+ function K() {
510
+ i.push({
511
+ query: {
512
+ ...e.value,
513
+ one: void 0
514
+ }
515
+ });
516
+ }
517
+ return {
518
+ info: a,
519
+ interval: R,
520
+ subscriptionType: O,
521
+ access: I,
522
+ invoices: d,
523
+ sessionId: g,
524
+ subscription: v,
525
+ monthlyTotal: m,
526
+ recentActivity: H,
527
+ hasBilling: T,
528
+ isLoading: n,
529
+ isOpen: c,
530
+ isSubscriber: _,
531
+ opencollective: b,
532
+ github: p,
533
+ discord: h,
534
+ shopify: W,
535
+ one: l,
536
+ activate: u,
537
+ cancel: N,
538
+ manage: y,
539
+ modify: z,
540
+ resetQuery: K,
541
+ subscribe: A,
542
+ subscriptionInfo: E
543
+ };
544
+ }), ue = $("team", () => {
545
+ const e = M(), i = Y(), t = X(), s = U(), r = J(), n = L(!1), c = S(null), a = S(!1), d = f(() => e.value.invite), g = f(
546
+ () => c.value ? t.access?.some((m) => ["one/team", "snips/team"].includes(m)) : !1
547
+ );
548
+ j(d, async () => {
549
+ if (d.value) {
550
+ i.user || (i.dialog = !0);
551
+ try {
552
+ n.value = !0;
553
+ const m = await s.get(`/one/team/${d.value}`);
554
+ c.value = m.team, a.value = !0;
555
+ } catch (m) {
556
+ v(), r.showError(m.message);
557
+ } finally {
558
+ n.value = !1;
559
+ }
560
+ }
561
+ }, { immediate: !0 });
562
+ async function R(m) {
563
+ try {
564
+ if (n.value = !0, !c.value)
565
+ return;
566
+ await s.post("/one/team/remove", { userId: m }), c.value.members = c.value.members.filter((l) => l.id !== m);
567
+ } catch (l) {
568
+ r.showError(l?.message ?? "Error removing user from team");
569
+ } finally {
570
+ n.value = !1;
571
+ }
572
+ }
573
+ async function O() {
574
+ try {
575
+ n.value = !0, await s.post("/one/team/leave", { teamId: c.value?.id }), await i.verify(!0);
576
+ } catch (m) {
577
+ r.showError(m?.message ?? "Error leaving team");
578
+ } finally {
579
+ n.value = !1;
580
+ }
581
+ }
582
+ async function I() {
583
+ try {
584
+ n.value = !0, await s.post("/one/team/join", { inviteCode: d.value }), await i.verify(!0), v();
585
+ } catch (m) {
586
+ r.showError(m?.message ?? "Error joining team");
587
+ } finally {
588
+ n.value = !1;
589
+ }
590
+ }
591
+ function v() {
592
+ a.value = !1;
593
+ const m = new URL(window.location.href);
594
+ m.searchParams.delete("invite"), window.history.replaceState({}, "", m.toString());
595
+ }
596
+ const T = f(() => i.user?.id === i.user?.team?.owner?.id);
597
+ return {
598
+ team: c,
599
+ teamInviteDialog: a,
600
+ teamInviteCode: d,
601
+ hasTeamAccess: g,
602
+ isTeamOwner: T,
603
+ isLoading: n,
604
+ removeFromTeam: R,
605
+ leaveTeam: O,
606
+ joinTeam: I,
607
+ clearTeamQuery: v
608
+ };
609
+ }), ce = typeof window < "u", Y = $("auth", () => {
610
+ const e = V(), i = U(), t = ae(), s = Q(), r = X(), n = ue(), c = J(), a = P(() => e.user), d = P(() => e.dialog), g = P(() => e.isLoading), R = P(() => e.isAuthenticated), O = P(() => e.isSuper), I = P(() => e.isAdmin), v = P(() => e.isEditor);
611
+ let T = !!e.lastLoginProvider();
612
+ j(a, (u) => {
613
+ if (!ce || !u?.settings)
614
+ return;
615
+ const y = localStorage.getItem("vuetify@user") || "{}";
616
+ if (JSON.stringify(u.settings, null, 2) === y)
617
+ return;
618
+ T = !0;
619
+ let A = u.settings;
620
+ A.version === 6 && (A = F(A));
621
+ const N = {
622
+ version: 7,
623
+ ecosystem: x(structuredClone(C.ecosystem), A.ecosystem || {}),
624
+ one: x(structuredClone(C.one), A.one || {})
625
+ };
626
+ Object.assign(t, N);
627
+ });
628
+ const m = ee(l, 500);
629
+ t.$subscribe(() => {
630
+ T || m(), T = !1;
631
+ });
632
+ async function l() {
633
+ if (await D(), !(!a.value || !t.one.sync))
634
+ try {
635
+ await i.post("/user/settings", { settings: t.$state }), await p(!0);
636
+ } catch (u) {
637
+ c.showError(u?.message ?? "Error syncing settings");
638
+ }
639
+ }
640
+ e.setCallbacks({
641
+ onAuth: (u) => {
642
+ r.access = u.access;
643
+ const y = u.user?.team;
644
+ y?.inviteCode && y.members && y.owner && (n.team = {
645
+ id: y.id,
646
+ name: y.name,
647
+ inviteCode: y.inviteCode,
648
+ members: y.members,
649
+ owner: y.owner
650
+ });
651
+ },
652
+ onError: (u) => {
653
+ c.showError(u.message ?? "Authentication error");
654
+ }
655
+ });
656
+ async function p(u = !1) {
657
+ return e.verify(u);
658
+ }
659
+ async function h(u = "github") {
660
+ await e.login(u), e.user && (e.dialog = !1, s.push("/user/dashboard"), l());
661
+ }
662
+ async function b(u) {
663
+ await e.logout(u), s.push({
664
+ path: "/",
665
+ query: s.currentRoute.value.query
666
+ });
667
+ }
668
+ function W(u) {
669
+ return e.findIdentity(u);
670
+ }
671
+ function _() {
672
+ return e.lastLoginProvider();
673
+ }
674
+ return {
675
+ // State (proxied from base)
676
+ user: a,
677
+ url: i.url,
678
+ dialog: d,
679
+ isLoading: g,
680
+ isAuthenticated: R,
681
+ isSuper: O,
682
+ isAdmin: I,
683
+ isEditor: v,
684
+ // Actions
685
+ verify: p,
686
+ findIdentity: W,
687
+ login: h,
688
+ logout: b,
689
+ lastLoginProvider: _,
690
+ sync: l
691
+ };
692
+ });
693
+ export {
694
+ Y as a,
695
+ ae as b,
696
+ X as c,
697
+ M as d,
698
+ he as e,
699
+ ue as f,
700
+ U as g,
701
+ ve as h,
702
+ J as u
703
+ };