@pasquelin/panels 0.1.1 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,238 +1,267 @@
1
- import { jsx as d, jsxs as m, Fragment as B } from "react/jsx-runtime";
2
- import k, { useEffect as K, useLayoutEffect as Mn, useState as tn, useMemo as w, useContext as fn, createContext as pn, useRef as j, useCallback as z, memo as hn, Fragment as Rn, Children as Cn, isValidElement as En } from "react";
3
- import { c as v } from "./cx-CcykAxZN.js";
4
- const en = (n) => {
1
+ import { jsx as u, jsxs as g, Fragment as A } from "react/jsx-runtime";
2
+ import F, { useEffect as nn, useLayoutEffect as kn, useState as W, useMemo as w, useContext as tn, createContext as en, useRef as H, useCallback as _, memo as Sn, Fragment as Dn, Children as jn, isValidElement as Hn } from "react";
3
+ import { c as b } from "./cx-CcykAxZN.js";
4
+ const an = (n) => {
5
5
  let t;
6
- const e = /* @__PURE__ */ new Set(), o = (u, a) => {
7
- const f = typeof u == "function" ? u(t) : u;
6
+ const e = /* @__PURE__ */ new Set(), o = (a, d) => {
7
+ const f = typeof a == "function" ? a(t) : a;
8
8
  if (!Object.is(f, t)) {
9
- const p = t;
10
- t = a ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((g) => g(t, p));
9
+ const h = t;
10
+ t = d ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((m) => m(t, h));
11
11
  }
12
- }, s = () => t, c = { setState: o, getState: s, getInitialState: () => l, subscribe: (u) => (e.add(u), () => e.delete(u)) }, l = t = n(o, s, c);
13
- return c;
14
- }, Ln = ((n) => n ? en(n) : en), On = (n) => n;
15
- function Tn(n, t = On) {
16
- const e = k.useSyncExternalStore(
12
+ }, c = () => t, i = { setState: o, getState: c, getInitialState: () => l, subscribe: (a) => (e.add(a), () => e.delete(a)) }, l = t = n(o, c, i);
13
+ return i;
14
+ }, Un = ((n) => n ? an(n) : an), Vn = (n) => n;
15
+ function Yn(n, t = Vn) {
16
+ const e = F.useSyncExternalStore(
17
17
  n.subscribe,
18
- k.useCallback(() => t(n.getState()), [n, t]),
19
- k.useCallback(() => t(n.getInitialState()), [n, t])
18
+ F.useCallback(() => t(n.getState()), [n, t]),
19
+ F.useCallback(() => t(n.getInitialState()), [n, t])
20
20
  );
21
- return k.useDebugValue(e), e;
21
+ return F.useDebugValue(e), e;
22
22
  }
23
- const C = ["left", "right", "top", "bottomLeft", "bottomRight"], $ = ["primary", "secondary"], kn = ["bottomLeft", "bottomRight"];
24
- function U(n) {
23
+ const U = ["left", "right", "top", "bottomLeft", "bottomRight"], Nn = ["primary", "secondary"], on = "default", $n = ["bottomLeft", "bottomRight"];
24
+ function rn(n) {
25
25
  return n === "bottomLeft" || n === "bottomRight";
26
26
  }
27
- function E(n) {
28
- return n === "top" || U(n);
27
+ function M(n) {
28
+ return n === "top" || rn(n);
29
29
  }
30
- const V = {
30
+ const G = {
31
31
  left: { column: ["left", "top"], band: "bottomLeft" },
32
32
  right: { column: ["right"], band: "bottomRight" }
33
33
  };
34
- function on(n) {
34
+ function un(n) {
35
35
  return n === "left" || n === "top";
36
36
  }
37
- const F = 140, gn = 240, R = 100, Bn = {
37
+ const B = 140, Pn = 240, Z = 100, Wn = {
38
38
  left: 320,
39
39
  right: 260,
40
40
  top: 180,
41
41
  bottomLeft: 240,
42
42
  bottomRight: 240
43
- }, mn = "bottomRight";
44
- function A(n) {
45
- return U(n) ? mn : n;
43
+ }, _n = "bottomRight";
44
+ function k(n) {
45
+ return rn(n) ? _n : n;
46
46
  }
47
- const M = {
47
+ const x = {
48
48
  left: "right",
49
49
  right: "left",
50
50
  // The band as a whole faces the top strip: either half of it takes the same height off.
51
- top: mn,
51
+ top: _n,
52
52
  bottomLeft: "top",
53
53
  bottomRight: "top"
54
54
  };
55
- function bn(n, t, e) {
55
+ function In(n, t, e) {
56
56
  return Math.min(Math.max(n, t), e);
57
57
  }
58
- function yn(n, t, e) {
59
- const o = Math.max(F, Math.round(t - e - gn));
60
- return bn(Math.round(n), F, o);
58
+ function xn(n, t, e) {
59
+ const o = Math.max(B, Math.round(t - e - Pn));
60
+ return In(Math.round(n), B, o);
61
61
  }
62
62
  function D(n, t) {
63
- const e = Math.max(R, Math.round(t - R));
64
- return bn(Math.round(n), R, e);
65
- }
66
- function H(n, t) {
67
- const e = n[t];
68
- return e !== void 0 && (e.primary !== void 0 || e.secondary !== void 0);
69
- }
70
- function Fn(n) {
71
- return H(n, "bottomLeft") || H(n, "bottomRight");
72
- }
73
- function vn(n, t, e, o) {
74
- return (U(e) ? Fn(t) : H(t, e)) ? n.sizes[A(e)] ?? o(e) : 0;
75
- }
76
- function An(n, t, e, o, s) {
77
- const r = { ...n.sizes }, i = { ...n.splits };
78
- for (const l of C) {
79
- const u = r[l];
80
- if (u === void 0) continue;
81
- const a = E(l) ? o : e;
82
- r[l] = yn(u, a, vn(n, t, M[l], s));
83
- const f = i[l];
84
- f !== void 0 && (i[l] = D(f, E(l) ? e : o));
63
+ const e = Math.max(Z, Math.round(t - Z));
64
+ return In(Math.round(n), Z, e);
65
+ }
66
+ function Cn(n, t, e, o) {
67
+ return e(t) ? n.sizes[k(t)] ?? o(t) : 0;
68
+ }
69
+ function Gn(n, t, e, o, c) {
70
+ const s = { ...n.sizes }, r = { ...n.splits };
71
+ for (const l of U) {
72
+ const a = s[l];
73
+ if (a !== void 0) {
74
+ const f = M(l) ? e : t, h = Cn(n, x[l], o, c);
75
+ s[l] = xn(a, f, h);
76
+ }
77
+ const d = r[l];
78
+ d !== void 0 && (r[l] = D(d, M(l) ? t : e));
85
79
  }
86
- const c = n.bandSplit === void 0 ? void 0 : D(n.bandSplit, e);
87
- return { sizes: r, splits: i, bandSplit: c };
88
- }
89
- function Dn(n, t, e) {
90
- const o = e - gn, s = n + t;
91
- if (s <= o) return [n, t];
92
- const r = (u) => u === 0 ? 0 : F, i = r(n) + r(t);
93
- if (o <= i)
94
- return [Math.min(n, r(n)), Math.min(t, r(t))];
95
- const c = o / s, l = Math.max(r(n), Math.round(n * c));
96
- return [l, Math.max(r(t), Math.round(o - l))];
80
+ const i = n.bandSplit === void 0 ? void 0 : D(n.bandSplit, t);
81
+ return { sizes: s, splits: r, bandSplit: i };
97
82
  }
98
- function Hn(n, t, e) {
99
- return n.find((o) => o.zone === t && o.slot === e)?.id;
100
- }
101
- function N(n, t) {
102
- return t === void 0 ? void 0 : n.find((e) => e.id === t);
103
- }
104
- function Z(n, t) {
105
- const e = n.open[t], o = e?.primary;
106
- return o !== void 0 && N(n.registry, o)?.solo === !0 ? { primary: o } : { primary: o, secondary: e?.secondary };
107
- }
108
- function jn(n, t) {
109
- return U(t) ? kn.some((e) => W(n, e)) : W(n, t);
110
- }
111
- function W(n, t) {
112
- const e = Z(n, t);
83
+ function Jn(n, t, e) {
84
+ const o = e - Pn, c = n + t;
85
+ if (c <= o) return [n, t];
86
+ const s = (a) => a === 0 ? 0 : B, r = s(n) + s(t);
87
+ if (o <= r)
88
+ return [Math.min(n, s(n)), Math.min(t, s(t))];
89
+ const i = o / c, l = Math.max(s(n), Math.round(n * i));
90
+ return [l, Math.max(s(t), Math.round(o - l))];
91
+ }
92
+ function z(n) {
93
+ return n.views[n.view] ?? {};
94
+ }
95
+ function $(n, t) {
96
+ const e = { ...t ?? {} };
97
+ for (const o of U)
98
+ for (const c of Nn)
99
+ e[o]?.[c] === void 0 && Zn(n, o, c) !== void 0 && (e[o] = { ...e[o], [c]: null });
100
+ return e;
101
+ }
102
+ function J(n, t) {
103
+ return Object.hasOwn(n.views, t);
104
+ }
105
+ function Zn(n, t, e) {
106
+ return n.find((o) => o.zone === t && o.slot === e);
107
+ }
108
+ function C(n, t) {
109
+ return t == null ? void 0 : n.find((e) => e.id === t);
110
+ }
111
+ function dn(n, t, e) {
112
+ const o = z(n)[t];
113
+ if (!o || !(e in o)) return;
114
+ const c = C(n.registry, o[e]);
115
+ return c?.zone === t && c.slot === e ? c : Zn(n.registry, t, e);
116
+ }
117
+ function E(n, t) {
118
+ const e = dn(n, t, "primary");
119
+ return e?.solo === !0 ? { primary: e } : { primary: e, secondary: dn(n, t, "secondary") };
120
+ }
121
+ function L(n, t) {
122
+ const { primary: e, secondary: o } = E(n, t);
123
+ return { primary: e?.id, secondary: o?.id };
124
+ }
125
+ function X(n, t) {
126
+ return rn(t) ? $n.some((e) => j(n, e)) : j(n, t);
127
+ }
128
+ function j(n, t) {
129
+ const e = L(n, t);
113
130
  return e.primary !== void 0 || e.secondary !== void 0;
114
131
  }
115
- function G(n, t, e) {
116
- return Math.max(Bn[t], N(n, e)?.opens ?? 0);
117
- }
118
- function Un(n, t, e, o) {
119
- const s = n.open[t] ?? {}, r = { ...n.stashed };
120
- if (N(n.registry, o)?.solo === !0)
121
- return r[t] = s, [{ [e]: o }, r];
122
- const i = s.primary;
123
- if (!(i !== void 0 && N(n.registry, i)?.solo === !0)) return [{ ...s, [e]: o }, n.stashed];
124
- const l = r[t] ?? {};
125
- return delete r[t], [{ ...l, [e]: o }, r];
126
- }
127
- function Yn(n, t, e) {
128
- const o = n.open[t] ?? {}, s = o[e], r = n.stashed[t];
129
- if (r && s !== void 0 && N(n.registry, s)?.solo === !0) {
130
- const c = { ...n.stashed };
131
- return delete c[t], [r, c];
132
+ function K(n, t) {
133
+ return Math.max(Wn[n], t?.opens ?? 0);
134
+ }
135
+ function Xn(n, t, e, o) {
136
+ const { slot: c, id: s } = e, r = z(n)[t] ?? {}, i = { ...n.stashed };
137
+ if (e.solo === !0 && c === "primary")
138
+ return i[t] = r, [{ [c]: s }, i];
139
+ if (o?.solo !== !0) return [{ ...r, [c]: s }, n.stashed];
140
+ const l = i[t];
141
+ if (delete i[t], l) return [{ ...l, [c]: s }, i];
142
+ const a = { ...r, [c]: s };
143
+ return c !== o.slot && delete a[o.slot], [a, i];
144
+ }
145
+ function Kn(n, t, e) {
146
+ const o = z(n)[t] ?? {}, c = o[e], s = n.stashed[t];
147
+ if (s && c !== void 0 && C(n.registry, c)?.solo === !0) {
148
+ const i = { ...n.stashed };
149
+ return delete i[t], [s, i];
132
150
  }
133
- const i = { ...o };
134
- return delete i[e], [i, n.stashed];
135
- }
136
- const rn = { sizes: {}, splits: {} };
137
- function $n(n = {}) {
138
- const t = n.initial;
139
- return Ln()((e, o) => ({
151
+ const r = { ...o };
152
+ return delete r[e], [r, n.stashed];
153
+ }
154
+ const fn = { sizes: {}, splits: {} };
155
+ function qn(n = {}) {
156
+ const t = n.initial, e = (o, c) => ({
157
+ ...o.views,
158
+ [o.view]: c
159
+ });
160
+ return Un()((o, c) => ({
140
161
  registry: [],
141
- open: t?.open ?? {},
142
- lengths: t?.lengths ?? rn,
162
+ view: n.view ?? on,
163
+ views: t?.views ?? {},
164
+ lengths: t?.lengths ?? fn,
143
165
  focusedZone: null,
144
166
  stashed: {},
145
- settled: t?.open !== void 0,
146
167
  available: { width: 0, height: 0 },
147
- register: (s) => e((r) => ({ registry: [...r.registry.filter((c) => c.id !== s.id), s] })),
148
- unregister: (s) => e((r) => {
149
- const i = { ...r.open };
150
- for (const c of C) {
151
- const l = i[c];
152
- if (l)
153
- for (const u of $) {
154
- if (l[u] !== s) continue;
155
- const a = { ...l };
156
- delete a[u], i[c] = a;
157
- }
158
- }
159
- return { registry: r.registry.filter((c) => c.id !== s), open: i };
168
+ // The arrangement is left ALONE by a panel leaving the list: the half naming it falls back
169
+ // to what is still declared — see `resolve` — and names it again the day it comes back.
170
+ declare: (s) => o({ registry: s }),
171
+ // Having an entry in `views` IS the record of having been settled. No second field can then
172
+ // disagree about which views have been opened, or fall out of step when a reset clears them.
173
+ // Having an entry in `views` IS the record of having been settled. No second field can then
174
+ // disagree about which views have been opened, or fall out of step when a reset clears them.
175
+ settle: (s) => o((r) => {
176
+ const i = s ?? r.defaults;
177
+ return J(r, r.view) ? i === r.defaults ? r : { defaults: i } : { views: e(r, $(r.registry, i)), defaults: i };
160
178
  }),
161
- settle: (s) => e((r) => {
162
- if (r.settled) return r;
163
- const i = { ...s ?? {} };
164
- for (const c of C)
165
- for (const l of $) {
166
- if (i[c]?.[l] !== void 0) continue;
167
- const u = Hn(r.registry, c, l);
168
- u !== void 0 && (i[c] = { ...i[c] ?? {}, [l]: u });
169
- }
170
- return { open: i, settled: !0 };
179
+ // Settles the view it arrives at, rather than leaving that to the next render: a project
180
+ // driving the chassis from outside React would otherwise land on an empty frame.
181
+ setView: (s) => o((r) => r.view === s ? r : {
182
+ view: s,
183
+ views: J(r, s) ? r.views : { ...r.views, [s]: $(r.registry, r.defaults) },
184
+ // Session state, and it belongs to the view being left: a zone accented on arrival is
185
+ // a zone nobody clicked, and a stash given back in another view would reopen a half
186
+ // there.
187
+ focusedZone: null,
188
+ stashed: {}
171
189
  }),
172
- show: (s) => e((r) => {
173
- const i = N(r.registry, s);
190
+ show: (s) => o((r) => {
191
+ const i = C(r.registry, s);
174
192
  if (!i) return r;
175
- const { zone: c, slot: l } = i;
176
- if (r.open[c]?.[l] === s) return { focusedZone: c };
177
- const [u, a] = Un(r, c, l, s);
178
- return { open: { ...r.open, [c]: u }, stashed: a, focusedZone: c };
193
+ const { zone: l } = i, a = E(r, l);
194
+ if (a[i.slot]?.id === s) return { focusedZone: l };
195
+ const [d, f] = Xn(r, l, i, a.primary);
196
+ return {
197
+ views: e(r, { ...z(r), [l]: d }),
198
+ stashed: f,
199
+ focusedZone: l
200
+ };
179
201
  }),
180
- close: (s, r) => e((i) => {
181
- const [c, l] = Yn(i, s, r), u = { ...i.open, [s]: c };
202
+ close: (s, r) => o((i) => {
203
+ const [l, a] = Kn(i, s, r), d = e(i, { ...z(i), [s]: l }), f = j({ registry: i.registry, view: i.view, views: d }, s);
182
204
  return {
183
- open: u,
184
- stashed: l,
185
- focusedZone: !H(u, s) && i.focusedZone === s ? null : i.focusedZone
205
+ views: d,
206
+ stashed: a,
207
+ focusedZone: !f && i.focusedZone === s ? null : i.focusedZone
186
208
  };
187
209
  }),
188
210
  toggle: (s) => {
189
- const r = o(), i = N(r.registry, s);
190
- if (!i) return;
191
- Z(r, i.zone)[i.slot] === s ? r.close(i.zone, i.slot) : r.show(s);
211
+ const r = c(), i = C(r.registry, s);
212
+ i && (L(r, i.zone)[i.slot] === s ? r.close(i.zone, i.slot) : r.show(s));
192
213
  },
193
- focus: (s) => e((r) => r.focusedZone === s ? r : { focusedZone: s }),
214
+ focus: (s) => o((r) => r.focusedZone === s ? r : { focusedZone: s }),
194
215
  // Guarded: a drag past the ceiling clamps to the same number for as long as the pointer
195
216
  // keeps going, and every write notifies every subscriber.
196
- resize: (s, r, i) => e((c) => {
197
- const l = vn(
198
- c.lengths,
199
- c.open,
200
- M[s],
201
- (f) => G(c.registry, f, Z(c, f).primary)
202
- ), u = yn(r, i, l), a = A(s);
203
- return u === c.lengths.sizes[a] ? c : { lengths: { ...c.lengths, sizes: { ...c.lengths.sizes, [a]: u } } };
217
+ resize: (s, r, i) => o((l) => {
218
+ const a = Cn(
219
+ l.lengths,
220
+ x[s],
221
+ (h) => X(l, h),
222
+ (h) => K(h, E(l, h).primary)
223
+ ), d = xn(r, i, a), f = k(s);
224
+ return d === l.lengths.sizes[f] ? l : { lengths: { ...l.lengths, sizes: { ...l.lengths.sizes, [f]: d } } };
204
225
  }),
205
- resplit: (s, r, i) => e((c) => {
206
- const l = D(r, i);
207
- return l === c.lengths.splits[s] ? c : { lengths: { ...c.lengths, splits: { ...c.lengths.splits, [s]: l } } };
226
+ resplit: (s, r, i) => o((l) => {
227
+ const a = D(r, i);
228
+ return a === l.lengths.splits[s] ? l : { lengths: { ...l.lengths, splits: { ...l.lengths.splits, [s]: a } } };
208
229
  }),
209
- resplitBand: (s, r) => e((i) => {
210
- const c = D(s, r);
211
- return c === i.lengths.bandSplit ? i : { lengths: { ...i.lengths, bandSplit: c } };
230
+ resplitBand: (s, r) => o((i) => {
231
+ const l = D(s, r);
232
+ return l === i.lengths.bandSplit ? i : { lengths: { ...i.lengths, bandSplit: l } };
212
233
  }),
213
- fit: (s, r) => e((i) => ({
234
+ fit: (s, r) => o((i) => ({
214
235
  available: { width: s, height: r },
215
- lengths: An(
236
+ lengths: Gn(
216
237
  i.lengths,
217
- i.open,
218
238
  s,
219
239
  r,
220
- (c) => G(i.registry, c, Z(i, c).primary)
240
+ (l) => X(i, l),
241
+ (l) => K(l, E(i, l).primary)
221
242
  )
222
243
  })),
223
- reset: () => e((s) => ({
224
- open: {},
225
- lengths: rn,
244
+ // Every view, not just the one in front: a reset the reader asked for must not leave the
245
+ // arrangement they were escaping waiting for them one click away.
246
+ reset: () => o((s) => ({
247
+ // The view in front is settled on the spot, not left for the next render: nothing
248
+ // re-renders the provider when a button inside the chassis is what asked for the reset,
249
+ // so the frame stayed blank — and the arrangement being escaped stayed on disk.
250
+ //
251
+ // 🛑 Unless nothing is declared yet, and then it is left UNSETTLED: settled against an
252
+ // empty registry it would be settled EMPTY, and having an entry is what stops anything
253
+ // reopening it. Every half would stay shut for good.
254
+ views: s.registry.length === 0 ? {} : { [s.view]: $(s.registry, s.defaults) },
255
+ lengths: fn,
226
256
  focusedZone: null,
227
257
  // Left behind, a solo panel closed after a reset would give back the zone the reset
228
258
  // had just cleared.
229
259
  stashed: {},
230
- settled: !1,
231
260
  registry: s.registry
232
261
  }))
233
262
  }));
234
263
  }
235
- const mt = () => {
264
+ const Ct = () => {
236
265
  const n = /* @__PURE__ */ new Map();
237
266
  return {
238
267
  read: (t) => n.get(t) ?? null,
@@ -240,7 +269,7 @@ const mt = () => {
240
269
  n.set(t, e);
241
270
  }
242
271
  };
243
- }, Vn = () => ({
272
+ }, Qn = () => ({
244
273
  read: (n) => {
245
274
  try {
246
275
  return globalThis.localStorage?.getItem(n) ?? null;
@@ -254,134 +283,197 @@ const mt = () => {
254
283
  } catch {
255
284
  }
256
285
  }
257
- }), Sn = 1;
258
- function I(n) {
286
+ }), En = 2;
287
+ function P(n) {
259
288
  return typeof n == "object" && n !== null && !Array.isArray(n);
260
289
  }
261
- function Wn(n) {
290
+ function hn(n) {
262
291
  const t = {};
263
- for (const e of C) {
292
+ for (const e of U) {
264
293
  const o = n[e];
265
- if (I(o))
266
- for (const s of $) {
267
- const r = o[s];
268
- typeof r == "string" && (t[e] = { ...t[e], [s]: r });
294
+ if (P(o))
295
+ for (const c of Nn) {
296
+ const s = o[c];
297
+ s !== null && typeof s != "string" || (t[e] = { ...t[e], [c]: s });
269
298
  }
270
299
  }
271
300
  return t;
272
301
  }
273
- function sn(n) {
302
+ function pn(n) {
274
303
  const t = {};
275
- for (const e of C) {
304
+ for (const e of U) {
276
305
  const o = n[e];
277
306
  typeof o == "number" && Number.isFinite(o) && (t[e] = o);
278
307
  }
279
308
  return t;
280
309
  }
281
- function Gn(n, t) {
282
- const e = n.read(t);
283
- if (e === null) return;
284
- let o;
310
+ function nt(n, t) {
311
+ if (n.version === 1)
312
+ return P(n.open) ? { [t]: hn(n.open) } : void 0;
313
+ if (n.version !== En || !P(n.views)) return;
314
+ const e = /* @__PURE__ */ Object.create(null);
315
+ for (const [o, c] of Object.entries(n.views))
316
+ P(c) && (e[o] = hn(c));
317
+ return e;
318
+ }
319
+ function tt(n, t, e = on) {
320
+ const o = n.read(t);
321
+ if (o === null) return;
322
+ let c;
285
323
  try {
286
- o = JSON.parse(e);
324
+ c = JSON.parse(o);
287
325
  } catch {
288
326
  return;
289
327
  }
290
- if (!I(o) || o.version !== Sn || !I(o.open) || !I(o.lengths)) return;
291
- const s = o.lengths;
292
- if (!I(s.sizes) || !I(s.splits)) return;
293
- const r = s.bandSplit;
328
+ if (!P(c) || !P(c.lengths)) return;
329
+ const s = nt(c, e);
330
+ if (!s) return;
331
+ const r = c.lengths;
332
+ if (!P(r.sizes) || !P(r.splits)) return;
333
+ const i = r.bandSplit;
294
334
  return {
295
- open: Wn(o.open),
335
+ views: s,
296
336
  lengths: {
297
- sizes: sn(s.sizes),
298
- splits: sn(s.splits),
299
- bandSplit: typeof r == "number" && Number.isFinite(r) ? r : void 0
337
+ sizes: pn(r.sizes),
338
+ splits: pn(r.splits),
339
+ bandSplit: typeof i == "number" && Number.isFinite(i) ? i : void 0
300
340
  }
301
341
  };
302
342
  }
303
- function Jn(n, t, e) {
304
- const o = { version: Sn, ...e };
343
+ function et(n, t, e) {
344
+ const o = {
345
+ version: En,
346
+ views: e.views,
347
+ lengths: e.lengths
348
+ };
305
349
  n.write(t, JSON.stringify(o));
306
350
  }
307
- const wn = typeof globalThis.document > "u" ? K : Mn, Nn = pn(null);
308
- function Xn({
351
+ const Mn = typeof globalThis.document > "u" ? nn : kn, zn = en(null);
352
+ function ot({
309
353
  store: n,
310
354
  storageKey: t = "panels:layout",
311
355
  storage: e,
312
356
  defaultOpen: o,
357
+ view: c,
313
358
  children: s
314
359
  }) {
315
- const [r] = tn(
316
- () => e === null ? null : e ?? Vn()
317
- ), [i] = tn(
318
- () => n ?? $n({
319
- initial: r ? Gn(r, t) : void 0
320
- })
321
- );
322
- return wn(() => {
323
- i.getState().settle(o);
324
- }, [i, o]), K(() => {
325
- if (r)
326
- return i.subscribe((c) => {
327
- c.settled && Jn(r, t, { open: c.open, lengths: c.lengths });
328
- });
329
- }, [r, i, t]), /* @__PURE__ */ d(Nn.Provider, { value: i, children: s });
330
- }
331
- function L() {
332
- const n = fn(Nn);
360
+ const [r] = W(
361
+ () => e === null ? null : e ?? Qn()
362
+ ), [i] = W(() => {
363
+ const l = c ?? on, a = r ? tt(r, t, l) : void 0;
364
+ return n ? (a && n.setState(a), n) : qn({ view: l, initial: a });
365
+ });
366
+ return Mn(() => {
367
+ const l = i.getState();
368
+ c !== void 0 && l.setView(c), l.settle(o);
369
+ }), nn(() => {
370
+ if (!r) return;
371
+ let l;
372
+ return i.subscribe((a) => {
373
+ J(a, a.view) && (l?.views === a.views && l.lengths === a.lengths || (l = { views: a.views, lengths: a.lengths }, et(r, t, a)));
374
+ });
375
+ }, [r, i, t]), /* @__PURE__ */ u(zn.Provider, { value: i, children: s });
376
+ }
377
+ function O() {
378
+ const n = tn(zn);
333
379
  if (!n) throw new Error("usePanelsStore must be used inside a <Panels> or <PanelsProvider>");
334
380
  return n;
335
381
  }
336
- function S(n) {
337
- const t = L();
338
- return Tn(t, n);
382
+ function v(n) {
383
+ const t = O();
384
+ return Yn(t, n);
339
385
  }
340
- function O() {
341
- const n = L();
386
+ function R() {
387
+ const n = O();
342
388
  return w(() => {
343
- const { show: t, close: e, toggle: o, focus: s, resize: r, resplit: i, resplitBand: c, fit: l, reset: u } = n.getState();
344
- return { show: t, close: e, toggle: o, focus: s, resize: r, resplit: i, resplitBand: c, fit: l, reset: u };
389
+ const { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a } = n.getState();
390
+ return { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a };
345
391
  }, [n]);
346
392
  }
347
- function Kn(n) {
348
- const t = L();
349
- K(() => {
393
+ function rt({
394
+ icon: n,
395
+ label: t,
396
+ active: e,
397
+ accented: o,
398
+ acts: c,
399
+ className: s,
400
+ children: r,
401
+ ref: i,
402
+ ...l
403
+ }) {
404
+ return /* @__PURE__ */ g(
405
+ "button",
406
+ {
407
+ type: "button",
408
+ ref: i,
409
+ "aria-label": t,
410
+ "aria-pressed": c ? void 0 : e,
411
+ className: b(
412
+ "pnl-icon-button",
413
+ e && "pnl-icon-button--active",
414
+ o && "pnl-icon-button--accented",
415
+ s
416
+ ),
417
+ ...l,
418
+ children: [
419
+ n !== void 0 && /* @__PURE__ */ u("span", { className: "pnl-icon-button__glyph", children: n }),
420
+ r
421
+ ]
422
+ }
423
+ );
424
+ }
425
+ const q = { IconButton: rt }, Ln = en(q), st = Ln.Provider;
426
+ function On() {
427
+ return tn(Ln);
428
+ }
429
+ function it(n) {
430
+ return n === void 0 ? q : { ...q, ...n };
431
+ }
432
+ function ct(n) {
433
+ const t = O();
434
+ nn(() => {
350
435
  const e = n.current;
351
436
  if (!e) return;
352
437
  const o = () => {
353
- const { clientWidth: r, clientHeight: i } = e;
354
- r === 0 || i === 0 || t.getState().fit(r, i);
438
+ const { clientWidth: s, clientHeight: r } = e;
439
+ s === 0 || r === 0 || t.getState().fit(s, r);
355
440
  };
356
441
  if (o(), typeof ResizeObserver > "u") return;
357
- const s = new ResizeObserver(o);
358
- return s.observe(e), () => s.disconnect();
442
+ const c = new ResizeObserver(o);
443
+ return c.observe(e), () => c.disconnect();
359
444
  }, [n, t]);
360
445
  }
361
446
  function T() {
362
- const n = S((e) => e.registry), t = S((e) => e.open);
363
- return w(() => ({ registry: n, open: t }), [n, t]);
447
+ const n = v((o) => o.registry), t = v((o) => o.view), e = v((o) => o.views[o.view]);
448
+ return w(
449
+ () => ({ registry: n, view: t, views: e === void 0 ? {} : { [t]: e } }),
450
+ [n, t, e]
451
+ );
364
452
  }
365
- function J(n) {
453
+ function lt(n) {
366
454
  const t = T();
367
- return w(() => Z(t, n), [t, n]);
455
+ return w(() => L(t, n), [t, n]);
368
456
  }
369
- function cn(n) {
457
+ function gn(n) {
370
458
  const t = T();
371
- return w(() => W(t, n), [t, n]);
459
+ return w(() => E(t, n), [t, n]);
372
460
  }
373
- function qn(n) {
461
+ function mn(n) {
374
462
  const t = T();
375
- return w(() => jn(t, n), [t, n]);
463
+ return w(() => j(t, n), [t, n]);
376
464
  }
377
- function Qn() {
465
+ function at(n) {
466
+ const t = T();
467
+ return w(() => X(t, n), [t, n]);
468
+ }
469
+ function ut() {
378
470
  return {
379
- left: cn(V.left.band),
380
- right: cn(V.right.band)
471
+ left: mn(G.left.band),
472
+ right: mn(G.right.band)
381
473
  };
382
474
  }
383
- function nt() {
384
- const n = j(null);
475
+ function dt() {
476
+ const n = H(null);
385
477
  return w(() => ({
386
478
  start: (e, o) => {
387
479
  e.currentTarget.setPointerCapture(e.pointerId), n.current = { ...o, pointerId: e.pointerId };
@@ -392,223 +484,174 @@ function nt() {
392
484
  }
393
485
  }), []);
394
486
  }
395
- function X({
487
+ function Q({
396
488
  axis: n,
397
489
  invert: t = !1,
398
490
  size: e,
399
491
  onSize: o,
400
- measure: s,
401
- label: r,
402
- min: i,
403
- max: c,
492
+ measure: c,
493
+ label: s,
494
+ min: r,
495
+ max: i,
404
496
  step: l = 16,
405
- className: u
497
+ className: a
406
498
  }) {
407
- const a = nt(), f = j(null), p = n === "vertical", g = z(
408
- (h) => (p ? h?.clientHeight : h?.clientWidth) ?? 0,
409
- [p]
410
- ), b = z(
411
- (h) => {
412
- const y = a.matching(h);
413
- if (!y) return;
414
- const Y = (p ? h.clientY : h.clientX) - y.position;
415
- o(y.size + Y * (t ? -1 : 1), y.available);
499
+ const d = dt(), f = H(null), h = n === "vertical", m = _(
500
+ (p) => (h ? p?.clientHeight : p?.clientWidth) ?? 0,
501
+ [h]
502
+ ), I = _(
503
+ (p) => {
504
+ const S = d.matching(p);
505
+ if (!S) return;
506
+ const Y = (h ? p.clientY : p.clientX) - S.position;
507
+ o(S.size + Y * (t ? -1 : 1), S.available);
416
508
  },
417
- [a, t, p, o]
418
- ), P = z(
419
- (h) => {
420
- const y = p ? "ArrowUp" : "ArrowLeft", _ = p ? "ArrowDown" : "ArrowRight";
421
- if (h.key !== y && h.key !== _) return;
422
- const Y = g(f.current?.parentElement), Zn = e ?? s?.() ?? 0, In = h.key === _ ? 1 : -1;
423
- h.preventDefault(), o(Zn + l * In * (t ? -1 : 1), Y);
509
+ [d, t, h, o]
510
+ ), y = _(
511
+ (p) => {
512
+ const S = h ? "ArrowUp" : "ArrowLeft", V = h ? "ArrowDown" : "ArrowRight";
513
+ if (p.key !== S && p.key !== V) return;
514
+ const Y = m(f.current?.parentElement), An = e ?? c?.() ?? 0, Bn = p.key === V ? 1 : -1;
515
+ p.preventDefault(), o(An + l * Bn * (t ? -1 : 1), Y);
424
516
  },
425
- [t, p, s, o, g, e, l]
517
+ [t, h, c, o, m, e, l]
426
518
  );
427
- return /* @__PURE__ */ d(
519
+ return /* @__PURE__ */ u(
428
520
  "div",
429
521
  {
430
522
  ref: f,
431
523
  role: "separator",
432
524
  tabIndex: 0,
433
- "aria-label": r,
434
- "aria-orientation": p ? "horizontal" : "vertical",
525
+ "aria-label": s,
526
+ "aria-orientation": h ? "horizontal" : "vertical",
435
527
  "aria-valuenow": e === void 0 ? void 0 : Math.round(e),
436
- "aria-valuemin": i,
437
- "aria-valuemax": c,
438
- onPointerDown: (h) => {
439
- a.start(h, {
440
- position: p ? h.clientY : h.clientX,
441
- size: e ?? s?.() ?? 0,
442
- available: g(h.currentTarget.parentElement)
528
+ "aria-valuemin": r,
529
+ "aria-valuemax": i,
530
+ onPointerDown: (p) => {
531
+ d.start(p, {
532
+ position: h ? p.clientY : p.clientX,
533
+ size: e ?? c?.() ?? 0,
534
+ available: m(p.currentTarget.parentElement)
443
535
  });
444
536
  },
445
- onPointerMove: b,
446
- onPointerUp: a.cancel,
447
- onPointerCancel: a.cancel,
448
- onLostPointerCapture: a.cancel,
449
- onKeyDown: P,
450
- className: v("pnl-handle", p ? "pnl-handle--row" : "pnl-handle--col", u)
537
+ onPointerMove: I,
538
+ onPointerUp: d.cancel,
539
+ onPointerCancel: d.cancel,
540
+ onLostPointerCapture: d.cancel,
541
+ onKeyDown: y,
542
+ className: b("pnl-handle", h ? "pnl-handle--row" : "pnl-handle--col", a)
451
543
  }
452
544
  );
453
545
  }
454
- function ln(n, t, e, o, s) {
455
- return s ? e ?? G(n, o, t) : 0;
456
- }
457
- function tt(n) {
458
- const t = T(), e = J(n), o = J(M[n]), s = qn(M[n]), r = S(
459
- (a) => a.lengths.sizes[A(n)]
460
- ), i = S(
461
- (a) => a.lengths.sizes[A(M[n])]
462
- ), c = S((a) => a.lengths.splits[n]), l = S(
463
- (a) => E(n) ? a.available.height : a.available.width
464
- ), u = S((a) => a.focusedZone === n);
546
+ function vn(n, t, e, o) {
547
+ return o ? t ?? K(e, n) : 0;
548
+ }
549
+ function ft(n) {
550
+ const t = gn(n), e = gn(x[n]), o = at(x[n]), c = v(
551
+ (a) => a.lengths.sizes[k(n)]
552
+ ), s = v(
553
+ (a) => a.lengths.sizes[k(x[n])]
554
+ ), r = v((a) => a.lengths.splits[n]), i = v(
555
+ (a) => M(n) ? a.available.height : a.available.width
556
+ ), l = v((a) => a.focusedZone === n);
465
557
  return w(() => {
466
- const { registry: a } = t, f = N(a, e.primary), p = N(a, e.secondary), g = f !== void 0 || p !== void 0, b = ln(a, e.primary, r, n, g), P = ln(
467
- a,
468
- o.primary,
469
- i,
470
- M[n],
471
- s
472
- );
558
+ const { primary: a, secondary: d } = t, f = a !== void 0 || d !== void 0, h = vn(a, c, n, f), m = vn(e.primary, s, x[n], o);
473
559
  return {
474
- primary: f,
475
- secondary: p,
476
- draws: g,
560
+ primary: a,
561
+ secondary: d,
562
+ draws: f,
477
563
  // Zero until the container has been measured: bounding against nothing would collapse
478
564
  // every zone to its floor on the very first paint.
479
- size: l === 0 ? b : Dn(b, P, l)[0],
480
- split: c,
481
- focused: u
565
+ size: i === 0 ? h : Jn(h, m, i)[0],
566
+ split: r,
567
+ focused: l
482
568
  };
483
- }, [
484
- t,
485
- e,
486
- o,
487
- s,
488
- r,
489
- i,
490
- l,
491
- c,
492
- u,
493
- n
494
- ]);
495
- }
496
- function et(n) {
497
- const t = S((e) => e.registry);
569
+ }, [t, e, o, c, s, i, r, l, n]);
570
+ }
571
+ function ht(n) {
572
+ const t = v((e) => e.registry);
498
573
  return w(() => [
499
574
  ["primary", t.filter((o) => o.zone === n && o.slot === "primary")],
500
575
  ["secondary", t.filter((o) => o.zone === n && o.slot === "secondary")]
501
576
  ].filter(([, o]) => o.length > 0), [t, n]);
502
577
  }
503
- const Pn = pn(/* @__PURE__ */ new Map()), ot = Pn.Provider;
504
- function rt(n) {
505
- return fn(Pn).get(n);
578
+ const Rn = en(/* @__PURE__ */ new Map()), pt = Rn.Provider;
579
+ function gt(n) {
580
+ return tn(Rn).get(n);
506
581
  }
507
- function st({
582
+ function mt({
508
583
  title: n,
509
584
  children: t,
510
585
  fillActions: e,
511
586
  trailing: o,
512
- className: s
587
+ className: c
513
588
  }) {
514
- return /* @__PURE__ */ m("header", { className: v("pnl-header", s), children: [
515
- /* @__PURE__ */ d("span", { className: v("pnl-header__title", e && "pnl-header__title--fixed"), children: n }),
516
- /* @__PURE__ */ d("span", { className: v("pnl-header__actions", e && "pnl-header__actions--fill"), children: t }),
517
- /* @__PURE__ */ d("span", { className: "pnl-header__trailing", children: o })
589
+ return /* @__PURE__ */ g("header", { className: b("pnl-header", c), children: [
590
+ /* @__PURE__ */ u("span", { className: b("pnl-header__title", e && "pnl-header__title--fixed"), children: n }),
591
+ /* @__PURE__ */ u("span", { className: b("pnl-header__actions", e && "pnl-header__actions--fill"), children: t }),
592
+ /* @__PURE__ */ u("span", { className: "pnl-header__trailing", children: o })
518
593
  ] });
519
594
  }
520
- function q({ orientation: n = "vertical", className: t }) {
521
- return /* @__PURE__ */ d(
595
+ function sn({ orientation: n = "vertical", className: t }) {
596
+ return /* @__PURE__ */ u(
522
597
  "span",
523
598
  {
524
599
  "aria-hidden": "true",
525
- className: v("pnl-separator", `pnl-separator--${n}`, t)
600
+ className: b("pnl-separator", `pnl-separator--${n}`, t)
526
601
  }
527
602
  );
528
603
  }
529
- function _n({ children: n, className: t, ...e }) {
530
- return /* @__PURE__ */ d("section", { className: v("pnl-surface", t), ...e, children: n });
531
- }
532
- function xn({
533
- icon: n,
534
- label: t,
535
- active: e,
536
- accented: o,
537
- acts: s,
538
- className: r,
539
- children: i,
540
- ref: c,
541
- ...l
542
- }) {
543
- return /* @__PURE__ */ m(
544
- "button",
545
- {
546
- type: "button",
547
- ref: c,
548
- "aria-label": t,
549
- "aria-pressed": s ? void 0 : e,
550
- className: v(
551
- "pnl-icon-button",
552
- e && "pnl-icon-button--active",
553
- o && "pnl-icon-button--accented",
554
- r
555
- ),
556
- ...l,
557
- children: [
558
- n !== void 0 && /* @__PURE__ */ d("span", { className: "pnl-icon-button__glyph", children: n }),
559
- i
560
- ]
561
- }
562
- );
604
+ function Tn({ children: n, className: t, ...e }) {
605
+ return /* @__PURE__ */ u("section", { className: b("pnl-surface", t), ...e, children: n });
563
606
  }
564
- function it({
607
+ function vt({
565
608
  panel: n,
566
609
  length: t,
567
610
  closeLabel: e,
568
611
  onFocus: o
569
612
  }) {
570
- const { close: s } = O(), r = rt(n.id);
613
+ const { close: c } = R(), { IconButton: s } = On(), r = gt(n.id);
571
614
  return (
572
615
  // The zone owns its length: a half given one keeps it, the other takes what is left. Both
573
616
  // sized here would make the pair overflow the zone the user dragged.
574
- /* @__PURE__ */ m(
575
- _n,
617
+ /* @__PURE__ */ g(
618
+ Tn,
576
619
  {
577
620
  "aria-label": n.title,
578
621
  onPointerDownCapture: o,
579
622
  className: t === void 0 ? "pnl-surface--fill" : "pnl-surface--give",
580
623
  style: t === void 0 ? void 0 : { flexBasis: t },
581
624
  children: [
582
- /* @__PURE__ */ d(
583
- st,
625
+ /* @__PURE__ */ u(
626
+ mt,
584
627
  {
585
628
  title: n.title,
586
- fillActions: r?.actions !== void 0 && E(n.zone),
587
- trailing: /* @__PURE__ */ m(B, { children: [
588
- r?.actions !== void 0 && /* @__PURE__ */ d(q, {}),
589
- /* @__PURE__ */ d(
590
- xn,
629
+ fillActions: n.fillActions ?? (r?.actions !== void 0 && M(n.zone)),
630
+ trailing: /* @__PURE__ */ g(A, { children: [
631
+ r?.actions !== void 0 && /* @__PURE__ */ u(sn, {}),
632
+ /* @__PURE__ */ u(
633
+ s,
591
634
  {
592
635
  label: e,
593
636
  acts: !0,
594
- onClick: () => s(n.zone, n.slot),
637
+ onClick: () => c(n.zone, n.slot),
595
638
  className: "pnl-icon-button--header",
596
- icon: /* @__PURE__ */ d(ct, {})
639
+ icon: /* @__PURE__ */ u(bt, {})
597
640
  }
598
641
  )
599
642
  ] }),
600
643
  children: r?.actions
601
644
  }
602
645
  ),
603
- /* @__PURE__ */ d("div", { className: v("pnl-body"), children: r?.content })
646
+ /* @__PURE__ */ u("div", { className: b("pnl-body"), children: r?.content })
604
647
  ]
605
648
  }
606
649
  )
607
650
  );
608
651
  }
609
- const an = hn(it);
610
- function ct() {
611
- return /* @__PURE__ */ d("svg", { viewBox: "0 0 24 24", width: "14", height: "14", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d(
652
+ const bn = Sn(vt);
653
+ function bt() {
654
+ return /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", width: "14", height: "14", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ u(
612
655
  "path",
613
656
  {
614
657
  fill: "currentColor",
@@ -616,248 +659,247 @@ function ct() {
616
659
  }
617
660
  ) });
618
661
  }
619
- function lt({ zone: n, labels: t }) {
620
- const e = tt(n), { focus: o, resize: s, resplit: r } = O(), i = j(null), c = z(() => o(n), [o, n]), l = E(n), u = z(
621
- () => l ? i.current?.clientHeight ?? 0 : i.current?.clientWidth ?? 0,
662
+ function wt({ zone: n, labels: t }) {
663
+ const e = ft(n), { focus: o, resize: c, resplit: s } = R(), r = H(null), i = _(() => o(n), [o, n]), l = M(n), a = _(
664
+ () => l ? r.current?.clientHeight ?? 0 : r.current?.clientWidth ?? 0,
622
665
  [l]
623
666
  );
624
667
  if (!e.draws) return null;
625
- const { primary: a, secondary: f, size: p, split: g } = e, b = /* @__PURE__ */ m(
668
+ const { primary: d, secondary: f, size: h, split: m } = e, I = /* @__PURE__ */ g(
626
669
  "div",
627
670
  {
628
- ref: i,
629
- className: v("pnl-zone", l ? "pnl-zone--row" : "pnl-zone--col"),
630
- style: { [l ? "height" : "width"]: p },
671
+ ref: r,
672
+ className: b("pnl-zone", l ? "pnl-zone--row" : "pnl-zone--col"),
673
+ style: { [l ? "height" : "width"]: h },
631
674
  children: [
632
- a && /* @__PURE__ */ d(an, { panel: a, closeLabel: t.closePanel, onFocus: c }),
633
- a && f && /* @__PURE__ */ d(
634
- X,
675
+ d && /* @__PURE__ */ u(bn, { panel: d, closeLabel: t.closePanel, onFocus: i }),
676
+ d && f && /* @__PURE__ */ u(
677
+ Q,
635
678
  {
636
679
  axis: l ? "horizontal" : "vertical",
637
680
  invert: !0,
638
- size: g,
639
- min: R,
681
+ size: m,
682
+ min: Z,
640
683
  label: t.resizeSplit,
641
- onSize: (h, y) => r(n, h, y)
684
+ onSize: (p, S) => s(n, p, S)
642
685
  }
643
686
  ),
644
- f && /* @__PURE__ */ d(
645
- an,
687
+ f && /* @__PURE__ */ u(
688
+ bn,
646
689
  {
647
690
  panel: f,
648
- length: a && g !== void 0 ? g : void 0,
691
+ length: d && m !== void 0 ? m : void 0,
649
692
  closeLabel: t.closePanel,
650
- onFocus: c
693
+ onFocus: i
651
694
  }
652
695
  )
653
696
  ]
654
697
  }
655
- ), P = /* @__PURE__ */ d(
656
- X,
698
+ ), y = /* @__PURE__ */ u(
699
+ Q,
657
700
  {
658
701
  axis: l ? "vertical" : "horizontal",
659
- invert: !on(n),
660
- size: p,
661
- min: F,
662
- measure: u,
702
+ invert: !un(n),
703
+ size: h,
704
+ min: B,
705
+ measure: a,
663
706
  label: t.resizeZone,
664
- onSize: (h, y) => s(n, h, y)
707
+ onSize: (p, S) => c(n, p, S)
665
708
  }
666
709
  );
667
- return on(n) ? /* @__PURE__ */ m(B, { children: [
668
- b,
669
- P
670
- ] }) : /* @__PURE__ */ m(B, { children: [
671
- P,
672
- b
710
+ return un(n) ? /* @__PURE__ */ g(A, { children: [
711
+ I,
712
+ y
713
+ ] }) : /* @__PURE__ */ g(A, { children: [
714
+ y,
715
+ I
673
716
  ] });
674
717
  }
675
- const x = hn(lt);
676
- function at({ left: n, right: t, labels: e }) {
677
- const o = S((i) => i.lengths.bandSplit), { resplitBand: s } = O(), r = z(
678
- (i, c) => s(i, c),
679
- [s]
718
+ const N = Sn(wt);
719
+ function yt({ left: n, right: t, labels: e }) {
720
+ const o = v((r) => r.lengths.bandSplit), { resplitBand: c } = R(), s = _(
721
+ (r, i) => c(r, i),
722
+ [c]
680
723
  );
681
- return !n && !t ? null : !n || !t ? /* @__PURE__ */ d(x, { zone: n ? "bottomLeft" : "bottomRight", labels: e }) : /* @__PURE__ */ m("div", { className: "pnl-band", children: [
682
- /* @__PURE__ */ d(
724
+ return !n && !t ? null : !n || !t ? /* @__PURE__ */ u(N, { zone: n ? "bottomLeft" : "bottomRight", labels: e }) : /* @__PURE__ */ g("div", { className: "pnl-band", children: [
725
+ /* @__PURE__ */ u(
683
726
  "div",
684
727
  {
685
- className: v("pnl-band__half", o === void 0 && "pnl-band__half--even"),
728
+ className: b("pnl-band__half", o === void 0 && "pnl-band__half--even"),
686
729
  style: o === void 0 ? void 0 : { width: o },
687
- children: /* @__PURE__ */ d(x, { zone: "bottomLeft", labels: e })
730
+ children: /* @__PURE__ */ u(N, { zone: "bottomLeft", labels: e })
688
731
  }
689
732
  ),
690
- /* @__PURE__ */ d(
691
- X,
733
+ /* @__PURE__ */ u(
734
+ Q,
692
735
  {
693
736
  axis: "horizontal",
694
737
  size: o,
695
- min: R,
738
+ min: Z,
696
739
  label: e.resizeBand,
697
- onSize: r
740
+ onSize: s
698
741
  }
699
742
  ),
700
- /* @__PURE__ */ d("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ d(x, { zone: "bottomRight", labels: e }) })
743
+ /* @__PURE__ */ u("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ u(N, { zone: "bottomRight", labels: e }) })
701
744
  ] });
702
745
  }
703
- function Q(n) {
746
+ function cn(n) {
704
747
  return null;
705
748
  }
706
- Q.displayName = "Panels.Center";
707
- const ut = {
749
+ cn.displayName = "Panels.Center";
750
+ const St = {
708
751
  closePanel: "Close panel",
709
752
  resizeZone: "Resize panel area",
710
753
  resizeSplit: "Resize the two panels",
711
754
  resizeBand: "Resize the bottom panels"
712
755
  };
713
- function nn(n) {
756
+ function ln(n) {
714
757
  return null;
715
758
  }
716
- nn.displayName = "Panels.Panel";
717
- function un({ side: n, header: t, className: e }) {
718
- const { column: o, band: s } = V[n];
719
- return /* @__PURE__ */ m(
759
+ ln.displayName = "Panels.Panel";
760
+ function wn({ side: n, header: t, className: e }) {
761
+ const { column: o, band: c } = G[n];
762
+ return /* @__PURE__ */ g(
720
763
  "div",
721
764
  {
722
765
  role: "toolbar",
723
766
  "aria-orientation": "vertical",
724
- className: v("pnl-rail", `pnl-rail--${n}`, e),
767
+ className: b("pnl-rail", `pnl-rail--${n}`, e),
725
768
  children: [
726
- /* @__PURE__ */ m("div", { className: "pnl-rail__group", children: [
727
- t !== void 0 && /* @__PURE__ */ m(B, { children: [
769
+ /* @__PURE__ */ g("div", { className: "pnl-rail__group", children: [
770
+ t !== void 0 && /* @__PURE__ */ g(A, { children: [
728
771
  t,
729
- /* @__PURE__ */ d(q, { orientation: "horizontal" })
772
+ /* @__PURE__ */ u(sn, { orientation: "horizontal" })
730
773
  ] }),
731
- o.map((r) => /* @__PURE__ */ d(dn, { zone: r }, r))
774
+ o.map((s) => /* @__PURE__ */ u(yn, { zone: s }, s))
732
775
  ] }),
733
- /* @__PURE__ */ d(dn, { zone: s })
776
+ /* @__PURE__ */ u(yn, { zone: c })
734
777
  ]
735
778
  }
736
779
  );
737
780
  }
738
- function dn({ zone: n }) {
739
- const t = et(n), e = J(n), o = S((r) => r.focusedZone === n), { toggle: s } = O();
740
- return t.length === 0 ? null : /* @__PURE__ */ d("div", { className: "pnl-rail__group", children: t.map(([r, i], c) => /* @__PURE__ */ m(Rn, { children: [
741
- c > 0 && /* @__PURE__ */ d(q, { orientation: "horizontal" }),
742
- i.map((l) => {
743
- const u = e[r] === l.id;
744
- return /* @__PURE__ */ d(
745
- xn,
781
+ function yn({ zone: n }) {
782
+ const t = ht(n), e = lt(n), o = v((r) => r.focusedZone === n), { toggle: c } = R(), { IconButton: s } = On();
783
+ return t.length === 0 ? null : /* @__PURE__ */ u("div", { className: "pnl-rail__group", children: t.map(([r, i], l) => /* @__PURE__ */ g(Dn, { children: [
784
+ l > 0 && /* @__PURE__ */ u(sn, { orientation: "horizontal" }),
785
+ i.map((a) => {
786
+ const d = e[r] === a.id;
787
+ return /* @__PURE__ */ u(
788
+ s,
746
789
  {
747
- icon: l.icon,
748
- label: l.title,
749
- active: u,
750
- accented: u && o,
751
- onClick: () => s(l.id),
790
+ icon: a.icon,
791
+ label: a.title,
792
+ active: d,
793
+ accented: d && o,
794
+ onClick: () => c(a.id),
752
795
  className: "pnl-rail__button"
753
796
  },
754
- l.id
797
+ a.id
755
798
  );
756
799
  })
757
800
  ] }, `${n}:${r}`)) });
758
801
  }
759
- function dt(n) {
802
+ function Nt(n) {
760
803
  const t = [], e = /* @__PURE__ */ new Map(), o = [];
761
- let s = null;
762
- for (const r of Cn.toArray(n)) {
763
- if (!En(r)) {
764
- o.push(r);
804
+ let c = null;
805
+ for (const s of jn.toArray(n)) {
806
+ if (!Hn(s)) {
807
+ o.push(s);
765
808
  continue;
766
809
  }
767
- if (r.type === Q) {
768
- s = r;
810
+ if (s.type === cn) {
811
+ c = s;
769
812
  continue;
770
813
  }
771
- if (r.type !== nn) {
772
- o.push(r);
814
+ if (s.type !== ln) {
815
+ o.push(s);
773
816
  continue;
774
817
  }
775
- const i = r.props, { id: c, zone: l, slot: u = "primary", title: a, icon: f, opens: p, solo: g, actions: b, children: P } = i;
776
- t.push({ id: c, zone: l, slot: u, title: a, icon: f, opens: p, solo: g }), e.set(c, { content: P, actions: b });
818
+ const r = s.props, { actions: i, children: l, slot: a = "primary", ...d } = r;
819
+ t.push({ ...d, slot: a }), e.set(d.id, { content: l, actions: i });
777
820
  }
778
- return { specs: t, content: e, centre: s, loose: o };
821
+ return { specs: t, content: e, centre: c, loose: o };
779
822
  }
780
- function zn({
823
+ function Fn({
781
824
  header: n,
782
825
  footer: t,
783
826
  railHeader: e,
784
827
  labels: o,
785
- theme: s,
786
- className: r,
828
+ theme: c,
829
+ className: s,
830
+ components: r,
787
831
  children: i,
788
- ...c
832
+ ...l
789
833
  }) {
790
- return /* @__PURE__ */ d(Xn, { ...c, children: /* @__PURE__ */ d(
791
- ft,
834
+ return /* @__PURE__ */ u(ot, { ...l, children: /* @__PURE__ */ u(
835
+ Pt,
792
836
  {
793
837
  header: n,
794
838
  footer: t,
795
839
  railHeader: e,
796
840
  labels: o,
797
- theme: s,
798
- className: r,
841
+ theme: c,
842
+ className: s,
843
+ components: r,
799
844
  children: i
800
845
  }
801
846
  ) });
802
847
  }
803
- function ft({
848
+ function Pt({
804
849
  header: n,
805
850
  footer: t,
806
851
  railHeader: e,
807
852
  labels: o,
808
- theme: s,
809
- className: r,
853
+ theme: c,
854
+ className: s,
855
+ components: r,
810
856
  children: i
811
857
  }) {
812
- const c = L(), l = j(null);
813
- Kn(l);
814
- const { specs: u, content: a, centre: f, loose: p } = w(() => dt(i), [i]), g = w(() => ({ ...ut, ...o }), [o]);
815
- wn(() => {
816
- const { register: P, unregister: h } = c.getState();
817
- for (const _ of u) P(_);
818
- const y = new Set(u.map((_) => _.id));
819
- for (const _ of c.getState().registry)
820
- y.has(_.id) || h(_.id);
821
- }, [c, u]);
822
- const b = Qn();
823
- return /* @__PURE__ */ d(ot, { value: a, children: /* @__PURE__ */ m("div", { "data-pnl-theme": s, className: v("pnl-root", r), children: [
858
+ const l = O(), a = H(null);
859
+ ct(a);
860
+ const [d] = W(() => it(r)), { specs: f, content: h, centre: m, loose: I } = w(() => Nt(i), [i]), y = w(() => ({ ...St, ...o }), [o]);
861
+ Mn(() => {
862
+ l.getState().declare(f);
863
+ }, [l, f]);
864
+ const p = ut();
865
+ return /* @__PURE__ */ u(st, { value: d, children: /* @__PURE__ */ u(pt, { value: h, children: /* @__PURE__ */ g("div", { "data-pnl-theme": c, className: b("pnl-root", s), children: [
824
866
  n,
825
- /* @__PURE__ */ m("div", { className: "pnl-middle", children: [
826
- /* @__PURE__ */ d(un, { side: "left", header: e }),
827
- /* @__PURE__ */ m("div", { ref: l, className: "pnl-columns", children: [
828
- /* @__PURE__ */ d(x, { zone: "top", labels: g }),
829
- /* @__PURE__ */ m("div", { className: "pnl-row", children: [
830
- !b.left && /* @__PURE__ */ d(x, { zone: "left", labels: g }),
831
- /* @__PURE__ */ m("div", { className: "pnl-stack", children: [
832
- /* @__PURE__ */ m("div", { className: "pnl-row", children: [
833
- b.left && /* @__PURE__ */ d(x, { zone: "left", labels: g }),
834
- /* @__PURE__ */ d(_n, { className: "pnl-centre", children: f?.props.children }),
835
- b.right && /* @__PURE__ */ d(x, { zone: "right", labels: g })
867
+ /* @__PURE__ */ g("div", { className: "pnl-middle", children: [
868
+ /* @__PURE__ */ u(wn, { side: "left", header: e }),
869
+ /* @__PURE__ */ g("div", { ref: a, className: "pnl-columns", children: [
870
+ /* @__PURE__ */ u(N, { zone: "top", labels: y }),
871
+ /* @__PURE__ */ g("div", { className: "pnl-row", children: [
872
+ !p.left && /* @__PURE__ */ u(N, { zone: "left", labels: y }),
873
+ /* @__PURE__ */ g("div", { className: "pnl-stack", children: [
874
+ /* @__PURE__ */ g("div", { className: "pnl-row", children: [
875
+ p.left && /* @__PURE__ */ u(N, { zone: "left", labels: y }),
876
+ /* @__PURE__ */ u(Tn, { className: "pnl-centre", children: m?.props.children }),
877
+ p.right && /* @__PURE__ */ u(N, { zone: "right", labels: y })
836
878
  ] }),
837
- /* @__PURE__ */ d(at, { left: b.left, right: b.right, labels: g })
879
+ /* @__PURE__ */ u(yt, { left: p.left, right: p.right, labels: y })
838
880
  ] }),
839
- !b.right && /* @__PURE__ */ d(x, { zone: "right", labels: g })
881
+ !p.right && /* @__PURE__ */ u(N, { zone: "right", labels: y })
840
882
  ] })
841
883
  ] }),
842
- /* @__PURE__ */ d(un, { side: "right" })
884
+ /* @__PURE__ */ u(wn, { side: "right" })
843
885
  ] }),
844
886
  t,
845
- p
846
- ] }) });
847
- }
848
- zn.Panel = nn;
849
- zn.Center = Q;
850
- function bt() {
851
- const n = L(), t = T(), e = S((i) => i.focusedZone), o = O(), s = z(
852
- (i) => {
853
- const c = N(t.registry, i);
854
- return c !== void 0 && Z(t, c.zone)[c.slot] === i;
887
+ I
888
+ ] }) }) });
889
+ }
890
+ Fn.Panel = ln;
891
+ Fn.Center = cn;
892
+ function Zt() {
893
+ const n = O(), t = T(), e = v((r) => r.focusedZone), o = R(), c = _(
894
+ (r) => {
895
+ const i = C(t.registry, r);
896
+ return i !== void 0 && L(t, i.zone)[i.slot] === r;
855
897
  },
856
898
  [t]
857
- ), r = z(
858
- (i) => {
859
- const c = N(t.registry, i);
860
- !c || Z(t, c.zone)[c.slot] !== i || n.getState().close(c.zone, c.slot);
899
+ ), s = _(
900
+ (r) => {
901
+ const i = C(t.registry, r);
902
+ !i || L(t, i.zone)[i.slot] !== r || n.getState().close(i.zone, i.slot);
861
903
  },
862
904
  [t, n]
863
905
  );
@@ -865,71 +907,76 @@ function bt() {
865
907
  () => ({
866
908
  panels: t.registry,
867
909
  reveal: o.show,
868
- close: r,
910
+ close: s,
869
911
  toggle: o.toggle,
870
- isShown: s,
912
+ isShown: c,
871
913
  focusedZone: e,
872
914
  reset: o.reset
873
915
  }),
874
- [t, o.show, o.toggle, o.reset, r, s, e]
916
+ [t, o.show, o.toggle, o.reset, s, c, e]
875
917
  );
876
918
  }
877
919
  export {
878
- kn as BOTTOM_ZONES,
879
- at as Band,
880
- Q as Center,
881
- ot as ContentProvider,
882
- ut as DEFAULT_LABELS,
883
- Bn as DEFAULT_SIZES,
884
- xn as IconButton,
885
- Sn as LAYOUT_VERSION,
886
- gn as MIN_CENTER,
887
- F as MIN_SIZE,
888
- R as MIN_SPLIT,
889
- nn as Panel,
890
- an as PanelFrame,
891
- st as PanelHeader,
892
- zn as Panels,
893
- Xn as PanelsProvider,
894
- un as Rail,
895
- dn as RailZone,
896
- X as ResizeHandle,
897
- $ as SLOTS,
898
- q as Separator,
899
- _n as Surface,
900
- C as ZONES,
901
- V as ZONES_BY_SIDE,
902
- x as ZoneEdge,
903
- Vn as browserStorage,
904
- $n as createPanelsStore,
905
- v as cx,
920
+ $n as BOTTOM_ZONES,
921
+ yt as Band,
922
+ cn as Center,
923
+ pt as ContentProvider,
924
+ St as DEFAULT_LABELS,
925
+ Wn as DEFAULT_SIZES,
926
+ on as DEFAULT_VIEW,
927
+ rt as IconButton,
928
+ En as LAYOUT_VERSION,
929
+ Pn as MIN_CENTER,
930
+ B as MIN_SIZE,
931
+ Z as MIN_SPLIT,
932
+ ln as Panel,
933
+ bn as PanelFrame,
934
+ mt as PanelHeader,
935
+ Fn as Panels,
936
+ ot as PanelsProvider,
937
+ wn as Rail,
938
+ yn as RailZone,
939
+ Q as ResizeHandle,
940
+ Nn as SLOTS,
941
+ sn as Separator,
942
+ Tn as Surface,
943
+ U as ZONES,
944
+ G as ZONES_BY_SIDE,
945
+ N as ZoneEdge,
946
+ Qn as browserStorage,
947
+ qn as createPanelsStore,
948
+ b as cx,
906
949
  D as fitSplit,
907
- yn as fitZoneSize,
908
- U as isBottom,
909
- E as isHorizontal,
910
- on as isLeading,
911
- mt as memoryStorage,
912
- Gn as readLayout,
913
- Dn as sharedSizes,
914
- Z as shownIn,
915
- A as sizeKeyOf,
916
- N as specOf,
917
- G as undraggedSizeOf,
950
+ xn as fitZoneSize,
951
+ rn as isBottom,
952
+ M as isHorizontal,
953
+ un as isLeading,
954
+ Ct as memoryStorage,
955
+ z as openOf,
956
+ tt as readLayout,
957
+ Jn as sharedSizes,
958
+ L as shownIn,
959
+ E as shownSpecsIn,
960
+ k as sizeKeyOf,
961
+ C as specOf,
962
+ K as undraggedSizeOf,
918
963
  T as useArrangement,
919
- Qn as useBandHalves,
920
- Kn as useContainerFit,
921
- rt as usePanelContent,
922
- bt as usePanels,
923
- O as usePanelsActions,
924
- S as usePanelsState,
925
- L as usePanelsStore,
926
- nt as usePointerDrag,
927
- J as useShownIn,
928
- tt as useZone,
929
- cn as useZoneDraws,
930
- et as useZonePanels,
931
- qn as useZoneTakesRoom,
932
- Jn as writeLayout,
933
- W as zoneDraws,
934
- jn as zoneTakesRoom
964
+ ut as useBandHalves,
965
+ ct as useContainerFit,
966
+ gt as usePanelContent,
967
+ Zt as usePanels,
968
+ R as usePanelsActions,
969
+ On as usePanelsComponents,
970
+ v as usePanelsState,
971
+ O as usePanelsStore,
972
+ dt as usePointerDrag,
973
+ lt as useShownIn,
974
+ gn as useShownSpecsIn,
975
+ ft as useZone,
976
+ mn as useZoneDraws,
977
+ ht as useZonePanels,
978
+ at as useZoneTakesRoom,
979
+ et as writeLayout,
980
+ j as zoneDraws,
981
+ X as zoneTakesRoom
935
982
  };