@netless/window-manager 1.0.0-canary.2 → 1.0.0-canary.5

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) {
@@ -893,9 +898,10 @@ class Storage {
893
898
  }
894
899
  }
895
900
  class WhiteBoardView {
896
- constructor(appContext, appProxy) {
901
+ constructor(appContext, appProxy, removeViewWrapper) {
897
902
  this.appContext = appContext;
898
903
  this.appProxy = appProxy;
904
+ this.removeViewWrapper = removeViewWrapper;
899
905
  this.nextPage = async () => {
900
906
  const nextIndex = this.pageState.index + 1;
901
907
  return this.jumpPage(nextIndex);
@@ -943,9 +949,18 @@ class WhiteBoardView {
943
949
  pageState$.setValue(pageState);
944
950
  });
945
951
  }
952
+ get view() {
953
+ return this.appContext.view;
954
+ }
946
955
  get pageState() {
947
956
  return this.pageState$.value;
948
957
  }
958
+ moveCamera(camera) {
959
+ this.appProxy.moveCamera(camera);
960
+ }
961
+ destroy() {
962
+ this.removeViewWrapper();
963
+ }
949
964
  }
950
965
  const setupWrapper = (root) => {
951
966
  const playground = document.createElement("div");
@@ -1009,6 +1024,7 @@ class AppContext {
1009
1024
  }
1010
1025
  };
1011
1026
  this.createWhiteBoardView = (size2) => {
1027
+ var _a;
1012
1028
  if (this.whiteBoardView) {
1013
1029
  return this.whiteBoardView;
1014
1030
  }
@@ -1016,9 +1032,18 @@ class AppContext {
1016
1032
  if (!view) {
1017
1033
  view = this.appProxy.createAppDir();
1018
1034
  }
1019
- view.divElement = this.box.$content;
1020
- this.initPageSize(size2);
1021
- this.whiteBoardView = new WhiteBoardView(this, this.appProxy);
1035
+ const viewWrapper = document.createElement("div");
1036
+ viewWrapper.className = "window-manager-view-wrapper";
1037
+ (_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
1038
+ const removeViewWrapper = () => {
1039
+ var _a2;
1040
+ (_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
1041
+ };
1042
+ view.divElement = viewWrapper;
1043
+ if (this.isAddApp) {
1044
+ this.initPageSize(size2);
1045
+ }
1046
+ this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
1022
1047
  return this.whiteBoardView;
1023
1048
  };
1024
1049
  this.initPageSize = (size2) => {
@@ -1172,6 +1197,134 @@ class AppPageStateImpl {
1172
1197
  (_a = this.sceneNode) == null ? void 0 : _a.dispose();
1173
1198
  }
1174
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
+ this.view.moveCamera({
1236
+ scale: nextScale,
1237
+ animationMode: AnimationMode.Immediately
1238
+ });
1239
+ }
1240
+ };
1241
+ }
1242
+ setRect(rect) {
1243
+ this.rect = rect;
1244
+ if (this.remoteCamera && this.remoteSize) {
1245
+ this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
1246
+ }
1247
+ }
1248
+ setView(view) {
1249
+ this.view = view;
1250
+ }
1251
+ onLocalCameraUpdate(camera) {
1252
+ this.saveCamera(camera);
1253
+ this.remoteCamera = camera;
1254
+ }
1255
+ }
1256
+ class AppViewSync {
1257
+ constructor(appProxy) {
1258
+ this.appProxy = appProxy;
1259
+ this.sem = new SideEffectManager();
1260
+ this.bindView = (view) => {
1261
+ if (!view)
1262
+ return;
1263
+ this.synchronizer.setView(view);
1264
+ this.sem.add(() => {
1265
+ view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1266
+ return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1267
+ });
1268
+ };
1269
+ this.onCameraUpdatedByDevice = (camera) => {
1270
+ var _a;
1271
+ this.synchronizer.onLocalCameraUpdate(camera);
1272
+ const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
1273
+ if (stage) {
1274
+ const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
1275
+ if (!isEqual(size2, this.appProxy.size$.value)) {
1276
+ this.appProxy.storeSize(size2);
1277
+ }
1278
+ }
1279
+ };
1280
+ this.synchronizer = new CameraSynchronizer((camera) => {
1281
+ this.appProxy.storeCamera(__spreadValues({
1282
+ id: this.appProxy.uid
1283
+ }, camera));
1284
+ });
1285
+ this.bindView(appProxy.view);
1286
+ this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
1287
+ const size2 = this.appProxy.size$.value;
1288
+ if (camera && size2) {
1289
+ this.synchronizer.onRemoteUpdate(camera, size2);
1290
+ }
1291
+ }));
1292
+ const box = this.appProxy.box;
1293
+ if (box && box.contentStageRect) {
1294
+ this.synchronizer.setRect(box.contentStageRect);
1295
+ this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
1296
+ if (rect) {
1297
+ this.synchronizer.setRect(rect);
1298
+ }
1299
+ }));
1300
+ if (!this.appProxy.size$.value) {
1301
+ this.appProxy.storeSize({
1302
+ id: this.appProxy.uid,
1303
+ width: box.contentStageRect.width,
1304
+ height: box.contentStageRect.height
1305
+ });
1306
+ }
1307
+ }
1308
+ }
1309
+ destroy() {
1310
+ this.sem.flushAll();
1311
+ }
1312
+ }
1313
+ const boxEmitter = new Emittery();
1314
+ const calculateNextIndex = (index2, pageState) => {
1315
+ let nextIndex = 0;
1316
+ const maxIndex = pageState.length - 1;
1317
+ if (index2 === pageState.index) {
1318
+ if (index2 === maxIndex) {
1319
+ nextIndex = index2 - 1;
1320
+ } else {
1321
+ nextIndex = pageState.index + 1;
1322
+ }
1323
+ } else {
1324
+ nextIndex = pageState.index;
1325
+ }
1326
+ return nextIndex;
1327
+ };
1175
1328
  var Fields = /* @__PURE__ */ ((Fields2) => {
1176
1329
  Fields2["Apps"] = "apps";
1177
1330
  Fields2["Focus"] = "focus";
@@ -1185,6 +1338,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
1185
1338
  Fields2["CursorState"] = "cursorState";
1186
1339
  Fields2["FullPath"] = "fullPath";
1187
1340
  Fields2["Registered"] = "registered";
1341
+ Fields2["Camera"] = "camera";
1342
+ Fields2["Size"] = "size";
1188
1343
  return Fields2;
1189
1344
  })(Fields || {});
