vue3-router-tab 1.3.5 → 1.3.7

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.
@@ -1,7 +1,7 @@
1
1
  import './vue3-router-tab.css';
2
- import { reactive as pe, ref as B, shallowRef as bt, computed as k, watch as A, nextTick as M, inject as Ee, getCurrentInstance as je, onMounted as ge, defineComponent as Oe, provide as pt, onErrorCaptured as gt, onBeforeUnmount as mt, resolveComponent as vt, createElementBlock as S, openBlock as E, createElementVNode as O, withDirectives as ht, normalizeClass as H, renderSlot as le, createVNode as Ae, TransitionGroup as yt, mergeProps as se, withCtx as ue, Fragment as Pe, renderList as Ie, withModifiers as ce, createCommentVNode as q, toDisplayString as $e, createBlock as W, normalizeProps as Tt, Transition as kt, resolveDynamicComponent as fe, KeepAlive as wt, normalizeStyle as Rt, vShow as Ct, isRef as Et, isReadonly as At } from "vue";
3
- import { RouterView as Pt } from "vue-router";
4
- function It(e = {}) {
2
+ import { reactive as ae, ref as S, shallowRef as Ct, computed as C, watch as A, nextTick as B, inject as Me, getCurrentInstance as We, onMounted as ke, defineComponent as Ce, provide as Kt, onErrorCaptured as Et, onBeforeUnmount as $t, h as At, resolveComponent as Pt, createElementBlock as x, openBlock as $, createElementVNode as j, withDirectives as St, normalizeClass as J, renderSlot as pe, createVNode as Le, TransitionGroup as It, mergeProps as ve, withCtx as he, Fragment as me, renderList as Oe, withModifiers as ye, createCommentVNode as ee, toDisplayString as je, normalizeProps as xt, createBlock as te, KeepAlive as Dt, resolveDynamicComponent as ze, Transition as Bt, normalizeStyle as Mt, vShow as Lt, isRef as Ot, isReadonly as jt } from "vue";
3
+ import { RouterView as zt } from "vue-router";
4
+ function Nt(e = {}) {
5
5
  return {
6
6
  initialTabs: e.initialTabs ?? [],
7
7
  keepAlive: e.keepAlive ?? !0,
@@ -11,80 +11,83 @@ function It(e = {}) {
11
11
  defaultRoute: e.defaultRoute ?? "/"
12
12
  };
13
13
  }
14
- function N(e, n) {
15
- const o = e.resolve(n);
14
+ function V(e, r) {
15
+ const o = e.resolve(r);
16
16
  if (!o || !o.matched.length)
17
- throw new Error(`[RouterTabs] Unable to resolve route: ${String(n)}`);
17
+ throw new Error(`[RouterTabs] Unable to resolve route: ${String(r)}`);
18
18
  return o;
19
19
  }
20
- const $t = {
20
+ const Ut = {
21
21
  path: (e) => e.path,
22
22
  fullpath: (e) => e.fullPath,
23
23
  fullname: (e) => e.fullPath,
24
24
  full: (e) => e.fullPath,
25
25
  name: (e) => e.name ? String(e.name) : e.fullPath
26
26
  };
27
- function z(e) {
28
- const n = e.meta?.key;
29
- if (typeof n == "function") {
30
- const o = n(e);
27
+ function _(e) {
28
+ const r = e.meta?.key;
29
+ if (typeof r == "function") {
30
+ const o = r(e);
31
31
  if (typeof o == "string" && o.length) return o;
32
- } else if (typeof n == "string" && n.length) {
33
- const o = $t[n.toLowerCase()];
34
- return o ? o(e) : n;
32
+ } else if (typeof r == "string" && r.length) {
33
+ const o = Ut[r.toLowerCase()];
34
+ return o ? o(e) : r;
35
35
  }
36
36
  return e.fullPath;
37
37
  }
38
- function me(e, n) {
38
+ function Ke(e, r) {
39
39
  const o = e.meta?.keepAlive;
40
- return typeof o == "boolean" ? o : n;
40
+ return typeof o == "boolean" ? o : r;
41
41
  }
42
- function ve(e, n) {
42
+ function Ee(e, r) {
43
43
  const o = e.meta?.reuse;
44
- return typeof o == "boolean" ? o : n;
44
+ return typeof o == "boolean" ? o : r;
45
45
  }
46
- function Ue(e) {
47
- const n = e.meta ?? {}, o = {};
48
- return "title" in n && (o.title = n.title), "tips" in n && (o.tips = n.tips), "icon" in n && (o.icon = n.icon), "closable" in n && (o.closable = n.closable), "tabClass" in n && (o.tabClass = n.tabClass), "target" in n && (o.target = n.target), "href" in n && (o.href = n.href), o;
46
+ function qe(e) {
47
+ const r = e.meta ?? {}, o = {};
48
+ return "title" in r && (o.title = r.title), "tips" in r && (o.tips = r.tips), "icon" in r && (o.icon = r.icon), "closable" in r && (o.closable = r.closable), "tabClass" in r && (o.tabClass = r.tabClass), "target" in r && (o.target = r.target), "href" in r && (o.href = r.href), o;
49
49
  }
50
- function Q(e, n, o) {
51
- const l = Ue(e);
50
+ function ne(e, r, o) {
51
+ const s = qe(e);
52
52
  return {
53
- id: z(e),
53
+ id: _(e),
54
54
  to: e.fullPath,
55
55
  fullPath: e.fullPath,
56
56
  matched: e,
57
- alive: me(e, o),
58
- reusable: ve(e, !1),
59
- closable: l.closable ?? !0,
60
- renderKey: typeof n.renderKey == "number" ? n.renderKey : 0,
61
- ...l,
62
- ...n
57
+ alive: Ke(e, o),
58
+ reusable: Ee(e, !1),
59
+ closable: s.closable ?? !0,
60
+ renderKey: typeof r.renderKey == "number" ? r.renderKey : 0,
61
+ ...s,
62
+ ...r
63
63
  };
64
64
  }
65
- function de(e, n, o, l) {
66
- if (!e.find((g) => g.id === n.id)) {
67
- if (o === "next" && l) {
68
- const g = e.findIndex((T) => T.id === l);
69
- if (g !== -1) {
70
- e.splice(g + 1, 0, n);
65
+ function Te(e, r, o, s) {
66
+ if (!e.find((p) => p.id === r.id)) {
67
+ if (o === "next" && s) {
68
+ const p = e.findIndex((T) => T.id === s);
69
+ if (p !== -1) {
70
+ e.splice(p + 1, 0, r);
71
71
  return;
72
72
  }
73
73
  }
74
- e.push(n);
74
+ e.push(r);
75
75
  }
76
76
  }
77
- function Ke(e, n, o) {
78
- if (!n || n <= 0) return;
79
- const l = e.filter((a) => a.alive);
80
- for (; l.length > n; ) {
81
- const a = l.shift();
82
- if (!a || a.id === o) continue;
83
- const g = e.findIndex((T) => T.id === a.id);
84
- g > -1 && (e[g].alive = !1);
77
+ function Re(e, r, o, s) {
78
+ if (!r || r <= 0) return;
79
+ const a = e.filter((p) => p.alive);
80
+ for (; a.length > r; ) {
81
+ const p = a.shift();
82
+ if (!p || p.id === o) continue;
83
+ const T = e.findIndex((i) => i.id === p.id);
84
+ if (T > -1) {
85
+ const i = e[T], b = `${i.id}::${i.renderKey ?? 0}`;
86
+ s.delete(b), i.alive = !1;
87
+ }
85
88
  }
86
89
  }
87
- function Kt(e) {
90
+ function Vt(e) {
88
91
  return {
89
92
  to: e.to,
90
93
  title: e.title,
@@ -95,177 +98,222 @@ function Kt(e) {
95
98
  renderKey: e.renderKey
96
99
  };
97
100
  }
98
- function xt(e) {
99
- const n = {};
100
- return "title" in e && (n.title = e.title), "tips" in e && (n.tips = e.tips), "icon" in e && (n.icon = e.icon), "tabClass" in e && (n.tabClass = e.tabClass), "closable" in e && (n.closable = e.closable), "renderKey" in e && typeof e.renderKey == "number" && (n.renderKey = e.renderKey), n;
101
+ function _t(e) {
102
+ const r = {};
103
+ return "title" in e && (r.title = e.title), "tips" in e && (r.tips = e.tips), "icon" in e && (r.icon = e.icon), "tabClass" in e && (r.tabClass = e.tabClass), "closable" in e && (r.closable = e.closable), "renderKey" in e && typeof e.renderKey == "number" && (r.renderKey = e.renderKey), r;
101
104
  }
102
- function Dt(e, n = {}) {
103
- const o = It(n), l = pe([]), a = B(null), g = bt(), T = B(null), s = k(
104
- () => l.filter((i) => i.alive).map((i) => `${i.id}::${i.renderKey ?? 0}`)
105
- );
106
- let f = !1;
107
- function v(i) {
108
- const b = typeof i.matched == "object" ? i : N(e, i);
105
+ function Yt(e, r = {}) {
106
+ const o = Nt(r), s = ae([]), a = S(null), p = Ct(), T = S(null), i = ae(/* @__PURE__ */ new Set()), b = C(() => Array.from(i));
107
+ let h = !1;
108
+ function E(u) {
109
+ const c = typeof u.matched == "object" ? u : V(e, u);
109
110
  return {
110
- key: z(b),
111
- fullPath: b.fullPath,
112
- alive: me(b, o.keepAlive),
113
- reusable: ve(b, !1),
114
- matched: b
111
+ key: _(c),
112
+ fullPath: c.fullPath,
113
+ alive: Ke(c, o.keepAlive),
114
+ reusable: Ee(c, !1),
115
+ matched: c
115
116
  };
116
117
  }
117
- function C(i) {
118
- const b = z(i);
119
- let d = l.find((y) => y.id === b);
120
- return d ? (d.fullPath = i.fullPath, d.to = i.fullPath, d.matched = i, d.alive = me(i, o.keepAlive), d.reusable = ve(i, d.reusable), typeof d.renderKey != "number" && (d.renderKey = 0), Object.assign(d, Ue(i)), d) : (d = Q(i, {}, o.keepAlive), de(l, d, o.appendPosition, a.value), Ke(l, o.maxAlive, a.value), d);
118
+ function P(u) {
119
+ const c = _(u);
120
+ let f = s.find((y) => y.id === c);
121
+ const m = Ke(u, o.keepAlive);
122
+ if (f) {
123
+ f.fullPath = u.fullPath, f.to = u.fullPath, f.matched = u, f.reusable = Ee(u, f.reusable), typeof f.renderKey != "number" && (f.renderKey = 0);
124
+ const y = `${c}::${f.renderKey}`;
125
+ return (c.includes("students") || c.includes("classroom") || c.includes("quiz")) && console.log(`[ensureTab] EXISTING tab: ${u.fullPath}`, {
126
+ key: c,
127
+ shouldBeAlive: m,
128
+ currentRenderKey: f.renderKey,
129
+ currentCacheKey: y,
130
+ isInCache: i.has(y),
131
+ aliveCacheSize: i.size,
132
+ cacheContents: Array.from(i)
133
+ }), m && (i.has(y) ? f.alive || (f.alive = !0, (c.includes("students") || c.includes("classroom") || c.includes("quiz")) && console.log(`[ensureTab] ✅ Reactivated: ${y}`)) : (i.add(y), f.alive = !0, (c.includes("students") || c.includes("classroom") || c.includes("quiz")) && console.log(`[ensureTab] ✅ Added to cache: ${y}`))), Object.assign(f, qe(u)), f;
134
+ }
135
+ if (f = ne(u, {}, o.keepAlive), f.alive) {
136
+ const y = `${c}::${f.renderKey ?? 0}`;
137
+ i.add(y), (c.includes("students") || c.includes("classroom") || c.includes("quiz")) && console.log(`[ensureTab] NEW tab created and cached: ${y}`);
138
+ }
139
+ return Te(s, f, o.appendPosition, a.value), Re(s, o.maxAlive, a.value, i), f;
121
140
  }
122
- async function $(i, b = !1, d = !0) {
123
- const y = N(e, i), w = z(y), P = a.value === w;
124
- d === "sameTab" && (d = P), d && await U(w, !0), await e[b ? "replace" : "push"](y), P && await h();
141
+ async function M(u, c = !1, f = "sameTab") {
142
+ const m = V(e, u), y = _(m), k = a.value === y;
143
+ f === "sameTab" && (f = k), f && await z(y, !0), await e[c ? "replace" : "push"](m), k && await N();
125
144
  }
126
- function L(i) {
127
- const b = l.findIndex((x) => x.id === i);
128
- if (b === -1) return o.defaultRoute;
129
- const d = l[b + 1], y = l[b - 1], w = l.find((x) => x.id !== i), P = d || y || w;
130
- return P ? P.to : o.defaultRoute;
145
+ function Y(u) {
146
+ const c = s.findIndex((I) => I.id === u);
147
+ if (c === -1) return o.defaultRoute;
148
+ const f = s[c + 1], m = s[c - 1], y = s.find((I) => I.id !== u), k = f || m || y;
149
+ return k ? k.to : o.defaultRoute;
131
150
  }
132
- async function Y(i = a.value, b = {}) {
133
- if (!i) return;
134
- if (!b.force && o.keepLastTab && l.length === 1)
151
+ async function L(u = a.value, c = {}) {
152
+ if (!u) return;
153
+ if (!c.force && o.keepLastTab && s.length === 1)
135
154
  throw new Error("[RouterTabs] Unable to close the final tab when keepLastTab is true.");
136
- const y = a.value === i && b.redirect !== null, w = y ? b.redirect ?? L(i) : null;
137
- await K(i, { force: b.force }), b.redirect !== null && y && w && await e.replace(w);
155
+ const m = a.value === u && c.redirect !== null, y = m ? c.redirect ?? Y(u) : null;
156
+ await F(u, { force: c.force }), c.redirect !== null && m && y && await e.replace(y);
138
157
  }
139
- async function K(i, b = {}) {
140
- const d = l.findIndex((y) => y.id === i);
141
- d !== -1 && (l.splice(d, 1), T.value === i && (T.value = null), a.value === i && (a.value = null, g.value = void 0));
158
+ async function F(u, c = {}) {
159
+ const f = s.findIndex((m) => m.id === u);
160
+ f !== -1 && (s.splice(f, 1), T.value === u && (T.value = null), a.value === u && (a.value = null, p.value = void 0));
142
161
  }
143
- async function U(i = a.value ?? void 0, b = !1) {
144
- if (!i) return;
145
- const d = l.find((w) => w.id === i);
146
- if (!d) return;
147
- const y = o.keepAlive && d.alive;
148
- y && (d.alive = !1, await M()), d.renderKey = (d.renderKey ?? 0) + 1, y && (d.alive = !0), T.value = i, await M(), b || await M(), T.value = null;
162
+ async function z(u = a.value ?? void 0, c = !1) {
163
+ if (!u) return;
164
+ const f = s.find((I) => I.id === u);
165
+ if (!f) return;
166
+ const m = o.keepAlive && f.alive, y = `${u}::${f.renderKey ?? 0}`;
167
+ m && (i.delete(y), f.alive = !1, await B()), f.renderKey = (f.renderKey ?? 0) + 1;
168
+ const k = `${u}::${f.renderKey}`;
169
+ m && (i.add(k), f.alive = !0), T.value = u, await B(), c || await B(), T.value = null;
149
170
  }
150
- async function ne(i = !1) {
151
- for (const b of l)
152
- await U(b.id, i);
171
+ async function le(u = !1) {
172
+ for (const c of s)
173
+ await z(c.id, u);
174
+ }
175
+ function R(u, c) {
176
+ const f = s.find((y) => y.id === u);
177
+ if (!f) return;
178
+ const m = `${u}::${f.renderKey ?? 0}`;
179
+ c ? (i.add(m), f.alive = !0, Re(s, o.maxAlive, a.value, i)) : (i.delete(m), f.alive = !1);
180
+ }
181
+ function X(u) {
182
+ const c = s.find((m) => m.id === u);
183
+ if (!c) return;
184
+ const f = `${u}::${c.renderKey ?? 0}`;
185
+ i.delete(f), c.alive = !1, c.renderKey = (c.renderKey ?? 0) + 1;
186
+ }
187
+ function O() {
188
+ i.clear(), s.forEach((u) => {
189
+ u.alive = !1;
190
+ });
153
191
  }
154
- async function oe(i = o.defaultRoute) {
155
- l.splice(0, l.length), a.value = null, g.value = void 0;
156
- for (const b of o.initialTabs) {
157
- const d = N(e, b.to), y = Q(d, b, o.keepAlive);
158
- l.push(y);
192
+ function D() {
193
+ return b.value.slice();
194
+ }
195
+ async function Q(u = o.defaultRoute) {
196
+ s.splice(0, s.length), a.value = null, p.value = void 0;
197
+ for (const c of o.initialTabs) {
198
+ const f = V(e, c.to), m = ne(f, c, o.keepAlive);
199
+ s.push(m);
159
200
  }
160
- await e.replace(i);
201
+ await e.replace(u);
161
202
  }
162
- async function h() {
163
- const i = a.value;
164
- i && await U(i, !0);
203
+ async function N() {
204
+ const u = a.value;
205
+ u && await z(u, !0);
165
206
  }
166
- function G(i) {
167
- return typeof i.matched == "object" ? z(i) : z(N(e, i));
207
+ function w(u) {
208
+ return typeof u.matched == "object" ? _(u) : _(V(e, u));
168
209
  }
169
- function j() {
170
- const i = l.find((b) => b.id === a.value);
210
+ function se() {
211
+ const u = s.find((c) => c.id === a.value);
171
212
  return {
172
- tabs: l.map(Kt),
173
- active: i ? i.to : null
213
+ tabs: s.map(Vt),
214
+ active: u ? u.to : null
174
215
  };
175
216
  }
176
- async function D(i) {
177
- f = !0, l.splice(0, l.length), a.value = null, g.value = void 0;
178
- const b = i?.tabs ?? [];
179
- for (const y of b)
217
+ async function W(u) {
218
+ h = !0, s.splice(0, s.length), a.value = null, p.value = void 0;
219
+ const c = u?.tabs ?? [];
220
+ for (const m of c)
180
221
  try {
181
- const w = N(e, y.to), P = xt(y), x = Q(w, P, o.keepAlive);
182
- de(l, x, "last", null);
183
- } catch {
222
+ const y = V(e, m.to), k = _t(m), I = ne(y, k, o.keepAlive);
223
+ Te(s, I, "last", null);
224
+ } catch (y) {
225
+ console.warn("[RouterTabs] Failed to restore tab", m, y);
184
226
  }
185
- f = !1;
186
- const d = i?.active ?? b[b.length - 1]?.to ?? o.defaultRoute;
187
- if (d)
227
+ h = !1;
228
+ const f = u?.active ?? c[c.length - 1]?.to ?? o.defaultRoute;
229
+ if (f)
188
230
  try {
189
- await e.replace(d);
190
- } catch {
231
+ await e.replace(f);
232
+ } catch (m) {
233
+ console.warn("[RouterTabs] Failed to navigate to restored route", f, m);
191
234
  }
192
235
  }
193
236
  return A(
194
237
  () => e.currentRoute.value,
195
- (i) => {
196
- if (f) return;
197
- const b = C(i);
198
- a.value = b.id, g.value = b, Ke(l, o.maxAlive, a.value);
238
+ (u) => {
239
+ if (h) return;
240
+ const c = P(u);
241
+ a.value = c.id, p.value = c, Re(s, o.maxAlive, a.value, i);
199
242
  },
200
243
  { immediate: !0 }
201
- ), o.initialTabs.length && o.initialTabs.forEach((i) => {
202
- const b = N(e, i.to), d = Q(b, i, o.keepAlive);
203
- de(l, d, "last", null);
244
+ ), o.initialTabs.length && o.initialTabs.forEach((u) => {
245
+ const c = V(e, u.to), f = ne(c, u, o.keepAlive);
246
+ Te(s, f, "last", null);
204
247
  }), {
205
248
  options: o,
206
- tabs: l,
249
+ tabs: s,
207
250
  activeId: a,
208
- current: g,
209
- includeKeys: s,
251
+ current: p,
252
+ includeKeys: b,
210
253
  refreshingKey: T,
211
- openTab: $,
212
- closeTab: Y,
213
- removeTab: K,
214
- refreshTab: U,
215
- refreshAll: ne,
216
- reset: oe,
217
- reload: h,
218
- getRouteKey: G,
219
- matchRoute: v,
220
- snapshot: j,
221
- hydrate: D
254
+ openTab: M,
255
+ closeTab: L,
256
+ removeTab: F,
257
+ refreshTab: z,
258
+ refreshAll: le,
259
+ setTabAlive: R,
260
+ evictCache: X,
261
+ clearCache: O,
262
+ getCacheKeys: D,
263
+ reset: Q,
264
+ reload: N,
265
+ getRouteKey: w,
266
+ matchRoute: E,
267
+ snapshot: se,
268
+ hydrate: W,
269
+ ensureTab: P
222
270
  };
223
271
  }
224
- function xe(e) {
272
+ function Ne(e) {
225
273
  return e ? typeof e == "string" ? { name: e } : e : {};
226
274
  }
227
- const te = Symbol("RouterTabsContext"), ee = "router-tabs:snapshot";
228
- function De(e = {}) {
229
- const { optional: n = !1 } = e, o = Ee(te, null);
275
+ const ie = Symbol("RouterTabsContext"), re = "router-tabs:snapshot";
276
+ function Ue(e = {}) {
277
+ const { optional: r = !1 } = e, o = Me(ie, null);
230
278
  if (o) return o;
231
- const l = Ee("$tabs", null);
232
- if (l) return l;
233
- const g = je()?.appContext.config.globalProperties.$tabs;
234
- if (g) return g;
235
- if (!n)
279
+ const s = Me("$tabs", null);
280
+ if (s) return s;
281
+ const p = We()?.appContext.config.globalProperties.$tabs;
282
+ if (p) return p;
283
+ if (!r)
236
284
  throw new Error("[RouterTabs] useRouterTabs must be used within <router-tab>.");
237
285
  return null;
238
286
  }
239
- const St = 864e5;
240
- function Bt(e) {
287
+ const Ft = 864e5;
288
+ function Wt(e) {
241
289
  if (typeof document > "u") return null;
242
- const n = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
243
- for (const l of o)
244
- if (l.startsWith(n))
245
- return decodeURIComponent(l.slice(n.length));
290
+ const r = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
291
+ for (const s of o)
292
+ if (s.startsWith(r))
293
+ return decodeURIComponent(s.slice(r.length));
246
294
  return null;
247
295
  }
248
- function Se(e, n, o) {
296
+ function Ve(e, r, o) {
249
297
  if (typeof document > "u") return;
250
298
  const {
251
- expiresInDays: l = 7,
299
+ expiresInDays: s = 7,
252
300
  path: a = "/",
253
- domain: g,
301
+ domain: p,
254
302
  secure: T,
255
- sameSite: s = "lax"
256
- } = o, f = [`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];
257
- if (l !== 1 / 0) {
258
- const v = new Date(Date.now() + l * St).toUTCString();
259
- f.push(`Expires=${v}`);
303
+ sameSite: i = "lax"
304
+ } = o, b = [`${encodeURIComponent(e)}=${encodeURIComponent(r)}`];
305
+ if (s !== 1 / 0) {
306
+ const h = new Date(Date.now() + s * Ft).toUTCString();
307
+ b.push(`Expires=${h}`);
260
308
  }
261
- a && f.push(`Path=${a}`), g && f.push(`Domain=${g}`), T && f.push("Secure"), s && f.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = f.join("; ");
309
+ a && b.push(`Path=${a}`), p && b.push(`Domain=${p}`), T && b.push("Secure"), i && b.push(`SameSite=${i.charAt(0).toUpperCase()}${i.slice(1)}`), document.cookie = b.join("; ");
262
310
  }
263
- function Be(e, n) {
311
+ function _e(e, r) {
264
312
  if (typeof document > "u") return;
265
- const { path: o = "/", domain: l } = n, a = [`${encodeURIComponent(e)}=`];
266
- a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && a.push(`Path=${o}`), l && a.push(`Domain=${l}`), document.cookie = a.join("; ");
313
+ const { path: o = "/", domain: s } = r, a = [`${encodeURIComponent(e)}=`];
314
+ a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && a.push(`Path=${o}`), s && a.push(`Domain=${s}`), document.cookie = a.join("; ");
267
315
  }
268
- const Mt = (e) => JSON.stringify(e ?? null), Lt = (e) => {
316
+ const qt = (e) => JSON.stringify(e ?? null), Ht = (e) => {
269
317
  if (!e) return null;
270
318
  try {
271
319
  return JSON.parse(e);
@@ -273,65 +321,65 @@ const Mt = (e) => JSON.stringify(e ?? null), Lt = (e) => {
273
321
  return null;
274
322
  }
275
323
  };
276
- function Ve(e = {}) {
324
+ function He(e = {}) {
277
325
  const {
278
- cookieKey: n = ee,
279
- serialize: o = Mt,
280
- deserialize: l = Lt
281
- } = e, a = De({ optional: !0 }), g = B(!0), T = (s) => {
282
- ge(async () => {
283
- const f = l(Bt(n));
284
- if (f && f.tabs?.length)
326
+ cookieKey: r = re,
327
+ serialize: o = qt,
328
+ deserialize: s = Ht
329
+ } = e, a = Ue({ optional: !0 }), p = S(!0), T = (i) => {
330
+ ke(async () => {
331
+ const b = s(Wt(r));
332
+ if (b && b.tabs?.length)
285
333
  try {
286
- if (g.value = !0, await s.hydrate(f), f.active) {
287
- await M();
288
- const C = s.tabs.find(($) => $.to === f.active);
289
- C && (s.activeId.value = C.id, s.current.value = C);
334
+ if (p.value = !0, await i.hydrate(b), b.active) {
335
+ await B();
336
+ const E = i.tabs.find((P) => P.to === b.active);
337
+ E && (i.activeId.value = E.id, i.current.value = E);
290
338
  }
291
339
  } finally {
292
- g.value = !1;
340
+ p.value = !1;
293
341
  }
294
342
  else if (Object.prototype.hasOwnProperty.call(e, "fallbackRoute"))
295
343
  try {
296
- g.value = !0;
297
- const C = e.fallbackRoute ?? s.options.defaultRoute;
298
- await s.reset(C);
344
+ p.value = !0;
345
+ const E = e.fallbackRoute ?? i.options.defaultRoute;
346
+ await i.reset(E);
299
347
  } finally {
300
- g.value = !1;
348
+ p.value = !1;
301
349
  }
302
350
  else
303
- g.value = !1;
304
- const v = s.snapshot();
305
- v.tabs.length ? Se(n, o(v), e) : Be(n, e), g.value = !1;
351
+ p.value = !1;
352
+ const h = i.snapshot();
353
+ h.tabs.length ? Ve(r, o(h), e) : _e(r, e), p.value = !1;
306
354
  }), A(
307
355
  () => ({
308
- tabs: s.tabs.map((f) => ({
309
- to: f.to,
310
- title: f.title,
311
- tips: f.tips,
312
- icon: f.icon,
313
- tabClass: f.tabClass,
314
- closable: f.closable,
315
- renderKey: f.renderKey
356
+ tabs: i.tabs.map((b) => ({
357
+ to: b.to,
358
+ title: b.title,
359
+ tips: b.tips,
360
+ icon: b.icon,
361
+ tabClass: b.tabClass,
362
+ closable: b.closable,
363
+ renderKey: b.renderKey
316
364
  })),
317
- active: s.activeId.value
365
+ active: i.activeId.value
318
366
  }),
319
367
  () => {
320
- if (g.value) return;
321
- const f = s.snapshot();
322
- f.tabs.length ? Se(n, o(f), e) : Be(n, e);
368
+ if (p.value) return;
369
+ const b = i.snapshot();
370
+ b.tabs.length ? Ve(r, o(b), e) : _e(r, e);
323
371
  },
324
372
  { deep: !0 }
325
373
  );
326
374
  };
327
- a ? T(a) : ge(() => {
328
- const s = De({ optional: !0 });
329
- s && T(s);
375
+ a ? T(a) : ke(() => {
376
+ const i = Ue({ optional: !0 });
377
+ i && T(i);
330
378
  });
331
379
  }
332
- const jt = Oe({
380
+ const Jt = Ce({
333
381
  name: "RouterTab",
334
- components: { RouterView: Pt },
382
+ components: { RouterView: zt },
335
383
  props: {
336
384
  tabs: {
337
385
  type: Array,
@@ -371,7 +419,7 @@ const jt = Oe({
371
419
  },
372
420
  cookieKey: {
373
421
  type: String,
374
- default: ee
422
+ default: re
375
423
  },
376
424
  persistence: {
377
425
  type: Object,
@@ -383,14 +431,14 @@ const jt = Oe({
383
431
  }
384
432
  },
385
433
  emits: ["tab-sort", "tab-sorted"],
386
- setup(e, { emit: n }) {
387
- const o = je();
434
+ setup(e, { emit: r }) {
435
+ const o = We();
388
436
  if (!o)
389
437
  throw new Error("[RouterTab] component must be used within a Vue application context.");
390
- const l = o.appContext.app.config.globalProperties.$router;
391
- if (!l)
438
+ const s = o.appContext.app.config.globalProperties.$router;
439
+ if (!s)
392
440
  throw new Error("[RouterTab] Vue Router is required. Make sure to call app.use(router) before RouterTab.");
393
- const a = Dt(l, {
441
+ const a = Yt(s, {
394
442
  initialTabs: e.tabs,
395
443
  keepAlive: e.keepAlive,
396
444
  maxAlive: e.maxAlive,
@@ -398,148 +446,138 @@ const jt = Oe({
398
446
  appendPosition: e.append,
399
447
  defaultRoute: e.defaultPage
400
448
  });
401
- pt(te, a), o.appContext.config.globalProperties.$tabs = a;
402
- const g = k(() => !!o?.slots?.default), T = k(() => !!o?.slots?.start), s = k(() => !!o?.slots?.end), f = B(0), v = k(() => {
403
- f.value;
449
+ Kt(ie, a), o.appContext.config.globalProperties.$tabs = a;
450
+ const p = C(() => !!o?.slots?.default), T = C(() => !!o?.slots?.start), i = C(() => !!o?.slots?.end), b = S(0), h = C(() => {
451
+ b.value;
404
452
  const t = {};
405
- return a.tabs.forEach((r) => {
406
- const u = typeof r.title == "string" ? r.title : String(r.title || re(r));
407
- t[r.id] = u;
453
+ return a.tabs.forEach((n) => {
454
+ const l = typeof n.title == "string" ? n.title : String(n.title || ue(n));
455
+ t[n.id] = l;
408
456
  }), t;
409
457
  });
410
- function C() {
411
- f.value++;
458
+ function E() {
459
+ b.value++;
412
460
  }
413
- const $ = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
414
- function Y(t, r) {
415
- if (!(!r || $.has(t)))
461
+ const P = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map();
462
+ function Y(t, n) {
463
+ if (!(!n || P.has(t)))
416
464
  try {
417
- $.set(t, r);
418
- const u = a.tabs.find((p) => a.getRouteKey(p.to) === t);
419
- if (!u) {
465
+ P.set(t, n);
466
+ const l = a.tabs.find((g) => a.getRouteKey(g.to) === t);
467
+ if (!l) {
420
468
  console.warn(`[RouterTab] Cannot setup watching: tab not found for ${t}`);
421
469
  return;
422
470
  }
423
- const m = [];
424
- if (r.routeTabTitle !== void 0)
471
+ const v = [];
472
+ if (n.routeTabTitle !== void 0)
425
473
  try {
426
- const p = A(
474
+ const g = A(
427
475
  () => {
428
- const c = r.routeTabTitle;
429
- return c && typeof c == "object" && "value" in c ? c.value : c;
476
+ const d = n.routeTabTitle;
477
+ return d && typeof d == "object" && "value" in d ? d.value : d;
430
478
  },
431
- (c) => {
432
- if (c != null) {
433
- const V = String(c);
434
- u.title = V, C();
479
+ (d) => {
480
+ if (d != null) {
481
+ const U = String(d);
482
+ l.title = U, E();
435
483
  }
436
484
  },
437
485
  { immediate: !0 }
438
486
  );
439
- m.push(p);
440
- } catch (p) {
441
- console.error(`[RouterTab] Error watching routeTabTitle for ${t}:`, p);
487
+ v.push(g);
488
+ } catch (g) {
489
+ console.error(`[RouterTab] Error watching routeTabTitle for ${t}:`, g);
442
490
  }
443
- if (r.routeTabIcon !== void 0)
491
+ if (n.routeTabIcon !== void 0)
444
492
  try {
445
- const p = A(
493
+ const g = A(
446
494
  () => {
447
- const c = r.routeTabIcon;
448
- return c && typeof c == "object" && "value" in c ? c.value : c;
495
+ const d = n.routeTabIcon;
496
+ return d && typeof d == "object" && "value" in d ? d.value : d;
449
497
  },
450
- (c) => {
451
- c != null && (u.icon = String(c), C());
498
+ (d) => {
499
+ d != null && (l.icon = String(d), E());
452
500
  },
453
501
  { immediate: !0 }
454
502
  );
455
- m.push(p);
456
- } catch (p) {
457
- console.error(`[RouterTab] Error watching routeTabIcon for ${t}:`, p);
503
+ v.push(g);
504
+ } catch (g) {
505
+ console.error(`[RouterTab] Error watching routeTabIcon for ${t}:`, g);
458
506
  }
459
- if (r.routeTabClosable !== void 0)
507
+ if (n.routeTabClosable !== void 0)
460
508
  try {
461
- const p = A(
509
+ const g = A(
462
510
  () => {
463
- const c = r.routeTabClosable;
464
- return c && typeof c == "object" && "value" in c ? c.value : c;
511
+ const d = n.routeTabClosable;
512
+ return d && typeof d == "object" && "value" in d ? d.value : d;
465
513
  },
466
- (c) => {
467
- c != null && (u.closable = !!c, C());
514
+ (d) => {
515
+ d != null && (l.closable = !!d, E());
468
516
  },
469
517
  { immediate: !0 }
470
518
  );
471
- m.push(p);
472
- } catch (p) {
473
- console.error(`[RouterTab] Error watching routeTabClosable for ${t}:`, p);
519
+ v.push(g);
520
+ } catch (g) {
521
+ console.error(`[RouterTab] Error watching routeTabClosable for ${t}:`, g);
474
522
  }
475
- if (r.routeTabMeta !== void 0)
523
+ if (n.routeTabMeta !== void 0)
476
524
  try {
477
- const p = A(
525
+ const g = A(
478
526
  () => {
479
- const c = r.routeTabMeta;
480
- return c && typeof c == "object" && "value" in c ? c.value : c;
527
+ const d = n.routeTabMeta;
528
+ return d && typeof d == "object" && "value" in d ? d.value : d;
481
529
  },
482
- (c) => {
483
- c && typeof c == "object" && (Object.assign(u, c), C());
530
+ (d) => {
531
+ d && typeof d == "object" && (Object.assign(l, d), E());
484
532
  },
485
533
  { immediate: !0, deep: !0 }
486
534
  );
487
- m.push(p);
488
- } catch (p) {
489
- console.error(`[RouterTab] Error watching routeTabMeta for ${t}:`, p);
535
+ v.push(g);
536
+ } catch (g) {
537
+ console.error(`[RouterTab] Error watching routeTabMeta for ${t}:`, g);
490
538
  }
491
- L.set(t, m);
492
- } catch (u) {
493
- console.error(`[RouterTab] Error in setupComponentWatching for ${t}:`, u), K(t);
539
+ M.set(t, v);
540
+ } catch (l) {
541
+ console.error(`[RouterTab] Error in setupComponentWatching for ${t}:`, l), L(t);
494
542
  }
495
543
  }
496
- function K(t) {
544
+ function L(t) {
497
545
  try {
498
- const r = L.get(t);
499
- r && (r.forEach((u) => {
546
+ const n = M.get(t);
547
+ n && (n.forEach((l) => {
500
548
  try {
501
- u();
502
- } catch (m) {
503
- console.error(`[RouterTab] Error cleaning up watcher for ${t}:`, m);
549
+ l();
550
+ } catch (v) {
551
+ console.error(`[RouterTab] Error cleaning up watcher for ${t}:`, v);
504
552
  }
505
- }), L.delete(t)), $.delete(t);
506
- } catch (r) {
507
- console.error(`[RouterTab] Error in cleanupComponentWatching for ${t}:`, r);
553
+ }), M.delete(t)), P.delete(t);
554
+ } catch (n) {
555
+ console.error(`[RouterTab] Error in cleanupComponentWatching for ${t}:`, n);
508
556
  }
509
557
  }
510
- function U(t, r) {
558
+ function F(t, n) {
511
559
  try {
512
- t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? Y(r, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && Y(r, t.$) : t === null && K(r);
513
- } catch (u) {
514
- console.error(`[RouterTab] Error handling component ref for ${r}:`, u), K(r);
560
+ t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? Y(n, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && Y(n, t.$) : t === null && L(n);
561
+ } catch (l) {
562
+ console.error(`[RouterTab] Error handling component ref for ${n}:`, l), L(n);
515
563
  }
516
564
  }
517
- if (gt((t, r, u) => {
518
- if (console.error("[RouterTab] Error captured from component:", t, u), r && a.activeId.value) {
519
- const m = a.activeId.value;
520
- K(m);
521
- const p = a.tabs.find((c) => c.id === m);
522
- p && p.alive && (console.warn(`[RouterTab] Removing errored component ${m} from KeepAlive cache`), p.alive = !1, M(() => {
523
- p.alive = !0;
524
- }));
525
- }
526
- return !1;
527
- }), e.cookieKey !== null || e.persistence) {
565
+ if (Et((t, n, l) => (console.error("[RouterTab] Error captured from component:", t, l), !1)), e.cookieKey !== null || e.persistence) {
528
566
  const t = {
529
567
  ...e.persistence ?? {}
530
568
  };
531
- e.cookieKey !== null ? t.cookieKey = e.cookieKey || ee : t.cookieKey || (t.cookieKey = ee), Ve(t);
569
+ e.cookieKey !== null ? t.cookieKey = e.cookieKey || re : t.cookieKey || (t.cookieKey = re), He(t);
532
570
  }
533
- const ne = k(() => xe(e.tabTransition)), oe = k(() => xe(e.pageTransition)), h = pe({
571
+ const z = C(() => Ne(e.tabTransition)), le = C(() => Ne(e.pageTransition)), R = ae({
534
572
  visible: !1,
535
573
  target: null,
536
574
  position: { x: 0, y: 0 }
537
- }), G = B(null), j = B([]), D = B(-1), i = pe({
575
+ }), X = S(null), O = S([]), D = S(-1), Q = S(null), N = /* @__PURE__ */ new Map(), w = ae({
538
576
  dragging: !1,
539
577
  dragIndex: -1,
540
578
  dropIndex: -1,
541
579
  dragTab: null
542
- }), b = [
580
+ }), se = [
543
581
  "refresh",
544
582
  "refreshAll",
545
583
  "close",
@@ -547,29 +585,29 @@ const jt = Oe({
547
585
  "closeRights",
548
586
  "closeOthers"
549
587
  ];
550
- function d(t) {
551
- return a.tabs.findIndex((r) => r.id === t);
588
+ function W(t) {
589
+ return a.tabs.findIndex((n) => n.id === t);
552
590
  }
553
- function y(t) {
554
- const r = d(t.id);
555
- return r > 0 ? a.tabs.slice(0, r) : [];
591
+ function u(t) {
592
+ const n = W(t.id);
593
+ return n > 0 ? a.tabs.slice(0, n) : [];
556
594
  }
557
- function w(t) {
558
- const r = d(t.id);
559
- return r > -1 ? a.tabs.slice(r + 1) : [];
595
+ function c(t) {
596
+ const n = W(t.id);
597
+ return n > -1 ? a.tabs.slice(n + 1) : [];
560
598
  }
561
- function P(t) {
562
- return a.tabs.filter((r) => r.id !== t.id);
599
+ function f(t) {
600
+ return a.tabs.filter((n) => n.id !== t.id);
563
601
  }
564
- async function x(t, r) {
565
- const u = t.filter((m) => m.closable !== !1);
566
- if (u.length) {
567
- for (const m of u)
568
- a.activeId.value === m.id ? await a.closeTab(m.id, { redirect: r.to, force: !0 }) : await a.removeTab(m.id, { force: !0 });
569
- a.activeId.value !== r.id && await a.openTab(r.to, !0, !1);
602
+ async function m(t, n) {
603
+ const l = t.filter((v) => v.closable !== !1);
604
+ if (l.length) {
605
+ for (const v of l)
606
+ a.activeId.value === v.id ? await a.closeTab(v.id, { redirect: n.to, force: !0 }) : await a.removeTab(v.id, { force: !0 });
607
+ a.activeId.value !== n.id && await a.openTab(n.to, !0, !1);
570
608
  }
571
609
  }
572
- const Fe = {
610
+ const y = {
573
611
  refresh: {
574
612
  label: "Refresh",
575
613
  handler: async ({ target: t }) => {
@@ -587,95 +625,95 @@ const jt = Oe({
587
625
  handler: async ({ target: t }) => {
588
626
  await a.closeTab(t.id);
589
627
  },
590
- enable: ({ target: t }) => ae(t)
628
+ enable: ({ target: t }) => fe(t)
591
629
  },
592
630
  closeLefts: {
593
631
  label: "Close to the Left",
594
632
  handler: async ({ target: t }) => {
595
- await x(y(t), t);
633
+ await m(u(t), t);
596
634
  },
597
- enable: ({ target: t }) => y(t).some((r) => r.closable !== !1)
635
+ enable: ({ target: t }) => u(t).some((n) => n.closable !== !1)
598
636
  },
599
637
  closeRights: {
600
638
  label: "Close to the Right",
601
639
  handler: async ({ target: t }) => {
602
- await x(w(t), t);
640
+ await m(c(t), t);
603
641
  },
604
- enable: ({ target: t }) => w(t).some((r) => r.closable !== !1)
642
+ enable: ({ target: t }) => c(t).some((n) => n.closable !== !1)
605
643
  },
606
644
  closeOthers: {
607
645
  label: "Close Others",
608
646
  handler: async ({ target: t }) => {
609
- await x(P(t), t);
647
+ await m(f(t), t);
610
648
  },
611
- enable: ({ target: t }) => P(t).some((r) => r.closable !== !1)
649
+ enable: ({ target: t }) => f(t).some((n) => n.closable !== !1)
612
650
  }
613
651
  };
614
- function I() {
615
- h.visible = !1, h.target = null, D.value = -1, j.value = [];
652
+ function k() {
653
+ R.visible = !1, R.target = null, D.value = -1, O.value = [];
616
654
  }
617
- function He(t, r) {
618
- e.contextmenu && (h.target = t, h.position.x = r.clientX, h.position.y = r.clientY, M(() => {
619
- h.visible = !0, document.addEventListener("click", I, { once: !0 }), M(() => {
620
- Je();
655
+ function I(t, n) {
656
+ e.contextmenu && (R.target = t, R.position.x = n.clientX, R.position.y = n.clientY, B(() => {
657
+ R.visible = !0, document.addEventListener("click", k, { once: !0 }), B(() => {
658
+ et();
621
659
  });
622
660
  }));
623
661
  }
624
- function We(t, r) {
625
- const u = typeof t == "string" ? { id: t } : t, m = Fe[u.id], p = u.label ?? m?.label ?? String(u.id), c = u.visible ?? m?.visible ?? !0;
626
- if (!(typeof c == "function" ? c(r) : c !== !1)) return null;
627
- const ie = u.enable ?? m?.enable ?? !0, ft = typeof ie == "function" ? ie(r) : ie !== !1, Ce = u.handler ?? m?.handler;
628
- if (!Ce) return null;
629
- const dt = async () => {
630
- await Promise.resolve(Ce(r));
662
+ function Ze(t, n) {
663
+ const l = typeof t == "string" ? { id: t } : t, v = y[l.id], g = l.label ?? v?.label ?? String(l.id), d = l.visible ?? v?.visible ?? !0;
664
+ if (!(typeof d == "function" ? d(n) : d !== !1)) return null;
665
+ const ge = l.enable ?? v?.enable ?? !0, wt = typeof ge == "function" ? ge(n) : ge !== !1, Be = l.handler ?? v?.handler;
666
+ if (!Be) return null;
667
+ const kt = async () => {
668
+ await Promise.resolve(Be(n));
631
669
  };
632
670
  return {
633
- id: String(u.id),
634
- label: p,
635
- disabled: !ft,
636
- action: dt
671
+ id: String(l.id),
672
+ label: g,
673
+ disabled: !wt,
674
+ action: kt
637
675
  };
638
676
  }
639
- const _ = k(() => {
640
- if (!h.visible || !h.target || e.contextmenu === !1) return [];
641
- const t = Array.isArray(e.contextmenu) ? e.contextmenu : b, r = { target: h.target, controller: a };
642
- return t.map((u) => We(u, r)).filter((u) => !!u);
677
+ const q = C(() => {
678
+ if (!R.visible || !R.target || e.contextmenu === !1) return [];
679
+ const t = Array.isArray(e.contextmenu) ? e.contextmenu : se, n = { target: R.target, controller: a };
680
+ return t.map((l) => Ze(l, n)).filter((l) => !!l);
643
681
  });
644
- function Je() {
645
- const t = G.value;
682
+ function et() {
683
+ const t = X.value;
646
684
  if (!t) return;
647
- const r = 8, { innerWidth: u, innerHeight: m } = window, p = t.getBoundingClientRect();
648
- let c = h.position.x, V = h.position.y;
649
- p.right > u - r && (c = Math.max(r, u - p.width - r)), p.bottom > m - r && (V = Math.max(r, m - p.height - r)), (c !== h.position.x || V !== h.position.y) && (h.position.x = c, h.position.y = V);
685
+ const n = 8, { innerWidth: l, innerHeight: v } = window, g = t.getBoundingClientRect();
686
+ let d = R.position.x, U = R.position.y;
687
+ g.right > l - n && (d = Math.max(n, l - g.width - n)), g.bottom > v - n && (U = Math.max(n, v - g.height - n)), (d !== R.position.x || U !== R.position.y) && (R.position.x = d, R.position.y = U);
650
688
  }
651
- function Ge(t, r) {
652
- j.value[r] = t ?? null;
689
+ function tt(t, n) {
690
+ O.value[n] = t ?? null;
653
691
  }
654
- function Xe(t) {
692
+ function nt(t) {
655
693
  if (t < 0) return;
656
- j.value[t]?.focus({ preventScroll: !0 });
694
+ O.value[t]?.focus({ preventScroll: !0 });
657
695
  }
658
- function X(t, r, u = _.value) {
659
- if (!u.length) return -1;
660
- const m = u.length;
661
- let p = t;
662
- for (let c = 0; c < m; c++)
663
- if (p = (p + r + m) % m, !u[p].disabled) return p;
696
+ function Z(t, n, l = q.value) {
697
+ if (!l.length) return -1;
698
+ const v = l.length;
699
+ let g = t;
700
+ for (let d = 0; d < v; d++)
701
+ if (g = (g + n + v) % v, !l[g].disabled) return g;
664
702
  return -1;
665
703
  }
666
- function F(t) {
667
- D.value = t, !(t < 0) && M(() => Xe(t));
704
+ function H(t) {
705
+ D.value = t, !(t < 0) && B(() => nt(t));
668
706
  }
669
- function Te(t) {
670
- const r = X(D.value, t);
671
- r !== -1 && F(r);
707
+ function Pe(t) {
708
+ const n = Z(D.value, t);
709
+ n !== -1 && H(n);
672
710
  }
673
- function qe(t) {
674
- if (!h.visible) return;
675
- const r = t.key, u = _.value;
676
- if (!u.length) return;
677
- if (r === "Tab") {
678
- I();
711
+ function ot(t) {
712
+ if (!R.visible) return;
713
+ const n = t.key, l = q.value;
714
+ if (!l.length) return;
715
+ if (n === "Tab") {
716
+ k();
679
717
  return;
680
718
  }
681
719
  if ([
@@ -689,128 +727,174 @@ const jt = Oe({
689
727
  " ",
690
728
  "Spacebar",
691
729
  "Escape"
692
- ].includes(r))
693
- switch (t.preventDefault(), r) {
730
+ ].includes(n))
731
+ switch (t.preventDefault(), n) {
694
732
  case "ArrowDown":
695
733
  case "ArrowRight":
696
- Te(1);
734
+ Pe(1);
697
735
  break;
698
736
  case "ArrowUp":
699
737
  case "ArrowLeft":
700
- Te(-1);
738
+ Pe(-1);
701
739
  break;
702
740
  case "Home":
703
- F(X(-1, 1));
741
+ H(Z(-1, 1));
704
742
  break;
705
743
  case "End":
706
- F(X(u.length, -1));
744
+ H(Z(l.length, -1));
707
745
  break;
708
746
  case "Enter":
709
747
  case " ":
710
748
  case "Spacebar": {
711
- const p = D.value;
712
- if (p > -1) {
713
- const c = u[p];
714
- c.disabled || ke(c);
749
+ const g = D.value;
750
+ if (g > -1) {
751
+ const d = l[g];
752
+ d.disabled || Se(d);
715
753
  }
716
754
  break;
717
755
  }
718
756
  case "Escape":
719
- I();
757
+ k();
720
758
  break;
721
759
  }
722
760
  }
723
- async function ke(t) {
724
- t.disabled || (I(), await t.action());
761
+ async function Se(t) {
762
+ t.disabled || (k(), await t.action());
725
763
  }
726
- function re(t) {
764
+ function ue(t) {
727
765
  return typeof t.title == "string" && t.title.trim() ? t.title : Array.isArray(t.title) && t.title.length && String(t.title[0]).trim() ? String(t.title[0]) : "Untitled";
728
766
  }
729
- function Qe(t) {
730
- return v.value[t.id] || re(t);
767
+ function rt(t) {
768
+ return h.value[t.id] || ue(t);
769
+ }
770
+ function at(t, n) {
771
+ return Ce({
772
+ name: n,
773
+ setup(l, { attrs: v, slots: g }) {
774
+ return () => At(t, v, g);
775
+ }
776
+ });
777
+ }
778
+ const ce = /* @__PURE__ */ new Map(), Ie = S(0);
779
+ function it(t, n, l) {
780
+ ce.has(l) || (ce.set(l, n), Ie.value++), t && F(t, l);
731
781
  }
732
- function we(t) {
733
- const r = a.getRouteKey(t), u = a.tabs.find((p) => p.id === r);
734
- if (!u)
735
- return console.warn("[RouterTab] Tab not found for route:", r), `${r}::0`;
736
- const m = u.renderKey ?? 0;
737
- return `${r}::${m}`;
782
+ function lt(t, n) {
783
+ return t && ((!t.name || t.name !== n) && (t.name = n), t);
738
784
  }
739
- function Ze(t) {
740
- return `${we(t)}::refresh`;
785
+ function st(t) {
786
+ const n = a.getRouteKey(t), l = s.currentRoute.value, v = a.getRouteKey(l);
787
+ return n === v;
741
788
  }
742
- function ae(t) {
789
+ function xe(t) {
790
+ const n = a.getRouteKey(t), l = a.tabs.find((d) => d.id === n);
791
+ if (!l)
792
+ return console.warn("[RouterTab] Tab not found for route:", n), `${n}::0`;
793
+ const v = l.renderKey ?? 0, g = `${n}::${v}`;
794
+ return (n.includes("students") || n.includes("classroom") || n.includes("quiz")) && console.log(`[getComponentCacheKey] Route: ${t.fullPath}`, {
795
+ routeKey: n,
796
+ renderKey: v,
797
+ cacheKey: g,
798
+ tabAlive: l.alive,
799
+ includeKeys: be.value,
800
+ isIncluded: be.value.includes(g)
801
+ }), g;
802
+ }
803
+ function ut(t) {
804
+ return `${xe(t)}::refresh`;
805
+ }
806
+ function fe(t) {
743
807
  return !(t.closable === !1 || a.options.keepLastTab && a.tabs.length <= 1);
744
808
  }
745
- async function et(t) {
809
+ async function ct(t) {
746
810
  await a.closeTab(t.id);
747
811
  }
748
- function tt(t) {
812
+ function ft(t, n) {
813
+ n ? N.set(t, n) : N.delete(t);
814
+ }
815
+ function de(t) {
816
+ B(() => {
817
+ const n = N.get(t), l = Q.value;
818
+ if (n && l) {
819
+ const v = n.getBoundingClientRect(), g = l.getBoundingClientRect();
820
+ (v.left < g.left || v.right > g.right) && n.scrollIntoView({
821
+ behavior: "smooth",
822
+ block: "nearest",
823
+ inline: "nearest"
824
+ });
825
+ }
826
+ });
827
+ }
828
+ function dt(t) {
749
829
  if (t.href && typeof window < "u") {
750
830
  t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
751
831
  return;
752
832
  }
753
- a.activeId.value !== t.id && a.openTab(t.to, !1);
833
+ a.activeId.value !== t.id && (a.openTab(t.to, !1), de(t.id));
754
834
  }
755
- function nt(t) {
835
+ function bt(t) {
756
836
  return [
757
837
  "router-tab__item",
758
838
  {
759
839
  "is-active": a.activeId.value === t.id,
760
- "is-closable": ae(t),
761
- "is-dragging": i.dragging && i.dragTab?.id === t.id,
762
- "is-drag-over": i.dropIndex === d(t.id)
840
+ "is-closable": fe(t),
841
+ "is-dragging": w.dragging && w.dragTab?.id === t.id,
842
+ "is-drag-over": w.dropIndex === W(t.id)
763
843
  },
764
844
  t.tabClass
765
845
  ];
766
846
  }
767
- function ot(t) {
847
+ function gt(t) {
768
848
  return a.refreshingKey.value === a.getRouteKey(t);
769
849
  }
770
- function rt(t) {
771
- const r = a.getRouteKey(t);
772
- return a.tabs.some((u) => u.id === r);
850
+ function pt(t) {
851
+ const n = a.getRouteKey(t), l = a.tabs.find((v) => v.id === n);
852
+ return l ? l.alive : !1;
853
+ }
854
+ function vt(t) {
855
+ const n = a.getRouteKey(t);
856
+ return !!a.tabs.find((v) => v.id === n);
773
857
  }
774
- function at(t, r, u) {
775
- e.sortable && (i.dragging = !0, i.dragIndex = r, i.dragTab = t, u.dataTransfer && (u.dataTransfer.effectAllowed = "move", u.dataTransfer.setData("text/plain", t.id)), n("tab-sort", { tab: t, index: r }));
858
+ function ht(t, n, l) {
859
+ e.sortable && (w.dragging = !0, w.dragIndex = n, w.dragTab = t, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", t.id)), r("tab-sort", { tab: t, index: n }));
776
860
  }
777
- function it(t, r) {
778
- !e.sortable || !i.dragging || (r.preventDefault(), r.dataTransfer && (r.dataTransfer.dropEffect = "move"));
861
+ function mt(t, n) {
862
+ !e.sortable || !w.dragging || (n.preventDefault(), n.dataTransfer && (n.dataTransfer.dropEffect = "move"));
779
863
  }
780
- function lt(t) {
781
- !e.sortable || !i.dragging || (i.dropIndex = t);
864
+ function yt(t) {
865
+ !e.sortable || !w.dragging || (w.dropIndex = t);
782
866
  }
783
- function st() {
784
- !e.sortable || i.dragging;
867
+ function Tt() {
868
+ !e.sortable || w.dragging;
785
869
  }
786
- function ut(t, r) {
787
- if (!(!e.sortable || !i.dragging)) {
788
- if (r.preventDefault(), i.dragIndex !== -1 && i.dragIndex !== t) {
789
- const u = a.tabs.splice(i.dragIndex, 1)[0];
790
- a.tabs.splice(t, 0, u), n("tab-sorted", {
791
- tab: u,
792
- fromIndex: i.dragIndex,
870
+ function Rt(t, n) {
871
+ if (!(!e.sortable || !w.dragging)) {
872
+ if (n.preventDefault(), w.dragIndex !== -1 && w.dragIndex !== t) {
873
+ const l = a.tabs.splice(w.dragIndex, 1)[0];
874
+ a.tabs.splice(t, 0, l), r("tab-sorted", {
875
+ tab: l,
876
+ fromIndex: w.dragIndex,
793
877
  toIndex: t
794
878
  });
795
879
  }
796
- Re();
880
+ De();
797
881
  }
798
882
  }
799
- function Re() {
800
- i.dragging = !1, i.dragIndex = -1, i.dropIndex = -1, i.dragTab = null;
883
+ function De() {
884
+ w.dragging = !1, w.dragIndex = -1, w.dropIndex = -1, w.dragTab = null;
801
885
  }
802
- ge(() => {
803
- document.addEventListener("keydown", I);
804
- }), mt(() => {
805
- document.removeEventListener("keydown", I), o.appContext.config.globalProperties.$tabs = null, L.forEach((t) => {
806
- t.forEach((r) => {
886
+ ke(() => {
887
+ document.addEventListener("keydown", k);
888
+ }), $t(() => {
889
+ document.removeEventListener("keydown", k), o.appContext.config.globalProperties.$tabs = null, M.forEach((t) => {
890
+ t.forEach((n) => {
807
891
  try {
808
- r();
809
- } catch (u) {
810
- console.error("[RouterTab] Error during cleanup:", u);
892
+ n();
893
+ } catch (l) {
894
+ console.error("[RouterTab] Error during cleanup:", l);
811
895
  }
812
896
  });
813
- }), L.clear(), $.clear();
897
+ }), M.clear(), P.clear();
814
898
  }), A(
815
899
  () => e.keepAlive,
816
900
  (t) => {
@@ -818,204 +902,218 @@ const jt = Oe({
818
902
  }
819
903
  ), A(
820
904
  () => a.activeId.value,
821
- () => I()
905
+ (t) => {
906
+ t && de(t), k();
907
+ }
822
908
  ), A(
823
909
  () => a.tabs.length,
824
910
  () => {
825
- const t = new Set(a.tabs.map((u) => u.id));
826
- Array.from($.keys()).forEach((u) => {
827
- t.has(u) || (console.log(`[RouterTab] Cleaning up stale component instance: ${u}`), K(u));
911
+ const t = new Set(a.tabs.map((l) => l.id));
912
+ Array.from(P.keys()).forEach((l) => {
913
+ t.has(l) || (console.log(`[RouterTab] Cleaning up stale component instance: ${l}`), L(l));
828
914
  });
829
915
  }
830
916
  ), A(
831
917
  () => e.contextmenu,
832
918
  (t) => {
833
- t || I();
919
+ t || k();
834
920
  }
835
921
  ), A(
836
- () => _.value.length,
922
+ () => q.value.length,
837
923
  (t) => {
838
- h.visible && t === 0 && I();
924
+ R.visible && t === 0 && k();
839
925
  },
840
926
  { flush: "post" }
841
927
  // Run after component updates to prevent blocking render
842
- ), A(_, (t) => {
843
- if (!h.visible) return;
844
- j.value = new Array(t.length).fill(null);
845
- const r = X(-1, 1, t);
846
- F(r);
928
+ ), A(q, (t) => {
929
+ if (!R.visible) return;
930
+ O.value = new Array(t.length).fill(null);
931
+ const n = Z(-1, 1, t);
932
+ H(n);
847
933
  }, { flush: "post" }), A(
848
- () => h.visible,
934
+ () => R.visible,
849
935
  (t) => {
850
- t || (D.value = -1, j.value = []);
936
+ t || (D.value = -1, O.value = []);
851
937
  }
852
938
  );
853
- const ct = a.includeKeys;
939
+ const be = a.includeKeys;
854
940
  return {
855
941
  controller: a,
856
942
  tabs: a.tabs,
857
- includeKeys: ct,
858
- tabTransitionProps: ne,
859
- pageTransitionProps: oe,
860
- buildTabClass: nt,
861
- activate: tt,
862
- close: et,
863
- context: h,
864
- menuItems: _,
865
- handleMenuAction: ke,
866
- showContextMenu: He,
867
- hideContextMenu: I,
868
- getTabTitle: re,
869
- isClosable: ae,
870
- isRefreshing: ot,
871
- isTabReady: rt,
872
- hasCustomSlot: g,
943
+ includeKeys: be,
944
+ componentCache: ce,
945
+ componentCacheTrigger: Ie,
946
+ cacheCurrentComponent: it,
947
+ tabTransitionProps: z,
948
+ pageTransitionProps: le,
949
+ buildTabClass: bt,
950
+ activate: dt,
951
+ close: ct,
952
+ context: R,
953
+ menuItems: q,
954
+ handleMenuAction: Se,
955
+ showContextMenu: I,
956
+ hideContextMenu: k,
957
+ getTabTitle: ue,
958
+ isClosable: fe,
959
+ isRefreshing: gt,
960
+ isTabCached: pt,
961
+ isTabReady: vt,
962
+ hasCustomSlot: p,
873
963
  hasStartSlot: T,
874
- hasEndSlot: s,
875
- onDragStart: at,
876
- onDragOver: it,
877
- onDragEnter: lt,
878
- onDragLeave: st,
879
- onDrop: ut,
880
- onDragEnd: Re,
964
+ hasEndSlot: i,
965
+ onDragStart: ht,
966
+ onDragOver: mt,
967
+ onDragEnter: yt,
968
+ onDragLeave: Tt,
969
+ onDrop: Rt,
970
+ onDragEnd: De,
881
971
  setupComponentWatching: Y,
882
- cleanupComponentWatching: K,
883
- handleComponentRef: U,
884
- getReactiveTabTitle: Qe,
885
- getComponentCacheKey: we,
886
- getRefreshComponentKey: Ze,
887
- triggerTabUpdate: C,
888
- menuRef: G,
972
+ cleanupComponentWatching: L,
973
+ handleComponentRef: F,
974
+ getReactiveTabTitle: rt,
975
+ getComponentCacheKey: xe,
976
+ getRefreshComponentKey: ut,
977
+ createNamedComponent: at,
978
+ ensureNamedComponent: lt,
979
+ shouldRenderRoute: st,
980
+ triggerTabUpdate: E,
981
+ menuRef: X,
889
982
  highlightedIndex: D,
890
- setMenuItemRef: Ge,
891
- onMenuKeydown: qe,
892
- highlightMenuIndex: F
983
+ setMenuItemRef: tt,
984
+ onMenuKeydown: ot,
985
+ highlightMenuIndex: H,
986
+ scrollContainer: Q,
987
+ setTabRef: ft,
988
+ scrollTabIntoView: de
893
989
  };
894
990
  }
895
- }), Ot = (e, n) => {
991
+ }), Gt = (e, r) => {
896
992
  const o = e.__vccOpts || e;
897
- for (const [l, a] of n)
898
- o[l] = a;
993
+ for (const [s, a] of r)
994
+ o[s] = a;
899
995
  return o;
900
- }, Ut = { class: "router-tab" }, Vt = { class: "router-tab__header" }, Nt = { class: "router-tab__scroll" }, zt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], Yt = ["title"], _t = ["onClick"], Ft = { class: "router-tab__container" }, Ht = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
901
- function Wt(e, n, o, l, a, g) {
902
- const T = vt("RouterView");
903
- return E(), S("div", Ut, [
904
- O("header", Vt, [
905
- O("div", {
906
- class: H(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
996
+ }, Xt = { class: "router-tab" }, Qt = { class: "router-tab__header" }, Zt = {
997
+ class: "router-tab__scroll",
998
+ ref: "scrollContainer"
999
+ }, en = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], tn = ["title"], nn = ["onClick"], on = { class: "router-tab__container" }, rn = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
1000
+ function an(e, r, o, s, a, p) {
1001
+ const T = Pt("RouterView");
1002
+ return $(), x("div", Xt, [
1003
+ j("header", Qt, [
1004
+ j("div", {
1005
+ class: J(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
907
1006
  }, [
908
- le(e.$slots, "start")
1007
+ pe(e.$slots, "start")
909
1008
  ], 2),
910
- O("div", Nt, [
911
- Ae(yt, se({
1009
+ j("div", Zt, [
1010
+ Le(It, ve({
912
1011
  tag: "ul",
913
1012
  class: "router-tab__nav"
914
1013
  }, e.tabTransitionProps), {
915
- default: ue(() => [
916
- (E(!0), S(Pe, null, Ie(e.tabs, (s, f) => (E(), S("li", {
917
- key: s.id,
918
- class: H(e.buildTabClass(s)),
919
- "data-title": e.getTabTitle(s),
1014
+ default: he(() => [
1015
+ ($(!0), x(me, null, Oe(e.tabs, (i, b) => ($(), x("li", {
1016
+ key: i.id,
1017
+ class: J(e.buildTabClass(i)),
1018
+ "data-title": e.getTabTitle(i),
920
1019
  draggable: e.sortable,
921
- onClick: (v) => e.activate(s),
922
- onAuxclick: ce((v) => e.close(s), ["middle", "prevent"]),
923
- onContextmenu: ce((v) => e.showContextMenu(s, v), ["prevent"]),
924
- onDragstart: (v) => e.onDragStart(s, f, v),
925
- onDragover: (v) => e.onDragOver(f, v),
926
- onDragenter: (v) => e.onDragEnter(f),
927
- onDragleave: n[0] || (n[0] = (...v) => e.onDragLeave && e.onDragLeave(...v)),
928
- onDrop: (v) => e.onDrop(f, v),
929
- onDragend: n[1] || (n[1] = (...v) => e.onDragEnd && e.onDragEnd(...v))
1020
+ ref_for: !0,
1021
+ ref: (h) => e.setTabRef(i.id, h),
1022
+ onClick: (h) => e.activate(i),
1023
+ onAuxclick: ye((h) => e.close(i), ["middle", "prevent"]),
1024
+ onContextmenu: ye((h) => e.showContextMenu(i, h), ["prevent"]),
1025
+ onDragstart: (h) => e.onDragStart(i, b, h),
1026
+ onDragover: (h) => e.onDragOver(b, h),
1027
+ onDragenter: (h) => e.onDragEnter(b),
1028
+ onDragleave: r[0] || (r[0] = (...h) => e.onDragLeave && e.onDragLeave(...h)),
1029
+ onDrop: (h) => e.onDrop(b, h),
1030
+ onDragend: r[1] || (r[1] = (...h) => e.onDragEnd && e.onDragEnd(...h))
930
1031
  }, [
931
- s.icon ? (E(), S("i", {
1032
+ i.icon ? ($(), x("i", {
932
1033
  key: 0,
933
- class: H(["router-tab__item-icon", s.icon])
934
- }, null, 2)) : q("", !0),
935
- O("span", {
1034
+ class: J(["router-tab__item-icon", i.icon])
1035
+ }, null, 2)) : ee("", !0),
1036
+ j("span", {
936
1037
  class: "router-tab__item-title",
937
- title: e.getReactiveTabTitle(s)
938
- }, $e(e.getReactiveTabTitle(s)), 9, Yt),
939
- e.isClosable(s) ? (E(), S("a", {
1038
+ title: e.getReactiveTabTitle(i)
1039
+ }, je(e.getReactiveTabTitle(i)), 9, tn),
1040
+ e.isClosable(i) ? ($(), x("a", {
940
1041
  key: 1,
941
1042
  class: "router-tab__item-close",
942
- onClick: ce((v) => e.close(s), ["stop"])
943
- }, null, 8, _t)) : q("", !0)
944
- ], 42, zt))), 128))
1043
+ onClick: ye((h) => e.close(i), ["stop"])
1044
+ }, null, 8, nn)) : ee("", !0)
1045
+ ], 42, en))), 128))
945
1046
  ]),
946
1047
  _: 1
947
1048
  }, 16)
948
- ]),
949
- O("div", {
950
- class: H(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
1049
+ ], 512),
1050
+ j("div", {
1051
+ class: J(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
951
1052
  }, [
952
- le(e.$slots, "end")
1053
+ pe(e.$slots, "end")
953
1054
  ], 2)
954
1055
  ]),
955
- O("div", Ft, [
956
- Ae(T, null, {
957
- default: ue((s) => [
958
- e.hasCustomSlot ? le(e.$slots, "default", Tt(se({ key: 0 }, {
959
- ...s,
1056
+ j("div", on, [
1057
+ Le(T, null, {
1058
+ default: he(({ Component: i, route: b }) => [
1059
+ e.hasCustomSlot ? pe(e.$slots, "default", xt(ve({ key: 0 }, {
1060
+ Component: i,
1061
+ route: b,
960
1062
  controller: e.controller,
961
- // Expose a ref binder so custom slots can keep reactivity
962
- pageRef: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route))
963
- }))) : (E(), W(kt, se({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
964
- default: ue(() => [
965
- e.isRefreshing(s.route) ? (E(), W(fe(s.Component), {
966
- key: e.getRefreshComponentKey(s.route),
967
- ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
1063
+ pageRef: (h) => e.handleComponentRef(h, e.controller.getRouteKey(b))
1064
+ }))) : ($(), x(me, { key: 1 }, [
1065
+ e.controller.options.keepAlive ? ($(), te(Dt, {
1066
+ key: 0,
1067
+ include: e.includeKeys
1068
+ }, [
1069
+ i ? ($(), te(ze(e.ensureNamedComponent(i, e.controller.getRouteKey(b))), {
1070
+ key: e.controller.getRouteKey(b),
1071
+ ref: (h) => e.handleComponentRef(h, e.controller.getRouteKey(b)),
968
1072
  class: "router-tab-page"
969
- })) : e.controller.options.keepAlive ? (E(), W(wt, {
970
- key: 1,
971
- include: e.includeKeys,
972
- max: e.controller.options.maxAlive || void 0
973
- }, [
974
- e.isTabReady(s.route) ? (E(), W(fe(s.Component), {
975
- key: e.getComponentCacheKey(s.route),
976
- ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
1073
+ })) : ee("", !0)
1074
+ ], 1032, ["include"])) : ($(), te(Bt, ve({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
1075
+ default: he(() => [
1076
+ i ? ($(), te(ze(i), {
1077
+ key: e.controller.getRouteKey(b),
1078
+ ref: (h) => e.handleComponentRef(h, e.controller.getRouteKey(b)),
977
1079
  class: "router-tab-page"
978
- })) : q("", !0)
979
- ], 1032, ["include", "max"])) : e.isTabReady(s.route) ? (E(), W(fe(s.Component), {
980
- key: e.getComponentCacheKey(s.route),
981
- ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
982
- class: "router-tab-page"
983
- })) : q("", !0)
984
- ]),
985
- _: 2
986
- }, 1040))
1080
+ })) : ee("", !0)
1081
+ ]),
1082
+ _: 2
1083
+ }, 1040))
1084
+ ], 64))
987
1085
  ]),
988
1086
  _: 3
989
1087
  })
990
1088
  ]),
991
- ht(O("div", {
1089
+ St(j("div", {
992
1090
  ref: "menuRef",
993
1091
  class: "router-tab__contextmenu",
994
1092
  role: "menu",
995
- onKeydown: n[2] || (n[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
996
- style: Rt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
1093
+ onKeydown: r[2] || (r[2] = (...i) => e.onMenuKeydown && e.onMenuKeydown(...i)),
1094
+ style: Mt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
997
1095
  }, [
998
- (E(!0), S(Pe, null, Ie(e.menuItems, (s, f) => (E(), S("a", {
999
- key: s.id,
1096
+ ($(!0), x(me, null, Oe(e.menuItems, (i, b) => ($(), x("a", {
1097
+ key: i.id,
1000
1098
  role: "menuitem",
1001
- class: H(["router-tab__contextmenu-item", { "is-focused": f === e.highlightedIndex }]),
1002
- "aria-disabled": s.disabled,
1003
- disabled: s.disabled,
1004
- tabindex: s.disabled ? -1 : f === e.highlightedIndex ? 0 : -1,
1099
+ class: J(["router-tab__contextmenu-item", { "is-focused": b === e.highlightedIndex }]),
1100
+ "aria-disabled": i.disabled,
1101
+ disabled: i.disabled,
1102
+ tabindex: i.disabled ? -1 : b === e.highlightedIndex ? 0 : -1,
1005
1103
  ref_for: !0,
1006
- ref: (v) => e.setMenuItemRef(v, f),
1007
- onMouseenter: (v) => !s.disabled && e.highlightMenuIndex(f),
1008
- onClick: (v) => e.handleMenuAction(s)
1009
- }, $e(s.label), 43, Ht))), 128))
1104
+ ref: (h) => e.setMenuItemRef(h, b),
1105
+ onMouseenter: (h) => !i.disabled && e.highlightMenuIndex(b),
1106
+ onClick: (h) => e.handleMenuAction(i)
1107
+ }, je(i.label), 43, rn))), 128))
1010
1108
  ], 36), [
1011
- [Ct, e.context.visible && e.context.target]
1109
+ [Lt, e.context.visible && e.context.target]
1012
1110
  ])
1013
1111
  ]);
1014
1112
  }
1015
- const Me = /* @__PURE__ */ Ot(jt, [["render", Wt]]), Jt = {
1113
+ const Ye = /* @__PURE__ */ Gt(Jt, [["render", an]]), ln = {
1016
1114
  class: "router-tabs",
1017
1115
  "aria-hidden": "true"
1018
- }, be = /* @__PURE__ */ Oe({
1116
+ }, we = /* @__PURE__ */ Ce({
1019
1117
  name: "RouterTabs",
1020
1118
  __name: "RouterTabs",
1021
1119
  props: {
@@ -1030,11 +1128,11 @@ const Me = /* @__PURE__ */ Ot(jt, [["render", Wt]]), Jt = {
1030
1128
  fallbackRoute: {}
1031
1129
  },
1032
1130
  setup(e) {
1033
- return Ve(e), (o, l) => (E(), S("span", Jt));
1131
+ return He(e), (o, s) => ($(), x("span", ln));
1034
1132
  }
1035
- }), Ne = "tab-theme-style", ze = "tab-theme-primary-color", Gt = "system", Ye = "(prefers-color-scheme: dark)";
1036
- let J = null;
1037
- const R = {
1133
+ }), Je = "tab-theme-style", Ge = "tab-theme-primary-color", sn = "system", Xe = "(prefers-color-scheme: dark)";
1134
+ let G = null;
1135
+ const K = {
1038
1136
  primary: "#034960",
1039
1137
  background: "#ffffff",
1040
1138
  text: "#1e293b",
@@ -1048,7 +1146,7 @@ const R = {
1048
1146
  activeButtonBackground: "#034960",
1049
1147
  activeButtonColor: "#ffffff",
1050
1148
  iconColor: "#475569"
1051
- }, Xt = {
1149
+ }, un = {
1052
1150
  primary: "#38bdf8",
1053
1151
  background: "#0f172a",
1054
1152
  text: "#f1f5f9",
@@ -1064,60 +1162,60 @@ const R = {
1064
1162
  activeButtonColor: "#0f172a",
1065
1163
  iconColor: "#cbd5e1"
1066
1164
  };
1067
- function qt(e) {
1165
+ function cn(e) {
1068
1166
  if (typeof window > "u") return null;
1069
- const n = window.localStorage.getItem(e);
1070
- if (!n) return null;
1167
+ const r = window.localStorage.getItem(e);
1168
+ if (!r) return null;
1071
1169
  try {
1072
- const o = JSON.parse(n);
1170
+ const o = JSON.parse(r);
1073
1171
  return o && typeof o == "object" ? o : null;
1074
1172
  } catch {
1075
1173
  return null;
1076
1174
  }
1077
1175
  }
1078
- function he(e) {
1079
- typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? R.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? R.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? R.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? R.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? R.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? R.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? R.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? R.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? R.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? R.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? R.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? R.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? R.iconColor));
1176
+ function $e(e) {
1177
+ typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? K.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? K.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? K.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? K.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? K.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? K.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? K.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? K.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? K.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? K.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? K.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? K.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? K.iconColor));
1080
1178
  }
1081
- function _e(e) {
1179
+ function Qe(e) {
1082
1180
  if (typeof document > "u") return;
1083
- const n = document.documentElement, o = window.matchMedia(Ye), l = () => {
1084
- n.dataset.theme = o.matches ? "dark" : "light";
1181
+ const r = document.documentElement, o = window.matchMedia(Xe), s = () => {
1182
+ r.dataset.theme = o.matches ? "dark" : "light";
1085
1183
  };
1086
- J && (o.removeEventListener("change", J), J = null), e === "system" ? (l(), J = () => l(), o.addEventListener("change", J)) : n.dataset.theme = e;
1184
+ G && (o.removeEventListener("change", G), G = null), e === "system" ? (s(), G = () => s(), o.addEventListener("change", G)) : r.dataset.theme = e;
1087
1185
  }
1088
- function Qt(e = {}) {
1186
+ function fn(e = {}) {
1089
1187
  if (typeof window > "u") return;
1090
1188
  const {
1091
- styleKey: n = Ne,
1092
- primaryKey: o = ze,
1093
- defaultStyle: l = Gt,
1189
+ styleKey: r = Je,
1190
+ primaryKey: o = Ge,
1191
+ defaultStyle: s = sn,
1094
1192
  defaultPrimary: a
1095
- } = e, g = window.localStorage.getItem(n) ?? l;
1096
- _e(g);
1097
- const s = g === "dark" || g === "system" && window.matchMedia(Ye).matches ? { ...Xt } : { ...R };
1098
- a && (s.primary = a);
1099
- const f = qt(o);
1100
- he(f ? {
1101
- ...s,
1102
- ...f
1103
- } : s);
1193
+ } = e, p = window.localStorage.getItem(r) ?? s;
1194
+ Qe(p);
1195
+ const i = p === "dark" || p === "system" && window.matchMedia(Xe).matches ? { ...un } : { ...K };
1196
+ a && (i.primary = a);
1197
+ const b = cn(o);
1198
+ $e(b ? {
1199
+ ...i,
1200
+ ...b
1201
+ } : i);
1104
1202
  }
1105
- function tn(e, n) {
1203
+ function gn(e, r) {
1106
1204
  if (typeof window > "u") return;
1107
- const o = n?.styleKey ?? Ne;
1108
- window.localStorage.setItem(o, e), _e(e);
1205
+ const o = r?.styleKey ?? Je;
1206
+ window.localStorage.setItem(o, e), Qe(e);
1109
1207
  }
1110
- function nn(e, n) {
1208
+ function pn(e, r) {
1111
1209
  if (typeof window > "u") return;
1112
- const o = n?.primaryKey ?? ze;
1113
- window.localStorage.setItem(o, JSON.stringify(e)), he(e);
1210
+ const o = r?.primaryKey ?? Ge;
1211
+ window.localStorage.setItem(o, JSON.stringify(e)), $e(e);
1114
1212
  }
1115
- function Z(e, n) {
1116
- if (Et(e)) {
1117
- const l = !At(e);
1213
+ function oe(e, r) {
1214
+ if (Ot(e)) {
1215
+ const s = !jt(e);
1118
1216
  return {
1119
1217
  value: e,
1120
- update: l ? (a) => {
1218
+ update: s ? (a) => {
1121
1219
  e.value = a;
1122
1220
  } : () => {
1123
1221
  }
@@ -1125,94 +1223,94 @@ function Z(e, n) {
1125
1223
  }
1126
1224
  if (typeof e == "function")
1127
1225
  return {
1128
- value: k(e),
1226
+ value: C(e),
1129
1227
  update: () => {
1130
1228
  }
1131
1229
  };
1132
- const o = B(
1133
- e === void 0 ? n : e
1230
+ const o = S(
1231
+ e === void 0 ? r : e
1134
1232
  );
1135
1233
  return {
1136
1234
  value: o,
1137
- update: (l) => {
1138
- o.value = l;
1235
+ update: (s) => {
1236
+ o.value = s;
1139
1237
  }
1140
1238
  };
1141
1239
  }
1142
- function ye(e = {}) {
1143
- const n = Z(e.title, "Untitled"), o = Z(e.icon, ""), l = Z(e.closable, !0), a = Z(e.meta, {});
1240
+ function Ae(e = {}) {
1241
+ const r = oe(e.title, "Untitled"), o = oe(e.icon, ""), s = oe(e.closable, !0), a = oe(e.meta, {});
1144
1242
  return {
1145
- routeTabTitle: n.value,
1243
+ routeTabTitle: r.value,
1146
1244
  routeTabIcon: o.value,
1147
- routeTabClosable: l.value,
1245
+ routeTabClosable: s.value,
1148
1246
  routeTabMeta: a.value,
1149
- updateTitle: n.update,
1247
+ updateTitle: r.update,
1150
1248
  updateIcon: o.update,
1151
- updateClosable: l.update,
1249
+ updateClosable: s.update,
1152
1250
  updateMeta: a.update
1153
1251
  };
1154
1252
  }
1155
- function on(e, n = "Page") {
1156
- return ye({
1157
- title: k(() => e.value ? "Loading..." : n),
1158
- icon: k(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
1159
- closable: k(() => !e.value)
1253
+ function vn(e, r = "Page") {
1254
+ return Ae({
1255
+ title: C(() => e.value ? "Loading..." : r),
1256
+ icon: C(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
1257
+ closable: C(() => !e.value)
1160
1258
  });
1161
1259
  }
1162
- function rn(e, n = "Page", o = "mdi-page") {
1163
- return ye({
1164
- title: k(() => e.value > 0 ? `${n} (${e.value})` : n),
1165
- icon: k(() => e.value > 0 ? "mdi-bell-badge" : o)
1260
+ function hn(e, r = "Page", o = "mdi-page") {
1261
+ return Ae({
1262
+ title: C(() => e.value > 0 ? `${r} (${e.value})` : r),
1263
+ icon: C(() => e.value > 0 ? "mdi-bell-badge" : o)
1166
1264
  });
1167
1265
  }
1168
- function an(e, n = "Page") {
1266
+ function mn(e, r = "Page") {
1169
1267
  const o = {
1170
1268
  normal: { suffix: "", icon: "mdi-page" },
1171
1269
  loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
1172
1270
  error: { suffix: " - Error", icon: "mdi-alert" },
1173
1271
  success: { suffix: " - Success", icon: "mdi-check-circle" }
1174
1272
  };
1175
- return ye({
1176
- title: k(() => n + o[e.value].suffix),
1177
- icon: k(() => o[e.value].icon),
1178
- closable: k(() => e.value !== "loading")
1273
+ return Ae({
1274
+ title: C(() => r + o[e.value].suffix),
1275
+ icon: C(() => o[e.value].icon),
1276
+ closable: C(() => e.value !== "loading")
1179
1277
  });
1180
1278
  }
1181
- let Le = !1;
1182
- const ln = {
1183
- install(e, n) {
1184
- if (Le) return;
1185
- Le = !0;
1279
+ let Fe = !1;
1280
+ const yn = {
1281
+ install(e, r) {
1282
+ if (Fe) return;
1283
+ Fe = !0;
1186
1284
  const {
1187
1285
  initTheme: o = !0,
1188
- themeOptions: l,
1189
- componentName: a = Me.name || "RouterTab",
1190
- tabsComponentName: g = be.name || "RouterTabs"
1191
- } = n ?? {};
1192
- o && Qt(l ?? {}), e.component(a, Me), e.component(g, be), g.toLowerCase() !== "router-tabs" && e.component("router-tabs", be), Object.defineProperty(e.config.globalProperties, "$tabs", {
1286
+ themeOptions: s,
1287
+ componentName: a = Ye.name || "RouterTab",
1288
+ tabsComponentName: p = we.name || "RouterTabs"
1289
+ } = r ?? {};
1290
+ o && fn(s ?? {}), e.component(a, Ye), e.component(p, we), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", we), Object.defineProperty(e.config.globalProperties, "$tabs", {
1193
1291
  configurable: !0,
1194
1292
  enumerable: !1,
1195
1293
  get() {
1196
- return e._context.provides[te];
1294
+ return e._context.provides[ie];
1197
1295
  },
1198
1296
  set(T) {
1199
- T && e.provide(te, T);
1297
+ T && e.provide(ie, T);
1200
1298
  }
1201
1299
  });
1202
1300
  }
1203
1301
  };
1204
1302
  export {
1205
- Me as RouterTab,
1206
- be as RouterTabs,
1207
- ln as default,
1208
- Qt as initRouterTabsTheme,
1209
- te as routerTabsKey,
1210
- nn as setRouterTabsPrimary,
1211
- tn as setRouterTabsTheme,
1212
- on as useLoadingTab,
1213
- rn as useNotificationTab,
1214
- ye as useReactiveTab,
1215
- De as useRouterTabs,
1216
- Ve as useRouterTabsPersistence,
1217
- an as useStatusTab
1303
+ Ye as RouterTab,
1304
+ we as RouterTabs,
1305
+ yn as default,
1306
+ fn as initRouterTabsTheme,
1307
+ ie as routerTabsKey,
1308
+ pn as setRouterTabsPrimary,
1309
+ gn as setRouterTabsTheme,
1310
+ vn as useLoadingTab,
1311
+ hn as useNotificationTab,
1312
+ Ae as useReactiveTab,
1313
+ Ue as useRouterTabs,
1314
+ He as useRouterTabsPersistence,
1315
+ mn as useStatusTab
1218
1316
  };