react-bwin 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- bw-window{--bw-font-family:system-ui;--bw-font-size:14px;--bw-drop-area-bg-color:#0000000d;--bw-glass-clearance:2px;--bw-glass-border-radius:2px;--bw-glass-border-color:#1a1a1a;--bw-glass-border-color-disabled:#ccc;--bw-glass-bg-color-disabled:#f7f7f7;--bw-glass-header-height:30px;--bw-glass-header-gap:4px;--bw-glass-header-bg-color:#f7f7f7;--bw-minimized-glass-highlight-color:#d9d9d9;--bw-detached-glass-shadow:0 2px 6px #0000001f, 0 4px 14px #00000038;--bw-detached-glass-shadow-active:0 4px 10px #00000038, 0 10px 30px #00000061;--bw-detached-glass-resize-handle-size:12px;--bw-sill-gap:6px}bw-window[theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bw-glass-border-color:#666;--bw-glass-border-color-disabled:#4d4d4d;--bw-glass-header-bg-color:#2e2e2e;--bw-glass-bg-color-disabled:#292929;--bw-drop-area-bg-color:#ffffff1a;--bw-detached-glass-shadow:0 2px 6px #0000008c, 0 4px 14px #000000a6;--bw-detached-glass-shadow-active:0 4px 10px #000000a6, 0 10px 30px #000c;--bw-minimized-glass-highlight-color:#a6a6a6cc}bw-window[theme=dark] bw-pane,bw-window[theme=dark] bw-muntin{background-color:#242424}bw-window[theme=dark] bw-glass{color:#e6e6e6;background-color:#292929}bw-window[theme=dark] .bw-glass-tab:hover,bw-window[theme=dark] .bw-glass-action:hover,bw-window[theme=dark] .bw-minimized-glass:hover{background-color:#424242}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{box-sizing:border-box;display:block;position:absolute}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{isolation:isolate;box-sizing:border-box;background-color:#f2f2f2;position:absolute;overflow:auto}bw-pane[drop-area]:before{content:"";background-color:var(--bw-drop-area-bg-color);position:absolute}bw-pane[drop-area=top]:before{height:50%;top:0;left:0;right:0}bw-pane[drop-area=right]:before{width:50%;top:0;bottom:0;right:0}bw-pane[drop-area=bottom]:before{height:50%;bottom:0;left:0;right:0}bw-pane[drop-area=left]:before{width:50%;top:0;bottom:0;left:0}bw-pane[drop-area=center]:before{inset:0}bw-muntin{box-sizing:border-box;background-color:#fff;position:absolute}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:#0000}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:#0000}bw-glass{inset:var(--bw-glass-clearance);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box;background-color:#fff;flex-direction:column;display:flex;position:absolute}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;flex-basis:var(--bw-glass-header-height);-webkit-user-select:none;user-select:none;align-items:center;gap:var(--bw-glass-header-gap);padding-inline:var(--bw-glass-header-gap);border-bottom:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);background-color:var(--bw-glass-header-bg-color);flex-shrink:0;display:flex;overflow:hidden}bw-glass-title{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}bw-glass-tab-container{align-self:flex-end;gap:var(--bw-glass-header-gap);display:flex}.bw-glass-tab{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);cursor:pointer;border-bottom:none}.bw-glass-tab:hover{background-color:#fff}.bw-glass-tab:active{transform:translateY(1px)}bw-glass-action-container{flex-shrink:0;gap:2px;margin-left:auto;display:flex}.bw-glass-action{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-action:hover{background-color:#fff}.bw-glass-action:active{transform:scale(.95)}.bw-glass-action:disabled{border:1px solid var(--bw-glass-border-color-disabled);background-color:var(--bw-glass-bg-color-disabled);cursor:not-allowed}.bw-glass-action:disabled:hover{background-color:var(--bw-glass-bg-color-disabled)}.bw-glass-action:disabled:active{transform:scale(1)}.bw-glass-action--minimize:before{content:"−"}.bw-glass-action--detach:before{content:"☐"}.bw-glass-action--attach:before{content:""}.bw-glass-action--maximize:before{content:"🡥"}bw-pane[maximized] .bw-glass-action--maximize:before{content:"🡧"}.bw-glass-action--close:before{content:"✕"}bw-glass-content{box-sizing:border-box;flex-grow:1;display:block;overflow:auto}bw-glass[detached]{box-shadow:var(--bw-detached-glass-shadow)}bw-glass[detached][active]{box-shadow:var(--bw-detached-glass-shadow-active)}bw-glass[detached]>bw-glass-header[can-drag=true]:active{cursor:move}bw-glass-resize-handle{z-index:2;touch-action:none;position:absolute}bw-glass-resize-handle[resize-dir=n]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=s]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=e]{top:0;bottom:0;right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=w]{top:0;bottom:0;left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=ne]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-glass-resize-handle[resize-dir=nw]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=se]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=sw]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-sill{margin-top:calc(var(--bw-sill-gap) - var(--bw-glass-clearance));gap:var(--bw-sill-gap);box-sizing:border-box;width:100%;padding-inline:var(--bw-glass-clearance);display:flex;position:absolute;top:100%}.bw-minimized-glass,.bw-minimized-detached-glass{border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer;background-color:var(--bw-glass-header-bg-color);flex-basis:10%;height:10px;display:block}:is(.bw-minimized-glass,.bw-minimized-detached-glass):hover{background-color:#fff}:is(.bw-minimized-glass,.bw-minimized-detached-glass):active{transform:scale(.95)}.bw-minimized-glass,.bw-minimized-detached-glass{animation:2s ease-out bw-minimized-glass-highlight}@keyframes bw-minimized-glass-highlight{0%{background-color:var(--bw-glass-header-bg-color)}30%{background-color:var(--bw-minimized-glass-highlight-color)}to{background-color:var(--bw-glass-header-bg-color)}}
1
+ bw-window{--bw-font-family:system-ui;--bw-font-size:14px;--bw-drop-area-bg-color:#0000000d;--bw-glass-clearance:2px;--bw-glass-border-radius:2px;--bw-glass-border-color:#1a1a1a;--bw-glass-border-color-disabled:#ccc;--bw-glass-bg-color-disabled:#f7f7f7;--bw-glass-header-height:30px;--bw-glass-header-gap:4px;--bw-glass-header-bg-color:#f7f7f7;--bw-minimized-glass-highlight-color:#d9d9d9;--bw-detached-glass-shadow:0 2px 6px #0000001f, 0 4px 14px #00000038;--bw-detached-glass-shadow-active:0 4px 10px #00000038, 0 10px 30px #00000061;--bw-detached-glass-resize-handle-size:12px;--bw-sill-gap:6px}bw-window[theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bw-glass-border-color:#666;--bw-glass-border-color-disabled:#4d4d4d;--bw-glass-header-bg-color:#2e2e2e;--bw-glass-bg-color-disabled:#292929;--bw-drop-area-bg-color:#ffffff1a;--bw-detached-glass-shadow:0 2px 6px #0000008c, 0 4px 14px #000000a6;--bw-detached-glass-shadow-active:0 4px 10px #000000a6, 0 10px 30px #000c;--bw-minimized-glass-highlight-color:#a6a6a6cc}bw-window[theme=dark] bw-pane,bw-window[theme=dark] bw-muntin{background-color:#242424}bw-window[theme=dark] bw-glass{color:#e6e6e6;background-color:#292929}bw-window[theme=dark] .bw-glass-tab:hover,bw-window[theme=dark] .bw-glass-action:hover,bw-window[theme=dark] .bw-minimized-glass:hover{background-color:#424242}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{box-sizing:border-box;display:block;position:absolute}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{isolation:isolate;box-sizing:border-box;background-color:#f2f2f2;position:absolute;overflow:auto}bw-pane[drop-area]:before{content:"";background-color:var(--bw-drop-area-bg-color);position:absolute}bw-pane[drop-area=top]:before{height:50%;top:0;left:0;right:0}bw-pane[drop-area=right]:before{width:50%;top:0;bottom:0;right:0}bw-pane[drop-area=bottom]:before{height:50%;bottom:0;left:0;right:0}bw-pane[drop-area=left]:before{width:50%;top:0;bottom:0;left:0}bw-pane[drop-area=center]:before{inset:0}bw-muntin{box-sizing:border-box;background-color:#fff;position:absolute}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:#0000}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:#0000}bw-glass{inset:var(--bw-glass-clearance);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box;background-color:#fff;flex-direction:column;display:flex;position:absolute}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;flex-basis:var(--bw-glass-header-height);-webkit-user-select:none;user-select:none;align-items:center;gap:var(--bw-glass-header-gap);padding-inline:var(--bw-glass-header-gap);border-bottom:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);background-color:var(--bw-glass-header-bg-color);flex-shrink:0;display:flex;overflow:hidden}bw-glass-title{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}bw-glass-tab-container{align-self:flex-end;gap:var(--bw-glass-header-gap);display:flex}.bw-glass-tab{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);cursor:pointer;border-bottom:none}.bw-glass-tab:hover{background-color:#fff}.bw-glass-tab:active{transform:translateY(1px)}bw-glass-action-container{flex-shrink:0;gap:2px;margin-left:auto;display:flex}.bw-glass-action{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-action:hover{background-color:#fff}.bw-glass-action:active{transform:scale(.95)}.bw-glass-action:disabled{border:1px solid var(--bw-glass-border-color-disabled);background-color:var(--bw-glass-bg-color-disabled);cursor:not-allowed}.bw-glass-action:disabled:hover{background-color:var(--bw-glass-bg-color-disabled)}.bw-glass-action:disabled:active{transform:scale(1)}.bw-glass-action--minimize:before{content:"−"}.bw-glass-action--detach:before{content:"☐"}.bw-glass-action--attach:before{content:""}.bw-glass-action--maximize:before{content:"🡥"}bw-pane[maximized] .bw-glass-action--maximize:before{content:"🡧"}.bw-glass-action--close:before{content:"✕"}bw-glass-content{box-sizing:border-box;flex-grow:1;display:block;overflow:auto}bw-glass[detached]{box-shadow:var(--bw-detached-glass-shadow)}bw-glass[detached][active]{box-shadow:var(--bw-detached-glass-shadow-active)}bw-glass[detached]>bw-glass-header[can-drag=true]:active{cursor:move}bw-glass-resize-handle{z-index:2;touch-action:none;position:absolute}bw-glass-resize-handle[resize-dir=n]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=s]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=e]{top:0;bottom:0;right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=w]{top:0;bottom:0;left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=ne]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-glass-resize-handle[resize-dir=nw]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=se]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=sw]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-sill{margin-top:calc(var(--bw-sill-gap) - var(--bw-glass-clearance));gap:var(--bw-sill-gap);box-sizing:border-box;width:100%;padding-inline:var(--bw-glass-clearance);display:flex;position:absolute;top:100%}.bw-minimized-glass,.bw-minimized-detached-glass{border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer;background-color:var(--bw-glass-header-bg-color);flex-basis:10%;height:10px;display:block}:is(.bw-minimized-glass,.bw-minimized-detached-glass):hover{background-color:#fff}:is(.bw-minimized-glass,.bw-minimized-detached-glass):active{transform:scale(.95)}.bw-minimized-glass,.bw-minimized-detached-glass{animation:2s ease-out bw-minimized-glass-highlight}@keyframes bw-minimized-glass-highlight{0%{background-color:var(--bw-glass-header-bg-color)}30%{background-color:var(--bw-minimized-glass-highlight-color)}to{background-color:var(--bw-glass-header-bg-color)}}
2
2
  /*$vite$:1*/
@@ -1,6 +1,6 @@
1
1
  import e, { forwardRef as t, useEffect as n, useImperativeHandle as r, useMemo as i, useRef as a, useState as o } from "react";
2
2
  import { createPortal as s } from "react-dom";
3
- //#region node_modules/.pnpm/bwin@0.4.1/node_modules/bwin/dist/bwin.js
3
+ //#region node_modules/.pnpm/bwin@0.4.2/node_modules/bwin/dist/bwin.js
4
4
  function c(e = .7, t = 128) {
5
5
  let n = 256 - t;
6
6
  return `rgba(${Math.floor(Math.random() * n + t)}, ${Math.floor(Math.random() * n + t)}, ${Math.floor(Math.random() * n + t)}, ${Math.max(.5, Math.random() * e)})`;
@@ -808,7 +808,7 @@ var P = {
808
808
  this.removePane(e), this.addPane(t.id, {
809
809
  position: n,
810
810
  id: e
811
- }).domNode.append(F);
811
+ }).domNode.replaceChildren(F);
812
812
  }
813
813
  },