1190
1345
  class AttributesDelegate {
@@ -1249,6 +1404,9 @@ class AttributesDelegate {
1249
1404
  this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
1250
1405
  }
1251
1406
  }
1407
+ updateAppAttributes(appId, key, value) {
1408
+ this.context.safeUpdateAttributes(["apps", appId, key], value);
1409
+ }
1252
1410
  cleanAppAttributes(id2) {
1253
1411
  this.context.safeUpdateAttributes(["apps", id2], void 0);
1254
1412
  this.context.safeSetAttributes({ [id2]: void 0 });
@@ -1345,21 +1503,6 @@ const log = (...args) => {
1345
1503
  console.log(`[WindowManager]:`, ...args);
1346
1504
  }
1347
1505
  };
1348
- const calculateNextIndex = (index2, pageState) => {
1349
- let nextIndex = 0;
1350
- const maxIndex = pageState.length - 1;
1351
- if (index2 === pageState.index) {
1352
- if (index2 === maxIndex) {
1353
- nextIndex = index2 - 1;
1354
- } else {
1355
- nextIndex = pageState.index + 1;
1356
- }
1357
- } else {
1358
- nextIndex = pageState.index;
1359
- }
1360
- return nextIndex;
1361
- };
1362
- const boxEmitter = new Emittery();
1363
1506
  class AppProxy {
1364
1507
  constructor(params, manager, appId, isAddApp) {
1365
1508
  var _a;
@@ -1369,8 +1512,13 @@ class AppProxy {
1369
1512
  this.appProxies = this.manager.appProxies;
1370
1513
  this.viewManager = this.manager.viewManager;
1371
1514
  this.store = this.manager.store;
1515
+ this.uid = this.manager.uid;
1372
1516
  this.status = "normal";
1373
1517
  this.sideEffectManager = new SideEffectManager();
1518
+ this.camera$ = new Val(void 0);
1519
+ this.size$ = new Val(void 0);
1520
+ this.box$ = new Val(void 0);
1521
+ this.view$ = new Val(void 0);
1374
1522
  this.getAppInitState = (id2) => {
1375
1523
  var _a2, _b;
1376
1524
  const attrs = this.store.getAppState(id2);
@@ -1440,6 +1588,19 @@ class AppProxy {
1440
1588
  this.appEmitter.emit("pageStateChange", this.pageState);
1441
1589
  }
1442
1590
  }, 50);
1591
+ this.storeCamera = (camera) => {
1592
+ this.store.updateAppAttributes(this.id, Fields.Camera, camera);
1593
+ };
1594
+ this.storeSize = (size2) => {
1595
+ this.store.updateAppAttributes(this.id, Fields.Size, size2);
1596
+ };
1597
+ this.moveCamera = (camera) => {
1598
+ if (!this.camera$.value) {
1599
+ return;
1600
+ }
1601
+ const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
1602
+ this.storeCamera(nextCamera);
1603
+ };
1443
1604
  this.kind = params.kind;
1444
1605
  this.id = appId;
1445
1606
  this.appScenePath = `/${this.id}-app-dir`;
@@ -1461,14 +1622,43 @@ class AppProxy {
1461
1622
  view: this.view,
1462
1623
  notifyPageStateChange: this.notifyPageStateChange
1463
1624
  });
1625
+ this.sideEffectManager.add(() => () => this._pageState.destroy());
1626
+ this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
1627
+ this.appEmitter.emit("roomMembersChange", members);
1628
+ }));
1629
+ this.camera$.setValue(toJS(this.appAttributes.camera));
1630
+ this.size$.setValue(toJS(this.appAttributes.size));
1464
1631
  this.sideEffectManager.add(() => {
1465
- return () => this._pageState.destroy();
1632
+ return this.manager.refresher.add(`${this.id}-camera`, () => {
1633
+ return reaction(() => {
1634
+ var _a2;
1635
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1636
+ }, (camera) => {
1637
+ if (camera && camera.id !== this.uid) {
1638
+ this.camera$.setValue(toJS(camera));
1639
+ }
1640
+ });
1641
+ });
1466
1642
  });
