@netless/window-manager 1.0.0-canary.3 → 1.0.0-canary.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -19,11 +19,11 @@ var __spreadValues = (a2, b2) => {
19
19
  var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
20
  import pRetry from "p-retry";
21
21
  import Emittery from "emittery";
22
- import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber, pick, throttle, delay, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
22
+ import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber, throttle, delay, pick, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
23
23
  import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin, ViewMode } from "white-web-sdk";
24
24
  import { v4 } from "uuid";
25
25
  import { genUID, SideEffectManager } from "side-effect-manager";
26
- import { Val, ValManager, combine, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
26
+ import { Val, combine, ValManager, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
27
27
  import { ResizeObserver as ResizeObserver$2 } from "@juggle/resize-observer";
28
28
  import p$1 from "video.js";
29
29
  var Events = /* @__PURE__ */ ((Events2) => {
@@ -355,6 +355,11 @@ const setViewFocusScenePath = (view, focusScenePath) => {
355
355
  return view;
356
356
  }
357
357
  };
358
+ const releaseView = (view) => {
359
+ if (!view.didRelease) {
360
+ view.release();
361
+ }
362
+ };
358
363
  const setScenePath = (room, scenePath) => {
359
364
  if (room && room.isWritable) {
360
365
  if (room.state.sceneState.scenePath !== scenePath) {
@@ -944,9 +949,15 @@ class WhiteBoardView {
944
949
  pageState$.setValue(pageState);
945
950
  });
946
951
  }
952
+ get view() {
953
+ return this.appContext.view;
954
+ }
947
955
  get pageState() {
948
956
  return this.pageState$.value;
949
957
  }
958
+ moveCamera(camera) {
959
+ this.appProxy.moveCamera(camera);
960
+ }
950
961
  destroy() {
951
962
  this.removeViewWrapper();
952
963
  }
@@ -1186,6 +1197,135 @@ class AppPageStateImpl {
1186
1197
  (_a = this.sceneNode) == null ? void 0 : _a.dispose();
1187
1198
  }
1188
1199
  }
1200
+ class CameraSynchronizer {
1201
+ constructor(saveCamera) {
1202
+ this.saveCamera = saveCamera;
1203
+ this.onRemoteUpdate = throttle((camera, size2) => {
1204
+ this.remoteCamera = camera;
1205
+ this.remoteSize = size2;
1206
+ if (this.remoteSize && this.rect) {
1207
+ let scale2;
1208
+ if (size2.width < size2.height) {
1209
+ scale2 = this.rect.width / size2.width;
1210
+ } else {
1211
+ scale2 = this.rect.height / size2.height;
1212
+ }
1213
+ const nextScale = camera.scale * scale2;
1214
+ const moveCamera = () => {
1215
+ var _a;
1216
+ return (_a = this.view) == null ? void 0 : _a.moveCamera({
1217
+ centerX: camera.centerX,
1218
+ centerY: camera.centerY,
1219
+ scale: nextScale,
1220
+ animationMode: AnimationMode.Immediately
1221
+ });
1222
+ };
1223
+ delay(moveCamera, 50);
1224
+ }
1225
+ }, 50);
1226
+ this.onLocalSizeUpdate = (size2) => {
1227
+ if (this.rect && this.view) {
1228
+ let scale2;
1229
+ if (size2.width < size2.height) {
1230
+ scale2 = this.rect.width / size2.width;
1231
+ } else {
1232
+ scale2 = this.rect.height / size2.height;
1233
+ }
1234
+ const nextScale = this.view.camera.scale / scale2;
1235
+ console.log("onLocalSizeUpdate", nextScale.toFixed(3), scale2.toFixed(3));
1236
+ this.view.moveCamera({
1237
+ scale: nextScale,
1238
+ animationMode: AnimationMode.Immediately
1239
+ });
1240
+ }
1241
+ };
1242
+ }
1243
+ setRect(rect) {
1244
+ this.rect = rect;
1245
+ if (this.remoteCamera && this.remoteSize) {
1246
+ this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
1247
+ }
1248
+ }
1249
+ setView(view) {
1250
+ this.view = view;
1251
+ }
1252
+ onLocalCameraUpdate(camera) {
1253
+ this.saveCamera(camera);
1254
+ this.remoteCamera = camera;
1255
+ }
1256
+ }
1257
+ class AppViewSync {
1258
+ constructor(appProxy) {
1259
+ this.appProxy = appProxy;
1260
+ this.sem = new SideEffectManager();
1261
+ this.bindView = (view) => {
1262
+ if (!view)
1263
+ return;
1264
+ this.synchronizer.setView(view);
1265
+ this.sem.add(() => {
1266
+ view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1267
+ return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1268
+ });
1269
+ };
1270
+ this.onCameraUpdatedByDevice = (camera) => {
1271
+ var _a;
1272
+ this.synchronizer.onLocalCameraUpdate(camera);
1273
+ const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
1274
+ if (stage) {
1275
+ const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
1276
+ if (!isEqual(size2, this.appProxy.size$.value)) {
1277
+ this.appProxy.storeSize(size2);
1278
+ }
1279
+ }
1280
+ };
1281
+ this.synchronizer = new CameraSynchronizer((camera) => {
1282
+ this.appProxy.storeCamera(__spreadValues({
1283
+ id: this.appProxy.uid
1284
+ }, camera));
1285
+ });
1286
+ this.bindView(appProxy.view);
1287
+ this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
1288
+ const size2 = this.appProxy.size$.value;
1289
+ if (camera && size2) {
1290
+ this.synchronizer.onRemoteUpdate(camera, size2);
1291
+ }
1292
+ }));
1293
+ const box = this.appProxy.box;
1294
+ if (box && box.contentStageRect) {
1295
+ this.synchronizer.setRect(box.contentStageRect);
1296
+ this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
1297
+ if (rect) {
1298
+ this.synchronizer.setRect(rect);
1299
+ }
1300
+ }));
1301
+ if (!this.appProxy.size$.value) {
1302
+ this.appProxy.storeSize({
1303
+ id: this.appProxy.uid,
1304
+ width: box.contentStageRect.width,
1305
+ height: box.contentStageRect.height
1306
+ });
1307
+ }
1308
+ }
1309
+ }
1310
+ destroy() {
1311
+ this.sem.flushAll();
1312
+ }
1313
+ }
1314
+ const boxEmitter = new Emittery();
1315
+ const calculateNextIndex = (index2, pageState) => {
1316
+ let nextIndex = 0;
1317
+ const maxIndex = pageState.length - 1;
1318
+ if (index2 === pageState.index) {
1319
+ if (index2 === maxIndex) {
1320
+ nextIndex = index2 - 1;
1321
+ } else {
1322
+ nextIndex = pageState.index + 1;
1323
+ }
1324
+ } else {
1325
+ nextIndex = pageState.index;
1326
+ }
1327
+ return nextIndex;
1328
+ };
1189
1329
  var Fields = /* @__PURE__ */ ((Fields2) => {
1190
1330
  Fields2["Apps"] = "apps";
1191
1331
  Fields2["Focus"] = "focus";
@@ -1199,6 +1339,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
1199
1339
  Fields2["CursorState"] = "cursorState";
1200
1340
  Fields2["FullPath"] = "fullPath";
1201
1341
  Fields2["Registered"] = "registered";
1342
+ Fields2["Camera"] = "camera";
1343
+ Fields2["Size"] = "size";
1202
1344
  return Fields2;
1203
1345
  })(Fields || {});
