@aiquants/resize-panels 1.9.0 → 2.0.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.
Files changed (62) hide show
  1. package/README.md +129 -22
  2. package/dist/GlobalDebugOverlay-Cf3GOn2A.cjs +1 -0
  3. package/dist/{GlobalDebugOverlay-Do70T2l6.js → GlobalDebugOverlay-DQtUdNeF.js} +28 -28
  4. package/dist/GlobalDebugOverlay.d.ts +1 -18
  5. package/dist/Panel.d.ts +13 -7
  6. package/dist/PanelDebugInfo.d.ts +6 -10
  7. package/dist/PanelGroup.d.ts +1 -6
  8. package/dist/PanelResizeHandle.d.ts +2 -7
  9. package/dist/allocateLayout.d.ts +12 -0
  10. package/dist/context.d.ts +2 -11
  11. package/dist/debugOverlayStore-D7FT6zPE.js +135 -0
  12. package/dist/debugOverlayStore-DY09saU8.cjs +1 -0
  13. package/dist/debugOverlayStore.d.ts +7 -36
  14. package/dist/hooks.d.ts +12 -24
  15. package/dist/index-DZ0itiBD.js +1299 -0
  16. package/dist/index-DqATP_BA.cjs +2 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.ts +10 -26
  19. package/dist/index.js +25 -13
  20. package/dist/reducer.d.ts +7 -38
  21. package/dist/roundHalfToEven.d.ts +0 -9
  22. package/dist/styles/resize-panels.standalone.css +1 -1
  23. package/dist/types.d.ts +67 -261
  24. package/dist/utils/simple-logger.d.ts +0 -74
  25. package/dist/utils.d.ts +10 -55
  26. package/package.json +2 -3
  27. package/dist/GlobalDebugOverlay-sEQN6exo.cjs +0 -1
  28. package/dist/GlobalDebugOverlay.d.ts.map +0 -1
  29. package/dist/Panel.d.ts.map +0 -1
  30. package/dist/PanelDebugInfo.d.ts.map +0 -1
  31. package/dist/PanelGroup.d.ts.map +0 -1
  32. package/dist/PanelResizeHandle.d.ts.map +0 -1
  33. package/dist/context.d.ts.map +0 -1
  34. package/dist/debugOverlayStore-Cntyxboe.js +0 -141
  35. package/dist/debugOverlayStore-Dkl-fHoa.cjs +0 -1
  36. package/dist/debugOverlayStore.d.ts.map +0 -1
  37. package/dist/hooks.d.ts.map +0 -1
  38. package/dist/index-B6YGX2DH.js +0 -2009
  39. package/dist/index-DssZUxGw.cjs +0 -2
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/reducer.d.ts.map +0 -1
  42. package/dist/roundHalfToEven.d.ts.map +0 -1
  43. package/dist/types.d.ts.map +0 -1
  44. package/dist/utils/simple-logger.d.ts.map +0 -1
  45. package/dist/utils.d.ts.map +0 -1
  46. package/src/GlobalDebugOverlay.tsx +0 -284
  47. package/src/Panel.tsx +0 -635
  48. package/src/PanelDebugInfo.tsx +0 -148
  49. package/src/PanelGroup.tsx +0 -260
  50. package/src/PanelResizeHandle.tsx +0 -797
  51. package/src/context.ts +0 -25
  52. package/src/debugOverlayStore.ts +0 -351
  53. package/src/hooks.ts +0 -968
  54. package/src/index.ts +0 -84
  55. package/src/reducer.ts +0 -1234
  56. package/src/roundHalfToEven.ts +0 -40
  57. package/src/styles/components.entry.css +0 -10
  58. package/src/styles/resize-panels.css +0 -1
  59. package/src/styles/standalone.entry.css +0 -12
  60. package/src/types.ts +0 -419
  61. package/src/utils/simple-logger.ts +0 -186
  62. package/src/utils.ts +0 -279