1467
1643
  this.sideEffectManager.add(() => {
1468
- return emitter.on("roomMembersChange", (members) => {
1469
- this.appEmitter.emit("roomMembersChange", members);
1644
+ return this.manager.refresher.add(`${this.id}-size`, () => {
1645
+ return reaction(() => {
1646
+ var _a2;
1647
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1648
+ }, (size2) => {
1649
+ if (size2 && size2.id !== this.uid) {
1650
+ this.size$.setValue(toJS(size2));
1651
+ }
1652
+ });
1470
1653
  });
1471
1654
  });
1655
+ combine([this.box$, this.view$]).subscribe(([box, view]) => {
1656
+ if (box && view) {
1657
+ const appViewSync = new AppViewSync(this);
1658
+ this.appViewSync = appViewSync;
1659
+ this.sideEffectManager.add(() => () => appViewSync.destroy());
1660
+ }
1661
+ });
1472
1662
  }
1473
1663
  createAppDir() {
1474
1664
  const scenePath = this.scenePath || this.appScenePath;
@@ -1526,7 +1716,7 @@ class AppProxy {
1526
1716
  return fullPath;
1527
1717
  }
1528
1718
  setFullPath(path) {
1529
- this.manager.safeUpdateAttributes(["apps", this.id, Fields.FullPath], path);
1719
+ this.store.updateAppAttributes(this.id, Fields.FullPath, path);
1530
1720
  }
1531
1721
  async baseInsertApp(skipUpdate = false) {
1532
1722
  var _a;
@@ -1548,8 +1738,7 @@ class AppProxy {
1548
1738
  };
1549
1739
  }
1550
1740
  get box() {
1551
- var _a;
1552
- return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
1741
+ return this.box$.value;
1553
1742
  }
1554
1743
  async setupApp(appId, skipUpdate, app, options, appOptions) {
1555
1744
  var _a;
@@ -1577,13 +1766,14 @@ class AppProxy {
1577
1766
  this.fixMobileSize();
1578
1767
  }, SETUP_APP_DELAY);
1579
1768
  });
1580
- (_a = this.boxManager) == null ? void 0 : _a.createBox({
1769
+ const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
1581
1770
  appId,
1582
1771
  app,
1583
1772
  options,
1584
1773
  canOperate: this.manager.canOperate,
1585
1774
  smartPosition: this.isAddApp
1586
1775
  });