1204
1346
  class AttributesDelegate {
@@ -1263,6 +1405,9 @@ class AttributesDelegate {
1263
1405
  this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
1264
1406
  }
1265
1407
  }
1408
+ updateAppAttributes(appId, key, value) {
1409
+ this.context.safeUpdateAttributes(["apps", appId, key], value);
1410
+ }
1266
1411
  cleanAppAttributes(id2) {
1267
1412
  this.context.safeUpdateAttributes(["apps", id2], void 0);
1268
1413
  this.context.safeSetAttributes({ [id2]: void 0 });
@@ -1359,21 +1504,6 @@ const log = (...args) => {
1359
1504
  console.log(`[WindowManager]:`, ...args);
1360
1505
  }
1361
1506
  };
1362
- const calculateNextIndex = (index2, pageState) => {
1363
- let nextIndex = 0;
1364
- const maxIndex = pageState.length - 1;
1365
- if (index2 === pageState.index) {
1366
- if (index2 === maxIndex) {
1367
- nextIndex = index2 - 1;
1368
- } else {
1369
- nextIndex = pageState.index + 1;
1370
- }
1371
- } else {
1372
- nextIndex = pageState.index;
1373
- }
1374
- return nextIndex;
1375
- };
1376
- const boxEmitter = new Emittery();
1377
1507
  class AppProxy {
1378
1508
  constructor(params, manager, appId, isAddApp) {
1379
1509
  var _a;
@@ -1383,8 +1513,13 @@ class AppProxy {
1383
1513
  this.appProxies = this.manager.appProxies;
1384
1514
  this.viewManager = this.manager.viewManager;
1385
1515
  this.store = this.manager.store;
1516
+ this.uid = this.manager.uid;
1386
1517
  this.status = "normal";
1387
1518
  this.sideEffectManager = new SideEffectManager();
1519
+ this.camera$ = new Val(void 0);
1520
+ this.size$ = new Val(void 0);
1521
+ this.box$ = new Val(void 0);
1522
+ this.view$ = new Val(void 0);
1388
1523
  this.getAppInitState = (id2) => {
1389
1524
  var _a2, _b;
1390
1525
  const attrs = this.store.getAppState(id2);
@@ -1454,6 +1589,19 @@ class AppProxy {
1454
1589
  this.appEmitter.emit("pageStateChange", this.pageState);
1455
1590
  }
1456
1591
  }, 50);
1592
+ this.storeCamera = (camera) => {
1593
+ this.store.updateAppAttributes(this.id, Fields.Camera, camera);
1594
+ };
1595
+ this.storeSize = (size2) => {
1596
+ this.store.updateAppAttributes(this.id, Fields.Size, size2);
1597
+ };
1598
+ this.moveCamera = (camera) => {
1599
+ if (!this.camera$.value) {
1600
+ return;
1601
+ }
1602
+ const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
1603
+ this.storeCamera(nextCamera);
1604
+ };
1457
1605
  this.kind = params.kind;
1458
1606
  this.id = appId;
1459
1607
  this.appScenePath = `/${this.id}-app-dir`;
@@ -1475,14 +1623,43 @@ class AppProxy {
1475
1623
  view: this.view,
1476
1624
  notifyPageStateChange: this.notifyPageStateChange
1477
1625
  });
1626
+ this.sideEffectManager.add(() => () => this._pageState.destroy());
1627
+ this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
1628
+ this.appEmitter.emit("roomMembersChange", members);
1629
+ }));
1630
+ this.camera$.setValue(toJS(this.appAttributes.camera));
1631
+ this.size$.setValue(toJS(this.appAttributes.size));
1478
1632
  this.sideEffectManager.add(() => {
1479
- return () => this._pageState.destroy();
1633
+ return this.manager.refresher.add(`${this.id}-camera`, () => {
1634
+ return reaction(() => {
1635
+ var _a2;
1636
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1637
+ }, (camera) => {
1638
+ if (camera && camera.id !== this.uid) {
1639
+ this.camera$.setValue(toJS(camera));
1640
+ }
1641
+ });
1642
+ });
1480
1643
  });
1481
1644
  this.sideEffectManager.add(() => {
1482
- return emitter.on("roomMembersChange", (members) => {
1483
- this.appEmitter.emit("roomMembersChange", members);
1645
+ return this.manager.refresher.add(`${this.id}-size`, () => {
1646
+ return reaction(() => {
1647
+ var _a2;
1648
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1649
+ }, (size2) => {
1650
+ if (size2 && size2.id !== this.uid) {
1651
+ this.size$.setValue(toJS(size2));
1652
+ }
1653
+ });
1484
1654
  });
1485
1655
  });
1656
+ combine([this.box$, this.view$]).subscribe(([box, view]) => {
1657
+ if (box && view) {
1658
+ const appViewSync = new AppViewSync(this);
1659
+ this.appViewSync = appViewSync;
1660
+ this.sideEffectManager.add(() => () => appViewSync.destroy());
1661
+ }
1662
+ });
1486
1663
  }
1487
1664
  createAppDir() {
1488
1665
  const scenePath = this.scenePath || this.appScenePath;
@@ -1540,7 +1717,7 @@ class AppProxy {
1540
1717
  return fullPath;
1541
1718
  }
1542
1719
  setFullPath(path) {
1543
- this.manager.safeUpdateAttributes(["apps", this.id, Fields.FullPath], path);
1720
+ this.store.updateAppAttributes(this.id, Fields.FullPath, path);
1544
1721
  }
1545
1722
  async baseInsertApp(skipUpdate = false) {
1546
1723
  var _a;
@@ -1562,8 +1739,7 @@ class AppProxy {
1562
1739
  };
1563
1740
  }
1564
1741
  get box() {
1565
- var _a;
1566
- return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
1742
+ return this.box$.value;
1567
1743
  }
1568
1744
  async setupApp(appId, skipUpdate, app, options, appOptions) {
1569
1745
  var _a;
@@ -1591,13 +1767,14 @@ class AppProxy {
1591
1767
  this.fixMobileSize();
1592
1768
  }, SETUP_APP_DELAY);
1593
1769
  });
1594
- (_a = this.boxManager) == null ? void 0 : _a.createBox({
1770
+ const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
1595
1771
  appId,
1596
1772
  app,
1597
1773
  options,
1598
1774
  canOperate: this.manager.canOperate,
1599
1775
  smartPosition: this.isAddApp
1600
1776
  });