@@ -0,0 +1,1299 @@
1
+ import { createContext as Vn, useContext as jn, useCallback as k, useMemo as w, useReducer as Kn, useState as Ee, useRef as H, useLayoutEffect as Se, useEffect as J, memo as Ze, useId as In, Suspense as Yn, lazy as Xn } from "react";
2
+ import { jsxs as ue, jsx as ie } from "react/jsx-runtime";
3
+ import { twMerge as Ce } from "tailwind-merge";
4
+ const qn = 12, C = 1e-6, Zn = 8, Jn = 6, Qn = 48, et = 80, nt = 2, tt = 32, rt = 64, ot = 8, it = 8, mn = 10, vn = 0.05, Nn = 10, st = 0.05, lt = 20, at = 0.05, ct = (e, n = 0) => {
5
+ if (!Number.isFinite(e))
6
+ return e;
7
+ const t = 10 ** n, r = e * t, o = Math.floor(r), i = r - o, s = Number.EPSILON * Math.max(1, Math.abs(r));
8
+ return i < 0.5 - s ? o / t : i > 0.5 + s ? (o + 1) / t : (o % 2 === 0 ? o : o + 1) / t;
9
+ }, dt = 6, Rn = (e, n) => n <= 0 ? 0 : ct(e / n * 100, dt), Qt = (e, n) => n <= 0 ? 0 : e / 100 * n, ut = (e, n = "percentage") => {
10
+ if (e !== void 0)
11
+ return typeof e == "number" ? { value: e, unit: n } : e;
12
+ }, gn = (e, n, t) => e === void 0 ? n : typeof e == "number" ? e / 100 * t : e.unit === "pixels" ? e.value : e.value / 100 * t, Fe = (e, n, t) => Math.min(Math.max(e, n), t), _n = (e) => !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.min(qn, Nn, e * vn)), he = (e) => {
13
+ if (!e)
14
+ return 0;
15
+ const n = Number.parseFloat(e);
16
+ return Number.isFinite(n) ? n : 0;
17
+ }, Me = (e, n, t) => {
18
+ const r = n === "horizontal", o = typeof window < "u" ? window.getComputedStyle(e) : null, i = o ? r ? he(o.paddingLeft) + he(o.paddingRight) : he(o.paddingTop) + he(o.paddingBottom) : 0, s = o ? r ? he(o.borderLeftWidth) + he(o.borderRightWidth) : he(o.borderTopWidth) + he(o.borderBottomWidth) : 0, l = t?.contentBoxSize?.[0], d = l ? r ? l.inlineSize : l.blockSize : void 0, c = r ? e.clientWidth : e.clientHeight, g = c > 0 ? Math.max(0, c - i) : Math.max(0, (r ? e.offsetWidth : e.offsetHeight) - i - s), a = d ?? g;
19
+ return { content: Math.max(0, a), border: Math.max(0, a + i + s) };
20
+ }, pt = "[data-panel-group-direction]", Ke = "[data-panel-id], [data-resize-handle-anchor]", ft = "[data-panel-id]", Te = (e) => e?.closest(pt) ?? null, Cn = (e) => Array.from(e.querySelectorAll(Ke)).filter((n) => {
21
+ if (Te(n) !== e)
22
+ return !1;
23
+ const t = n.parentElement?.closest(ft);
24
+ return !(t && e.contains(t));
25
+ }), ht = (e) => {
26
+ const n = (t) => {
27
+ for (const r of Array.from(t))
28
+ if (r instanceof Element && (r.matches(Ke) || r.querySelector(Ke) !== null))
29
+ return !0;
30
+ return !1;
31
+ };
32
+ return e.some((t) => n(t.addedNodes) || n(t.removedNodes));
33
+ }, mt = (e, n) => {
34
+ if (typeof window > "u")
35
+ return 1;
36
+ const t = n === "horizontal", r = e.getBoundingClientRect(), o = t ? r.width : r.height, i = window.getComputedStyle(e), s = t ? i.width : i.height;
37
+ if (!s.endsWith("px"))
38
+ return 1;
39
+ const l = Number.parseFloat(s);
40
+ return o > 0 && Number.isFinite(l) && l > 0 ? o / l : 1;
41
+ }, xn = (e, n) => {
42
+ try {
43
+ localStorage.setItem(`panel-layout-${e}`, JSON.stringify(n));
44
+ } catch (t) {
45
+ console.warn("Failed to save panel layout:", t);
46
+ }
47
+ }, gt = (e) => {
48
+ try {
49
+ const n = localStorage.getItem(`panel-layout-${e}`);
50
+ if (!n)
51
+ return null;
52
+ const t = JSON.parse(n);
53
+ if (!Array.isArray(t))
54
+ return null;
55
+ const r = (o) => typeof o == "object" && o !== null && typeof o.id == "string" && Number.isFinite(o.size);
56
+ return t.every(r) ? t : null;
57
+ } catch (n) {
58
+ return console.warn("Failed to load panel layout:", n), null;
59
+ }
60
+ }, Ye = 0, Mn = 1, Be = (e) => Number.isFinite(e) && e > 0 ? e : 0, re = (e) => e.sizeUnit === "pixels", be = (e, n) => {
61
+ const t = Math.max(0, Be(gn(e.minSize, 0, n))), r = Math.max(t, Be(gn(e.maxSize, n, n)));
62
+ return { min: t, max: r };
63
+ }, xt = (e, n) => {
64
+ const t = e.map((o) => o.min), r = e.map(() => !1);
65
+ for (; ; ) {
66
+ let o = 0, i = 0, s = 0;
67
+ for (let a = 0; a < e.length; a += 1) {
68
+ if (r[a]) {
69
+ i += t[a];
70
+ continue;
71
+ }
72
+ s += 1, o += e[a].weight;
73
+ }
74
+ if (s === 0)
75
+ return t;
76
+ const l = n - i;
77
+ if (o <= 0) {
78
+ for (let a = 0; a < e.length; a += 1)
79
+ r[a] || (t[a] = e[a].min);
80
+ return t;
81
+ }
82
+ const d = Math.max(0, l / o);
83
+ let c = 0;
84
+ for (let a = 0; a < e.length; a += 1) {
85
+ if (r[a])
86
+ continue;
87
+ const N = d * e[a].weight, f = Fe(N, e[a].min, e[a].max);
88
+ t[a] = f, c += f - N;
89
+ }
90
+ let g = !1;
91
+ for (let a = 0; a < e.length; a += 1) {
92
+ if (r[a])
93
+ continue;
94
+ const N = d * e[a].weight;
95
+ c > C && t[a] > N + C ? (r[a] = !0, t[a] = e[a].min, g = !0) : c < -C && t[a] < N - C && (r[a] = !0, t[a] = e[a].max, g = !0);
96
+ }
97
+ if (!g)
98
+ return t;
99
+ }
100
+ }, St = (e, n, t) => {
101
+ const { min: r, max: o } = be(e, t);
102
+ if (re(e))
103
+ return {
104
+ index: n,
105
+ weight: 0,
106
+ target: Fe(Be(e.preferredPixelSize), r, o),
107
+ priority: e.pixelAdjustPriority ?? 0,
108
+ tier: Ye,
109
+ min: r,
110
+ max: o
111
+ };
112
+ const i = Be(e.preferredPercentageSize), s = e.flexAdjustPriority !== void 0;
113
+ return {
114
+ index: n,
115
+ weight: i,
116
+ target: s ? Fe(i / 100 * t, r, o) : null,
117
+ priority: e.flexAdjustPriority ?? 0,
118
+ tier: Mn,
119
+ min: r,
120
+ max: o
121
+ };
122
+ }, Sn = (e, n, t, r) => {
123
+ let o = r;
124
+ for (const i of e) {
125
+ if (o <= C)
126
+ break;
127
+ const s = t(i) - n[i.index];
128
+ if (s <= 0)
129
+ continue;
130
+ const l = Math.min(s, o);
131
+ n[i.index] += l, o -= l;
132
+ }
133
+ return o;
134
+ }, Xe = (e, n, t) => {
135
+ if (e.length === 0 || t <= C)
136
+ return t;
137
+ const r = e.map((s) => ({ ...s, min: n[s.index] })), o = xt(r, t + r.reduce((s, l) => s + l.min, 0));
138
+ let i = 0;
139
+ for (let s = 0; s < e.length; s += 1)
140
+ i += o[s] - n[e[s].index], n[e[s].index] = o[s];
141
+ return t - i;
142
+ }, bt = (e, n, t) => Xe(
143
+ e.map((r) => ({ ...r, weight: 1 })),
144
+ n,
145
+ t
146
+ ), zt = (e, n) => e.tier !== n.tier ? e.tier - n.tier : e.priority !== n.priority ? n.priority - e.priority : e.index - n.index, yt = (e, n) => {
147
+ const t = e.map(() => 0);
148
+ if (!Number.isFinite(n) || n <= 0 || e.length === 0)
149
+ return { sizes: t, violation: null };
150
+ const r = [];
151
+ for (let f = 0; f < e.length; f += 1) {
152
+ const L = e[f];
153
+ L.collapsed || r.push(St(L, f, n));
154
+ }
155
+ if (r.length === 0)
156
+ return { sizes: t, violation: null };
157
+ let o = 0, i = 0;
158
+ for (const f of r)
159
+ t[f.index] = f.min, o += f.min, i += f.max;
160
+ const s = Pt(o, i, n);
161
+ let l = n - o;
162
+ if (l <= C)
163
+ return { sizes: t, violation: s };
164
+ const d = r.filter((f) => f.target !== null).sort(zt), c = r.filter((f) => f.target === null && f.weight > 0), g = r.filter((f) => f.tier !== Ye && f.weight <= 0), a = d.filter((f) => f.tier === Mn), N = d.filter((f) => f.tier === Ye);
165
+ return l = Sn(d, t, (f) => f.target ?? f.min, l), l = Xe(c, t, l), l = Xe(a, t, l), l = Sn(N, t, (f) => f.max, l), l = bt(g, t, l), { sizes: t, violation: s };
166
+ }, Pt = (e, n, t) => e - t > C ? {
167
+ reason: "minimum-exceeded",
168
+ totalMinimumSize: e,
169
+ totalMaximumSize: n,
170
+ availableContainerSize: t
171
+ } : t - n > C ? {
172
+ reason: "maximum-insufficient",
173
+ totalMinimumSize: e,
174
+ totalMaximumSize: n,
175
+ availableContainerSize: t
176
+ } : null, Ln = Vn(null), Je = () => {
177
+ const e = jn(Ln);
178
+ if (!e)
179
+ throw new Error("usePanelGroup must be used within a PanelGroup");
180
+ return e;
181
+ };
182
+ var ke = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(ke || {});
183
+ const Z = class Z {
184
+ /**
185
+ * @constructor
186
+ * @param {LogLevel} [level=LogLevel.WARN] - The minimum log level to output.
187
+ * @param {string} [prefix="[resize-panels]"] - The prefix to add to all log messages.
188
+ * @param {ILogger} [impl=console] - The implementation to use for logging.
189
+ */
190
+ constructor(n = 2, t = "[resize-panels]", r = console) {
191
+ this.level = n, this.prefix = t, this.impl = r, Z.instances.add(this);
192
+ }
193
+ /**
194
+ * @method setLevel
195
+ * @description Updates the log level for every constructed logger (module-level loggers included).
196
+ * @description 生成済みのすべてのロガー (モジュールレベルのロガーを含む) のログレベルを更新します。
197
+ * @param {LogLevel} level - The new log level.
198
+ */
199
+ static setLevel(n) {
200
+ for (const t of Z.instances)
201
+ t.setLevel(n);
202
+ }
203
+ /**
204
+ * @method setLevel
205
+ * @description Updates the current log level.
206
+ * @description 現在のログレベルを更新します。
207
+ * @param {LogLevel} level - The new log level.
208
+ */
209
+ setLevel(n) {
210
+ this.level = n;
211
+ }
212
+ /**
213
+ * @method setImplementation
214
+ * @description Updates the logger implementation for every constructed logger.
215
+ * @description 生成済みのすべてのロガーの実装を更新します。
216
+ * @param {ILogger} impl - The new logger implementation.
217
+ */
218
+ static setImplementation(n) {
219
+ for (const t of Z.instances)
220
+ t.setImplementation(n);
221
+ }
222
+ /**
223
+ * @method setImplementation
224
+ * @description Updates the logger implementation.
225
+ * @description ロガーの実装を更新します。
226
+ * @param {ILogger} impl - The new logger implementation.
227
+ */
228
+ setImplementation(n) {
229
+ this.impl = n;
230
+ }
231
+ /**
232
+ * @method setPrefix
233
+ * @description Updates the log prefix for every constructed logger.
234
+ * @description 生成済みのすべてのロガーのログのプレフィックスを更新します。
235
+ * @param {string} prefix - The new prefix.
236
+ */
237
+ static setPrefix(n) {
238
+ for (const t of Z.instances)
239
+ t.setPrefix(n);
240
+ }
241
+ /**
242
+ * @method setPrefix
243
+ * @description Updates the log prefix.
244
+ * @description ログのプレフィックスを更新します。
245
+ * @param {string} prefix - The new prefix.
246
+ */
247
+ setPrefix(n) {
248
+ this.prefix = n;
249
+ }
250
+ /**
251
+ * @method enabledFor
252
+ * @description Returns whether messages at the given level would be emitted.
253
+ * @description 指定レベルのメッセージが出力対象かどうかを返します。
254
+ * 高コストなログ引数 (スナップショット等) の組み立てを抑制中に省略するために使用します。
255
+ * @param {LogLevel} level - The message level to test.
256
+ */
257
+ enabledFor(n) {
258
+ return this.level <= n;
259
+ }
260
+ formatMessage(n) {
261
+ return typeof n == "string" ? [`${this.prefix} ${n}`] : [this.prefix, n];
262
+ }
263
+ static debug(n, ...t) {
264
+ Z.instance.debug(n, ...t);
265
+ }
266
+ debug(n, ...t) {
267
+ this.level <= 0 && this.impl.debug(...this.formatMessage(n), ...t);
268
+ }
269
+ static info(n, ...t) {
270
+ Z.instance.info(n, ...t);
271
+ }
272
+ info(n, ...t) {
273
+ this.level <= 1 && this.impl.info(...this.formatMessage(n), ...t);
274
+ }
275
+ static warn(n, ...t) {
276
+ Z.instance.warn(n, ...t);
277
+ }
278
+ warn(n, ...t) {
279
+ this.level <= 2 && this.impl.warn(...this.formatMessage(n), ...t);
280
+ }
281
+ static error(n, ...t) {
282
+ Z.instance.error(n, ...t);
283
+ }
284
+ error(n, ...t) {
285
+ this.level <= 3 && this.impl.error(...this.formatMessage(n), ...t);
286
+ }
287
+ };
288
+ Z.instances = /* @__PURE__ */ new Set(), Z.instance = new Z(2, "[resize-panels]");
289
+ let Le = Z;
290
+ const An = new Le(ke.INFO, "[resize-panels]"), Et = {
291
+ containerSize: 0,
292
+ panels: [],
293
+ violation: null
294
+ }, bn = (e, n) => e === null || n === null ? e === n : e.reason === n.reason && Math.abs(e.totalMinimumSize - n.totalMinimumSize) <= C && Math.abs(e.totalMaximumSize - n.totalMaximumSize) <= C && Math.abs(e.availableContainerSize - n.availableContainerSize) <= C, ce = (e, n) => {
295
+ const { sizes: t, violation: r } = yt(e, n);
296
+ let o = !1;
297
+ const i = e.map((l, d) => {
298
+ const c = l.collapsed ? 0 : t[d];
299
+ return Math.abs(l.size - c) <= C ? l : (o = !0, { ...l, size: c });
300
+ }), s = { containerSize: n, panels: o ? i : e, violation: r };
301
+ return It(s), s;
302
+ }, wt = (e) => {
303
+ if (e.containerSize <= 0 || e.violation !== null)
304
+ return null;
305
+ let n = 0, t = 0;
306
+ for (const o of e.panels)
307
+ o.collapsed || (n += o.size, t += 1);
308
+ if (t === 0)
309
+ return null;
310
+ const r = C * Math.max(1, e.containerSize);
311
+ return !Number.isFinite(n) || Math.abs(n - e.containerSize) > r ? { allocatedTotal: n, containerSize: e.containerSize } : null;
312
+ }, It = (e) => {
313
+ const n = wt(e);
314
+ n && An.error("Allocated sizes do not fill the container.", {
315
+ ...n,
316
+ panels: e.panels.map((t) => ({ id: t.id, size: t.size, collapsed: t.collapsed }))
317
+ });
318
+ }, de = (e, n) => e.panels === n.panels && e.containerSize === n.containerSize && bn(e.violation, n.violation) ? e : {
319
+ containerSize: n.containerSize,
320
+ panels: n.panels,
321
+ violation: bn(e.violation, n.violation) ? e.violation : n.violation
322
+ }, vt = (e, n) => {
323
+ const t = e.sizeUnit === "pixels" ? e.preferredPixelSize : e.preferredPercentageSize;
324
+ return {
325
+ ...e,
326
+ size: 0,
327
+ collapsed: e.collapsed,
328
+ collapsedByDirection: e.collapsed ? n : null,
329
+ preferenceBeforeCollapse: t,
330
+ authoredPreference: t
331
+ };
332
+ }, je = (e) => e.collapseFromStart ? "start" : e.collapseFromEnd ? "end" : null, Nt = (e, n) => {
333
+ if (n <= 0)
334
+ return e;
335
+ const t = _n(n);
336
+ return e.map((r) => {
337
+ if (r.collapsed)
338
+ return r;
339
+ const o = re(r) ? r.size : r.size / n * 100, i = re(r) ? r.preferredPixelSize : r.preferredPercentageSize, s = r.size > t ? o : r.preferenceBeforeCollapse;
340
+ return i === o && s === r.preferenceBeforeCollapse ? r : re(r) ? { ...r, preferredPixelSize: o, preferenceBeforeCollapse: s } : { ...r, preferredPercentageSize: o, preferenceBeforeCollapse: s };
341
+ });
342
+ }, qe = (e, n, t) => {
343
+ if (re(e)) {
344
+ const o = Math.max(0, n);
345
+ return { ...e, preferredPixelSize: o, preferenceBeforeCollapse: o };
346
+ }
347
+ if (t <= 0)
348
+ return e;
349
+ const r = Math.max(0, n / t * 100);
350
+ return { ...e, preferredPercentageSize: r, preferenceBeforeCollapse: r };
351
+ }, Rt = (e, n) => {
352
+ const t = e.collapsed ? e.preferenceBeforeCollapse : re(e) ? e.preferredPixelSize : e.preferredPercentageSize;
353
+ return re(e) ? t : t / 100 * n;
354
+ }, _t = (e, n, t, r) => {
355
+ const o = Math.max(0, Math.min(t, r)), i = e.filter((c) => c.id !== n && !c.collapsed && !re(c)), s = e.reduce((c, g) => g.id !== n && !g.collapsed && re(g) ? c + g.size : c, 0), l = i.reduce((c, g) => c + g.size, 0), d = Math.max(0, r - o - s);
356
+ return e.map((c) => {
357
+ if (c.id === n)
358
+ return qe(c, o, r);
359
+ if (c.collapsed || re(c) || i.length === 0)
360
+ return c;
361
+ const g = l > 0 ? c.size / l * d : d / i.length;
362
+ return qe(c, g, r);
363
+ });
364
+ }, Ct = (e, n) => {
365
+ switch (n.type) {
366
+ case "SET_CONTAINER_SIZE":
367
+ return !Number.isFinite(n.containerSize) || n.containerSize < 0 || n.containerSize === e.containerSize ? e : de(e, ce(e.panels, n.containerSize));
368
+ case "REGISTER_PANEL": {
369
+ const t = e.panels.findIndex((a) => a.id === n.panel.id);
370
+ if (t === -1) {
371
+ const a = [...e.panels, vt(n.panel, je(n.panel))];
372
+ return de(e, ce(a, e.containerSize));
373
+ }
374
+ const r = e.panels[t], o = n.panel.sizeUnit === "pixels" ? n.panel.preferredPixelSize : n.panel.preferredPercentageSize, i = o !== r.authoredPreference || n.panel.sizeUnit !== r.sizeUnit, s = r.collapsedByDirection === "start" ? n.panel.collapseFromStart : r.collapsedByDirection === "end" ? n.panel.collapseFromEnd : !1, l = n.panel.collapseFromStart || n.panel.collapseFromEnd, d = r.collapsed && l, c = {
375
+ ...r,
376
+ ...n.panel,
377
+ collapsed: d,
378
+ collapsedByDirection: d ? s ? r.collapsedByDirection : je(n.panel) : null,
379
+ preferredPercentageSize: i ? n.panel.preferredPercentageSize : r.preferredPercentageSize,
380
+ preferredPixelSize: i ? n.panel.preferredPixelSize : r.preferredPixelSize,
381
+ preferenceBeforeCollapse: i ? o : r.preferenceBeforeCollapse,
382
+ authoredPreference: o
383
+ }, g = [...e.panels];
384
+ return g[t] = c, de(e, ce(g, e.containerSize));
385
+ }
386
+ case "UNREGISTER_PANEL": {
387
+ const t = e.panels.filter((r) => r.id !== n.id);
388
+ return t.length === e.panels.length ? e : de(e, ce(t, e.containerSize));
389
+ }
390
+ case "REORDER_PANELS": {
391
+ if (n.ids.length !== e.panels.length || new Set(n.ids).size !== n.ids.length)
392
+ return e;
393
+ const t = new Map(e.panels.map((o) => [o.id, o])), r = [];
394
+ for (const o of n.ids) {
395
+ const i = t.get(o);
396
+ if (!i)
397
+ return e;
398
+ r.push(i);
399
+ }
400
+ return r.every((o, i) => o === e.panels[i]) ? e : de(e, ce(r, e.containerSize));
401
+ }
402
+ case "RESIZE_PANELS": {
403
+ const t = e.panels.findIndex((L) => L.id === n.startId), r = e.panels.findIndex((L) => L.id === n.endId);
404
+ if (t === -1 || r === -1)
405
+ return e;
406
+ const o = e.panels[t], i = e.panels[r];
407
+ if (o.collapsed || i.collapsed || e.containerSize <= 0 || !Number.isFinite(n.startSize))
408
+ return e;
409
+ const s = o.size + i.size, l = be(o, e.containerSize), d = be(i, e.containerSize), c = Math.max(l.min, s - d.max), g = Math.min(l.max, s - d.min);
410
+ if (c - g > C)
411
+ return e;
412
+ const a = Fe(n.startSize, c, Math.max(c, g)), N = s - a;
413
+ if (Math.abs(a - o.size) <= C)
414
+ return e;
415
+ const f = [...e.panels];
416
+ return f[t] = { ...o, size: a }, f[r] = { ...i, size: N }, de(e, ce(Nt(f, e.containerSize), e.containerSize));
417
+ }
418
+ case "COLLAPSE_PANEL": {
419
+ const t = e.panels.findIndex((s) => s.id === n.id);
420
+ if (t === -1)
421
+ return e;
422
+ const r = e.panels[t];
423
+ if (!(n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) || r.collapsed)
424
+ return e;
425
+ const i = [...e.panels];
426
+ return i[t] = {
427
+ ...r,
428
+ collapsed: !0,
429
+ collapsedByDirection: n.from
430
+ }, de(e, ce(i, e.containerSize));
431
+ }
432
+ case "EXPAND_PANEL": {
433
+ const t = e.panels.findIndex((d) => d.id === n.id);
434
+ if (t === -1 || n.targetSize !== void 0 && e.containerSize <= 0)
435
+ return e;
436
+ const r = e.panels[t];
437
+ if (!((n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) && r.collapsed) || r.collapsedByDirection !== null && r.collapsedByDirection !== n.from)
438
+ return e;
439
+ const i = {
440
+ ...r,
441
+ collapsed: !1,
442
+ collapsedByDirection: null,
443
+ preferredPixelSize: re(r) ? r.preferenceBeforeCollapse : r.preferredPixelSize,
444
+ preferredPercentageSize: re(r) ? r.preferredPercentageSize : r.preferenceBeforeCollapse
445
+ }, s = [...e.panels];
446
+ s[t] = i;
447
+ const l = n.targetSize === void 0 ? s : _t(s, n.id, n.targetSize, e.containerSize);
448
+ return de(e, ce(l, e.containerSize));
449
+ }
450
+ case "RESTORE_LAYOUT": {
451
+ if (n.entries.length !== e.panels.length || e.containerSize <= 0)
452
+ return e;
453
+ const t = new Map(n.entries.map((o) => [o.id, o]));
454
+ if (e.panels.some((o) => !t.has(o.id)))
455
+ return e;
456
+ const r = e.panels.map((o) => {
457
+ const i = t.get(o.id);
458
+ if (!i)
459
+ return o;
460
+ const s = qe(o, i.size, e.containerSize), l = o.collapseFromStart || o.collapseFromEnd;
461
+ return i.collapsed && l ? { ...s, collapsed: !0, collapsedByDirection: o.collapsedByDirection ?? je(o) } : s.collapsed ? { ...s, collapsed: !1, collapsedByDirection: null } : s;
462
+ });
463
+ return An.debug("restore layout", { containerSize: e.containerSize, entries: n.entries }), de(e, ce(r, e.containerSize));
464
+ }
465
+ default:
466
+ return e;
467
+ }
468
+ }, Mt = new Le(ke.INFO, "[resize-panels]"), Lt = 200, At = "\0handle", Dt = ({ direction: e, style: n, onLayout: t, autoSaveId: r, showDebugInfo: o = !1 }) => {
469
+ const [i, s] = Kn(Ct, Et), [l, d] = Ee({}), [c, g] = Ee({}), a = H(null), [N, f] = Ee(""), L = H({}), Y = H(t);
470
+ Y.current = t, Se(() => {
471
+ const u = a.current;
472
+ if (!u || typeof ResizeObserver > "u")
473
+ return;
474
+ let p = Number.NaN;
475
+ const h = (_) => {
476
+ _ !== p && (p = _, s({ type: "SET_CONTAINER_SIZE", containerSize: _ }));
477
+ }, z = new ResizeObserver((_) => {
478
+ h(Me(u, e, _[0]).content);
479
+ });
480
+ return z.observe(u), h(Me(u, e).content), () => {
481
+ z.disconnect();
482
+ };
483
+ }, [e]);
484
+ const R = i.panels, $ = H(R);
485
+ $.current = R;
486
+ const F = k(() => {
487
+ const u = a.current, p = $.current;
488
+ if (!u)
489
+ return;
490
+ const h = Cn(u);
491
+ if (f((_) => {
492
+ const le = h.map((me) => me.dataset.panelId ?? At).join("\0");
493
+ return _ === le ? _ : le;
494
+ }), p.length === 0)
495
+ return;
496
+ const z = [];
497
+ for (const _ of h) {
498
+ const le = _.dataset.panelId;
499
+ le !== void 0 && z.push(le);
500
+ }
501
+ if (new Set(z).size !== z.length) {
502
+ Mt.error("Duplicate panel id in one group.", { ids: z });
503
+ return;
504
+ }
505
+ z.length !== p.length || z.every((_, le) => _ === p[le].id) || s({ type: "REORDER_PANELS", ids: z });
506
+ }, []);
507
+ Se(() => {
508
+ const u = a.current;
509
+ if (!u || (F(), typeof MutationObserver > "u"))
510
+ return;
511
+ const p = new MutationObserver((h) => {
512
+ ht(h) && F();
513
+ });
514
+ return p.observe(u, { childList: !0, subtree: !0 }), () => {
515
+ p.disconnect();
516
+ };
517
+ }, [F]), Se(() => {
518
+ F();
519
+ }, [F, R]);
520
+ const S = w(() => R.map((u) => u.size), [R]), M = i.containerSize > 0;
521
+ Se(() => {
522
+ !M || S.length === 0 || Y.current?.(S);
523
+ }, [S, M]);
524
+ const P = H(null);
525
+ J(() => {
526
+ if (!r || P.current === r || !M || R.length === 0)
527
+ return;
528
+ P.current = r;
529
+ const u = gt(r);
530
+ u && s({ type: "RESTORE_LAYOUT", entries: u });
531
+ }, [r, M, R.length]);
532
+ const j = H(null);
533
+ J(() => {
534
+ if (!(r && P.current === r && M) || R.length === 0)
535
+ return;
536
+ const u = R.map((h) => ({ id: h.id, size: Rt(h, i.containerSize), collapsed: h.collapsed }));
537
+ j.current = { id: r, entries: u };
538
+ const p = setTimeout(() => {
539
+ j.current = null, xn(r, u);
540
+ }, Lt);
541
+ return () => {
542
+ clearTimeout(p);
543
+ };
544
+ }, [r, R, i.containerSize, M]), J(() => () => {
545
+ const u = j.current;
546
+ u && (j.current = null, xn(u.id, u.entries));
547
+ }, []);
548
+ const E = k((u) => {
549
+ const p = JSON.stringify(u);
550
+ L.current[u.id] !== p && (L.current[u.id] = p, s({ type: "REGISTER_PANEL", panel: u }));
551
+ }, []), A = k((u) => {
552
+ delete L.current[u], s({ type: "UNREGISTER_PANEL", id: u }), d((p) => {
553
+ if (!(u in p))
554
+ return p;
555
+ const h = { ...p };
556
+ return delete h[u], h;
557
+ });
558
+ }, []), v = k((u, p, h) => {
559
+ s({ type: "RESIZE_PANELS", startId: u, endId: p, startSize: h });
560
+ }, []), Q = k((u, p) => {
561
+ s({ type: "COLLAPSE_PANEL", id: u, from: p });
562
+ }, []), D = k((u, p, h) => {
563
+ s({ type: "EXPAND_PANEL", id: u, from: p, targetSize: h });
564
+ }, []), b = k((u) => R.find((p) => p.id === u), [R]), x = k((u, p) => {
565
+ d((h) => {
566
+ if (p === null) {
567
+ if (!(u in h))
568
+ return h;
569
+ const _ = { ...h };
570
+ return delete _[u], _;
571
+ }
572
+ const z = h[u];
573
+ return z && z.pixelSize === p.pixelSize && z.percentageSize === p.percentageSize ? h : { ...h, [u]: p };
574
+ });
575
+ }, []), W = k((u, p) => {
576
+ g((h) => {
577
+ if (p === null) {
578
+ if (!(u in h))
579
+ return h;
580
+ const _ = { ...h };
581
+ return delete _[u], _;
582
+ }
583
+ const z = h[u];
584
+ return z && z.thickness === p.thickness && z.visible === p.visible && z.direction === p.direction && z.startPanelId === p.startPanelId && z.endPanelId === p.endPanelId ? h : { ...h, [u]: p };
585
+ });
586
+ }, []), G = w(
587
+ () => ({
588
+ direction: e,
589
+ panels: R,
590
+ containerSize: i.containerSize,
591
+ layoutOrderKey: N,
592
+ showDebugInfo: o,
593
+ registerPanel: E,
594
+ unregisterPanel: A,
595
+ resizePanels: v,
596
+ collapsePanel: Q,
597
+ expandPanel: D,
598
+ getPanel: b,
599
+ reportPanelMeasurement: x,
600
+ panelMeasurements: l,
601
+ reportHandleMeasurement: W,
602
+ handleMeasurements: c,
603
+ layoutConstraintViolation: i.violation
604
+ }),
605
+ [e, R, i.containerSize, N, i.violation, o, E, A, v, Q, D, b, x, l, W, c]
606
+ ), X = w(
607
+ () => ({
608
+ // 見た目に関わる既定値は利用者が上書きできる
609
+ width: "100%",
610
+ height: "100%",
611
+ minWidth: "0px",
612
+ minHeight: "0px",
613
+ // ハンドルは境界をまたいで描かれるため、その張り出しでスクロールバーを出さない
614
+ overflow: "hidden",
615
+ ...n,
616
+ // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると
617
+ // 配分結果と描画が一致しなくなるため、最後に適用して上書きを受け付けない:
618
+ // gap はパネルの合計に含まれない隙間を作り、flex-direction の反転は DOM 順と視覚順をずらし、
619
+ // writing-mode は主軸の向きそのものを変えてしまう
620
+ display: "flex",
621
+ flexDirection: e === "horizontal" ? "row" : "column",
622
+ alignItems: "stretch",
623
+ gap: "0px",
624
+ position: "relative",
625
+ boxSizing: "border-box",
626
+ writingMode: "horizontal-tb"
627
+ }),
628
+ [e, n]
629
+ );
630
+ return { groupRef: a, contextValue: G, groupStyle: X };
631
+ }, er = (e) => {
632
+ const { getPanel: n, collapsePanel: t, expandPanel: r } = Je(), o = n(e), i = k(
633
+ (d) => {
634
+ t(e, d);
635
+ },
636
+ [t, e]
637
+ ), s = k(
638
+ (d, c) => {
639
+ r(e, d, c);
640
+ },
641
+ [r, e]
642
+ ), l = k(
643
+ (d, c) => {
644
+ o?.collapsed ? s(d, c) : i(d);
645
+ },
646
+ [o?.collapsed, i, s]
647
+ );
648
+ return w(
649
+ () => ({
650
+ panel: o,
651
+ isCollapsed: o?.collapsed ?? !1,
652
+ canCollapseFromStart: o?.collapseFromStart ?? !1,
653
+ canCollapseFromEnd: o?.collapseFromEnd ?? !1,
654
+ collapse: i,
655
+ expand: s,
656
+ toggle: l
657
+ }),
658
+ [o, i, s, l]
659
+ );
660
+ }, Ot = ({ panel: e, containerAxisSize: n, containerLabel: t }) => {
661
+ if (!e)
662
+ return { sizeDisplay: "-", preferenceDisplay: "-", boundsDisplay: "-", containerDisplay: "-", headlineLabel: "Unregistered", titleText: "Unregistered" };
663
+ const r = e.sizeUnit === "pixels", o = `${e.size.toFixed(3)}px / ${Rn(e.size, n).toFixed(3)}%`, i = r ? `${e.preferredPixelSize.toFixed(3)}px` : `${e.preferredPercentageSize.toFixed(3)}%`, s = be(e, n), l = `${s.min.toFixed(1)} - ${s.max.toFixed(1)}px`, d = Number.isFinite(n) ? `${n.toFixed(3)}px` : "-", c = r ? "Fixed" : "Flexible", g = [c, `${t}: ${d}`, `size: ${o}`, `preference: ${i}`, `bounds: ${l}`].join(`
664
+ `);
665
+ return { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: l, containerDisplay: d, headlineLabel: c, titleText: g };
666
+ }, Tt = Ze(({ panel: e, containerAxisSize: n, direction: t }) => {
667
+ const r = t === "horizontal" ? "container width" : "container height", { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: s, containerDisplay: l, headlineLabel: d, titleText: c } = w(() => Ot({ panel: e, containerAxisSize: n, containerLabel: r }), [e, n, r]);
668
+ return /* @__PURE__ */ ue("div", { style: {
669
+ position: "absolute",
670
+ top: 2,
671
+ left: 2,
672
+ zIndex: 30,
673
+ pointerEvents: "none",
674
+ maxWidth: "calc(100% - 4px)",
675
+ padding: "2px 4px",
676
+ borderRadius: 4,
677
+ border: "1px solid rgba(255,255,255,0.1)",
678
+ backgroundColor: "rgba(15, 23, 42, 0.78)",
679
+ color: "#e2e8f0",
680
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
681
+ fontSize: 10,
682
+ lineHeight: 1.35,
683
+ whiteSpace: "pre",
684
+ overflow: "hidden",
685
+ textOverflow: "ellipsis"
686
+ }, title: c, "data-panel-debug-info": "", children: [
687
+ /* @__PURE__ */ ue("div", { children: [
688
+ d,
689
+ " · ",
690
+ r,
691
+ ": ",
692
+ l
693
+ ] }),
694
+ /* @__PURE__ */ ue("div", { children: [
695
+ "size: ",
696
+ o
697
+ ] }),
698
+ /* @__PURE__ */ ue("div", { children: [
699
+ "preference: ",
700
+ i
701
+ ] }),
702
+ /* @__PURE__ */ ue("div", { children: [
703
+ "bounds: ",
704
+ s
705
+ ] })
706
+ ] });
707
+ }), zn = new Le(ke.INFO, "[resize-panels]"), Ft = {
708
+ both: { collapseFromStart: !0, collapseFromEnd: !0 },
709
+ start: { collapseFromStart: !0, collapseFromEnd: !1 },
710
+ end: { collapseFromStart: !1, collapseFromEnd: !0 }
711
+ }, Bt = (e) => {
712
+ if (!e)
713
+ return { collapseFromStart: !1, collapseFromEnd: !1 };
714
+ const n = Ft[e.from];
715
+ if (!n)
716
+ throw new Error("Invalid collapsible configuration: unsupported 'from' value");
717
+ return n;
718
+ }, kt = (e) => {
719
+ const n = Math.max(0, e.value);
720
+ return e.unit === "pixels" ? { sizeUnit: "pixels", preferredPixelSize: n, preferredPercentageSize: 0 } : { sizeUnit: "percentage", preferredPercentageSize: n, preferredPixelSize: 0 };
721
+ }, Ht = ({ size: e, panel: n, registration: t, containerSize: r, isCollapsed: o }) => {
722
+ if (o)
723
+ return { flexBasis: "0px", flexGrow: 0, flexShrink: 0 };
724
+ if (!n || r <= 0) {
725
+ const d = t.sizeUnit === "pixels";
726
+ return {
727
+ flexBasis: d ? `${t.preferredPixelSize}px` : `${t.preferredPercentageSize}%`,
728
+ flexGrow: d ? 0 : t.preferredPercentageSize,
729
+ flexShrink: d ? 0 : 1
730
+ };
731
+ }
732
+ if (n.sizeUnit === "pixels")
733
+ return { flexBasis: `${e}px`, flexGrow: 0, flexShrink: 0 };
734
+ const i = be(n, r), s = e < i.max - C, l = s && e > i.min + C;
735
+ return { flexBasis: `${e}px`, flexGrow: s ? n.preferredPercentageSize : 0, flexShrink: l ? 1 : 0 };
736
+ }, nr = Ze(
737
+ ({ id: e, defaultSize: n = { value: 50, unit: "percentage" }, minSize: t, maxSize: r, className: o, style: i, children: s, collapsible: l, defaultCollapsed: d = !1, pixelAdjustPriority: c, flexAdjustPriority: g, contentOverflow: a = "auto", ...N }) => {
738
+ const { direction: f, registerPanel: L, unregisterPanel: Y, getPanel: R, containerSize: $, showDebugInfo: F, reportPanelMeasurement: S } = Je(), M = H(null), P = In(), E = H(e || `panel-${P}`).current;
739
+ J(() => {
740
+ e && e !== E && zn.warn("Panel id prop change after mount is ignored.", { currentId: E, attemptedId: e });
741
+ }, [e, E]);
742
+ const A = w(() => Bt(l), [l]), v = A.collapseFromStart || A.collapseFromEnd;
743
+ J(() => {
744
+ d && !v && zn.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.", { panelId: E });
745
+ }, [d, v, E]);
746
+ const Q = w(() => {
747
+ const p = ut(n) ?? { value: 50, unit: "percentage" };
748
+ return {
749
+ id: E,
750
+ ...kt(p),
751
+ minSize: t,
752
+ maxSize: r,
753
+ ...A,
754
+ collapsed: v && d,
755
+ pixelAdjustPriority: c,
756
+ flexAdjustPriority: g
757
+ };
758
+ }, [E, n, t, r, A, v, d, c, g]);
759
+ Se(() => {
760
+ L(Q);
761
+ }, [L, Q]), Se(() => () => {
762
+ Y(E);
763
+ }, [Y, E]);
764
+ const D = R(E), b = D?.size ?? 0, x = D?.collapsed ?? !1, W = H($);
765
+ W.current = $;
766
+ const G = k(() => {
767
+ const p = M.current;
768
+ if (!p)
769
+ return;
770
+ const h = Me(p, f).border;
771
+ S(E, { pixelSize: h, percentageSize: Rn(h, W.current) });
772
+ }, [f, E, S]);
773
+ J(() => {
774
+ if (!F) {
775
+ S(E, null);
776
+ return;
777
+ }
778
+ const p = M.current;
779
+ if (!p || typeof ResizeObserver > "u") {
780
+ G();
781
+ return;
782
+ }
783
+ const h = new ResizeObserver(G);
784
+ return h.observe(p), G(), () => {
785
+ h.disconnect(), S(E, null);
786
+ };
787
+ }, [F, G, E, S]);
788
+ const X = w(() => {
789
+ const p = { overflow: "hidden", isolation: "isolate" }, h = x ? { ...f === "horizontal" ? { width: "0px" } : { height: "0px" }, pointerEvents: "none", visibility: "hidden", display: "none" } : {};
790
+ return {
791
+ ...p,
792
+ ...i,
793
+ // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると配分結果と
794
+ // 描画が一致しなくなるため、最後に適用して上書きを受け付けない:
795
+ // flex の三つ組は配分器が決めた長さそのもの、margin はパネルの合計に含まれない隙間を作り、
796
+ // order は DOM 順と視覚順をずらす
797
+ ...Ht({ size: b, panel: D, registration: Q, containerSize: $, isCollapsed: x }),
798
+ order: 0,
799
+ margin: 0,
800
+ // 内容を通常フローで内容ボックスいっぱいに伸ばすための入れ物 (パディングを効かせる唯一の形)
801
+ display: "flex",
802
+ flexDirection: "column",
803
+ position: "relative",
804
+ boxSizing: "border-box",
805
+ // 主軸の縮小をコンテンツの固有幅に妨げられないようにし、
806
+ // 上限側のクランプ (max-w-* のようなユーティリティクラスを含む) も受け付けない。
807
+ // 配分器が配った長さより短く描くと、状態と描画が食い違ったままハンドルが動かなくなる
808
+ minWidth: 0,
809
+ minHeight: 0,
810
+ maxWidth: "none",
811
+ maxHeight: "none",
812
+ ...f === "horizontal" ? { height: "100%" } : { width: "100%" },
813
+ ...h
814
+ };
815
+ }, [b, f, x, D, Q, $, i]), u = w(
816
+ () => ({
817
+ // 内容は通常フローの伸縮子として置く。絶対配置にするとパディングボックスを基準にしてしまい、
818
+ // 利用者がパネルへ与えたパディングが何の効果も持たなくなる
819
+ flex: "1 1 auto",
820
+ position: "relative",
821
+ overflow: a,
822
+ display: "flex",
823
+ flexDirection: "column",
824
+ minWidth: "0px",
825
+ minHeight: "0px"
826
+ }),
827
+ [a]
828
+ );
829
+ return /* @__PURE__ */ ue(
830
+ "div",
831
+ {
832
+ ...N,
833
+ ref: M,
834
+ className: Ce("panel", o),
835
+ style: X,
836
+ "data-panel-id": E,
837
+ "data-panel-size": b,
838
+ "data-panel-size-unit": D?.sizeUnit ?? "percentage",
839
+ "data-panel-collapsible": v,
840
+ "data-panel-collapse-start": A.collapseFromStart,
841
+ "data-panel-collapse-end": A.collapseFromEnd,
842
+ "data-panel-collapsed": x,
843
+ "aria-hidden": x,
844
+ children: [
845
+ /* @__PURE__ */ ie("div", { style: u, children: s }),
846
+ F && /* @__PURE__ */ ie(Tt, { panel: D, containerAxisSize: $, direction: f })
847
+ ]
848
+ }
849
+ );
850
+ }
851
+ ), $t = Xn(() => import("./GlobalDebugOverlay-DQtUdNeF.js").then((e) => ({ default: e.GlobalDebugOverlayGate }))), Gt = [], Ut = {};
852
+ let yn = 0;
853
+ const Wt = () => (yn += 1, `panel-group-${yn}`), Vt = (e) => {
854
+ const n = e.reason === "minimum-exceeded", t = n ? "Layout unavailable: minimum panel sizes exceed the container." : "Layout unavailable: panels cannot fill the container with their maximum sizes.", r = n ? `Min required: ${Math.ceil(e.totalMinimumSize)}px | Available: ${Math.floor(e.availableContainerSize)}px` : `Max total: ${Math.floor(e.totalMaximumSize)}px | Needed: ${Math.floor(e.availableContainerSize)}px`;
855
+ return { summary: t, detail: r };
856
+ }, jt = (e, n) => e.map((t) => {
857
+ const r = n[t.id];
858
+ return r ? { ...t, measuredPixelSize: r.pixelSize, measuredPercentageSize: r.percentageSize } : t;
859
+ }), Pn = (e, n, t) => {
860
+ const r = Me(e, "horizontal"), o = Me(e, "vertical"), i = e.getBoundingClientRect(), s = r.content > 0 ? r.content : n ?? i.width, l = o.content > 0 ? o.content : t ?? i.height;
861
+ return { width: s, height: l };
862
+ }, tr = (e) => {
863
+ const { id: n, className: t, style: r, children: o, direction: i, onLayout: s, autoSaveId: l, showDebugInfo: d, ...c } = e, { groupRef: g, contextValue: a, groupStyle: N } = Dt(e), [f, L] = Ee({ width: 0, height: 0 }), Y = a.layoutConstraintViolation, R = !!Y, $ = w(() => {
864
+ if (!Y)
865
+ return null;
866
+ const { summary: b, detail: x } = Vt(Y);
867
+ return /* @__PURE__ */ ue(
868
+ "div",
869
+ {
870
+ className: "flex w-full flex-1 flex-col items-center justify-center gap-2 rounded-lg border border-slate-300 border-dashed bg-slate-100/70 px-6 py-8 text-center text-slate-600 text-sm dark:border-slate-600 dark:bg-slate-800/50 dark:text-slate-200",
871
+ "data-panel-group-placeholder": "constraint-violation",
872
+ children: [
873
+ /* @__PURE__ */ ie("span", { children: b }),
874
+ /* @__PURE__ */ ie("span", { className: "text-slate-500 text-xs dark:text-slate-400", children: x })
875
+ ]
876
+ }
877
+ );
878
+ }, [Y]), F = H(null);
879
+ F.current === null && (F.current = n ?? Wt());
880
+ const S = F.current, M = n ?? S, P = a.showDebugInfo && a.panels.length > 0, j = P ? a.panels : Gt, E = P ? a.panelMeasurements : Ut, A = w(() => {
881
+ if (!P)
882
+ return [];
883
+ const b = Object.values(a.handleMeasurements);
884
+ return b.length <= 1 ? b : b.slice().sort((x, W) => x.id.localeCompare(W.id));
885
+ }, [a.handleMeasurements, P]), v = f.width, Q = f.height;
886
+ Se(() => {
887
+ if (!P) {
888
+ L({ width: 0, height: 0 });
889
+ return;
890
+ }
891
+ if (typeof window > "u" || typeof ResizeObserver > "u")
892
+ return;
893
+ const b = g.current;
894
+ if (!b)
895
+ return;
896
+ const x = (G) => {
897
+ L((X) => X.width === G.width && X.height === G.height ? X : G);
898
+ }, W = new ResizeObserver((G) => {
899
+ for (const X of G) {
900
+ if (X.target !== b)
901
+ continue;
902
+ const u = Pn(b, X.contentRect.width, X.contentRect.height);
903
+ x(u);
904
+ }
905
+ });
906
+ return W.observe(b), x(Pn(b)), () => {
907
+ W.disconnect();
908
+ };
909
+ }, [g, P]);
910
+ const D = w(() => jt(j, E), [j, E]);
911
+ return J(() => {
912
+ if (!P)
913
+ return;
914
+ let b = !1, x = null;
915
+ return import("./debugOverlayStore-D7FT6zPE.js").then((W) => {
916
+ b || (x = W, W.enableDebugOverlayGroup(S));
917
+ }), () => {
918
+ b = !0, x && (x.disableDebugOverlayGroup(S), x.removeDebugOverlayGroup(S));
919
+ };
920
+ }, [P, S]), J(() => {
921
+ if (!P)
922
+ return;
923
+ let b = !1;
924
+ return import("./debugOverlayStore-D7FT6zPE.js").then((x) => {
925
+ b || x.updateDebugOverlayGroup(S, {
926
+ displayName: M,
927
+ direction: i,
928
+ containerSize: {
929
+ width: v,
930
+ height: Q
931
+ },
932
+ panels: D,
933
+ handles: A
934
+ });
935
+ }), () => {
936
+ b = !0;
937
+ };
938
+ }, [P, S, M, i, v, Q, D, A]), /* @__PURE__ */ ue(Ln.Provider, { value: a, children: [
939
+ /* @__PURE__ */ ue("div", { ...c, ref: g, className: Ce("panel-group", i === "horizontal" ? "flex-row" : "flex-col", t), style: N, "data-panel-group-id": n, "data-panel-group-direction": i, children: [
940
+ o,
941
+ R && $ ? /* @__PURE__ */ ie(
942
+ "div",
943
+ {
944
+ className: "pointer-events-auto",
945
+ style: {
946
+ position: "absolute",
947
+ inset: 0,
948
+ // パネル内部要素 (VirtualScroll のスクロールバー z-50 等) を完全に隠蔽するため zIndex を 60 に設定
949
+ zIndex: 60,
950
+ display: "flex",
951
+ flexDirection: "column",
952
+ alignItems: "center",
953
+ justifyContent: "center",
954
+ backgroundColor: "rgba(248, 250, 252, 0.82)",
955
+ backdropFilter: "blur(2px)"
956
+ },
957
+ children: $
958
+ }
959
+ ) : null
960
+ ] }),
961
+ P && /* @__PURE__ */ ie(Yn, { fallback: null, children: /* @__PURE__ */ ie($t, { groupId: S }) })
962
+ ] });
963
+ }, Kt = {
964
+ display: "none",
965
+ pointerEvents: "none",
966
+ visibility: "hidden"
967
+ }, Yt = {
968
+ display: "none"
969
+ }, _e = (e, n) => typeof e != "number" || !Number.isFinite(e) || e <= 0 ? n : e, Xt = (e) => {
970
+ const n = Math.round(e);
971
+ return n % 2 === 0 ? n : n + 1;
972
+ }, En = (e) => !e || typeof window > "u" ? !1 : window.getComputedStyle(e).direction === "rtl", wn = (e, n, t) => {
973
+ const r = e.collapsed ? 0 : e.size, o = n.collapsed ? 0 : n.size, i = r + o;
974
+ if (i <= 0)
975
+ return;
976
+ const s = be(e, t), l = be(n, t), d = Math.max(s.min, i - l.max), c = Math.max(d, Math.min(s.max, i - l.min));
977
+ if (e.collapsed)
978
+ return { position: 0, lower: 0, upper: e.collapsedByDirection === "end" ? Math.max(0, c) : 0, resizeLower: d, resizeUpper: c };
979
+ if (n.collapsed) {
980
+ const N = n.collapsedByDirection === "start";
981
+ return { position: i, lower: N ? Math.min(i, d) : i, upper: i, resizeLower: d, resizeUpper: c };
982
+ }
983
+ const g = Math.min(r, e.collapseFromEnd ? 0 : d), a = Math.max(r, g, n.collapseFromStart ? i : c);
984
+ return { position: r, lower: g, upper: a, resizeLower: d, resizeUpper: c };
985
+ }, rr = Ze((e) => {
986
+ const { id: n, disabled: t = !1, className: r, style: o, children: i, onDragging: s, thickness: l, indicator: d = !0, indicatorThickness: c, indicatorLength: g, indicatorBarThickness: a, indicatorBarLength: N, title: f, onPointerDown: L, onKeyDown: Y, ...R } = e, { direction: $, resizePanels: F, getPanel: S, collapsePanel: M, expandPanel: P, panels: j, layoutOrderKey: E, reportHandleMeasurement: A, containerSize: v, layoutConstraintViolation: Q } = Je(), [D, b] = Ee(!1), [x, W] = Ee({ start: null, end: null }), G = H(null), X = H(null), u = H({ getPanel: S, containerSize: v });
987
+ u.current = { getPanel: S, containerSize: v };
988
+ const p = H(""), h = H(""), z = H(null), _ = H(null), le = In(), me = H(n ?? `resize-handle-${le}`), ge = n ?? me.current, y = $ === "horizontal", He = !!Q, ee = t || He, en = k(() => {
989
+ const m = G.current, q = Te(m);
990
+ if (!(m && q))
991
+ return;
992
+ const B = Cn(q), O = B.indexOf(m);
993
+ let T = "", V = "";
994
+ for (let U = O - 1; U >= 0; U -= 1) {
995
+ const I = B[U].dataset.panelId;
996
+ if (I !== void 0) {
997
+ T = I;
998
+ break;
999
+ }
1000
+ }
1001
+ for (let U = O + 1; U < B.length; U += 1) {
1002
+ const I = B[U].dataset.panelId;
1003
+ if (I !== void 0) {
1004
+ V = I;
1005
+ break;
1006
+ }
1007
+ }
1008
+ T === p.current && V === h.current || (p.current = T, h.current = V, W({ start: T || null, end: V || null }));
1009
+ }, []);
1010
+ J(() => {
1011
+ en();
1012
+ }, [en, E]), J(() => () => {
1013
+ z.current?.();
1014
+ }, []);
1015
+ const nn = k(
1016
+ (m) => {
1017
+ if (ee || z.current || m.button !== 0)
1018
+ return;
1019
+ const q = S(p.current), B = S(h.current);
1020
+ if (!(q && B))
1021
+ return;
1022
+ m.preventDefault(), m.stopPropagation();
1023
+ const O = p.current, T = h.current, V = q.size, U = q.size + B.size, I = y ? m.clientX : m.clientY, ne = Te(G.current), ye = y && En(ne) ? -1 : 1, te = ne ? mt(ne, $) : 1, xe = m.pointerId, ve = m.currentTarget;
1024
+ ve.setPointerCapture?.(xe), b(!0), s?.(!0);
1025
+ let sn = 0, Ne = null;
1026
+ const ln = (K) => {
1027
+ const Pe = ((y ? K.clientX : K.clientY) - I) * ye / te, Re = V + Pe, Ue = U - Re, Oe = u.current, We = Oe.getPanel(O), Ve = Oe.getPanel(T);
1028
+ if (!(We && Ve))
1029
+ return;
1030
+ const fn = Math.min(Oe.containerSize * vn, Nn), hn = Math.min(Oe.containerSize * st, lt);
1031
+ if (Ve.collapsed) {
1032
+ Ue > hn && P(T, "start", Ue);
1033
+ return;
1034
+ }
1035
+ if (We.collapsed) {
1036
+ Re > hn && P(O, "end", Re);
1037
+ return;
1038
+ }
1039
+ if (Ve.collapseFromStart && Ue <= fn) {
1040
+ M(T, "start");
1041
+ return;
1042
+ }
1043
+ if (We.collapseFromEnd && Re <= fn) {
1044
+ M(O, "end");
1045
+ return;
1046
+ }
1047
+ F(O, T, Re);
1048
+ }, an = (K) => {
1049
+ if (K.pointerId !== xe)
1050
+ return;
1051
+ K.preventDefault(), K.stopPropagation();
1052
+ const Pe = performance.now();
1053
+ if (Pe - sn < it) {
1054
+ Ne = K;
1055
+ return;
1056
+ }
1057
+ sn = Pe, Ne = null, ln(K);
1058
+ };
1059
+ let cn = !0;
1060
+ const De = () => {
1061
+ cn && (cn = !1, z.current = null, b(!1), s?.(!1), document.removeEventListener("pointermove", an), document.removeEventListener("pointerup", dn), document.removeEventListener("pointercancel", un), ve.removeEventListener("lostpointercapture", pn), ve.hasPointerCapture?.(xe) && ve.releasePointerCapture(xe));
1062
+ }, dn = (K) => {
1063
+ if (K.pointerId === xe) {
1064
+ if (Ne) {
1065
+ const Pe = Ne;
1066
+ Ne = null, ln(Pe);
1067
+ }
1068
+ De();
1069
+ }
1070
+ }, un = (K) => {
1071
+ K.pointerId === xe && De();
1072
+ }, pn = (K) => {
1073
+ K.pointerId === xe && De();
1074
+ };
1075
+ document.addEventListener("pointermove", an), document.addEventListener("pointerup", dn), document.addEventListener("pointercancel", un), ve.addEventListener("lostpointercapture", pn), z.current = De;
1076
+ },
1077
+ [ee, y, $, S, F, M, P, s]
1078
+ ), tn = k(
1079
+ (m) => {
1080
+ if (ee)
1081
+ return;
1082
+ const q = y ? "ArrowLeft" : "ArrowUp", B = y ? "ArrowRight" : "ArrowDown";
1083
+ if (m.key !== q && m.key !== B)
1084
+ return;
1085
+ const O = p.current, T = h.current, V = S(O), U = S(T);
1086
+ if (!(V && U))
1087
+ return;
1088
+ const I = wn(V, U, v);
1089
+ if (!I || I.upper - I.lower <= C)
1090
+ return;
1091
+ m.preventDefault(), m.stopPropagation();
1092
+ const ne = m.shiftKey ? mn * 5 : mn, ye = y && En(Te(G.current)) ? -1 : 1, te = (m.key === B ? ne : -ne) * ye;
1093
+ if (V.collapsed) {
1094
+ te > 0 && P(O, "end");
1095
+ return;
1096
+ }
1097
+ if (U.collapsed) {
1098
+ te < 0 && P(T, "start");
1099
+ return;
1100
+ }
1101
+ if (te < 0 && V.collapseFromEnd && I.position <= I.resizeLower + C) {
1102
+ M(O, "end");
1103
+ return;
1104
+ }
1105
+ if (te > 0 && U.collapseFromStart && I.position >= I.resizeUpper - C) {
1106
+ M(T, "start");
1107
+ return;
1108
+ }
1109
+ F(O, T, V.size + te);
1110
+ },
1111
+ [ee, y, S, F, M, P, v]
1112
+ ), ae = typeof d == "object" && d !== null ? d : void 0, $e = d === !1 || ae?.visible === !1, oe = Math.max(1, _e(l, Zn)), Dn = y ? Qn : et, On = y ? tt : rt, pe = Math.min(oe, Math.max(1, _e(c ?? ae?.thickness, Jn))), ze = Math.max(1, _e(g ?? ae?.length, Dn)), we = Math.min(pe, Math.max(1, _e(a ?? ae?.barThickness, nt))), Ie = Math.min(ze, Math.max(1, _e(N ?? ae?.barLength, On))), fe = w(() => {
1113
+ const m = _n(v), q = (I) => {
1114
+ const ne = j[I];
1115
+ return ne ? ne.collapsed || ne.size <= m : !1;
1116
+ }, B = (I, ne) => {
1117
+ let ye = 0;
1118
+ for (let te = I; te >= 0 && te < j.length && q(te); te += ne)
1119
+ ye += 1;
1120
+ return ye;
1121
+ }, O = j.findIndex((I) => I.id === x.start), T = j.findIndex((I) => I.id === x.end), V = O >= 0 ? B(O, -1) : 0, U = T >= 0 ? B(T, 1) : 0;
1122
+ return { groupSize: V + U + 1, overlapIndex: V };
1123
+ }, [x.start, x.end, j, v]), se = w(() => He ? !0 : fe.groupSize <= 1 ? !1 : fe.overlapIndex > 0 && fe.overlapIndex < fe.groupSize - 1, [fe, He]), Ae = w(() => {
1124
+ if (fe.groupSize <= 1 || se)
1125
+ return 0;
1126
+ const m = Xt(Math.max(ot, pe + 4));
1127
+ return (fe.overlapIndex === 0 ? -0.5 : 0.5) * m;
1128
+ }, [fe, se, pe]), Tn = w(() => {
1129
+ const m = {
1130
+ // 長さ 0 のフレックスアイテム: フレックスレイアウトがこれを境界そのものへ配置する
1131
+ position: "relative",
1132
+ flex: "0 0 0px",
1133
+ alignSelf: "stretch",
1134
+ // DOM 順を配置順の真実として扱うため、クラス由来の order で並びが変わらないようにする
1135
+ order: 0,
1136
+ margin: 0,
1137
+ overflow: "visible",
1138
+ ...y ? { width: 0, minWidth: 0 } : { height: 0, minHeight: 0 }
1139
+ };
1140
+ return se ? { ...m, ...Kt } : m;
1141
+ }, [y, se]), rn = w(
1142
+ () => ({
1143
+ "--rp-handle-thickness": `${oe}px`,
1144
+ "--rp-indicator-thickness": `${pe}px`,
1145
+ "--rp-indicator-length": `${ze}px`,
1146
+ "--rp-indicator-bar-thickness": `${we}px`,
1147
+ "--rp-indicator-bar-length": `${Ie}px`
1148
+ }),
1149
+ [oe, pe, ze, we, Ie]
1150
+ ), Fn = w(() => ({
1151
+ ...rn,
1152
+ ...o,
1153
+ // ここから下は境界に載るという前提そのもの。利用者のスタイルやクラスで変わると
1154
+ // 操作領域の中心が境界から外れ、touch-action が戻るとタッチではスクロールが優先されてしまう
1155
+ position: "absolute",
1156
+ zIndex: 20,
1157
+ touchAction: "none",
1158
+ // 位置は論理プロパティで与える。アンカーは寸法 0 なので RTL でも同じ点に重なるが、
1159
+ // 「境界からの距離」という意図をそのまま表せる
1160
+ ...y ? { insetBlockStart: 0, insetInlineStart: `${-oe / 2}px`, width: `${oe}px`, height: "100%" } : { insetInlineStart: 0, insetBlockStart: `${-oe / 2}px`, height: `${oe}px`, width: "100%" }
1161
+ }), [y, oe, rn, o]), Bn = w(() => {
1162
+ if (se || $e)
1163
+ return Yt;
1164
+ const m = {
1165
+ width: `${y ? pe : ze}px`,
1166
+ height: `${y ? ze : pe}px`,
1167
+ flexShrink: 0
1168
+ };
1169
+ return Ae !== 0 && (m.position = "relative", y ? m.insetInlineStart = `${Ae}px` : m.insetBlockStart = `${Ae}px`), m;
1170
+ }, [se, $e, y, pe, ze, Ae]), kn = w(
1171
+ () => ({
1172
+ width: `${y ? we : Ie}px`,
1173
+ height: `${y ? Ie : we}px`,
1174
+ flexShrink: 0
1175
+ }),
1176
+ [y, we, Ie]
1177
+ ), Hn = w(
1178
+ () => Ce(
1179
+ "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1180
+ y ? "cursor-col-resize h-full" : "cursor-row-resize w-full",
1181
+ !ee && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1182
+ !ee && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1183
+ D && "bg-blue-200/80 dark:bg-blue-800/60",
1184
+ ee && "cursor-not-allowed opacity-50",
1185
+ "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1186
+ r
1187
+ ),
1188
+ [y, ee, D, r]
1189
+ ), $n = w(
1190
+ () => Ce(
1191
+ "pointer-events-none flex items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-inset ring-white/80 backdrop-blur-sm transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.85),0_1px_3px_rgba(15,23,42,0.18)]",
1192
+ "dark:bg-slate-800/95 dark:text-slate-200 dark:ring-slate-500/60 dark:shadow-[0_0_0_1px_rgba(148,163,184,0.45),0_1px_3px_rgba(2,6,23,0.55)]",
1193
+ D && "bg-blue-200/80 ring-blue-300 shadow-[0_0_0_1px_rgba(191,219,254,0.65),0_1px_4px_rgba(59,130,246,0.45)] dark:bg-blue-900/70 dark:ring-blue-400 dark:shadow-[0_0_0_1px_rgba(147,197,253,0.5),0_1px_4px_rgba(59,130,246,0.55)]",
1194
+ ae?.className
1195
+ ),
1196
+ [D, ae?.className]
1197
+ ), Gn = w(
1198
+ () => Ce(
1199
+ "pointer-events-none rounded-full bg-slate-600 transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.9)] dark:bg-slate-200 dark:shadow-[0_0_0_1px_rgba(15,23,42,0.55)]",
1200
+ D && "bg-blue-500 dark:bg-blue-300",
1201
+ !ee && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100",
1202
+ ae?.barClassName
1203
+ ),
1204
+ [D, ee, ae?.barClassName]
1205
+ );
1206
+ J(() => {
1207
+ if (ge === me.current)
1208
+ return;
1209
+ const m = me.current;
1210
+ me.current = ge, _.current = null, A(m, null);
1211
+ }, [A, ge]), J(() => {
1212
+ const m = {
1213
+ id: ge,
1214
+ thickness: se ? 0 : oe,
1215
+ direction: $,
1216
+ visible: !se && oe > at,
1217
+ startPanelId: x.start,
1218
+ endPanelId: x.end
1219
+ };
1220
+ _.current = m, A(ge, m);
1221
+ }, [ge, oe, se, $, x.start, x.end, A]), J(() => () => {
1222
+ A(me.current, null);
1223
+ }, [A]);
1224
+ const Un = k(
1225
+ (m) => {
1226
+ L?.(m), m.defaultPrevented || nn(m);
1227
+ },
1228
+ [L, nn]
1229
+ ), Wn = k(
1230
+ (m) => {
1231
+ Y?.(m), m.defaultPrevented || tn(m);
1232
+ },
1233
+ [Y, tn]
1234
+ ), on = `Resize ${y ? "columns" : "rows"} - Drag or use arrow keys to resize, drag to the edge to collapse/expand panels`, Ge = w(() => {
1235
+ const m = x.start === null ? void 0 : S(x.start), q = x.end === null ? void 0 : S(x.end);
1236
+ if (!(m && q) || v <= 0)
1237
+ return;
1238
+ const B = wn(m, q, v);
1239
+ if (!B)
1240
+ return;
1241
+ const O = (T) => Math.round(T / v * 100);
1242
+ return { now: O(B.position), min: O(B.lower), max: O(B.upper) };
1243
+ }, [x.start, x.end, S, v]);
1244
+ return /* @__PURE__ */ ie("div", { ref: G, style: Tn, "data-resize-handle-anchor": "", children: /* @__PURE__ */ ie(
1245
+ "button",
1246
+ {
1247
+ ...R,
1248
+ type: "button",
1249
+ ref: X,
1250
+ className: Hn,
1251
+ style: Fn,
1252
+ onPointerDown: Un,
1253
+ onKeyDown: Wn,
1254
+ disabled: ee,
1255
+ role: "separator",
1256
+ "aria-orientation": y ? "vertical" : "horizontal",
1257
+ "aria-valuenow": Ge?.now,
1258
+ "aria-valuemin": Ge?.min,
1259
+ "aria-valuemax": Ge?.max,
1260
+ "aria-disabled": ee || void 0,
1261
+ "aria-hidden": se || void 0,
1262
+ "aria-label": R["aria-label"] ?? on,
1263
+ "data-resize-handle-id": ge,
1264
+ title: f ?? on,
1265
+ children: i || !$e && /* @__PURE__ */ ie("div", { className: $n, style: Bn, "data-resize-handle-indicator": "", "aria-hidden": "true", children: /* @__PURE__ */ ie("span", { className: Gn, style: kn, "data-resize-handle-indicator-bar": "", "aria-hidden": "true" }) })
1266
+ }
1267
+ ) });
1268
+ }), Qe = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), or = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-id="${Qe(e)}"]`), ir = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-group-id="${Qe(e)}"]`), sr = (e) => typeof document > "u" ? null : document.querySelector(`[data-resize-handle-id="${Qe(e)}"]`);
1269
+ export {
1270
+ Je as A,
1271
+ Dt as B,
1272
+ qn as P,
1273
+ nr as a,
1274
+ tr as b,
1275
+ Ln as c,
1276
+ rr as d,
1277
+ yt as e,
1278
+ _n as f,
1279
+ Fe as g,
1280
+ wt as h,
1281
+ Te as i,
1282
+ gn as j,
1283
+ Me as k,
1284
+ Cn as l,
1285
+ or as m,
1286
+ ir as n,
1287
+ Rt as o,
1288
+ sr as p,
1289
+ Et as q,
1290
+ re as r,
1291
+ gt as s,
1292
+ ut as t,
1293
+ Ct as u,
1294
+ Qt as v,
1295
+ be as w,
1296
+ xn as x,
1297
+ Rn as y,
1298
+ er as z
1299
+ };