1776
+ this.box$.setValue(box);
1587
1777
  if (this.isAddApp && this.box) {
1588
1778
  this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
1589
1779
  this.boxManager.focusBox({ appId }, false);
@@ -1712,6 +1902,7 @@ class AppProxy {
1712
1902
  }
1713
1903
  createView() {
1714
1904
  const view = this.viewManager.createView(this.id);
1905
+ this.view$.setValue(view);
1715
1906
  this.setViewFocusScenePath();
1716
1907
  return view;
1717
1908
  }
@@ -1762,6 +1953,7 @@ class AppProxy {
1762
1953
  console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
1763
1954
  }
1764
1955
  this.appEmitter.clearListeners();
1956
+ this.sideEffectManager.flushAll();
1765
1957
  emitter.emit(`destroy-${this.id}`, { error });
1766
1958
  if (needCloseBox) {
1767
1959
  (_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
@@ -1779,7 +1971,9 @@ class AppProxy {
1779
1971
  (_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
1780
1972
  (_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
1781
1973
  this._prevFullPath = void 0;
1782
- this.sideEffectManager.flushAll();
1974
+ this.camera$.destroy();
1975
+ this.size$.destroy();
1976
+ this.box$.destroy();
1783
1977
  }
1784
1978
  close() {
1785
1979
  return this.destroy(true, true, false);
@@ -1835,56 +2029,6 @@ const setDefaultCameraBound = (view) => {
1835
2029
  minContentMode: () => 0.1
1836
2030
  });
1837
2031
  };
1838
- class CameraSynchronizer {
1839
- constructor(saveCamera) {
1840
- this.saveCamera = saveCamera;
1841
- this.onRemoteUpdate = throttle((camera, size2) => {
1842
- this.remoteCamera = camera;
1843
- this.remoteSize = size2;
1844
- if (this.remoteSize && this.rect) {
1845
- let scale2;
1846
- if (size2.width < size2.height) {
1847
- scale2 = this.rect.width / size2.width;
1848
- } else {
1849
- scale2 = this.rect.height / size2.height;
1850
- }
1851
- const nextScale = camera.scale * scale2;
1852
- const moveCamera = () => {
1853
- var _a;
1854
- return (_a = this.view) == null ? void 0 : _a.moveCamera({
1855
- centerX: camera.centerX,
1856
- centerY: camera.centerY,
1857
- scale: nextScale,
1858
- animationMode: AnimationMode.Immediately
1859
- });
1860
- };
1861
- delay(moveCamera, 10);
1862
- }
1863
- }, 50);
1864
- }
1865
- setRect(rect) {
1866
- this.rect = rect;
1867
- if (this.remoteCamera && this.remoteSize) {
1868
- this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
1869
- }
1870
- }
1871
- setView(view) {
1872
- this.view = view;
1873
- }
1874
- onLocalCameraUpdate(camera) {
1875
- this.saveCamera(camera);
1876
- }
1877
- onLocalSizeUpdate(size2) {
1878
- if (this.rect && this.view) {
1879
- const scale2 = this.rect.width / size2.width;
1880
- const nextScale = this.view.camera.scale * scale2;
1881
- this.view.moveCamera({
1882
- scale: nextScale,
1883
- animationMode: AnimationMode.Immediately
1884
- });
1885
- }
1886
- }
1887
- }
1888
2032
  class MainViewProxy {
1889
2033
  constructor(manager) {
1890
2034
  var _a;
@@ -1914,9 +2058,6 @@ class MainViewProxy {
1914
2058
  }, { fireImmediately: true });
1915
2059
  };
1916
2060
  this.sizeChangeHandler = debounce((size2) => {
1917
- if (size2) {
1918
- this.synchronizer.onLocalSizeUpdate(size2);
1919
- }
1920
2061
  }, 30);
1921
2062
  this.onUpdateContainerSizeRatio = () => {
1922
2063
  const size2 = this.store.getMainViewSize();
@@ -1955,9 +2096,7 @@ class MainViewProxy {
1955
2096
  });
1956
2097
  this.sideEffectManager.add(() => {
1957
2098
  return emitter.on("startReconnect", () => {
1958
- if (!this.mainView.didRelease) {
1959
- this.mainView.release();
1960
- }
2099
+ releaseView(this.mainView);
1961
2100
  });
1962
2101
  });
1963
2102
  const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
@@ -1967,7 +2106,6 @@ class MainViewProxy {
1967
2106
  this.sideEffectManager.add(() => {
1968
2107
  return emitter.on("playgroundSizeChange", (rect2) => {
1969
2108
  this.synchronizer.setRect(rect2);
1970
- this.synchronizer.onLocalSizeUpdate(rect2);
1971
2109
  });
1972
2110
  });
1973
2111
  }
@@ -2037,9 +2175,7 @@ class MainViewProxy {
2037
2175
  const divElement = this.mainView.divElement;
2038
2176
  const disableCameraTransform = this.mainView.disableCameraTransform;
2039
2177
  this.stop();
2040
- if (!this.didRelease) {
2041
- this.mainView.release();
2042
- }
2178
+ releaseView(this.mainView);
2043
2179
  this.removeMainViewListener();
2044
2180
  this.mainView = this.createMainView();
2045
2181
  this.mainView.disableCameraTransform = disableCameraTransform;
@@ -3687,16 +3823,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
3687
3823
  }
3688
3824
  return true;
3689
3825
  };
3690
- 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) => {
3826
+ 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) => {
3691
3827
  for (var i2 in t2 || (t2 = {}))
3692
- a$1.call(t2, i2) && r$4(e2, i2, t2[i2]);
3828
+ a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
3693
3829
  if (s$2)
3694
3830
  for (var i2 of s$2(t2))
3695
- o$2.call(t2, i2) && r$4(e2, i2, t2[i2]);
3831
+ n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
3696
3832
  return e2;
3697
3833
  };
3698
- var v$3, w$2, C$3, y$2, E$3, z$2, B$2, _, N$3, M$3;
3699
- (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";
3834
+ var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
3835
+ (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";
3700
3836
  function I$3(e2, t2, i2) {
3701
3837
  return Math.min(Math.max(e2, t2), i2);
3702
3838
  }
@@ -3717,7 +3853,7 @@ function V$3(e2) {
3717
3853
  return !e2;
3718
3854
  }
3719
3855
  class H$3 {
3720
- constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: o2, namespace: r2 = "telebox" }) {
3856
+ constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
3721
3857
  this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
3722
3858
  var t3;
3723
3859
  if (this.readonly$.value)
@@ -3728,7 +3864,7 @@ class H$3 {
3728
3864
  return;
3729
3865
  k$1(e3);
3730
3866
  const i3 = Date.now();
3731
- 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;
3867
+ 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;
3732
3868
  }, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
3733
3869
  var t3;
3734
3870
  if (this.readonly$.value)
@@ -3737,8 +3873,8 @@ class H$3 {
3737
3873
  return;
3738
3874
  k$1(e3);
3739
3875
  const i3 = Date.now(), { clientX: s3 = this.lastTitleBarTouch.clientX + 100, clientY: a3 = this.lastTitleBarTouch.clientY + 100 } = e3.touches[0] || {};
3740
- 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;
3741
- }, 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();
3876
+ 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;
3877
+ }, 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();
3742
3878
  }
3743
3879
  render() {
3744
3880
  if (!this.$titleBar) {
@@ -3814,13 +3950,13 @@ class A$2 {
3814
3950
  i2.className = this.wrapClassName("box-stage-mask");
3815
3951
  const s2 = document.createElement("div");
3816
3952
  s2.className = this.wrapClassName("box-stage-frame");
3817
- const [a2, o2, r2, n2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
3953
+ const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
3818
3954
  const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3819
3955
  i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
3820
3956
  const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
3821
3957
  return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
3822
3958
  });
3823
- 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) => {
3959
+ 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) => {
3824
3960
  e2.classList.toggle("is-active", t3);
3825
3961
  })), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
3826
3962
  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`));
@@ -3835,40 +3971,40 @@ class A$2 {
3835
3971
  }
3836
3972
  const W$3 = window.ResizeObserver || ResizeObserver$2;
3837
3973
  class Y$3 {
3838
- 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 }) {
3974
+ 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 }) {
3839
3975
  this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
3840
3976
  var t3;
3841
3977
  return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
3842
3978
  }, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
3843
- const Z2 = new ValManager();
3844
- this._sideEffect.addDisposer(() => Z2.destroy());
3845
- 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 });
3846
- this._sideEffect.addDisposer(ae2.reaction((e3, t3) => {
3847
- re2.setValue({ width: Math.max(a2, e3.width), height: Math.max(o2, e3.height) }, t3);
3979
+ const G2 = new ValManager();
3980
+ this._sideEffect.addDisposer(() => G2.destroy());
3981
+ 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 });
3982
+ this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
3983
+ le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
3848
3984
  }));
3849
- 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 });
3850
- this._sideEffect.addDisposer(() => xe2.destroy());
3851
- withReadonlyValueEnhancer(this, { darkMode: k2, fence: R2, minimized: D2, maximized: T2, readonly: V2, rootRect: Y2, managerStageRect: X2, collectorRect: O2 });
3852
- 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$ };
3853
- withReadonlyValueEnhancer(this, ge2, Z2);
3854
- 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) => {
3985
+ 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 });
3986
+ this._sideEffect.addDisposer(() => $e2.destroy());
3987
+ withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
3988
+ 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$ };
3989
+ withReadonlyValueEnhancer(this, be2, G2);
3990
+ 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) => {
3855
3991
  var t3;
3856
3992
  return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
3857
- }, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(Q2.subscribe((e3) => {
3858
- e3 > 0 && this.transform(le2.value.x, le2.value.y, he2.value.width, he2.value.height, true);
3859
- })), this._sideEffect.addDisposer(R2.subscribe((e3) => {
3860
- e3 && this.move(le2.value.x, le2.value.y, true);
3861
- })), this.$box = this.render(), me2.setValue(this.$content.parentElement);
3862
- const pe2 = (e3, t3) => {
3993
+ }, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
3994
+ e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
3995
+ })), this._sideEffect.addDisposer(T2.subscribe((e3) => {
3996
+ e3 && this.move(me2.value.x, me2.value.y, true);
3997
+ })), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
3998
+ const ve2 = (e3, t3) => {
3863
3999
  this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
3864
4000
  i3 || this.events.emit(t3, e4);
3865
4001
  }));
3866
4002
  };
3867
- 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) => {
4003
+ 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) => {
3868
4004
  t3 || e3 || this.events.emit(E$3.Close);
3869
- }), U2.reaction((e3, t3) => {
4005
+ }), te2.reaction((e3, t3) => {
3870
4006
  t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
3871
- }), W2.subscribe((e3) => {
4007
+ }), X2.subscribe((e3) => {
3872
4008
  e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
3873
4009
  })]);
3874
4010
  }
@@ -3901,22 +4037,22 @@ class Y$3 {
3901
4037
  }
3902
4038
  move(e2, t2, i2 = false) {
3903
4039
  let s2, a2;
3904
- const o2 = this.managerStageRect, r2 = this.pxIntrinsicSize;
4040
+ const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
3905
4041
  if (this.fence)
3906
- s2 = I$3(e2, o2.x, o2.x + o2.width - r2.width), a2 = I$3(t2, o2.y, o2.y + o2.height - r2.height);
4042
+ s2 = I$3(e2, n2.x, n2.x + n2.width - o2.width), a2 = I$3(t2, n2.y, n2.y + n2.height - o2.height);
3907
4043
  else {
3908
4044
  const i3 = this.rootRect;
3909
- 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);
4045
+ s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
3910
4046
  }
3911
- this._intrinsicCoord$.setValue({ x: (s2 - o2.x) / o2.width, y: (a2 - o2.y) / o2.height }, i2);
4047
+ this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
3912
4048
  }
3913
4049
  transform(e2, t2, i2, s2, a2 = false) {
3914
- const o2 = this.managerStageRect, r2 = this.rootRect;
4050
+ const n2 = this.managerStageRect, o2 = this.rootRect;
3915
4051
  if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
3916
4052
  const e3 = this.ratio * i2;
3917
4053
  t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
3918
4054
  }
3919
- 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);
4055
+ 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);
3920
4056
  }
3921
4057
  mountContent(e2) {
3922
4058
  this._$userContent$.setValue(e2);
@@ -3924,6 +4060,12 @@ class Y$3 {
3924
4060
  unmountContent() {
3925
4061
  this._$userContent$.setValue(void 0);
3926
4062
  }
4063
+ mountStage(e2) {
4064
+ this._$userStage$.setValue(e2);
4065
+ }
4066
+ unmountStage() {
4067
+ this._$userStage$.setValue(void 0);
4068
+ }
3927
4069
  mountFooter(e2) {
3928
4070
  this._$userFooter$.setValue(e2);
3929
4071
  }
@@ -3966,47 +4108,62 @@ class Y$3 {
3966
4108
  this.$box.style.zIndex = String(e3);
3967
4109
  })), this.$box.dataset.teleBoxID = this.id;
3968
4110
  const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
3969
- 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 };
4111
+ 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 };
3970
4112
  if (t3 && a3) {
3971
4113
  const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
3972
- 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;
4114
+ 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;
3973
4115
  }
3974
- return o3;
4116
+ return n3;
3975
4117
  }, { compare: shallowequal }), s2 = i2.value;
3976
4118
  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) => {
3977
4119
  t2.set(e3);
3978
4120
  }));
3979
4121
  const a2 = document.createElement("div");
3980
4122
  a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
4123
+ const n2 = document.createElement("div");
4124
+ n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
3981
4125
  const o2 = document.createElement("div");
3982
- o2.className = this.wrapClassName("titlebar-wrap"), o2.appendChild(this.titleBar.render()), this.$titleBar = o2;
4126
+ o2.className = this.wrapClassName("content-wrap");
3983
4127
  const r2 = document.createElement("div");
3984
- r2.className = this.wrapClassName("content-wrap");
3985
- const n2 = document.createElement("div");
3986
- n2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = n2, this._sideEffect.add(() => {
4128
+ r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
3987
4129
  const e3 = new W$3(() => {
3988
- const e4 = n2.getBoundingClientRect();
4130
+ const e4 = r2.getBoundingClientRect();
3989
4131
  this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
3990
4132
  });
3991
- return e3.observe(n2), () => e3.disconnect();
4133
+ return e3.observe(r2), () => e3.disconnect();
3992
4134
  }), this._sideEffect.add(() => {
3993
4135
  let e3;
3994
4136
  return this._$userStyles$.subscribe((t3) => {
3995
- e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
4137
+ e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
3996
4138
  });
3997
4139
  }), this._sideEffect.add(() => {
3998
4140
  let e3;
3999
4141
  return this._$userContent$.subscribe((t3) => {
4000
- e3 && e3.remove(), e3 = t3, t3 && n2.appendChild(t3);
4142
+ e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
4143
+ });
4144
+ }), this._sideEffect.add(() => {
4145
+ let e3;
4146
+ return this._$userStage$.subscribe((t3) => {
4147
+ var i3;
4148
+ if (e3 && e3.remove(), e3 = t3, t3) {
4149
+ if (!this.$stage) {
4150
+ const e4 = document.createElement("div");
4151
+ this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
4152
+ 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");
4153
+ }), "content-stage-rect"), r2.appendChild(e4);
4154
+ }
4155
+ this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
4156
+ } else
4157
+ ((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
4001
4158
  });
4002
- }), r2.appendChild(n2);
4159
+ }), o2.appendChild(r2);
4003
4160
  const h = document.createElement("div");
4004
4161
  return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
4005
4162
  let e3;
4006
4163
  return this._$userFooter$.subscribe((t3) => {
4007
4164
  e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
4008
4165
  });
4009
- }), a2.appendChild(o2), a2.appendChild(r2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
4166
+ }), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
4010
4167
  }
4011
4168
  _renderResizeHandlers() {
4012
4169
  const e2 = document.createElement("div");
@@ -4015,7 +4172,7 @@ class Y$3 {
4015
4172
  i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
4016
4173
  }), this.$box.appendChild(e2);
4017
4174
  const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
4018
- let s2, a2, o2 = 0, r2 = 0, n2 = 0, h = 0, l2 = 0, d2 = 0;
4175
+ let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
4019
4176
  const c = (e3) => {
4020
4177
  if (this.state !== C$3.Normal)
4021
4178
  return;
@@ -4023,36 +4180,36 @@ class Y$3 {
4023
4180
  let { pageX: t3, pageY: i3 } = R$3(e3);
4024
4181
  i3 < this.rootRect.y && (i3 = this.rootRect.y);
4025
4182
  const s3 = t3 - l2, c2 = i3 - d2;
4026
- let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: x2, height: g2 } = this.pxIntrinsicSize;
4183
+ let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
4027
4184
  switch (a2) {
4028
4185
  case N$3.North:
4029
- u3 = r2 + c2, g2 = h - c2;
4186
+ u3 = o2 + c2, x2 = h - c2;
4030
4187
  break;
4031
4188
  case N$3.South:
4032
- g2 = h + c2;
4189
+ x2 = h + c2;
4033
4190
  break;
4034
4191
  case N$3.West:
4035
- m3 = o2 + s3, x2 = n2 - s3;
4192
+ m3 = n2 + s3, g2 = r2 - s3;
4036
4193
  break;
4037
4194
  case N$3.East:
4038
- x2 = n2 + s3;
4195
+ g2 = r2 + s3;
4039
4196
  break;
4040
4197
  case N$3.NorthWest:
4041
- m3 = o2 + s3, u3 = r2 + c2, x2 = n2 - s3, g2 = h - c2;
4198
+ m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
4042
4199
  break;
4043
4200
  case N$3.NorthEast:
4044
- u3 = r2 + c2, x2 = n2 + s3, g2 = h - c2;
4201
+ u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
4045
4202
  break;
4046
4203
  case N$3.SouthEast:
4047
- x2 = n2 + s3, g2 = h + c2;
4204
+ g2 = r2 + s3, x2 = h + c2;
4048
4205
  break;
4049
4206
  case N$3.SouthWest:
4050
- m3 = o2 + s3, x2 = n2 - s3, g2 = h + c2;
4207
+ m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
4051
4208
  break;
4052
4209
  default:
4053
- return void this.move(o2 + s3, r2 + c2);
4210
+ return void this.move(n2 + s3, o2 + c2);
4054
4211
  }
4055
- this.transform(m3, u3, x2, g2);
4212
+ this.transform(m3, u3, g2, x2);
4056
4213
  }, m2 = (e3) => {
4057
4214
  a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
4058
4215
  }, u2 = (e3) => {
@@ -4063,9 +4220,9 @@ class Y$3 {
4063
4220
  return;
4064
4221
  if (!this.draggable || a2 || this.state !== C$3.Normal)
4065
4222
  return;
4066
- const x2 = e3.target;
4067
- if ((u3 = x2.dataset) == null ? void 0 : u3.teleBoxHandle) {
4068
- 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"));
4223
+ const g2 = e3.target;
4224
+ if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
4225
+ 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"));
4069
4226
  const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
4070
4227
  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 }), () => {
4071
4228
  window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
@@ -4083,14 +4240,14 @@ class Y$3 {
4083
4240
  }
4084
4241
  var X$3, P$3;
4085
4242
  class O$3 {
4086
- constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: o2 = {}, root$: r2 }) {
4243
+ constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: n2 = {}, root$: o2 }) {
4087
4244
  this._sideEffect = new SideEffectManager(), this.namespace = a2;
4088
- const n2 = new ValManager();
4089
- this._sideEffect.addDisposer(() => n2.destroy());
4090
- const h = new Val(void 0), l2 = derive(e2), d2 = new Val(o2), m2 = new Val(document.createElement("button"));
4091
- withValueEnhancer(this, { styles: d2, $collector: m2 }, n2);
4092
- withReadonlyValueEnhancer(this, { root: r2 });
4093
- 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) => {
4245
+ const r2 = new ValManager();
4246
+ this._sideEffect.addDisposer(() => r2.destroy());
4247
+ const h = new Val(void 0), l2 = derive(e2), d2 = new Val(n2), m2 = new Val(document.createElement("button"));
4248
+ withValueEnhancer(this, { styles: d2, $collector: m2 }, r2);
4249
+ withReadonlyValueEnhancer(this, { root: o2 });
4250
+ 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) => {
4094
4251
  this._sideEffect.addEventListener(a3, "click", () => {
4095
4252
  t2.value || e2.setValue(false);
4096
4253
  }, {}, "telebox-collector-click"), this._sideEffect.addDisposer([l2.subscribe((e3) => {
@@ -4104,12 +4261,12 @@ class O$3 {
4104
4261
  const i3 = e3[t3];
4105
4262
  i3 != null && (a3.style[t3] = i3);
4106
4263
  });
4107
- }), r2.subscribe((e3) => {
4264
+ }), o2.subscribe((e3) => {
4108
4265
  e3 && e3.appendChild(a3);
4109
- }), combine([e2, s2, r2]).subscribe(([e3, t3, i3]) => {
4266
+ }), combine([e2, s2, o2]).subscribe(([e3, t3, i3]) => {
4110
4267
  if (e3 && i3) {
4111
- const { x: e4, y: i4, width: s3, height: o3 } = a3.getBoundingClientRect();
4112
- h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: o3 });
4268
+ const { x: e4, y: i4, width: s3, height: n3 } = a3.getBoundingClientRect();
4269
+ h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: n3 });
4113
4270
  }
4114
4271
  })], "telebox-collector-el");
4115
4272
  }));
@@ -4135,8 +4292,8 @@ class j$1 extends H$3 {
4135
4292
  if (this.$titles && this.state$.value === C$3.Maximized) {
4136
4293
  const { children: i2 } = this.$titles.firstElementChild;
4137
4294
  for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
4138
- const a2 = i2[s2], o2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
4139
- 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));
4295
+ const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
4296
+ 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));
4140
4297
  }
4141
4298
  }
4142
4299
  this.focusedBox = e2;
@@ -4176,11 +4333,11 @@ class j$1 extends H$3 {
4176
4333
  }
4177
4334
  const Z$3 = window.ResizeObserver || ResizeObserver$2;
4178
4335
  class F$3 {
4179
- 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 } = {}) {
4180
- this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = r2;
4336
+ 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 } = {}) {
4337
+ this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
4181
4338
  const b2 = new ValManager();
4182
4339
  this._sideEffect.addDisposer(() => b2.destroy());
4183
- 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 });
4340
+ 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 });
4184
4341
  this._sideEffect.addDisposer(w2.subscribe((e3) => {
4185
4342
  this._sideEffect.add(() => {
4186
4343
  if (!e3)
@@ -4210,13 +4367,13 @@ class F$3 {
4210
4367
  this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
4211
4368
  t3 || this.events.emit(X$3.PrefersColorScheme, e3);
4212
4369
  }));
4213
- 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);
4214
- this.collector = o2 != null ? o2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: r2, root$: w2, rootRect$: I2 });
4215
- const V2 = new A$2({ namespace: r2, rootRect$: I2, ratio$: M2, root$: w2, highlightStage$: combine([S2, _2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
4370
+ 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);
4371
+ this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2, rootRect$: I2 });
4372
+ const V2 = new A$2({ namespace: o2, rootRect$: I2, ratio$: S2, root$: w2, highlightStage$: combine([M2, B2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
4216
4373
  this._sideEffect.addDisposer(() => V2.destroy());
4217
4374
  const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
4218
4375
  withReadonlyValueEnhancer(this, H2, b2);
4219
- withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: _2, stageRatio: M2, highlightStage: S2 }, b2);
4376
+ withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
4220
4377
  const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
4221
4378
  var t3;
4222
4379
  if (y2.value)
@@ -4236,10 +4393,10 @@ class F$3 {
4236
4393
  };
4237
4394
  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) => {
4238
4395
  switch (e3.type) {
4239
- case B$2.Maximize:
4240
- _2.setValue(!_2.value);
4396
+ case _.Maximize:
4397
+ B2.setValue(!B2.value);
4241
4398
  break;
4242
- case B$2.Minimize:
4399
+ case _.Minimize:
4243
4400
  z2.setValue(true);
4244
4401
  break;
4245
4402
  case E$3.Close:
@@ -4247,7 +4404,7 @@ class F$3 {
4247
4404
  }
4248
4405
  } }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
4249
4406
  t3 || this.events.emit(X$3.State, e3);
4250
- }), _2.reaction((e3, t3) => {
4407
+ }), B2.reaction((e3, t3) => {
4251
4408
  t3 || this.events.emit(X$3.Maximized, e3);
4252
4409
  }), z2.reaction((e3, t3) => {
4253
4410
  t3 || this.events.emit(X$3.Minimized, e3);
@@ -4275,13 +4432,13 @@ class F$3 {
4275
4432
  return this;
4276
4433
  }
4277
4434
  create(e2 = {}, s2 = true) {
4278
- 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))));
4279
- var o2, r2;
4280
- 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, () => {
4435
+ 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))));
4436
+ var n2, o2;
4437
+ return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
4281
4438
  this.setMaximized(!this.maximized);
4282
- }), a2._delegateEvents.on(B$2.Minimize, () => {
4439
+ }), a2._delegateEvents.on(_.Minimize, () => {
4283
4440
  this.setMinimized(true);
4284
- }), a2._delegateEvents.on(B$2.Close, () => {
4441
+ }), a2._delegateEvents.on(_.Close, () => {
4285
4442
  this.remove(a2), this.focusTopBox();
4286
4443
  }), a2._intrinsicCoord$.reaction((e3, t2) => {
4287
4444
  t2 || this.events.emit(X$3.IntrinsicMove, a2);
@@ -4366,27 +4523,27 @@ class F$3 {
4366
4523
  return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
4367
4524
  }
4368
4525
  updateBox(e2, t2, i2 = false) {
4369
- var s2, a2, o2, r2, n2, h;
4370
- 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);
4526
+ var s2, a2, n2, o2, r2, h;
4527
+ 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);
4371
4528
  }
4372
4529
  smartPosition(e2) {
4373
4530
  let { x: t2, y: i2 } = e2;
4374
- const { width: s2 = 0.5, height: a2 = 0.5 } = e2, o2 = this.stageRect, r2 = this.topBox;
4531
+ const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
4375
4532
  if (t2 == null) {
4376
- let e3 = o2.x + 20;
4377
- if (r2) {
4378
- const t3 = r2.pxIntrinsicCoord.x + 20;
4379
- t3 + s2 * o2.width <= o2.x + o2.width && (e3 = t3);
4533
+ let e3 = n2.x + 20;
4534
+ if (o2) {
4535
+ const t3 = o2.pxIntrinsicCoord.x + 20;
4536
+ t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
4380
4537
  }
4381
- t2 = (e3 - o2.x) / o2.width;
4538
+ t2 = (e3 - n2.x) / n2.width;
4382
4539
  }
4383
4540
  if (i2 == null) {
4384
- let e3 = o2.y + 20;
4385
- if (r2) {
4386
- const t3 = r2.pxIntrinsicCoord.y + 20;
4387
- t3 + a2 * o2.height <= o2.y + o2.height && (e3 = t3);
4541
+ let e3 = n2.y + 20;
4542
+ if (o2) {
4543
+ const t3 = o2.pxIntrinsicCoord.y + 20;
4544
+ t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
4388
4545
  }
4389
- i2 = (e3 - o2.y) / o2.height;
4546
+ i2 = (e3 - n2.y) / n2.height;
4390
4547
  }
4391
4548
  return { x: t2, y: i2, width: s2, height: a2 };
4392
4549
  }
@@ -4553,8 +4710,9 @@ class BoxManager {
4553
4710
  height,
4554
4711
  id: params.appId
4555
4712
  };
4556
- this.teleBoxManager.create(createBoxConfig, params.smartPosition);
4713
+ const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
4557
4714
  this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
4715
+ return box;
4558
4716
  }
4559
4717
  setupBoxManager(createTeleBoxManagerConfig) {
4560
4718
  const root = WindowManager.playground;
@@ -5677,6 +5835,7 @@ class ReconnectRefresher {
5677
5835
  this.reactors.set(id2, func);
5678
5836
  this.disposers.set(id2, func());
5679
5837
  }
5838
+ return () => this.remove(id2);
5680
5839
  }
5681
5840
  remove(id2) {
5682
5841
  if (this.reactors.has(id2)) {
@@ -15302,14 +15461,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15302
15461
  const _WindowManager = class extends InvisiblePlugin {
15303
15462
  constructor(context) {
15304
15463
  super(context);
15305
- this.version = "1.0.0-canary.2";
15306
- this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.8", "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" } };
15464
+ this.version = "1.0.0-canary.5";
15465
+ this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "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" } };
15307
15466
  this.emitter = callbacks$1;
15308
15467
  this.viewMode = ViewMode.Broadcaster;
15309
15468
  this.isReplay = isPlayer(this.displayer);
15310
15469
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15311
15470
  _WindowManager.displayer = context.displayer;
15312
- window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.8", "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" } };
15471
+ window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "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" } };
15313
15472
  }
15314
15473
  static async mount(params) {
15315
15474
  var _a;