1777
+ this.box$.setValue(box);
1601
1778
  if (this.isAddApp && this.box) {
1602
1779
  this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
1603
1780
  this.boxManager.focusBox({ appId }, false);
@@ -1726,6 +1903,7 @@ class AppProxy {
1726
1903
  }
1727
1904
  createView() {
1728
1905
  const view = this.viewManager.createView(this.id);
1906
+ this.view$.setValue(view);
1729
1907
  this.setViewFocusScenePath();
1730
1908
  return view;
1731
1909
  }
@@ -1776,6 +1954,7 @@ class AppProxy {
1776
1954
  console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
1777
1955
  }
1778
1956
  this.appEmitter.clearListeners();
1957
+ this.sideEffectManager.flushAll();
1779
1958
  emitter.emit(`destroy-${this.id}`, { error });
1780
1959
  if (needCloseBox) {
1781
1960
  (_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
@@ -1793,7 +1972,9 @@ class AppProxy {
1793
1972
  (_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
1794
1973
  (_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
1795
1974
  this._prevFullPath = void 0;
1796
- this.sideEffectManager.flushAll();
1975
+ this.camera$.destroy();
1976
+ this.size$.destroy();
1977
+ this.box$.destroy();
1797
1978
  }
1798
1979
  close() {
1799
1980
  return this.destroy(true, true, false);
@@ -1849,56 +2030,6 @@ const setDefaultCameraBound = (view) => {
1849
2030
  minContentMode: () => 0.1
1850
2031
  });
1851
2032
  };
1852
- class CameraSynchronizer {
1853
- constructor(saveCamera) {
1854
- this.saveCamera = saveCamera;
1855
- this.onRemoteUpdate = throttle((camera, size2) => {
1856
- this.remoteCamera = camera;
1857
- this.remoteSize = size2;
1858
- if (this.remoteSize && this.rect) {
1859
- let scale2;
1860
- if (size2.width < size2.height) {
1861
- scale2 = this.rect.width / size2.width;
1862
- } else {
1863
- scale2 = this.rect.height / size2.height;
1864
- }
1865
- const nextScale = camera.scale * scale2;
1866
- const moveCamera = () => {
1867
- var _a;
1868
- return (_a = this.view) == null ? void 0 : _a.moveCamera({
1869
- centerX: camera.centerX,
1870
- centerY: camera.centerY,
1871
- scale: nextScale,
1872
- animationMode: AnimationMode.Immediately
1873
- });
1874
- };
1875
- delay(moveCamera, 10);
1876
- }
1877
- }, 50);
1878
- }
1879
- setRect(rect) {
1880
- this.rect = rect;
1881
- if (this.remoteCamera && this.remoteSize) {
1882
- this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
1883
- }
1884
- }
1885
- setView(view) {
1886
- this.view = view;
1887
- }
1888
- onLocalCameraUpdate(camera) {
1889
- this.saveCamera(camera);
1890
- }
1891
- onLocalSizeUpdate(size2) {
1892
- if (this.rect && this.view) {
1893
- const scale2 = this.rect.width / size2.width;
1894
- const nextScale = this.view.camera.scale * scale2;
1895
- this.view.moveCamera({
1896
- scale: nextScale,
1897
- animationMode: AnimationMode.Immediately
1898
- });
1899
- }
1900
- }
1901
- }
1902
2033
  class MainViewProxy {
1903
2034
  constructor(manager) {
1904
2035
  var _a;
@@ -1928,9 +2059,6 @@ class MainViewProxy {
1928
2059
  }, { fireImmediately: true });
1929
2060
  };
1930
2061
  this.sizeChangeHandler = debounce((size2) => {
1931
- if (size2) {
1932
- this.synchronizer.onLocalSizeUpdate(size2);
1933
- }
1934
2062
  }, 30);
1935
2063
  this.onUpdateContainerSizeRatio = () => {
1936
2064
  const size2 = this.store.getMainViewSize();
@@ -1969,9 +2097,7 @@ class MainViewProxy {
1969
2097
  });
1970
2098
  this.sideEffectManager.add(() => {
1971
2099
  return emitter.on("startReconnect", () => {
1972
- if (!this.mainView.didRelease) {
1973
- this.mainView.release();
1974
- }
2100
+ releaseView(this.mainView);
1975
2101
  });
1976
2102
  });
1977
2103
  const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
@@ -1981,7 +2107,6 @@ class MainViewProxy {
1981
2107
  this.sideEffectManager.add(() => {
1982
2108
  return emitter.on("playgroundSizeChange", (rect2) => {
1983
2109
  this.synchronizer.setRect(rect2);
1984
- this.synchronizer.onLocalSizeUpdate(rect2);
1985
2110
  });
1986
2111
  });
1987
2112
  }
@@ -2051,9 +2176,7 @@ class MainViewProxy {
2051
2176
  const divElement = this.mainView.divElement;
2052
2177
  const disableCameraTransform = this.mainView.disableCameraTransform;
2053
2178
  this.stop();
2054
- if (!this.didRelease) {
2055
- this.mainView.release();
2056
- }
2179
+ releaseView(this.mainView);
2057
2180
  this.removeMainViewListener();
2058
2181
  this.mainView = this.createMainView();
2059
2182
  this.mainView.disableCameraTransform = disableCameraTransform;
@@ -3701,16 +3824,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
3701
3824
  }
3702
3825
  return true;
3703
3826
  };
3704
- var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty, o$2 = Object.prototype.propertyIsEnumerable, r$4 = (t2, i2, s2) => i2 in t2 ? e$2(t2, i2, { enumerable: true, configurable: true, writable: true, value: s2 }) : t2[i2] = s2, n$3 = (e2, t2) => {
3827
+ var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty, n$3 = Object.prototype.propertyIsEnumerable, o$2 = (t2, i2, s2) => i2 in t2 ? e$2(t2, i2, { enumerable: true, configurable: true, writable: true, value: s2 }) : t2[i2] = s2, r$4 = (e2, t2) => {
3705
3828
  for (var i2 in t2 || (t2 = {}))
3706
- a$1.call(t2, i2) && r$4(e2, i2, t2[i2]);
3829
+ a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
3707
3830
  if (s$2)
3708
3831
  for (var i2 of s$2(t2))
3709
- o$2.call(t2, i2) && r$4(e2, i2, t2[i2]);
3832
+ n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
3710
3833
  return e2;
3711
3834
  };
3712
- var v$3, w$2, C$3, y$2, E$3, z$2, B$2, _, N$3, M$3;
3713
- (w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (_ = B$2 || (B$2 = {})).Close = "close", _.Maximize = "maximize", _.Minimize = "minimize", (M$3 = N$3 || (N$3 = {})).North = "n", M$3.South = "s", M$3.West = "w", M$3.East = "e", M$3.NorthWest = "nw", M$3.NorthEast = "ne", M$3.SouthEast = "se", M$3.SouthWest = "sw";
3835
+ var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
3836
+ (w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (B$2 = _ || (_ = {})).Close = "close", B$2.Maximize = "maximize", B$2.Minimize = "minimize", (S$3 = N$3 || (N$3 = {})).North = "n", S$3.South = "s", S$3.West = "w", S$3.East = "e", S$3.NorthWest = "nw", S$3.NorthEast = "ne", S$3.SouthEast = "se", S$3.SouthWest = "sw";
3714
3837
  function I$3(e2, t2, i2) {
3715
3838
  return Math.min(Math.max(e2, t2), i2);
3716
3839
  }
@@ -3731,7 +3854,7 @@ function V$3(e2) {
3731
3854
  return !e2;
3732
3855
  }
3733
3856
  class H$3 {
3734
- constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: o2, namespace: r2 = "telebox" }) {
3857
+ constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
3735
3858
  this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
3736
3859
  var t3;
3737
3860
  if (this.readonly$.value)
@@ -3742,7 +3865,7 @@ class H$3 {
3742
3865
  return;
3743
3866
  k$1(e3);
3744
3867
  const i3 = Date.now();
3745
- i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type: B$2.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarClick.timestamp = i3, this.lastTitleBarClick.clientX = e3.clientX, this.lastTitleBarClick.clientY = e3.clientY;
3868
+ i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarClick.timestamp = i3, this.lastTitleBarClick.clientX = e3.clientX, this.lastTitleBarClick.clientY = e3.clientY;
3746
3869
  }, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
3747
3870
  var t3;
3748
3871
  if (this.readonly$.value)
@@ -3751,8 +3874,8 @@ class H$3 {
3751
3874
  return;
3752
3875
  k$1(e3);
3753
3876
  const i3 = Date.now(), { clientX: s3 = this.lastTitleBarTouch.clientX + 100, clientY: a3 = this.lastTitleBarTouch.clientY + 100 } = e3.touches[0] || {};
3754
- i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type: B$2.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarTouch.timestamp = i3, this.lastTitleBarTouch.clientX = s3, this.lastTitleBarTouch.clientY = a3;
3755
- }, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart = o2, this.namespace = r2, this.buttons = s2 || [{ type: B$2.Minimize, iconClassName: this.wrapClassName("titlebar-icon-minimize") }, { type: B$2.Maximize, iconClassName: this.wrapClassName("titlebar-icon-maximize"), isActive: (e3) => e3 === C$3.Maximized }, { type: B$2.Close, iconClassName: this.wrapClassName("titlebar-icon-close") }], this.$dragArea = this.renderDragArea();
3877
+ i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarTouch.timestamp = i3, this.lastTitleBarTouch.clientX = s3, this.lastTitleBarTouch.clientY = a3;
3878
+ }, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart = n2, this.namespace = o2, this.buttons = s2 || [{ type: _.Minimize, iconClassName: this.wrapClassName("titlebar-icon-minimize") }, { type: _.Maximize, iconClassName: this.wrapClassName("titlebar-icon-maximize"), isActive: (e3) => e3 === C$3.Maximized }, { type: _.Close, iconClassName: this.wrapClassName("titlebar-icon-close") }], this.$dragArea = this.renderDragArea();
3756
3879
  }
3757
3880
  render() {
3758
3881
  if (!this.$titleBar) {
@@ -3828,13 +3951,13 @@ class A$2 {
3828
3951
  i2.className = this.wrapClassName("box-stage-mask");
3829
3952
  const s2 = document.createElement("div");
3830
3953
  s2.className = this.wrapClassName("box-stage-frame");
3831
- const [a2, o2, r2, n2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
3954
+ const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
3832
3955
  const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3833
3956
  i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
3834
3957
  const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
3835
3958
  return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
3836
3959
  });
3837
- return s2.appendChild(a2), s2.appendChild(r2), s2.appendChild(o2), s2.appendChild(n2), e2.appendChild(t2), e2.appendChild(s2), e2.appendChild(i2), this._sideEffect.addDisposer(this.highlightStage$.subscribe((t3) => {
3960
+ return s2.appendChild(a2), s2.appendChild(o2), s2.appendChild(n2), s2.appendChild(r2), e2.appendChild(t2), e2.appendChild(s2), e2.appendChild(i2), this._sideEffect.addDisposer(this.highlightStage$.subscribe((t3) => {
3838
3961
  e2.classList.toggle("is-active", t3);
3839
3962
  })), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
3840
3963
  s3 && (a3.x > 0 ? (e2.style.flexDirection = "row", t2.style.width = `${a3.x}px`, t2.style.height = "", i2.style.width = `${a3.x}px`, i2.style.height = "") : a3.y > 0 && (e2.style.flexDirection = "column", t2.style.width = "", t2.style.height = `${a3.y}px`, i2.style.width = "", i2.style.height = `${a3.y}px`));
@@ -3849,40 +3972,40 @@ class A$2 {
3849
3972
  }
3850
3973
  const W$3 = window.ResizeObserver || ResizeObserver$2;
3851
3974
  class Y$3 {
3852
- constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height: o2 = 0.5, minWidth: r2 = 0, minHeight: n2 = 0, x: l2 = 0.1, y: $ = 0.1, resizable: b2 = true, draggable: v2 = true, ratio: w2 = -1, focus: y2 = false, zIndex: z2 = 100, titleBar: B2, content: _2, footer: N2, styles: M2, highlightStage: S2 = null, darkMode$: k2, fence$: R2, minimized$: D2, maximized$: T2, readonly$: V2, root$: W2, rootRect$: Y2, managerStageRect$: X2, stageRatio$: P2, collectorRect$: O2, managerHighlightStage$: j2 }) {
3975
+ constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height: n2 = 0.5, minWidth: o2 = 0, minHeight: r2 = 0, x: l2 = 0.1, y: $ = 0.1, resizable: b2 = true, draggable: v2 = true, ratio: w2 = -1, focus: y2 = false, zIndex: z2 = 100, stageRatio: _2 = null, titleBar: B2, content: N2, stage: S2, footer: M2, styles: k2, highlightStage: R2 = null, darkMode$: D2, fence$: T2, minimized$: V2, maximized$: W2, readonly$: Y2, root$: X2, rootRect$: P2, managerStageRect$: O2, managerStageRatio$: j2, collectorRect$: Z2, managerHighlightStage$: F2 }) {
3853
3976
  this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
3854
3977
  var t3;
3855
3978
  return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
3856
3979
  }, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
3857
- const Z2 = new ValManager();
3858
- this._sideEffect.addDisposer(() => Z2.destroy());
3859
- const F2 = new Val(t2), G2 = new Val(s2), J2 = new Val(b2), q2 = new Val(v2), Q2 = new Val(w2), K2 = new Val(z2), U2 = new Val(y2), ee2 = new Val(_2), te2 = new Val(N2), ie2 = new Val(M2), se2 = combine([D2, T2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal), ae2 = new Val({ width: I$3(r2, 0, 1), height: I$3(n2, 0, 1) }, { compare: shallowequal }), oe2 = combine([ae2, X2], ([e3, t3]) => ({ width: e3.width * t3.width, height: e3.height * t3.height }), { compare: shallowequal }), re2 = new Val({ width: a2, height: o2 }, { compare: shallowequal });
3860
- this._sideEffect.addDisposer(ae2.reaction((e3, t3) => {
3861
- re2.setValue({ width: Math.max(a2, e3.width), height: Math.max(o2, e3.height) }, t3);
3980
+ const G2 = new ValManager();
3981
+ this._sideEffect.addDisposer(() => G2.destroy());
3982
+ const J2 = new Val(t2), q2 = new Val(s2), Q2 = new Val(b2), K2 = new Val(v2), U2 = new Val(w2), ee2 = new Val(z2), te2 = new Val(y2), ie2 = new Val(N2), se2 = new Val(S2), ae2 = new Val(M2), ne2 = new Val(k2), oe2 = combine([V2, W2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal), re2 = new Val({ width: I$3(o2, 0, 1), height: I$3(r2, 0, 1) }, { compare: shallowequal }), he2 = combine([re2, O2], ([e3, t3]) => ({ width: e3.width * t3.width, height: e3.height * t3.height }), { compare: shallowequal }), le2 = new Val({ width: a2, height: n2 }, { compare: shallowequal });
3983
+ this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
3984
+ le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
3862
3985
  }));
3863
- const ne2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), he2 = combine([re2, X2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), le2 = combine([ne2, X2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), de2 = new Val(S2), ce2 = combine([T2, de2, j2], ([e3, t3, i3]) => t3 === null ? i3 && e3 : t3), me2 = new Val(null), ue2 = new Val(Y2.value, { compare: shallowequal }), xe2 = new A$2({ namespace: i2, root$: me2, rootRect$: ue2, ratio$: P2, highlightStage$: ce2 });
3864
- this._sideEffect.addDisposer(() => xe2.destroy());
3865
- withReadonlyValueEnhancer(this, { darkMode: k2, fence: R2, minimized: D2, maximized: T2, readonly: V2, rootRect: Y2, managerStageRect: X2, collectorRect: O2 });
3866
- const ge2 = { zIndex: K2, focus: U2, $userContent: ee2, $userFooter: te2, $userStyles: ie2, state: se2, minSize: ae2, pxMinSize: oe2, intrinsicSize: re2, intrinsicCoord: ne2, pxIntrinsicSize: he2, pxIntrinsicCoord: le2, highlightStage: ce2, boxHighlightStage: de2, contentRect: ue2, contentStageRect: xe2.stageRect$ };
3867
- withReadonlyValueEnhancer(this, ge2, Z2);
3868
- withValueEnhancer(this, { title: F2, visible: G2, resizable: J2, draggable: q2, ratio: Q2 }, Z2), this.titleBar = B2 || new H$3({ readonly$: V2, state$: se2, title$: F2, namespace: this.namespace, onDragStart: (e3) => {
3986
+ const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), xe2 = new Val(null), pe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: xe2, rootRect$: pe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
3987
+ this._sideEffect.addDisposer(() => $e2.destroy());
3988
+ withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
3989
+ const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: pe2, contentStageRect: $e2.stageRect$ };
3990
+ withReadonlyValueEnhancer(this, be2, G2);
3991
+ withValueEnhancer(this, { title: J2, visible: q2, resizable: Q2, draggable: K2, ratio: U2, stageRatio: fe2 }, G2), this.titleBar = B2 || new H$3({ readonly$: Y2, state$: oe2, title$: J2, namespace: this.namespace, onDragStart: (e3) => {
3869
3992
  var t3;
3870
3993
  return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
3871
- }, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(Q2.subscribe((e3) => {
3872
- e3 > 0 && this.transform(le2.value.x, le2.value.y, he2.value.width, he2.value.height, true);
3873
- })), this._sideEffect.addDisposer(R2.subscribe((e3) => {
3874
- e3 && this.move(le2.value.x, le2.value.y, true);
3875
- })), this.$box = this.render(), me2.setValue(this.$content.parentElement);
3876
- const pe2 = (e3, t3) => {
3994
+ }, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
3995
+ e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
3996
+ })), this._sideEffect.addDisposer(T2.subscribe((e3) => {
3997
+ e3 && this.move(me2.value.x, me2.value.y, true);
3998
+ })), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
3999
+ const ve2 = (e3, t3) => {
3877
4000
  this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
3878
4001
  i3 || this.events.emit(t3, e4);
3879
4002
  }));
3880
4003
  };
3881
- pe2(k2, E$3.DarkMode), pe2(V2, E$3.Readonly), pe2(K2, E$3.ZIndex), pe2(D2, E$3.Minimized), pe2(T2, E$3.Maximized), pe2(se2, E$3.State), pe2(re2, E$3.IntrinsicResize), pe2(ne2, E$3.IntrinsicMove), this._sideEffect.addDisposer([G2.reaction((e3, t3) => {
4004
+ ve2(D2, E$3.DarkMode), ve2(Y2, E$3.Readonly), ve2(ee2, E$3.ZIndex), ve2(V2, E$3.Minimized), ve2(W2, E$3.Maximized), ve2(oe2, E$3.State), ve2(le2, E$3.IntrinsicResize), ve2(de2, E$3.IntrinsicMove), this._sideEffect.addDisposer([q2.reaction((e3, t3) => {
3882
4005
  t3 || e3 || this.events.emit(E$3.Close);
3883
- }), U2.reaction((e3, t3) => {
4006
+ }), te2.reaction((e3, t3) => {
3884
4007
  t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
3885
- }), W2.subscribe((e3) => {
4008
+ }), X2.subscribe((e3) => {
3886
4009
  e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
3887
4010
  })]);
3888
4011
  }
@@ -3915,22 +4038,22 @@ class Y$3 {
3915
4038
  }
3916
4039
  move(e2, t2, i2 = false) {
3917
4040
  let s2, a2;
3918
- const o2 = this.managerStageRect, r2 = this.pxIntrinsicSize;
4041
+ const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
3919
4042
  if (this.fence)
3920
- s2 = I$3(e2, o2.x, o2.x + o2.width - r2.width), a2 = I$3(t2, o2.y, o2.y + o2.height - r2.height);
4043
+ s2 = I$3(e2, n2.x, n2.x + n2.width - o2.width), a2 = I$3(t2, n2.y, n2.y + n2.height - o2.height);
3921
4044
  else {
3922
4045
  const i3 = this.rootRect;
3923
- s2 = I$3(e2, i3.x - r2.width + 20, i3.x + i3.width - 20), a2 = I$3(t2, i3.y, i3.y + i3.height - 20);
4046
+ s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
3924
4047
  }
3925
- this._intrinsicCoord$.setValue({ x: (s2 - o2.x) / o2.width, y: (a2 - o2.y) / o2.height }, i2);
4048
+ this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
3926
4049
  }
3927
4050
  transform(e2, t2, i2, s2, a2 = false) {
3928
- const o2 = this.managerStageRect, r2 = this.rootRect;
4051
+ const n2 = this.managerStageRect, o2 = this.rootRect;
3929
4052
  if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
3930
4053
  const e3 = this.ratio * i2;
3931
4054
  t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
3932
4055
  }
3933
- t2 < r2.y && (t2 = r2.y, s2 = this.pxIntrinsicSize.height), this.move(e2, t2, a2), this._intrinsicSize$.setValue({ width: i2 / o2.width, height: s2 / o2.height }, a2);
4056
+ t2 < o2.y && (t2 = o2.y, s2 = this.pxIntrinsicSize.height), this.move(e2, t2, a2), this._intrinsicSize$.setValue({ width: i2 / n2.width, height: s2 / n2.height }, a2);
3934
4057
  }
3935
4058
  mountContent(e2) {
3936
4059
  this._$userContent$.setValue(e2);
@@ -3938,6 +4061,12 @@ class Y$3 {
3938
4061
  unmountContent() {
3939
4062
  this._$userContent$.setValue(void 0);
3940
4063
  }
4064
+ mountStage(e2) {
4065
+ this._$userStage$.setValue(e2);
4066
+ }
4067
+ unmountStage() {
4068
+ this._$userStage$.setValue(void 0);
4069
+ }
3941
4070
  mountFooter(e2) {
3942
4071
  this._$userFooter$.setValue(e2);
3943
4072
  }
@@ -3980,47 +4109,62 @@ class Y$3 {
3980
4109
  this.$box.style.zIndex = String(e3);
3981
4110
  })), this.$box.dataset.teleBoxID = this.id;
3982
4111
  const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
3983
- const o3 = e3 ? { x: 0, y: 0, width: "100%", height: "100%", scaleX: 1, scaleY: 1 } : { x: s3.x, y: s3.y, width: i3.width + "px", height: i3.height + "px", scaleX: 1, scaleY: 1 };
4112
+ const n3 = e3 ? { x: 0, y: 0, width: "100%", height: "100%", scaleX: 1, scaleY: 1 } : { x: s3.x, y: s3.y, width: i3.width + "px", height: i3.height + "px", scaleX: 1, scaleY: 1 };
3984
4113
  if (t3 && a3) {
3985
4114
  const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
3986
- o3.x = a3.x - t4 / 2 + a3.width / 2, o3.y = a3.y - s4 / 2 + a3.height / 2, o3.scaleX = a3.width / t4, o3.scaleY = a3.height / s4;
4115
+ n3.x = a3.x - t4 / 2 + a3.width / 2, n3.y = a3.y - s4 / 2 + a3.height / 2, n3.scaleX = a3.width / t4, n3.scaleY = a3.height / s4;
3987
4116
  }
3988
- return o3;
4117
+ return n3;
3989
4118
  }, { compare: shallowequal }), s2 = i2.value;
3990
4119
  this.$box.style.width = s2.width, this.$box.style.height = s2.height, this.$box.style.transform = `translate(${s2.x - 10}px,${s2.y - 10}px)`, this._sideEffect.addDisposer(i2.subscribe((e3) => {
3991
4120
  t2.set(e3);
3992
4121
  }));
3993
4122
  const a2 = document.createElement("div");
3994
4123
  a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
4124
+ const n2 = document.createElement("div");
4125
+ n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
3995
4126
  const o2 = document.createElement("div");
3996
- o2.className = this.wrapClassName("titlebar-wrap"), o2.appendChild(this.titleBar.render()), this.$titleBar = o2;
4127
+ o2.className = this.wrapClassName("content-wrap");
3997
4128
  const r2 = document.createElement("div");
3998
- r2.className = this.wrapClassName("content-wrap");
3999
- const n2 = document.createElement("div");
4000
- n2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = n2, this._sideEffect.add(() => {
4129
+ r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
4001
4130
  const e3 = new W$3(() => {
4002
- const e4 = n2.getBoundingClientRect();
4131
+ const e4 = r2.getBoundingClientRect();
4003
4132
  this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
4004
4133
  });
4005
- return e3.observe(n2), () => e3.disconnect();
4134
+ return e3.observe(r2), () => e3.disconnect();
4006
4135
  }), this._sideEffect.add(() => {
4007
4136
  let e3;
4008
4137
  return this._$userStyles$.subscribe((t3) => {
4009
- e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
4138
+ e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
4010
4139
  });
4011
4140
  }), this._sideEffect.add(() => {
4012
4141
  let e3;
4013
4142
  return this._$userContent$.subscribe((t3) => {
4014
- e3 && e3.remove(), e3 = t3, t3 && n2.appendChild(t3);
4143
+ e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
4144
+ });
4145
+ }), this._sideEffect.add(() => {
4146
+ let e3;
4147
+ return this._$userStage$.subscribe((t3) => {
4148
+ var i3;
4149
+ if (e3 && e3.remove(), e3 = t3, t3) {
4150
+ if (!this.$stage) {
4151
+ const e4 = document.createElement("div");
4152
+ this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
4153
+ t4 && (e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px");
4154
+ }), "content-stage-rect"), r2.appendChild(e4);
4155
+ }
4156
+ this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
4157
+ } else
4158
+ ((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
4015
4159
  });
4016
- }), r2.appendChild(n2);
4160
+ }), o2.appendChild(r2);
4017
4161
  const h = document.createElement("div");
4018
4162
  return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
4019
4163
  let e3;
4020
4164
  return this._$userFooter$.subscribe((t3) => {
4021
4165
  e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
4022
4166
  });
4023
- }), a2.appendChild(o2), a2.appendChild(r2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
4167
+ }), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
4024
4168
  }
4025
4169
  _renderResizeHandlers() {
4026
4170
  const e2 = document.createElement("div");
@@ -4029,7 +4173,7 @@ class Y$3 {
4029
4173
  i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
4030
4174
  }), this.$box.appendChild(e2);
4031
4175
  const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
4032
- let s2, a2, o2 = 0, r2 = 0, n2 = 0, h = 0, l2 = 0, d2 = 0;
4176
+ let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
4033
4177
  const c = (e3) => {
4034
4178
  if (this.state !== C$3.Normal)
4035
4179
  return;
@@ -4037,36 +4181,36 @@ class Y$3 {
4037
4181
  let { pageX: t3, pageY: i3 } = R$3(e3);
4038
4182
  i3 < this.rootRect.y && (i3 = this.rootRect.y);
4039
4183
  const s3 = t3 - l2, c2 = i3 - d2;
4040
- let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: x2, height: g2 } = this.pxIntrinsicSize;
4184
+ let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
4041
4185
  switch (a2) {
4042
4186
  case N$3.North:
4043
- u3 = r2 + c2, g2 = h - c2;
4187
+ u3 = o2 + c2, x2 = h - c2;
4044
4188
  break;
4045
4189
  case N$3.South:
4046
- g2 = h + c2;
4190
+ x2 = h + c2;
4047
4191
  break;
4048
4192
  case N$3.West:
4049
- m3 = o2 + s3, x2 = n2 - s3;
4193
+ m3 = n2 + s3, g2 = r2 - s3;
4050
4194
  break;
4051
4195
  case N$3.East:
4052
- x2 = n2 + s3;
4196
+ g2 = r2 + s3;
4053
4197
  break;
4054
4198
  case N$3.NorthWest:
4055
- m3 = o2 + s3, u3 = r2 + c2, x2 = n2 - s3, g2 = h - c2;
4199
+ m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
4056
4200
  break;
4057
4201
  case N$3.NorthEast:
4058
- u3 = r2 + c2, x2 = n2 + s3, g2 = h - c2;
4202
+ u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
4059
4203
  break;
4060
4204
  case N$3.SouthEast:
4061
- x2 = n2 + s3, g2 = h + c2;
4205
+ g2 = r2 + s3, x2 = h + c2;
4062
4206
  break;
4063
4207
  case N$3.SouthWest:
4064
- m3 = o2 + s3, x2 = n2 - s3, g2 = h + c2;
4208
+ m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
4065
4209
  break;
4066
4210
  default:
4067
- return void this.move(o2 + s3, r2 + c2);
4211
+ return void this.move(n2 + s3, o2 + c2);
4068
4212
  }
4069
- this.transform(m3, u3, x2, g2);
4213
+ this.transform(m3, u3, g2, x2);
4070
4214
  }, m2 = (e3) => {
4071
4215
  a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
4072
4216
  }, u2 = (e3) => {
@@ -4077,9 +4221,9 @@ class Y$3 {
4077
4221
  return;
4078
4222
  if (!this.draggable || a2 || this.state !== C$3.Normal)
4079
4223
  return;
4080
- const x2 = e3.target;
4081
- if ((u3 = x2.dataset) == null ? void 0 : u3.teleBoxHandle) {
4082
- k$1(e3), { x: o2, y: r2 } = this.pxIntrinsicCoord, { width: n2, height: h } = this.pxIntrinsicSize, { pageX: l2, pageY: d2 } = R$3(e3), a2 = x2.dataset.teleBoxHandle, s2 || (s2 = document.createElement("div"));
4224
+ const g2 = e3.target;
4225
+ if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
4226
+ k$1(e3), { x: n2, y: o2 } = this.pxIntrinsicCoord, { width: r2, height: h } = this.pxIntrinsicSize, { pageX: l2, pageY: d2 } = R$3(e3), a2 = g2.dataset.teleBoxHandle, s2 || (s2 = document.createElement("div"));
4083
4227
  const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
4084
4228
  s2.className = this.wrapClassName("track-mask" + (u4 ? ` ${u4}` : "")), this.$box.appendChild(s2), this.$box.classList.add(i2), this._sideEffect.add(() => (window.addEventListener("mousemove", c), window.addEventListener("touchmove", c, { passive: false }), window.addEventListener("mouseup", m2), window.addEventListener("touchend", m2, { passive: false }), window.addEventListener("touchcancel", m2, { passive: false }), () => {
4085
4229
  window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
@@ -4097,14 +4241,14 @@ class Y$3 {
4097
4241
  }
4098
4242
  var X$3, P$3;
4099
4243
  class O$3 {
4100
- constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: o2 = {}, root$: r2 }) {
4244
+ constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: n2 = {}, root$: o2 }) {
4101
4245
  this._sideEffect = new SideEffectManager(), this.namespace = a2;
4102
- const n2 = new ValManager();
4103
- this._sideEffect.addDisposer(() => n2.destroy());
4104
- const h = new Val(void 0), l2 = derive(e2), d2 = new Val(o2), m2 = new Val(document.createElement("button"));
4105
- withValueEnhancer(this, { styles: d2, $collector: m2 }, n2);
4106
- withReadonlyValueEnhancer(this, { root: r2 });
4107
- withReadonlyValueEnhancer(this, { rect: h, visible: l2 }, n2), m2.value.className = this.wrapClassName("collector"), m2.value.style.backgroundImage = "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')", this._sideEffect.addDisposer(m2.subscribe((a3) => {
4246
+ const r2 = new ValManager();
4247
+ this._sideEffect.addDisposer(() => r2.destroy());
4248
+ const h = new Val(void 0), l2 = derive(e2), d2 = new Val(n2), m2 = new Val(document.createElement("button"));
4249
+ withValueEnhancer(this, { styles: d2, $collector: m2 }, r2);
4250
+ withReadonlyValueEnhancer(this, { root: o2 });
4251
+ withReadonlyValueEnhancer(this, { rect: h, visible: l2 }, r2), m2.value.className = this.wrapClassName("collector"), m2.value.style.backgroundImage = "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')", this._sideEffect.addDisposer(m2.subscribe((a3) => {
4108
4252
  this._sideEffect.addEventListener(a3, "click", () => {
4109
4253
  t2.value || e2.setValue(false);
4110
4254
  }, {}, "telebox-collector-click"), this._sideEffect.addDisposer([l2.subscribe((e3) => {
@@ -4118,12 +4262,12 @@ class O$3 {
4118
4262
  const i3 = e3[t3];
4119
4263
  i3 != null && (a3.style[t3] = i3);
4120
4264
  });
4121
- }), r2.subscribe((e3) => {
4265
+ }), o2.subscribe((e3) => {
4122
4266
  e3 && e3.appendChild(a3);
4123
- }), combine([e2, s2, r2]).subscribe(([e3, t3, i3]) => {
4267
+ }), combine([e2, s2, o2]).subscribe(([e3, t3, i3]) => {
4124
4268
  if (e3 && i3) {
4125
- const { x: e4, y: i4, width: s3, height: o3 } = a3.getBoundingClientRect();
4126
- h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: o3 });
4269
+ const { x: e4, y: i4, width: s3, height: n3 } = a3.getBoundingClientRect();
4270
+ h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: n3 });
4127
4271
  }
4128
4272
  })], "telebox-collector-el");
4129
4273
  }));
@@ -4149,8 +4293,8 @@ class j$1 extends H$3 {
4149
4293
  if (this.$titles && this.state$.value === C$3.Maximized) {
4150
4294
  const { children: i2 } = this.$titles.firstElementChild;
4151
4295
  for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
4152
- const a2 = i2[s2], o2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
4153
- o2 && (e2 && o2 === e2.id ? a2.classList.toggle(this.wrapClassName("titles-tab-focus"), true) : this.focusedBox && o2 === this.focusedBox.id && a2.classList.toggle(this.wrapClassName("titles-tab-focus"), false));
4296
+ const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
4297
+ n2 && (e2 && n2 === e2.id ? a2.classList.toggle(this.wrapClassName("titles-tab-focus"), true) : this.focusedBox && n2 === this.focusedBox.id && a2.classList.toggle(this.wrapClassName("titles-tab-focus"), false));
4154
4298
  }
4155
4299
  }
4156
4300
  this.focusedBox = e2;
@@ -4190,11 +4334,11 @@ class j$1 extends H$3 {
4190
4334
  }
4191
4335
  const Z$3 = window.ResizeObserver || ResizeObserver$2;
4192
4336
  class F$3 {
4193
- constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector: o2, namespace: r2 = "telebox", readonly: n2 = false, stageRatio: l2 = -1, highlightStage: m2 = true } = {}) {
4194
- this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = r2;
4337
+ constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector: n2, namespace: o2 = "telebox", readonly: r2 = false, stageRatio: l2 = -1, highlightStage: m2 = true } = {}) {
4338
+ this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
4195
4339
  const b2 = new ValManager();
4196
4340
  this._sideEffect.addDisposer(() => b2.destroy());
4197
- const w2 = new Val(e2), y2 = new Val(n2), z2 = new Val(i2), _2 = new Val(s2), N2 = new Val(a2), M2 = new Val(l2), S2 = new Val(m2), I2 = new Val({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight }, { compare: shallowequal });
4341
+ const w2 = new Val(e2), y2 = new Val(r2), z2 = new Val(i2), B2 = new Val(s2), N2 = new Val(a2), S2 = new Val(l2), M2 = new Val(m2), I2 = new Val({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight }, { compare: shallowequal });
4198
4342
  this._sideEffect.addDisposer(w2.subscribe((e3) => {
4199
4343
  this._sideEffect.add(() => {
4200
4344
  if (!e3)
@@ -4224,13 +4368,13 @@ class F$3 {
4224
4368
  this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
4225
4369
  t3 || this.events.emit(X$3.PrefersColorScheme, e3);
4226
4370
  }));
4227
- const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2, _2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal);
4228
- this.collector = o2 != null ? o2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: r2, root$: w2, rootRect$: I2 });
4229
- const V2 = new A$2({ namespace: r2, rootRect$: I2, ratio$: M2, root$: w2, highlightStage$: combine([S2, _2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
4371
+ const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2, B2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal);
4372
+ this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2, rootRect$: I2 });
4373
+ const V2 = new A$2({ namespace: o2, rootRect$: I2, ratio$: S2, root$: w2, highlightStage$: combine([M2, B2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
4230
4374
  this._sideEffect.addDisposer(() => V2.destroy());
4231
4375
  const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
4232
4376
  withReadonlyValueEnhancer(this, H2, b2);
4233
- withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: _2, stageRatio: M2, highlightStage: S2 }, b2);
4377
+ withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
4234
4378
  const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
4235
4379
  var t3;
4236
4380
  if (y2.value)
@@ -4250,10 +4394,10 @@ class F$3 {
4250
4394
  };
4251
4395
  this._sideEffect.addEventListener(window, "mousedown", Y2, true), this._sideEffect.addEventListener(window, "touchstart", Y2, true), this.titleBar = new j$1({ namespace: this.namespace, title$: derive(this.topBox$, (e3) => (e3 == null ? void 0 : e3.title) || ""), boxes$: this.boxes$, darkMode$: L2, readonly$: y2, state$: T2, root$: w2, rootRect$: I2, onEvent: (e3) => {
4252
4396
  switch (e3.type) {
4253
- case B$2.Maximize:
4254
- _2.setValue(!_2.value);
4397
+ case _.Maximize:
4398
+ B2.setValue(!B2.value);
4255
4399
  break;
4256
- case B$2.Minimize:
4400
+ case _.Minimize:
4257
4401
  z2.setValue(true);
4258
4402
  break;
4259
4403
  case E$3.Close:
@@ -4261,7 +4405,7 @@ class F$3 {
4261
4405
  }
4262
4406
  } }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
4263
4407
  t3 || this.events.emit(X$3.State, e3);
4264
- }), _2.reaction((e3, t3) => {
4408
+ }), B2.reaction((e3, t3) => {
4265
4409
  t3 || this.events.emit(X$3.Maximized, e3);
4266
4410
  }), z2.reaction((e3, t3) => {
4267
4411
  t3 || this.events.emit(X$3.Minimized, e3);
@@ -4289,13 +4433,13 @@ class F$3 {
4289
4433
  return this;
4290
4434
  }
4291
4435
  create(e2 = {}, s2 = true) {
4292
- const a2 = new Y$3((o2 = n$3(n$3({ zIndex: this.topBox ? this.topBox.zIndex + 1 : 100 }, e2), s2 ? this.smartPosition(e2) : {}), r2 = { namespace: this.namespace, root$: this._root$, darkMode$: this._darkMode$, maximized$: this._maximized$, minimized$: this._minimized$, fence$: this._fence$, rootRect$: this._rootRect$, managerStageRect$: this._stageRect$, stageRatio$: this._stageRatio$, readonly$: this._readonly$, collectorRect$: this.collector._rect$, managerHighlightStage$: this._highlightStage$ }, t$3(o2, i$1(r2))));
4293
- var o2, r2;
4294
- return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(B$2.Maximize, () => {
4436
+ const a2 = new Y$3((n2 = r$4(r$4({ zIndex: this.topBox ? this.topBox.zIndex + 1 : 100 }, e2), s2 ? this.smartPosition(e2) : {}), o2 = { namespace: this.namespace, root$: this._root$, darkMode$: this._darkMode$, maximized$: this._maximized$, minimized$: this._minimized$, fence$: this._fence$, rootRect$: this._rootRect$, managerStageRect$: this._stageRect$, managerStageRatio$: this._stageRatio$, readonly$: this._readonly$, collectorRect$: this.collector._rect$, managerHighlightStage$: this._highlightStage$ }, t$3(n2, i$1(o2))));
4437
+ var n2, o2;
4438
+ return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
4295
4439
  this.setMaximized(!this.maximized);
4296
- }), a2._delegateEvents.on(B$2.Minimize, () => {
4440
+ }), a2._delegateEvents.on(_.Minimize, () => {
4297
4441
  this.setMinimized(true);
4298
- }), a2._delegateEvents.on(B$2.Close, () => {
4442
+ }), a2._delegateEvents.on(_.Close, () => {
4299
4443
  this.remove(a2), this.focusTopBox();
4300
4444
  }), a2._intrinsicCoord$.reaction((e3, t2) => {
4301
4445
  t2 || this.events.emit(X$3.IntrinsicMove, a2);
@@ -4380,27 +4524,27 @@ class F$3 {
4380
4524
  return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
4381
4525
  }
4382
4526
  updateBox(e2, t2, i2 = false) {
4383
- var s2, a2, o2, r2, n2, h;
4384
- t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (o2 = t2.width) != null ? o2 : e2.intrinsicWidth, height: (r2 = t2.height) != null ? r2 : e2.intrinsicHeight }, i2), t2.title != null && e2._title$.setValue(t2.title), t2.visible != null && e2._visible$.setValue(t2.visible, i2), t2.resizable != null && e2._resizable$.setValue(t2.resizable, i2), t2.draggable != null && e2._draggable$.setValue(t2.draggable, i2), t2.ratio != null && e2._ratio$.setValue(t2.ratio, i2), t2.zIndex != null && e2._zIndex$.setValue(t2.zIndex, i2), t2.content != null && e2.mountContent(t2.content), t2.footer != null && e2.mountFooter(t2.footer), t2.minHeight == null && t2.minWidth == null || e2._minSize$.setValue({ width: (n2 = t2.minWidth) != null ? n2 : e2.minWidth, height: (h = t2.minHeight) != null ? h : e2.minHeight }, i2);
4527
+ var s2, a2, n2, o2, r2, h;
4528
+ t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (n2 = t2.width) != null ? n2 : e2.intrinsicWidth, height: (o2 = t2.height) != null ? o2 : e2.intrinsicHeight }, i2), t2.title != null && e2._title$.setValue(t2.title), t2.visible != null && e2._visible$.setValue(t2.visible, i2), t2.resizable != null && e2._resizable$.setValue(t2.resizable, i2), t2.draggable != null && e2._draggable$.setValue(t2.draggable, i2), t2.ratio != null && e2._ratio$.setValue(t2.ratio, i2), t2.zIndex != null && e2._zIndex$.setValue(t2.zIndex, i2), t2.stageRatio !== void 0 && e2.setStageRatio(t2.stageRatio, i2), t2.content != null && e2.mountContent(t2.content), t2.footer != null && e2.mountFooter(t2.footer), t2.minHeight == null && t2.minWidth == null || e2._minSize$.setValue({ width: (r2 = t2.minWidth) != null ? r2 : e2.minWidth, height: (h = t2.minHeight) != null ? h : e2.minHeight }, i2);
4385
4529
  }
4386
4530
  smartPosition(e2) {
4387
4531
  let { x: t2, y: i2 } = e2;
4388
- const { width: s2 = 0.5, height: a2 = 0.5 } = e2, o2 = this.stageRect, r2 = this.topBox;
4532
+ const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
4389
4533
  if (t2 == null) {
4390
- let e3 = o2.x + 20;
4391
- if (r2) {
4392
- const t3 = r2.pxIntrinsicCoord.x + 20;
4393
- t3 + s2 * o2.width <= o2.x + o2.width && (e3 = t3);
4534
+ let e3 = n2.x + 20;
4535
+ if (o2) {
4536
+ const t3 = o2.pxIntrinsicCoord.x + 20;
4537
+ t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
4394
4538
  }
4395
- t2 = (e3 - o2.x) / o2.width;
4539
+ t2 = (e3 - n2.x) / n2.width;
4396
4540
  }
4397
4541
  if (i2 == null) {
4398
- let e3 = o2.y + 20;
4399
- if (r2) {
4400
- const t3 = r2.pxIntrinsicCoord.y + 20;
4401
- t3 + a2 * o2.height <= o2.y + o2.height && (e3 = t3);
4542
+ let e3 = n2.y + 20;
4543
+ if (o2) {
4544
+ const t3 = o2.pxIntrinsicCoord.y + 20;
4545
+ t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
4402
4546
  }
4403
- i2 = (e3 - o2.y) / o2.height;
4547
+ i2 = (e3 - n2.y) / n2.height;
4404
4548
  }
4405
4549
  return { x: t2, y: i2, width: s2, height: a2 };
4406
4550
  }
@@ -4567,8 +4711,9 @@ class BoxManager {
4567
4711
  height,
4568
4712
  id: params.appId
4569
4713
  };
4570
- this.teleBoxManager.create(createBoxConfig, params.smartPosition);
4714
+ const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
4571
4715
  this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
4716
+ return box;
4572
4717
  }
4573
4718
  setupBoxManager(createTeleBoxManagerConfig) {
4574
4719
  const root = WindowManager.playground;
@@ -5691,6 +5836,7 @@ class ReconnectRefresher {
5691
5836
  this.reactors.set(id2, func);
5692
5837
  this.disposers.set(id2, func());
5693
5838
  }
5839
+ return () => this.remove(id2);
5694
5840
  }
5695
5841
  remove(id2) {
5696
5842
  if (this.reactors.has(id2)) {
@@ -15316,14 +15462,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15316
15462
  const _WindowManager = class extends InvisiblePlugin {
15317
15463
  constructor(context) {
15318
15464
  super(context);
15319
- this.version = "1.0.0-canary.3";
15320
- this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.9", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
15465
+ this.version = "1.0.0-canary.4";
15466
+ this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.12", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
15321
15467
  this.emitter = callbacks$1;
15322
15468
  this.viewMode = ViewMode.Broadcaster;
15323
15469
  this.isReplay = isPlayer(this.displayer);
15324
15470
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15325
15471
  _WindowManager.displayer = context.displayer;
15326
- window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.9", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
15472
+ window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.12", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
15327
15473
  }
15328
15474
  static async mount(params) {
15329
15475
  var _a;