vue3-router-tab 1.3.6 → 1.3.8

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