@gospore/theme 1.0.139 → 1.0.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/theme.es.js CHANGED
@@ -1,82 +1,82 @@
1
- import { inject as he, computed as j, ref as N, watch as A, onBeforeUnmount as pe, provide as J, createElementBlock as be, openBlock as Z, normalizeStyle as ge, renderSlot as ke, createElementVNode as ee, createBlock as Me, unref as g, withCtx as X, createVNode as U } from "vue";
1
+ import { inject as Ut, computed as ot, ref as G, watch as H, onBeforeUnmount as $t, provide as mt, createElementBlock as Pt, openBlock as _t, normalizeStyle as Ht, renderSlot as Ft, createElementVNode as Ct, createBlock as Vt, unref as w, withCtx as bt, createVNode as K } from "vue";
2
2
  import "what-input";
3
- import { DropdownMenu as ve, DropdownItemGroup as ye, DropdownItemRadio as K } from "@gospore/dropdown-menu";
4
- const B = ["auto", "light", "dark"], te = "gospore-theme-mode", Ee = 3600 * 24 * 365, Se = "(prefers-color-scheme: dark)";
5
- function V() {
3
+ import { DropdownMenu as Gt, DropdownItemGroup as jt, DropdownItemRadio as Z } from "@gospore/dropdown-menu";
4
+ const Q = ["auto", "light", "dark"], vt = "gospore-theme-mode", Kt = 3600 * 24 * 365, Yt = "(prefers-color-scheme: dark)";
5
+ function nt() {
6
6
  if (typeof document > "u")
7
7
  return null;
8
- const n = Oe(te);
9
- return n && B.includes(n) ? n : null;
8
+ const a = Xt(vt);
9
+ return a && Q.includes(a) ? a : null;
10
10
  }
11
- function we(n) {
12
- if (typeof document > "u" || !B.includes(n))
11
+ function Qt(a) {
12
+ if (typeof document > "u" || !Q.includes(a))
13
13
  return;
14
- const a = typeof window < "u" ? window.location.hostname : "", s = typeof window < "u" ? window.location.protocol : "", c = _e(a), p = s === "https:", k = [
14
+ const l = typeof window < "u" ? window.location.hostname : "", m = typeof window < "u" ? window.location.protocol : "", u = qt(l), D = m === "https:", I = [
15
15
  "path=/",
16
- `max-age=${Ee}`,
16
+ `max-age=${Kt}`,
17
17
  "SameSite=Lax"
18
18
  ];
19
- c && k.push(`domain=${c}`), p && k.push("Secure"), document.cookie = [
20
- `${encodeURIComponent(te)}=${encodeURIComponent(n)}`,
21
- ...k
19
+ u && I.push(`domain=${u}`), D && I.push("Secure"), document.cookie = [
20
+ `${encodeURIComponent(vt)}=${encodeURIComponent(a)}`,
21
+ ...I
22
22
  ].join("; ");
23
23
  }
24
- function ne(n) {
24
+ function Rt(a) {
25
25
  if (typeof document > "u")
26
26
  return;
27
- const a = typeof n == "string" && B.includes(n) ? n : V() ?? "auto";
28
- console.log("Applying theme mode:", a);
29
- const s = Re(a);
30
- document.documentElement.setAttribute("dark-mode", s);
27
+ const l = typeof a == "string" && Q.includes(a) ? a : nt() ?? "auto";
28
+ console.log("Applying theme mode:", l);
29
+ const m = zt(l);
30
+ document.documentElement.setAttribute("dark-mode", m);
31
31
  }
32
- function Oe(n) {
32
+ function Xt(a) {
33
33
  if (typeof document > "u" || !document.cookie)
34
34
  return null;
35
- const a = `${encodeURIComponent(n)}=`, s = document.cookie.split("; ");
36
- for (const c of s)
37
- if (c.startsWith(a))
38
- return decodeURIComponent(c.slice(a.length));
35
+ const l = `${encodeURIComponent(a)}=`, m = document.cookie.split("; ");
36
+ for (const u of m)
37
+ if (u.startsWith(l))
38
+ return decodeURIComponent(u.slice(l.length));
39
39
  return null;
40
40
  }
41
- function _e(n) {
42
- if (!n || n === "localhost")
41
+ function qt(a) {
42
+ if (!a || a === "localhost")
43
43
  return null;
44
- if (/^\d+(?:\.\d+){3}$/.test(n))
45
- return n;
46
- const s = n.split(".");
47
- return s.length <= 1 ? null : s.length === 2 ? n : s.slice(-2).join(".");
44
+ if (/^\d+(?:\.\d+){3}$/.test(a))
45
+ return a;
46
+ const m = a.split(".");
47
+ return m.length <= 1 ? null : m.length === 2 ? a : m.slice(-2).join(".");
48
48
  }
49
- function Re(n) {
50
- if (n === "dark")
49
+ function zt(a) {
50
+ if (a === "dark")
51
51
  return !0;
52
- if (n === "light" || typeof window > "u")
52
+ if (a === "light" || typeof window > "u")
53
53
  return !1;
54
54
  try {
55
- const a = typeof window.matchMedia == "function" ? window.matchMedia(Se) : null;
56
- return a ? a.matches : !1;
55
+ const l = typeof window.matchMedia == "function" ? window.matchMedia(Yt) : null;
56
+ return l ? l.matches : !1;
57
57
  } catch {
58
58
  return !1;
59
59
  }
60
60
  }
61
- const oe = /* @__PURE__ */ Symbol.for("gospore.theme.portalHost");
62
- function Ne() {
63
- const n = he(oe, null);
64
- console.log("Using theme portal host:", n);
65
- const a = typeof document < "u" ? document.body : "body";
66
- return j(() => n?.value ?? a);
61
+ const Tt = /* @__PURE__ */ Symbol.for("gospore.theme.portalHost");
62
+ function ae() {
63
+ const a = Ut(Tt, null);
64
+ console.log("Using theme portal host:", a);
65
+ const l = typeof document < "u" ? document.body : "body";
66
+ return ot(() => a?.value ?? l);
67
67
  }
68
- const Te = "(prefers-color-scheme: dark)", De = "(prefers-reduced-motion: reduce)", Ce = 200, Ue = /* @__PURE__ */ Object.assign({
68
+ const Wt = "(prefers-color-scheme: dark)", Jt = "(prefers-reduced-motion: reduce)", Zt = 200, B = 3.8, pt = 1.8, St = 1.15, kt = 1.08, Y = 2.5, Mt = 3, tt = "#ffffff", et = "#1f2228", ce = /* @__PURE__ */ Object.assign({
69
69
  name: "Theme"
70
70
  }, {
71
71
  __name: "Theme",
72
72
  props: {
73
73
  mode: {
74
74
  type: String,
75
- validator: (n) => ["auto", "light", "dark"].includes(n)
75
+ validator: (a) => ["auto", "light", "dark"].includes(a)
76
76
  },
77
77
  /**
78
78
  * Optional hex accent color ("#RRGGBB" or "#RGB"). When provided,
79
- * Theme derives the `--color-brand-*` palette and exposes the tokens on
79
+ * Theme derives contrast-safe semantic brand tokens and exposes them on
80
80
  * the root .theme element (and the global document for portals).
81
81
  */
82
82
  accentColor: {
@@ -93,287 +93,460 @@ const Te = "(prefers-color-scheme: dark)", De = "(prefers-reduced-motion: reduce
93
93
  default: !1
94
94
  }
95
95
  },
96
- setup(n) {
97
- const a = n, s = [], c = /* @__PURE__ */ new Set();
98
- function p() {
99
- const e = document.documentElement;
100
- if (!e)
96
+ setup(a) {
97
+ const l = a, m = [], u = /* @__PURE__ */ new Set();
98
+ function D() {
99
+ const t = document.documentElement;
100
+ if (!t)
101
101
  return;
102
- c.forEach((r) => {
103
- e.style.removeProperty(r);
104
- }), c.clear();
105
- const t = [...s].reverse().find(
106
- (r) => r.enabled && r.vars && Object.keys(r.vars).length > 0
102
+ u.forEach((o) => {
103
+ t.style.removeProperty(o);
104
+ }), u.clear();
105
+ const e = [...m].reverse().find(
106
+ (o) => o.enabled && o.vars && Object.keys(o.vars).length > 0
107
107
  );
108
- t && Object.entries(t.vars).forEach(([r, o]) => {
109
- e.style.setProperty(r, o), c.add(r);
108
+ e && Object.entries(e.vars).forEach(([o, r]) => {
109
+ t.style.setProperty(o, r), u.add(o);
110
110
  });
111
111
  }
112
- const k = window.matchMedia(Te), P = window.matchMedia(
113
- De
114
- ), T = q();
115
- ne(T);
116
- const I = N(T), l = N({
117
- darkMode: M(T)
118
- }), f = N(null);
119
- k.addEventListener("change", Y), A(
120
- () => a.mode,
112
+ const I = window.matchMedia(Wt), X = window.matchMedia(
113
+ Jt
114
+ ), L = ct();
115
+ Rt(L);
116
+ const F = G(L), S = G({
117
+ darkMode: y(L)
118
+ }), _ = G(null);
119
+ I.addEventListener("change", rt), H(
120
+ () => l.mode,
121
121
  () => {
122
- d();
122
+ M();
123
123
  },
124
124
  { immediate: !0 }
125
- ), A(
126
- () => l.value.darkMode,
127
- (e, t) => {
128
- if (t === void 0) {
129
- Q(e);
125
+ ), H(
126
+ () => S.value.darkMode,
127
+ (t, e) => {
128
+ if (e === void 0) {
129
+ at(t);
130
130
  return;
131
131
  }
132
- re(() => {
133
- Q(e);
132
+ Et(() => {
133
+ at(t);
134
134
  });
135
135
  },
136
136
  { immediate: !0 }
137
- ), pe(() => {
138
- k.removeEventListener("change", Y);
139
- const e = s.indexOf($);
140
- e !== -1 && s.splice(e, 1), p();
137
+ ), $t(() => {
138
+ I.removeEventListener("change", rt);
139
+ const t = m.indexOf(V);
140
+ t !== -1 && m.splice(t, 1), D();
141
141
  });
142
- function d() {
143
- const e = q();
144
- I.value = e, l.value.darkMode = M(e);
142
+ function M() {
143
+ const t = ct();
144
+ F.value = t, S.value.darkMode = y(t);
145
145
  }
146
- function M(e) {
147
- return e === "dark" ? !0 : e === "light" ? !1 : k.matches;
146
+ function y(t) {
147
+ return t === "dark" ? !0 : t === "light" ? !1 : I.matches;
148
148
  }
149
- function Y(e) {
150
- !e || I.value !== "auto" || (l.value.darkMode = e.matches);
149
+ function rt(t) {
150
+ !t || F.value !== "auto" || (S.value.darkMode = t.matches);
151
151
  }
152
- function Q(e) {
153
- document.documentElement.setAttribute("dark-mode", e);
152
+ function at(t) {
153
+ document.documentElement.setAttribute("dark-mode", t);
154
154
  }
155
- function re(e) {
156
- if (P.matches) {
157
- e();
155
+ function Et(t) {
156
+ if (X.matches) {
157
+ t();
158
158
  return;
159
159
  }
160
- const t = document.startViewTransition?.bind(document);
161
- if (t) {
162
- t(() => {
163
- e();
160
+ const e = document.startViewTransition?.bind(document);
161
+ if (e) {
162
+ e(() => {
163
+ t();
164
164
  });
165
165
  return;
166
166
  }
167
- e();
168
- const r = document.documentElement;
169
- typeof r.animate == "function" && window.requestAnimationFrame(() => {
170
- r.animate([{ opacity: 0.85 }, { opacity: 1 }], {
171
- duration: Ce,
167
+ t();
168
+ const o = document.documentElement;
169
+ typeof o.animate == "function" && window.requestAnimationFrame(() => {
170
+ o.animate([{ opacity: 0.85 }, { opacity: 1 }], {
171
+ duration: Zt,
172
172
  easing: "ease-in-out"
173
173
  });
174
174
  });
175
175
  }
176
- function q() {
177
- return a.mode ?? V() ?? "auto";
176
+ function ct() {
177
+ return l.mode ?? nt() ?? "auto";
178
178
  }
179
- J("theme", l), J(oe, f);
180
- function z(e) {
181
- if (!e) return null;
182
- const t = e.trim().toLowerCase();
183
- if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t)) return null;
184
- if (t.length === 4) {
185
- const o = t[1], i = t[2], m = t[3];
186
- return `#${o}${o}${i}${i}${m}${m}`;
179
+ mt("theme", S), mt(Tt, _);
180
+ function st(t) {
181
+ if (!t) return null;
182
+ const e = t.trim().toLowerCase();
183
+ if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)) return null;
184
+ if (e.length === 4) {
185
+ const r = e[1], n = e[2], c = e[3];
186
+ return `#${r}${r}${n}${n}${c}${c}`;
187
187
  }
188
- return t;
188
+ return e;
189
189
  }
190
- function ae(e) {
191
- const t = z(e);
192
- if (!t) return null;
193
- const r = parseInt(t.slice(1, 3), 16), o = parseInt(t.slice(3, 5), 16), i = parseInt(t.slice(5, 7), 16);
194
- return { r, g: o, b: i };
190
+ function lt(t) {
191
+ const e = st(t);
192
+ if (!e) return null;
193
+ const o = parseInt(e.slice(1, 3), 16), r = parseInt(e.slice(3, 5), 16), n = parseInt(e.slice(5, 7), 16);
194
+ return { r: o, g: r, b: n };
195
195
  }
196
- function ce({ r: e, g: t, b: r }) {
197
- const o = (i) => i.toString(16).padStart(2, "0");
198
- return `#${o(e)}${o(t)}${o(r)}`;
196
+ function q({ r: t, g: e, b: o }) {
197
+ const r = (n) => n.toString(16).padStart(2, "0");
198
+ return `#${r(t)}${r(e)}${r(o)}`;
199
199
  }
200
- function h(e) {
201
- return Math.max(0, Math.min(1, e));
200
+ function C(t) {
201
+ return Math.max(0, Math.min(1, t));
202
202
  }
203
- function H(e) {
204
- return e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
203
+ function U(t) {
204
+ return t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
205
205
  }
206
- function G(e) {
207
- const t = h(e);
208
- return t <= 31308e-7 ? 12.92 * t : 1.055 * Math.pow(t, 1 / 2.4) - 0.055;
206
+ function z(t) {
207
+ const e = C(t);
208
+ return e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055;
209
209
  }
210
- function se({ r: e, g: t, b: r }) {
211
- const o = e / 255, i = t / 255, m = r / 255, E = H(o), R = H(i), u = H(m), v = 0.4122214708 * E + 0.5363325363 * R + 0.0514459929 * u, y = 0.2119034982 * E + 0.6806995451 * R + 0.1073969566 * u, S = 0.0883024619 * E + 0.2817188376 * R + 0.6299787005 * u, b = Math.cbrt(v), w = Math.cbrt(y), D = Math.cbrt(S), L = 0.2104542553 * b + 0.793617785 * w - 0.0040720468 * D, O = 1.9779984951 * b - 2.428592205 * w + 0.4505937099 * D, _ = 0.0259040371 * b + 0.7827717662 * w - 0.808675766 * D, C = Math.sqrt(O * O + _ * _);
212
- let x = Math.atan2(_, O) * (180 / Math.PI);
213
- return x < 0 && (x += 360), { l: L, c: C, h: x };
210
+ function At({ r: t, g: e, b: o }) {
211
+ const r = t / 255, n = e / 255, c = o / 255, i = U(r), f = U(n), v = U(c), d = 0.4122214708 * i + 0.5363325363 * f + 0.0514459929 * v, h = 0.2119034982 * i + 0.6806995451 * f + 0.1073969566 * v, b = 0.0883024619 * i + 0.2817188376 * f + 0.6299787005 * v, p = Math.cbrt(d), R = Math.cbrt(h), E = Math.cbrt(b), A = 0.2104542553 * p + 0.793617785 * R - 0.0040720468 * E, g = 1.9779984951 * p - 2.428592205 * R + 0.4505937099 * E, k = 0.0259040371 * p + 0.7827717662 * R - 0.808675766 * E, T = Math.sqrt(g * g + k * k);
212
+ let x = Math.atan2(k, g) * (180 / Math.PI);
213
+ return x < 0 && (x += 360), { l: A, c: T, h: x };
214
214
  }
215
- function F(e, t, r, o = !1) {
216
- const i = r * Math.PI / 180, m = t * Math.cos(i), E = t * Math.sin(i), R = e + 0.3963377774 * m + 0.2158037573 * E, u = e - 0.1055613458 * m - 0.0638541728 * E, v = e - 0.0894841775 * m - 1.291485548 * E, y = o ? h(R) : R, S = o ? h(u) : u, b = o ? h(v) : v;
217
- if (!o && (y < -1e-4 || y > 1.0001 || S < -1e-4 || S > 1.0001 || b < -1e-4 || b > 1.0001))
215
+ function it(t, e, o, r = !1) {
216
+ const n = o * Math.PI / 180, c = e * Math.cos(n), i = e * Math.sin(n), f = t + 0.3963377774 * c + 0.2158037573 * i, v = t - 0.1055613458 * c - 0.0638541728 * i, d = t - 0.0894841775 * c - 1.291485548 * i, h = r ? C(f) : f, b = r ? C(v) : v, p = r ? C(d) : d;
217
+ if (!r && (h < -1e-4 || h > 1.0001 || b < -1e-4 || b > 1.0001 || p < -1e-4 || p > 1.0001))
218
218
  return null;
219
- const w = y * y * y, D = S * S * S, L = b * b * b;
220
- let O = 4.0767416621 * w - 3.3077115913 * D + 0.2309699292 * L, _ = -1.2684380046 * w + 2.6097574011 * D - 0.3413193965 * L, C = -0.0041960863 * w - 0.7034186147 * D + 1.707614701 * L;
221
- if (o)
222
- O = h(O), _ = h(_), C = h(C);
223
- else if (O < -1e-4 || O > 1.0001 || _ < -1e-4 || _ > 1.0001 || C < -1e-4 || C > 1.0001)
219
+ const R = h * h * h, E = b * b * b, A = p * p * p;
220
+ let g = 4.0767416621 * R - 3.3077115913 * E + 0.2309699292 * A, k = -1.2684380046 * R + 2.6097574011 * E - 0.3413193965 * A, T = -0.0041960863 * R - 0.7034186147 * E + 1.707614701 * A;
221
+ if (r)
222
+ g = C(g), k = C(k), T = C(T);
223
+ else if (g < -1e-4 || g > 1.0001 || k < -1e-4 || k > 1.0001 || T < -1e-4 || T > 1.0001)
224
224
  return null;
225
- const x = h(G(O)), de = h(G(_)), me = h(G(C));
225
+ const x = C(z(g)), J = C(z(k)), O = C(z(T));
226
226
  return {
227
227
  r: Math.round(x * 255),
228
- g: Math.round(de * 255),
229
- b: Math.round(me * 255)
228
+ g: Math.round(J * 255),
229
+ b: Math.round(O * 255)
230
230
  };
231
231
  }
232
- function le(e, t, r) {
233
- let o = t;
234
- for (let i = 0; i < 8; i += 1) {
235
- const m = F(e, o, r);
236
- if (m)
237
- return m;
238
- o *= 0.9;
232
+ function W(t, e, o) {
233
+ let r = e;
234
+ for (let n = 0; n < 8; n += 1) {
235
+ const c = it(t, r, o);
236
+ if (c)
237
+ return c;
238
+ r *= 0.9;
239
239
  }
240
- return F(e, h(o), r, !0) || { r: 0, g: 0, b: 0 };
240
+ return it(t, C(r), o, !0) || { r: 0, g: 0, b: 0 };
241
241
  }
242
- function ie(e) {
243
- const t = z(e);
244
- if (!t) return null;
245
- const r = ae(t);
246
- if (!r) return null;
247
- const o = se(r), i = {
248
- 100: { lightness: 0.35, chroma: 0.45 },
249
- 200: { lightness: 0.28, chroma: 0.5 },
250
- 300: { lightness: 0.22, chroma: 0.6 },
251
- 400: { lightness: 0.16, chroma: 0.75 },
252
- 500: { lightness: 0.08, chroma: 0.9 },
253
- 600: { lightness: 0, chroma: 1, base: !0 },
254
- 700: { lightness: -0.08, chroma: 1.05 },
255
- 800: { lightness: -0.18, chroma: 1.1 },
256
- 900: { lightness: -0.28, chroma: 1.15 },
257
- 1e3: { lightness: -0.35, chroma: 1.2 }
258
- }, m = {}, E = (u) => u === 0 ? o.l : u > 0 ? h(o.l + u * (1 - o.l)) : h(o.l * (1 + u)), R = (u) => {
259
- if (u === 1)
260
- return o.c;
261
- const v = o.c * u;
262
- return Math.max(0, Math.min(0.4, v));
263
- };
264
- return Object.entries(i).forEach(([u, v]) => {
265
- const y = `--color-brand-${u}`;
266
- if (v.base) {
267
- m[y] = t;
268
- return;
242
+ function dt(t) {
243
+ const e = lt(t);
244
+ if (!e)
245
+ return 0;
246
+ const o = U(e.r / 255), r = U(e.g / 255), n = U(e.b / 255);
247
+ return 0.2126 * o + 0.7152 * r + 0.0722 * n;
248
+ }
249
+ function N(t, e) {
250
+ const o = dt(t), r = dt(e), n = Math.max(o, r), c = Math.min(o, r);
251
+ return (n + 0.05) / (c + 0.05);
252
+ }
253
+ function Dt(t, e, o = {}) {
254
+ const r = o.minContrast ?? B, n = o.preferDark !== !1, c = Math.max(
255
+ 0.01,
256
+ Math.min(0.06, (t.c || 0.12) * (o.chromaScale ?? 0.25))
257
+ ), i = o.initialLightness ?? (n ? 0.24 : 0.94), f = n ? -1 : 1, v = o.step ?? 0.03;
258
+ let d = C(i), h = q(W(d, c, t.h)), b = N(e, h);
259
+ for (let g = 0; g < 48; g += 1) {
260
+ const k = q(
261
+ W(d, c, t.h)
262
+ ), T = N(e, k);
263
+ if (T > b && (b = T, h = k), T >= r)
264
+ return k;
265
+ if (d = C(d + f * v), d === 0 || d === 1)
266
+ break;
267
+ }
268
+ const p = "#101214", R = "#ffffff", E = N(e, p), A = N(e, R);
269
+ return E >= r || A >= r ? E >= A ? p : R : h;
270
+ }
271
+ function $(t, e, o = {}) {
272
+ const r = o.minContrast ?? B, n = o.darkCandidate ?? "#101214", c = o.lightCandidate ?? "#ffffff", i = o.preferredCandidate, f = o.preferredMinContrast ?? r, v = o.preferredSwitchDelta ?? 0, d = N(e, n), h = N(e, c), b = d >= r, p = h >= r, R = h >= f, E = d >= f;
273
+ if (b || p)
274
+ return i === "light" && R ? c : i === "dark" && E ? n : i === "light" && p ? !b || d - h <= v ? c : n : i === "dark" && b ? !p || h - d <= v ? n : c : b && p ? d >= h ? n : c : b ? n : c;
275
+ const A = d >= h;
276
+ return Dt(t, e, {
277
+ minContrast: r,
278
+ preferDark: A,
279
+ initialLightness: A ? 0.2 : 0.96,
280
+ chromaScale: 0.1
281
+ });
282
+ }
283
+ const wt = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1e3], ut = [
284
+ 0.9,
285
+ 0.84,
286
+ 0.78,
287
+ 0.72,
288
+ 0.67,
289
+ 0.62,
290
+ 0.56,
291
+ 0.5,
292
+ 0.44,
293
+ 0.38
294
+ ], It = [
295
+ 0.28,
296
+ 0.4,
297
+ 0.54,
298
+ 0.7,
299
+ 0.86,
300
+ 1,
301
+ 1.08,
302
+ 1.14,
303
+ 1.2,
304
+ 1.24
305
+ ];
306
+ function P(t, e, o, r) {
307
+ const n = e[e.length - 1];
308
+ for (const c of e) {
309
+ const i = t[c];
310
+ if (i && N(i, o) >= r)
311
+ return c;
312
+ }
313
+ return n;
314
+ }
315
+ function yt(t) {
316
+ const e = t.l - ut[5], o = t.c > 0.02 ? 0.02 : 0;
317
+ return wt.reduce((r, n, c) => {
318
+ const i = C(
319
+ ut[c] + e
320
+ ), f = Math.min(
321
+ 0.4,
322
+ Math.max(
323
+ o,
324
+ t.c * It[c]
325
+ )
326
+ );
327
+ return r[n] = q(W(i, f, t.h)), r;
328
+ }, {});
329
+ }
330
+ function Nt(t, e) {
331
+ const o = [100, 200, 300, 400, 500, 600, 700], r = P(
332
+ e,
333
+ o,
334
+ tt,
335
+ kt
336
+ ), n = o.indexOf(r), c = o[Math.min(n + 1, o.length - 1)], i = o[Math.min(n + 2, o.length - 1)], f = [1e3, 900, 800, 700, 600, 500], v = P(
337
+ e,
338
+ f,
339
+ et,
340
+ kt
341
+ ), d = f.indexOf(v), h = f[Math.min(d + 1, f.length - 1)], b = f[Math.min(d + 2, f.length - 1)], R = P(
342
+ e,
343
+ [200, 300, 400, 500, 600, 700, 800],
344
+ tt,
345
+ St
346
+ ), A = P(
347
+ e,
348
+ [900, 800, 700, 600, 500, 400],
349
+ et,
350
+ St
351
+ ), g = [600, 700, 800, 900, 1e3], k = P(
352
+ e,
353
+ g,
354
+ tt,
355
+ pt
356
+ ), T = g.indexOf(k), x = g[Math.min(T + 1, g.length - 1)], J = g[Math.min(T + 2, g.length - 1)], O = [400, 300, 200, 100], j = P(
357
+ e,
358
+ O,
359
+ et,
360
+ pt
361
+ ), ht = O.indexOf(j), Lt = O[Math.min(ht + 1, O.length - 1)], xt = O[Math.min(ht + 2, O.length - 1)], s = {
362
+ "--color-brand-surface-soft-light": e[r],
363
+ "--color-brand-surface-soft-hovered-light": e[c],
364
+ "--color-brand-surface-soft-pressed-light": e[i],
365
+ "--color-brand-surface-soft-dark": e[v],
366
+ "--color-brand-surface-soft-hovered-dark": e[h],
367
+ "--color-brand-surface-soft-pressed-dark": e[b],
368
+ "--color-brand-surface-subtle-light": e[R],
369
+ "--color-brand-surface-subtle-dark": e[A],
370
+ "--color-brand-surface-strong-light": e[k],
371
+ "--color-brand-surface-strong-hovered-light": e[x],
372
+ "--color-brand-surface-strong-pressed-light": e[J],
373
+ "--color-brand-surface-strong-dark": e[j],
374
+ "--color-brand-surface-strong-hovered-dark": e[Lt],
375
+ "--color-brand-surface-strong-pressed-dark": e[xt]
376
+ }, gt = e[600], Bt = N(
377
+ s["--color-brand-surface-soft-light"],
378
+ gt
379
+ );
380
+ return s["--color-brand-on-soft-light"] = Bt >= B ? gt : $(
381
+ t,
382
+ s["--color-brand-surface-soft-light"],
383
+ {
384
+ minContrast: B
385
+ }
386
+ ), s["--color-brand-on-soft-dark"] = $(
387
+ t,
388
+ s["--color-brand-surface-soft-dark"],
389
+ {
390
+ minContrast: B
391
+ }
392
+ ), s["--color-brand-on-subtle-light"] = $(
393
+ t,
394
+ s["--color-brand-surface-subtle-light"],
395
+ {
396
+ minContrast: Y,
397
+ preferredCandidate: "light",
398
+ preferredMinContrast: Y,
399
+ preferredSwitchDelta: Mt
400
+ }
401
+ ), s["--color-brand-on-subtle-dark"] = $(
402
+ t,
403
+ s["--color-brand-surface-subtle-dark"],
404
+ {
405
+ minContrast: B
269
406
  }
270
- const S = E(v.lightness), b = R(v.chroma), w = le(S, b, o.h);
271
- m[y] = ce(w);
272
- }), m;
407
+ ), s["--color-brand-on-strong-light"] = $(
408
+ t,
409
+ s["--color-brand-surface-strong-light"],
410
+ {
411
+ minContrast: Y,
412
+ preferredCandidate: "light",
413
+ preferredMinContrast: Y,
414
+ preferredSwitchDelta: Mt
415
+ }
416
+ ), s["--color-brand-on-strong-dark"] = $(
417
+ t,
418
+ s["--color-brand-surface-strong-dark"],
419
+ {
420
+ minContrast: B
421
+ }
422
+ ), s["--color-brand-text-light"] = s["--color-brand-surface-strong-light"], s["--color-brand-text-dark"] = s["--color-brand-surface-strong-dark"], s["--color-brand-icon-light"] = s["--color-brand-surface-strong-light"], s["--color-brand-icon-dark"] = s["--color-brand-surface-strong-dark"], s["--color-brand-border-light"] = s["--color-brand-surface-strong-light"], s["--color-brand-border-dark"] = s["--color-brand-surface-strong-dark"], s;
423
+ }
424
+ function Ot(t) {
425
+ const e = st(t);
426
+ if (!e)
427
+ return null;
428
+ const o = lt(e);
429
+ if (!o)
430
+ return null;
431
+ const r = At(o), n = yt(r);
432
+ return n[600] = e, {
433
+ "--color-brand-seed": e,
434
+ "--color-brand-100": n[100],
435
+ "--color-brand-200": n[200],
436
+ "--color-brand-300": n[300],
437
+ "--color-brand-400": n[400],
438
+ "--color-brand-500": n[500],
439
+ "--color-brand-600": n[600],
440
+ "--color-brand-700": n[700],
441
+ "--color-brand-800": n[800],
442
+ "--color-brand-900": n[900],
443
+ "--color-brand-1000": n[1e3],
444
+ ...Nt(r, n)
445
+ };
273
446
  }
274
- const W = j(() => ie(a.accentColor) ?? {}), ue = j(() => W.value), $ = {
447
+ const ft = ot(() => Ot(l.accentColor) ?? {}), V = {
275
448
  vars: {},
276
- enabled: !!a.exposeGlobalAccent
449
+ enabled: !!l.exposeGlobalAccent
277
450
  };
278
- return s.push($), A(
279
- () => a.exposeGlobalAccent,
280
- (e) => {
281
- $.enabled = !!e, p();
451
+ return m.push(V), H(
452
+ () => l.exposeGlobalAccent,
453
+ (t) => {
454
+ V.enabled = !!t, D();
282
455
  },
283
456
  { immediate: !0 }
284
- ), A(
285
- W,
286
- (e) => {
287
- e && Object.keys(e).length > 0 ? $.vars = { ...e } : $.vars = {}, p();
457
+ ), H(
458
+ ft,
459
+ (t) => {
460
+ t && Object.keys(t).length > 0 ? V.vars = { ...t } : V.vars = {}, D();
288
461
  },
289
462
  { immediate: !0 }
290
- ), (e, t) => (Z(), be("div", {
463
+ ), (t, e) => (_t(), Pt("div", {
291
464
  class: "theme",
292
- style: ge(ue.value)
465
+ style: Ht(ft.value)
293
466
  }, [
294
- ke(e.$slots, "default"),
295
- ee("div", {
467
+ Ft(t.$slots, "default"),
468
+ Ct("div", {
296
469
  ref_key: "portalHost",
297
- ref: f,
470
+ ref: _,
298
471
  class: "theme__portal-host"
299
472
  }, null, 512)
300
473
  ], 4));
301
474
  }
302
- }), Ae = (n, a) => {
303
- const s = n.__vccOpts || n;
304
- for (const [c, p] of a)
305
- s[c] = p;
306
- return s;
307
- }, Ie = {
475
+ }), te = (a, l) => {
476
+ const m = a.__vccOpts || a;
477
+ for (const [u, D] of l)
478
+ m[u] = D;
479
+ return m;
480
+ }, ee = {
308
481
  __name: "ThemeSwitcher",
309
482
  props: {
310
483
  mode: {
311
484
  type: String,
312
485
  default: "auto",
313
- validator: (n) => ["auto", "light", "dark"].includes(n)
486
+ validator: (a) => ["auto", "light", "dark"].includes(a)
314
487
  }
315
488
  },
316
489
  emits: ["update:mode"],
317
- setup(n, { emit: a }) {
318
- const c = [
490
+ setup(a, { emit: l }) {
491
+ const u = [
319
492
  { value: "auto", label: "System" },
320
493
  { value: "light", label: "Light" },
321
494
  { value: "dark", label: "Dark" }
322
- ].reduce((f, d) => (f[d.value] = d.label, f), {}), p = B, k = n, P = a;
323
- ne();
324
- const T = N(!1), I = V() ?? k.mode, l = N(
325
- p.includes(I) ? I : "auto"
495
+ ].reduce((_, M) => (_[M.value] = M.label, _), {}), D = Q, I = a, X = l;
496
+ Rt();
497
+ const L = G(!1), F = nt() ?? I.mode, S = G(
498
+ D.includes(F) ? F : "auto"
326
499
  );
327
- return j(
328
- () => c[l.value] ?? c.auto
329
- ), A(
330
- () => k.mode,
331
- (f) => {
332
- p.includes(f) && f !== l.value && (l.value = f);
500
+ return ot(
501
+ () => u[S.value] ?? u.auto
502
+ ), H(
503
+ () => I.mode,
504
+ (_) => {
505
+ D.includes(_) && _ !== S.value && (S.value = _);
333
506
  }
334
- ), A(
335
- l,
336
- (f) => {
337
- if (!p.includes(f)) {
338
- l.value = "auto";
507
+ ), H(
508
+ S,
509
+ (_) => {
510
+ if (!D.includes(_)) {
511
+ S.value = "auto";
339
512
  return;
340
513
  }
341
- T.value = !1, P("update:mode", f), we(f);
514
+ L.value = !1, X("update:mode", _), Qt(_);
342
515
  },
343
516
  { immediate: !0 }
344
- ), (f, d) => (Z(), Me(g(ve), {
345
- open: T.value,
346
- "onUpdate:open": d[3] || (d[3] = (M) => T.value = M),
517
+ ), (_, M) => (_t(), Vt(w(Gt), {
518
+ open: L.value,
519
+ "onUpdate:open": M[3] || (M[3] = (y) => L.value = y),
347
520
  text: "Theme",
348
521
  "aria-label": "Select theme mode"
349
522
  }, {
350
- default: X(() => [
351
- U(g(ye), { title: "Theme" }, {
352
- default: X(() => [
353
- U(g(K), {
354
- checked: l.value,
355
- "onUpdate:checked": d[0] || (d[0] = (M) => l.value = M),
523
+ default: bt(() => [
524
+ K(w(jt), { title: "Theme" }, {
525
+ default: bt(() => [
526
+ K(w(Z), {
527
+ checked: S.value,
528
+ "onUpdate:checked": M[0] || (M[0] = (y) => S.value = y),
356
529
  value: "auto",
357
- label: g(c).auto,
358
- "aria-label": `${g(c).auto} mode`
530
+ label: w(u).auto,
531
+ "aria-label": `${w(u).auto} mode`
359
532
  }, null, 8, ["checked", "label", "aria-label"]),
360
- d[4] || (d[4] = ee("hr", {
533
+ M[4] || (M[4] = Ct("hr", {
361
534
  class: "theme-switcher-divider",
362
535
  role: "separator"
363
536
  }, null, -1)),
364
- U(g(K), {
365
- checked: l.value,
366
- "onUpdate:checked": d[1] || (d[1] = (M) => l.value = M),
537
+ K(w(Z), {
538
+ checked: S.value,
539
+ "onUpdate:checked": M[1] || (M[1] = (y) => S.value = y),
367
540
  value: "light",
368
- label: g(c).light,
369
- "aria-label": `${g(c).light} mode`
541
+ label: w(u).light,
542
+ "aria-label": `${w(u).light} mode`
370
543
  }, null, 8, ["checked", "label", "aria-label"]),
371
- U(g(K), {
372
- checked: l.value,
373
- "onUpdate:checked": d[2] || (d[2] = (M) => l.value = M),
544
+ K(w(Z), {
545
+ checked: S.value,
546
+ "onUpdate:checked": M[2] || (M[2] = (y) => S.value = y),
374
547
  value: "dark",
375
- label: g(c).dark,
376
- "aria-label": `${g(c).dark} mode`
548
+ label: w(u).dark,
549
+ "aria-label": `${w(u).dark} mode`
377
550
  }, null, 8, ["checked", "label", "aria-label"])
378
551
  ]),
379
552
  _: 1
@@ -382,11 +555,11 @@ const Te = "(prefers-color-scheme: dark)", De = "(prefers-reduced-motion: reduce
382
555
  _: 1
383
556
  }, 8, ["open"]));
384
557
  }
385
- }, je = /* @__PURE__ */ Ae(Ie, [["__scopeId", "data-v-bcbc87cb"]]);
558
+ }, se = /* @__PURE__ */ te(ee, [["__scopeId", "data-v-bcbc87cb"]]);
386
559
  export {
387
- Ue as Theme,
388
- je as ThemeSwitcher,
389
- oe as themePortalHostKey,
390
- Ne as useThemePortalTarget
560
+ ce as Theme,
561
+ se as ThemeSwitcher,
562
+ Tt as themePortalHostKey,
563
+ ae as useThemePortalTarget
391
564
  };
392
565
  //# sourceMappingURL=theme.es.js.map