@vuetify/one 2.13.2 → 3.0.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.
@@ -0,0 +1,702 @@
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(p, "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
+ let y = -1, A = -1;
145
+ function N(E) {
146
+ if (E.origin === e.url && E.data?.type === "auth-response") {
147
+ if (E.data.status === "success")
148
+ t.value || (localStorage.setItem("vuetify@lastLoginProvider", l), i.value = !1), t.value = E.data.body.user, r.value.onAuth?.({
149
+ user: E.data.body.user,
150
+ access: E.data.body.access ?? []
151
+ });
152
+ else {
153
+ const H = new Error(E.data.message || "Authentication failed");
154
+ r.value.onError?.(H);
155
+ }
156
+ z();
157
+ }
158
+ }
159
+ function z() {
160
+ window.removeEventListener("message", N), window.clearInterval(y), window.clearTimeout(A), u?.close(), s.value = !1;
161
+ }
162
+ window.addEventListener("message", N), y = window.setInterval(() => {
163
+ !u || u.closed ? (r.value.onError?.(/* @__PURE__ */ new Error("Auth popup closed")), z()) : u.postMessage({ type: "auth-request" }, e.url);
164
+ }, 1e3), A = window.setTimeout(() => {
165
+ z(), r.value.onError?.(/* @__PURE__ */ new Error("Auth timed out"));
166
+ }, 120 * 1e3);
167
+ }
168
+ async function v(l) {
169
+ s.value = !0;
170
+ const p = l ? `/auth/${l}/logout` : "/auth/logout";
171
+ try {
172
+ await e.post(p), t.value = null;
173
+ } catch (h) {
174
+ r.value.onError?.(h);
175
+ } finally {
176
+ s.value = !1;
177
+ }
178
+ }
179
+ function T(l) {
180
+ return t.value?.identities.find((p) => p.provider === l);
181
+ }
182
+ function m() {
183
+ return ne ? localStorage.getItem("vuetify@lastLoginProvider") : null;
184
+ }
185
+ return {
186
+ user: t,
187
+ dialog: i,
188
+ isLoading: s,
189
+ isAuthenticated: c,
190
+ isSuper: a,
191
+ isAdmin: d,
192
+ isEditor: g,
193
+ setCallbacks: R,
194
+ verify: O,
195
+ login: I,
196
+ logout: v,
197
+ findIdentity: T,
198
+ lastLoginProvider: m
199
+ };
200
+ }), ve = $("auth-device", () => {
201
+ const e = U(), i = V(), t = S(null), s = L("idle"), r = S(null);
202
+ async function n(d) {
203
+ if (!i.isAuthenticated)
204
+ return r.value = "Must be authenticated to authorize device", !1;
205
+ try {
206
+ return s.value = "pending", await e.post(`/auth/device/${d}/authorize`), s.value = "authorized", !0;
207
+ } catch (g) {
208
+ return s.value = "error", r.value = g.message, !1;
209
+ }
210
+ }
211
+ async function c(d) {
212
+ try {
213
+ return (await e.get(`/auth/device/${d}/status`)).status;
214
+ } catch {
215
+ return "error";
216
+ }
217
+ }
218
+ function a() {
219
+ t.value = null, s.value = "idle", r.value = null;
220
+ }
221
+ return {
222
+ deviceCode: q(t),
223
+ status: q(s),
224
+ error: q(r),
225
+ authorize: n,
226
+ getStatus: c,
227
+ reset: a
228
+ };
229
+ }), re = [
230
+ (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),
231
+ (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),
232
+ (e) => (e.v === 2 && (e.syncSettings = !0, e.disableAds = !1, e.v = 3), e),
233
+ (e) => (e.v === 3 && (e.quickbar = !1, e.v = 4), e),
234
+ (e) => (e.v === 4 && (e.suits = { show: !1, elements: ["app-bar"], suit: "" }, e.notifications = e.notifications || {}, e.notifications.banners = !0, e.v = 5), e)
235
+ ];
236
+ function oe(e) {
237
+ return {
238
+ version: 6,
239
+ ecosystem: {
240
+ bin: {
241
+ wordWrap: !1
242
+ },
243
+ play: {
244
+ showErrors: !0,
245
+ wordWrap: !1
246
+ },
247
+ studio: {},
248
+ link: {},
249
+ docs: {
250
+ api: e.api || "link-only",
251
+ composition: e.composition || "composition",
252
+ pins: {
253
+ enabled: e.pins || !1,
254
+ pinned: Array.isArray(e.pinned) ? e.pinned.map((i) => i.name || i).filter(Boolean) : []
255
+ },
256
+ mixedTheme: e.mixedTheme ?? !0,
257
+ favorites: [],
258
+ slashSearch: e.slashSearch || !1,
259
+ railDrawer: e.railDrawer || !1
260
+ }
261
+ },
262
+ one: {
263
+ avatar: e.avatar || "",
264
+ ads: {
265
+ enabled: !e.disableAds,
266
+ house: e.showHouseAds || !1
267
+ },
268
+ command: {},
269
+ theme: e.theme || "system",
270
+ direction: e.direction || "ltr",
271
+ colors: {
272
+ primary: e.colors?.one || "surface-light"
273
+ },
274
+ suits: {
275
+ enabled: e.suits?.show || !1,
276
+ elements: e.suits?.elements || ["app-bar"],
277
+ suit: e.suits?.suit || ""
278
+ },
279
+ notifications: {
280
+ enabled: e.notifications?.show ?? !0,
281
+ read: e.notifications?.read || [],
282
+ last: ""
283
+ },
284
+ banners: {
285
+ enabled: e.notifications?.banners ?? !0,
286
+ read: e.notifications?.last?.banner || [],
287
+ last: ""
288
+ },
289
+ quicklinks: e.quickbar || !1,
290
+ sync: e.syncSettings ?? !0,
291
+ devmode: e.dev || !1
292
+ }
293
+ };
294
+ }
295
+ function F(e) {
296
+ return {
297
+ ...e,
298
+ version: 7,
299
+ ecosystem: {
300
+ ...e.ecosystem,
301
+ mcp: {
302
+ seen: !1
303
+ }
304
+ }
305
+ };
306
+ }
307
+ function ie(e) {
308
+ const i = re.reduce((s, r) => r(s), e), t = oe(i);
309
+ return F(t);
310
+ }
311
+ const B = typeof window < "u", C = {
312
+ version: 7,
313
+ ecosystem: {
314
+ bin: {
315
+ wordWrap: !0
316
+ },
317
+ play: {
318
+ showErrors: !0,
319
+ wordWrap: !1
320
+ },
321
+ studio: {},
322
+ link: {},
323
+ docs: {
324
+ api: "link-only",
325
+ composition: "composition",
326
+ pins: {
327
+ enabled: !1,
328
+ pinned: []
329
+ },
330
+ mixedTheme: !0,
331
+ favorites: [],
332
+ slashSearch: !1,
333
+ railDrawer: !1
334
+ },
335
+ mcp: {
336
+ seen: !1
337
+ }
338
+ },
339
+ one: {
340
+ avatar: "",
341
+ ads: {
342
+ enabled: !0,
343
+ house: !1
344
+ },
345
+ command: {},
346
+ theme: "system",
347
+ direction: "ltr",
348
+ colors: {
349
+ primary: "surface-light"
350
+ },
351
+ suits: {
352
+ enabled: !1,
353
+ elements: ["app-bar"],
354
+ suit: ""
355
+ },
356
+ notifications: {
357
+ enabled: !0,
358
+ read: [],
359
+ last: ""
360
+ },
361
+ banners: {
362
+ enabled: !0,
363
+ read: [],
364
+ last: ""
365
+ },
366
+ quicklinks: !1,
367
+ ecosystem: {
368
+ pinned: [],
369
+ seen: !1
370
+ },
371
+ sync: !0,
372
+ devmode: !1
373
+ }
374
+ }, ae = $("user", () => {
375
+ const e = G(structuredClone(C));
376
+ j(e, t, { deep: !0 });
377
+ function i() {
378
+ if (!B)
379
+ return;
380
+ const r = localStorage.getItem("vuetify@user");
381
+ if (r)
382
+ try {
383
+ const n = JSON.parse(r);
384
+ if (n.version >= 7) {
385
+ const c = {
386
+ version: 7,
387
+ ecosystem: x(structuredClone(C.ecosystem), n.ecosystem || {}),
388
+ one: x(structuredClone(C.one), n.one || {})
389
+ };
390
+ Object.assign(e, c);
391
+ } else if (n.version === 6) {
392
+ const c = F(n), a = {
393
+ version: 7,
394
+ ecosystem: x(structuredClone(C.ecosystem), c.ecosystem || {}),
395
+ one: x(structuredClone(C.one), c.one || {})
396
+ };
397
+ Object.assign(e, a);
398
+ } else {
399
+ const c = ie(n);
400
+ Object.assign(e, c);
401
+ }
402
+ t();
403
+ } catch (n) {
404
+ console.error("Failed to load user settings:", n);
405
+ }
406
+ }
407
+ function t() {
408
+ B && localStorage.setItem("vuetify@user", JSON.stringify(e, null, 2));
409
+ }
410
+ function s() {
411
+ B && (Object.assign(e, structuredClone(C)), t());
412
+ }
413
+ return i(), {
414
+ ...Z(e),
415
+ load: i,
416
+ save: t,
417
+ reset: s
418
+ };
419
+ });
420
+ function M() {
421
+ const e = te();
422
+ return f(
423
+ () => e.query
424
+ );
425
+ }
426
+ const X = $("one", () => {
427
+ 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) => {
428
+ if (!w.isActive || w.interval === "once")
429
+ return o;
430
+ const k = w.interval === "month" ? w.amount : w.amount / 12;
431
+ return o + k / 100;
432
+ }, 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)));
433
+ j(c, K), j(g, async (o) => {
434
+ o && await u();
435
+ }, { immediate: !0 }), j(e, (o) => {
436
+ if (o.one !== "subscribe" || t.user)
437
+ return;
438
+ t.dialog = !0;
439
+ const w = j(() => t.user, (k) => {
440
+ k && (t.dialog = !1, w());
441
+ });
442
+ }, { immediate: !0 });
443
+ async function u() {
444
+ try {
445
+ n.value = !0, await s.post("/one/activate", { sessionId: g.value }), await t.verify(!0), await E();
446
+ const o = new URL(window.location.href), w = o.searchParams;
447
+ w.delete("session_id"), w.delete("team"), history.pushState(null, "", o.toString());
448
+ } catch (o) {
449
+ r.showError(o?.message ?? "Error activating subscription, Please contact support");
450
+ } finally {
451
+ n.value = !1;
452
+ }
453
+ }
454
+ async function y() {
455
+ window.open(`${s.url}/one/manage`, "_blank");
456
+ }
457
+ async function A(o, w) {
458
+ n.value = !0;
459
+ const k = new URL("/one/subscribe", s.url);
460
+ k.searchParams.set("interval", o), k.searchParams.set("type", w), window.location.href = k.toString();
461
+ }
462
+ async function N() {
463
+ if (v.value)
464
+ try {
465
+ n.value = !0, await s.post(
466
+ `/one/cancel?subscriptionId=${v.value?.tierName}`
467
+ ), await t.verify(!0);
468
+ } catch (o) {
469
+ r.showError(o?.message ?? "Error cancelling subscription, Please contact support");
470
+ } finally {
471
+ n.value = !1;
472
+ }
473
+ }
474
+ async function z(o, w) {
475
+ if (v.value)
476
+ try {
477
+ n.value = !0, await s.post("/one/modify", {
478
+ subscriptionId: v.value.tierName,
479
+ interval: o,
480
+ type: w
481
+ }), await t.verify(!0);
482
+ } catch (k) {
483
+ r.showError(k?.message ?? "Error modifying subscription");
484
+ } finally {
485
+ n.value = !1;
486
+ }
487
+ }
488
+ async function E() {
489
+ try {
490
+ n.value = !0;
491
+ const o = await s.get("/one/info");
492
+ return a.value = o.subscription, d.value = o.invoices, o;
493
+ } catch (o) {
494
+ r.showError(o?.message ?? "Error fetching subscription info");
495
+ } finally {
496
+ n.value = !1;
497
+ }
498
+ }
499
+ async function H() {
500
+ try {
501
+ return n.value = !0, (await s.get("/one/activity")).items;
502
+ } catch (o) {
503
+ r.showError(o?.message ?? "Error fetching recent activity");
504
+ } finally {
505
+ n.value = !1;
506
+ }
507
+ }
508
+ function K() {
509
+ i.push({
510
+ query: {
511
+ ...e.value,
512
+ one: void 0
513
+ }
514
+ });
515
+ }
516
+ return {
517
+ info: a,
518
+ interval: R,
519
+ subscriptionType: O,
520
+ access: I,
521
+ invoices: d,
522
+ sessionId: g,
523
+ subscription: v,
524
+ monthlyTotal: m,
525
+ recentActivity: H,
526
+ hasBilling: T,
527
+ isLoading: n,
528
+ isOpen: c,
529
+ isSubscriber: _,
530
+ opencollective: b,
531
+ github: p,
532
+ discord: h,
533
+ shopify: W,
534
+ one: l,
535
+ activate: u,
536
+ cancel: N,
537
+ manage: y,
538
+ modify: z,
539
+ resetQuery: K,
540
+ subscribe: A,
541
+ subscriptionInfo: E
542
+ };
543
+ }), ue = $("team", () => {
544
+ 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(
545
+ () => c.value ? t.access?.some((m) => ["one/team", "snips/team"].includes(m)) : !1
546
+ );
547
+ j(d, async () => {
548
+ if (d.value) {
549
+ i.user || (i.dialog = !0);
550
+ try {
551
+ n.value = !0;
552
+ const m = await s.get(`/one/team/${d.value}`);
553
+ c.value = m.team, a.value = !0;
554
+ } catch (m) {
555
+ v(), r.showError(m.message);
556
+ } finally {
557
+ n.value = !1;
558
+ }
559
+ }
560
+ }, { immediate: !0 });
561
+ async function R(m) {
562
+ try {
563
+ if (n.value = !0, !c.value)
564
+ return;
565
+ await s.post("/one/team/remove", { userId: m }), c.value.members = c.value.members.filter((l) => l.id !== m);
566
+ } catch (l) {
567
+ r.showError(l?.message ?? "Error removing user from team");
568
+ } finally {
569
+ n.value = !1;
570
+ }
571
+ }
572
+ async function O() {
573
+ try {
574
+ n.value = !0, await s.post("/one/team/leave", { teamId: c.value?.id }), await i.verify(!0);
575
+ } catch (m) {
576
+ r.showError(m?.message ?? "Error leaving team");
577
+ } finally {
578
+ n.value = !1;
579
+ }
580
+ }
581
+ async function I() {
582
+ try {
583
+ n.value = !0, await s.post("/one/team/join", { inviteCode: d.value }), await i.verify(!0), v();
584
+ } catch (m) {
585
+ r.showError(m?.message ?? "Error joining team");
586
+ } finally {
587
+ n.value = !1;
588
+ }
589
+ }
590
+ function v() {
591
+ a.value = !1;
592
+ const m = new URL(window.location.href);
593
+ m.searchParams.delete("invite"), window.history.replaceState({}, "", m.toString());
594
+ }
595
+ const T = f(() => i.user?.id === i.user?.team?.owner?.id);
596
+ return {
597
+ team: c,
598
+ teamInviteDialog: a,
599
+ teamInviteCode: d,
600
+ hasTeamAccess: g,
601
+ isTeamOwner: T,
602
+ isLoading: n,
603
+ removeFromTeam: R,
604
+ leaveTeam: O,
605
+ joinTeam: I,
606
+ clearTeamQuery: v
607
+ };
608
+ }), ce = typeof window < "u", Y = $("auth", () => {
609
+ 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);
610
+ let T = !!e.lastLoginProvider();
611
+ j(a, (u) => {
612
+ if (!ce || !u?.settings)
613
+ return;
614
+ const y = localStorage.getItem("vuetify@user") || "{}";
615
+ if (JSON.stringify(u.settings, null, 2) === y)
616
+ return;
617
+ T = !0;
618
+ let A = u.settings;
619
+ A.version === 6 && (A = F(A));
620
+ const N = {
621
+ version: 7,
622
+ ecosystem: x(structuredClone(C.ecosystem), A.ecosystem || {}),
623
+ one: x(structuredClone(C.one), A.one || {})
624
+ };
625
+ Object.assign(t, N);
626
+ });
627
+ const m = ee(l, 500);
628
+ t.$subscribe(() => {
629
+ T || m(), T = !1;
630
+ });
631
+ async function l() {
632
+ if (await D(), !(!a.value || !t.one.sync))
633
+ try {
634
+ await i.post("/user/settings", { settings: t.$state }), await p(!0);
635
+ } catch (u) {
636
+ c.showError(u?.message ?? "Error syncing settings");
637
+ }
638
+ }
639
+ e.setCallbacks({
640
+ onAuth: (u) => {
641
+ r.access = u.access;
642
+ const y = u.user?.team;
643
+ y?.inviteCode && y.members && y.owner && (n.team = {
644
+ id: y.id,
645
+ name: y.name,
646
+ inviteCode: y.inviteCode,
647
+ members: y.members,
648
+ owner: y.owner
649
+ });
650
+ },
651
+ onError: (u) => {
652
+ c.showError(u.message ?? "Authentication error");
653
+ }
654
+ });
655
+ async function p(u = !1) {
656
+ return e.verify(u);
657
+ }
658
+ async function h(u = "github") {
659
+ await e.login(u), e.user && (e.dialog = !1, s.push("/user/dashboard"), l());
660
+ }
661
+ async function b(u) {
662
+ await e.logout(u), s.push({
663
+ path: "/",
664
+ query: s.currentRoute.value.query
665
+ });
666
+ }
667
+ function W(u) {
668
+ return e.findIdentity(u);
669
+ }
670
+ function _() {
671
+ return e.lastLoginProvider();
672
+ }
673
+ return {
674
+ // State (proxied from base)
675
+ user: a,
676
+ url: i.url,
677
+ dialog: d,
678
+ isLoading: g,
679
+ isAuthenticated: R,
680
+ isSuper: O,
681
+ isAdmin: I,
682
+ isEditor: v,
683
+ // Actions
684
+ verify: p,
685
+ findIdentity: W,
686
+ login: h,
687
+ logout: b,
688
+ lastLoginProvider: _,
689
+ sync: l
690
+ };
691
+ });
692
+ export {
693
+ Y as a,
694
+ ae as b,
695
+ X as c,
696
+ M as d,
697
+ he as e,
698
+ ue as f,
699
+ U as g,
700
+ ve as h,
701
+ J as u
702
+ };