react-bwin 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import f, { useRef as M, useEffect as W, forwardRef as Y, useState as j, useImperativeHandle as K, useMemo as V } from "react";
2
- import { createPortal as Z } from "react-dom";
3
- var J = Object.defineProperty, Q = (e, t, i) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, E = (e, t, i) => Q(e, typeof t != "symbol" ? t + "" : t, i);
4
- function tt(e = 0.7, t = 128) {
1
+ import f, { useRef as A, useEffect as W, forwardRef as X, useState as Y, useImperativeHandle as j, useMemo as K } from "react";
2
+ import { createPortal as V } from "react-dom";
3
+ var Z = Object.defineProperty, J = (e, t, i) => t in e ? Z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, y = (e, t, i) => J(e, typeof t != "symbol" ? t + "" : t, i);
4
+ function Q(e = 0.7, t = 128) {
5
5
  const i = 256 - t, n = Math.floor(Math.random() * i + t), s = Math.floor(Math.random() * i + t), o = Math.floor(Math.random() * i + t), h = Math.max(0.5, Math.random() * e);
6
6
  return `rgba(${n}, ${s}, ${o}, ${h})`;
7
7
  }
8
- function B(e = 2, t = 3) {
8
+ function S(e = 2, t = 3) {
9
9
  if (e < 0 || t < 0)
10
10
  throw new Error("Parameters must be non-negative numbers");
11
11
  const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "0123456789";
@@ -21,15 +21,15 @@ function B(e = 2, t = 3) {
21
21
  }
22
22
  return s;
23
23
  }
24
- function z(e, t) {
24
+ function B(e, t) {
25
25
  for (; t.firstChild; )
26
26
  e.append(t.firstChild);
27
27
  }
28
- function et(e, t) {
28
+ function tt(e, t) {
29
29
  const i = document.createElement("div");
30
- z(i, e), z(e, t), z(t, i);
30
+ B(i, e), B(e, t), B(t, i);
31
31
  }
32
- function C(e) {
32
+ function z(e) {
33
33
  if (typeof e == "number" && !isNaN(e))
34
34
  return e;
35
35
  if (typeof e == "string") {
@@ -50,10 +50,10 @@ function C(e) {
50
50
  }
51
51
  return NaN;
52
52
  }
53
- function it(e) {
53
+ function et(e) {
54
54
  return e !== null && typeof e == "object" && !Array.isArray(e) && Object.getPrototypeOf(e) === Object.prototype;
55
55
  }
56
- function nt(e, t) {
56
+ function it(e, t) {
57
57
  for (const i in t) {
58
58
  if (Object.hasOwn(e, i))
59
59
  throw new Error(`Key "${i}" already exists in target object`);
@@ -61,7 +61,7 @@ function nt(e, t) {
61
61
  }
62
62
  return e;
63
63
  }
64
- function st(e) {
64
+ function nt(e) {
65
65
  const t = document.createElement("template");
66
66
  return t.innerHTML = e.trim(), t.content;
67
67
  }
@@ -70,18 +70,18 @@ function N(e) {
70
70
  return null;
71
71
  if (typeof e == "string")
72
72
  try {
73
- const t = st(e);
73
+ const t = nt(e);
74
74
  return t.childNodes.length === 1 ? t.firstChild : t;
75
75
  } catch {
76
76
  return document.createTextNode(e);
77
77
  }
78
78
  return e instanceof Node ? e : document.createTextNode(String(e));
79
79
  }
80
- function R(e) {
80
+ function M(e) {
81
81
  const t = parseFloat(e.style.left) || 0, i = parseFloat(e.style.top) || 0, n = parseFloat(e.style.width) || 0, s = parseFloat(e.style.height) || 0;
82
82
  return { left: t, top: i, width: n, height: s };
83
83
  }
84
- const r = {
84
+ const a = {
85
85
  Top: "top",
86
86
  Right: "right",
87
87
  Bottom: "bottom",
@@ -91,47 +91,47 @@ const r = {
91
91
  Unknown: "unknown",
92
92
  Outside: "outside"
93
93
  };
94
- function ot(e) {
94
+ function st(e) {
95
95
  switch (e) {
96
- case r.Top:
97
- return r.Bottom;
98
- case r.Right:
99
- return r.Left;
100
- case r.Bottom:
101
- return r.Top;
102
- case r.Left:
103
- return r.Right;
96
+ case a.Top:
97
+ return a.Bottom;
98
+ case a.Right:
99
+ return a.Left;
100
+ case a.Bottom:
101
+ return a.Top;
102
+ case a.Left:
103
+ return a.Right;
104
104
  default:
105
105
  throw new Error(`[bwin] Invalid position: ${e}`);
106
106
  }
107
107
  }
108
- function ht({ width: e, height: t, x: i }) {
108
+ function ot({ width: e, height: t, x: i }) {
109
109
  return t / e * i;
110
110
  }
111
- function rt({ width: e, height: t, y: i }) {
111
+ function ht({ width: e, height: t, y: i }) {
112
112
  return e / t * i;
113
113
  }
114
- function at({ width: e, height: t, x: i }) {
114
+ function rt({ width: e, height: t, x: i }) {
115
115
  return t - t / e * i;
116
116
  }
117
- function lt({ width: e, height: t, y: i }) {
117
+ function at({ width: e, height: t, y: i }) {
118
118
  return e - e / t * i;
119
119
  }
120
- function dt(e, { clientX: t, clientY: i }) {
121
- const n = e.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, a = i - n.top;
122
- if (h < 0 || h > s || a < 0 || a > o)
123
- return r.Outside;
124
- const d = 0.3, l = ht({ width: s, height: o, x: h }), c = at({ width: s, height: o, x: h }), u = rt({ width: s, height: o, y: a }), g = lt({ width: s, height: o, y: a });
125
- return h < s * (0.5 - d / 2) && a > l && a < c ? r.Left : h > s * (0.5 + d / 2) && a < l && a > c ? r.Right : a < o * (0.5 - d / 2) && h > u && h < g ? r.Top : a > o * (0.5 + d / 2) && h < u && h > g ? r.Bottom : h > s * (0.5 - d / 2) && h < s * (0.5 + d / 2) && a > o * (0.5 - d / 2) && a < o * (0.5 + d / 2) ? r.Center : r.Unknown;
120
+ function lt(e, { clientX: t, clientY: i }) {
121
+ const n = e.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, r = i - n.top;
122
+ if (h < 0 || h > s || r < 0 || r > o)
123
+ return a.Outside;
124
+ const d = 0.3, l = ot({ width: s, height: o, x: h }), c = rt({ width: s, height: o, x: h }), u = ht({ width: s, height: o, y: r }), g = at({ width: s, height: o, y: r });
125
+ return h < s * (0.5 - d / 2) && r > l && r < c ? a.Left : h > s * (0.5 + d / 2) && r < l && r > c ? a.Right : r < o * (0.5 - d / 2) && h > u && h < g ? a.Top : r > o * (0.5 + d / 2) && h < u && h > g ? a.Bottom : h > s * (0.5 - d / 2) && h < s * (0.5 + d / 2) && r > o * (0.5 - d / 2) && r < o * (0.5 + d / 2) ? a.Center : a.Unknown;
126
126
  }
127
- const ct = 100, pt = 100, v = {
127
+ const dt = 100, ct = 100, v = {
128
128
  left: 0,
129
129
  top: 0,
130
130
  width: 150,
131
131
  height: 150,
132
132
  // Initial min values, real min width/height is calculated based on children
133
- minWidth: ct,
134
- minHeight: pt
133
+ minWidth: dt,
134
+ minHeight: ct
135
135
  };
136
136
  class b {
137
137
  constructor({
@@ -141,14 +141,14 @@ class b {
141
141
  height: s = v.height,
142
142
  minWidth: o = v.minWidth,
143
143
  minHeight: h = v.minHeight,
144
- domNode: a = null,
144
+ domNode: r = null,
145
145
  store: d = {},
146
146
  position: l,
147
147
  id: c
148
148
  } = v) {
149
- if (this.id = c ?? B(), !l)
149
+ if (this.id = c ?? S(), !l)
150
150
  throw new Error("[bwin] Sash position is required");
151
- this.position = l, this.domNode = a, this._top = i, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = d;
151
+ this.position = l, this.domNode = r, this._top = i, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = d;
152
152
  }
153
153
  walk(t) {
154
154
  this.children.forEach((i) => i.walk(t)), t(this);
@@ -162,30 +162,30 @@ class b {
162
162
  }
163
163
  isLeftRightSplit() {
164
164
  return this.children.some(
165
- (t) => t.position === r.Left || t.position === r.Right
165
+ (t) => t.position === a.Left || t.position === a.Right
166
166
  );
167
167
  }
168
168
  isTopBottomSplit() {
169
169
  return this.children.some(
170
- (t) => t.position === r.Top || t.position === r.Bottom
170
+ (t) => t.position === a.Top || t.position === a.Bottom
171
171
  );
172
172
  }
173
173
  get leftChild() {
174
- return this.children.find((t) => t.position === r.Left);
174
+ return this.children.find((t) => t.position === a.Left);
175
175
  }
176
176
  get rightChild() {
177
- return this.children.find((t) => t.position === r.Right);
177
+ return this.children.find((t) => t.position === a.Right);
178
178
  }
179
179
  get topChild() {
180
- return this.children.find((t) => t.position === r.Top);
180
+ return this.children.find((t) => t.position === a.Top);
181
181
  }
182
182
  get bottomChild() {
183
- return this.children.find((t) => t.position === r.Bottom);
183
+ return this.children.find((t) => t.position === a.Bottom);
184
184
  }
185
185
  getChildren() {
186
186
  let t = null, i = null, n = null, s = null;
187
187
  for (const o of this.children)
188
- o.position === r.Left ? t = o : o.position === r.Right ? i = o : o.position === r.Top ? n = o : o.position === r.Bottom && (s = o);
188
+ o.position === a.Left ? t = o : o.position === a.Right ? i = o : o.position === a.Top ? n = o : o.position === a.Bottom && (s = o);
189
189
  return [n, i, s, t];
190
190
  }
191
191
  getAllLeafDescendants() {
@@ -231,6 +231,13 @@ class b {
231
231
  }
232
232
  return null;
233
233
  }
234
+ swapIds(t, i) {
235
+ const n = this.getById(t), s = this.getById(i);
236
+ if (!n || !s)
237
+ throw new Error("[bwin] Sash not found when swapping IDs");
238
+ const o = n.id;
239
+ n.id = s.id, s.id = o;
240
+ }
234
241
  // Get all ids of self and descendants
235
242
  getAllIds() {
236
243
  const t = [this.id];
@@ -282,10 +289,10 @@ class b {
282
289
  this._width = t;
283
290
  const [n, s, o, h] = this.getChildren();
284
291
  if (h && s) {
285
- const a = h.width + s.width, d = i * (h.width / a), l = a + i;
292
+ const r = h.width + s.width, d = i * (h.width / r), l = r + i;
286
293
  let c = h.width + d, u = l - c, g = s.left + d;
287
- const m = h.calcMinWidth(), w = s.calcMinWidth();
288
- i < 0 && (c < m && u > w ? (c = h.width, u = l - c, g = h.left + c) : u < w && c > m && (u = s.width, c = l - u, g = h.left + c)), h.width = c, s.width = u, s.left = g;
294
+ const w = h.calcMinWidth(), m = s.calcMinWidth();
295
+ i < 0 && (c < w && u > m ? (c = h.width, u = l - c, g = h.left + c) : u < m && c > w && (u = s.width, c = l - u, g = h.left + c)), h.width = c, s.width = u, s.left = g;
289
296
  }
290
297
  n && o && (n.width += i, o.width += i);
291
298
  }
@@ -297,11 +304,11 @@ class b {
297
304
  this._height = t;
298
305
  const [n, s, o, h] = this.getChildren();
299
306
  if (n && o) {
300
- const a = n.height + o.height, d = i * (n.height / a), l = a + i;
307
+ const r = n.height + o.height, d = i * (n.height / r), l = r + i;
301
308
  let c = n.height + d, u = l - c, g = o.top + d;
302
309
  if (i < 0) {
303
- const m = n.calcMinHeight(), w = o.calcMinHeight();
304
- c < m && u > w ? (c = n.height, u = l - c, g = n.top + c) : u < w && c > m && (u = o.height, c = l - u, g = n.top + c);
310
+ const w = n.calcMinHeight(), m = o.calcMinHeight();
311
+ c < w && u > m ? (c = n.height, u = l - c, g = n.top + c) : u < m && c > w && (u = o.height, c = l - u, g = n.top + c);
305
312
  }
306
313
  n.height = c, o.height = u, o.top = g;
307
314
  }
@@ -310,9 +317,9 @@ class b {
310
317
  }
311
318
  const H = {
312
319
  size: "50%",
313
- position: r.Left
320
+ position: a.Left
314
321
  };
315
- class P {
322
+ class R {
316
323
  constructor({
317
324
  parentRect: t,
318
325
  children: i,
@@ -320,16 +327,16 @@ class P {
320
327
  id: s,
321
328
  minWidth: o,
322
329
  minHeight: h,
323
- position: a,
330
+ position: r,
324
331
  size: d,
325
332
  ...l
326
333
  }) {
327
- E(this, "left"), E(this, "top"), E(this, "width"), E(this, "height"), this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(a), this.size = this.getSize(d), this.nonCoreData = l, this.setBounds();
334
+ y(this, "left"), y(this, "top"), y(this, "width"), y(this, "height"), this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(r), this.size = this.getSize(d), this.nonCoreData = l, this.setBounds();
328
335
  }
329
336
  getPosition(t) {
330
337
  if (!this.siblingConfigNode)
331
338
  return t;
332
- const i = ot(this.siblingConfigNode.position);
339
+ const i = st(this.siblingConfigNode.position);
333
340
  if (!t)
334
341
  return i;
335
342
  if (t !== i)
@@ -338,40 +345,40 @@ class P {
338
345
  }
339
346
  getSize(t) {
340
347
  if (!this.siblingConfigNode)
341
- return C(t);
348
+ return z(t);
342
349
  if (!t) {
343
350
  if (this.siblingConfigNode.size < 1)
344
351
  return 1 - this.siblingConfigNode.size;
345
- if (this.siblingConfigNode.position === r.Left || this.siblingConfigNode.position === r.Right)
352
+ if (this.siblingConfigNode.position === a.Left || this.siblingConfigNode.position === a.Right)
346
353
  return this.parentRect.width - this.siblingConfigNode.width;
347
- if (this.siblingConfigNode.position === r.Top || this.siblingConfigNode.position === r.Bottom)
354
+ if (this.siblingConfigNode.position === a.Top || this.siblingConfigNode.position === a.Bottom)
348
355
  return this.parentRect.height - this.siblingConfigNode.height;
349
356
  }
350
- const i = C(t);
357
+ const i = z(t);
351
358
  if (i < 1) {
352
359
  if (i + this.siblingConfigNode.size !== 1)
353
360
  throw new Error("[bwin] Sum of sibling sizes is not equal to 1");
354
361
  } else {
355
- if ((this.position === r.Left || this.position === r.Right) && i + this.siblingConfigNode.size !== this.parentRect.width)
362
+ if ((this.position === a.Left || this.position === a.Right) && i + this.siblingConfigNode.size !== this.parentRect.width)
356
363
  throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");
357
- if ((this.position === r.Top || this.position === r.Bottom) && i + this.siblingConfigNode.size !== this.parentRect.height)
364
+ if ((this.position === a.Top || this.position === a.Bottom) && i + this.siblingConfigNode.size !== this.parentRect.height)
358
365
  throw new Error("[bwin] Sum of sibling sizes is not equal to parent height");
359
366
  }
360
367
  return i;
361
368
  }
362
369
  setBounds() {
363
- if (this.position === r.Root)
370
+ if (this.position === a.Root)
364
371
  this.left = 0, this.top = 0, this.width = this.parentRect.width, this.height = this.parentRect.height;
365
- else if (this.position === r.Left) {
372
+ else if (this.position === a.Left) {
366
373
  const t = this.size < 1 ? this.parentRect.width * this.size : this.size;
367
374
  this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = t, this.height = this.parentRect.height;
368
- } else if (this.position === r.Right) {
375
+ } else if (this.position === a.Right) {
369
376
  const t = this.size < 1 ? this.parentRect.width * this.size : this.size;
370
377
  this.left = this.parentRect.left + this.parentRect.width - t, this.top = this.parentRect.top, this.width = t, this.height = this.parentRect.height;
371
- } else if (this.position === r.Top) {
378
+ } else if (this.position === a.Top) {
372
379
  const t = this.size < 1 ? this.parentRect.height * this.size : this.size;
373
380
  this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = this.parentRect.width, this.height = t;
374
- } else if (this.position === r.Bottom) {
381
+ } else if (this.position === a.Bottom) {
375
382
  const t = this.size < 1 ? this.parentRect.height * this.size : this.size;
376
383
  this.left = this.parentRect.left, this.top = this.parentRect.top + this.parentRect.height - t, this.width = this.parentRect.width, this.height = t;
377
384
  }
@@ -390,14 +397,14 @@ class P {
390
397
  });
391
398
  }
392
399
  normConfig(t) {
393
- if (it(t))
400
+ if (et(t))
394
401
  return t;
395
402
  if (Array.isArray(t))
396
403
  return {
397
404
  children: t
398
405
  };
399
406
  if (typeof t == "string" || typeof t == "number") {
400
- const i = C(t);
407
+ const i = z(t);
401
408
  if (isNaN(i))
402
409
  throw new Error(`[bwin] Invalid size value: ${i}`);
403
410
  return {
@@ -409,8 +416,8 @@ class P {
409
416
  throw new Error(`[bwin] Invalid config value: ${t}`);
410
417
  }
411
418
  }
412
- createPrimaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...a }) {
413
- return new P({
419
+ createPrimaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...r }) {
420
+ return new R({
414
421
  parentRect: this,
415
422
  size: t ?? H.size,
416
423
  position: i ?? H.position,
@@ -418,11 +425,11 @@ class P {
418
425
  id: s,
419
426
  minWidth: o,
420
427
  minHeight: h,
421
- ...a
428
+ ...r
422
429
  });
423
430
  }
424
- createSecondaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...a }, d) {
425
- return new P({
431
+ createSecondaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...r }, d) {
432
+ return new R({
426
433
  parentRect: this,
427
434
  size: t,
428
435
  position: i,
@@ -431,7 +438,7 @@ class P {
431
438
  id: s,
432
439
  minWidth: o,
433
440
  minHeight: h,
434
- ...a
441
+ ...r
435
442
  });
436
443
  }
437
444
  buildSashTree() {
@@ -440,7 +447,7 @@ class P {
440
447
  return t;
441
448
  const i = this.normConfig(this.children[0]), n = this.normConfig(this.children.at(1));
442
449
  let s, o;
443
- return !i.size && !i.position && n ? (n.position || (n.position = r.Right), s = this.createPrimaryConfigNode(n), o = this.createSecondaryConfigNode(
450
+ return !i.size && !i.position && n ? (n.position || (n.position = a.Right), s = this.createPrimaryConfigNode(n), o = this.createSecondaryConfigNode(
444
451
  i,
445
452
  s
446
453
  )) : (s = this.createPrimaryConfigNode(i), o = this.createSecondaryConfigNode(
@@ -455,7 +462,7 @@ const L = {
455
462
  }, T = {
456
463
  fitContainer: !1
457
464
  };
458
- class ut extends P {
465
+ class pt extends R {
459
466
  constructor({
460
467
  id: t,
461
468
  children: i,
@@ -471,18 +478,18 @@ class ut extends P {
471
478
  id: t,
472
479
  children: i,
473
480
  size: NaN,
474
- position: r.Root,
481
+ position: a.Root,
475
482
  parentRect: { width: n, height: s },
476
483
  ...h
477
484
  }), this.fitContainer = o;
478
485
  }
479
486
  }
480
- class gt extends b {
487
+ class ut extends b {
481
488
  constructor(t = v) {
482
- super({ ...t, position: r.Root }), Object.assign(this, T);
489
+ super({ ...t, position: a.Root }), Object.assign(this, T);
483
490
  }
484
491
  }
485
- function A(e) {
492
+ function gt(e) {
486
493
  const t = document.createElement("bw-pane");
487
494
  return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("sash-id", e.id), t.setAttribute("position", e.position), t;
488
495
  }
@@ -490,100 +497,120 @@ function ft(e) {
490
497
  const t = e.domNode;
491
498
  return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("position", e.position), t;
492
499
  }
493
- function mt(e, { size: t }) {
494
- const i = C(t);
495
- let n = e.width / 2;
496
- i && (i < 1 ? n = e.width * i : n = i);
497
- const s = new b({
500
+ function wt(e, { size: t, id: i }) {
501
+ const n = z(t);
502
+ let s = e.width / 2;
503
+ n && (n < 1 ? s = e.width * n : s = n);
504
+ const o = new b({
505
+ id: i,
498
506
  top: e.top,
499
507
  left: e.left,
500
- width: n,
508
+ width: s,
501
509
  height: e.height,
502
- position: r.Left
503
- }), o = new b({
510
+ position: a.Left
511
+ }), h = new b({
512
+ id: e.id,
504
513
  top: e.top,
505
- left: e.left + s.width,
506
- width: e.width - n,
514
+ left: e.left + o.width,
515
+ width: e.width - s,
507
516
  height: e.height,
508
- position: r.Right
509
- }), h = A(o);
510
- return o.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), s;
517
+ position: a.Right,
518
+ domNode: e.domNode
519
+ });
520
+ return e.addChild(o), e.addChild(h), e.domNode = null, e.id = S(), o;
511
521
  }
512
- function wt(e, { size: t }) {
513
- const i = C(t);
514
- let n = e.width / 2;
515
- i && (i < 1 ? n = e.width * i : n = i);
516
- const s = new b({
522
+ function mt(e, { size: t, id: i }) {
523
+ const n = z(t);
524
+ let s = e.width / 2;
525
+ n && (n < 1 ? s = e.width * n : s = n);
526
+ const o = new b({
527
+ id: e.id,
517
528
  left: e.left,
518
529
  top: e.top,
519
- width: e.width - n,
530
+ width: e.width - s,
520
531
  height: e.height,
521
- position: r.Left
522
- }), o = new b({
523
- left: e.left + s.width,
532
+ position: a.Left,
533
+ domNode: e.domNode
534
+ }), h = new b({
535
+ id: i,
536
+ left: e.left + o.width,
524
537
  top: e.top,
525
- width: n,
538
+ width: s,
526
539
  height: e.height,
527
- position: r.Right
528
- }), h = A(s);
529
- return s.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), o;
540
+ position: a.Right
541
+ });
542
+ return e.addChild(o), e.addChild(h), e.domNode = null, e.id = S(), h;
530
543
  }
531
- function bt(e, { size: t }) {
532
- const i = C(t);
533
- let n = e.height / 2;
534
- i && (i < 1 ? n = e.height * i : n = i);
535
- const s = new b({
544
+ function bt(e, { size: t, id: i }) {
545
+ const n = z(t);
546
+ let s = e.height / 2;
547
+ n && (n < 1 ? s = e.height * n : s = n);
548
+ const o = new b({
549
+ id: i,
536
550
  left: e.left,
537
551
  top: e.top,
538
552
  width: e.width,
539
- height: n,
540
- position: r.Top
541
- }), o = new b({
553
+ height: s,
554
+ position: a.Top
555
+ }), h = new b({
556
+ id: e.id,
542
557
  left: e.left,
543
- top: e.top + s.height,
558
+ top: e.top + o.height,
544
559
  width: e.width,
545
- height: e.height - n,
546
- position: r.Bottom
547
- }), h = A(o);
548
- return o.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), s;
560
+ height: e.height - s,
561
+ position: a.Bottom,
562
+ domNode: e.domNode
563
+ });
564
+ return e.addChild(o), e.addChild(h), e.domNode = null, e.id = S(), o;
549
565
  }
550
- function Et(e, { size: t }) {
551
- const i = C(t);
552
- let n = e.height / 2;
553
- i && (i < 1 ? n = e.height * i : n = i);
554
- const s = new b({
566
+ function yt(e, { size: t, id: i }) {
567
+ const n = z(t);
568
+ let s = e.height / 2;
569
+ n && (n < 1 ? s = e.height * n : s = n);
570
+ const o = new b({
571
+ id: e.id,
555
572
  top: e.top,
556
573
  left: e.left,
557
574
  width: e.width,
558
- height: e.height - n,
559
- position: r.Top
560
- }), o = new b({
561
- top: e.top + s.height,
575
+ height: e.height - s,
576
+ position: a.Top,
577
+ domNode: e.domNode
578
+ }), h = new b({
579
+ id: i,
580
+ top: e.top + o.height,
562
581
  left: e.left,
563
582
  width: e.width,
564
- height: n,
565
- position: r.Bottom
566
- }), h = A(s);
567
- return s.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), o;
583
+ height: s,
584
+ position: a.Bottom
585
+ });
586
+ return e.addChild(o), e.addChild(h), e.domNode = null, e.id = S(), h;
568
587
  }
569
- function yt(e, { position: t, size: i, minWidth: n, minHeight: s }) {
570
- if (t === r.Left)
571
- return mt(e, { size: i });
572
- if (t === r.Right)
573
- return wt(e, { size: i });
574
- if (t === r.Top)
575
- return bt(e, { size: i });
576
- if (t === r.Bottom)
577
- return Et(e, { size: i });
588
+ function Et(e, { position: t, size: i, id: n, minWidth: s, minHeight: o }) {
589
+ if (t === a.Left)
590
+ return wt(e, { size: i, id: n });
591
+ if (t === a.Right)
592
+ return mt(e, { size: i, id: n });
593
+ if (t === a.Top)
594
+ return bt(e, { size: i, id: n });
595
+ if (t === a.Bottom)
596
+ return yt(e, { size: i, id: n });
597
+ }
598
+ function P(e) {
599
+ if (e.tagName === "BW-PANE")
600
+ return e.getAttribute("sash-id");
601
+ const t = e.closest("bw-pane");
602
+ if (!t)
603
+ throw new Error("[bwin] Pane element not found");
604
+ return t.getAttribute("sash-id");
578
605
  }
579
606
  const vt = {
580
607
  createPane(e) {
581
- const t = A(e);
608
+ const t = gt(e);
582
609
  return e.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
583
610
  },
584
611
  // Intended to be overridden
585
612
  onPaneCreate(e, t) {
586
- t.store.content && e.append(N(t.store.content)), this != null && this.debug && (e.style.backgroundColor = tt(), e.innerHTML = "", e.append(I(e)));
613
+ t.store.content && e.append(N(t.store.content)), this != null && this.debug && (e.style.backgroundColor = Q(), e.innerHTML = "", e.append(I(e)));
587
614
  },
588
615
  updatePane(e) {
589
616
  return ft(e);
@@ -599,12 +626,12 @@ const vt = {
599
626
  * @param {'top'|'right'|'bottom'|'left'} position - The position of the new pane relative to the target pane
600
627
  * @returns {Sash} - The newly created sash
601
628
  */
602
- addPane(e, { position: t, size: i }) {
629
+ addPane(e, { position: t, size: i, id: n }) {
603
630
  if (!t) throw new Error("[bwin] Position is required when adding pane");
604
- const n = this.rootSash.getById(e);
605
- if (!n) throw new Error("[bwin] Parent sash not found when adding pane");
606
- const s = yt(n, { position: t, size: i });
607
- return n.id = B(), this.update(), s;
631
+ const s = this.rootSash.getById(e);
632
+ if (!s) throw new Error("[bwin] Parent sash not found when adding pane");
633
+ const o = Et(s, { position: t, size: i, id: n });
634
+ return this.update(), o;
608
635
  },
609
636
  /**
610
637
  * Remove a pane
@@ -615,7 +642,11 @@ const vt = {
615
642
  const t = this.rootSash.getDescendantParentById(e);
616
643
  if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
617
644
  const i = t.getChildSiblingById(e);
618
- t.id = B(), i.children.length === 0 ? (t.domNode = i.domNode, t.domNode.setAttribute("sash-id", t.id), t.children = []) : (t.children = i.children, i.position === r.Left ? i.width = t.width : i.position === r.Right ? (i.width = t.width, i.left = t.left) : i.position === r.Top ? i.height = t.height : i.position === r.Bottom && (i.height = t.height, i.top = t.top)), this.update();
645
+ i.children.length === 0 ? (t.id = i.id, t.domNode = i.domNode, t.domNode.setAttribute("sash-id", i.id), t.children = []) : (t.id = S(), t.children = i.children, i.position === a.Left ? i.width = t.width : i.position === a.Right ? (i.width = t.width, i.left = t.left) : i.position === a.Top ? i.height = t.height : i.position === a.Bottom && (i.height = t.height, i.top = t.top)), this.update();
646
+ },
647
+ swapPanes(e, t) {
648
+ const i = P(e), n = P(t), s = e.getAttribute("can-drop") !== "false", o = t.getAttribute("can-drop") !== "false";
649
+ this.rootSash.swapIds(i, n), tt(e, this.activeDropPaneEl), e.setAttribute("sash-id", n), t.setAttribute("sash-id", i), e.setAttribute("can-drop", o), t.setAttribute("can-drop", s);
619
650
  }
620
651
  };
621
652
  function I(e) {
@@ -666,7 +697,7 @@ const Nt = {
666
697
  },
667
698
  onMuntinUpdate(e, t) {
668
699
  }
669
- }, Ct = {
700
+ }, St = {
670
701
  fitContainer: !1,
671
702
  fit() {
672
703
  this.rootSash.width = this.containerElement.clientWidth, this.rootSash.height = this.containerElement.clientHeight, this.update();
@@ -677,7 +708,7 @@ const Nt = {
677
708
  t.target === this.containerElement && this.fitContainer && this.fit();
678
709
  }).observe(this.containerElement);
679
710
  }
680
- }, St = {
711
+ }, Ct = {
681
712
  activeMuntinSash: null,
682
713
  isResizeStarted: !1,
683
714
  isDropStarted: !1,
@@ -698,13 +729,13 @@ const Nt = {
698
729
  if (!this.isResizeStarted || !this.activeMuntinSash) return;
699
730
  const [t, i, n, s] = this.activeMuntinSash.getChildren(), o = this.activeMuntinSash.isLeftRightSplit(), h = this.activeMuntinSash.isTopBottomSplit();
700
731
  if (o && s && i) {
701
- const a = e.pageX - this.lastX, d = s.width + a, l = i.width - a;
702
- if (a > 0 && l <= i.calcMinWidth() || a < 0 && d <= s.calcMinWidth()) return;
703
- s.width = d, i.width = l, i.left = i.left + a, this.update(), this.lastX = e.pageX;
732
+ const r = e.pageX - this.lastX, d = s.width + r, l = i.width - r;
733
+ if (r > 0 && l <= i.calcMinWidth() || r < 0 && d <= s.calcMinWidth()) return;
734
+ s.width = d, i.width = l, i.left = i.left + r, this.update(), this.lastX = e.pageX;
704
735
  } else if (h && t && n) {
705
- const a = e.pageY - this.lastY, d = t.height + a, l = n.height - a;
706
- if (a > 0 && l <= n.calcMinHeight() || a < 0 && d <= t.calcMinHeight()) return;
707
- t.height = d, n.height = l, n.top = n.top + a, this.update(), this.lastY = e.pageY;
736
+ const r = e.pageY - this.lastY, d = t.height + r, l = n.height - r;
737
+ if (r > 0 && l <= n.calcMinHeight() || r < 0 && d <= t.calcMinHeight()) return;
738
+ t.height = d, n.height = l, n.top = n.top + r, this.update(), this.lastY = e.pageY;
708
739
  }
709
740
  }), document.addEventListener("mouseup", () => {
710
741
  this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
@@ -720,7 +751,7 @@ const Nt = {
720
751
  e.preventDefault();
721
752
  const t = e.target.matches("bw-pane") ? e.target : e.target.closest("bw-pane");
722
753
  if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
723
- const i = dt(t, e);
754
+ const i = lt(t, e);
724
755
  t.setAttribute("drop-area", i);
725
756
  }), this.windowElement.addEventListener("dragleave", (e) => {
726
757
  e.currentTarget.contains(e.relatedTarget) && e.currentTarget !== e.relatedTarget || this.activeDropPaneEl && (this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null);
@@ -731,11 +762,11 @@ const Nt = {
731
762
  });
732
763
  }
733
764
  }, Mt = !1;
734
- class O {
765
+ class G {
735
766
  constructor(t) {
736
- E(this, "windowElement", null), E(this, "containerElement", null), E(this, "debug", Mt);
767
+ y(this, "windowElement", null), y(this, "containerElement", null), y(this, "debug", Mt);
737
768
  let i = null;
738
- t instanceof gt ? (i = t, this.rootSash = t) : (i = new ut(t), this.rootSash = i.buildSashTree()), this.fitContainer = i.fitContainer;
769
+ t instanceof ut ? (i = t, this.rootSash = t) : (i = new pt(t), this.rootSash = i.buildSashTree()), this.fitContainer = i.fitContainer;
739
770
  }
740
771
  frame(t) {
741
772
  this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
@@ -749,31 +780,23 @@ class O {
749
780
  }
750
781
  static assemble(...t) {
751
782
  t.forEach((i) => {
752
- nt(this.prototype, i);
783
+ it(this.prototype, i);
753
784
  });
754
785
  }
755
786
  }
756
- O.assemble(
787
+ G.assemble(
757
788
  Nt,
758
789
  zt,
759
790
  vt,
760
- Ct,
791
+ St,
761
792
  At,
762
- St
793
+ Ct
763
794
  );
764
- function k(e) {
765
- if (e.tagName === "BW-PANE")
766
- return e.getAttribute("sash-id");
767
- const t = e.closest("bw-pane");
768
- if (!t)
769
- throw new Error("[bwin] Pane element not found");
770
- return t.getAttribute("sash-id");
771
- }
772
795
  const Rt = {
773
796
  label: "",
774
797
  className: "bw-glass-action--close",
775
798
  onClick: (e, t) => {
776
- const i = k(e.target);
799
+ const i = P(e.target);
777
800
  t.removePane(i);
778
801
  }
779
802
  }, Pt = {
@@ -784,30 +807,30 @@ const Rt = {
784
807
  if (!i) throw new Error("[bwin] Sill element not found when minimizing");
785
808
  const n = N('<button class="bw-minimized-glass" />');
786
809
  i.append(n);
787
- const s = e.target.closest("bw-pane"), o = e.target.closest("bw-glass"), h = s.getAttribute("sash-id"), a = s.getAttribute("position");
788
- n.bwGlassElement = o, n.bwOriginalPosition = a, n.bwOriginalBoundingRect = R(s), t.removePane(h);
810
+ const s = e.target.closest("bw-pane"), o = e.target.closest("bw-glass"), h = s.getAttribute("sash-id"), r = s.getAttribute("position");
811
+ n.bwGlassElement = o, n.bwOriginalPosition = r, n.bwOriginalBoundingRect = M(s), n.bwOriginalSashId = h, t.removePane(h);
789
812
  }
790
813
  }, xt = {
791
814
  label: "",
792
815
  className: "bw-glass-action--maximize",
793
816
  onClick: (e) => {
794
817
  const t = e.target.closest("bw-pane");
795
- t.hasAttribute("maximized") ? (t.removeAttribute("maximized"), t.style.left = `${t.bwOriginalBoundingRect.left}px`, t.style.top = `${t.bwOriginalBoundingRect.top}px`, t.style.width = `${t.bwOriginalBoundingRect.width}px`, t.style.height = `${t.bwOriginalBoundingRect.height}px`) : (t.setAttribute("maximized", ""), t.bwOriginalBoundingRect = R(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
818
+ t.hasAttribute("maximized") ? (t.removeAttribute("maximized"), t.style.left = `${t.bwOriginalBoundingRect.left}px`, t.style.top = `${t.bwOriginalBoundingRect.top}px`, t.style.width = `${t.bwOriginalBoundingRect.width}px`, t.style.height = `${t.bwOriginalBoundingRect.height}px`) : (t.setAttribute("maximized", ""), t.bwOriginalBoundingRect = M(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
796
819
  }
797
820
  };
798
821
  function Dt(e, t) {
799
822
  const i = e.left + e.width, n = e.top + e.height, s = t.left + t.width, o = t.top + t.height;
800
823
  if (e.left >= s || t.left >= i || e.top >= o || t.top >= n)
801
824
  return null;
802
- const h = Math.max(e.left, t.left), a = Math.max(e.top, t.top), d = Math.min(i, s), l = Math.min(n, o);
825
+ const h = Math.max(e.left, t.left), r = Math.max(e.top, t.top), d = Math.min(i, s), l = Math.min(n, o);
803
826
  return {
804
827
  left: h,
805
- top: a,
828
+ top: r,
806
829
  width: d - h,
807
- height: l - a
830
+ height: l - r
808
831
  };
809
832
  }
810
- const F = [Pt, xt, Rt], $t = {
833
+ const k = [Pt, xt, Rt], $t = {
811
834
  enableActions() {
812
835
  this.handleMinimizedGlassClick(), this.observeActionButtons();
813
836
  },
@@ -815,21 +838,23 @@ const F = [Pt, xt, Rt], $t = {
815
838
  const t = e.bwOriginalBoundingRect;
816
839
  let i = 0, n = null;
817
840
  if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
818
- const o = R(s), h = Dt(t, o);
841
+ const o = M(s), h = Dt(t, o);
819
842
  if (h) {
820
- const a = h.width * h.height;
821
- a > i && (i = a, n = s);
843
+ const r = h.width * h.height;
844
+ r > i && (i = r, n = s);
822
845
  }
823
846
  }), n) {
824
- const s = e.bwOriginalPosition, o = R(n), h = n.getAttribute("sash-id"), a = this.rootSash.getById(h);
847
+ const s = e.bwOriginalPosition, o = M(n), h = n.getAttribute("sash-id"), r = this.rootSash.getById(h);
825
848
  let d = 0;
826
- if (s === r.Left || s === r.Right)
827
- d = o.width - t.width < a.minWidth ? o.width / 2 : t.width;
828
- else if (s === r.Top || s === r.Bottom)
829
- d = o.height - t.height < a.minHeight ? o.height / 2 : t.height;
849
+ if (s === a.Left || s === a.Right)
850
+ d = o.width - t.width < r.minWidth ? o.width / 2 : t.width;
851
+ else if (s === a.Top || s === a.Bottom)
852
+ d = o.height - t.height < r.minHeight ? o.height / 2 : t.height;
830
853
  else
831
854
  throw new Error("[bwin] Invalid position when restoring glass");
855
+ const l = e.bwOriginalSashId;
832
856
  this.addPane(n.getAttribute("sash-id"), {
857
+ id: l,
833
858
  position: s,
834
859
  size: d
835
860
  }).domNode.append(e.bwGlassElement);
@@ -863,24 +888,24 @@ const F = [Pt, xt, Rt], $t = {
863
888
  childList: !0
864
889
  });
865
890
  }
866
- }, S = {
891
+ }, C = {
867
892
  title: null,
868
893
  content: null,
869
894
  tabs: [],
870
895
  actions: void 0,
871
896
  draggable: !0
872
897
  };
873
- class G {
898
+ class O {
874
899
  constructor({
875
- title: t = S.title,
876
- content: i = S.content,
877
- tabs: n = S.tabs,
878
- actions: s = S.actions,
879
- draggable: o = S.draggable,
900
+ title: t = C.title,
901
+ content: i = C.content,
902
+ tabs: n = C.tabs,
903
+ actions: s = C.actions,
904
+ draggable: o = C.draggable,
880
905
  sash: h,
881
- binaryWindow: a
906
+ binaryWindow: r
882
907
  }) {
883
- E(this, "domNode"), this.title = t, this.content = i, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = a, this.build();
908
+ y(this, "domNode"), this.title = t, this.content = i, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = r, this.build();
884
909
  }
885
910
  build() {
886
911
  const t = document.createElement("bw-glass-header");
@@ -903,11 +928,11 @@ class G {
903
928
  return t;
904
929
  }
905
930
  createActions() {
906
- const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? F : Array.isArray(this.actions) ? this.actions : [];
931
+ const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? k : Array.isArray(this.actions) ? this.actions : [];
907
932
  for (const n of i) {
908
933
  const s = (n == null ? void 0 : n.label) ?? n, o = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", h = N(`<button class="${o}">${s}</button>`);
909
- typeof n.onClick == "function" && h.addEventListener("click", (a) => {
910
- n.onClick(a, this.binaryWindow);
934
+ typeof n.onClick == "function" && h.addEventListener("click", (r) => {
935
+ n.onClick(r, this.binaryWindow);
911
936
  }), t.append(h);
912
937
  }
913
938
  return t;
@@ -919,19 +944,19 @@ class G {
919
944
  return this.domNode.querySelector("bw-glass-header");
920
945
  }
921
946
  }
922
- const Lt = {
947
+ const Bt = {
923
948
  activeDragGlassEl: null,
924
949
  activeDragGlassPaneCanDrop: !1,
925
950
  onPaneDrop(e, t) {
926
951
  if (!this.activeDragGlassEl) return;
927
952
  const i = this.activeDropPaneEl.getAttribute("drop-area");
928
953
  if (i === "center") {
929
- const n = this.activeDragGlassEl.closest("bw-pane"), s = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
930
- et(n, this.activeDropPaneEl), n.setAttribute("can-drop", s);
954
+ const n = this.activeDragGlassEl.closest("bw-pane");
955
+ this.swapPanes(n, this.activeDropPaneEl);
931
956
  return;
932
957
  } else {
933
- const n = k(this.activeDragGlassEl);
934
- this.addPane(t.id, { position: i }).domNode.append(this.activeDragGlassEl), this.removePane(n);
958
+ const n = P(this.activeDragGlassEl);
959
+ this.removePane(n), this.addPane(t.id, { position: i, id: n }).domNode.append(this.activeDragGlassEl);
935
960
  }
936
961
  },
937
962
  enableDrag() {
@@ -955,7 +980,7 @@ const Lt = {
955
980
  this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop", this.activeDragGlassPaneCanDrop), this.activeDragGlassEl = null);
956
981
  });
957
982
  }
958
- }, Bt = {
983
+ }, Lt = {
959
984
  trimMuntin(e) {
960
985
  e.hasAttribute("vertical") ? (e.style.top = `${parseFloat(e.style.top) + this.muntinSize / 2}px`, e.style.height = `${parseFloat(e.style.height) - this.muntinSize}px`) : e.hasAttribute("horizontal") && (e.style.left = `${parseFloat(e.style.left) + this.muntinSize / 2}px`, e.style.width = `${parseFloat(e.style.width) - this.muntinSize}px`);
961
986
  },
@@ -966,9 +991,9 @@ const Lt = {
966
991
  this.trimMuntin(e);
967
992
  }
968
993
  };
969
- class _ extends O {
994
+ class F extends G {
970
995
  constructor() {
971
- super(...arguments), E(this, "sillElement", null);
996
+ super(...arguments), y(this, "sillElement", null);
972
997
  }
973
998
  frame() {
974
999
  super.frame(...arguments);
@@ -979,7 +1004,7 @@ class _ extends O {
979
1004
  super.enableFeatures(), this.enableDrag(), this.enableActions();
980
1005
  }
981
1006
  onPaneCreate(t, i) {
982
- const n = new G({ ...i.store, sash: i, binaryWindow: this });
1007
+ const n = new O({ ...i.store, sash: i, binaryWindow: this });
983
1008
  t.innerHTML = "", t.append(n.domNode), this.debug && n.contentElement.prepend(`${i.id}`);
984
1009
  }
985
1010
  onPaneUpdate() {
@@ -992,17 +1017,17 @@ class _ extends O {
992
1017
  * @returns {Sash} - The newly created Sash
993
1018
  */
994
1019
  addPane(t, i) {
995
- const { position: n, size: s, ...o } = i, h = super.addPane(t, { position: n, size: s }), a = new G({ ...o, sash: h, binaryWindow: this });
996
- return h.domNode.append(a.domNode), h;
1020
+ const { position: n, size: s, id: o, ...h } = i, r = super.addPane(t, { position: n, size: s, id: o }), d = new O({ ...h, sash: r, binaryWindow: this });
1021
+ return r.domNode.append(d.domNode), r;
997
1022
  }
998
1023
  }
999
- _.assemble(Lt, Bt, $t);
1000
- const y = 4;
1024
+ F.assemble(Bt, Lt, $t);
1025
+ const E = 4;
1001
1026
  function Tt({ sash: e }) {
1002
1027
  var c;
1003
- const t = M(), i = e.leftChild, n = e.topChild;
1004
- let s, o, h, a, d, l;
1005
- return i ? (s = y, o = e.height - y, h = e.top + y / 2, a = e.left + i.width - y / 2, d = !0) : n && (s = e.width - y, o = y, h = e.top + n.height - y / 2, a = e.left + y / 2, l = !0), W(() => {
1028
+ const t = A(), i = e.leftChild, n = e.topChild;
1029
+ let s, o, h, r, d, l;
1030
+ return i ? (s = E, o = e.height - E, h = e.top + E / 2, r = e.left + i.width - E / 2, d = !0) : n && (s = e.width - E, o = E, h = e.top + n.height - E / 2, r = e.left + E / 2, l = !0), W(() => {
1006
1031
  e.domNode = t.current;
1007
1032
  }, []), /* @__PURE__ */ f.createElement(
1008
1033
  "bw-muntin",
@@ -1012,7 +1037,7 @@ function Tt({ sash: e }) {
1012
1037
  width: s,
1013
1038
  height: o,
1014
1039
  top: h,
1015
- left: a
1040
+ left: r
1016
1041
  },
1017
1042
  vertical: d,
1018
1043
  horizontal: l,
@@ -1025,16 +1050,16 @@ function Wt({
1025
1050
  sash: e,
1026
1051
  bwin: t
1027
1052
  }) {
1028
- var c, u, g, m, w;
1029
- const i = M(), { left: n, top: s, width: o, height: h, id: a, position: d } = e;
1053
+ var c, u, g, w, m;
1054
+ const i = A(), { left: n, top: s, width: o, height: h, id: r, position: d } = e;
1030
1055
  W(() => {
1031
1056
  e.domNode = i.current;
1032
1057
  }, []);
1033
- const l = ((c = e.store) == null ? void 0 : c.actions) === void 0 ? F : Array.isArray(e.store.actions) ? e.store.actions : [];
1058
+ const l = ((c = e.store) == null ? void 0 : c.actions) === void 0 ? k : Array.isArray(e.store.actions) ? e.store.actions : [];
1034
1059
  return /* @__PURE__ */ f.createElement(
1035
1060
  "bw-pane",
1036
1061
  {
1037
- "sash-id": a,
1062
+ "sash-id": r,
1038
1063
  position: d,
1039
1064
  style: { left: n, top: s, width: o, height: h },
1040
1065
  "can-drop": ((u = e.store) == null ? void 0 : u.droppable) === !1 ? "false" : "true",
@@ -1045,7 +1070,7 @@ function Wt({
1045
1070
  {
1046
1071
  "can-drag": ((g = e.store) == null ? void 0 : g.draggable) === !1 ? "false" : "true"
1047
1072
  },
1048
- ((m = e.store) == null ? void 0 : m.title) && /* @__PURE__ */ f.createElement("bw-glass-title", null, e.store.title),
1073
+ ((w = e.store) == null ? void 0 : w.title) && /* @__PURE__ */ f.createElement("bw-glass-title", null, e.store.title),
1049
1074
  l.length > 0 && /* @__PURE__ */ f.createElement("bw-glass-action-container", null, l.map((p, x) => {
1050
1075
  const D = p.className ? `bw-glass-action ${p.className}` : "bw-glass-action";
1051
1076
  return /* @__PURE__ */ f.createElement(
@@ -1058,22 +1083,22 @@ function Wt({
1058
1083
  p.label
1059
1084
  );
1060
1085
  }))
1061
- ), /* @__PURE__ */ f.createElement("bw-glass-content", null, (w = e.store) == null ? void 0 : w.content))
1086
+ ), /* @__PURE__ */ f.createElement("bw-glass-content", null, (m = e.store) == null ? void 0 : m.content))
1062
1087
  );
1063
1088
  }
1064
- const Gt = Y((e, t) => {
1065
- const i = M(), n = M(), [s, o] = j(), { panes: h, ...a } = e, d = { ...a, children: h }, l = new _(d), c = [], u = [];
1089
+ const Ot = X((e, t) => {
1090
+ const i = A(), n = A(), [s, o] = Y(), { panes: h, ...r } = e, d = { ...r, children: h }, l = new F(d), c = [], u = [];
1066
1091
  l.rootSash.walk((p) => {
1067
1092
  p.children.length > 0 ? c.push(p) : u.push(p);
1068
1093
  }), W(() => {
1069
1094
  const p = i.current;
1070
1095
  p != null && p.parentElement && (l.windowElement = p, l.containerElement = p.parentElement, l.sillElement = n.current, l.enableFeatures());
1071
- }, []), K(
1096
+ }, []), j(
1072
1097
  t,
1073
1098
  () => ({
1074
1099
  fit: l.fit.bind(l),
1075
1100
  removePane: l.removePane.bind(l),
1076
- addPane: w
1101
+ addPane: m
1077
1102
  }),
1078
1103
  []
1079
1104
  );
@@ -1087,20 +1112,20 @@ const Gt = Y((e, t) => {
1087
1112
  u.map((p) => /* @__PURE__ */ f.createElement(Wt, { key: p.id, sash: p, bwin: l })),
1088
1113
  c.map((p) => /* @__PURE__ */ f.createElement(Tt, { key: p.id, sash: p })),
1089
1114
  /* @__PURE__ */ f.createElement("bw-sill", { ref: n })
1090
- ), m = V(() => g, []);
1091
- function w(p, x) {
1092
- const { content: D, ...$ } = x, q = l.addPane(p, $), U = document.querySelector(
1093
- `bw-pane[sash-id="${q.id}"] bw-glass-content`
1115
+ ), w = K(() => g, []);
1116
+ function m(p, x) {
1117
+ const { content: D, ...$ } = x, _ = l.addPane(p, $), q = document.querySelector(
1118
+ `bw-pane[sash-id="${_.id}"] bw-glass-content`
1094
1119
  );
1095
- o((X) => [
1096
- ...X || [],
1097
- { node: D, container: U }
1120
+ o((U) => [
1121
+ ...U || [],
1122
+ { node: D, container: q }
1098
1123
  ]);
1099
1124
  }
1100
- return /* @__PURE__ */ f.createElement(f.Fragment, null, m, s == null ? void 0 : s.map((p) => Z(p.node, p.container)));
1101
- }), Ot = "0.3.2";
1125
+ return /* @__PURE__ */ f.createElement(f.Fragment, null, w, s == null ? void 0 : s.map((p) => V(p.node, p.container)));
1126
+ }), Gt = "0.3.3";
1102
1127
  export {
1103
- F as BUILTIN_ACTIONS,
1104
- Gt as Window,
1105
- Ot as version
1128
+ k as BUILTIN_ACTIONS,
1129
+ Ot as Window,
1130
+ Gt as version
1106
1131
  };
@@ -1,8 +1,8 @@
1
- (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.ReactBinaryWindow={},w.React,w.ReactDOM))})(this,function(w,u,_){"use strict";var q=Object.defineProperty,U=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,E=(e,t,i)=>U(e,typeof t!="symbol"?t+"":t,i);function j(e=.7,t=128){const i=256-t,n=Math.floor(Math.random()*i+t),s=Math.floor(Math.random()*i+t),o=Math.floor(Math.random()*i+t),h=Math.max(.5,Math.random()*e);return`rgba(${n}, ${s}, ${o}, ${h})`}function x(e=2,t=3){if(e<0||t<0)throw new Error("Parameters must be non-negative numbers");const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="0123456789";let s="";for(let o=0;o<e;o++){const h=Math.floor(Math.random()*i.length);s+=i[h]}s+="-";for(let o=0;o<t;o++){const h=Math.floor(Math.random()*n.length);s+=n[h]}return s}function z(e,t){for(;t.firstChild;)e.append(t.firstChild)}function X(e,t){const i=document.createElement("div");z(i,e),z(e,t),z(t,i)}function C(e){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("%")){const i=t.slice(0,-1);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n/100}if(t.endsWith("px")){const i=t.slice(0,-2);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n}return Number(t)}return NaN}function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function K(e,t){for(const i in t){if(Object.hasOwn(e,i))throw new Error(`Key "${i}" already exists in target object`);e[i]=t[i]}return e}function V(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function S(e){if(e==null||e==="")return null;if(typeof e=="string")try{const t=V(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function P(e){const t=parseFloat(e.style.left)||0,i=parseFloat(e.style.top)||0,n=parseFloat(e.style.width)||0,s=parseFloat(e.style.height)||0;return{left:t,top:i,width:n,height:s}}const r={Top:"top",Right:"right",Bottom:"bottom",Left:"left",Center:"center",Root:"root",Unknown:"unknown",Outside:"outside"};function Z(e){switch(e){case r.Top:return r.Bottom;case r.Right:return r.Left;case r.Bottom:return r.Top;case r.Left:return r.Right;default:throw new Error(`[bwin] Invalid position: ${e}`)}}function J({width:e,height:t,x:i}){return t/e*i}function Q({width:e,height:t,y:i}){return e/t*i}function tt({width:e,height:t,x:i}){return t-t/e*i}function et({width:e,height:t,y:i}){return e-e/t*i}function it(e,{clientX:t,clientY:i}){const n=e.getBoundingClientRect(),{width:s,height:o}=n,h=t-n.left,a=i-n.top;if(h<0||h>s||a<0||a>o)return r.Outside;const d=.3,l=J({width:s,height:o,x:h}),c=tt({width:s,height:o,x:h}),g=Q({width:s,height:o,y:a}),f=et({width:s,height:o,y:a});return h<s*(.5-d/2)&&a>l&&a<c?r.Left:h>s*(.5+d/2)&&a<l&&a>c?r.Right:a<o*(.5-d/2)&&h>g&&h<f?r.Top:a>o*(.5+d/2)&&h<g&&h>f?r.Bottom:h>s*(.5-d/2)&&h<s*(.5+d/2)&&a>o*(.5-d/2)&&a<o*(.5+d/2)?r.Center:r.Unknown}const nt=100,st=100,v={left:0,top:0,width:150,height:150,minWidth:nt,minHeight:st};class m{constructor({left:t=v.left,top:i=v.top,width:n=v.width,height:s=v.height,minWidth:o=v.minWidth,minHeight:h=v.minHeight,domNode:a=null,store:d={},position:l,id:c}=v){if(this.id=c??x(),!l)throw new Error("[bwin] Sash position is required");this.position=l,this.domNode=a,this._top=i,this._left=t,this._width=n,this._height=s,this.children=[],this.minWidth=o,this.minHeight=h,this.store=d}walk(t){this.children.forEach(i=>i.walk(t)),t(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(t=>t.position===r.Left||t.position===r.Right)}isTopBottomSplit(){return this.children.some(t=>t.position===r.Top||t.position===r.Bottom)}get leftChild(){return this.children.find(t=>t.position===r.Left)}get rightChild(){return this.children.find(t=>t.position===r.Right)}get topChild(){return this.children.find(t=>t.position===r.Top)}get bottomChild(){return this.children.find(t=>t.position===r.Bottom)}getChildren(){let t=null,i=null,n=null,s=null;for(const o of this.children)o.position===r.Left?t=o:o.position===r.Right?i=o:o.position===r.Top?n=o:o.position===r.Bottom&&(s=o);return[n,i,s,t]}getAllLeafDescendants(){const t=[];return this.walk(i=>{i.children.length===0&&t.push(i)}),t}calcMinWidth(){if(this.isLeaf())return this.minWidth;const[t,i,n,s]=this.getChildren();if(s&&i){const o=s.calcMinWidth()+i.calcMinWidth();return Math.max(this.minWidth,o)}if(t&&n){const o=Math.max(t.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,o)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;const[t,i,n,s]=this.getChildren();if(s&&i){const o=Math.max(s.calcMinHeight(),i.calcMinHeight());return Math.max(this.minHeight,o)}if(t&&n){const o=t.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,o)}}getById(t){if(this.id===t)return this;for(const i of this.children){const n=i.getById(t);if(n)return n}return null}getAllIds(){const t=[this.id];for(const i of this.children)t.push(...i.getAllIds());return t}addChild(t){if(this.children.length>=2)throw new Error("[bwin] Maximum 2 children allowed");this.children.push(t)}getDescendantParentById(t){for(const i of this.children){if(i.id===t)return this;const n=i.getDescendantParentById(t);if(n)return n}return null}getChildSiblingById(t){return this.children.find(i=>i.id!==t)}get top(){return this._top}set top(t){const i=t-this._top;this._top=t;const[n,s,o,h]=this.getChildren();n&&o&&(n.top+=i,o.top+=i),h&&s&&(h.top+=i,s.top+=i)}get left(){return this._left}set left(t){const i=t-this._left;this._left=t;const[n,s,o,h]=this.getChildren();h&&s&&(h.left+=i,s.left+=i),n&&o&&(n.left+=i,o.left+=i)}get width(){return this._width}set width(t){const i=t-this._width;this._width=t;const[n,s,o,h]=this.getChildren();if(h&&s){const a=h.width+s.width,d=i*(h.width/a),l=a+i;let c=h.width+d,g=l-c,f=s.left+d;const b=h.calcMinWidth(),y=s.calcMinWidth();i<0&&(c<b&&g>y?(c=h.width,g=l-c,f=h.left+c):g<y&&c>b&&(g=s.width,c=l-g,f=h.left+c)),h.width=c,s.width=g,s.left=f}n&&o&&(n.width+=i,o.width+=i)}get height(){return this._height}set height(t){const i=t-this._height;this._height=t;const[n,s,o,h]=this.getChildren();if(n&&o){const a=n.height+o.height,d=i*(n.height/a),l=a+i;let c=n.height+d,g=l-c,f=o.top+d;if(i<0){const b=n.calcMinHeight(),y=o.calcMinHeight();c<b&&g>y?(c=n.height,g=l-c,f=n.top+c):g<y&&c>b&&(g=o.height,c=l-g,f=n.top+c)}n.height=c,o.height=g,o.top=f}h&&s&&(h.height+=i,s.height+=i)}}const H={size:"50%",position:r.Left};class D{constructor({parentRect:t,children:i,siblingConfigNode:n,id:s,minWidth:o,minHeight:h,position:a,size:d,...l}){E(this,"left"),E(this,"top"),E(this,"width"),E(this,"height"),this.parentRect=t,this.children=i,this.siblingConfigNode=n,this.id=s,this.minWidth=o,this.minHeight=h,this.position=this.getPosition(a),this.size=this.getSize(d),this.nonCoreData=l,this.setBounds()}getPosition(t){if(!this.siblingConfigNode)return t;const i=Z(this.siblingConfigNode.position);if(!t)return i;if(t!==i)throw new Error("[bwin] Sibling position and current position are not opposite");return t}getSize(t){if(!this.siblingConfigNode)return C(t);if(!t){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===r.Left||this.siblingConfigNode.position===r.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===r.Top||this.siblingConfigNode.position===r.Bottom)return this.parentRect.height-this.siblingConfigNode.height}const i=C(t);if(i<1){if(i+this.siblingConfigNode.size!==1)throw new Error("[bwin] Sum of sibling sizes is not equal to 1")}else{if((this.position===r.Left||this.position===r.Right)&&i+this.siblingConfigNode.size!==this.parentRect.width)throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");if((this.position===r.Top||this.position===r.Bottom)&&i+this.siblingConfigNode.size!==this.parentRect.height)throw new Error("[bwin] Sum of sibling sizes is not equal to parent height")}return i}setBounds(){if(this.position===r.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===r.Left){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Right){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-t,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Top){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=t}else if(this.position===r.Bottom){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-t,this.width=this.parentRect.width,this.height=t}}createSash(){return new m({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,store:this.nonCoreData})}normConfig(t){if(Y(t))return t;if(Array.isArray(t))return{children:t};if(typeof t=="string"||typeof t=="number"){const i=C(t);if(isNaN(i))throw new Error(`[bwin] Invalid size value: ${i}`);return{size:t}}else{if(t==null)return{};throw new Error(`[bwin] Invalid config value: ${t}`)}}createPrimaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a}){return new D({parentRect:this,size:t??H.size,position:i??H.position,children:n,id:s,minWidth:o,minHeight:h,...a})}createSecondaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a},d){return new D({parentRect:this,size:t,position:i,children:n,siblingConfigNode:d,id:s,minWidth:o,minHeight:h,...a})}buildSashTree(){const t=this.createSash();if(!Array.isArray(this.children)||this.children.length===0)return t;const i=this.normConfig(this.children[0]),n=this.normConfig(this.children.at(1));let s,o;return!i.size&&!i.position&&n?(n.position||(n.position=r.Right),s=this.createPrimaryConfigNode(n),o=this.createSecondaryConfigNode(i,s)):(s=this.createPrimaryConfigNode(i),o=this.createSecondaryConfigNode(n,s)),s&&o&&(t.children.push(s.buildSashTree()),t.children.push(o.buildSashTree())),t}}const R={width:333,height:333},$={fitContainer:!1};class ot extends D{constructor({id:t,children:i,width:n=R.width,height:s=R.height,fitContainer:o=$.fitContainer,...h}={...R,...$}){super({id:t,children:i,size:NaN,position:r.Root,parentRect:{width:n,height:s},...h}),this.fitContainer=o}}class ht extends m{constructor(t=v){super({...t,position:r.Root}),Object.assign(this,$)}}function M(e){const t=document.createElement("bw-pane");return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("sash-id",e.id),t.setAttribute("position",e.position),t}function rt(e){const t=e.domNode;return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("position",e.position),t}function at(e,{size:t}){const i=C(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new m({top:e.top,left:e.left,width:n,height:e.height,position:r.Left}),o=new m({top:e.top,left:e.left+s.width,width:e.width-n,height:e.height,position:r.Right}),h=M(o);return o.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),s}function lt(e,{size:t}){const i=C(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new m({left:e.left,top:e.top,width:e.width-n,height:e.height,position:r.Left}),o=new m({left:e.left+s.width,top:e.top,width:n,height:e.height,position:r.Right}),h=M(s);return s.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),o}function dt(e,{size:t}){const i=C(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new m({left:e.left,top:e.top,width:e.width,height:n,position:r.Top}),o=new m({left:e.left,top:e.top+s.height,width:e.width,height:e.height-n,position:r.Bottom}),h=M(o);return o.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),s}function ct(e,{size:t}){const i=C(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new m({top:e.top,left:e.left,width:e.width,height:e.height-n,position:r.Top}),o=new m({top:e.top+s.height,left:e.left,width:e.width,height:n,position:r.Bottom}),h=M(s);return s.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),o}function ut(e,{position:t,size:i,minWidth:n,minHeight:s}){if(t===r.Left)return at(e,{size:i});if(t===r.Right)return lt(e,{size:i});if(t===r.Top)return dt(e,{size:i});if(t===r.Bottom)return ct(e,{size:i})}const pt={createPane(e){const t=M(e);return e.store.droppable===!1&&t.setAttribute("can-drop","false"),t},onPaneCreate(e,t){t.store.content&&e.append(S(t.store.content)),this!=null&&this.debug&&(e.style.backgroundColor=j(),e.innerHTML="",e.append(O(e)))},updatePane(e){return rt(e)},onPaneUpdate(e,t){this!=null&&this.debug&&(e.innerHTML="",e.append(O(e)))},addPane(e,{position:t,size:i}){if(!t)throw new Error("[bwin] Position is required when adding pane");const n=this.rootSash.getById(e);if(!n)throw new Error("[bwin] Parent sash not found when adding pane");const s=ut(n,{position:t,size:i});return n.id=x(),this.update(),s},removePane(e){const t=this.rootSash.getDescendantParentById(e);if(!t)throw new Error("[bwin] Parent sash not found when removing pane");const i=t.getChildSiblingById(e);t.id=x(),i.children.length===0?(t.domNode=i.domNode,t.domNode.setAttribute("sash-id",t.id),t.children=[]):(t.children=i.children,i.position===r.Left?i.width=t.width:i.position===r.Right?(i.width=t.width,i.left=t.left):i.position===r.Top?i.height=t.height:i.position===r.Bottom&&(i.height=t.height,i.top=t.top)),this.update()}};function O(e){const t=document.createElement("pre");t.style.fontSize="10px";const i=`
1
+ (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.ReactBinaryWindow={},w.React,w.ReactDOM))})(this,function(w,u,F){"use strict";var _=Object.defineProperty,q=(e,t,i)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,E=(e,t,i)=>q(e,typeof t!="symbol"?t+"":t,i);function U(e=.7,t=128){const i=256-t,n=Math.floor(Math.random()*i+t),s=Math.floor(Math.random()*i+t),o=Math.floor(Math.random()*i+t),h=Math.max(.5,Math.random()*e);return`rgba(${n}, ${s}, ${o}, ${h})`}function C(e=2,t=3){if(e<0||t<0)throw new Error("Parameters must be non-negative numbers");const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="0123456789";let s="";for(let o=0;o<e;o++){const h=Math.floor(Math.random()*i.length);s+=i[h]}s+="-";for(let o=0;o<t;o++){const h=Math.floor(Math.random()*n.length);s+=n[h]}return s}function x(e,t){for(;t.firstChild;)e.append(t.firstChild)}function j(e,t){const i=document.createElement("div");x(i,e),x(e,t),x(t,i)}function S(e){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("%")){const i=t.slice(0,-1);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n/100}if(t.endsWith("px")){const i=t.slice(0,-2);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n}return Number(t)}return NaN}function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Y(e,t){for(const i in t){if(Object.hasOwn(e,i))throw new Error(`Key "${i}" already exists in target object`);e[i]=t[i]}return e}function K(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function z(e){if(e==null||e==="")return null;if(typeof e=="string")try{const t=K(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function M(e){const t=parseFloat(e.style.left)||0,i=parseFloat(e.style.top)||0,n=parseFloat(e.style.width)||0,s=parseFloat(e.style.height)||0;return{left:t,top:i,width:n,height:s}}const a={Top:"top",Right:"right",Bottom:"bottom",Left:"left",Center:"center",Root:"root",Unknown:"unknown",Outside:"outside"};function V(e){switch(e){case a.Top:return a.Bottom;case a.Right:return a.Left;case a.Bottom:return a.Top;case a.Left:return a.Right;default:throw new Error(`[bwin] Invalid position: ${e}`)}}function Z({width:e,height:t,x:i}){return t/e*i}function J({width:e,height:t,y:i}){return e/t*i}function Q({width:e,height:t,x:i}){return t-t/e*i}function tt({width:e,height:t,y:i}){return e-e/t*i}function et(e,{clientX:t,clientY:i}){const n=e.getBoundingClientRect(),{width:s,height:o}=n,h=t-n.left,r=i-n.top;if(h<0||h>s||r<0||r>o)return a.Outside;const d=.3,l=Z({width:s,height:o,x:h}),c=Q({width:s,height:o,x:h}),g=J({width:s,height:o,y:r}),f=tt({width:s,height:o,y:r});return h<s*(.5-d/2)&&r>l&&r<c?a.Left:h>s*(.5+d/2)&&r<l&&r>c?a.Right:r<o*(.5-d/2)&&h>g&&h<f?a.Top:r>o*(.5+d/2)&&h<g&&h>f?a.Bottom:h>s*(.5-d/2)&&h<s*(.5+d/2)&&r>o*(.5-d/2)&&r<o*(.5+d/2)?a.Center:a.Unknown}const it=100,nt=100,v={left:0,top:0,width:150,height:150,minWidth:it,minHeight:nt};class m{constructor({left:t=v.left,top:i=v.top,width:n=v.width,height:s=v.height,minWidth:o=v.minWidth,minHeight:h=v.minHeight,domNode:r=null,store:d={},position:l,id:c}=v){if(this.id=c??C(),!l)throw new Error("[bwin] Sash position is required");this.position=l,this.domNode=r,this._top=i,this._left=t,this._width=n,this._height=s,this.children=[],this.minWidth=o,this.minHeight=h,this.store=d}walk(t){this.children.forEach(i=>i.walk(t)),t(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(t=>t.position===a.Left||t.position===a.Right)}isTopBottomSplit(){return this.children.some(t=>t.position===a.Top||t.position===a.Bottom)}get leftChild(){return this.children.find(t=>t.position===a.Left)}get rightChild(){return this.children.find(t=>t.position===a.Right)}get topChild(){return this.children.find(t=>t.position===a.Top)}get bottomChild(){return this.children.find(t=>t.position===a.Bottom)}getChildren(){let t=null,i=null,n=null,s=null;for(const o of this.children)o.position===a.Left?t=o:o.position===a.Right?i=o:o.position===a.Top?n=o:o.position===a.Bottom&&(s=o);return[n,i,s,t]}getAllLeafDescendants(){const t=[];return this.walk(i=>{i.children.length===0&&t.push(i)}),t}calcMinWidth(){if(this.isLeaf())return this.minWidth;const[t,i,n,s]=this.getChildren();if(s&&i){const o=s.calcMinWidth()+i.calcMinWidth();return Math.max(this.minWidth,o)}if(t&&n){const o=Math.max(t.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,o)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;const[t,i,n,s]=this.getChildren();if(s&&i){const o=Math.max(s.calcMinHeight(),i.calcMinHeight());return Math.max(this.minHeight,o)}if(t&&n){const o=t.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,o)}}getById(t){if(this.id===t)return this;for(const i of this.children){const n=i.getById(t);if(n)return n}return null}swapIds(t,i){const n=this.getById(t),s=this.getById(i);if(!n||!s)throw new Error("[bwin] Sash not found when swapping IDs");const o=n.id;n.id=s.id,s.id=o}getAllIds(){const t=[this.id];for(const i of this.children)t.push(...i.getAllIds());return t}addChild(t){if(this.children.length>=2)throw new Error("[bwin] Maximum 2 children allowed");this.children.push(t)}getDescendantParentById(t){for(const i of this.children){if(i.id===t)return this;const n=i.getDescendantParentById(t);if(n)return n}return null}getChildSiblingById(t){return this.children.find(i=>i.id!==t)}get top(){return this._top}set top(t){const i=t-this._top;this._top=t;const[n,s,o,h]=this.getChildren();n&&o&&(n.top+=i,o.top+=i),h&&s&&(h.top+=i,s.top+=i)}get left(){return this._left}set left(t){const i=t-this._left;this._left=t;const[n,s,o,h]=this.getChildren();h&&s&&(h.left+=i,s.left+=i),n&&o&&(n.left+=i,o.left+=i)}get width(){return this._width}set width(t){const i=t-this._width;this._width=t;const[n,s,o,h]=this.getChildren();if(h&&s){const r=h.width+s.width,d=i*(h.width/r),l=r+i;let c=h.width+d,g=l-c,f=s.left+d;const b=h.calcMinWidth(),y=s.calcMinWidth();i<0&&(c<b&&g>y?(c=h.width,g=l-c,f=h.left+c):g<y&&c>b&&(g=s.width,c=l-g,f=h.left+c)),h.width=c,s.width=g,s.left=f}n&&o&&(n.width+=i,o.width+=i)}get height(){return this._height}set height(t){const i=t-this._height;this._height=t;const[n,s,o,h]=this.getChildren();if(n&&o){const r=n.height+o.height,d=i*(n.height/r),l=r+i;let c=n.height+d,g=l-c,f=o.top+d;if(i<0){const b=n.calcMinHeight(),y=o.calcMinHeight();c<b&&g>y?(c=n.height,g=l-c,f=n.top+c):g<y&&c>b&&(g=o.height,c=l-g,f=n.top+c)}n.height=c,o.height=g,o.top=f}h&&s&&(h.height+=i,s.height+=i)}}const H={size:"50%",position:a.Left};class P{constructor({parentRect:t,children:i,siblingConfigNode:n,id:s,minWidth:o,minHeight:h,position:r,size:d,...l}){E(this,"left"),E(this,"top"),E(this,"width"),E(this,"height"),this.parentRect=t,this.children=i,this.siblingConfigNode=n,this.id=s,this.minWidth=o,this.minHeight=h,this.position=this.getPosition(r),this.size=this.getSize(d),this.nonCoreData=l,this.setBounds()}getPosition(t){if(!this.siblingConfigNode)return t;const i=V(this.siblingConfigNode.position);if(!t)return i;if(t!==i)throw new Error("[bwin] Sibling position and current position are not opposite");return t}getSize(t){if(!this.siblingConfigNode)return S(t);if(!t){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===a.Left||this.siblingConfigNode.position===a.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===a.Top||this.siblingConfigNode.position===a.Bottom)return this.parentRect.height-this.siblingConfigNode.height}const i=S(t);if(i<1){if(i+this.siblingConfigNode.size!==1)throw new Error("[bwin] Sum of sibling sizes is not equal to 1")}else{if((this.position===a.Left||this.position===a.Right)&&i+this.siblingConfigNode.size!==this.parentRect.width)throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");if((this.position===a.Top||this.position===a.Bottom)&&i+this.siblingConfigNode.size!==this.parentRect.height)throw new Error("[bwin] Sum of sibling sizes is not equal to parent height")}return i}setBounds(){if(this.position===a.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===a.Left){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===a.Right){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-t,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===a.Top){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=t}else if(this.position===a.Bottom){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-t,this.width=this.parentRect.width,this.height=t}}createSash(){return new m({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,store:this.nonCoreData})}normConfig(t){if(X(t))return t;if(Array.isArray(t))return{children:t};if(typeof t=="string"||typeof t=="number"){const i=S(t);if(isNaN(i))throw new Error(`[bwin] Invalid size value: ${i}`);return{size:t}}else{if(t==null)return{};throw new Error(`[bwin] Invalid config value: ${t}`)}}createPrimaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...r}){return new P({parentRect:this,size:t??H.size,position:i??H.position,children:n,id:s,minWidth:o,minHeight:h,...r})}createSecondaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...r},d){return new P({parentRect:this,size:t,position:i,children:n,siblingConfigNode:d,id:s,minWidth:o,minHeight:h,...r})}buildSashTree(){const t=this.createSash();if(!Array.isArray(this.children)||this.children.length===0)return t;const i=this.normConfig(this.children[0]),n=this.normConfig(this.children.at(1));let s,o;return!i.size&&!i.position&&n?(n.position||(n.position=a.Right),s=this.createPrimaryConfigNode(n),o=this.createSecondaryConfigNode(i,s)):(s=this.createPrimaryConfigNode(i),o=this.createSecondaryConfigNode(n,s)),s&&o&&(t.children.push(s.buildSashTree()),t.children.push(o.buildSashTree())),t}}const R={width:333,height:333},$={fitContainer:!1};class st extends P{constructor({id:t,children:i,width:n=R.width,height:s=R.height,fitContainer:o=$.fitContainer,...h}={...R,...$}){super({id:t,children:i,size:NaN,position:a.Root,parentRect:{width:n,height:s},...h}),this.fitContainer=o}}class ot extends m{constructor(t=v){super({...t,position:a.Root}),Object.assign(this,$)}}function ht(e){const t=document.createElement("bw-pane");return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("sash-id",e.id),t.setAttribute("position",e.position),t}function rt(e){const t=e.domNode;return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("position",e.position),t}function at(e,{size:t,id:i}){const n=S(t);let s=e.width/2;n&&(n<1?s=e.width*n:s=n);const o=new m({id:i,top:e.top,left:e.left,width:s,height:e.height,position:a.Left}),h=new m({id:e.id,top:e.top,left:e.left+o.width,width:e.width-s,height:e.height,position:a.Right,domNode:e.domNode});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),o}function lt(e,{size:t,id:i}){const n=S(t);let s=e.width/2;n&&(n<1?s=e.width*n:s=n);const o=new m({id:e.id,left:e.left,top:e.top,width:e.width-s,height:e.height,position:a.Left,domNode:e.domNode}),h=new m({id:i,left:e.left+o.width,top:e.top,width:s,height:e.height,position:a.Right});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),h}function dt(e,{size:t,id:i}){const n=S(t);let s=e.height/2;n&&(n<1?s=e.height*n:s=n);const o=new m({id:i,left:e.left,top:e.top,width:e.width,height:s,position:a.Top}),h=new m({id:e.id,left:e.left,top:e.top+o.height,width:e.width,height:e.height-s,position:a.Bottom,domNode:e.domNode});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),o}function ct(e,{size:t,id:i}){const n=S(t);let s=e.height/2;n&&(n<1?s=e.height*n:s=n);const o=new m({id:e.id,top:e.top,left:e.left,width:e.width,height:e.height-s,position:a.Top,domNode:e.domNode}),h=new m({id:i,top:e.top+o.height,left:e.left,width:e.width,height:s,position:a.Bottom});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),h}function ut(e,{position:t,size:i,id:n,minWidth:s,minHeight:o}){if(t===a.Left)return at(e,{size:i,id:n});if(t===a.Right)return lt(e,{size:i,id:n});if(t===a.Top)return dt(e,{size:i,id:n});if(t===a.Bottom)return ct(e,{size:i,id:n})}function D(e){if(e.tagName==="BW-PANE")return e.getAttribute("sash-id");const t=e.closest("bw-pane");if(!t)throw new Error("[bwin] Pane element not found");return t.getAttribute("sash-id")}const pt={createPane(e){const t=ht(e);return e.store.droppable===!1&&t.setAttribute("can-drop","false"),t},onPaneCreate(e,t){t.store.content&&e.append(z(t.store.content)),this!=null&&this.debug&&(e.style.backgroundColor=U(),e.innerHTML="",e.append(I(e)))},updatePane(e){return rt(e)},onPaneUpdate(e,t){this!=null&&this.debug&&(e.innerHTML="",e.append(I(e)))},addPane(e,{position:t,size:i,id:n}){if(!t)throw new Error("[bwin] Position is required when adding pane");const s=this.rootSash.getById(e);if(!s)throw new Error("[bwin] Parent sash not found when adding pane");const o=ut(s,{position:t,size:i,id:n});return this.update(),o},removePane(e){const t=this.rootSash.getDescendantParentById(e);if(!t)throw new Error("[bwin] Parent sash not found when removing pane");const i=t.getChildSiblingById(e);i.children.length===0?(t.id=i.id,t.domNode=i.domNode,t.domNode.setAttribute("sash-id",i.id),t.children=[]):(t.id=C(),t.children=i.children,i.position===a.Left?i.width=t.width:i.position===a.Right?(i.width=t.width,i.left=t.left):i.position===a.Top?i.height=t.height:i.position===a.Bottom&&(i.height=t.height,i.top=t.top)),this.update()},swapPanes(e,t){const i=D(e),n=D(t),s=e.getAttribute("can-drop")!=="false",o=t.getAttribute("can-drop")!=="false";this.rootSash.swapIds(i,n),j(e,this.activeDropPaneEl),e.setAttribute("sash-id",n),t.setAttribute("sash-id",i),e.setAttribute("can-drop",o),t.setAttribute("can-drop",s)}};function I(e){const t=document.createElement("pre");t.style.fontSize="10px";const i=`
2
2
  ${e.getAttribute("sash-id")}
3
3
  ${e.getAttribute("position")}
4
4
  top: ${e.style.top}
5
5
  left: ${e.style.left}
6
6
  width: ${e.style.width}
7
7
  height: ${e.style.height}
8
- `;return t.innerHTML=i.trim(),t}const gt={createWindow(){const e=document.createElement("bw-window");return e.style.width=`${this.rootSash.width}px`,e.style.height=`${this.rootSash.height}px`,e.setAttribute("root-sash-id",this.rootSash.id),e},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;const e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll("[sash-id]").forEach(i=>{const n=i.getAttribute("sash-id");t.push(n),e.includes(n)||i.remove()}),this.rootSash.walk(i=>{i.children.length>0?t.includes(i.id)?(this.updateMuntin(i),this.onMuntinUpdate(i.domNode,i)):(i.domNode=this.createMuntin(i),this.windowElement.append(i.domNode)):t.includes(i.id)?(this.updatePane(i),this.onPaneUpdate(i.domNode,i)):(i.domNode||(i.domNode=this.createPane(i)),this.windowElement.prepend(i.domNode))})}},ft={muntinSize:4,createMuntin(e){const t=document.createElement("bw-muntin"),i=e.leftChild,n=e.topChild;return i?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`,t.setAttribute("vertical","")):n&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute("horizontal","")),t.setAttribute("sash-id",e.id),e.store.resizable===!1&&t.setAttribute("resizable","false"),t},onMuntinCreate(e,t){},updateMuntin(e){const t=e.domNode,i=e.leftChild,n=e.topChild;i?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`):n&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},wt={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{for(const t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()}).observe(this.containerElement)}},mt={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute("vertical")?document.body.classList.add("body--bw-resize-x"):this.activeMuntinSash.domNode.hasAttribute("horizontal")&&document.body.classList.add("body--bw-resize-y")},revertResizeStyles(){document.body.classList.remove("body--bw-resize-x"),document.body.classList.remove("body--bw-resize-y")},enableResize(){document.addEventListener("mousedown",e=>{if(e.target.tagName!=="BW-MUNTIN"||e.target.getAttribute("resizable")==="false")return;const t=e.target.getAttribute("sash-id");this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener("mousemove",e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;const[t,i,n,s]=this.activeMuntinSash.getChildren(),o=this.activeMuntinSash.isLeftRightSplit(),h=this.activeMuntinSash.isTopBottomSplit();if(o&&s&&i){const a=e.pageX-this.lastX,d=s.width+a,l=i.width-a;if(a>0&&l<=i.calcMinWidth()||a<0&&d<=s.calcMinWidth())return;s.width=d,i.width=l,i.left=i.left+a,this.update(),this.lastX=e.pageX}else if(h&&t&&n){const a=e.pageY-this.lastY,d=t.height+a,l=n.height-a;if(a>0&&l<=n.calcMinHeight()||a<0&&d<=t.calcMinHeight())return;t.height=d,n.height=l,n.top=n.top+a,this.update(),this.lastY=e.pageY}}),document.addEventListener("mouseup",()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},bt={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener("dragover",e=>{e.preventDefault();const t=e.target.matches("bw-pane")?e.target:e.target.closest("bw-pane");if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=t),t.getAttribute("can-drop")==="false"))return;const i=it(t,e);t.setAttribute("drop-area",i)}),this.windowElement.addEventListener("dragleave",e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||this.activeDropPaneEl&&(this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null)}),this.windowElement.addEventListener("drop",e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute("can-drop")==="false")return;const t=this.activeDropPaneEl.getAttribute("sash-id"),i=this.rootSash.getById(t);this.onPaneDrop(e,i),typeof i.store.onDrop=="function"&&i.store.onDrop(e,i),this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null})}},yt=!1;class I{constructor(t){E(this,"windowElement",null),E(this,"containerElement",null),E(this,"debug",yt);let i=null;t instanceof ht?(i=t,this.rootSash=t):(i=new ot(t),this.rootSash=i.buildSashTree()),this.fitContainer=i.fitContainer}frame(t){this.containerElement=t,this.windowElement=this.createWindow(),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(t){this.frame(t),this.enableFeatures()}static assemble(...t){t.forEach(i=>{K(this.prototype,i)})}}I.assemble(gt,ft,pt,wt,bt,mt);function G(e){if(e.tagName==="BW-PANE")return e.getAttribute("sash-id");const t=e.closest("bw-pane");if(!t)throw new Error("[bwin] Pane element not found");return t.getAttribute("sash-id")}const Et={label:"",className:"bw-glass-action--close",onClick:(e,t)=>{const i=G(e.target);t.removePane(i)}},vt={label:"",className:"bw-glass-action--minimize",onClick:(e,t)=>{const i=t.sillElement;if(!i)throw new Error("[bwin] Sill element not found when minimizing");const n=S('<button class="bw-minimized-glass" />');i.append(n);const s=e.target.closest("bw-pane"),o=e.target.closest("bw-glass"),h=s.getAttribute("sash-id"),a=s.getAttribute("position");n.bwGlassElement=o,n.bwOriginalPosition=a,n.bwOriginalBoundingRect=P(s),t.removePane(h)}},Nt={label:"",className:"bw-glass-action--maximize",onClick:e=>{const t=e.target.closest("bw-pane");t.hasAttribute("maximized")?(t.removeAttribute("maximized"),t.style.left=`${t.bwOriginalBoundingRect.left}px`,t.style.top=`${t.bwOriginalBoundingRect.top}px`,t.style.width=`${t.bwOriginalBoundingRect.width}px`,t.style.height=`${t.bwOriginalBoundingRect.height}px`):(t.setAttribute("maximized",""),t.bwOriginalBoundingRect=P(t),t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%")}};function zt(e,t){const i=e.left+e.width,n=e.top+e.height,s=t.left+t.width,o=t.top+t.height;if(e.left>=s||t.left>=i||e.top>=o||t.top>=n)return null;const h=Math.max(e.left,t.left),a=Math.max(e.top,t.top),d=Math.min(i,s),l=Math.min(n,o);return{left:h,top:a,width:d-h,height:l-a}}const B=[vt,Nt,Et],Ct={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){const t=e.bwOriginalBoundingRect;let i=0,n=null;if(this.windowElement.querySelectorAll("bw-pane").forEach(s=>{const o=P(s),h=zt(t,o);if(h){const a=h.width*h.height;a>i&&(i=a,n=s)}}),n){const s=e.bwOriginalPosition,o=P(n),h=n.getAttribute("sash-id"),a=this.rootSash.getById(h);let d=0;if(s===r.Left||s===r.Right)d=o.width-t.width<a.minWidth?o.width/2:t.width;else if(s===r.Top||s===r.Bottom)d=o.height-t.height<a.minHeight?o.height/2:t.height;else throw new Error("[bwin] Invalid position when restoring glass");this.addPane(n.getAttribute("sash-id"),{position:s,size:d}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener("click",e=>{if(!e.target.matches(".bw-minimized-glass"))return;const t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(".bw-glass-action--close"),this.updateDisabledState(".bw-glass-action--minimize"),this.updateDisabledState(".bw-glass-action--maximize")},updateDisabledState(e){if(this.windowElement.querySelectorAll("bw-pane").length===1){const t=this.windowElement.querySelector(e);t&&t.setAttribute("disabled","")}else this.windowElement.querySelectorAll(e).forEach(t=>{t.removeAttribute("disabled")})},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(t=>{t.type==="childList"&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},A={title:null,content:null,tabs:[],actions:void 0,draggable:!0};class k{constructor({title:t=A.title,content:i=A.content,tabs:n=A.tabs,actions:s=A.actions,draggable:o=A.draggable,sash:h,binaryWindow:a}){E(this,"domNode"),this.title=t,this.content=i,this.tabs=n,this.actions=s,this.sash=h,this.draggable=o,this.binaryWindow=a,this.build()}build(){const t=document.createElement("bw-glass-header");if(Array.isArray(this.tabs)&&this.tabs.length>0)t.append(this.createTabs());else if(this.title){const s=document.createElement("bw-glass-title");s.append(S(this.title)),t.append(s)}t.setAttribute("can-drag",this.draggable),t.append(this.createActions());const i=document.createElement("bw-glass-content"),n=S(this.content);n&&i.append(n),this.domNode=document.createElement("bw-glass"),this.domNode.append(t,i)}createTabs(){const t=document.createElement("bw-glass-tab-container");for(const i of this.tabs){const n=(i==null?void 0:i.label)??i,s=S(`<button class="bw-glass-tab">${n}</button>`);t.append(s)}return t}createActions(){const t=document.createElement("bw-glass-action-container"),i=this.actions===void 0?B:Array.isArray(this.actions)?this.actions:[];for(const n of i){const s=(n==null?void 0:n.label)??n,o=n.className?`bw-glass-action ${n.className}`:"bw-glass-action",h=S(`<button class="${o}">${s}</button>`);typeof n.onClick=="function"&&h.addEventListener("click",a=>{n.onClick(a,this.binaryWindow)}),t.append(h)}return t}get contentElement(){return this.domNode.querySelector("bw-glass-content")}get headerElement(){return this.domNode.querySelector("bw-glass-header")}}const St={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;const i=this.activeDropPaneEl.getAttribute("drop-area");if(i==="center"){const n=this.activeDragGlassEl.closest("bw-pane"),s=this.activeDropPaneEl.getAttribute("can-drop")!=="false";X(n,this.activeDropPaneEl),n.setAttribute("can-drop",s);return}else{const n=G(this.activeDragGlassEl);this.addPane(t.id,{position:i}).domNode.append(this.activeDragGlassEl),this.removePane(n)}},enableDrag(){document.addEventListener("mousedown",e=>{if(e.button!==0||!e.target.matches("bw-glass-header"))return;if(e.target.getAttribute("can-drag")==="false"){e.preventDefault();return}const t=e.target.closest("bw-glass");t.setAttribute("draggable",!0),this.activeDragGlassEl=t}),document.addEventListener("mouseup",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl=null)}),this.windowElement.addEventListener("dragstart",e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches("bw-glass")||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed="move";const t=this.activeDragGlassEl.closest("bw-pane");this.activeDragGlassPaneCanDrop=t.getAttribute("can-drop")!=="false",t.setAttribute("can-drop",!1)}),this.windowElement.addEventListener("dragend",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop",this.activeDragGlassPaneCanDrop),this.activeDragGlassEl=null)})}},Mt={trimMuntin(e){e.hasAttribute("vertical")?(e.style.top=`${parseFloat(e.style.top)+this.muntinSize/2}px`,e.style.height=`${parseFloat(e.style.height)-this.muntinSize}px`):e.hasAttribute("horizontal")&&(e.style.left=`${parseFloat(e.style.left)+this.muntinSize/2}px`,e.style.width=`${parseFloat(e.style.width)-this.muntinSize}px`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}};class F extends I{constructor(){super(...arguments),E(this,"sillElement",null)}frame(){super.frame(...arguments);const t=S("<bw-sill />");this.windowElement.append(t),this.sillElement=t}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(t,i){const n=new k({...i.store,sash:i,binaryWindow:this});t.innerHTML="",t.append(n.domNode),this.debug&&n.contentElement.prepend(`${i.id}`)}onPaneUpdate(){}addPane(t,i){const{position:n,size:s,...o}=i,h=super.addPane(t,{position:n,size:s}),a=new k({...o,sash:h,binaryWindow:this});return h.domNode.append(a.domNode),h}}F.assemble(St,Mt,Ct);const N=4;function At({sash:e}){var c;const t=u.useRef(),i=e.leftChild,n=e.topChild;let s,o,h,a,d,l;return i?(s=N,o=e.height-N,h=e.top+N/2,a=e.left+i.width-N/2,d=!0):n&&(s=e.width-N,o=N,h=e.top+n.height-N/2,a=e.left+N/2,l=!0),u.useEffect(()=>{e.domNode=t.current},[]),u.createElement("bw-muntin",{"sash-id":e.id,style:{width:s,height:o,top:h,left:a},vertical:d,horizontal:l,resizable:((c=e.store)==null?void 0:c.resizable)===!1?"false":"true",ref:t})}function Pt({sash:e,bwin:t}){var c,g,f,b,y;const i=u.useRef(),{left:n,top:s,width:o,height:h,id:a,position:d}=e;u.useEffect(()=>{e.domNode=i.current},[]);const l=((c=e.store)==null?void 0:c.actions)===void 0?B:Array.isArray(e.store.actions)?e.store.actions:[];return u.createElement("bw-pane",{"sash-id":a,position:d,style:{left:n,top:s,width:o,height:h},"can-drop":((g=e.store)==null?void 0:g.droppable)===!1?"false":"true",ref:i},u.createElement("bw-glass",null,u.createElement("bw-glass-header",{"can-drag":((f=e.store)==null?void 0:f.draggable)===!1?"false":"true"},((b=e.store)==null?void 0:b.title)&&u.createElement("bw-glass-title",null,e.store.title),l.length>0&&u.createElement("bw-glass-action-container",null,l.map((p,L)=>{const T=p.className?`bw-glass-action ${p.className}`:"bw-glass-action";return u.createElement("button",{className:T,key:L,onClick:W=>p.onClick(W,t)},p.label)}))),u.createElement("bw-glass-content",null,(y=e.store)==null?void 0:y.content)))}const Dt=u.forwardRef((e,t)=>{const i=u.useRef(),n=u.useRef(),[s,o]=u.useState(),{panes:h,...a}=e,d={...a,children:h},l=new F(d),c=[],g=[];l.rootSash.walk(p=>{p.children.length>0?c.push(p):g.push(p)}),u.useEffect(()=>{const p=i.current;p!=null&&p.parentElement&&(l.windowElement=p,l.containerElement=p.parentElement,l.sillElement=n.current,l.enableFeatures())},[]),u.useImperativeHandle(t,()=>({fit:l.fit.bind(l),removePane:l.removePane.bind(l),addPane:y}),[]);const f=u.createElement("bw-window",{"root-sash-id":l.rootSash.id,style:{width:l.rootSash.width,height:l.rootSash.height},ref:i},g.map(p=>u.createElement(Pt,{key:p.id,sash:p,bwin:l})),c.map(p=>u.createElement(At,{key:p.id,sash:p})),u.createElement("bw-sill",{ref:n})),b=u.useMemo(()=>f,[]);function y(p,L){const{content:T,...W}=L,Rt=l.addPane(p,W),$t=document.querySelector(`bw-pane[sash-id="${Rt.id}"] bw-glass-content`);o(Bt=>[...Bt||[],{node:T,container:$t}])}return u.createElement(u.Fragment,null,b,s==null?void 0:s.map(p=>_.createPortal(p.node,p.container)))}),xt="0.3.2";w.BUILTIN_ACTIONS=B,w.Window=Dt,w.version=xt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
8
+ `;return t.innerHTML=i.trim(),t}const gt={createWindow(){const e=document.createElement("bw-window");return e.style.width=`${this.rootSash.width}px`,e.style.height=`${this.rootSash.height}px`,e.setAttribute("root-sash-id",this.rootSash.id),e},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;const e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll("[sash-id]").forEach(i=>{const n=i.getAttribute("sash-id");t.push(n),e.includes(n)||i.remove()}),this.rootSash.walk(i=>{i.children.length>0?t.includes(i.id)?(this.updateMuntin(i),this.onMuntinUpdate(i.domNode,i)):(i.domNode=this.createMuntin(i),this.windowElement.append(i.domNode)):t.includes(i.id)?(this.updatePane(i),this.onPaneUpdate(i.domNode,i)):(i.domNode||(i.domNode=this.createPane(i)),this.windowElement.prepend(i.domNode))})}},ft={muntinSize:4,createMuntin(e){const t=document.createElement("bw-muntin"),i=e.leftChild,n=e.topChild;return i?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`,t.setAttribute("vertical","")):n&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute("horizontal","")),t.setAttribute("sash-id",e.id),e.store.resizable===!1&&t.setAttribute("resizable","false"),t},onMuntinCreate(e,t){},updateMuntin(e){const t=e.domNode,i=e.leftChild,n=e.topChild;i?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`):n&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},wt={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{for(const t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()}).observe(this.containerElement)}},mt={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute("vertical")?document.body.classList.add("body--bw-resize-x"):this.activeMuntinSash.domNode.hasAttribute("horizontal")&&document.body.classList.add("body--bw-resize-y")},revertResizeStyles(){document.body.classList.remove("body--bw-resize-x"),document.body.classList.remove("body--bw-resize-y")},enableResize(){document.addEventListener("mousedown",e=>{if(e.target.tagName!=="BW-MUNTIN"||e.target.getAttribute("resizable")==="false")return;const t=e.target.getAttribute("sash-id");this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener("mousemove",e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;const[t,i,n,s]=this.activeMuntinSash.getChildren(),o=this.activeMuntinSash.isLeftRightSplit(),h=this.activeMuntinSash.isTopBottomSplit();if(o&&s&&i){const r=e.pageX-this.lastX,d=s.width+r,l=i.width-r;if(r>0&&l<=i.calcMinWidth()||r<0&&d<=s.calcMinWidth())return;s.width=d,i.width=l,i.left=i.left+r,this.update(),this.lastX=e.pageX}else if(h&&t&&n){const r=e.pageY-this.lastY,d=t.height+r,l=n.height-r;if(r>0&&l<=n.calcMinHeight()||r<0&&d<=t.calcMinHeight())return;t.height=d,n.height=l,n.top=n.top+r,this.update(),this.lastY=e.pageY}}),document.addEventListener("mouseup",()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},bt={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener("dragover",e=>{e.preventDefault();const t=e.target.matches("bw-pane")?e.target:e.target.closest("bw-pane");if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=t),t.getAttribute("can-drop")==="false"))return;const i=et(t,e);t.setAttribute("drop-area",i)}),this.windowElement.addEventListener("dragleave",e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||this.activeDropPaneEl&&(this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null)}),this.windowElement.addEventListener("drop",e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute("can-drop")==="false")return;const t=this.activeDropPaneEl.getAttribute("sash-id"),i=this.rootSash.getById(t);this.onPaneDrop(e,i),typeof i.store.onDrop=="function"&&i.store.onDrop(e,i),this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null})}},yt=!1;class O{constructor(t){E(this,"windowElement",null),E(this,"containerElement",null),E(this,"debug",yt);let i=null;t instanceof ot?(i=t,this.rootSash=t):(i=new st(t),this.rootSash=i.buildSashTree()),this.fitContainer=i.fitContainer}frame(t){this.containerElement=t,this.windowElement=this.createWindow(),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(t){this.frame(t),this.enableFeatures()}static assemble(...t){t.forEach(i=>{Y(this.prototype,i)})}}O.assemble(gt,ft,pt,wt,bt,mt);const Et={label:"",className:"bw-glass-action--close",onClick:(e,t)=>{const i=D(e.target);t.removePane(i)}},vt={label:"",className:"bw-glass-action--minimize",onClick:(e,t)=>{const i=t.sillElement;if(!i)throw new Error("[bwin] Sill element not found when minimizing");const n=z('<button class="bw-minimized-glass" />');i.append(n);const s=e.target.closest("bw-pane"),o=e.target.closest("bw-glass"),h=s.getAttribute("sash-id"),r=s.getAttribute("position");n.bwGlassElement=o,n.bwOriginalPosition=r,n.bwOriginalBoundingRect=M(s),n.bwOriginalSashId=h,t.removePane(h)}},Nt={label:"",className:"bw-glass-action--maximize",onClick:e=>{const t=e.target.closest("bw-pane");t.hasAttribute("maximized")?(t.removeAttribute("maximized"),t.style.left=`${t.bwOriginalBoundingRect.left}px`,t.style.top=`${t.bwOriginalBoundingRect.top}px`,t.style.width=`${t.bwOriginalBoundingRect.width}px`,t.style.height=`${t.bwOriginalBoundingRect.height}px`):(t.setAttribute("maximized",""),t.bwOriginalBoundingRect=M(t),t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%")}};function St(e,t){const i=e.left+e.width,n=e.top+e.height,s=t.left+t.width,o=t.top+t.height;if(e.left>=s||t.left>=i||e.top>=o||t.top>=n)return null;const h=Math.max(e.left,t.left),r=Math.max(e.top,t.top),d=Math.min(i,s),l=Math.min(n,o);return{left:h,top:r,width:d-h,height:l-r}}const B=[vt,Nt,Et],zt={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){const t=e.bwOriginalBoundingRect;let i=0,n=null;if(this.windowElement.querySelectorAll("bw-pane").forEach(s=>{const o=M(s),h=St(t,o);if(h){const r=h.width*h.height;r>i&&(i=r,n=s)}}),n){const s=e.bwOriginalPosition,o=M(n),h=n.getAttribute("sash-id"),r=this.rootSash.getById(h);let d=0;if(s===a.Left||s===a.Right)d=o.width-t.width<r.minWidth?o.width/2:t.width;else if(s===a.Top||s===a.Bottom)d=o.height-t.height<r.minHeight?o.height/2:t.height;else throw new Error("[bwin] Invalid position when restoring glass");const l=e.bwOriginalSashId;this.addPane(n.getAttribute("sash-id"),{id:l,position:s,size:d}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener("click",e=>{if(!e.target.matches(".bw-minimized-glass"))return;const t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(".bw-glass-action--close"),this.updateDisabledState(".bw-glass-action--minimize"),this.updateDisabledState(".bw-glass-action--maximize")},updateDisabledState(e){if(this.windowElement.querySelectorAll("bw-pane").length===1){const t=this.windowElement.querySelector(e);t&&t.setAttribute("disabled","")}else this.windowElement.querySelectorAll(e).forEach(t=>{t.removeAttribute("disabled")})},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(t=>{t.type==="childList"&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},A={title:null,content:null,tabs:[],actions:void 0,draggable:!0};class G{constructor({title:t=A.title,content:i=A.content,tabs:n=A.tabs,actions:s=A.actions,draggable:o=A.draggable,sash:h,binaryWindow:r}){E(this,"domNode"),this.title=t,this.content=i,this.tabs=n,this.actions=s,this.sash=h,this.draggable=o,this.binaryWindow=r,this.build()}build(){const t=document.createElement("bw-glass-header");if(Array.isArray(this.tabs)&&this.tabs.length>0)t.append(this.createTabs());else if(this.title){const s=document.createElement("bw-glass-title");s.append(z(this.title)),t.append(s)}t.setAttribute("can-drag",this.draggable),t.append(this.createActions());const i=document.createElement("bw-glass-content"),n=z(this.content);n&&i.append(n),this.domNode=document.createElement("bw-glass"),this.domNode.append(t,i)}createTabs(){const t=document.createElement("bw-glass-tab-container");for(const i of this.tabs){const n=(i==null?void 0:i.label)??i,s=z(`<button class="bw-glass-tab">${n}</button>`);t.append(s)}return t}createActions(){const t=document.createElement("bw-glass-action-container"),i=this.actions===void 0?B:Array.isArray(this.actions)?this.actions:[];for(const n of i){const s=(n==null?void 0:n.label)??n,o=n.className?`bw-glass-action ${n.className}`:"bw-glass-action",h=z(`<button class="${o}">${s}</button>`);typeof n.onClick=="function"&&h.addEventListener("click",r=>{n.onClick(r,this.binaryWindow)}),t.append(h)}return t}get contentElement(){return this.domNode.querySelector("bw-glass-content")}get headerElement(){return this.domNode.querySelector("bw-glass-header")}}const Ct={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;const i=this.activeDropPaneEl.getAttribute("drop-area");if(i==="center"){const n=this.activeDragGlassEl.closest("bw-pane");this.swapPanes(n,this.activeDropPaneEl);return}else{const n=D(this.activeDragGlassEl);this.removePane(n),this.addPane(t.id,{position:i,id:n}).domNode.append(this.activeDragGlassEl)}},enableDrag(){document.addEventListener("mousedown",e=>{if(e.button!==0||!e.target.matches("bw-glass-header"))return;if(e.target.getAttribute("can-drag")==="false"){e.preventDefault();return}const t=e.target.closest("bw-glass");t.setAttribute("draggable",!0),this.activeDragGlassEl=t}),document.addEventListener("mouseup",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl=null)}),this.windowElement.addEventListener("dragstart",e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches("bw-glass")||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed="move";const t=this.activeDragGlassEl.closest("bw-pane");this.activeDragGlassPaneCanDrop=t.getAttribute("can-drop")!=="false",t.setAttribute("can-drop",!1)}),this.windowElement.addEventListener("dragend",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop",this.activeDragGlassPaneCanDrop),this.activeDragGlassEl=null)})}},At={trimMuntin(e){e.hasAttribute("vertical")?(e.style.top=`${parseFloat(e.style.top)+this.muntinSize/2}px`,e.style.height=`${parseFloat(e.style.height)-this.muntinSize}px`):e.hasAttribute("horizontal")&&(e.style.left=`${parseFloat(e.style.left)+this.muntinSize/2}px`,e.style.width=`${parseFloat(e.style.width)-this.muntinSize}px`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}};class k extends O{constructor(){super(...arguments),E(this,"sillElement",null)}frame(){super.frame(...arguments);const t=z("<bw-sill />");this.windowElement.append(t),this.sillElement=t}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(t,i){const n=new G({...i.store,sash:i,binaryWindow:this});t.innerHTML="",t.append(n.domNode),this.debug&&n.contentElement.prepend(`${i.id}`)}onPaneUpdate(){}addPane(t,i){const{position:n,size:s,id:o,...h}=i,r=super.addPane(t,{position:n,size:s,id:o}),d=new G({...h,sash:r,binaryWindow:this});return r.domNode.append(d.domNode),r}}k.assemble(Ct,At,zt);const N=4;function Mt({sash:e}){var c;const t=u.useRef(),i=e.leftChild,n=e.topChild;let s,o,h,r,d,l;return i?(s=N,o=e.height-N,h=e.top+N/2,r=e.left+i.width-N/2,d=!0):n&&(s=e.width-N,o=N,h=e.top+n.height-N/2,r=e.left+N/2,l=!0),u.useEffect(()=>{e.domNode=t.current},[]),u.createElement("bw-muntin",{"sash-id":e.id,style:{width:s,height:o,top:h,left:r},vertical:d,horizontal:l,resizable:((c=e.store)==null?void 0:c.resizable)===!1?"false":"true",ref:t})}function Pt({sash:e,bwin:t}){var c,g,f,b,y;const i=u.useRef(),{left:n,top:s,width:o,height:h,id:r,position:d}=e;u.useEffect(()=>{e.domNode=i.current},[]);const l=((c=e.store)==null?void 0:c.actions)===void 0?B:Array.isArray(e.store.actions)?e.store.actions:[];return u.createElement("bw-pane",{"sash-id":r,position:d,style:{left:n,top:s,width:o,height:h},"can-drop":((g=e.store)==null?void 0:g.droppable)===!1?"false":"true",ref:i},u.createElement("bw-glass",null,u.createElement("bw-glass-header",{"can-drag":((f=e.store)==null?void 0:f.draggable)===!1?"false":"true"},((b=e.store)==null?void 0:b.title)&&u.createElement("bw-glass-title",null,e.store.title),l.length>0&&u.createElement("bw-glass-action-container",null,l.map((p,L)=>{const T=p.className?`bw-glass-action ${p.className}`:"bw-glass-action";return u.createElement("button",{className:T,key:L,onClick:W=>p.onClick(W,t)},p.label)}))),u.createElement("bw-glass-content",null,(y=e.store)==null?void 0:y.content)))}const Dt=u.forwardRef((e,t)=>{const i=u.useRef(),n=u.useRef(),[s,o]=u.useState(),{panes:h,...r}=e,d={...r,children:h},l=new k(d),c=[],g=[];l.rootSash.walk(p=>{p.children.length>0?c.push(p):g.push(p)}),u.useEffect(()=>{const p=i.current;p!=null&&p.parentElement&&(l.windowElement=p,l.containerElement=p.parentElement,l.sillElement=n.current,l.enableFeatures())},[]),u.useImperativeHandle(t,()=>({fit:l.fit.bind(l),removePane:l.removePane.bind(l),addPane:y}),[]);const f=u.createElement("bw-window",{"root-sash-id":l.rootSash.id,style:{width:l.rootSash.width,height:l.rootSash.height},ref:i},g.map(p=>u.createElement(Pt,{key:p.id,sash:p,bwin:l})),c.map(p=>u.createElement(Mt,{key:p.id,sash:p})),u.createElement("bw-sill",{ref:n})),b=u.useMemo(()=>f,[]);function y(p,L){const{content:T,...W}=L,Rt=l.addPane(p,W),$t=document.querySelector(`bw-pane[sash-id="${Rt.id}"] bw-glass-content`);o(Bt=>[...Bt||[],{node:T,container:$t}])}return u.createElement(u.Fragment,null,b,s==null?void 0:s.map(p=>F.createPortal(p.node,p.container)))}),xt="0.3.3";w.BUILTIN_ACTIONS=B,w.Window=Dt,w.version=xt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-bwin",
3
3
  "description": "A tiling window manager in React based on Binary Window library",
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -45,7 +45,7 @@
45
45
  "@types/react": "^16.14.62",
46
46
  "@types/react-dom": "^16.9.24",
47
47
  "@vitejs/plugin-react": "^4.3.4",
48
- "bwin": "0.2.2",
48
+ "bwin": "0.2.5",
49
49
  "prettier": "^3.4.1",
50
50
  "react": "^16.14.0",
51
51
  "react-dom": "^16.14.0",