814
814
  enableGlassDrag() {
@@ -866,7 +866,7 @@ var P = {
866
866
  width: o,
867
867
  height: s
868
868
  }), l = n.getAttribute("sash-id"), u = t.rootSash.getById(l), d = u.parent.getChildSiblingById(l).id;
869
- c.domNode.bwOriginalSiblingSashId = d, c.domNode.bwOriginalPosition = n.getAttribute("position"), c.domNode.bwOriginalRelativeSize = u.getRelativeSize(), c.contentElement.replaceWith(r), c.titleElement.replaceWith(i), t.removePane(l);
869
+ c.domNode.bwOriginalSiblingSashId = d, c.domNode.bwOriginalPosition = n.getAttribute("position"), c.domNode.bwOriginalRelativeSize = u.getRelativeSize(), c.contentElement.replaceWith(r), i && c.titleElement.replaceWith(i), t.removePane(l);
870
870
  }
871
871
  }, V = [
872
872
  R,
@@ -1351,6 +1351,6 @@ var Ve = t((t, c) => {
1351
1351
  }]);
1352
1352
  }
1353
1353
  return /* @__PURE__ */ e.createElement(e.Fragment, null, y, d?.map((e) => s(e.node, e.container)));
1354
- }), He = "0.4.0";
1354
+ }), He = "0.4.1";
1355
1355
  //#endregion
1356
1356
  export { be as BUILTIN_ACTIONS, W as DEFAULT_DETACHED_GLASS_ACTIONS, V as DEFAULT_GLASS_ACTIONS, Ve as Window, He as version };
@@ -5,4 +5,4 @@ top: ${e.style.top}
5
5
  left: ${e.style.left}
6
6
  width: ${e.style.width}
7
7
  height: ${e.style.height}
