@mintplayer/web-components 2.16.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/accordion/index.mjs +5 -5
  2. package/calendar/index.mjs +1 -1
  3. package/carousel/index.mjs +57 -143
  4. package/charts/core/index.mjs +30 -20
  5. package/charts/core/src/attributes.d.ts +18 -0
  6. package/charts/core/src/index.d.ts +2 -0
  7. package/charts/core/src/view-window.d.ts +46 -0
  8. package/charts/hierarchy/index.mjs +245 -256
  9. package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
  10. package/charts/sparkline/index.mjs +27 -26
  11. package/charts/trend/index.mjs +21 -20
  12. package/checkbox/index.mjs +1 -1
  13. package/checkbox/src/components/mp-checkbox.d.ts +1 -0
  14. package/chunks/attributes-L3eKsbdy.mjs +16 -0
  15. package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
  16. package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
  17. package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
  18. package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
  19. package/chunks/{mp-datatable-B7st6G-I.mjs → mp-datatable-CEpSxlkd.mjs} +660 -357
  20. package/chunks/{mp-datetime-picker.element-DsWA1AFs.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
  21. package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
  22. package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
  23. package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
  24. package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
  25. package/chunks/{mp-timepicker.element-CwaAAOcm.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
  26. package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
  27. package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
  28. package/chunks/{overlay-controller-DifgO6jT.mjs → overlay-controller-BHDagokg.mjs} +96 -92
  29. package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
  30. package/chunks/view-window-DGvFiDnW.mjs +263 -0
  31. package/code-snippet/index.mjs +70 -66
  32. package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
  33. package/custom-elements.json +66193 -0
  34. package/datatable/index.mjs +1 -1
  35. package/datatable/src/components/column-resize.d.ts +11 -0
  36. package/datatable/src/components/index.d.ts +1 -1
  37. package/datatable/src/components/mp-datatable.d.ts +264 -20
  38. package/datatable/src/index.d.ts +1 -1
  39. package/datatable/src/types/labels.d.ts +11 -0
  40. package/datepicker/index.mjs +10 -9
  41. package/datetime-picker/index.mjs +1 -1
  42. package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
  43. package/dock/index.mjs +430 -463
  44. package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
  45. package/dock/src/core/resize.d.ts +60 -0
  46. package/dropdown-menu/index.mjs +4 -2
  47. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
  48. package/dropdown-menu/src/index.d.ts +1 -1
  49. package/dropdown-menu/src/types/dropdown.d.ts +14 -1
  50. package/dropdown-menu/src/types/index.d.ts +1 -1
  51. package/file-manager/index.mjs +63 -61
  52. package/file-manager/src/components/mp-file-manager.d.ts +4 -3
  53. package/multi-range/index.mjs +56 -50
  54. package/multi-range/src/mint-multi-range.element.d.ts +4 -10
  55. package/multi-range/src/pointer-geometry.d.ts +31 -0
  56. package/navbar/index.mjs +89 -439
  57. package/overlay/index.mjs +1 -1
  58. package/overlay/src/overlay-controller.d.ts +0 -14
  59. package/overlay/src/placement.d.ts +48 -0
  60. package/package.json +7 -1
  61. package/pagination/index.mjs +1 -1
  62. package/phone-input/index.mjs +44 -40
  63. package/phone-input/src/components/stack.d.ts +8 -0
  64. package/query-builder/index.mjs +418 -466
  65. package/query-builder/src/dnd/drag-controller.d.ts +12 -8
  66. package/query-builder/src/mp-query-builder.element.d.ts +5 -1
  67. package/query-builder/src/mp-query-condition.element.d.ts +1 -0
  68. package/radio/index.mjs +1 -1
  69. package/radio-group/index.mjs +1 -1
  70. package/ribbon/index.mjs +477 -498
  71. package/ribbon/src/core/band-text-color.d.ts +10 -0
  72. package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
  73. package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
  74. package/ribbon/src/mp-ribbon.element.d.ts +0 -27
  75. package/scheduler/index.mjs +726 -711
  76. package/scheduler/src/components/mp-scheduler.d.ts +19 -3
  77. package/scheduler/src/drag/drag-manager.d.ts +1 -9
  78. package/scheduler/src/input/input-handler.d.ts +12 -2
  79. package/scheduler/src/utils/geometry.d.ts +39 -0
  80. package/scheduler/src/views/timeline-view.d.ts +0 -1
  81. package/scheduler-core/index.mjs +84 -71
  82. package/scheduler-core/src/services/resource.service.d.ts +0 -12
  83. package/scheduler-core/src/services/timeline.service.d.ts +0 -9
  84. package/select/index.mjs +1 -1
  85. package/select/src/components/mp-select.d.ts +1 -0
  86. package/signature-pad/index.mjs +21 -23
  87. package/signature-pad/src/canvas-point.d.ts +26 -0
  88. package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
  89. package/splitter/index.mjs +1 -1
  90. package/splitter/src/components/mp-splitter.d.ts +16 -0
  91. package/splitter/src/managers/index.d.ts +1 -0
  92. package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
  93. package/swiper-core/index.mjs +2 -2
  94. package/theming/bs-theme-preboot.js +1 -0
  95. package/theming/color-mode.css +36 -0
  96. package/theming/index.d.ts +1 -0
  97. package/theming/index.mjs +327 -0
  98. package/theming/src/components/mp-theme-toggle.d.ts +71 -0
  99. package/theming/src/cookie.d.ts +31 -0
  100. package/theming/src/index.d.ts +5 -0
  101. package/theming/src/preboot.d.ts +1 -0
  102. package/theming/src/resolve.d.ts +36 -0
  103. package/theming/src/store.d.ts +27 -0
  104. package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
  105. package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
  106. package/theming/src/toggle-modes.d.ts +23 -0
  107. package/tile-manager/index.mjs +252 -211
  108. package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
  109. package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
  110. package/timeline/index.mjs +156 -164
  111. package/timeline/src/components/mp-timeline.d.ts +41 -7
  112. package/timepicker/index.mjs +7 -4
  113. package/timepicker/src/mp-time-list.element.d.ts +26 -0
  114. package/timepicker/src/mp-timepicker.element.d.ts +3 -0
  115. package/toggle-button/index.mjs +1 -1
  116. package/tree-select/index.mjs +21 -9
  117. package/treeview/index.mjs +1 -1
  118. package/treeview/src/components/mp-treeview.d.ts +6 -4
  119. package/chunks/color-DIeST-IS.mjs +0 -224
  120. package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
@@ -0,0 +1,263 @@
1
+ function X(t) {
2
+ const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), e = (a, u) => {
3
+ o.set(a.id, a), s.set(a.id, u);
4
+ const l = a.children?.length ? a.children.map((i) => e(i, a)).reduce((i, m) => i + m, 0) : a.value ?? 0;
5
+ n.set(a.id, l);
6
+ const c = (a.children ?? []).filter((i) => r.get(i.id) !== void 0), h = c.map((i) => n.get(i.id) ?? 0).reduce((i, m) => i + m, 0);
7
+ return r.set(
8
+ a.id,
9
+ a.colorValue !== void 0 ? a.colorValue : h > 0 ? c.map((i) => (r.get(i.id) ?? 0) * (n.get(i.id) ?? 0)).reduce((i, m) => i + m, 0) / h : void 0
10
+ ), l;
11
+ };
12
+ return e(t, null), { root: t, byId: o, parents: s, values: n, colorValues: r };
13
+ }
14
+ function Z(t, o) {
15
+ const s = (n) => n ? [...s(t.parents.get(n.id)), n] : [];
16
+ return s(o);
17
+ }
18
+ function k(t, o) {
19
+ return Z(t, o).length;
20
+ }
21
+ const q = (t) => !!(t.children?.length || t.hasChildren);
22
+ function F(t, o) {
23
+ return [...o.children ?? []].sort(
24
+ (s, n) => (t.values.get(n.id) ?? 0) - (t.values.get(s.id) ?? 0)
25
+ );
26
+ }
27
+ function R(t, o) {
28
+ return o !== void 0 && t.byId.get(o) || t.root;
29
+ }
30
+ function Y(t, o) {
31
+ const s = (n) => n.children?.length ? 1 + Math.max(...n.children.map(s)) : 0;
32
+ return s(R(t, o));
33
+ }
34
+ function tt(t, o, s = {}) {
35
+ const { maxDepth: n = 2, minFraction: r = 0 } = s, e = R(t, o), a = [], u = (l, c, h, i, m) => {
36
+ if (i > n) return;
37
+ const d = F(t, l);
38
+ if (!d.length) return;
39
+ const $ = d.map((g) => t.values.get(g.id) ?? 0).reduce((g, M) => g + M, 0);
40
+ d.reduce((g, M, b) => {
41
+ const z = $ > 0 ? (t.values.get(M.id) ?? 0) / $ : 1 / d.length, p = g + (h - c) * z;
42
+ return p - g >= r && p > g && (a.push({
43
+ node: M,
44
+ x0: g,
45
+ x1: p,
46
+ depth: i,
47
+ level: m + 1,
48
+ setsize: d.length,
49
+ posinset: b + 1,
50
+ hasChildren: q(M)
51
+ }), u(M, g, p, i + 1, m + 1)), p;
52
+ }, c);
53
+ };
54
+ return u(e, 0, 1, 1, k(t, e)), a;
55
+ }
56
+ function V(t, o) {
57
+ const s = t.reduce((u, l) => u + l, 0);
58
+ if (s === 0 || o === 0) return 1 / 0;
59
+ const n = Math.max(...t), r = Math.min(...t), e = s * s, a = o * o;
60
+ return Math.max(a * n / e, e / (a * r));
61
+ }
62
+ function _(t, o) {
63
+ const s = /* @__PURE__ */ new Map();
64
+ let n = { ...o }, r = t.filter((u) => u.area > 0);
65
+ const e = (u) => {
66
+ const l = u.reduce((i, m) => i + m.area, 0), c = n.x1 - n.x0, h = n.y1 - n.y0;
67
+ if (!(l <= 0 || c <= 0 || h <= 0))
68
+ if (c >= h) {
69
+ const i = l / h;
70
+ u.reduce((m, d) => {
71
+ const $ = d.area / i;
72
+ return s.set(d.id, { x0: n.x0, y0: m, x1: n.x0 + i, y1: m + $ }), m + $;
73
+ }, n.y0), n = { ...n, x0: n.x0 + i };
74
+ } else {
75
+ const i = l / c;
76
+ u.reduce((m, d) => {
77
+ const $ = d.area / i;
78
+ return s.set(d.id, { x0: m, y0: n.y0, x1: m + $, y1: n.y0 + i }), m + $;
79
+ }, n.x0), n = { ...n, y0: n.y0 + i };
80
+ }
81
+ };
82
+ let a = [];
83
+ for (; r.length; ) {
84
+ const u = Math.min(n.x1 - n.x0, n.y1 - n.y0), l = [...a, r[0]];
85
+ !a.length || V(l.map((c) => c.area), u) <= V(a.map((c) => c.area), u) ? (a = l, r = r.slice(1)) : (e(a), a = []);
86
+ }
87
+ return e(a), s;
88
+ }
89
+ function nt(t, o, s = {}) {
90
+ const { maxDepth: n = 2, minArea: r = 0, childPadding: e = 0, childHeaderSpace: a = 0 } = s, u = R(t, o), l = [], c = (i) => {
91
+ const m = {
92
+ x0: i.x0 + e,
93
+ y0: i.y0 + e + a,
94
+ x1: i.x1 - e,
95
+ y1: i.y1 - e
96
+ };
97
+ return m.x1 - m.x0 > 0 && m.y1 - m.y0 > 0 ? m : null;
98
+ }, h = (i, m, d, $) => {
99
+ if (d > n) return;
100
+ const g = d === 1 ? m : c(m);
101
+ if (!g) return;
102
+ const M = F(t, i);
103
+ if (!M.length) return;
104
+ const b = (g.x1 - g.x0) * (g.y1 - g.y0), z = M.map((f) => t.values.get(f.id) ?? 0).reduce((f, N) => f + N, 0), p = M.map((f) => ({
105
+ id: f.id,
106
+ area: z > 0 ? (t.values.get(f.id) ?? 0) / z * b : b / M.length
107
+ })), L = _(p, g);
108
+ M.map((f, N) => ({ kid: f, i: N, r: L.get(f.id) })).filter((f) => !!f.r && (f.r.x1 - f.r.x0) * (f.r.y1 - f.r.y0) >= r).map((f) => (l.push({
109
+ node: f.kid,
110
+ ...f.r,
111
+ depth: d,
112
+ level: $ + 1,
113
+ setsize: M.length,
114
+ posinset: f.i + 1,
115
+ hasChildren: q(f.kid)
116
+ }), h(f.kid, f.r, d + 1, $ + 1), f));
117
+ };
118
+ return h(u, { x0: 0, y0: 0, x1: 1, y1: 1 }, 1, k(t, u)), l;
119
+ }
120
+ const G = 2 * Math.PI, I = 1e-6, y = (t, o, s) => A(t + o * Math.sin(s)), x = (t, o, s) => A(t - o * Math.cos(s)), A = (t) => Math.round(t * 1e3) / 1e3;
121
+ function U(t, o, s, n) {
122
+ const r = `M ${y(t, n, 0)} ${x(o, n, 0)} A ${n} ${n} 0 1 1 ${y(t, n, Math.PI)} ${x(o, n, Math.PI)} A ${n} ${n} 0 1 1 ${y(t, n, 0)} ${x(o, n, 0)} Z`;
123
+ if (s <= I) return r;
124
+ const e = `M ${y(t, s, 0)} ${x(o, s, 0)} A ${s} ${s} 0 1 0 ${y(t, s, Math.PI)} ${x(o, s, Math.PI)} A ${s} ${s} 0 1 0 ${y(t, s, 0)} ${x(o, s, 0)} Z`;
125
+ return `${r} ${e}`;
126
+ }
127
+ function ot(t, o, s, n, r, e, a = {}) {
128
+ const { padAngle: u = 0, ringGap: l = 1 } = a, c = Math.max(0, s), h = Math.max(c, n - l);
129
+ if (h - c <= I || e - r <= I) return "";
130
+ if (e - r >= G - I) return U(t, o, c, h);
131
+ const i = Math.min((e - r) / 2, u) / 2, m = i > 0 ? a.padRadius ?? Math.sqrt(c * c + h * h) : 0, d = (H) => H > I ? Math.asin(Math.min(1, m * Math.sin(i) / H)) : 0, $ = (r + e) / 2, g = (H, S) => S > H ? [H, S] : [$, $ + I], [M, b] = g(r + d(h), e - d(h)), z = b - M > Math.PI ? 1 : 0, p = `M ${y(t, h, M)} ${x(o, h, M)} A ${h} ${h} 0 ${z} 1 ${y(t, h, b)} ${x(o, h, b)}`;
132
+ if (c <= I) return `${p} L ${A(t)} ${A(o)} Z`;
133
+ const [L, f] = g(r + d(c), e - d(c)), N = f - L > Math.PI ? 1 : 0;
134
+ return `${p} L ${y(t, c, f)} ${x(o, c, f)} A ${c} ${c} 0 ${N} 0 ${y(t, c, L)} ${x(o, c, L)} Z`;
135
+ }
136
+ function st(t, o, s, n = "radial") {
137
+ const r = (t + o) / 2 * 360 % 360, e = n === "radial" ? r < 180 ? 0 : 180 : r > 90 && r < 270 ? 270 : 90;
138
+ return `rotate(${A(r - 90)}) translate(${A(s)},0) rotate(${e})`;
139
+ }
140
+ const W = 0.6, w = 1.2, D = 8, K = 4, B = "…", j = { visible: !1, text: "", orientation: "tangential" }, v = (t, o, s) => !t.length || o < K ? j : o >= t.length ? { visible: !0, text: t, orientation: s } : { visible: !0, text: t.slice(0, o - 1) + B, orientation: s };
141
+ function rt(t, o, s, n, r) {
142
+ const e = n - s, a = (s + n) / 2;
143
+ if (e <= 0 || o <= 0 || r <= 0) return j;
144
+ const u = a * o, l = W * r, c = w * r, h = u >= c ? Math.floor((e - D) / l) : 0, i = 2 * a * Math.sin(Math.min(o, Math.PI) / 2), m = e >= c ? Math.floor((Math.min(u, i) - D) / l) : 0;
145
+ return m >= h ? v(t, m, "tangential") : v(t, h, "radial");
146
+ }
147
+ function et(t, o, s) {
148
+ return o >= 1.4 * s && t - D >= 3 * W * s;
149
+ }
150
+ function J(t, o, s) {
151
+ const n = (t % 360 + 360) % 360, r = (1 - Math.abs(2 * s - 1)) * o, e = r * (1 - Math.abs(n / 60 % 2 - 1)), a = s - r / 2, u = Math.floor(n / 60), [l, c, h] = u === 0 ? [r, e, 0] : u === 1 ? [e, r, 0] : u === 2 ? [0, r, e] : u === 3 ? [0, e, r] : u === 4 ? [e, 0, r] : [r, 0, e];
152
+ return [(l + a) * 255, (c + a) * 255, (h + a) * 255];
153
+ }
154
+ function P(t) {
155
+ const o = t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)?.[1];
156
+ if (o) {
157
+ const r = o.length === 3 ? [...o].map((e) => e + e).join("") : o;
158
+ return [0, 2, 4].map((e) => parseInt(r.slice(e, e + 2), 16));
159
+ }
160
+ const s = t.trim().match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)$/i);
161
+ if (s) return [Number(s[1]), Number(s[2]), Number(s[3])];
162
+ const n = t.trim().match(/^hsl\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*\)$/i);
163
+ if (n) return J(Number(n[1]), Number(n[2]) / 100, Number(n[3]) / 100);
164
+ throw new Error(`Unsupported color: "${t}" (use #rrggbb, rgb(r, g, b) or hsl(h, s%, l%))`);
165
+ }
166
+ function E(t) {
167
+ try {
168
+ return P(t);
169
+ } catch {
170
+ return;
171
+ }
172
+ }
173
+ function O([t, o, s]) {
174
+ const n = t / 255, r = o / 255, e = s / 255, a = Math.max(n, r, e), u = Math.min(n, r, e), l = (a + u) / 2;
175
+ if (a === u) return { h: 0, s: 0, l };
176
+ const c = a - u, h = l > 0.5 ? c / (2 - a - u) : c / (a + u);
177
+ return { h: (a === n ? (r - e) / c + (r < e ? 6 : 0) : a === r ? (e - n) / c + 2 : (n - r) / c + 4) * 60, s: h, l };
178
+ }
179
+ function at(t, o, s, n) {
180
+ const r = O(P(s)), e = O(P(n)), a = o - t;
181
+ return (u) => {
182
+ const l = a === 0 ? 0 : Math.min(1, Math.max(0, (u - t) / a)), c = r.h + (e.h - r.h) * l, h = r.s + (e.s - r.s) * l, i = r.l + (e.l - r.l) * l;
183
+ return `hsl(${C(c)}, ${C(h * 100)}%, ${C(i * 100)}%)`;
184
+ };
185
+ }
186
+ const C = (t) => Math.round(t * 10) / 10;
187
+ function Q(t) {
188
+ const o = E(t);
189
+ if (!o) return;
190
+ const [s, n, r] = o.map((e) => {
191
+ const a = e / 255;
192
+ return a <= 0.03928 ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4);
193
+ });
194
+ return 0.2126 * s + 0.7152 * n + 0.0722 * r;
195
+ }
196
+ function ct(t, o, s) {
197
+ const n = E(t), r = E(o);
198
+ if (!n || !r) return;
199
+ const e = Math.min(1, Math.max(0, s)), a = n.map((u, l) => Math.round(u * e + r[l] * (1 - e)));
200
+ return `rgb(${a[0]}, ${a[1]}, ${a[2]})`;
201
+ }
202
+ function it(t) {
203
+ const o = Q(t);
204
+ if (o === void 0) return;
205
+ const s = (o + 0.05) / 0.05, n = 1.05 / (o + 0.05);
206
+ return s >= n ? "dark" : "light";
207
+ }
208
+ const ut = Object.freeze({ zoom: 1, x: 0, y: 0 });
209
+ function T(t, o) {
210
+ return Math.min(1 - 1 / o, Math.max(0, t));
211
+ }
212
+ function lt(t, o, s, n, r) {
213
+ const e = Math.min(r, Math.max(1, Number(o) || 1)), a = t.x + s / t.zoom, u = t.y + n / t.zoom;
214
+ return {
215
+ zoom: e,
216
+ x: T(a - s / e, e),
217
+ y: T(u - n / e, e)
218
+ };
219
+ }
220
+ function ht(t, o, s) {
221
+ return t.zoom <= 1 ? t : {
222
+ zoom: t.zoom,
223
+ x: T(t.x - o / t.zoom, t.zoom),
224
+ y: T(t.y - s / t.zoom, t.zoom)
225
+ };
226
+ }
227
+ function mt(t, o, s, n, r) {
228
+ return {
229
+ x0: (o - t.x) * t.zoom,
230
+ y0: (s - t.y) * t.zoom,
231
+ x1: (n - t.x) * t.zoom,
232
+ y1: (r - t.y) * t.zoom
233
+ };
234
+ }
235
+ function ft(t, o, s) {
236
+ return !t || !t.width || !t.height ? { x: 0.5, y: 0.5 } : {
237
+ x: Math.min(1, Math.max(0, (o - t.left) / t.width)),
238
+ y: Math.min(1, Math.max(0, (s - t.top) / t.height))
239
+ };
240
+ }
241
+ export {
242
+ ut as F,
243
+ st as a,
244
+ ot as b,
245
+ X as c,
246
+ T as d,
247
+ at as e,
248
+ ct as f,
249
+ it as g,
250
+ rt as h,
251
+ et as i,
252
+ tt as j,
253
+ Z as k,
254
+ k as l,
255
+ ft as m,
256
+ mt as n,
257
+ R as o,
258
+ ht as p,
259
+ Y as q,
260
+ Q as r,
261
+ nt as s,
262
+ lt as z
263
+ };
@@ -1,8 +1,8 @@
1
- import { unsafeCSS as k, LitElement as x, nothing as c, html as h } from "lit";
2
- import { property as s, state as u } from "lit/decorators.js";
3
- import { unsafeHTML as L } from "lit/directives/unsafe-html.js";
4
- import d from "highlight.js/lib/core";
5
- const $ = k(`@charset "UTF-8";
1
+ import { unsafeCSS as k, LitElement as H, nothing as h, html as c } from "lit";
2
+ import { property as s, state as m } from "lit/decorators.js";
3
+ import { unsafeHTML as N } from "lit/directives/unsafe-html.js";
4
+ import u from "highlight.js/lib/core";
5
+ const S = k(`@charset "UTF-8";
6
6
  :host {
7
7
  --mp-code-bg: light-dark(#fefefe, #2b2b2b);
8
8
  --mp-code-fg: light-dark(#545454, #f8f8f2);
@@ -82,7 +82,7 @@ const $ = k(`@charset "UTF-8";
82
82
 
83
83
  .hljs-strong {
84
84
  font-weight: bold;
85
- }`), C = k(`:host {
85
+ }`), q = k(`:host {
86
86
  display: flex;
87
87
  flex-direction: column;
88
88
  position: relative;
@@ -225,7 +225,7 @@ a.line-number:focus-visible {
225
225
  right: 0.5rem;
226
226
  padding: 0.25rem 0.75rem;
227
227
  font-size: 0.75rem;
228
- color: var(--bs-body-bg);
228
+ color: var(--bs-white);
229
229
  background: var(--bs-success);
230
230
  border-radius: var(--bs-border-radius-sm);
231
231
  opacity: 0;
@@ -262,14 +262,14 @@ a.line-number:focus-visible {
262
262
  slot {
263
263
  display: none;
264
264
  }`);
265
- function T(t) {
265
+ function M(t) {
266
266
  return t.replace(/\r\n?/g, `
267
267
  `).replace(/\n$/, "");
268
268
  }
269
- function S(t) {
269
+ function _(t) {
270
270
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
271
271
  }
272
- function y(t) {
272
+ function v(t) {
273
273
  const e = [], i = [];
274
274
  let n = "", a = 0;
275
275
  for (; a < t.length; ) {
@@ -280,14 +280,14 @@ function y(t) {
280
280
  n += t.slice(a);
281
281
  break;
282
282
  }
283
- const m = t.slice(a, p + 1);
284
- m[1] === "/" ? i.pop() : t[p - 1] !== "/" && i.push(m), n += m, a = p + 1;
283
+ const f = t.slice(a, p + 1);
284
+ f[1] === "/" ? i.pop() : t[p - 1] !== "/" && i.push(f), n += f, a = p + 1;
285
285
  } else l === `
286
286
  ` ? (e.push(n + "</span>".repeat(i.length)), n = i.join(""), a++) : (n += l, a++);
287
287
  }
288
288
  return e.push(n + "</span>".repeat(i.length)), e;
289
289
  }
290
- const j = {
290
+ const w = {
291
291
  atom: () => import("highlight.js/lib/languages/xml").then((t) => t.default),
292
292
  bash: () => import("highlight.js/lib/languages/bash").then((t) => t.default),
293
293
  c: () => import("highlight.js/lib/languages/c").then((t) => t.default),
@@ -322,6 +322,7 @@ const j = {
322
322
  javascript: () => import("highlight.js/lib/languages/javascript").then((t) => t.default),
323
323
  js: () => import("highlight.js/lib/languages/javascript").then((t) => t.default),
324
324
  json: () => import("highlight.js/lib/languages/json").then((t) => t.default),
325
+ json5: () => import("highlight.js/lib/languages/json").then((t) => t.default),
325
326
  jsonc: () => import("highlight.js/lib/languages/json").then((t) => t.default),
326
327
  jsp: () => import("highlight.js/lib/languages/java").then((t) => t.default),
327
328
  jsx: () => import("highlight.js/lib/languages/javascript").then((t) => t.default),
@@ -392,7 +393,7 @@ const j = {
392
393
  yaml: () => import("highlight.js/lib/languages/yaml").then((t) => t.default),
393
394
  yml: () => import("highlight.js/lib/languages/yaml").then((t) => t.default),
394
395
  zsh: () => import("highlight.js/lib/languages/bash").then((t) => t.default)
395
- }, H = {
396
+ }, B = {
396
397
  atom: "xml",
397
398
  bash: "bash",
398
399
  c: "c",
@@ -427,6 +428,7 @@ const j = {
427
428
  javascript: "javascript",
428
429
  js: "javascript",
429
430
  json: "json",
431
+ json5: "json",
430
432
  jsonc: "json",
431
433
  jsp: "java",
432
434
  jsx: "javascript",
@@ -497,49 +499,51 @@ const j = {
497
499
  yaml: "yaml",
498
500
  yml: "yaml",
499
501
  zsh: "bash"
500
- }, f = /* @__PURE__ */ new Map(), w = (t) => t in j, b = (t) => d.getLanguage(t) != null;
501
- function K(t, e) {
502
- d.registerLanguage(t, e);
502
+ }, g = /* @__PURE__ */ new Map(), L = (t) => t in w, y = (t) => u.getLanguage(t) != null;
503
+ function G(t, e) {
504
+ u.registerLanguage(t, e);
503
505
  }
504
- function P(t) {
505
- return b(t) || w(t);
506
+ function R(t) {
507
+ return y(t) || L(t);
506
508
  }
507
- async function q(t) {
508
- if (b(t)) return "ready";
509
- if (!w(t)) return "unknown-language";
510
- const e = H[t];
511
- let i = f.get(e);
512
- return i || (i = j[t]().then((n) => (b(e) || d.registerLanguage(e, n), !0)).catch(() => (f.delete(e), !1)), f.set(e, i)), await i ? "ready" : "load-failed";
509
+ async function P(t) {
510
+ if (y(t)) return "ready";
511
+ if (!L(t)) return "unknown-language";
512
+ const e = B[t];
513
+ let i = g.get(e);
514
+ return i || (i = w[t]().then((n) => (y(e) || u.registerLanguage(e, n), !0)).catch(() => (g.delete(e), !1)), g.set(e, i)), await i ? "ready" : "load-failed";
513
515
  }
514
- let g = null;
515
- function A() {
516
- return g ??= import("highlight.js/lib/common").then(() => !0).catch(() => (g = null, !1)), g;
516
+ let b = null;
517
+ function z() {
518
+ return b ??= import("highlight.js/lib/common").then(() => !0).catch(() => (b = null, !1)), b;
517
519
  }
518
- async function E(t, e) {
520
+ async function O(t, e) {
519
521
  if (!t) return { value: "", language: null, load: "ready" };
520
522
  if (e) {
521
- const n = await q(e);
523
+ const n = await P(e);
522
524
  if (n !== "ready") return { value: "", language: null, load: n };
523
- const a = d.highlight(t, { language: e, ignoreIllegals: !0 });
525
+ const a = u.highlight(t, { language: e, ignoreIllegals: !0 });
524
526
  return { value: a.value, language: a.language ?? e, load: "ready" };
525
527
  }
526
- if (!await A())
528
+ if (!await z())
527
529
  return { value: "", language: null, load: "load-failed" };
528
- const i = d.highlightAuto(t);
530
+ const i = u.highlightAuto(t);
529
531
  return { value: i.value, language: i.language ?? null, load: "ready" };
530
532
  }
531
- var M = Object.defineProperty, r = (t, e, i, n) => {
533
+ var D = Object.defineProperty, r = (t, e, i, n) => {
532
534
  for (var a = void 0, l = t.length - 1, p; l >= 0; l--)
533
535
  (p = t[l]) && (a = p(e, i, a) || a);
534
- return a && M(e, i, a), a;
536
+ return a && D(e, i, a), a;
535
537
  };
536
- const v = "mp-code-snippet";
537
- class o extends x {
538
+ const x = "Copy ${language} code to clipboard", $ = "Line ${line}", C = "${language} code sample", T = "Copied!", E = "Copied to clipboard", A = "Use the up and down arrow keys to move between line links, Home and End for the first and last line.", d = (t) => ({
539
+ fromAttribute: (e) => e ?? t
540
+ }), j = "mp-code-snippet";
541
+ class o extends H {
538
542
  constructor() {
539
- super(...arguments), this.language = "", this.theme = "auto", this.copyLabel = "Copy ${language} code to clipboard", this.code = "", this.lineNumbers = !1, this.startLine = 1, this.wrap = !1, this.annotations = [], this.activeLine = null, this.lineHref = null, this.lineLabel = "Line ${line}", this.label = "", this.regionLabel = "${language} code sample", this.copiedLabel = "Copied!", this.copiedAnnouncement = "Copied to clipboard", this.keymapHint = "Use the up and down arrow keys to move between line links, Home and End for the first and last line.", this.detectedLanguage = "code", this.lines = [], this.toastVisible = !1, this.rovingLine = null, this.toastTimer = null, this.annotationsByLine = /* @__PURE__ */ new Map(), this.highlightToken = 0, this.highlightPending = Promise.resolve();
543
+ super(...arguments), this.language = "", this.theme = "auto", this.copyLabel = x, this.code = "", this.lineNumbers = !1, this.startLine = 1, this.wrap = !1, this.annotations = [], this.activeLine = null, this.lineHref = null, this.lineLabel = $, this.label = "", this.regionLabel = C, this.copiedLabel = T, this.copiedAnnouncement = E, this.keymapHint = A, this.detectedLanguage = "code", this.lines = [], this.toastVisible = !1, this.rovingLine = null, this.toastTimer = null, this.annotationsByLine = /* @__PURE__ */ new Map(), this.highlightToken = 0, this.highlightPending = Promise.resolve();
540
544
  }
541
545
  static {
542
- this.styles = [$, C];
546
+ this.styles = [S, q];
543
547
  }
544
548
  /**
545
549
  * Explicit `label` wins; otherwise the pattern, so the region is never
@@ -576,17 +580,17 @@ class o extends x {
576
580
  * still-readable state rather than a blank box.
577
581
  */
578
582
  runHighlight() {
579
- const e = T(this.code ?? "");
583
+ const e = M(this.code ?? "");
580
584
  if (!e) {
581
585
  this.lines = [], this.setDetectedLanguage("code");
582
586
  return;
583
587
  }
584
- this.lines = y(S(e));
588
+ this.lines = v(_(e));
585
589
  const i = ++this.highlightToken, n = this.language;
586
- this.highlightPending = E(e, n).then(({ value: a, language: l, load: p }) => {
590
+ this.highlightPending = O(e, n).then(({ value: a, language: l, load: p }) => {
587
591
  i === this.highlightToken && (p === "unknown-language" ? console.warn(
588
592
  `[mp-code-snippet] unknown language "${n}" — rendering as plain text. Register it with registerLanguage() if it is outside the bundled set.`
589
- ) : p === "load-failed" && console.warn(`[mp-code-snippet] failed to load the grammar for "${n || "auto"}".`), a && (this.lines = y(a)), this.setDetectedLanguage(l ?? "code"));
593
+ ) : p === "load-failed" && console.warn(`[mp-code-snippet] failed to load the grammar for "${n || "auto"}".`), a && (this.lines = v(a)), this.setDetectedLanguage(l ?? "code"));
590
594
  });
591
595
  }
592
596
  setDetectedLanguage(e) {
@@ -611,7 +615,7 @@ class o extends x {
611
615
  }, 3e3);
612
616
  }
613
617
  render() {
614
- return h`
618
+ return c`
615
619
  <slot @slotchange=${this.onSlotChange}></slot>
616
620
  <button
617
621
  type="button"
@@ -625,12 +629,12 @@ class o extends x {
625
629
  tabindex="0"
626
630
  role="region"
627
631
  aria-label="${this.regionName}"
628
- aria-describedby="${this.lineHref ? "keymap" : c}"
632
+ aria-describedby="${this.lineHref ? "keymap" : h}"
629
633
  ><code part="code" class="hljs">${Array.from(
630
634
  { length: this.rowCount },
631
635
  (e, i) => this.renderLine(i)
632
636
  )}</code></pre>
633
- ${this.lineHref ? h`<div id="keymap" class="sr-only">${this.keymapHint}</div>` : c}
637
+ ${this.lineHref ? c`<div id="keymap" class="sr-only">${this.keymapHint}</div>` : h}
634
638
  <div class="toast ${this.toastVisible ? "visible" : ""}" part="toast" aria-hidden="${!this.toastVisible}">${this.copiedLabel}</div>
635
639
  <div class="sr-only" role="status" aria-live="polite">${this.toastVisible ? this.copiedAnnouncement : ""}</div>
636
640
  `;
@@ -692,15 +696,15 @@ class o extends x {
692
696
  */
693
697
  renderLine(e) {
694
698
  const i = this.startLine + e, n = this.annotationFor(i), a = this.activeLine === i, l = this.lineLabel.replace("${line}", String(i)), p = ["line", n?.kind ? `annotation-${n.kind}` : "", a ? "active-line" : ""].filter(Boolean).join(" ");
695
- return h`<span
699
+ return c`<span
696
700
  class="line${a ? " active" : ""}${n ? " annotated" : ""}"
697
701
  part="${p}"
698
702
  id="L${i}"
699
- title="${n?.description ?? c}"
700
- >${this.lineNumbers ? this.renderGutter(i, l) : c}${n?.label !== void 0 ? h`<span class="line-mark" part="line-mark" aria-hidden="true">${n.label}</span>` : c}${n?.secondaryLabel !== void 0 ? h`<span class="line-mark secondary" part="line-mark-secondary" aria-hidden="true"
703
+ title="${n?.description ?? h}"
704
+ >${this.lineNumbers ? this.renderGutter(i, l) : h}${n?.label !== void 0 ? c`<span class="line-mark" part="line-mark" aria-hidden="true">${n.label}</span>` : h}${n?.secondaryLabel !== void 0 ? c`<span class="line-mark secondary" part="line-mark-secondary" aria-hidden="true"
701
705
  >${n.secondaryLabel}</span
702
- >` : c}<span class="line-text" part="line-text">${L(this.lines[e] ?? "")}</span
703
- >${n?.description ? h`<span class="sr-only">${n.description}</span>` : c}</span
706
+ >` : h}<span class="line-text" part="line-text">${N(this.lines[e] ?? "")}</span
707
+ >${n?.description ? c`<span class="sr-only">${n.description}</span>` : h}</span
704
708
  >`;
705
709
  }
706
710
  /**
@@ -714,7 +718,7 @@ class o extends x {
714
718
  * reader and the rest of the page.
715
719
  */
716
720
  renderGutter(e, i) {
717
- return this.lineHref ? h`<a
721
+ return this.lineHref ? c`<a
718
722
  class="line-number"
719
723
  part="line-number"
720
724
  href="${this.resolveLineHref(this.lineHref(e))}"
@@ -723,7 +727,7 @@ class o extends x {
723
727
  @click=${(n) => this.onLineActivate(e, n)}
724
728
  @keydown=${(n) => this.onGutterKeydown(e, n)}
725
729
  >${e}</a
726
- >` : h`<span class="line-number" part="line-number" aria-hidden="true">${e}</span>`;
730
+ >` : c`<span class="line-number" part="line-number" aria-hidden="true">${e}</span>`;
727
731
  }
728
732
  /**
729
733
  * The single tabbable line link: wherever the user last was, else the active
@@ -778,7 +782,7 @@ r([
778
782
  s({ type: String, reflect: !0 })
779
783
  ], o.prototype, "theme");
780
784
  r([
781
- s({ type: String, attribute: "copy-label" })
785
+ s({ attribute: "copy-label", converter: d(x) })
782
786
  ], o.prototype, "copyLabel");
783
787
  r([
784
788
  s({ type: String })
@@ -802,38 +806,38 @@ r([
802
806
  s({ attribute: !1 })
803
807
  ], o.prototype, "lineHref");
804
808
  r([
805
- s({ type: String, attribute: "line-label" })
809
+ s({ attribute: "line-label", converter: d($) })
806
810
  ], o.prototype, "lineLabel");
807
811
  r([
808
812
  s({ type: String })
809
813
  ], o.prototype, "label");
810
814
  r([
811
- s({ type: String, attribute: "region-label" })
815
+ s({ attribute: "region-label", converter: d(C) })
812
816
  ], o.prototype, "regionLabel");
813
817
  r([
814
- s({ type: String, attribute: "copied-label" })
818
+ s({ attribute: "copied-label", converter: d(T) })
815
819
  ], o.prototype, "copiedLabel");
816
820
  r([
817
- s({ type: String, attribute: "copied-announcement" })
821
+ s({ attribute: "copied-announcement", converter: d(E) })
818
822
  ], o.prototype, "copiedAnnouncement");
819
823
  r([
820
- s({ type: String, attribute: "keymap-hint" })
824
+ s({ attribute: "keymap-hint", converter: d(A) })
821
825
  ], o.prototype, "keymapHint");
822
826
  r([
823
- u()
827
+ m()
824
828
  ], o.prototype, "detectedLanguage");
825
829
  r([
826
- u()
830
+ m()
827
831
  ], o.prototype, "lines");
828
832
  r([
829
- u()
833
+ m()
830
834
  ], o.prototype, "toastVisible");
831
835
  r([
832
- u()
836
+ m()
833
837
  ], o.prototype, "rovingLine");
834
- typeof customElements < "u" && !customElements.get(v) && customElements.define(v, o);
838
+ typeof customElements < "u" && !customElements.get(j) && customElements.define(j, o);
835
839
  export {
836
840
  o as MpCodeSnippet,
837
- P as canHighlight,
838
- K as registerLanguage
841
+ R as canHighlight,
842
+ G as registerLanguage
839
843
  };
@@ -1,6 +1,6 @@
1
1
  import { LanguageFn } from 'highlight.js';
2
2
  /** Every language id and alias `<mp-code-snippet>` can load on demand. */
3
- export type HljsLanguageKey = 'atom' | 'bash' | 'c' | 'c#' | 'c++' | 'cc' | 'cjs' | 'console' | 'cpp' | 'cs' | 'csharp' | 'css' | 'cts' | 'cxx' | 'diff' | 'gemspec' | 'go' | 'golang' | 'gql' | 'graphql' | 'gyp' | 'h' | 'h++' | 'hh' | 'hpp' | 'html' | 'hxx' | 'ini' | 'ipython' | 'irb' | 'java' | 'javascript' | 'js' | 'json' | 'jsonc' | 'jsp' | 'jsx' | 'kotlin' | 'kt' | 'kts' | 'less' | 'lua' | 'mak' | 'make' | 'makefile' | 'markdown' | 'md' | 'mjs' | 'mk' | 'mkd' | 'mkdown' | 'mm' | 'mts' | 'obj-c' | 'obj-c++' | 'objc' | 'objective-c++' | 'objectivec' | 'patch' | 'perl' | 'php' | 'php-template' | 'pl' | 'plaintext' | 'plist' | 'pluto' | 'pm' | 'podspec' | 'py' | 'pycon' | 'python' | 'python-repl' | 'r' | 'rb' | 'rs' | 'rss' | 'ruby' | 'rust' | 'scss' | 'sh' | 'shell' | 'shellsession' | 'sql' | 'svg' | 'swift' | 'text' | 'thor' | 'toml' | 'ts' | 'tsx' | 'txt' | 'typescript' | 'vb' | 'vbnet' | 'wasm' | 'wsf' | 'xhtml' | 'xjb' | 'xml' | 'xsd' | 'xsl' | 'yaml' | 'yml' | 'zsh';
3
+ export type HljsLanguageKey = 'atom' | 'bash' | 'c' | 'c#' | 'c++' | 'cc' | 'cjs' | 'console' | 'cpp' | 'cs' | 'csharp' | 'css' | 'cts' | 'cxx' | 'diff' | 'gemspec' | 'go' | 'golang' | 'gql' | 'graphql' | 'gyp' | 'h' | 'h++' | 'hh' | 'hpp' | 'html' | 'hxx' | 'ini' | 'ipython' | 'irb' | 'java' | 'javascript' | 'js' | 'json' | 'json5' | 'jsonc' | 'jsp' | 'jsx' | 'kotlin' | 'kt' | 'kts' | 'less' | 'lua' | 'mak' | 'make' | 'makefile' | 'markdown' | 'md' | 'mjs' | 'mk' | 'mkd' | 'mkdown' | 'mm' | 'mts' | 'obj-c' | 'obj-c++' | 'objc' | 'objective-c++' | 'objectivec' | 'patch' | 'perl' | 'php' | 'php-template' | 'pl' | 'plaintext' | 'plist' | 'pluto' | 'pm' | 'podspec' | 'py' | 'pycon' | 'python' | 'python-repl' | 'r' | 'rb' | 'rs' | 'rss' | 'ruby' | 'rust' | 'scss' | 'sh' | 'shell' | 'shellsession' | 'sql' | 'svg' | 'swift' | 'text' | 'thor' | 'toml' | 'ts' | 'tsx' | 'txt' | 'typescript' | 'vb' | 'vbnet' | 'wasm' | 'wsf' | 'xhtml' | 'xjb' | 'xml' | 'xsd' | 'xsl' | 'yaml' | 'yml' | 'zsh';
4
4
  /**
5
5
  * One lazy loader per language id AND alias, so `language="tsx"` and
6
6
  * `language="html"` resolve rather than falling through to auto-detect.