@cntrl-site/components 1.0.113-alpha.0 → 1.0.113-alpha.1

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,18 +1,18 @@
1
- import { jsxs as V, jsx as C } from "react/jsx-runtime";
2
- import { useMemo as X, useState as Z, useEffect as H, useRef as q, useLayoutEffect as ue } from "react";
3
- import { createPortal as he } from "react-dom";
4
- import { s as Ht } from "./scalingValue-C9JH5L6O.mjs";
5
- import { u as pe } from "./useScopedStyles-DhBG3557.mjs";
6
- import { u as de } from "./useLightboxScrollLock-VQ07s7EJ.mjs";
7
- import { n as me } from "./textStylesToCss-05Mn6I_2.mjs";
8
- import { R as ge } from "./RichTextRenderer-D52Xto59.mjs";
9
- import { S as fe } from "./SvgImage-CwRq9-ec.mjs";
10
- const $e = 60, be = 900 / 1440, ve = ["left", "center", "right"], Ut = {
1
+ import { jsx as I, jsxs as q } from "react/jsx-runtime";
2
+ import { useMemo as Z, useState as j, useEffect as U, useRef as H, useLayoutEffect as Ut } from "react";
3
+ import { createPortal as fe } from "react-dom";
4
+ import { s as qt } from "./scalingValue-C9JH5L6O.mjs";
5
+ import { u as $e } from "./useScopedStyles-DhBG3557.mjs";
6
+ import { u as be } from "./useLightboxScrollLock-VQ07s7EJ.mjs";
7
+ import { n as ve } from "./textStylesToCss-05Mn6I_2.mjs";
8
+ import { R as xe } from "./RichTextRenderer-D52Xto59.mjs";
9
+ import { S as we } from "./SvgImage-CwRq9-ec.mjs";
10
+ const ye = 60, Me = 900 / 1440, ke = ["left", "center", "right"], Zt = {
11
11
  columns: 12,
12
12
  columnWidth: 99 / 1440,
13
13
  gutter: 20 / 1440
14
14
  };
15
- function xe(t, e = Ut) {
15
+ function Ce(t, e = Zt) {
16
16
  const o = (c) => typeof c == "number" && Number.isFinite(c), n = (c, ...s) => s.find(o) ?? c, r = t.gridLayout ?? {}, u = Math.max(0, n(e.gutter, r.horizontalGap, t.gridGutter));
17
17
  return {
18
18
  columns: Math.max(1, Math.round(n(e.columns, r.columnsCount, t.gridColumns))),
@@ -21,30 +21,30 @@ function xe(t, e = Ut) {
21
21
  rowGap: Math.max(0, n(u, t.verticalGap))
22
22
  };
23
23
  }
24
- function tt(t) {
24
+ function et(t) {
25
25
  return t.rowGap ?? t.gutter;
26
26
  }
27
- function Yt(t) {
27
+ function Kt(t) {
28
28
  const e = t.popupHeight;
29
- return Math.min(100, Math.max(0, typeof e == "number" && Number.isFinite(e) ? e : $e));
29
+ return Math.min(100, Math.max(0, typeof e == "number" && Number.isFinite(e) ? e : ye));
30
30
  }
31
- function ye(t, e = be) {
32
- return Yt(t) / 100 * e;
31
+ function Ie(t, e = Me) {
32
+ return Kt(t) / 100 * e;
33
33
  }
34
- function Me(t) {
35
- return ve.includes(t.popupAlign) ? t.popupAlign : "center";
34
+ function Re(t) {
35
+ return ke.includes(t.popupAlign) ? t.popupAlign : "center";
36
36
  }
37
- function we(t, e) {
37
+ function _e(t, e) {
38
38
  var r;
39
39
  const o = (r = t.gridLayout) == null ? void 0 : r.wrapperWidth, n = e.columns * e.columnWidth + (e.columns - 1) * e.gutter;
40
40
  return typeof o == "number" && Number.isFinite(o) && o > 0 ? Math.max(o, n) : n > 0 ? n : 1;
41
41
  }
42
- function ke(t) {
42
+ function Se(t) {
43
43
  if (typeof t == "number") return { top: t, right: t, bottom: t, left: t };
44
44
  const e = (o) => typeof o == "number" && Number.isFinite(o) ? Math.max(0, o) : 0;
45
45
  return { top: e(t == null ? void 0 : t.top), right: e(t == null ? void 0 : t.right), bottom: e(t == null ? void 0 : t.bottom), left: e(t == null ? void 0 : t.left) };
46
46
  }
47
- const Ce = {
47
+ const ze = {
48
48
  span: {
49
49
  text: { min: 1 / 4, max: 5 / 12 },
50
50
  image: { min: 1 / 6, max: 1 / 3 },
@@ -53,70 +53,70 @@ const Ce = {
53
53
  },
54
54
  breakChance: 0.25
55
55
  };
56
- function Ie(t, e, o, n, r = Ce) {
57
- const u = Re(o), c = Math.max(1, Math.floor(e.columns)), s = [];
58
- let d = 0, g = new Array(c).fill(!1);
59
- const $ = {};
60
- for (const z of t) {
61
- const m = $[z] ?? ($[z] = ze(r.span[z] ?? r.span.text, c, u));
62
- let h = Et(g, m);
63
- const b = g.some(Boolean);
64
- (h.length === 0 || b && u() < r.breakChance) && (d += 1, g = new Array(c).fill(!1), h = Et(g, m));
65
- const N = h[Math.floor(u() * h.length)];
66
- for (let R = Math.max(0, N - 1); R < Math.min(c, N + m + 1); R++) g[R] = !0;
67
- s.push({ column: N, span: m, row: d });
56
+ function Ae(t, e, o, n, r = ze) {
57
+ const u = Fe(o), c = Math.max(1, Math.floor(e.columns)), s = [];
58
+ let d = 0, f = new Array(c).fill(!1);
59
+ const w = {};
60
+ for (const T of t) {
61
+ const m = w[T] ?? (w[T] = Ge(r.span[T] ?? r.span.text, c, u));
62
+ let p = Yt(f, m);
63
+ const v = f.some(Boolean);
64
+ (p.length === 0 || v && u() < r.breakChance) && (d += 1, f = new Array(c).fill(!1), p = Yt(f, m));
65
+ const A = p[Math.floor(u() * p.length)];
66
+ for (let z = Math.max(0, A - 1); z < Math.min(c, A + m + 1); z++) f[z] = !0;
67
+ s.push({ column: A, span: m, row: d });
68
68
  }
69
69
  const a = d + 1;
70
70
  return {
71
71
  seed: o,
72
72
  grid: { ...e, columns: c },
73
- placements: s.map(({ column: z, span: m, row: h }) => ({ column: z, span: m, top: K(e, h * n / a, n) }))
73
+ placements: s.map(({ column: T, span: m, row: p }) => ({ column: T, span: m, top: K(e, p * n / a, n) }))
74
74
  };
75
75
  }
76
- function ro() {
76
+ function so() {
77
77
  return Math.floor(Math.random() * 2147483647);
78
78
  }
79
79
  function K(t, e, o = 1 / 0) {
80
80
  const n = t.beat ?? 0, r = Math.max(0, o), u = n > 0 ? Math.round(e / n) * n : e, c = u <= r ? u : n > 0 ? Math.floor(r / n + 1e-9) * n : r;
81
81
  return Math.round(Math.max(0, c) * 1e6) / 1e6;
82
82
  }
83
- function xt(t) {
83
+ function yt(t) {
84
84
  return t.beat && t.beat > 0 ? t.beat : 8 / 1440;
85
85
  }
86
86
  function lt(t, e, o = 1 / 0) {
87
- const n = t.beat ?? 0, r = xt(t), u = n > 0 ? Math.round(e / n) * n : e, c = u <= o ? u : n > 0 ? Math.floor(o / n + 1e-9) * n : o;
88
- return jt(Math.max(r, c));
87
+ const n = t.beat ?? 0, r = yt(t), u = n > 0 ? Math.round(e / n) * n : e, c = u <= o ? u : n > 0 ? Math.floor(o / n + 1e-9) * n : o;
88
+ return Jt(Math.max(r, c));
89
89
  }
90
- function _e(t, e) {
90
+ function Ne(t, e) {
91
91
  const o = (n, r) => Math.abs(n - r) < 1e-9;
92
- return Math.floor(t.columns) === Math.floor(e.columns) && o(t.columnWidth, e.columnWidth) && o(t.gutter, e.gutter) && o(tt(t), tt(e)) && o(t.beat ?? 0, e.beat ?? 0);
92
+ return Math.floor(t.columns) === Math.floor(e.columns) && o(t.columnWidth, e.columnWidth) && o(t.gutter, e.gutter) && o(et(t), et(e)) && o(t.beat ?? 0, e.beat ?? 0);
93
93
  }
94
- function Ae(t, e) {
94
+ function Te(t, e) {
95
95
  const o = { ...e, columns: Math.max(1, Math.floor(e.columns)) };
96
- if (_e(t.grid, o)) return t;
96
+ if (Ne(t.grid, o)) return t;
97
97
  const n = Math.max(1, Math.floor(t.grid.columns)), r = o.columns, u = (s) => n === r ? s : Math.round(s * r / n), c = t.placements.map((s) => {
98
- const d = Math.min(r, Math.max(1, u(s.span))), g = Math.min(Math.max(0, u(s.column)), r - d), $ = K(o, s.top);
99
- return s.height === void 0 ? { column: g, span: d, top: $ } : { column: g, span: d, top: $, height: lt(o, s.height) };
98
+ const d = Math.min(r, Math.max(1, u(s.span))), f = Math.min(Math.max(0, u(s.column)), r - d), w = K(o, s.top);
99
+ return s.height === void 0 ? { column: f, span: d, top: w } : { column: f, span: d, top: w, height: lt(o, s.height) };
100
100
  });
101
101
  return { ...t, grid: o, placements: c };
102
102
  }
103
- function jt(t) {
103
+ function Jt(t) {
104
104
  return Math.round(t * 1e6) / 1e6;
105
105
  }
106
- function Vt(t, e, o, n, r) {
106
+ function Qt(t, e, o, n, r) {
107
107
  return t.column < o.column + o.span && o.column < t.column + t.span && t.top < o.top + n + r - 1e-9 && o.top < t.top + e + r - 1e-9;
108
108
  }
109
- function Se(t, e, o, n, r) {
109
+ function Le(t, e, o, n, r) {
110
110
  const u = t.placements[e];
111
- return u ? Xt(t, e, { ...u, column: o, top: n }, r) : null;
111
+ return u ? Pt(t, e, { ...u, column: o, top: n }, r) : null;
112
112
  }
113
- function Ne(t, e, o, n) {
113
+ function Be(t, e, o, n) {
114
114
  if (!t.placements[e]) return null;
115
- const { columns: r } = t.grid, u = Math.min(Math.max(0, o.column), r - 1), c = Math.min(Math.max(1, o.span), r - u), s = K(t.grid, o.top, n ? n.height - xt(t.grid) : 1 / 0), d = o.height === void 0 ? void 0 : lt(t.grid, o.height, n ? n.height - s : 1 / 0);
116
- return Xt(t, e, d === void 0 ? { column: u, span: c, top: s } : { column: u, span: c, top: s, height: d }, n);
115
+ const { columns: r } = t.grid, u = Math.min(Math.max(0, o.column), r - 1), c = Math.min(Math.max(1, o.span), r - u), s = K(t.grid, o.top, n ? n.height - yt(t.grid) : 1 / 0), d = o.height === void 0 ? void 0 : lt(t.grid, o.height, n ? n.height - s : 1 / 0);
116
+ return Pt(t, e, d === void 0 ? { column: u, span: c, top: s } : { column: u, span: c, top: s, height: d }, n);
117
117
  }
118
- function Xt(t, e, o, n) {
119
- const { columns: r } = t.grid, u = tt(t.grid), c = Math.min(o.span, r);
118
+ function Pt(t, e, o, n) {
119
+ const { columns: r } = t.grid, u = et(t.grid), c = Math.min(o.span, r);
120
120
  if (c < 1 || o.column < 0 || o.column + c > r) return null;
121
121
  const s = o.height ?? (n == null ? void 0 : n.heights[e]) ?? 0, d = {
122
122
  column: o.column,
@@ -124,48 +124,48 @@ function Xt(t, e, o, n) {
124
124
  top: K(t.grid, o.top, n ? n.height - s : 1 / 0),
125
125
  ...o.height === void 0 ? {} : { height: o.height }
126
126
  };
127
- return n && t.placements.some((g, $) => $ !== e && Vt(d, s, g, n.heights[$] ?? 0, u)) ? null : {
127
+ return n && t.placements.some((f, w) => w !== e && Qt(d, s, f, n.heights[w] ?? 0, u)) ? null : {
128
128
  ...t,
129
129
  edited: !0,
130
- placements: t.placements.map((g, $) => $ === e ? d : g)
130
+ placements: t.placements.map((f, w) => w === e ? d : f)
131
131
  };
132
132
  }
133
- function Te(t, e) {
134
- const { columns: o } = t.grid, n = tt(t.grid), r = t.grid.beat ?? 0, u = e.height, c = t.placements.map((m, h) => e.heights[h] ?? 0), s = [...t.placements], d = s.map((m, h) => h).sort((m, h) => s[m].top - s[h].top || m - h), g = [], $ = (m, h) => {
135
- let { top: b } = m;
136
- for (let N = !0, R = 0; N && R <= g.length; R++) {
137
- N = !1;
138
- for (const T of g) {
139
- const y = s[T];
140
- if (!Vt({ ...m, top: b }, h, y, c[T], n)) continue;
141
- const S = y.top + c[T] + n, I = r > 0 ? jt(Math.ceil(S / r - 1e-9) * r) : Math.ceil(S * 1e6 - 1e-6) / 1e6;
142
- I <= b || (b = I, N = !0);
133
+ function Ee(t, e) {
134
+ const { columns: o } = t.grid, n = et(t.grid), r = t.grid.beat ?? 0, u = e.height, c = t.placements.map((m, p) => e.heights[p] ?? 0), s = [...t.placements], d = s.map((m, p) => p).sort((m, p) => s[m].top - s[p].top || m - p), f = [], w = (m, p) => {
135
+ let { top: v } = m;
136
+ for (let A = !0, z = 0; A && z <= f.length; z++) {
137
+ A = !1;
138
+ for (const N of f) {
139
+ const k = s[N];
140
+ if (!Qt({ ...m, top: v }, p, k, c[N], n)) continue;
141
+ const S = k.top + c[N] + n, R = r > 0 ? Jt(Math.ceil(S / r - 1e-9) * r) : Math.ceil(S * 1e6 - 1e-6) / 1e6;
142
+ R <= v || (v = R, A = !0);
143
143
  }
144
144
  }
145
- return b;
146
- }, a = (m, h) => m + h > u + 1e-9;
147
- let z = !1;
145
+ return v;
146
+ }, a = (m, p) => m + p > u + 1e-9;
147
+ let T = !1;
148
148
  for (const m of d) {
149
- const h = s[m];
150
- let b = { column: h.column, top: $(h, c[m]) };
151
- if (b.top !== h.top && a(b.top, c[m])) {
152
- const N = Math.min(h.span, o), R = Array.from({ length: Math.max(0, o - N + 1) }, (y, S) => S).sort((y, S) => Math.abs(y - h.column) - Math.abs(S - h.column) || y - S);
153
- let T = null;
154
- for (const y of R) {
155
- const S = $({ ...h, column: y }, c[m]);
156
- !a(S, c[m]) && (!T || S < T.top - 1e-9) && (T = { column: y, top: S });
149
+ const p = s[m];
150
+ let v = { column: p.column, top: w(p, c[m]) };
151
+ if (v.top !== p.top && a(v.top, c[m])) {
152
+ const A = Math.min(p.span, o), z = Array.from({ length: Math.max(0, o - A + 1) }, (k, S) => S).sort((k, S) => Math.abs(k - p.column) - Math.abs(S - p.column) || k - S);
153
+ let N = null;
154
+ for (const k of z) {
155
+ const S = w({ ...p, column: k }, c[m]);
156
+ !a(S, c[m]) && (!N || S < N.top - 1e-9) && (N = { column: k, top: S });
157
157
  }
158
- T && (b = T);
158
+ N && (v = N);
159
159
  }
160
- (b.column !== h.column || b.top !== h.top) && (s[m] = { ...s[m], ...b }, z = !0), g.push(m);
160
+ (v.column !== p.column || v.top !== p.top) && (s[m] = { ...s[m], ...v }, T = !0), f.push(m);
161
161
  }
162
- return z ? { ...t, placements: s } : t;
162
+ return T ? { ...t, placements: s } : t;
163
163
  }
164
- function ze(t, e, o) {
164
+ function Ge(t, e, o) {
165
165
  const n = Math.max(1, Math.round(t.min * e)), r = Math.max(n, Math.round(t.max * e));
166
166
  return Math.min(e, n + Math.floor(o() * (r - n + 1)));
167
167
  }
168
- function Et(t, e) {
168
+ function Yt(t, e) {
169
169
  const o = [];
170
170
  for (let n = 0; n + e <= t.length; n++) {
171
171
  let r = !0;
@@ -178,7 +178,7 @@ function Et(t, e) {
178
178
  }
179
179
  return o;
180
180
  }
181
- function Re(t) {
181
+ function Fe(t) {
182
182
  let e = t >>> 0;
183
183
  return () => {
184
184
  e = e + 1831565813 >>> 0;
@@ -186,25 +186,25 @@ function Re(t) {
186
186
  return o = Math.imul(o ^ o >>> 15, o | 1), o ^= o + Math.imul(o ^ o >>> 7, o | 61), ((o ^ o >>> 14) >>> 0) / 4294967296;
187
187
  };
188
188
  }
189
- const U = 300, Le = 3e3, qt = ["slide down", "slide up", "fade", "scale", "none"], Be = "slide down";
190
- function Ge(t) {
189
+ const Y = 300, We = 3e3, te = ["slide down", "slide up", "fade", "scale", "none"], De = "slide down";
190
+ function Oe(t) {
191
191
  const e = t.popupTransition;
192
- return qt.includes(e) ? e : Be;
192
+ return te.includes(e) ? e : De;
193
193
  }
194
- const Fe = ["burger", "plus", "image", "text"], We = 24 / 1440, Ee = ["--cntrl-article-top", "--cntrl-article-left", "--cntrl-article-width", "--cntrl-viewport-height"], De = ["top", "right", "bottom", "left", "top-left", "top-right", "bottom-right", "bottom-left"], Oe = ["right", "left"];
195
- function Dt(t, e) {
194
+ const He = ["burger", "plus", "icon", "text"], je = 24 / 1440, Ue = ["--cntrl-article-top", "--cntrl-article-left", "--cntrl-article-width", "--cntrl-viewport-height"], Ye = ["top", "right", "bottom", "left", "top-left", "top-right", "bottom-right", "bottom-left"], Ve = ["right", "left"];
195
+ function Vt(t, e) {
196
196
  return { ...e, heights: e.heights.map((o, n) => {
197
197
  var r;
198
198
  return ((r = t.placements[n]) == null ? void 0 : r.height) ?? o;
199
199
  }) };
200
200
  }
201
- function He(t, e) {
201
+ function Xe(t, e) {
202
202
  return t.column === e.column && t.span === e.span && t.top === e.top && t.height === e.height;
203
203
  }
204
- function Ot(t, e) {
205
- return e.handle ? Ne(t, e.index, e.placement, e.measure) : Se(t, e.index, e.placement.column, e.placement.top, e.measure);
204
+ function Xt(t, e) {
205
+ return e.handle ? Be(t, e.index, e.placement, e.measure) : Le(t, e.index, e.placement.column, e.placement.top, e.measure);
206
206
  }
207
- function Ue(t) {
207
+ function qe(t) {
208
208
  return `
209
209
  /* the element is the trigger alone, placed and sized on the page as any other element; the popup opens over the page */
210
210
  .${t}-root {
@@ -235,7 +235,7 @@ function Ue(t) {
235
235
  width: var(--${t}-icon-size);
236
236
  height: var(--${t}-icon-size);
237
237
  --${t}-icon-stroke: max(1px, calc(var(--${t}-icon-size) / 12));
238
- transition: transform ${U}ms ease;
238
+ transition: transform ${Y}ms ease;
239
239
  }
240
240
  .${t}-icon-line {
241
241
  position: absolute;
@@ -244,7 +244,7 @@ function Ue(t) {
244
244
  height: var(--${t}-icon-stroke);
245
245
  top: calc(50% - var(--${t}-icon-stroke) / 2);
246
246
  background-color: currentColor;
247
- transition: transform ${U}ms ease, opacity ${U}ms ease;
247
+ transition: transform ${Y}ms ease, opacity ${Y}ms ease;
248
248
  }
249
249
  /* three lines, the outer two meeting in the middle and crossing as the popup opens, the middle one fading */
250
250
  .${t}-icon-burger .${t}-icon-line:nth-child(1) { transform: translateY(calc(var(--${t}-icon-size) * -0.3)) rotate(0deg) scaleX(1); }
@@ -290,6 +290,19 @@ function Ue(t) {
290
290
  .${t}-overlay-active {
291
291
  pointer-events: auto;
292
292
  }
293
+ /* the trigger drawn again over the popup, where it is on the page, so that its cross shows above the popup and closes
294
+ it; the page's own trigger, under the overlay, is hidden meanwhile */
295
+ .${t}-overlay .${t}-close {
296
+ position: absolute;
297
+ z-index: 1;
298
+ }
299
+ /* on the canvas, where the popup is pinned open, it lets the blocks under it be taken */
300
+ .${t}-overlay .${t}-close-inert {
301
+ pointer-events: none;
302
+ }
303
+ .${t}-button-hidden {
304
+ opacity: 0;
305
+ }
293
306
  .${t}-backdrop {
294
307
  all: unset;
295
308
  position: absolute;
@@ -299,7 +312,7 @@ function Ue(t) {
299
312
  -webkit-backdrop-filter: var(--${t}-overlay-blur, none);
300
313
  backdrop-filter: var(--${t}-overlay-blur, none);
301
314
  opacity: 0;
302
- transition: opacity ${U}ms ease;
315
+ transition: opacity ${Y}ms ease;
303
316
  }
304
317
  .${t}-card {
305
318
  position: absolute;
@@ -310,7 +323,7 @@ function Ue(t) {
310
323
  overscroll-behavior: contain;
311
324
  background-color: var(--${t}-popup-bg);
312
325
  opacity: 0;
313
- transition: opacity ${U}ms ease, transform ${U}ms ease;
326
+ transition: opacity ${Y}ms ease, transform ${Y}ms ease;
314
327
  }
315
328
  /* where the popup comes in from and goes back to, by its transition; it fades in and out with each, and 'none'
316
329
  shows and hides the popup and its overlay at once */
@@ -562,13 +575,13 @@ function Ue(t) {
562
575
  }
563
576
  `;
564
577
  }
565
- function P(t, e, o, n) {
578
+ function tt(t, e, o, n) {
566
579
  const r = (d) => t[`${e}${d}`] ?? (n ? t[`${n}${d}`] : void 0), u = (d) => {
567
- const g = r(d);
568
- return g === void 0 ? void 0 : Ht(g, o);
580
+ const f = r(d);
581
+ return f === void 0 ? void 0 : qt(f, o);
569
582
  }, c = r("FontSettings"), s = r("TextAppearance");
570
583
  return {
571
- fontFamily: me(r("FontFamily")),
584
+ fontFamily: ve(r("FontFamily")),
572
585
  fontWeight: c == null ? void 0 : c.fontWeight,
573
586
  fontStyle: c == null ? void 0 : c.fontStyle,
574
587
  fontSize: u("FontSize"),
@@ -580,15 +593,15 @@ function P(t, e, o, n) {
580
593
  fontVariant: s == null ? void 0 : s.fontVariant
581
594
  };
582
595
  }
583
- function yt(t) {
596
+ function Mt(t) {
584
597
  const e = t.type ?? "text";
585
598
  return e === "list" ? "listA" : e;
586
599
  }
587
- function Ye(t, e, o, n) {
588
- return t != null && t.grid && Array.isArray(t.placements) && t.placements.every((r) => typeof (r == null ? void 0 : r.top) == "number") ? je(Ae(t, n), e) : Ie(e.map(yt), n, 1, o);
600
+ function Ze(t, e, o, n) {
601
+ return t != null && t.grid && Array.isArray(t.placements) && t.placements.every((r) => typeof (r == null ? void 0 : r.top) == "number") ? Ke(Te(t, n), e) : Ae(e.map(Mt), n, 1, o);
589
602
  }
590
- function je(t, e) {
591
- const o = (n, r) => n.height !== void 0 && e[r] && yt(e[r]) !== "image";
603
+ function Ke(t, e) {
604
+ const o = (n, r) => n.height !== void 0 && e[r] && Mt(e[r]) !== "image";
592
605
  return t.placements.some(o) ? {
593
606
  ...t,
594
607
  placements: t.placements.map((n, r) => {
@@ -598,17 +611,17 @@ function je(t, e) {
598
611
  })
599
612
  } : t;
600
613
  }
601
- function Ve(t, e) {
614
+ function Je(t, e) {
602
615
  const o = (n, r) => Math.abs(n - r) < 1e-4;
603
616
  return o(t.height, e.height) && t.heights.length === e.heights.length && t.heights.every((n, r) => o(n, e.heights[r]));
604
617
  }
605
- function vt(t, e) {
618
+ function wt(t, e) {
606
619
  const { columns: o } = t.grid, n = t.placements[e];
607
620
  if (!n) return { column: 0, span: Math.min(o, Math.max(1, Math.round(o / 4))), top: 0 };
608
621
  const r = Math.min(n.span, o), u = { column: Math.min(n.column, o - r), span: r, top: n.top };
609
622
  return typeof n.height == "number" ? { ...u, height: n.height } : u;
610
623
  }
611
- function Xe({
624
+ function Qe({
612
625
  settings: t,
613
626
  content: e = [],
614
627
  isEditor: o,
@@ -618,315 +631,357 @@ function Xe({
618
631
  portalId: c,
619
632
  currentState: s,
620
633
  unavailableStates: d = [],
621
- onOpenChange: g,
622
- onUpdateSettings: $
634
+ onOpenChange: f,
635
+ onUpdateSettings: w
623
636
  }) {
624
- var Gt, Ft;
625
- const { prefix: a } = pe(), z = X(() => Ue(a), [a]), [m, h] = Z(!1), [b, N] = Z(!1), [R, T] = Z(!1), y = !!(o && !r), S = y && s === "open" && !d.includes("open"), I = S || !y && m, ct = Ge(t);
626
- de(I && !y), H(() => {
627
- g == null || g(I);
628
- }, [I, g]), H(() => {
629
- h(!1);
630
- }, [u]), H(() => {
631
- if (I) {
632
- N(!0);
637
+ var Ot, Ht;
638
+ const { prefix: a } = $e(), T = Z(() => qe(a), [a]), [m, p] = j(!1), [v, A] = j(!1), [z, N] = j(!1), k = !!(o && !r), S = k && s === "open" && !d.includes("open"), R = S || !k && m, ct = Oe(t);
639
+ be(R && !k), U(() => {
640
+ f == null || f(R);
641
+ }, [R, f]), U(() => {
642
+ p(!1);
643
+ }, [u]), U(() => {
644
+ if (R) {
645
+ A(!0);
633
646
  return;
634
647
  }
635
- T(!1);
636
- const i = window.setTimeout(() => N(!1), ct === "none" ? 0 : U);
648
+ N(!1);
649
+ const i = window.setTimeout(() => A(!1), ct === "none" ? 0 : Y);
637
650
  return () => window.clearTimeout(i);
638
- }, [I, ct]), H(() => {
639
- if (!I || !b) return;
640
- const i = nt.current;
651
+ }, [R, ct]), U(() => {
652
+ if (!R || !v) return;
653
+ const i = Q.current;
641
654
  i && getComputedStyle(i.querySelector("[role=dialog]") ?? i).opacity;
642
- const l = requestAnimationFrame(() => T(!0));
655
+ const l = requestAnimationFrame(() => N(!0));
643
656
  return () => cancelAnimationFrame(l);
644
- }, [I, b]), H(() => {
645
- if (!I || y) return;
657
+ }, [R, v]), U(() => {
658
+ if (!R || k) return;
646
659
  const i = (l) => {
647
- l.key === "Escape" && h(!1);
660
+ l.key === "Escape" && p(!1);
648
661
  };
649
662
  return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
650
- }, [I, y]);
651
- const _ = (i) => Ht(i ?? 0, o), Mt = ye(t), et = (Gt = t.menuLayout) == null ? void 0 : Gt.grid, wt = xe(t, et != null && et.columnWidth ? et : Ut), st = `min(100%, ${_(we(t, wt))})`, ut = _(t.popupOffset), Zt = {
663
+ }, [R, k]);
664
+ const _ = (i) => qt(i ?? 0, o), kt = Ie(t), ot = (Ot = t.menuLayout) == null ? void 0 : Ot.grid, Ct = Ce(t, ot != null && ot.columnWidth ? ot : Zt), st = `min(100%, ${_(_e(t, Ct))})`, ut = _(t.popupOffset), ee = {
652
665
  left: `calc(0px + ${ut})`,
653
666
  center: `calc((100% - ${st}) / 2 + ${ut})`,
654
667
  right: `calc(100% - ${st} + ${ut})`
655
- }[Me(t)], { columns: kt, columnWidth: Ct, gutter: It, rowGap: _t } = wt, At = X(
656
- () => ({ columns: kt, columnWidth: Ct, gutter: It, rowGap: _t }),
657
- [kt, Ct, It, _t]
658
- ), J = X(
659
- () => Ye(t.menuLayout, e, Mt, At),
660
- [t.menuLayout, e, Mt, At]
661
- ), [ht, Kt] = Z(null), pt = X(() => ht ? Dt(J, ht) : null, [J, ht]), M = X(() => pt ? Te(J, pt) : J, [J, pt]), { columns: F, gutter: dt, columnWidth: mt } = M.grid, Jt = F * mt + (F - 1) * dt, gt = mt > 0 ? {
662
- gridTemplateColumns: `repeat(${F}, minmax(0, ${_(mt)}))`,
668
+ }[Re(t)], { columns: It, columnWidth: Rt, gutter: _t, rowGap: St } = Ct, zt = Z(
669
+ () => ({ columns: It, columnWidth: Rt, gutter: _t, rowGap: St }),
670
+ [It, Rt, _t, St]
671
+ ), J = Z(
672
+ () => Ze(t.menuLayout, e, kt, zt),
673
+ [t.menuLayout, e, kt, zt]
674
+ ), [ht, oe] = j(null), pt = Z(() => ht ? Vt(J, ht) : null, [J, ht]), C = Z(() => pt ? Ee(J, pt) : J, [J, pt]), { columns: G, gutter: dt, columnWidth: mt } = C.grid, ne = G * mt + (G - 1) * dt, gt = mt > 0 ? {
675
+ gridTemplateColumns: `repeat(${G}, minmax(0, ${_(mt)}))`,
663
676
  columnGap: _(dt),
664
- width: `min(100%, ${_(Jt)})`,
677
+ width: `min(100%, ${_(ne)})`,
665
678
  marginInline: "auto"
666
- } : { gridTemplateColumns: `repeat(${F}, minmax(0, 1fr))`, columnGap: _(dt) }, St = t.triggerLabel || "Menu", ot = ke(t.triggerPadding), Y = t.triggerType === "image" && !t.triggerIcon ? "burger" : t.triggerType ?? "text", Qt = P(t, "trigger", o), Pt = P(t, "title", o), te = {
667
- text: P(t, "text", o),
668
- listA: P(t, "listA", o, "text"),
669
- listB: P(t, "listB", o, "text")
670
- }, E = ((Ft = t.stateOverrides) == null ? void 0 : Ft.open) ?? {}, Nt = {
679
+ } : { gridTemplateColumns: `repeat(${G}, minmax(0, 1fr))`, columnGap: _(dt) }, At = t.triggerLabel || "Menu", nt = Se(t.triggerPadding), V = t.triggerType === "icon" && !t.triggerIcon ? "burger" : t.triggerType ?? "text", re = tt(t, "trigger", o), ie = tt(t, "title", o), ae = {
680
+ text: tt(t, "text", o),
681
+ listA: tt(t, "listA", o, "text"),
682
+ listB: tt(t, "listB", o, "text")
683
+ }, W = ((Ht = t.stateOverrides) == null ? void 0 : Ht.open) ?? {}, Nt = {
671
684
  [`--${a}-trigger-bg`]: t.barBackgroundColor,
672
- [`--${a}-trigger-color`]: (I ? E.triggerColor : void 0) ?? t.triggerColor,
673
- [`--${a}-overlay-color`]: E.overlayColor ?? t.overlayColor,
685
+ [`--${a}-trigger-color`]: (R ? W.triggerColor : void 0) ?? t.triggerColor,
686
+ [`--${a}-overlay-color`]: W.overlayColor ?? t.overlayColor,
674
687
  [`--${a}-overlay-blur`]: t.overlayBlur ? `blur(${_(t.overlayBlur)})` : void 0,
675
- [`--${a}-popup-bg`]: E.popupBackgroundColor ?? t.popupBackgroundColor,
676
- [`--${a}-title-color`]: E.titleColor ?? t.titleColor,
677
- [`--${a}-text-color`]: E.textColor ?? t.textColor,
678
- [`--${a}-list-a-color`]: E.listAColor ?? t.listAColor,
679
- [`--${a}-list-b-color`]: E.listBColor ?? t.listBColor
680
- }, Tt = q(null), ee = X(() => {
688
+ [`--${a}-popup-bg`]: W.popupBackgroundColor ?? t.popupBackgroundColor,
689
+ [`--${a}-title-color`]: W.titleColor ?? t.titleColor,
690
+ [`--${a}-text-color`]: W.textColor ?? t.textColor,
691
+ [`--${a}-list-a-color`]: W.listAColor ?? t.listAColor,
692
+ [`--${a}-list-b-color`]: W.listBColor ?? t.listBColor
693
+ }, Tt = H(null), le = Z(() => {
681
694
  const i = Tt.current;
682
- if (!b || !o || !i) return;
695
+ if (!v || !o || !i) return;
683
696
  const l = getComputedStyle(i);
684
697
  return Object.fromEntries(
685
- Ee.map((p) => [p, l.getPropertyValue(p).trim()]).filter(([, p]) => p)
698
+ Ue.map((h) => [h, l.getPropertyValue(h).trim()]).filter(([, h]) => h)
686
699
  );
687
- }, [b, o]), nt = q(null), zt = q(null), ft = q(null), Q = q([]), [B, oe] = Z(null), $t = q(null), j = (i) => {
688
- $t.current = i, oe(i);
689
- }, W = !!(S && n && $), ne = B ? Ot(M, B) : null;
690
- H(() => {
691
- W || j(null);
692
- }, [W]), ue(() => {
693
- const i = zt.current, l = ft.current;
694
- if (!b || !i || !l) return;
695
- const p = () => {
696
- var A;
697
- const v = (A = nt.current) == null ? void 0 : A.getBoundingClientRect().width;
698
- if (!v) return;
699
- const x = {
700
- height: i.getBoundingClientRect().height / v,
701
- heights: e.map((k, L) => {
702
- var f;
703
- return (((f = Q.current[L]) == null ? void 0 : f.getBoundingClientRect().height) ?? 0) / v;
700
+ }, [v, o]), Q = H(null), Lt = H(null), Bt = H(null), ft = H(null), P = H([]), [B, ce] = j(null), $t = H(null), X = (i) => {
701
+ $t.current = i, ce(i);
702
+ }, F = !!(S && n && w), se = B ? Xt(C, B) : null;
703
+ U(() => {
704
+ F || X(null);
705
+ }, [F]);
706
+ const [bt, Et] = j(null);
707
+ Ut(() => {
708
+ const i = Lt.current;
709
+ if (!v || !i) {
710
+ Et(null);
711
+ return;
712
+ }
713
+ const l = () => {
714
+ const y = Q.current;
715
+ if (!y) return;
716
+ const $ = y.getBoundingClientRect(), g = i.getBoundingClientRect(), M = { top: g.top - $.top, left: g.left - $.left, width: g.width, height: g.height };
717
+ Et((b) => b && b.top === M.top && b.left === M.left && b.width === M.width && b.height === M.height ? b : M);
718
+ };
719
+ l();
720
+ const h = new ResizeObserver(l);
721
+ return h.observe(i), window.addEventListener("resize", l), window.addEventListener("scroll", l, { capture: !0, passive: !0 }), () => {
722
+ h.disconnect(), window.removeEventListener("resize", l), window.removeEventListener("scroll", l, { capture: !0 });
723
+ };
724
+ }, [v]), Ut(() => {
725
+ const i = Bt.current, l = ft.current;
726
+ if (!v || !i || !l) return;
727
+ const h = () => {
728
+ var M;
729
+ const $ = (M = Q.current) == null ? void 0 : M.getBoundingClientRect().width;
730
+ if (!$) return;
731
+ const g = {
732
+ height: i.getBoundingClientRect().height / $,
733
+ heights: e.map((b, L) => {
734
+ var x;
735
+ return (((x = P.current[L]) == null ? void 0 : x.getBoundingClientRect().height) ?? 0) / $;
704
736
  })
705
737
  };
706
- Kt((k) => k && Ve(k, x) ? k : x);
738
+ oe((b) => b && Je(b, g) ? b : g);
707
739
  };
708
- p();
709
- const w = new ResizeObserver(p);
710
- return w.observe(i), w.observe(l), Q.current.slice(0, e.length).forEach((v) => v && w.observe(v)), () => w.disconnect();
711
- }, [b, e]);
712
- const Rt = () => {
713
- const i = ft.current, l = i.getBoundingClientRect(), p = i.offsetWidth ? l.width / i.offsetWidth : 1, w = (parseFloat(getComputedStyle(i).columnGap) || 0) * p;
714
- return { area: l, gap: w, pitch: (l.width + w) / F };
715
- }, re = (i, l, p) => {
716
- var L, f;
717
- if (!W || !M.placements[l] || i.button !== 0) return;
740
+ h();
741
+ const y = new ResizeObserver(h);
742
+ return y.observe(i), y.observe(l), P.current.slice(0, e.length).forEach(($) => $ && y.observe($)), () => y.disconnect();
743
+ }, [v, e]);
744
+ const Gt = () => {
745
+ const i = ft.current, l = i.getBoundingClientRect(), h = i.offsetWidth ? l.width / i.offsetWidth : 1, y = (parseFloat(getComputedStyle(i).columnGap) || 0) * h;
746
+ return { area: l, gap: y, pitch: (l.width + y) / G };
747
+ }, ue = (i, l, h) => {
748
+ var L, x;
749
+ if (!F || !C.placements[l] || i.button !== 0) return;
718
750
  i.preventDefault(), i.stopPropagation(), i.currentTarget.setPointerCapture(i.pointerId);
719
- const { area: w, pitch: v } = Rt(), x = ((L = Q.current[l]) == null ? void 0 : L.getBoundingClientRect()) ?? i.currentTarget.getBoundingClientRect(), A = ((f = nt.current) == null ? void 0 : f.getBoundingClientRect().width) || 1, k = vt(M, l);
720
- j({
751
+ const { area: y, pitch: $ } = Gt(), g = ((L = P.current[l]) == null ? void 0 : L.getBoundingClientRect()) ?? i.currentTarget.getBoundingClientRect(), M = ((x = Q.current) == null ? void 0 : x.getBoundingClientRect().width) || 1, b = wt(C, l);
752
+ X({
721
753
  index: l,
722
754
  pointerId: i.pointerId,
723
- handle: p,
724
- grabColumn: Math.min(Math.max(Math.floor((i.clientX - w.left) / v) - k.column, 0), k.span - 1),
725
- grabY: i.clientY - x.top,
726
- unit: A,
727
- start: k,
728
- placement: k,
729
- measure: Dt(M, {
730
- height: w.height / A,
755
+ handle: h,
756
+ grabColumn: Math.min(Math.max(Math.floor((i.clientX - y.left) / $) - b.column, 0), b.span - 1),
757
+ grabY: i.clientY - g.top,
758
+ unit: M,
759
+ start: b,
760
+ placement: b,
761
+ measure: Vt(C, {
762
+ height: y.height / M,
731
763
  heights: e.map((D, rt) => {
732
- var G;
733
- return (((G = Q.current[rt]) == null ? void 0 : G.getBoundingClientRect().height) ?? 0) / A;
764
+ var E;
765
+ return (((E = P.current[rt]) == null ? void 0 : E.getBoundingClientRect().height) ?? 0) / M;
734
766
  })
735
767
  })
736
768
  });
737
- }, ie = (i) => {
769
+ }, he = (i) => {
738
770
  const l = $t.current;
739
771
  if (!l || i.pointerId !== l.pointerId) return;
740
772
  i.stopPropagation();
741
- const { area: p, gap: w, pitch: v } = Rt(), { start: x, measure: A, handle: k } = l, L = A.height;
742
- if (!k) {
743
- j({
773
+ const { area: h, gap: y, pitch: $ } = Gt(), { start: g, measure: M, handle: b } = l, L = M.height;
774
+ if (!b) {
775
+ X({
744
776
  ...l,
745
777
  placement: {
746
- ...x,
747
- column: Math.min(Math.max(Math.floor((i.clientX - p.left) / v) - l.grabColumn, 0), F - x.span),
748
- top: K(M.grid, (i.clientY - l.grabY - p.top) / l.unit, L - A.heights[l.index])
778
+ ...g,
779
+ column: Math.min(Math.max(Math.floor((i.clientX - h.left) / $) - l.grabColumn, 0), G - g.span),
780
+ top: K(C.grid, (i.clientY - l.grabY - h.top) / l.unit, L - M.heights[l.index])
749
781
  }
750
782
  });
751
783
  return;
752
784
  }
753
- const f = i.clientX - p.left, D = (i.clientY - p.top) / l.unit, rt = x.column + x.span;
754
- let { column: G, span: it, top: O } = x, at = x.height;
755
- if (k.includes("left") && (G = Math.min(Math.max(Math.round(f / v), 0), rt - 1), it = rt - G), k.includes("right") && (it = Math.min(Math.max(Math.round((f + w) / v), G + 1), F) - G), k.includes("top")) {
756
- const Wt = x.top + (x.height ?? A.heights[l.index] ?? 0);
757
- O = K(M.grid, D, Wt - xt(M.grid)), at = lt(M.grid, Wt - O, L - O);
785
+ const x = i.clientX - h.left, D = (i.clientY - h.top) / l.unit, rt = g.column + g.span;
786
+ let { column: E, span: it, top: O } = g, at = g.height;
787
+ if (b.includes("left") && (E = Math.min(Math.max(Math.round(x / $), 0), rt - 1), it = rt - E), b.includes("right") && (it = Math.min(Math.max(Math.round((x + y) / $), E + 1), G) - E), b.includes("top")) {
788
+ const jt = g.top + (g.height ?? M.heights[l.index] ?? 0);
789
+ O = K(C.grid, D, jt - yt(C.grid)), at = lt(C.grid, jt - O, L - O);
758
790
  }
759
- k.includes("bottom") && (at = lt(M.grid, D - O, L - O)), j({ ...l, placement: at === void 0 ? { column: G, span: it, top: O } : { column: G, span: it, top: O, height: at } });
760
- }, ae = (i) => {
791
+ b.includes("bottom") && (at = lt(C.grid, D - O, L - O)), X({ ...l, placement: at === void 0 ? { column: E, span: it, top: O } : { column: E, span: it, top: O, height: at } });
792
+ }, pe = (i) => {
761
793
  const l = $t.current;
762
794
  if (!l || i.pointerId !== l.pointerId) return;
763
795
  i.stopPropagation();
764
- const p = Ot(M, l), w = p == null ? void 0 : p.placements[l.index];
765
- p && w && !He(w, vt(M, l.index)) && ($ == null || $({ ...t, menuLayout: p })), j(null);
766
- }, le = (i, l) => {
796
+ const h = Xt(C, l), y = h == null ? void 0 : h.placements[l.index];
797
+ h && y && !Xe(y, wt(C, l.index)) && (w == null || w({ ...t, menuLayout: h })), X(null);
798
+ }, de = (i, l) => {
767
799
  i.stopPropagation();
768
- const p = M.placements[l];
769
- if (!W || !p || p.height === void 0) return;
770
- const { height: w, ...v } = p;
771
- $ == null || $({
800
+ const h = C.placements[l];
801
+ if (!F || !h || h.height === void 0) return;
802
+ const { height: y, ...$ } = h;
803
+ w == null || w({
772
804
  ...t,
773
- menuLayout: { ...M, edited: !0, placements: M.placements.map((x, A) => A === l ? v : x) }
805
+ menuLayout: { ...C, edited: !0, placements: C.placements.map((g, M) => M === l ? $ : g) }
774
806
  });
775
- }, Lt = () => h(!1), ce = (i) => {
776
- !y && i.target.closest("a") && Lt();
777
- }, se = (i, l) => {
778
- const p = yt(i), w = (i.images ?? []).filter((f) => f == null ? void 0 : f.assetId), v = (B == null ? void 0 : B.index) === l, x = v ? B.placement : vt(M, l), A = x.height !== void 0, k = W && (!B || v), L = (f) => ({
779
- onPointerDown: (D) => re(D, l, f),
780
- onPointerMove: ie,
781
- onPointerUp: ae,
782
- onPointerCancel: () => j(null)
807
+ }, vt = () => p(!1), me = (i) => {
808
+ !k && i.target.closest("a") && vt();
809
+ }, ge = (i, l) => {
810
+ const h = Mt(i), y = (i.images ?? []).filter((x) => x == null ? void 0 : x.assetId), $ = (B == null ? void 0 : B.index) === l, g = $ ? B.placement : wt(C, l), M = g.height !== void 0, b = F && (!B || $), L = (x) => ({
811
+ onPointerDown: (D) => ue(D, l, x),
812
+ onPointerMove: he,
813
+ onPointerUp: pe,
814
+ onPointerCancel: () => X(null)
783
815
  });
784
- return /* @__PURE__ */ V(
816
+ return /* @__PURE__ */ q(
785
817
  "div",
786
818
  {
787
- className: `${a}-slot${v ? ` ${a}-slot-dragged` : ""}`,
788
- style: { gridColumn: `${x.column + 1} / span ${x.span}` },
819
+ className: `${a}-slot${$ ? ` ${a}-slot-dragged` : ""}`,
820
+ style: { gridColumn: `${g.column + 1} / span ${g.span}` },
789
821
  children: [
790
- /* @__PURE__ */ C("div", { className: `${a}-spacer`, style: { height: _(x.top) } }),
791
- /* @__PURE__ */ V("div", { className: `${a}-frame`, children: [
792
- /* @__PURE__ */ V(
822
+ /* @__PURE__ */ I("div", { className: `${a}-spacer`, style: { height: _(g.top) } }),
823
+ /* @__PURE__ */ q("div", { className: `${a}-frame`, children: [
824
+ /* @__PURE__ */ q(
793
825
  "div",
794
826
  {
795
- ref: (f) => {
796
- Q.current[l] = f;
827
+ ref: (x) => {
828
+ P.current[l] = x;
797
829
  },
798
830
  className: [
799
- `${a}-block ${a}-block-${p}`,
800
- A ? `${a}-block-sized` : "",
801
- v ? `${a}-block-dragged` : "",
802
- v && !ne ? `${a}-block-invalid` : ""
831
+ `${a}-block ${a}-block-${h}`,
832
+ M ? `${a}-block-sized` : "",
833
+ $ ? `${a}-block-dragged` : "",
834
+ $ && !se ? `${a}-block-invalid` : ""
803
835
  ].filter(Boolean).join(" "),
804
- style: A ? { height: _(x.height) } : void 0,
805
- ...W ? L(null) : {},
836
+ style: M ? { height: _(g.height) } : void 0,
837
+ ...F ? L(null) : {},
806
838
  children: [
807
- i.title && p !== "image" ? /* @__PURE__ */ C("div", { className: `${a}-block-title`, style: { ...Pt, marginBottom: _(t.titleGap) }, children: i.title }) : null,
808
- p === "image" ? /* @__PURE__ */ C(qe, { prefix: a, images: w, isRunning: I, radius: _(t.imageRadius) }) : /* @__PURE__ */ C("div", { className: `${a}-block-text`, style: te[p], children: /* @__PURE__ */ C(ge, { content: Array.isArray(i.text) ? i.text : [] }) })
839
+ i.title && h !== "image" ? /* @__PURE__ */ I("div", { className: `${a}-block-title`, style: { ...ie, marginBottom: _(t.titleGap) }, children: i.title }) : null,
840
+ h === "image" ? /* @__PURE__ */ I(Pe, { prefix: a, images: y, isRunning: R, radius: _(t.imageRadius) }) : /* @__PURE__ */ I("div", { className: `${a}-block-text`, style: ae[h], children: /* @__PURE__ */ I(xe, { content: Array.isArray(i.text) ? i.text : [] }) })
809
841
  ]
810
842
  }
811
843
  ),
812
- k ? (p === "image" ? De : Oe).map((f) => /* @__PURE__ */ C(
844
+ b ? (h === "image" ? Ye : Ve).map((x) => /* @__PURE__ */ I(
813
845
  "div",
814
846
  {
815
- className: `${a}-handle ${a}-handle-${f}${v && B.handle === f ? ` ${a}-handle-active` : ""}`,
847
+ className: `${a}-handle ${a}-handle-${x}${$ && B.handle === x ? ` ${a}-handle-active` : ""}`,
816
848
  "aria-hidden": !0,
817
- ...L(f),
818
- onDoubleClick: f.includes("top") || f.includes("bottom") ? (D) => le(D, l) : void 0
849
+ ...L(x),
850
+ onDoubleClick: x.includes("top") || x.includes("bottom") ? (D) => de(D, l) : void 0
819
851
  },
820
- f
852
+ x
821
853
  )) : null
822
854
  ] })
823
855
  ]
824
856
  },
825
857
  l
826
858
  );
827
- }, bt = M.grid.beat || tt(M.grid), Bt = b ? /* @__PURE__ */ V(
859
+ }, Ft = {
860
+ ...V === "text" ? re : void 0,
861
+ padding: [nt.top, nt.right, nt.bottom, nt.left].map((i) => _(i)).join(" "),
862
+ [`--${a}-icon-size`]: _(t.triggerIconSize ?? je)
863
+ }, Wt = V === "text" ? At : /* @__PURE__ */ I("span", { className: `${a}-icon ${a}-icon-${V}`, "aria-hidden": !0, children: V === "icon" ? /* @__PURE__ */ I(
864
+ we,
865
+ {
866
+ url: t.triggerIcon,
867
+ fill: `var(--${a}-trigger-color)`,
868
+ hoverFill: `var(--${a}-trigger-color)`,
869
+ className: `${a}-icon-picture`
870
+ }
871
+ ) : Array.from({ length: V === "burger" ? 3 : 2 }, (i, l) => /* @__PURE__ */ I("span", { className: `${a}-icon-line` }, l)) }), xt = C.grid.beat || et(C.grid), Dt = v ? /* @__PURE__ */ q(
828
872
  "div",
829
873
  {
830
- ref: nt,
874
+ ref: Q,
831
875
  "data-selection": "none",
832
- className: [`${a}-overlay`, `${a}-transition-${ct.replace(" ", "-")}`, o ? `${a}-overlay-editor` : "", R ? `${a}-overlay-active` : ""].filter(Boolean).join(" "),
833
- style: { ...ee, ...Nt },
834
- "aria-hidden": !R,
876
+ className: [`${a}-overlay`, `${a}-transition-${ct.replace(" ", "-")}`, o ? `${a}-overlay-editor` : "", z ? `${a}-overlay-active` : ""].filter(Boolean).join(" "),
877
+ style: { ...le, ...Nt },
878
+ "aria-hidden": !z,
835
879
  children: [
836
- /* @__PURE__ */ C(
880
+ /* @__PURE__ */ I(
837
881
  "button",
838
882
  {
839
883
  type: "button",
840
884
  className: `${a}-backdrop`,
841
885
  "aria-label": "Close menu",
842
886
  tabIndex: -1,
843
- onClick: y ? void 0 : Lt
887
+ onClick: k ? void 0 : vt
844
888
  }
845
889
  ),
846
- /* @__PURE__ */ C(
890
+ /* @__PURE__ */ I(
847
891
  "div",
848
892
  {
849
- ref: zt,
893
+ ref: Bt,
850
894
  className: `${a}-card`,
851
895
  role: "dialog",
852
896
  "aria-modal": "true",
853
897
  "aria-label": t.triggerLabel || "Menu",
854
- onClick: ce,
898
+ onClick: me,
855
899
  style: {
856
900
  top: _(t.popupOffsetTop),
857
- height: `${Yt(t)}%`,
858
- left: Zt,
901
+ height: `${Kt(t)}%`,
902
+ left: ee,
859
903
  width: st,
860
904
  borderRadius: _(t.popupRadius)
861
905
  },
862
- children: /* @__PURE__ */ V(
906
+ children: /* @__PURE__ */ q(
863
907
  "div",
864
908
  {
865
909
  ref: ft,
866
- className: `${a}-grid${W ? ` ${a}-grid-editable` : ""}`,
910
+ className: `${a}-grid${F ? ` ${a}-grid-editable` : ""}`,
867
911
  style: gt,
868
912
  children: [
869
- e.map(se),
870
- W ? /* @__PURE__ */ C(
913
+ e.map(ge),
914
+ F ? /* @__PURE__ */ I(
871
915
  "div",
872
916
  {
873
- className: `${a}-guides${bt > 0 ? ` ${a}-guides-beats` : ""}${B ? ` ${a}-guides-shown` : ""}`,
917
+ className: `${a}-guides${xt > 0 ? ` ${a}-guides-beats` : ""}${B ? ` ${a}-guides-shown` : ""}`,
874
918
  style: {
875
919
  gridTemplateColumns: gt.gridTemplateColumns,
876
920
  columnGap: gt.columnGap,
877
- [`--${a}-beat`]: bt > 0 ? _(bt) : void 0
921
+ [`--${a}-beat`]: xt > 0 ? _(xt) : void 0
878
922
  },
879
923
  "aria-hidden": !0,
880
- children: Array.from({ length: F }, (i, l) => /* @__PURE__ */ C("div", { className: `${a}-guide` }, l))
924
+ children: Array.from({ length: G }, (i, l) => /* @__PURE__ */ I("div", { className: `${a}-guide` }, l))
881
925
  }
882
926
  ) : null
883
927
  ]
884
928
  }
885
929
  )
886
930
  }
887
- )
931
+ ),
932
+ bt ? /* @__PURE__ */ I(
933
+ "button",
934
+ {
935
+ type: "button",
936
+ className: [
937
+ `${a}-button ${a}-close`,
938
+ z ? `${a}-button-open` : "",
939
+ k ? `${a}-close-inert` : ""
940
+ ].filter(Boolean).join(" "),
941
+ style: { ...Ft, ...bt },
942
+ "aria-label": "Close menu",
943
+ "aria-expanded": R,
944
+ tabIndex: z ? void 0 : -1,
945
+ onClick: k ? void 0 : vt,
946
+ children: Wt
947
+ }
948
+ ) : null
888
949
  ]
889
950
  }
890
951
  ) : null;
891
- return /* @__PURE__ */ V("div", { ref: Tt, className: `${a}-root`, style: Nt, "data-edit-mode": n ? "" : void 0, children: [
892
- /* @__PURE__ */ C("style", { dangerouslySetInnerHTML: { __html: z } }),
893
- /* @__PURE__ */ C(
952
+ return /* @__PURE__ */ q("div", { ref: Tt, className: `${a}-root`, style: Nt, "data-edit-mode": n ? "" : void 0, children: [
953
+ /* @__PURE__ */ I("style", { dangerouslySetInnerHTML: { __html: T } }),
954
+ /* @__PURE__ */ I(
894
955
  "button",
895
956
  {
957
+ ref: Lt,
896
958
  type: "button",
897
- className: `${a}-button${I ? ` ${a}-button-open` : ""}`,
898
- style: {
899
- ...Y === "text" ? Qt : void 0,
900
- padding: [ot.top, ot.right, ot.bottom, ot.left].map((i) => _(i)).join(" "),
901
- [`--${a}-icon-size`]: _(t.triggerIconSize ?? We)
902
- },
903
- "aria-expanded": I,
904
- "aria-label": Y === "text" ? void 0 : St,
905
- onClick: y ? void 0 : () => h((i) => !i),
906
- children: Y === "text" ? St : /* @__PURE__ */ C("span", { className: `${a}-icon ${a}-icon-${Y}`, "aria-hidden": !0, children: Y === "image" ? /* @__PURE__ */ C(
907
- fe,
908
- {
909
- url: t.triggerIcon,
910
- fill: `var(--${a}-trigger-color)`,
911
- hoverFill: `var(--${a}-trigger-color)`,
912
- className: `${a}-icon-picture`
913
- }
914
- ) : Array.from({ length: Y === "burger" ? 3 : 2 }, (i, l) => /* @__PURE__ */ C("span", { className: `${a}-icon-line` }, l)) })
959
+ className: [
960
+ `${a}-button`,
961
+ R ? `${a}-button-open` : "",
962
+ // the close button over the popup stands in for it while the popup shows
963
+ bt ? `${a}-button-hidden` : ""
964
+ ].filter(Boolean).join(" "),
965
+ style: Ft,
966
+ "aria-expanded": R,
967
+ "aria-label": V === "text" ? void 0 : At,
968
+ onClick: k ? void 0 : () => p((i) => !i),
969
+ children: Wt
915
970
  }
916
971
  ),
917
- Bt && typeof document < "u" ? he(Bt, (c ? document.getElementById(c) : null) ?? document.body) : null
972
+ Dt && typeof document < "u" ? fe(Dt, (c ? document.getElementById(c) : null) ?? document.body) : null
918
973
  ] });
919
974
  }
920
- function qe({ prefix: t, images: e, isRunning: o, radius: n }) {
921
- const [r, u] = Z(0), c = e.length;
922
- return H(() => {
975
+ function Pe({ prefix: t, images: e, isRunning: o, radius: n }) {
976
+ const [r, u] = j(0), c = e.length;
977
+ return U(() => {
923
978
  if (!o || c < 2) {
924
979
  u(0);
925
980
  return;
926
981
  }
927
- const s = window.setInterval(() => u((d) => (d + 1) % c), Le);
982
+ const s = window.setInterval(() => u((d) => (d + 1) % c), We);
928
983
  return () => window.clearInterval(s);
929
- }, [o, c]), /* @__PURE__ */ C("div", { className: `${t}-images`, children: e.map((s, d) => /* @__PURE__ */ C(
984
+ }, [o, c]), /* @__PURE__ */ I("div", { className: `${t}-images`, children: e.map((s, d) => /* @__PURE__ */ I(
930
985
  "img",
931
986
  {
932
987
  className: `${t}-image${d === r % c ? "" : ` ${t}-image-hidden`}`,
@@ -938,35 +993,34 @@ function qe({ prefix: t, images: e, isRunning: o, radius: n }) {
938
993
  d
939
994
  )) });
940
995
  }
941
- const io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
996
+ const uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
942
997
  __proto__: null,
943
- POPUP_MENU_TRANSITIONS: qt,
944
- POPUP_MENU_TRIGGER_TYPES: Fe,
945
- PopupMenu: Xe
998
+ POPUP_MENU_TRANSITIONS: te,
999
+ POPUP_MENU_TRIGGER_TYPES: He,
1000
+ PopupMenu: Qe
946
1001
  }, Symbol.toStringTag, { value: "Module" }));
947
1002
  export {
948
- be as D,
949
- ve as P,
1003
+ Me as D,
1004
+ ke as P,
950
1005
  K as a,
951
1006
  lt as b,
952
- ye as c,
953
- Yt as d,
954
- Me as e,
955
- Ae as f,
956
- Ie as g,
957
- we as h,
958
- _e as i,
959
- ke as j,
960
- xe as k,
961
- Ut as l,
962
- Se as m,
963
- ro as n,
964
- Ce as o,
965
- $e as p,
966
- qt as q,
967
- Ne as r,
968
- Te as s,
969
- Fe as t,
970
- Xe as u,
971
- io as v
1007
+ Ie as c,
1008
+ Kt as d,
1009
+ _e as e,
1010
+ Te as f,
1011
+ Ae as g,
1012
+ Se as h,
1013
+ Ne as i,
1014
+ Ce as j,
1015
+ Zt as k,
1016
+ so as l,
1017
+ Le as m,
1018
+ ze as n,
1019
+ ye as o,
1020
+ te as p,
1021
+ He as q,
1022
+ Be as r,
1023
+ Ee as s,
1024
+ Qe as t,
1025
+ uo as u
972
1026
  };