8
- `.trim(),t}var ye={createWindow({theme:e}={}){let t=document.createElement(`bw-window`);return t.style.width=`${this.rootSash.width}px`,t.style.height=`${this.rootSash.height}px`,t.setAttribute(`root-sash-id`,this.rootSash.id),e&&t.setAttribute(`theme`,e),t},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`;let e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll(`[sash-id]`).forEach(n=>{let r=n.getAttribute(`sash-id`);t.push(r),e.includes(r)||n.remove()}),this.rootSash.walk(e=>{e.children.length>0?t.includes(e.id)?(this.updateMuntin(e),this.onMuntinUpdate(e.domNode,e)):(e.domNode=this.createMuntin(e),this.windowElement.append(e.domNode)):t.includes(e.id)?(this.updatePane(e),this.onPaneUpdate(e.domNode,e)):(e.domNode||=this.createPane(e),this.windowElement.prepend(e.domNode))})}},be={muntinSize:4,createMuntin(e){let t=document.createElement(`bw-muntin`),n=e.leftChild,r=e.topChild;return n?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`,t.setAttribute(`vertical`,``)):r&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+r.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){let t=e.domNode,n=e.leftChild,r=e.topChild;n?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`):r&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+r.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},D={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{requestAnimationFrame(()=>{for(let t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()})}).observe(this.containerElement)}},O={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;let 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;let[t,n,r,i]=this.activeMuntinSash.getChildren(),a=this.activeMuntinSash.isLeftRightSplit(),o=this.activeMuntinSash.isTopBottomSplit();if(a&&i&&n){let t=e.pageX-this.lastX,r=i.width+t,a=n.width-t;if(t>0&&a<=n.calcMinWidth()||t<0&&r<=i.calcMinWidth())return;i.width=r,n.width=a,n.left+=t,this.update(),this.lastX=e.pageX}else if(o&&t&&r){let n=e.pageY-this.lastY,i=t.height+n,a=r.height-n;if(n>0&&a<=r.calcMinHeight()||n<0&&i<=t.calcMinHeight())return;t.height=i,r.height=a,r.top+=n,this.update(),this.lastY=e.pageY}}),document.addEventListener(`mouseup`,()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},k={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener(`dragover`,e=>{e.preventDefault();let 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;let n=se(t,e);t.setAttribute(`drop-area`,n)}),this.windowElement.addEventListener(`dragleave`,e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||(this.activeDropPaneEl&&=(this.activeDropPaneEl.removeAttribute(`drop-area`),null))}),this.windowElement.addEventListener(`drop`,e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute(`can-drop`)===`false`)return;let t=this.activeDropPaneEl.getAttribute(`sash-id`),n=this.rootSash.getById(t);this.onPaneDrop(e,n),typeof n.store.onDrop==`function`&&n.store.onDrop(e,n),this.activeDropPaneEl.removeAttribute(`drop-area`),this.activeDropPaneEl=null})}},A=!1,j=class{windowElement=null;containerElement=null;debug=A;constructor(e){let t=null;e instanceof ue?(t=e,this.rootSash=e):(t=new le(e),this.rootSash=t.buildSashTree({resizeStrategy:t.resizeStrategy})),this.fitContainer=t.fitContainer}frame(e){this.containerElement=e,this.windowElement=this.createWindow({theme:this.theme}),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(e){this.frame(e),this.enableFeatures()}static assemble(...e){e.forEach(e=>{ee(this.prototype,e)})}};j.assemble(ye,be,ve,D,k,O);function M(e,t){let n=e.left+e.width,r=e.top+e.height,i=t.left+t.width,a=t.top+t.height;if(e.left>=i||t.left>=n||e.top>=a||t.top>=r)return null;let o=Math.max(e.left,t.left),s=Math.max(e.top,t.top),c=Math.min(n,i),l=Math.min(r,a);return{left:o,top:s,width:c-o,height:l-s}}var N={enableGlassActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){let t=e.bwOriginalBoundingRect,n=0,r=null;if(this.windowElement.querySelectorAll(`bw-pane`).forEach(e=>{let i=M(t,_(e));if(i){let t=i.width*i.height;t>n&&(n=t,r=e)}}),r){let n=e.bwOriginalPosition,i=_(r),a=r.getAttribute(`sash-id`),o=this.rootSash.getById(a),s=0;if(n===v.Left||n===v.Right)s=i.width-t.width<o.minWidth?i.width/2:t.width;else if(n===v.Top||n===v.Bottom)s=i.height-t.height<o.minHeight?i.height/2:t.height;else throw Error(`[bwin] Invalid position when restoring glass`);let c=e.bwOriginalSashId;this.addPane(r.getAttribute(`sash-id`),{id:c,position:n,size:s}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener(`click`,e=>{if(!e.target.matches(`.bw-minimized-glass`))return;let 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`),this.updateDisabledState(`.bw-glass-action--detach`)},updateDisabledState(e){if(this.windowElement.querySelectorAll(`bw-pane`).length===1){let t=this.windowElement.querySelector(e);t&&t.setAttribute(`disabled`,``)}else this.windowElement.querySelectorAll(e).forEach(e=>{e.removeAttribute(`disabled`)})},getMinimizedGlassElementBySashId(e){let t=this.windowElement.querySelectorAll(`.bw-minimized-glass`);return Array.from(t).find(t=>t.bwOriginalSashId===e)},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(e=>{e.type===`childList`&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},P=null,F=!1,xe={onPaneDrop(e,t){if(!P)return;let n=this.activeDropPaneEl.getAttribute(`drop-area`);if(n===`center`){let e=P.closest(`bw-pane`);this.swapPanes(e,this.activeDropPaneEl);return}else{let e=T(P);this.removePane(e),this.addPane(t.id,{position:n,id:e}).domNode.append(P)}},enableGlassDrag(){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}let t=e.target.closest(`bw-glass`);t.setAttribute(`draggable`,!0),P=t}),document.addEventListener(`mouseup`,()=>{P&&=(P.removeAttribute(`draggable`),null)}),this.windowElement.addEventListener(`dragstart`,e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches(`bw-glass`)||!P)return;e.dataTransfer.effectAllowed=`move`;let t=P.closest(`bw-pane`);F=t.getAttribute(`can-drop`)!==`false`,t.setAttribute(`can-drop`,!1)}),this.windowElement.addEventListener(`dragend`,()=>{P&&=(P.removeAttribute(`draggable`),P.closest(`bw-pane`).setAttribute(`can-drop`,F),null)})}},I={label:``,className:`bw-glass-action--close`,onClick:(e,t)=>{let n=T(e.target);t.removePane(n)}},L={label:``,className:`bw-glass-action--minimize`,onClick:(e,t)=>{let n=t.sillElement;if(!n)throw Error(`[bwin] Sill element not found when minimizing`);let r=g(`<button class="bw-minimized-glass" />`);n.append(r);let i=e.target.closest(`bw-pane`),a=e.target.closest(`bw-glass`),o=i.getAttribute(`sash-id`),s=i.getAttribute(`position`);r.bwGlassElement=a,r.bwOriginalPosition=s,r.bwOriginalBoundingRect=_(i),r.bwOriginalSashId=o,t.removePane(o)}},Se={label:``,className:`bw-glass-action--maximize`,onClick:e=>{let 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=_(t),t.style.left=`0`,t.style.top=`0`,t.style.width=`100%`,t.style.height=`100%`)}},R=15,z={label:``,className:`bw-glass-action--detach`,onClick:(e,t)=>{if(!t.addDetachedGlass)throw Error(`[bwin] Failed to detach glass from pane`);let n=e.target.closest(`bw-pane`),r=n.querySelector(`bw-glass-content`),i=n.querySelector(`bw-glass-title`),a=t.windowElement.getBoundingClientRect(),o=a.width-R*2,s=a.height-R*2,c=t.addDetachedGlass({position:`center`,width:o,height:s}),l=n.getAttribute(`sash-id`),u=t.rootSash.getById(l),d=u.parent.getChildSiblingById(l).id;c.domNode.bwOriginalSiblingSashId=d,c.domNode.bwOriginalPosition=n.getAttribute(`position`),c.domNode.bwOriginalRelativeSize=u.getRelativeSize(),c.contentElement.replaceWith(r),c.titleElement.replaceWith(i),t.removePane(l)}},B=[L,z,I],V=class{domNode;constructor({title:e=null,content:t=null,tabs:n=[],actions:r=B,draggable:i=!0,sash:a=null,binaryWindow:o}){this.title=e,this.content=t,this.tabs=n,this.actions=r,this.sash=a,this.draggable=i,this.binaryWindow=o,this.build()}build(){let e=document.createElement(`bw-glass-header`);if(Array.isArray(this.tabs)&&this.tabs.length>0)e.append(this.createTabs());else{let t=document.createElement(`bw-glass-title`);this.title&&t.append(g(this.title)),e.append(t)}e.setAttribute(`can-drag`,this.draggable),e.append(this.createActions());let t=document.createElement(`bw-glass-content`),n=g(this.content);n&&t.append(n),this.domNode=document.createElement(`bw-glass`),this.domNode.append(e,t)}createTabs(){let e=document.createElement(`bw-glass-tab-container`);for(let t of this.tabs){let n=g(`<button class="bw-glass-tab">${t?.label??t}</button>`);e.append(n)}return e}createActions(){let e=document.createElement(`bw-glass-action-container`),t=Array.isArray(this.actions)?this.actions:[];for(let n of t){let t=n?.label??n,r=g(`<button class="${n.className?`bw-glass-action ${n.className}`:`bw-glass-action`}">${t}</button>`);typeof n.onClick==`function`&&r.addEventListener(`click`,e=>{n.onClick(e,this.binaryWindow)}),e.append(r)}return e}get contentElement(){return this.domNode.querySelector(`bw-glass-content`)}get headerElement(){return this.domNode.querySelector(`bw-glass-header`)}get titleElement(){return this.domNode.querySelector(`bw-glass-title`)}},Ce=[L,Se,z,I],we={enableGlassFeature(){this.enableGlassActions(),this.enableGlassDrag()},...N,...xe},Te={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)}},H=[`n`,`s`,`e`,`w`,`ne`,`nw`,`se`,`sw`];function Ee(){return H.map(e=>{let t=document.createElement(`bw-glass-resize-handle`);return t.setAttribute(`resize-dir`,e),t})}function De({position:e,offset:t,offsetX:n,offsetY:r,width:i,height:a}){let o=n??t,s=r??t;switch(e){case`top-left`:return{top:`${s}px`,left:`${o}px`,right:`auto`,bottom:`auto`};case`top-right`:return{top:`${s}px`,right:`${o}px`,left:`auto`,bottom:`auto`};case`bottom-left`:return{bottom:`${s}px`,left:`${o}px`,right:`auto`,top:`auto`};case`bottom-right`:return{bottom:`${s}px`,right:`${o}px`,left:`auto`,top:`auto`};case`center`:return{top:`calc(50% - ${a/2}px + ${s}px)`,left:`calc(50% - ${i/2}px + ${o}px)`,right:`auto`,bottom:`auto`};default:throw Error(`Position "${e}" is not supported for detached glass.`)}}var U=new class{constructor(){this.glasses=[],this.topZIndex=1}addGlassByElement(e){this.glasses.push(e)}getActiveGlass(){return this.glasses.find(e=>e.hasAttribute(`active`))??null}bringToFront(e){e.hasAttribute(`active`)||(this.topZIndex+=1,e.style.zIndex=this.topZIndex,e.parentElement?.querySelectorAll(`:scope > bw-glass[detached][active]`).forEach(t=>t!==e&&t.removeAttribute(`active`)),e.setAttribute(`active`,``))}removeGlassById(e){let t=this.glasses.findIndex(t=>t.id===e);if(t!==-1){let[e]=this.glasses.splice(t,1);return e}return null}},W=[{label:``,className:`bw-glass-action--minimize`,onClick:(e,t)=>{let n=t.sillElement;if(!n)throw Error(`[bwin] Sill element not found when minimizing`);let r=g(`<button class="bw-minimized-detached-glass" />`);n.append(r);let i=e.target.closest(`bw-glass[detached]`);if(!i)throw Error(`[bwin] Detached Glass element not found when minimizing`);r.bwDetachedGlassElement=i,i.style.display=`none`}},{label:``,className:`bw-glass-action--attach`,onClick:(e,t)=>{let n=e.target.closest(`bw-glass[detached]`),r=n.bwOriginalPosition,i=n.bwOriginalSiblingSashId,a=n.bwOriginalRelativeSize,o=t.rootSash.getById(i),s=i,c=r,l=a;if(!o){let e=t.rootSash.getLargestLeaf();s=e.id,c=e.width>e.height?`right`:`bottom`,l=.5}let u=n.querySelector(`bw-glass-content`);t.addPane(s,{position:c,size:l,content:ne(u),title:n.querySelector(`bw-glass-title`)?.textContent||``}),t.removeDetachedGlass(n.id)}},{label:``,className:`bw-glass-action--close`,onClick:e=>{let t=e.target.closest(`bw-glass[detached]`);t&&(U.removeGlassById(t.id),t.remove())}}],Oe=class extends V{constructor(e){let{position:t,width:n=222,height:r=222,offset:i=0,offsetX:a,offsetY:o,id:s,actions:c=W,...l}=e;super({...l,actions:c}),this.domNode.setAttribute(`id`,s||d()+`-F`),this.domNode.setAttribute(`detached`,``),this.domNode.style.position=`absolute`,this.domNode.style.width=`${n}px`,this.domNode.style.height=`${r}px`;let{top:u,left:f,right:p,bottom:m}=De({position:t,offset:i,offsetX:a,offsetY:o,width:n,height:r});this.domNode.style.top=u,this.domNode.style.left=f,this.domNode.style.right=p,this.domNode.style.bottom=m}},ke=200,Ae=200,G=25;function je(e,{width:t,height:n}){let r=U.getActiveGlass();if(!r)return{position:`center`};let i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.left-i.left+G,s=a.top-i.top+G;return o+t>i.width&&(o=G),s+n>i.height&&(s=G),{position:`top-left`,offsetX:o,offsetY:s}}var Me={addDetachedGlass(e={}){let t=e.width??ke,n=e.height??Ae,{position:r,offsetX:i,offsetY:a}=e.position?{}:je(this.windowElement,{width:t,height:n}),o=new Oe({actions:this.actions[1],binaryWindow:this,position:r,offsetX:i,offsetY:a,...e,width:t,height:n});return this.windowElement.append(o.domNode),U.addGlassByElement(o.domNode),U.bringToFront(o.domNode),o},removeDetachedGlass(e){let t=U.removeGlassById(e);return t?.remove(),t}},Ne={enableDetachedGlassActivate(){this.windowElement.addEventListener(`pointerdown`,e=>{if(e.button!==0)return;let t=e.target.closest?.(`bw-glass[detached]`);t&&U.bringToFront(t)})}},Pe={enableDetachedGlassMove(){let e=null,t=0,n=0,r=0,i=0;this.windowElement.addEventListener(`pointerdown`,a=>{if(a.button!==0)return;let o=a.target.closest(`bw-glass-header`);if(!o||a.target.closest(`button`)||o.getAttribute(`can-drag`)===`false`)return;let s=o.closest(`bw-glass[detached]`);if(!s)return;a.preventDefault(),o.setPointerCapture(a.pointerId),e=s,t=a.pageX,n=a.pageY;let c=this.windowElement.getBoundingClientRect(),l=s.getBoundingClientRect();r=l.left-c.left,i=l.top-c.top}),this.windowElement.addEventListener(`pointermove`,a=>{if(!e)return;let o=r+(a.pageX-t),s=i+(a.pageY-n);e.style.right=`auto`,e.style.bottom=`auto`,e.style.left=`${o}px`,e.style.top=`${s}px`}),this.windowElement.addEventListener(`pointerup`,t=>{e&&=(t.target.hasPointerCapture?.(t.pointerId)&&t.target.releasePointerCapture(t.pointerId),null)})}},K=null,q=0,J=0,Fe={enableDetachedGlassDrag(){document.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`bw-glass-header`);if(!t||e.target.closest(`button`)||t.getAttribute(`can-drag`)===`false`)return;let n=t.closest(`bw-glass[detached]`);n&&(n.setAttribute(`draggable`,!0),K=n)}),document.addEventListener(`mouseup`,()=>{K&&=(K.removeAttribute(`draggable`),null)}),this.windowElement.addEventListener(`dragstart`,e=>{if(!K)return;e.dataTransfer.effectAllowed=`move`;let t=K.getBoundingClientRect();q=e.clientX-t.left,J=e.clientY-t.top}),this.windowElement.addEventListener(`dragend`,e=>{if(!K)return;let t=this.windowElement.getBoundingClientRect(),n=e.clientX-t.left-q,r=e.clientY-t.top-J;K.style.right=`auto`,K.style.bottom=`auto`,K.style.left=`${n}px`,K.style.top=`${r}px`,K.removeAttribute(`draggable`),K=null})}},Y=100,X=60;function Ie(e){return!!e.querySelector(`:scope > bw-glass-resize-handle`)}function Le(e){Ie(e)||e.append(...Ee())}function Z(e){e.querySelectorAll(`:scope > bw-glass-resize-handle`).forEach(e=>e.remove())}var Re={enableDetachedGlassResize(){let e=null,t=``,n=0,r=0,i=null;this.windowElement.addEventListener(`pointerover`,e=>{let t=e.target.closest?.(`bw-glass[detached]`);t&&Le(t)}),this.windowElement.addEventListener(`pointerout`,t=>{let n=t.target.closest?.(`bw-glass[detached]`);n&&t.relatedTarget?.closest?.(`bw-glass[detached]`)!==n&&n!==e&&Z(n)}),this.windowElement.addEventListener(`pointerdown`,a=>{if(a.button!==0||a.target.tagName!==`BW-GLASS-RESIZE-HANDLE`)return;let o=a.target.closest(`bw-glass[detached]`);if(!o)return;a.preventDefault(),a.target.setPointerCapture(a.pointerId),e=o,t=a.target.getAttribute(`resize-dir`),n=a.pageX,r=a.pageY;let s=this.windowElement.getBoundingClientRect(),c=o.getBoundingClientRect();i={left:c.left-s.left,top:c.top-s.top,width:c.width,height:c.height}}),this.windowElement.addEventListener(`pointermove`,a=>{if(!e)return;let o=t,s=a.pageX-n,c=a.pageY-r,l=i,{left:u,top:d,width:f,height:p}=l;o.includes(`e`)?f=Math.max(Y,l.width+s):o.includes(`w`)&&(f=Math.max(Y,l.width-s),u=l.left+(l.width-f)),o.includes(`s`)?p=Math.max(X,l.height+c):o.includes(`n`)&&(p=Math.max(X,l.height-c),d=l.top+(l.height-p)),e.style.right=`auto`,e.style.bottom=`auto`,e.style.left=`${u}px`,e.style.top=`${d}px`,e.style.width=`${f}px`,e.style.height=`${p}px`}),this.windowElement.addEventListener(`pointerup`,n=>{if(!e)return;n.target.hasPointerCapture?.(n.pointerId)&&n.target.releasePointerCapture(n.pointerId);let r=e;e=null,t=``,i=null,r.matches(`:hover`)||Z(r)})}},ze={handleMinimizedDetachedGlassClick(){this.sillElement.addEventListener(`click`,e=>{let t=e.target;if(!t.matches(`.bw-minimized-detached-glass`))return;let n=t.bwDetachedGlassElement;n&&(n.style.display=``,t.remove(),U.bringToFront(n))})}},Be={enableDetachedGlassFeatures(){this.enableDetachedGlassActivate(),this.enableDetachedGlassResize(),this.enableDetachedGlassMove(),this.handleMinimizedDetachedGlassClick()},...Me,...Ne,...Pe,...Fe,...Re,...ze},Q=class e extends j{sillElement=null;constructor(t){super(t),this.theme=t.theme||``,this.actions=e.normActions(t.actions)}frame(){super.frame(...arguments);let e=g(`<bw-sill />`);this.windowElement.append(e),this.sillElement=e}enableFeatures(){super.enableFeatures(),this.enableGlassFeature(),this.enableDetachedGlassFeatures()}onPaneCreate(e,t){let n=this.actions[0],r=new V({actions:n,...t.store,sash:t,binaryWindow:this});e.innerHTML=``,e.append(r.domNode),this.debug&&r.contentElement.prepend(`${t.id}`)}onPaneUpdate(){}addPane(e,t){let{position:n,size:r,id:i,...a}=t,o=super.addPane(e,{position:n,size:r,id:i}),s=new V({...a,sash:o,binaryWindow:this});return o.domNode.append(s.domNode),o}setTheme(e){if(!e){this.theme=``,this.windowElement.removeAttribute(`theme`);return}this.theme=e,this.windowElement.setAttribute(`theme`,e)}removePane(e){if(this.windowElement.querySelector(`[sash-id="${e}"]`)){super.removePane(e);return}let t=this.getMinimizedGlassElementBySashId(e);t&&t.remove()}static normActions(e){if(e===void 0)return[B,W];if(!e||!Array.isArray(e)||e.length===0)return[[],[]];if(e.length===1&&Array.isArray(e[0]))return[e[0],W];if(!e.some(Array.isArray))return[e,W];if(e.length>=2&&!Array.isArray(e[0])&&Array.isArray(e[1]))return[[],e[1]];if(e.length>=2&&Array.isArray(e[0])&&!Array.isArray(e[1]))return[e[0],[]];if(e.length>=2&&Array.isArray(e[0])&&Array.isArray(e[1]))return e;throw Error(`[bwin] Invalid actions format`)}};Q.assemble(we,Be,Te);var $=4;function Ve({sash:e}){let n=(0,t.useRef)(),r=e.leftChild,i=e.topChild,a,o,s,c,l,u;return r?(a=$,o=e.height-$,s=e.top+$/2,c=e.left+r.width-$/2,l=!0):i&&(a=e.width-$,o=$,s=e.top+i.height-$/2,c=e.left+$/2,u=!0),(0,t.useEffect)(()=>{e.domNode=n.current},[]),t.default.createElement(`bw-muntin`,{"sash-id":e.id,style:{width:a,height:o,top:s,left:c},vertical:l,horizontal:u,resizable:e.store?.resizable===!1?`false`:`true`,ref:n})}function He({sash:e,bwin:n}){let r=(0,t.useRef)(),{left:i,top:a,width:o,height:s,id:c,position:l}=e;(0,t.useEffect)(()=>{e.domNode=r.current},[]);let u=e.store?.actions===void 0?n.actions[0]:Array.isArray(e.store.actions)?e.store.actions:[];return t.default.createElement(`bw-pane`,{"sash-id":c,position:l,style:{left:i,top:a,width:o,height:s},"can-drop":e.store?.droppable===!1?`false`:`true`,ref:r},t.default.createElement(`bw-glass`,null,t.default.createElement(`bw-glass-header`,{"can-drag":e.store?.draggable===!1?`false`:`true`},t.default.createElement(`bw-glass-title`,null,e.store?.title),u.length>0&&t.default.createElement(`bw-glass-action-container`,null,u.map((e,r)=>{let i=e.className?`bw-glass-action ${e.className}`:`bw-glass-action`;return t.default.createElement(`button`,{className:i,key:r,onClick:t=>e.onClick(t,n)},e.label)}))),t.default.createElement(`bw-glass-content`,null,e.store?.content)))}var Ue=(0,t.forwardRef)((e,r)=>{let i=(0,t.useRef)(),a=(0,t.useRef)(),[o,s]=(0,t.useState)(),{panes:c,...l}=e,u=new Q({...l,children:c}),d=[],f=[];u.rootSash.walk(e=>{e.children.length>0?d.push(e):f.push(e)}),(0,t.useEffect)(()=>{let e=i.current;e?.parentElement&&(u.windowElement=e,u.containerElement=e.parentElement,u.sillElement=a.current,u.enableFeatures())},[]),(0,t.useImperativeHandle)(r,()=>({fit:u.fit.bind(u),removePane:u.removePane.bind(u),setTheme:u.setTheme.bind(u),addPane:h}),[]);let p=t.default.createElement(`bw-window`,{"root-sash-id":u.rootSash.id,theme:u.theme||void 0,style:{width:u.rootSash.width,height:u.rootSash.height},ref:i},f.map(e=>t.default.createElement(He,{key:e.id,sash:e,bwin:u})),d.map(e=>t.default.createElement(Ve,{key:e.id,sash:e})),t.default.createElement(`bw-sill`,{ref:a})),m=(0,t.useMemo)(()=>p,[]);function h(e,t){let{content:n,...r}=t,i=u.addPane(e,r),a=document.querySelector(`bw-pane[sash-id="${i.id}"] bw-glass-content`);s(e=>[...e||[],{node:n,container:a}])}return t.default.createElement(t.default.Fragment,null,m,o?.map(e=>(0,n.createPortal)(e.node,e.container)))});e.BUILTIN_ACTIONS=Ce,e.DEFAULT_DETACHED_GLASS_ACTIONS=W,e.DEFAULT_GLASS_ACTIONS=B,e.Window=Ue,e.version=`0.4.0`});
8
+ `.trim(),t}var ye={createWindow({theme:e}={}){let t=document.createElement(`bw-window`);return t.style.width=`${this.rootSash.width}px`,t.style.height=`${this.rootSash.height}px`,t.setAttribute(`root-sash-id`,this.rootSash.id),e&&t.setAttribute(`theme`,e),t},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`;let e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll(`[sash-id]`).forEach(n=>{let r=n.getAttribute(`sash-id`);t.push(r),e.includes(r)||n.remove()}),this.rootSash.walk(e=>{e.children.length>0?t.includes(e.id)?(this.updateMuntin(e),this.onMuntinUpdate(e.domNode,e)):(e.domNode=this.createMuntin(e),this.windowElement.append(e.domNode)):t.includes(e.id)?(this.updatePane(e),this.onPaneUpdate(e.domNode,e)):(e.domNode||=this.createPane(e),this.windowElement.prepend(e.domNode))})}},be={muntinSize:4,createMuntin(e){let t=document.createElement(`bw-muntin`),n=e.leftChild,r=e.topChild;return n?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`,t.setAttribute(`vertical`,``)):r&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+r.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){let t=e.domNode,n=e.leftChild,r=e.topChild;n?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`):r&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+r.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},D={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{requestAnimationFrame(()=>{for(let t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()})}).observe(this.containerElement)}},O={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;let 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;let[t,n,r,i]=this.activeMuntinSash.getChildren(),a=this.activeMuntinSash.isLeftRightSplit(),o=this.activeMuntinSash.isTopBottomSplit();if(a&&i&&n){let t=e.pageX-this.lastX,r=i.width+t,a=n.width-t;if(t>0&&a<=n.calcMinWidth()||t<0&&r<=i.calcMinWidth())return;i.width=r,n.width=a,n.left+=t,this.update(),this.lastX=e.pageX}else if(o&&t&&r){let n=e.pageY-this.lastY,i=t.height+n,a=r.height-n;if(n>0&&a<=r.calcMinHeight()||n<0&&i<=t.calcMinHeight())return;t.height=i,r.height=a,r.top+=n,this.update(),this.lastY=e.pageY}}),document.addEventListener(`mouseup`,()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},k={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener(`dragover`,e=>{e.preventDefault();let 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;let n=se(t,e);t.setAttribute(`drop-area`,n)}),this.windowElement.addEventListener(`dragleave`,e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||(this.activeDropPaneEl&&=(this.activeDropPaneEl.removeAttribute(`drop-area`),null))}),this.windowElement.addEventListener(`drop`,e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute(`can-drop`)===`false`)return;let t=this.activeDropPaneEl.getAttribute(`sash-id`),n=this.rootSash.getById(t);this.onPaneDrop(e,n),typeof n.store.onDrop==`function`&&n.store.onDrop(e,n),this.activeDropPaneEl.removeAttribute(`drop-area`),this.activeDropPaneEl=null})}},A=!1,j=class{windowElement=null;containerElement=null;debug=A;constructor(e){let t=null;e instanceof ue?(t=e,this.rootSash=e):(t=new le(e),this.rootSash=t.buildSashTree({resizeStrategy:t.resizeStrategy})),this.fitContainer=t.fitContainer}frame(e){this.containerElement=e,this.windowElement=this.createWindow({theme:this.theme}),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(e){this.frame(e),this.enableFeatures()}static assemble(...e){e.forEach(e=>{ee(this.prototype,e)})}};j.assemble(ye,be,ve,D,k,O);function M(e,t){let n=e.left+e.width,r=e.top+e.height,i=t.left+t.width,a=t.top+t.height;if(e.left>=i||t.left>=n||e.top>=a||t.top>=r)return null;let o=Math.max(e.left,t.left),s=Math.max(e.top,t.top),c=Math.min(n,i),l=Math.min(r,a);return{left:o,top:s,width:c-o,height:l-s}}var N={enableGlassActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){let t=e.bwOriginalBoundingRect,n=0,r=null;if(this.windowElement.querySelectorAll(`bw-pane`).forEach(e=>{let i=M(t,_(e));if(i){let t=i.width*i.height;t>n&&(n=t,r=e)}}),r){let n=e.bwOriginalPosition,i=_(r),a=r.getAttribute(`sash-id`),o=this.rootSash.getById(a),s=0;if(n===v.Left||n===v.Right)s=i.width-t.width<o.minWidth?i.width/2:t.width;else if(n===v.Top||n===v.Bottom)s=i.height-t.height<o.minHeight?i.height/2:t.height;else throw Error(`[bwin] Invalid position when restoring glass`);let c=e.bwOriginalSashId;this.addPane(r.getAttribute(`sash-id`),{id:c,position:n,size:s}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener(`click`,e=>{if(!e.target.matches(`.bw-minimized-glass`))return;let 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`),this.updateDisabledState(`.bw-glass-action--detach`)},updateDisabledState(e){if(this.windowElement.querySelectorAll(`bw-pane`).length===1){let t=this.windowElement.querySelector(e);t&&t.setAttribute(`disabled`,``)}else this.windowElement.querySelectorAll(e).forEach(e=>{e.removeAttribute(`disabled`)})},getMinimizedGlassElementBySashId(e){let t=this.windowElement.querySelectorAll(`.bw-minimized-glass`);return Array.from(t).find(t=>t.bwOriginalSashId===e)},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(e=>{e.type===`childList`&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},P=null,F=!1,xe={onPaneDrop(e,t){if(!P)return;let n=this.activeDropPaneEl.getAttribute(`drop-area`);if(n===`center`){let e=P.closest(`bw-pane`);this.swapPanes(e,this.activeDropPaneEl);return}else{let e=T(P);this.removePane(e),this.addPane(t.id,{position:n,id:e}).domNode.replaceChildren(P)}},enableGlassDrag(){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}let t=e.target.closest(`bw-glass`);t.setAttribute(`draggable`,!0),P=t}),document.addEventListener(`mouseup`,()=>{P&&=(P.removeAttribute(`draggable`),null)}),this.windowElement.addEventListener(`dragstart`,e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches(`bw-glass`)||!P)return;e.dataTransfer.effectAllowed=`move`;let t=P.closest(`bw-pane`);F=t.getAttribute(`can-drop`)!==`false`,t.setAttribute(`can-drop`,!1)}),this.windowElement.addEventListener(`dragend`,()=>{P&&=(P.removeAttribute(`draggable`),P.closest(`bw-pane`).setAttribute(`can-drop`,F),null)})}},I={label:``,className:`bw-glass-action--close`,onClick:(e,t)=>{let n=T(e.target);t.removePane(n)}},L={label:``,className:`bw-glass-action--minimize`,onClick:(e,t)=>{let n=t.sillElement;if(!n)throw Error(`[bwin] Sill element not found when minimizing`);let r=g(`<button class="bw-minimized-glass" />`);n.append(r);let i=e.target.closest(`bw-pane`),a=e.target.closest(`bw-glass`),o=i.getAttribute(`sash-id`),s=i.getAttribute(`position`);r.bwGlassElement=a,r.bwOriginalPosition=s,r.bwOriginalBoundingRect=_(i),r.bwOriginalSashId=o,t.removePane(o)}},Se={label:``,className:`bw-glass-action--maximize`,onClick:e=>{let 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=_(t),t.style.left=`0`,t.style.top=`0`,t.style.width=`100%`,t.style.height=`100%`)}},R=15,z={label:``,className:`bw-glass-action--detach`,onClick:(e,t)=>{if(!t.addDetachedGlass)throw Error(`[bwin] Failed to detach glass from pane`);let n=e.target.closest(`bw-pane`),r=n.querySelector(`bw-glass-content`),i=n.querySelector(`bw-glass-title`),a=t.windowElement.getBoundingClientRect(),o=a.width-R*2,s=a.height-R*2,c=t.addDetachedGlass({position:`center`,width:o,height:s}),l=n.getAttribute(`sash-id`),u=t.rootSash.getById(l),d=u.parent.getChildSiblingById(l).id;c.domNode.bwOriginalSiblingSashId=d,c.domNode.bwOriginalPosition=n.getAttribute(`position`),c.domNode.bwOriginalRelativeSize=u.getRelativeSize(),c.contentElement.replaceWith(r),i&&c.titleElement.replaceWith(i),t.removePane(l)}},B=[L,z,I],V=class{domNode;constructor({title:e=null,content:t=null,tabs:n=[],actions:r=B,draggable:i=!0,sash:a=null,binaryWindow:o}){this.title=e,this.content=t,this.tabs=n,this.actions=r,this.sash=a,this.draggable=i,this.binaryWindow=o,this.build()}build(){let e=document.createElement(`bw-glass-header`);if(Array.isArray(this.tabs)&&this.tabs.length>0)e.append(this.createTabs());else{let t=document.createElement(`bw-glass-title`);this.title&&t.append(g(this.title)),e.append(t)}e.setAttribute(`can-drag`,this.draggable),e.append(this.createActions());let t=document.createElement(`bw-glass-content`),n=g(this.content);n&&t.append(n),this.domNode=document.createElement(`bw-glass`),this.domNode.append(e,t)}createTabs(){let e=document.createElement(`bw-glass-tab-container`);for(let t of this.tabs){let n=g(`<button class="bw-glass-tab">${t?.label??t}</button>`);e.append(n)}return e}createActions(){let e=document.createElement(`bw-glass-action-container`),t=Array.isArray(this.actions)?this.actions:[];for(let n of t){let t=n?.label??n,r=g(`<button class="${n.className?`bw-glass-action ${n.className}`:`bw-glass-action`}">${t}</button>`);typeof n.onClick==`function`&&r.addEventListener(`click`,e=>{n.onClick(e,this.binaryWindow)}),e.append(r)}return e}get contentElement(){return this.domNode.querySelector(`bw-glass-content`)}get headerElement(){return this.domNode.querySelector(`bw-glass-header`)}get titleElement(){return this.domNode.querySelector(`bw-glass-title`)}},Ce=[L,Se,z,I],we={enableGlassFeature(){this.enableGlassActions(),this.enableGlassDrag()},...N,...xe},Te={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)}},H=[`n`,`s`,`e`,`w`,`ne`,`nw`,`se`,`sw`];function Ee(){return H.map(e=>{let t=document.createElement(`bw-glass-resize-handle`);return t.setAttribute(`resize-dir`,e),t})}function De({position:e,offset:t,offsetX:n,offsetY:r,width:i,height:a}){let o=n??t,s=r??t;switch(e){case`top-left`:return{top:`${s}px`,left:`${o}px`,right:`auto`,bottom:`auto`};case`top-right`:return{top:`${s}px`,right:`${o}px`,left:`auto`,bottom:`auto`};case`bottom-left`:return{bottom:`${s}px`,left:`${o}px`,right:`auto`,top:`auto`};case`bottom-right`:return{bottom:`${s}px`,right:`${o}px`,left:`auto`,top:`auto`};case`center`:return{top:`calc(50% - ${a/2}px + ${s}px)`,left:`calc(50% - ${i/2}px + ${o}px)`,right:`auto`,bottom:`auto`};default:throw Error(`Position "${e}" is not supported for detached glass.`)}}var U=new class{constructor(){this.glasses=[],this.topZIndex=1}addGlassByElement(e){this.glasses.push(e)}getActiveGlass(){return this.glasses.find(e=>e.hasAttribute(`active`))??null}bringToFront(e){e.hasAttribute(`active`)||(this.topZIndex+=1,e.style.zIndex=this.topZIndex,e.parentElement?.querySelectorAll(`:scope > bw-glass[detached][active]`).forEach(t=>t!==e&&t.removeAttribute(`active`)),e.setAttribute(`active`,``))}removeGlassById(e){let t=this.glasses.findIndex(t=>t.id===e);if(t!==-1){let[e]=this.glasses.splice(t,1);return e}return null}},W=[{label:``,className:`bw-glass-action--minimize`,onClick:(e,t)=>{let n=t.sillElement;if(!n)throw Error(`[bwin] Sill element not found when minimizing`);let r=g(`<button class="bw-minimized-detached-glass" />`);n.append(r);let i=e.target.closest(`bw-glass[detached]`);if(!i)throw Error(`[bwin] Detached Glass element not found when minimizing`);r.bwDetachedGlassElement=i,i.style.display=`none`}},{label:``,className:`bw-glass-action--attach`,onClick:(e,t)=>{let n=e.target.closest(`bw-glass[detached]`),r=n.bwOriginalPosition,i=n.bwOriginalSiblingSashId,a=n.bwOriginalRelativeSize,o=t.rootSash.getById(i),s=i,c=r,l=a;if(!o){let e=t.rootSash.getLargestLeaf();s=e.id,c=e.width>e.height?`right`:`bottom`,l=.5}let u=n.querySelector(`bw-glass-content`);t.addPane(s,{position:c,size:l,content:ne(u),title:n.querySelector(`bw-glass-title`)?.textContent||``}),t.removeDetachedGlass(n.id)}},{label:``,className:`bw-glass-action--close`,onClick:e=>{let t=e.target.closest(`bw-glass[detached]`);t&&(U.removeGlassById(t.id),t.remove())}}],Oe=class extends V{constructor(e){let{position:t,width:n=222,height:r=222,offset:i=0,offsetX:a,offsetY:o,id:s,actions:c=W,...l}=e;super({...l,actions:c}),this.domNode.setAttribute(`id`,s||d()+`-F`),this.domNode.setAttribute(`detached`,``),this.domNode.style.position=`absolute`,this.domNode.style.width=`${n}px`,this.domNode.style.height=`${r}px`;let{top:u,left:f,right:p,bottom:m}=De({position:t,offset:i,offsetX:a,offsetY:o,width:n,height:r});this.domNode.style.top=u,this.domNode.style.left=f,this.domNode.style.right=p,this.domNode.style.bottom=m}},ke=200,Ae=200,G=25;function je(e,{width:t,height:n}){let r=U.getActiveGlass();if(!r)return{position:`center`};let i=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=a.left-i.left+G,s=a.top-i.top+G;return o+t>i.width&&(o=G),s+n>i.height&&(s=G),{position:`top-left`,offsetX:o,offsetY:s}}var Me={addDetachedGlass(e={}){let t=e.width??ke,n=e.height??Ae,{position:r,offsetX:i,offsetY:a}=e.position?{}:je(this.windowElement,{width:t,height:n}),o=new Oe({actions:this.actions[1],binaryWindow:this,position:r,offsetX:i,offsetY:a,...e,width:t,height:n});return this.windowElement.append(o.domNode),U.addGlassByElement(o.domNode),U.bringToFront(o.domNode),o},removeDetachedGlass(e){let t=U.removeGlassById(e);return t?.remove(),t}},Ne={enableDetachedGlassActivate(){this.windowElement.addEventListener(`pointerdown`,e=>{if(e.button!==0)return;let t=e.target.closest?.(`bw-glass[detached]`);t&&U.bringToFront(t)})}},Pe={enableDetachedGlassMove(){let e=null,t=0,n=0,r=0,i=0;this.windowElement.addEventListener(`pointerdown`,a=>{if(a.button!==0)return;let o=a.target.closest(`bw-glass-header`);if(!o||a.target.closest(`button`)||o.getAttribute(`can-drag`)===`false`)return;let s=o.closest(`bw-glass[detached]`);if(!s)return;a.preventDefault(),o.setPointerCapture(a.pointerId),e=s,t=a.pageX,n=a.pageY;let c=this.windowElement.getBoundingClientRect(),l=s.getBoundingClientRect();r=l.left-c.left,i=l.top-c.top}),this.windowElement.addEventListener(`pointermove`,a=>{if(!e)return;let o=r+(a.pageX-t),s=i+(a.pageY-n);e.style.right=`auto`,e.style.bottom=`auto`,e.style.left=`${o}px`,e.style.top=`${s}px`}),this.windowElement.addEventListener(`pointerup`,t=>{e&&=(t.target.hasPointerCapture?.(t.pointerId)&&t.target.releasePointerCapture(t.pointerId),null)})}},K=null,q=0,J=0,Fe={enableDetachedGlassDrag(){document.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`bw-glass-header`);if(!t||e.target.closest(`button`)||t.getAttribute(`can-drag`)===`false`)return;let n=t.closest(`bw-glass[detached]`);n&&(n.setAttribute(`draggable`,!0),K=n)}),document.addEventListener(`mouseup`,()=>{K&&=(K.removeAttribute(`draggable`),null)}),this.windowElement.addEventListener(`dragstart`,e=>{if(!K)return;e.dataTransfer.effectAllowed=`move`;let t=K.getBoundingClientRect();q=e.clientX-t.left,J=e.clientY-t.top}),this.windowElement.addEventListener(`dragend`,e=>{if(!K)return;let t=this.windowElement.getBoundingClientRect(),n=e.clientX-t.left-q,r=e.clientY-t.top-J;K.style.right=`auto`,K.style.bottom=`auto`,K.style.left=`${n}px`,K.style.top=`${r}px`,K.removeAttribute(`draggable`),K=null})}},Y=100,X=60;function Ie(e){return!!e.querySelector(`:scope > bw-glass-resize-handle`)}function Le(e){Ie(e)||e.append(...Ee())}function Z(e){e.querySelectorAll(`:scope > bw-glass-resize-handle`).forEach(e=>e.remove())}var Re={enableDetachedGlassResize(){let e=null,t=``,n=0,r=0,i=null;this.windowElement.addEventListener(`pointerover`,e=>{let t=e.target.closest?.(`bw-glass[detached]`);t&&Le(t)}),this.windowElement.addEventListener(`pointerout`,t=>{let n=t.target.closest?.(`bw-glass[detached]`);n&&t.relatedTarget?.closest?.(`bw-glass[detached]`)!==n&&n!==e&&Z(n)}),this.windowElement.addEventListener(`pointerdown`,a=>{if(a.button!==0||a.target.tagName!==`BW-GLASS-RESIZE-HANDLE`)return;let o=a.target.closest(`bw-glass[detached]`);if(!o)return;a.preventDefault(),a.target.setPointerCapture(a.pointerId),e=o,t=a.target.getAttribute(`resize-dir`),n=a.pageX,r=a.pageY;let s=this.windowElement.getBoundingClientRect(),c=o.getBoundingClientRect();i={left:c.left-s.left,top:c.top-s.top,width:c.width,height:c.height}}),this.windowElement.addEventListener(`pointermove`,a=>{if(!e)return;let o=t,s=a.pageX-n,c=a.pageY-r,l=i,{left:u,top:d,width:f,height:p}=l;o.includes(`e`)?f=Math.max(Y,l.width+s):o.includes(`w`)&&(f=Math.max(Y,l.width-s),u=l.left+(l.width-f)),o.includes(`s`)?p=Math.max(X,l.height+c):o.includes(`n`)&&(p=Math.max(X,l.height-c),d=l.top+(l.height-p)),e.style.right=`auto`,e.style.bottom=`auto`,e.style.left=`${u}px`,e.style.top=`${d}px`,e.style.width=`${f}px`,e.style.height=`${p}px`}),this.windowElement.addEventListener(`pointerup`,n=>{if(!e)return;n.target.hasPointerCapture?.(n.pointerId)&&n.target.releasePointerCapture(n.pointerId);let r=e;e=null,t=``,i=null,r.matches(`:hover`)||Z(r)})}},ze={handleMinimizedDetachedGlassClick(){this.sillElement.addEventListener(`click`,e=>{let t=e.target;if(!t.matches(`.bw-minimized-detached-glass`))return;let n=t.bwDetachedGlassElement;n&&(n.style.display=``,t.remove(),U.bringToFront(n))})}},Be={enableDetachedGlassFeatures(){this.enableDetachedGlassActivate(),this.enableDetachedGlassResize(),this.enableDetachedGlassMove(),this.handleMinimizedDetachedGlassClick()},...Me,...Ne,...Pe,...Fe,...Re,...ze},Q=class e extends j{sillElement=null;constructor(t){super(t),this.theme=t.theme||``,this.actions=e.normActions(t.actions)}frame(){super.frame(...arguments);let e=g(`<bw-sill />`);this.windowElement.append(e),this.sillElement=e}enableFeatures(){super.enableFeatures(),this.enableGlassFeature(),this.enableDetachedGlassFeatures()}onPaneCreate(e,t){let n=this.actions[0],r=new V({actions:n,...t.store,sash:t,binaryWindow:this});e.innerHTML=``,e.append(r.domNode),this.debug&&r.contentElement.prepend(`${t.id}`)}onPaneUpdate(){}addPane(e,t){let{position:n,size:r,id:i,...a}=t,o=super.addPane(e,{position:n,size:r,id:i}),s=new V({...a,sash:o,binaryWindow:this});return o.domNode.append(s.domNode),o}setTheme(e){if(!e){this.theme=``,this.windowElement.removeAttribute(`theme`);return}this.theme=e,this.windowElement.setAttribute(`theme`,e)}removePane(e){if(this.windowElement.querySelector(`[sash-id="${e}"]`)){super.removePane(e);return}let t=this.getMinimizedGlassElementBySashId(e);t&&t.remove()}static normActions(e){if(e===void 0)return[B,W];if(!e||!Array.isArray(e)||e.length===0)return[[],[]];if(e.length===1&&Array.isArray(e[0]))return[e[0],W];if(!e.some(Array.isArray))return[e,W];if(e.length>=2&&!Array.isArray(e[0])&&Array.isArray(e[1]))return[[],e[1]];if(e.length>=2&&Array.isArray(e[0])&&!Array.isArray(e[1]))return[e[0],[]];if(e.length>=2&&Array.isArray(e[0])&&Array.isArray(e[1]))return e;throw Error(`[bwin] Invalid actions format`)}};Q.assemble(we,Be,Te);var $=4;function Ve({sash:e}){let n=(0,t.useRef)(),r=e.leftChild,i=e.topChild,a,o,s,c,l,u;return r?(a=$,o=e.height-$,s=e.top+$/2,c=e.left+r.width-$/2,l=!0):i&&(a=e.width-$,o=$,s=e.top+i.height-$/2,c=e.left+$/2,u=!0),(0,t.useEffect)(()=>{e.domNode=n.current},[]),t.default.createElement(`bw-muntin`,{"sash-id":e.id,style:{width:a,height:o,top:s,left:c},vertical:l,horizontal:u,resizable:e.store?.resizable===!1?`false`:`true`,ref:n})}function He({sash:e,bwin:n}){let r=(0,t.useRef)(),{left:i,top:a,width:o,height:s,id:c,position:l}=e;(0,t.useEffect)(()=>{e.domNode=r.current},[]);let u=e.store?.actions===void 0?n.actions[0]:Array.isArray(e.store.actions)?e.store.actions:[];return t.default.createElement(`bw-pane`,{"sash-id":c,position:l,style:{left:i,top:a,width:o,height:s},"can-drop":e.store?.droppable===!1?`false`:`true`,ref:r},t.default.createElement(`bw-glass`,null,t.default.createElement(`bw-glass-header`,{"can-drag":e.store?.draggable===!1?`false`:`true`},t.default.createElement(`bw-glass-title`,null,e.store?.title),u.length>0&&t.default.createElement(`bw-glass-action-container`,null,u.map((e,r)=>{let i=e.className?`bw-glass-action ${e.className}`:`bw-glass-action`;return t.default.createElement(`button`,{className:i,key:r,onClick:t=>e.onClick(t,n)},e.label)}))),t.default.createElement(`bw-glass-content`,null,e.store?.content)))}var Ue=(0,t.forwardRef)((e,r)=>{let i=(0,t.useRef)(),a=(0,t.useRef)(),[o,s]=(0,t.useState)(),{panes:c,...l}=e,u=new Q({...l,children:c}),d=[],f=[];u.rootSash.walk(e=>{e.children.length>0?d.push(e):f.push(e)}),(0,t.useEffect)(()=>{let e=i.current;e?.parentElement&&(u.windowElement=e,u.containerElement=e.parentElement,u.sillElement=a.current,u.enableFeatures())},[]),(0,t.useImperativeHandle)(r,()=>({fit:u.fit.bind(u),removePane:u.removePane.bind(u),setTheme:u.setTheme.bind(u),addPane:h}),[]);let p=t.default.createElement(`bw-window`,{"root-sash-id":u.rootSash.id,theme:u.theme||void 0,style:{width:u.rootSash.width,height:u.rootSash.height},ref:i},f.map(e=>t.default.createElement(He,{key:e.id,sash:e,bwin:u})),d.map(e=>t.default.createElement(Ve,{key:e.id,sash:e})),t.default.createElement(`bw-sill`,{ref:a})),m=(0,t.useMemo)(()=>p,[]);function h(e,t){let{content:n,...r}=t,i=u.addPane(e,r),a=document.querySelector(`bw-pane[sash-id="${i.id}"] bw-glass-content`);s(e=>[...e||[],{node:n,container:a}])}return t.default.createElement(t.default.Fragment,null,m,o?.map(e=>(0,n.createPortal)(e.node,e.container)))});e.BUILTIN_ACTIONS=Ce,e.DEFAULT_DETACHED_GLASS_ACTIONS=W,e.DEFAULT_GLASS_ACTIONS=B,e.Window=Ue,e.version=`0.4.1`});
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.4.0",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -41,7 +41,7 @@
41
41
  "@types/react": "^16.14.62",
42
42
  "@types/react-dom": "^16.9.24",
43
43
  "@vitejs/plugin-react": "^6.0.2",
44
- "bwin": "0.4.1",
44
+ "bwin": "0.4.2",
45
45
  "picocolors": "^1.1.1",
46
46
  "prettier": "^3.4.1",
47
47
  "react": "^16.14.0",