@dimina-kit/devtools 0.4.0-dev.20260907055341 → 0.5.0-dev.20260908120530
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/README.md +1 -1
- package/dist/main/app/window-runtime-services.d.ts +12 -12
- package/dist/main/app/window-runtime-services.js +34 -15
- package/dist/main/index.bundle.js +6307 -6050
- package/dist/main/services/elements-forward/index.d.ts +2 -2
- package/dist/main/services/elements-forward/index.js +6 -6
- package/dist/main/services/network-forward/body-cache.d.ts +2 -0
- package/dist/main/services/network-forward/body-cache.js +4 -0
- package/dist/main/services/network-forward/global-body-gate.d.ts +1 -1
- package/dist/main/services/network-forward/global-body-gate.js +4 -4
- package/dist/main/services/network-forward/http.d.ts +47 -0
- package/dist/main/services/network-forward/http.js +162 -0
- package/dist/main/services/network-forward/index.d.ts +19 -13
- package/dist/main/services/network-forward/index.js +220 -134
- package/dist/main/services/network-forward/request-ids.d.ts +5 -0
- package/dist/main/services/network-forward/request-ids.js +5 -0
- package/dist/main/services/safe-area/index.d.ts +7 -9
- package/dist/main/services/safe-area/index.js +7 -14
- package/dist/main/services/views/native-simulator-view.js +7 -8
- package/dist/main/services/workbench-context.d.ts +3 -3
- package/dist/main/services/workbench-context.js +7 -1
- package/dist/native-host/render/render.js +525 -482
- package/dist/native-host/service/service.js +2 -2
- package/dist/preload/shared/api-compat.js +63 -41
- package/dist/preload/windows/main.cjs +15 -1
- package/dist/preload/windows/main.cjs.map +2 -2
- package/dist/preload/windows/simulator.cjs +55 -134
- package/dist/preload/windows/simulator.cjs.map +4 -4
- package/dist/preload/windows/simulator.js +55 -134
- package/dist/renderer/assets/workbench-C0Jkdlps.js +5 -0
- package/dist/renderer/entries/workbench/index.html +1 -1
- package/dist/shared/types.d.ts +2 -0
- package/dist/simulator/assets/device-shell-DucLepkm.js +431 -0
- package/dist/simulator/assets/simulator-B4rbcOVt.js +10 -0
- package/dist/simulator/assets/simulator-ui-i3GCc7YJ.js +2 -0
- package/dist/simulator/simulator.html +2 -2
- package/package.json +12 -12
- package/dist/renderer/assets/workbench-BLJ0wKsg.js +0 -5
- package/dist/shared/request-core.d.ts +0 -2
- package/dist/shared/request-core.js +0 -2
- package/dist/simulator/assets/device-shell-pxnZZp10.js +0 -431
- package/dist/simulator/assets/simulator-Dwp7lnvu.js +0 -10
- package/dist/simulator/assets/simulator-ui-B2ddJB1R.js +0 -2
|
@@ -399,7 +399,21 @@ var BRIDGE_CHANNELS = {
|
|
|
399
399
|
* active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
|
|
400
400
|
* this to report multi-page stacks. Fire-and-forget.
|
|
401
401
|
*/
|
|
402
|
-
PAGE_STACK: "dmb:page-stack"
|
|
402
|
+
PAGE_STACK: "dmb:page-stack",
|
|
403
|
+
/**
|
|
404
|
+
* preload (window.wx.request, no service-host in the picture) → main
|
|
405
|
+
* (invoke): run an HTTP request through the main-process native transport
|
|
406
|
+
* (`main/services/native-request`) instead of the renderer's `fetch()`, so
|
|
407
|
+
* it never hits Chromium's Fetch/CORS algorithm (no spurious OPTIONS
|
|
408
|
+
* preflight). Reply is a `NativeRequestResult` (success or fail shape).
|
|
409
|
+
*/
|
|
410
|
+
NATIVE_REQUEST: "dmb:native-request",
|
|
411
|
+
/**
|
|
412
|
+
* preload → main: cancel the in-flight native request named by the
|
|
413
|
+
* requestId a prior NATIVE_REQUEST call was invoked with. Fire-and-forget;
|
|
414
|
+
* a requestId that already settled or belongs to another sender is a no-op.
|
|
415
|
+
*/
|
|
416
|
+
NATIVE_REQUEST_ABORT: "dmb:native-request-abort"
|
|
403
417
|
};
|
|
404
418
|
var SimulatorCustomApiBridgeChannel = {
|
|
405
419
|
Request: "simulator:custom-apis:bridge-request",
|
|
@@ -751,115 +765,8 @@ function createAppDataSource() {
|
|
|
751
765
|
};
|
|
752
766
|
}
|
|
753
767
|
|
|
754
|
-
// ../dimina-electron-runtime/dist/shared/request-core.js
|
|
755
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
|
|
756
|
-
var MAX_TIMEOUT_MS = 2147483647;
|
|
757
|
-
function resolveTimeoutBudgetMs(timeout) {
|
|
758
|
-
const t = Number(timeout);
|
|
759
|
-
return Number.isFinite(t) && t > 0 && t <= MAX_TIMEOUT_MS ? t : DEFAULT_REQUEST_TIMEOUT_MS;
|
|
760
|
-
}
|
|
761
|
-
function buildHeaders(header) {
|
|
762
|
-
const headers = new Headers();
|
|
763
|
-
for (const [key, value] of Object.entries(header ?? {})) {
|
|
764
|
-
if (value != null)
|
|
765
|
-
headers.set(key, String(value));
|
|
766
|
-
}
|
|
767
|
-
if (!headers.has("content-type"))
|
|
768
|
-
headers.set("content-type", "application/json");
|
|
769
|
-
return headers;
|
|
770
|
-
}
|
|
771
|
-
function appendQueryParams(url, data) {
|
|
772
|
-
const base = typeof location !== "undefined" ? location.href : void 0;
|
|
773
|
-
const resolved = new URL(url, base);
|
|
774
|
-
for (const [key, value] of Object.entries(data)) {
|
|
775
|
-
resolved.searchParams.append(key, String(value));
|
|
776
|
-
}
|
|
777
|
-
return resolved.toString();
|
|
778
|
-
}
|
|
779
|
-
function encodeBody(data, contentType) {
|
|
780
|
-
if (typeof data === "string")
|
|
781
|
-
return data;
|
|
782
|
-
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
783
|
-
const form = new URLSearchParams();
|
|
784
|
-
for (const [key, value] of Object.entries(data)) {
|
|
785
|
-
form.append(key, String(value));
|
|
786
|
-
}
|
|
787
|
-
return form.toString();
|
|
788
|
-
}
|
|
789
|
-
return JSON.stringify(data);
|
|
790
|
-
}
|
|
791
|
-
async function decodeResponseData(response, dataType, responseType) {
|
|
792
|
-
if (responseType === "arraybuffer" || dataType === "arraybuffer") {
|
|
793
|
-
return response.arrayBuffer();
|
|
794
|
-
}
|
|
795
|
-
const text = await response.text();
|
|
796
|
-
if (dataType !== "json")
|
|
797
|
-
return text;
|
|
798
|
-
try {
|
|
799
|
-
return JSON.parse(text);
|
|
800
|
-
} catch {
|
|
801
|
-
return text;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
function performRequest(opts, callbacks) {
|
|
805
|
-
const method = (opts.method || "GET").toUpperCase();
|
|
806
|
-
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
807
|
-
const headers = buildHeaders(opts.header);
|
|
808
|
-
let url = opts.url;
|
|
809
|
-
const init = { method, headers };
|
|
810
|
-
if (!canHaveBody) {
|
|
811
|
-
if (opts.data && typeof opts.data === "object") {
|
|
812
|
-
url = appendQueryParams(url, opts.data);
|
|
813
|
-
}
|
|
814
|
-
} else if (opts.data != null) {
|
|
815
|
-
init.body = encodeBody(opts.data, headers.get("content-type") ?? "");
|
|
816
|
-
}
|
|
817
|
-
const controller = new AbortController();
|
|
818
|
-
init.signal = controller.signal;
|
|
819
|
-
let settled = false;
|
|
820
|
-
function settleSuccess(res) {
|
|
821
|
-
if (settled)
|
|
822
|
-
return;
|
|
823
|
-
settled = true;
|
|
824
|
-
clearTimeout(timer);
|
|
825
|
-
callbacks.success?.(res);
|
|
826
|
-
callbacks.complete?.(res);
|
|
827
|
-
}
|
|
828
|
-
function settleFail(err) {
|
|
829
|
-
if (settled)
|
|
830
|
-
return;
|
|
831
|
-
settled = true;
|
|
832
|
-
clearTimeout(timer);
|
|
833
|
-
callbacks.fail?.(err);
|
|
834
|
-
callbacks.complete?.(err);
|
|
835
|
-
}
|
|
836
|
-
const timeoutMs = resolveTimeoutBudgetMs(opts.timeout);
|
|
837
|
-
const timer = setTimeout(() => {
|
|
838
|
-
settleFail({ errMsg: "request:fail timeout" });
|
|
839
|
-
controller.abort();
|
|
840
|
-
}, timeoutMs);
|
|
841
|
-
const dataType = opts.dataType ?? "json";
|
|
842
|
-
const responseType = opts.responseType ?? "text";
|
|
843
|
-
fetch(url, init).then(async (response) => {
|
|
844
|
-
const header = {};
|
|
845
|
-
response.headers.forEach((value, key) => {
|
|
846
|
-
header[key] = value;
|
|
847
|
-
});
|
|
848
|
-
const data = await decodeResponseData(response, dataType, responseType);
|
|
849
|
-
settleSuccess({ data, statusCode: response.status, header, errMsg: "request:ok" });
|
|
850
|
-
}).catch((error) => {
|
|
851
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
852
|
-
settleFail({ errMsg: `request:fail ${reason || "network error"}` });
|
|
853
|
-
});
|
|
854
|
-
return {
|
|
855
|
-
abort() {
|
|
856
|
-
settleFail({ errMsg: "request:fail abort" });
|
|
857
|
-
controller.abort();
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
|
|
862
768
|
// src/preload/shared/api-compat.ts
|
|
769
|
+
var import_electron5 = require("electron");
|
|
863
770
|
function call(fn, payload) {
|
|
864
771
|
try {
|
|
865
772
|
fn?.(payload);
|
|
@@ -975,8 +882,12 @@ function ensureWxApi(wx) {
|
|
|
975
882
|
};
|
|
976
883
|
}
|
|
977
884
|
if (typeof wx.request !== "function") {
|
|
978
|
-
wx.request = (opts) =>
|
|
979
|
-
{
|
|
885
|
+
wx.request = (opts) => {
|
|
886
|
+
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
887
|
+
const task = {
|
|
888
|
+
abort: () => import_electron5.ipcRenderer.send(BRIDGE_CHANNELS.NATIVE_REQUEST_ABORT, requestId)
|
|
889
|
+
};
|
|
890
|
+
import_electron5.ipcRenderer.invoke(BRIDGE_CHANNELS.NATIVE_REQUEST, requestId, {
|
|
980
891
|
url: opts.url,
|
|
981
892
|
data: opts.data,
|
|
982
893
|
header: opts.header,
|
|
@@ -984,13 +895,23 @@ function ensureWxApi(wx) {
|
|
|
984
895
|
method: opts.method,
|
|
985
896
|
dataType: opts.dataType,
|
|
986
897
|
responseType: opts.responseType
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
898
|
+
}).then((result) => {
|
|
899
|
+
if (result && typeof result === "object" && "statusCode" in result) {
|
|
900
|
+
call(opts.success, result);
|
|
901
|
+
call(opts.complete, result);
|
|
902
|
+
} else {
|
|
903
|
+
call(opts.fail, result);
|
|
904
|
+
call(opts.complete, result);
|
|
905
|
+
}
|
|
906
|
+
}).catch((error) => {
|
|
907
|
+
const err = {
|
|
908
|
+
errMsg: `request:fail ${error instanceof Error ? error.message : String(error)}`
|
|
909
|
+
};
|
|
910
|
+
call(opts.fail, err);
|
|
911
|
+
call(opts.complete, err);
|
|
912
|
+
});
|
|
913
|
+
return task;
|
|
914
|
+
};
|
|
994
915
|
}
|
|
995
916
|
}
|
|
996
917
|
function setupApiCompatHook() {
|
|
@@ -1010,7 +931,7 @@ function setupApiCompatHook() {
|
|
|
1010
931
|
}
|
|
1011
932
|
|
|
1012
933
|
// src/preload/runtime/native-host.ts
|
|
1013
|
-
var
|
|
934
|
+
var import_electron6 = require("electron");
|
|
1014
935
|
|
|
1015
936
|
// ../dimina-electron-runtime/dist/shared/dmb-resource-url.js
|
|
1016
937
|
var DMB_PAGEFRAME_DOC_NAME = "__frame__.html";
|
|
@@ -1045,7 +966,7 @@ function buildRenderHostDocumentUrl(opts) {
|
|
|
1045
966
|
// src/preload/runtime/native-host.ts
|
|
1046
967
|
function queryNativeHostConfig() {
|
|
1047
968
|
try {
|
|
1048
|
-
const res =
|
|
969
|
+
const res = import_electron6.ipcRenderer.sendSync(BRIDGE_CHANNELS.NATIVE_HOST_ENABLED);
|
|
1049
970
|
return res && res.enabled ? res : null;
|
|
1050
971
|
} catch {
|
|
1051
972
|
return null;
|
|
@@ -1055,33 +976,33 @@ function buildBridge2(cfg) {
|
|
|
1055
976
|
return {
|
|
1056
977
|
enabled: true,
|
|
1057
978
|
spawn(opts) {
|
|
1058
|
-
return
|
|
979
|
+
return import_electron6.ipcRenderer.invoke(BRIDGE_CHANNELS.SPAWN, opts);
|
|
1059
980
|
},
|
|
1060
981
|
dispose(bridgeId) {
|
|
1061
982
|
const payload = { bridgeId };
|
|
1062
|
-
|
|
983
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.DISPOSE, payload);
|
|
1063
984
|
},
|
|
1064
985
|
openPage(opts) {
|
|
1065
|
-
return
|
|
986
|
+
return import_electron6.ipcRenderer.invoke(BRIDGE_CHANNELS.PAGE_OPEN, opts);
|
|
1066
987
|
},
|
|
1067
988
|
closePage(bridgeId) {
|
|
1068
989
|
const payload = { bridgeId };
|
|
1069
|
-
|
|
990
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.PAGE_CLOSE, payload);
|
|
1070
991
|
},
|
|
1071
992
|
notifyLifecycle(payload) {
|
|
1072
|
-
|
|
993
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.PAGE_LIFECYCLE, payload);
|
|
1073
994
|
},
|
|
1074
995
|
notifyNavCallback(payload) {
|
|
1075
|
-
|
|
996
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.NAV_CALLBACK, payload);
|
|
1076
997
|
},
|
|
1077
998
|
notifyApiResponse(payload) {
|
|
1078
|
-
|
|
999
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.API_RESPONSE, payload);
|
|
1079
1000
|
},
|
|
1080
1001
|
notifyActivePage(payload) {
|
|
1081
|
-
|
|
1002
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.ACTIVE_PAGE, payload);
|
|
1082
1003
|
},
|
|
1083
1004
|
notifyPageStack(payload) {
|
|
1084
|
-
|
|
1005
|
+
import_electron6.ipcRenderer.send(BRIDGE_CHANNELS.PAGE_STACK, payload);
|
|
1085
1006
|
},
|
|
1086
1007
|
createRenderHostUrl(opts) {
|
|
1087
1008
|
return buildRenderHostDocumentUrl(opts);
|
|
@@ -1093,8 +1014,8 @@ function buildBridge2(cfg) {
|
|
|
1093
1014
|
;
|
|
1094
1015
|
listener(payload);
|
|
1095
1016
|
};
|
|
1096
|
-
|
|
1097
|
-
return () =>
|
|
1017
|
+
import_electron6.ipcRenderer.on(channel, wrapped);
|
|
1018
|
+
return () => import_electron6.ipcRenderer.removeListener(channel, wrapped);
|
|
1098
1019
|
}
|
|
1099
1020
|
};
|
|
1100
1021
|
}
|
|
@@ -1106,11 +1027,11 @@ function installNativeHostBridge() {
|
|
|
1106
1027
|
}
|
|
1107
1028
|
|
|
1108
1029
|
// src/preload/runtime/clipboard.ts
|
|
1109
|
-
var
|
|
1030
|
+
var import_electron7 = require("electron");
|
|
1110
1031
|
function buildBridge3() {
|
|
1111
1032
|
return {
|
|
1112
|
-
readText: () =>
|
|
1113
|
-
writeText: (text) =>
|
|
1033
|
+
readText: () => import_electron7.clipboard.readText(),
|
|
1034
|
+
writeText: (text) => import_electron7.clipboard.writeText(text)
|
|
1114
1035
|
};
|
|
1115
1036
|
}
|
|
1116
1037
|
function installClipboardBridge() {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as e,i as t,n,t as r}from"./jsx-runtime-DIw5wnYl.js";import{C as i,S as a,d as o,h as s,l as c,x as l,y as u}from"./ipc-channels-overlays-gIPUFnqc.js";import{a as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./view-ids-BfaDVV5P.js";import{_ as x,a as S,d as C,f as w,g as T,n as E,p as D,s as O}from"./project-api-YTOr_Yvo.js";import{A as k,E as ee,F as te,M as ne,P as re,_ as ie,c as ae,d as oe,g as se,j as ce,n as le,o as ue,p as de,s as fe,u as pe,x as me}from"./view-api-B-2zPBR5.js";import{l as he}from"./settings-api-Ccsf-Nsj.js";import{n as ge}from"./utils-sEB5OZEQ.js";import{t as A}from"./button-CB2MWjHY.js";import{t as j}from"./createLucideIcon-cZ9FlZZw.js";import{t as _e}from"./smartphone-Bb2GdIKy.js";import{n as ve,r as ye,t as be}from"./constants-zQZ2-y21.js";import{r as xe,t as Se}from"./presets-DMZOb9ay.js";import{a as Ce,n as we,o as Te,r as Ee,t as De}from"./select-nFP95TxM.js";function Oe(){return c(s.Open)}var ke=j(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Ae=j(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),je=j(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Me=j(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Ne=j(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Pe=j(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Fe=j(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ie=`149.0.7827.55`,Le=`ArkWeb/4.1.6.1 Mobile`,Re=`AppleWebKit/605.1.15 (KHTML, like Gecko)`,ze=`AppleWebKit/537.36 (KHTML, like Gecko)`,Be={ios:`18.0`,android:`13`,harmony:`5.0`};function Ve(e){return/(\d[\d.]*)/.exec(e.system??``)?.[1]??Be[e.os]??``}function He(e){if(e.userAgent)return e.userAgent;let t=Ve(e),n=e.formFactor===`tablet`;switch(e.os){case`ios`:{let e=Number.parseInt(t,10)>=26?`18_6`:t.replace(/\./g,`_`);return n?`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ${Re} Version/${t} Safari/605.1.15`:`Mozilla/5.0 (iPhone; CPU iPhone OS ${e} like Mac OS X) ${Re} Version/${t} Mobile/15E148 Safari/604.1`}case`harmony`:return`Mozilla/5.0 (${n?`Tablet`:`Phone`}; OpenHarmony ${t}) ${ze} Chrome/114.0.0.0 Safari/537.36 ${Le}`;default:return n?`Mozilla/5.0 (Linux; Android ${t}; ${e.name}) ${ze} Chrome/${Ie} Safari/537.36`:`Mozilla/5.0 (Linux; Android ${t}; ${e.name}) ${ze} Chrome/${Ie} Mobile Safari/537.36`}}function Ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function M(e,t,n,r){if(!(typeof t==`number`&&Number.isFinite(t)&&(r?t>n:t>=n))){let i=r?`greater than ${n}`:`>= ${n}`;throw TypeError(`${e} must be a finite number ${i}, got ${t}`)}}function We(e,t,n,r){if(!(typeof t==`number`&&Number.isFinite(t)&&t>=n&&t<=r))throw TypeError(`${e} must be a finite number between ${n} and ${r}, got ${t}`)}function Ge(e,t){if(typeof t!=`string`)throw TypeError(`${e} must be a string, got ${JSON.stringify(t)}`)}var Ke=[`top`,`right`,`bottom`,`left`],qe=[`statusBarHeight`,`statusBarHeightLandscape`,`navigationBarHeight`,`navigationBarHeightLandscape`],Je=[`system`,`userAgent`],Ye=[`safeAreaInsets`,`safeAreaInsetsLandscape`],Xe=[`screenRadius`,`bezel`,`bodyRadius`],Ze=[`notch`,`pill`,`circle`];function Qe(e,t=`deviceProfile`){if(!Ue(e))throw TypeError(`${t} must be an object, got ${e===null?`null`:typeof e}`);let n=e.os;if(n!==`ios`&&n!==`android`&&n!==`harmony`)throw TypeError(`${t}.os must be one of "ios", "android", "harmony", got ${JSON.stringify(n)}`);if(e.formFactor!==void 0){let n=e.formFactor;if(n!==`phone`&&n!==`tablet`)throw TypeError(`${t}.formFactor must be one of "phone", "tablet", got ${JSON.stringify(n)}`)}let r=e.screen;if(!Ue(r))throw TypeError(`${t}.screen must be an object, got ${r===null?`null`:typeof r}`);M(`${t}.screen.width`,r.width,0,!0),M(`${t}.screen.height`,r.height,0,!0),Ge(`${t}.name`,e.name),M(`${t}.pixelRatio`,e.pixelRatio,0,!0);for(let n of qe)e[n]!==void 0&&M(`${t}.${n}`,e[n],0,!1);for(let n of Ye){let r=e[n];if(r!==void 0){if(!Ue(r))throw TypeError(`${t}.${n} must be an object, got ${r===null?`null`:typeof r}`);for(let e of Ke)r[e]!==void 0&&M(`${t}.${n}.${e}`,r[e],0,!1)}}for(let n of Je)e[n]!==void 0&&Ge(`${t}.${n}`,e[n]);if(e.cutout!==void 0){let n=e.cutout;if(!Ue(n))throw TypeError(`${t}.cutout must be an object, got ${n===null?`null`:typeof n}`);let r=n.shape;if(!Ze.includes(r))throw TypeError(`${t}.cutout.shape must be one of "notch", "pill", "circle", got ${JSON.stringify(r)}`);M(`${t}.cutout.width`,n.width,0,!1),M(`${t}.cutout.height`,n.height,0,!1),M(`${t}.cutout.top`,n.top,0,!1),n.centerX!==void 0&&We(`${t}.cutout.centerX`,n.centerX,0,1)}if(e.shell!==void 0){let n=e.shell;if(!Ue(n))throw TypeError(`${t}.shell must be an object, got ${n===null?`null`:typeof n}`);for(let e of Xe)n[e]!==void 0&&M(`${t}.shell.${e}`,n[e],0,!1)}}var $e={ios:{statusBarHeight:44,statusBarHeightLandscape:0,navigationBarHeight:44,navigationBarHeightLandscape:32,shell:{screenRadius:38,bezel:6}},android:{statusBarHeight:24,statusBarHeightLandscape:24,navigationBarHeight:48,navigationBarHeightLandscape:48,shell:{screenRadius:16,bezel:4}},harmony:{statusBarHeight:36,statusBarHeightLandscape:36,navigationBarHeight:28,navigationBarHeightLandscape:28,shell:{screenRadius:34,bezel:4}}},et={top:0,right:0,bottom:0,left:0};function tt(e,t){return e?{top:e.top??t.top,right:e.right??t.right,bottom:e.bottom??t.bottom,left:e.left??t.left}:t}function nt(e){Qe(e,`device`);let t=$e[e.os],n=e.statusBarHeight??t.statusBarHeight,r=e.statusBarHeightLandscape??t.statusBarHeightLandscape,i=e.shell?.screenRadius??t.shell.screenRadius,a=e.shell?.bezel??t.shell.bezel;return{name:e.name,os:e.os,screen:e.screen,pixelRatio:e.pixelRatio,formFactor:e.formFactor??`phone`,system:e.system??``,userAgent:e.userAgent??He(e),statusBarHeight:n,statusBarHeightLandscape:r,navigationBarHeight:e.navigationBarHeight??t.navigationBarHeight,navigationBarHeightLandscape:e.navigationBarHeightLandscape??t.navigationBarHeightLandscape,safeAreaInsets:tt(e.safeAreaInsets,{...et,top:n}),safeAreaInsetsLandscape:tt(e.safeAreaInsetsLandscape,{...et,top:r}),cutout:e.cutout??null,shell:{screenRadius:i,bezel:a,bodyRadius:e.shell?.bodyRadius??i+a}}}function rt(e,t){return t===`landscape`?e.statusBarHeightLandscape:e.statusBarHeight}function it(e,t){return t===`landscape`?e.safeAreaInsetsLandscape:e.safeAreaInsets}function at(e,t=`portrait`){let{screen:n}=e;return t===`landscape`?{width:n.height,height:n.width}:{width:n.width,height:n.height}}function ot(e,t){let n=at(e,t),r=2*(nt(e).shell.bezel+1);return{width:n.width+r,height:n.height+r}}var N=e(t(),1),st=e(n(),1);function ct(e){return e+48}function lt(e,t){return Math.max(200,Math.min(t-200,e))}var ut={selected:`simulator`,simulatorVisible:!0};function dt(e){return e.os===`ios`?`Apple`:e.os===`harmony`?`HUAWEI`:e.name.split(` `)[0]??e.name}function ft(e){let{initialDevice:t}=e,[n,r]=(0,N.useState)(t),[i,a]=(0,N.useState)(85),[o,s]=(0,N.useState)(()=>ct(ot(t,`portrait`).width)),c=(0,N.useRef)(o),l=(0,N.useRef)(n);(0,N.useEffect)(()=>{c.current=o},[o]),(0,N.useEffect)(()=>{l.current=n},[n]);let u=(0,N.useCallback)(e=>{let t=nt(e),n=`portrait`,r=t.screen;k({device:e.name,brand:dt(e),model:e.name,system:t.system,platform:e.os,orientation:n,pixelRatio:e.pixelRatio,screenWidth:r.width,screenHeight:r.height,statusBarHeight:rt(t,n),safeAreaInsets:it(t,n)})},[]),d=(0,N.useCallback)(e=>{let t=xe(e)??Se;r(t),u(t),s(ct(ot(t,`portrait`).width))},[u]),f=(0,N.useCallback)(()=>{ce({deviceName:l.current.name})},[]);(0,N.useEffect)(()=>de(({deviceName:e})=>d(e)),[d]);let p=(0,N.useCallback)(e=>{u(e)},[u]);return{device:n,zoom:i,simPanelWidth:o,setSimPanelWidth:s,handleDeviceChange:d,openDevicePicker:f,handleZoomChange:(0,N.useCallback)(e=>{a(e.target.value===`auto`?be:Number(e.target.value))},[]),handleSplitterDrag:(0,N.useCallback)((e,t=`trailing`)=>{e.preventDefault();let n=e.clientX,r=c.current,i=e=>{let i=e.clientX-n;s(lt(r+(t===`trailing`?i:-i),window.innerWidth))},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[]),sendDeviceInfo:p,simPanelWidthRef:c,deviceRef:l}}var pt=200,mt=300;function ht(e){let{projectPath:t}=e,[n,r]=(0,N.useState)({status:`compiling`,message:`正在编译...`}),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)([]),[c,l]=(0,N.useState)(0),[u,d]=(0,N.useState)(``),[f,p]=(0,N.useState)(we()),[m,h]=(0,N.useState)(!1),g=(0,N.useMemo)(()=>{let e=Ce(Ee(f));return{...e,startPage:e.startPage||u||o[0]||``}},[f,u,o]),_=(0,N.useRef)(-1),v=(0,N.useRef)(async()=>{});(0,N.useEffect)(()=>{let e=!1;_.current=-1,h(!1);let n=oe(t=>{e||t.revision<=_.current||(_.current=t.revision,p(t.state),h(!0),t.relaunch&&v.current())}),i=pe(t=>{e||r({status:`error`,message:t.message})});async function o(){try{let n=await T(t);if(e)return;if(!n.success){r({status:`error`,message:n.error});return}let[i,o]=await Promise.all([O(t),S(t)]);if(e)return;a(n.appInfo),l(n.port),s(i.pages),d(i.entryPagePath||i.pages[0]||``),o.revision>_.current&&(_.current=o.revision,p(o.state),h(!0)),r({status:`ready`,message:`编译完成`})}catch(t){if(e)return;r({status:`error`,message:t instanceof Error?t.message:String(t)})}}return o(),()=>{e=!0,n(),i()}},[t]);let[y,b]=(0,N.useState)(0),[E,k]=(0,N.useState)([]),[ee,te]=(0,N.useState)([]),ne=(0,N.useRef)(0),[re,ie]=(0,N.useState)(null),[ae,se]=(0,N.useState)(!1);(0,N.useEffect)(()=>{k([]),te([]),ie(null),se(!1)},[t]),(0,N.useEffect)(()=>w(e=>{r(e),e.pages&&s(e.pages),e.watcher===`dead`&&se(!0);let t=++ne.current;k(n=>{let r=e.hotReload===!0?{at:Date.now(),status:e.status,message:e.message,hotReload:!0,seq:t}:{at:Date.now(),status:e.status,message:e.message,seq:t},i=[...n,r];return i.length>pt?i.slice(i.length-pt):i}),e.hotReload===!0&&(ie(null),b(e=>e+1))}),[]),(0,N.useEffect)(()=>D(e=>{i?.appId&&e.appId!==i.appId||ie(e)}),[i]),(0,N.useEffect)(()=>C(e=>{let t=++ne.current;te(n=>{let r=[...n,{...e,seq:t}];return r.length>mt?r.slice(r.length-mt):r})}),[]);let ce=(0,N.useCallback)(()=>{k([]),te([])},[]),le=(0,N.useRef)(!1),[ue,de]=(0,N.useState)(0),fe=(0,N.useCallback)(async()=>{try{if(!i?.appId||le.current)return;le.current=!0,r({status:`compiling`,message:`正在编译...`});try{await x(),de(e=>e+1),r({status:`ready`,message:`刷新完成`})}finally{le.current=!1}}catch(e){le.current=!1,r({status:`error`,message:e instanceof Error?e.message:`刷新失败`})}},[i]);return(0,N.useEffect)(()=>{v.current=fe},[fe]),{compileStatus:n,appInfo:i,port:c,pages:o,entryPagePath:u,compileModes:f,compileModesReady:m,compileConfig:g,hotReloadToken:y,compileEvents:E,compileLogs:ee,clearCompileEvents:ce,relaunch:fe,relaunchNonce:ue,runtimeStatus:re,watcherDead:ae}}var gt=[`appId`,`entry`,`page`];function _t(e){return encodeURIComponent(e).replace(/%2F/g,`/`).replace(/%2C/g,`,`)}function vt(e){let t=Object.keys(e.query);if(t.length===0)return e.pagePath;let n=t.map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t]??``)}`).join(`&`);return`${e.pagePath}?${n}`}function yt(e){let t=e.indexOf(`?`);if(t<0)return{pagePath:e,query:{}};let n=e.slice(0,t),r={};for(let n of e.slice(t+1).split(`&`)){if(!n)continue;let e=n.indexOf(`=`),t=e>=0?n.slice(0,e):n,i=e>=0?n.slice(e+1):``;t&&(r[decodeURIComponent(t)]=decodeURIComponent(i))}return{pagePath:n,query:r}}function bt(e,t,n={}){let r=vt(t),i=[`appId=${_t(e)}`,`entry=${_t(r)}`,`page=${_t(r)}`];for(let[e,t]of Object.entries(n))gt.includes(e)||i.push(`${encodeURIComponent(e)}=${_t(t)}`);return i.join(`&`)}function xt(e){let t=e.host??`localhost`,n=e.pathname??`/simulator.html`,r=bt(e.appId,e.page,e.extras??{});return`http://${t}:${e.port}${n}?${r}`}function St(e,t,n,r){let i=t.startPage||`pages/index/index`,a={};for(let e of t.queryParams??[])e.key&&(a[e.key]=e.value);a.scene=String(t.scene??1001);let o={};return r?.length&&(o.apiNamespaces=r.join(`,`)),xt({appId:e,page:{pagePath:i,query:a},port:n,extras:o})}function Ct(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`appId`),r=t.get(`entry`);if(!n||!r)return null;let i=yt(r),a=t.get(`page`);return{appId:n,entry:i,current:a&&a!==r?yt(a):i}}function wt(e){if(!e)return null;try{return Ct(new URL(e).search)}catch{return null}}function Tt(e){let t=wt(e);if(!t)return``;let n={...t.current.query};return delete n.scene,vt({pagePath:t.current.pagePath,query:n})}function Et(e){let{compileStatus:t,sendDeviceInfo:n,simPanelWidthRef:r,deviceRef:i,appInfo:a,compileConfig:o,port:s,projectPath:c,hotReloadToken:l,relaunchNonce:u}=e,d=(0,N.useMemo)(()=>!a||!s?``:St(a.appId,o,s),[a,o,s]),[f,p]=(0,N.useState)(()=>Tt(d)),m=(0,N.useMemo)(()=>yt(f).pagePath,[f]);(0,N.useEffect)(()=>{p(Tt(d))},[d]),(0,N.useEffect)(()=>me(e=>{e&&p(e)}),[]);let h=(0,N.useRef)({currentPage:m,currentRoute:f,compileConfig:o,appInfo:a,port:s});(0,N.useEffect)(()=>{h.current={currentPage:m,currentRoute:f,compileConfig:o,appInfo:a,port:s}});let g=(0,N.useRef)(l),_=(0,N.useRef)(u);return(0,N.useEffect)(()=>{if(t.status!==`ready`||!d)return;let e=u===_.current&&l!==g.current;g.current=l,_.current=u;let a=d;if(e){let e=h.current;if(e.appInfo&&e.port){let t=yt(e.currentRoute),n=t.pagePath||e.compileConfig.startPage;a=St(e.appInfo.appId,{...e.compileConfig,startPage:n,queryParams:Object.entries(t.query).map(([e,t])=>({key:e,value:t}))},e.port)}}n(i.current);let o=!1,s=null,f=()=>{o||(s=window.setTimeout(()=>{o||E(c).catch(()=>{})},3e3))},p=()=>{le(a,r.current).then(f).catch(()=>{})};return e?te(a).then(e=>{if(!o){if(e===!0){f();return}p()}}).catch(()=>{o||p()}):p(),()=>{o=!0,s!==null&&window.clearTimeout(s)}},[t.status,d,l,u,r,i,n,c]),{simulatorUrl:d,currentPage:m,currentRoute:f}}function Dt(){return{getSnapshot:async()=>await c(i.GetSnapshot)??null,subscribe:e=>o(i.Event,e),setActive:e=>{c(i.SetActive,e)},inspect:async e=>await c(l.Inspect,e)??null,clearInspection:async()=>{await c(l.Clear)}}}var Ot={ok:!1,error:`ipc transport failed`};function kt(){return{getSnapshot:async()=>await c(a.GetSnapshot)??[],subscribe:e=>o(a.Event,e),setActive:()=>{},setItem:async(e,t)=>await c(a.Set,{key:e,value:t})??Ot,removeItem:async e=>await c(a.Remove,{key:e})??Ot,clear:async()=>await c(a.Clear)??Ot,clearAll:async()=>await c(a.ClearAll)??Ot,getPrefix:async()=>await c(a.GetActivePrefix)??``}}var At={bridges:[],entries:{}};function jt(){return{getSnapshot:async()=>await c(u.GetSnapshot)??At,subscribe:e=>o(u.Event,e),setActive:()=>{},setData:async(e,t)=>await c(u.SetData,{bridgeId:e,data:t})??!1}}function Mt(e){let{compileStatus:t}=e,n=t.status===`ready`;return{wxmlSource:(0,N.useMemo)(()=>Dt(),[]),wxmlEnabled:n,storageSource:(0,N.useMemo)(()=>kt(),[]),storageEnabled:n,appDataSource:(0,N.useMemo)(()=>jt(),[]),appDataEnabled:n}}function Nt(e){let{initialRightPane:t}=e,[n,r]=(0,N.useState)(t);return{rightPane:n,selectRightPane:(0,N.useCallback)(e=>{r({selected:e,simulatorVisible:!0})},[]),toggleRightPaneVisible:(0,N.useCallback)(()=>{r(e=>({...e,simulatorVisible:!e.simulatorVisible}))},[])}}function Pt(e){let{pages:t,entryPagePath:n,currentRoute:r,compileDropdownRef:i}=e,[a,o]=(0,N.useState)(!1);(0,N.useEffect)(()=>ie(()=>o(!1)),[]);let s=(0,N.useRef)({pages:t,entryPagePath:n,currentRoute:r});return(0,N.useEffect)(()=>{s.current={pages:t,entryPagePath:n,currentRoute:r}},[t,n,r]),{showCompilePanel:a,toggleCompilePanel:(0,N.useCallback)(()=>{o(e=>{if(e)return fe(),!1;let t=i.current;if(!t)return e;let n=t.getBoundingClientRect();return ne({top:Math.round(n.bottom-40+6),left:Math.round(n.left),pages:s.current.pages,entryPagePath:s.current.entryPagePath,currentRoute:s.current.currentRoute}),!0})},[i])}}function Ft(e){let{projectPath:t,initialDevice:n=Se,initialRightPane:r=ut}=e,i=(0,N.useRef)(null),a=(0,N.useRef)(null),o=ft({initialDevice:n}),s=ht({projectPath:t});(0,N.useEffect)(()=>{s.compileStatus.status===`ready`&&o.setSimPanelWidth(ct(ot(o.device,`portrait`).width))},[o.device,s.compileStatus.status,o.setSimPanelWidth]);let c=Et({compileStatus:s.compileStatus,sendDeviceInfo:o.sendDeviceInfo,simPanelWidthRef:o.simPanelWidthRef,deviceRef:o.deviceRef,appInfo:s.appInfo,compileConfig:s.compileConfig,port:s.port,projectPath:t,hotReloadToken:s.hotReloadToken,relaunchNonce:s.relaunchNonce}),l=Mt({compileStatus:s.compileStatus,activePagePath:c.currentPage}),u=Nt({initialRightPane:r}),d=Pt({pages:s.pages,entryPagePath:s.entryPagePath,currentRoute:c.currentRoute,compileDropdownRef:a});return{session:{compileStatus:s.compileStatus,appInfo:s.appInfo,port:s.port,pages:s.pages,entryPagePath:s.entryPagePath,compileModes:s.compileModes,compileModesReady:s.compileModesReady,compileConfig:s.compileConfig,compileEvents:s.compileEvents,compileLogs:s.compileLogs,clearCompileEvents:s.clearCompileEvents,relaunch:s.relaunch,runtimeStatus:s.runtimeStatus,watcherDead:s.watcherDead},device:{device:o.device,zoom:o.zoom,simPanelWidth:o.simPanelWidth,setSimPanelWidth:o.setSimPanelWidth,handleDeviceChange:o.handleDeviceChange,openDevicePicker:o.openDevicePicker,handleZoomChange:o.handleZoomChange,handleSplitterDrag:o.handleSplitterDrag,sendDeviceInfo:o.sendDeviceInfo},simulator:{simulatorRef:i,simulatorUrl:c.simulatorUrl,currentPage:c.currentPage,currentRoute:c.currentRoute},panelData:{wxmlSource:l.wxmlSource,wxmlEnabled:l.wxmlEnabled,storageSource:l.storageSource,storageEnabled:l.storageEnabled,appDataSource:l.appDataSource,appDataEnabled:l.appDataEnabled},rightPane:{rightPane:u.rightPane,selectRightPane:u.selectRightPane,toggleRightPaneVisible:u.toggleRightPaneVisible},popover:{compileDropdownRef:a,showCompilePanel:d.showCompilePanel,toggleCompilePanel:d.toggleCompilePanel}}}var It={dockTree:null,simulatorAlignment:`left`,devtoolsPosition:`inEditor`},Lt=`dimina-devtools.layout.v1`,Rt=`dimina-devtools.layout.p.`,zt=24;function Bt(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return`${Rt}${t.toString(36)}`}function Vt(e){return{dockTree:typeof e.dockTree==`string`?e.dockTree:null,simulatorAlignment:e.simulatorAlignment===`right`?`right`:`left`,devtoolsPosition:e.devtoolsPosition===`belowSimulator`||e.devtoolsPosition===`rightOfSimulator`?e.devtoolsPosition:`inEditor`}}function Ht(e){try{let t=window.localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return n&&typeof n==`object`?n:null}catch{return null}}function Ut(e){if(!e)return It;let t=Ht(Bt(e));return t&&t.projectPath===e?Vt(t):Vt(Ht(Lt)??{})}var Wt=0;function Gt(e,t){if(!e)return;Wt=Math.max(Date.now(),Wt+1);let n={...t,projectPath:e,savedAt:Wt};try{window.localStorage.setItem(Bt(e),JSON.stringify(n))}catch{return}Kt()}function Kt(){try{let e=[];for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);if(!n?.startsWith(Rt))continue;let r=Ht(n)?.savedAt;e.push({key:n,savedAt:typeof r==`number`?r:0})}if(e.length<=zt)return;e.sort((e,t)=>e.savedAt-t.savedAt);for(let{key:t}of e.slice(0,e.length-zt))window.localStorage.removeItem(t)}catch{}}function qt(e){let[t,n]=(0,N.useState)(()=>Ut(e)),r=(0,N.useRef)(e);return(0,N.useEffect)(()=>{if(r.current!==e){r.current=e,n(Ut(e));return}Gt(e,t)},[e,t]),{state:t,setDockTree:(0,N.useCallback)(e=>{n(t=>t.dockTree===e?t:{...t,dockTree:e})},[]),setSimulatorAlignment:(0,N.useCallback)(e=>{n(t=>t.simulatorAlignment===e?t:{...t,simulatorAlignment:e})},[]),setDevtoolsPosition:(0,N.useCallback)(e=>{n(t=>t.devtoolsPosition===e?t:{...t,devtoolsPosition:e})},[])}}var P=r(),Jt={compiling:`bg-status-warn animate-[pulse_1s_infinite]`,ready:`bg-accent`,error:`bg-status-error`};function Yt({status:e}){return(0,P.jsx)(`span`,{className:ge(`w-1.5 h-1.5 rounded-full shrink-0`,Jt[e]??`bg-border`)})}var Xt=400,Zt=null;function Qt(e,t,n){Zt=e,re({anchor:{x:n.x,y:n.y,width:n.width,height:n.height},text:t})}function $t(e){Zt===e&&(Zt=null,ae())}function en(e){let t=(0,N.useRef)(null),n=(0,N.useRef)(void 0),r=(0,N.useRef)(Symbol(`overlay-tooltip-owner`));function i(){window.clearTimeout(n.current),n.current=window.setTimeout(()=>{let n=t.current;n&&Qt(r.current,e,n.getBoundingClientRect())},Xt)}function a(){window.clearTimeout(n.current),$t(r.current)}return(0,N.useEffect)(()=>a,[]),{ref:t,onMouseEnter:i,onMouseLeave:a}}function tn(){let e=new Map;return{register(t){return e.set(t.id,t),{dispose(){e.get(t.id)===t&&e.delete(t.id)}}},get(t){return e.get(t)},list(){return[...e.values()]}}}var nn=64;function rn(e){return JSON.stringify(e)}function an(e,t,n,r){e===void 0?r.push(`node missing string id (kind=${String(t)})`):n.seenIds.has(e)?r.push(`duplicate node id: ${e}`):n.seenIds.add(e)}function on(e,t,n,r){if(typeof e!=`string`){r.push(`tabs ${t??`?`}: non-string panel id`);return}n.panelOwners.get(e)===void 0?n.panelOwners.set(e,t??`?`):r.push(`duplicate panel id across groups: ${e}`),n.knownPanelIds&&!n.knownPanelIds.has(e)&&r.push(`orphan panel not in known panel ids: ${e}`)}function sn(e,t,n,r){let i=e,a=Array.isArray(i.panels)?i.panels:null;if(!a){r.push(`tabs ${t??`?`}: panels is not an array`);return}a.length===0&&r.push(`tabs ${t??`?`}: empty tabgroup`);for(let e of a)on(e,t,n,r);let o=i.active;(typeof o!=`string`||!a.includes(o))&&r.push(`tabs ${t??`?`}: active ${String(o)} not in panels`)}function cn(e,t,n){if(e===null)return!1;if(typeof e!=`object`)return n.push(`split ${t??`?`}: constraint is not null nor an object: ${String(e)}`),!1;let r=Object.keys(e),i=r.includes(`fixedPx`),a=r.includes(`minPx`);(r.length!==1||!(i||a))&&n.push(`split ${t??`?`}: constraint must have exactly one of 'fixedPx' or 'minPx', got [${r.join(`, `)}]`);let o=i?`fixedPx`:`minPx`,s=i?e.fixedPx:e.minPx;return(typeof s!=`number`||!Number.isFinite(s)||s<=0)&&n.push(`split ${t??`?`}: constraint ${o} must be a finite number > 0, got ${String(s)}`),!0}function ln(e,t,n){let r=Array.isArray(e)?e:null;if(!r){n.push(`split ${t??`?`}: constraints is not an array`);return}let i=r.length>0;for(let e of r)cn(e,t,n)||(i=!1);i&&n.push(`split ${t??`?`}: all children are px-sized constraints; at least one must be weight-sized`)}function un(e,t,n,r){if(!e||e.length!==t.length){r.push(`split ${n??`?`}: sizes ${e?e.length:`missing`} != children ${t.length}`);return}for(let t of e)(typeof t!=`number`||!Number.isFinite(t))&&r.push(`split ${n??`?`}: non-finite size ${String(t)}`)}function dn(e,t){let n=[],r={seenIds:new Set,seenObjects:new Set,panelOwners:new Map,knownPanelIds:t},i=(e,t,a)=>{if(t>nn){n.push(`depth exceeds ${nn}`);return}if(typeof e!=`object`||!e){n.push(`node is not an object: ${String(e)}`);return}let o=e;if(a.has(o)){n.push(`cycle detected: node reachable from itself`);return}if(r.seenObjects.has(o)){n.push(`shared node reference: same object appears twice`);return}r.seenObjects.add(o);let s=e,c=s.kind,l=typeof s.id==`string`?s.id:void 0;an(l,c,r,n),c===`tabs`?sn(e,l,r,n):c===`split`?fn(e,l,t,a,o,r,n,i):n.push(`unknown node kind: ${String(c)}`)};return i(e,0,new Set),n}function fn(e,t,n,r,i,a,o,s){let c=e,l=Array.isArray(c.children)?c.children:null,u=Array.isArray(c.sizes)?c.sizes:null,d=c.orientation;if(d!==`row`&&d!==`column`&&o.push(`split ${t??`?`}: invalid orientation ${String(d)}`),c.constraints!==void 0&&ln(c.constraints,t,o),!l){o.push(`split ${t??`?`}: children is not an array`);return}if(l.length<2&&o.push(`split ${t??`?`}: must have >= 2 children, has ${l.length}`),un(u,l,t,o),c.constraints!==void 0&&Array.isArray(c.constraints)){let e=c.constraints;e.length!==l.length&&o.push(`split ${t??`?`}: constraints ${e.length} != children ${l.length}`)}let f=new Set(r);f.add(i);for(let e of l)s(e,n+1,f)}function pn(e,t){return typeof e!=`object`||!e?[`tree is not an object`]:e.version===1?dn(e.root,t):[`unsupported version: ${String(e.version)}`]}function mn(e){let t;try{t=JSON.parse(e)}catch{throw Error(`parseLayout: input is not valid JSON`)}if(typeof t!=`object`||!t)throw Error(`parseLayout: top-level value is not an object`);let n=t;if(n.version!==1)throw Error(`parseLayout: unsupported version ${String(n.version)}`);if(n.root===void 0||n.root===null)throw Error(`parseLayout: missing root`);let r=dn(n.root,null);if(r.length>0)throw Error(`parseLayout: illegal layout — ${r.join(`; `)}`);return{version:1,root:n.root}}var hn=1;function gn(e,t){return(e.constraints?.[t]??null)===null}function _n(e){if(e.kind===`tabs`)return e;let t=e.children.map(_n),n=t.some((t,n)=>t!==e.children[n]),r=e.sizes.map((t,r)=>!gn(e,r)||typeof t==`number`&&Number.isFinite(t)&&t>0?t:(n=!0,hn));if(!n)return e;let i={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:r};return e.constraints===void 0?i:{...i,constraints:e.constraints}}function vn(e){let t=_n(e.root);return t===e.root?e:{version:1,root:t}}function yn(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.id===t&&(n=e):e.children.forEach(r))};return r(e),n}function bn(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.panels.includes(t)&&(n=e):e.children.forEach(r))};return r(e),n}function xn(e,t){return bn(e,t)?.id}function Sn(e){return e.kind===`tabs`?e.panels.length:e.children.reduce((e,t)=>e+Sn(t),0)}function F(e,t,n){return{kind:`tabs`,id:e,panels:t,active:n}}function Cn(e,t,n){if(e.length===0)return``;if(e.includes(t))return t;let r=Math.min(n,e.length-1);return e[Math.max(0,r)]}function wn(e){if(e.kind===`tabs`)return e.panels.length===0?null:e;let t=[],n=[],r=[],i=e.constraints!==void 0;if(e.children.forEach((a,o)=>{let s=wn(a);s!==null&&(t.push(s),n.push(e.sizes[o]??1),i&&r.push(e.constraints[o]??null))}),t.length===0)return null;if(t.length===1)return t[0];let a={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:n};return i?(r.length>0&&!r.some(e=>e===null)&&(r[r.length-1]=null),{...a,constraints:r}):a}function I(e){let t=wn(e);if(t===null)throw Error(`mutation would empty the entire layout`);return t}function Tn(e){let t=new Set,n=e=>{if(e.kind===`tabs`)for(let n of e.panels)t.add(n);else e.children.forEach(n)};return n(e),t}function En(e,t){return Tn(e).has(t)}function Dn(e){let t=new Set,n=e=>{t.add(e.id),e.kind===`split`&&e.children.forEach(n)};return n(e),t}function L(e,t){let n=t,r=2;for(;e.has(n);)n=`${t}#${r}`,r+=1;return e.add(n),n}function On(e,t){let n=null,r=e=>{n||e.kind===`split`&&(e.id===t&&(n=e),e.children.forEach(r))};return r(e),n}function R(e,t,n){if(e.id===t)return n;if(e.kind===`tabs`)return F(e.id,[...e.panels],e.active);let r={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(e=>R(e,t,n)),sizes:[...e.sizes]};return e.constraints===void 0?r:{...r,constraints:[...e.constraints]}}function kn(e){if(e.kind===`tabs`)return F(e.id,[...e.panels],e.active);let t={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(kn),sizes:[...e.sizes]};return e.constraints===void 0?t:{...t,constraints:[...e.constraints]}}function z(e){return{version:1,root:e}}function An(e,t,n){let r=On(e.root,t);if(!r)throw Error(`setSizes: split not found: ${t}`);if(n.length!==r.children.length)throw Error(`setSizes: sizes length ${n.length} != children length ${r.children.length}`);if(!n.every(e=>Number.isFinite(e)))throw Error(`setSizes: every size must be a finite number, got [${n.join(`, `)}]`);let i={kind:`split`,id:r.id,orientation:r.orientation,children:r.children.map(kn),sizes:[...n]},a=r.constraints===void 0?i:{...i,constraints:[...r.constraints]};return z(R(e.root,t,a))}function jn(e,t,n,r){let i=On(e.root,t);if(!i)throw Error(`setConstraint: split not found: ${t}`);if(!Number.isInteger(n))throw Error(`setConstraint: childIndex must be an integer, got ${n}`);if(n<0||n>=i.children.length)throw Error(`setConstraint: childIndex ${n} out of range [0, ${i.children.length})`);let a=i.constraints===void 0?i.children.map(()=>null):[...i.constraints];if(a[n]=r,a.length>0&&a.every(e=>e!==null))return e;let o={kind:`split`,id:i.id,orientation:i.orientation,children:i.children.map(kn),sizes:[...i.sizes],constraints:a};return z(R(e.root,t,o))}function Mn(e,t,n){let r=yn(e.root,t);if(!r)throw Error(`setActive: group not found: ${t}`);if(!r.panels.includes(n))throw Error(`setActive: panel ${n} not in group ${t}`);let i=F(r.id,[...r.panels],n);return z(R(e.root,t,i))}function Nn(e,t){let n=bn(e,t);if(!n)throw Error(`panel not found: ${t}`);let r=n.panels.indexOf(t),i=n.panels.filter(e=>e!==t),a=F(n.id,i,Cn(i,n.active,r));return I(R(e,n.id,a))}function Pn(e,t){let n=Tn(e.root);return n.size===1&&n.has(t)?e:z(Nn(e.root,t))}function Fn(e,t){if(!bn(e.root,t))throw Error(`extractPanel: panel not found: ${t}`);return{tree:z(Nn(e.root,t)),extracted:t}}function In(e,t,n){if(En(e.root,t))throw Error(`insertPanel: panel already exists in the tree: ${t}`);let r=yn(e.root,n.groupId);if(!r)throw Error(`insertPanel: dest group not found: ${n.groupId}`);let i=[...r.panels],a=Ln(n.index,i.length);i.splice(a,0,t);let o=F(r.id,i,r.active);return z(I(R(e.root,r.id,o)))}function Ln(e,t){return e===void 0?t:e<0?0:e>t?t:e}function Rn(e,t,n){let r=bn(e.root,t);if(!r)throw Error(`movePanel: panel not found: ${t}`);let i=yn(e.root,n.groupId);if(!i)throw Error(`movePanel: dest group not found: ${n.groupId}`);if(r.id===i.id){let i=r.panels.filter(e=>e!==t),a=Ln(n.index,i.length),o=[...i];o.splice(a,0,t);let s=F(r.id,o,r.active);return z(I(R(e.root,r.id,s)))}let a=r.panels.indexOf(t),o=r.panels.filter(e=>e!==t),s=F(r.id,o,Cn(o,r.active,a)),c=[...i.panels],l=Ln(n.index,c.length);c.splice(l,0,t);let u=F(i.id,c,i.active),d=R(e.root,r.id,s);return d=R(d,i.id,u),z(I(d))}function zn(e,t,n,r){if(En(e.root,t))throw Error(`wrapRoot: new panel already exists in the tree: ${t}`);let i=Dn(e.root),a=e.root.id,o=F(L(i,`${a}__new`),[t],t),s=kn(e.root),c=r===`after`?[s,o]:[o,s];return z({kind:`split`,id:L(i,`${a}__wrap`),orientation:n,children:c,sizes:[1,1]})}function Bn(e,t,n,r,i){if(En(e.root,r))throw Error(`splitGroup: new panel already exists in the tree: ${r}`);let a=yn(e.root,t);if(!a)throw Error(`splitGroup: group not found: ${t}`);let o=Dn(e.root),s=F(L(o,`${t}__new`),[r],r),c=kn(a),l=i===`after`?[c,s]:[s,c],u={kind:`split`,id:L(o,`${t}__sp`),orientation:n,children:l,sizes:[1,1]};return z(I(R(e.root,t,u)))}function B(e,t,n,r,i){if(En(e.root,r))throw Error(`splitPanel: new panel already exists in the tree: ${r}`);let a=bn(e.root,t);if(!a)throw Error(`splitPanel: panel not found: ${t}`);let o=Dn(e.root),s=a.id,c=F(L(o,`${s}__split`),[t],t),l=F(L(o,`${s}__new`),[r],r),u=i===`after`?[c,l]:[l,c],d={kind:`split`,id:L(o,`${s}__sp`),orientation:n,children:u,sizes:[1,1]};if(a.panels.length===1)return z(I(R(e.root,s,d)));let f=a.panels.indexOf(t),p=a.panels.filter(e=>e!==t),m=F(s,p,Cn(p,a.active,f)),h=i===`after`?[m,d]:[d,m],g={kind:`split`,id:L(o,`${s}__outer`),orientation:n,children:h,sizes:[1,1]};return z(I(R(e.root,s,g)))}function Vn(e){let t=structuredClone(e),n=0,r=new Set,i=!1,a=[],o=e=>{let i=e(t);if(i===t)return;t=i,n+=1;let a={tree:t,revision:n};for(let e of[...r])try{e(a)}catch{}};return{get(){return t},apply(e){if(i){a.push(e);return}i=!0;try{for(o(e);a.length>0;){let e=a.shift();try{o(e)}catch{}}}finally{i=!1}},subscribe(e){return r.add(e),()=>{r.delete(e)}}}}function Hn(e,t,n){return n.get(t)?.closable===!1?e:Pn(e,t)}var Un=`dock-root`;function Wn(){let e=tn();return e.register({kind:`dom`,id:`simulator`,title:`Simulator`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`editor`,title:`Editor`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`wxml`,title:`WXML`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`appdata`,title:`AppData`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`storage`,title:`Storage`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`native`,id:`console`,title:`Console`,nativeRef:{id:`console`},dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`compile`,title:`编译`,dropPolicy:`reorder-only`,closable:!1}),e}function Gn(e){return{version:1,root:{kind:`split`,id:Un,orientation:`row`,sizes:[1,6],constraints:[{minPx:e},null],children:[{kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`},{kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`}]}}}var Kn={kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`},qn=()=>({kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`}),Jn=()=>({kind:`tabs`,id:`g-editor`,panels:[`editor`],active:`editor`}),Yn=()=>({...Kn,panels:[...Kn.panels]});function Xn(e,t,n,r){return{version:1,root:{kind:`split`,id:Un,orientation:`row`,sizes:e.map((e,t)=>r[t]??1),constraints:e.map((e,r)=>r===t?{minPx:n}:null),children:e}}}function Zn(e,t,n){let r=t===`left`;if(n===`belowSimulator`){let t={kind:`split`,id:`col-sim`,orientation:`column`,sizes:[60,40],children:[qn(),Yn()]};return r?Xn([t,Jn()],0,e,[1,6]):Xn([Jn(),t],1,e,[6,1])}if(n===`rightOfSimulator`)return r?Xn([qn(),Yn(),Jn()],0,e,[1,4,5]):Xn([Jn(),Yn(),qn()],2,e,[5,4,1]);let i={kind:`split`,id:`col-main`,orientation:`column`,sizes:[70,30],children:[Jn(),Yn()]};return r?Xn([qn(),i],0,e,[1,6]):Xn([i,qn()],1,e,[6,1])}function Qn(e,t,n){return Vn($n(e,t,n))}function $n(e,t,n){if(e===null)return Gn(t);try{let r=mn(e);if(pn(r,n).length===0)return er(vn(tr(r)),t)}catch{}return Gn(t)}function er(e,t){let n=ar(e);return rr.some(e=>n.has(e))?rr.reduce((e,r)=>n.has(r)?e:ur(e,r,t),e):e}function tr(e){return{...e,root:nr(e.root,`root`,Un)}}function nr(e,t,n){return e.kind===`tabs`?e:{...e,id:e.id===t?n:e.id,children:e.children.map(e=>nr(e,t,n))}}var rr=[`wxml`,`appdata`,`storage`,`console`,`compile`];function ir(e,t){if(e.kind===`tabs`){for(let n of e.panels)t.add(n);return}for(let n of e.children)ir(n,t)}function ar(e){let t=new Set;return ir(e.root,t),t}function or(e,t){if(e.kind===`tabs`)return e.panels.includes(t)?e.id:void 0;for(let n of e.children){let e=or(n,t);if(e!==void 0)return e}}function sr(e,t){return t.find(t=>e.has(t))}function cr(e,t){if(e.kind===`tabs`)return null;for(let n=0;n<e.children.length;n++){if(e.children[n].id===t)return{splitId:e.id,childIndex:n};let r=cr(e.children[n],t);if(r)return r}return null}function lr(e,t){let n=or(e.root,`simulator`);if(!n)return e;let r=cr(e.root,n);return r?jn(e,r.splitId,r.childIndex,{minPx:t}):e}function ur(e,t,n){let r=ar(e);if(r.has(t))return e;if(rr.includes(t)){let n=rr.find(e=>e!==t&&r.has(e));return n?In(e,t,{groupId:or(e.root,n)}):r.has(`editor`)?B(e,`editor`,`column`,t,`after`):r.has(`simulator`)?B(e,`simulator`,`row`,t,`after`):B(e,[...r][0],`column`,t,`after`)}if(t===`editor`){let t=sr(r,rr);return t?Bn(e,or(e.root,t),`column`,`editor`,`before`):r.has(`simulator`)?B(e,`simulator`,`row`,`editor`,`after`):B(e,[...r][0],`column`,`editor`,`before`)}return t===`simulator`?lr(zn(e,`simulator`,`row`,`before`),n):B(e,[...r][0],`column`,t,`after`)}function dr(e,t){let n=ar(e);return t.list().map(e=>({id:e.id,title:e.title??e.id,open:n.has(e.id)}))}var fr=rr;function pr({model:e,registry:t,simPanelWidth:n}){let[,r]=(0,N.useState)(0);(0,N.useEffect)(()=>e.subscribe(()=>r(e=>e+1)),[e]);let i=new Set(dr(e.get(),t).filter(e=>e.open).map(e=>e.id)),a=i.has(`simulator`),o=i.has(`editor`),s=fr.some(e=>i.has(e)),c=[a,o,s].filter(Boolean).length;function l(r,i){e.apply(e=>i?Hn(e,r,t):ur(e,r,n))}function u(){if(s){let t=fr.filter(e=>i.has(e));e.apply(e=>t.reduce((e,t)=>Pn(e,t),e))}else{let t=fr.filter(e=>!i.has(e));e.apply(e=>t.reduce((e,t)=>ur(e,t,n),e))}}return(0,P.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`面板可见性`,children:[(0,P.jsx)(gr,{active:a,disabled:a&&c===1,onClick:()=>l(`simulator`,a),label:a?`隐藏模拟器`:`显示模拟器`,testId:`layout-toolbar-toggle-simulator`,icon:(0,P.jsx)(_e,{className:`size-3.5`})}),(0,P.jsx)(gr,{active:o,disabled:o&&c===1,onClick:()=>l(`editor`,o),label:o?`隐藏编辑器`:`显示编辑器`,testId:`layout-toolbar-toggle-editor`,icon:(0,P.jsx)(je,{className:`size-3.5`})}),(0,P.jsx)(gr,{active:s,disabled:s&&c===1,onClick:u,label:s?`隐藏调试器`:`显示调试器`,testId:`layout-toolbar-toggle-debug`,icon:(0,P.jsx)(ke,{className:`size-3.5`})})]})}function mr({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state,a=r===`left`;function o(){let r=a?`right`:`left`;t.setSimulatorAlignment(r),e.apply(()=>Zn(n,r,i))}let s=a?`模拟器位置:左侧(点击切换到右侧)`:`模拟器位置:右侧(点击切换到左侧)`;return(0,P.jsx)(A,{variant:`toolbar`,size:`icon`,onClick:o,"aria-label":s,"data-testid":`layout-toolbar-alignment-toggle`,"data-alignment":r,...en(s),children:a?(0,P.jsx)(Me,{className:`size-3.5`}):(0,P.jsx)(Ne,{className:`size-3.5`})})}function hr({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state;function a(i){t.setDevtoolsPosition(i),e.apply(()=>Zn(n,r,i))}return(0,P.jsx)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`调试器位置`,children:[{id:`inEditor`,label:`调试器位置:在编辑器面板中`},{id:`belowSimulator`,label:`调试器位置:在模拟器下方`},{id:`rightOfSimulator`,label:`调试器位置:在模拟器右侧`}].map(e=>(0,P.jsx)(gr,{active:i===e.id,onClick:()=>a(e.id),label:e.label,testId:`layout-toolbar-devtools-${e.id}`,icon:(0,P.jsx)(_r,{variant:e.id})},e.id))})}function gr({active:e,disabled:t,onClick:n,label:r,testId:i,icon:a}){let o=en(r);return(0,P.jsx)(A,{variant:`toolbar`,size:`icon`,onClick:n,disabled:t,"aria-label":r,"aria-pressed":e,"data-testid":i,"data-active":e?`true`:`false`,...o,children:a})}function _r({variant:e}){return e===`inEditor`?(0,P.jsxs)(`svg`,{className:`size-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,P.jsx)(`line`,{x1:`9`,y1:`3`,x2:`9`,y2:`21`}),(0,P.jsx)(`path`,{d:`M9 15h12`}),(0,P.jsx)(`rect`,{x:`9`,y:`15`,width:`12`,height:`6`,fill:`currentColor`,stroke:`none`})]}):e===`belowSimulator`?(0,P.jsxs)(`svg`,{className:`size-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,P.jsx)(`line`,{x1:`12`,y1:`3`,x2:`12`,y2:`21`}),(0,P.jsx)(`path`,{d:`M3 15h9`}),(0,P.jsx)(`rect`,{x:`3`,y:`15`,width:`9`,height:`6`,fill:`currentColor`,stroke:`none`})]}):(0,P.jsxs)(`svg`,{className:`size-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`}),(0,P.jsx)(`line`,{x1:`9`,y1:`3`,x2:`9`,y2:`21`}),(0,P.jsx)(`line`,{x1:`15`,y1:`3`,x2:`15`,y2:`21`}),(0,P.jsx)(`rect`,{x:`9`,y:`3`,width:`6`,height:`18`,fill:`currentColor`,stroke:`none`})]})}function vr(){return(0,P.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`,"aria-hidden":`true`})}function yr({compileDropdownRef:e,showCompilePanel:t,onToggleCompilePanel:n,compileModeLabel:r,compileModesReady:i,onRelaunch:a,compileStatus:o,dockModel:s,dockRegistry:c,layout:l,simPanelWidth:u}){N.useEffect(()=>{ee()},[]);let d=en(`重新编译`),f=en(`设置`);return(0,P.jsx)(`div`,{className:`flex flex-col shrink-0`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 bg-surface-2 border-b border-border shrink-0`,style:{height:40},children:[(0,P.jsx)(`div`,{ref:e,children:(0,P.jsxs)(A,{variant:`toolbar`,onClick:n,disabled:!i,"data-active":t?`true`:`false`,"data-testid":`compile-mode-button`,className:`h-7 gap-0.5 pl-2 pr-1.5 text-[13px] text-text-secondary max-w-40`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:r}),(0,P.jsx)(Ae,{className:`size-3.5 shrink-0`})]})}),(0,P.jsx)(vr,{}),(0,P.jsx)(A,{variant:`toolbar`,size:`icon`,className:`size-7 rounded-[var(--qd-radius-md)]`,onClick:()=>{a()},disabled:o.status===`compiling`,"aria-label":`重新编译`,...d,children:(0,P.jsx)(Pe,{className:`size-3.5`})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 shrink-0`,children:[(0,P.jsx)(Yt,{status:o.status}),(0,P.jsx)(`span`,{"data-testid":`compile-status-message`,className:`text-[12px] text-text-secondary max-w-28 truncate`,children:o.message})]}),(0,P.jsx)(`div`,{className:`flex-1 min-w-2`}),(0,P.jsx)(pr,{model:s,registry:c,simPanelWidth:u}),(0,P.jsx)(vr,{}),(0,P.jsx)(mr,{model:s,layout:l,simPanelWidth:u}),(0,P.jsx)(vr,{}),(0,P.jsx)(hr,{model:s,layout:l,simPanelWidth:u}),(0,P.jsx)(vr,{}),(0,P.jsx)(A,{variant:`toolbar`,size:`icon`,className:`size-7 rounded-[var(--qd-radius-md)]`,onClick:()=>{he(!0)},"aria-label":`设置`,...f,children:(0,P.jsx)(Fe,{className:`size-3.5`})})]})})}function br(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function xr(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Sr(e){return e/100*window.innerHeight}function Cr(e){return e/100*window.innerWidth}function wr(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Tr({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=wr(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=xr(t,i);break;case`em`:r=br(t,i);break;case`vh`:r=Sr(i);break;case`vw`:r=Cr(i);break}return r}function V(e){return parseFloat(e.toFixed(3))}function Er({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Dr(e){let{panels:t}=e,n=Er({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=V(Tr({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=V(Tr({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=V(Tr({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=V(Tr({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function H(e,t=`Assertion error`){if(!e)throw Error(t)}function Or(e,t){return Array.from(t).sort(e===`horizontal`?kr:Ar)}function kr(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Ar(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function jr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Mr(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Nr({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Mr(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return H(i,`No rect found`),i}var Pr;function Fr(){return Pr===void 0&&(Pr=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Pr}function Ir(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Or(n,Array.from(t.children).filter(jr).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Nr({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Fr()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Er({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Lr=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},U=new Map,Rr=new Lr;function zr(e){U=new Map(U),U.delete(e)}function Br(e,t){for(let[t]of U)if(t.id===e)return t}function W(e,t){for(let[t,n]of U)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function G(){return U}function Vr(e,t){return Rr.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function K(e,t){let n=U.get(e);U=new Map(U),U.set(e,t),Rr.emit(`groupChange`,{group:e,prev:n,next:t})}function Hr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Mr(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Ur(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Wr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Xr(e),b:Xr(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();H(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Yr(Jr(n.a)),b:Yr(Jr(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Gr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Kr(e){let t=getComputedStyle(Zr(e)??e).display;return t===`flex`||t===`inline-flex`}function qr(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Kr(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Gr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Jr(e){let t=e.length;for(;t--;){let n=e[t];if(H(n,`Missing node`),qr(n))return n}return null}function Yr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Xr(e){let t=[];for(;e;)t.push(e),e=Zr(e);return t}function Zr(e){let{parentNode:t}=e;return Ur(t)?t.host:t}function Qr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function $r({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!jr(n)||n.contains(e)||e.contains(n))return!0;if(Wr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Qr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function ei(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Ir(r),a=Hr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&$r({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function ti(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function q(e,t,n=0){return Math.abs(V(e)-V(t))<=n}function J(e,t){return q(e,t)?0:e>t?1:-1}function ni({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(J(r,c)<0)if(a){let e=(i+c)/2;r=J(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=V(r),r}function ri({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(q(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;H(u!=null,`Invalid first pivot index`),H(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];H(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(H(n!=null,`Previous layout not found for panel index ${t}`),q(n,i)){let t=o-n;J(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];H(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(H(n!=null,`Previous layout not found for panel index ${t}`),q(n,o)){let t=n-i;J(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];H(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&J(i,c)<0)if(e>0){let t=c-o,n=t/2;J(i+e,c)<0&&(e=J(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;J(i-e,c)<0&&(e=J(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];H(e!=null,`Previous layout not found for panel index ${r}`);let a=ni({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];H(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=ni({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!q(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(ti(c,l))return i;{let t=e<0?d:u,r=s[t];H(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=ni({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!q(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];H(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=ni({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(q(i,s)||(t-=s-i,l[r]=s),q(t,0))break;e>0?r--:r++}}}if(!q(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Y(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||J(e[n],t[n])!==0)return!1;return!0}function X({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!q(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];H(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];H(i!=null,`No layout data found for index ${e}`);let o=r[e];H(o!=null,`No layout data found for index ${e}`);let s=ni({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!q(a,0))for(let e=0;e<t.length;e++){let n=r[e];H(n!=null,`No layout data found for index ${e}`);let i=n+a,o=ni({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,q(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function ii({groupId:e,panelId:t}){let n=()=>{let t=G();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=X({layout:ri({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});Y(l,p)||K(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&q(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Er({group:t});o(V(Tr({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function ai(e){e.defaultPrevented||ei(e,G()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=ii({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function oi(e){let t=G();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function si({groupId:e}){let t=()=>{let t=G();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=X({layout:e,panelConstraints:r});return n?o:(Y(o,c)||K(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Z(e,t){let n=oi(e),r=W(n.id,!0),i=n.separators.find(t=>t.element===e);H(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);H(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=si({groupId:n.id}).getLayout(),c=X({layout:ri({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Y(s,c)||K(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function ci(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=oi(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Z(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Z(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Z(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Z(t,-5);break;case`End`:e.preventDefault(),Z(t,100);break;case`Enter`:{e.preventDefault();let n=oi(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=W(n.id,!0),o=n.separators.find(e=>e.element===t);H(o,`Matching separator not found`);let s=a.get(o);H(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(H(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Z(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=oi(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);H(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Z(t,-100);break}}var li={cursorFlags:0,state:`inactive`},ui=new Lr;function Q(){return li}function di(e){return ui.addListener(`change`,e)}function fi(e){let t=li,n={...li};n.cursorFlags=e,li=n,ui.emit(`change`,{prev:t,next:n})}function pi(e){let t=li;li=e,ui.emit(`change`,{prev:t,next:e})}function mi(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=G(),n=ei(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),pi({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var hi=e=>e,gi=()=>{},_i=1,vi=2,yi=4,bi=8,xi=3,Si=12,Ci;function wi(){return Ci===void 0&&(Ci=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Ci=!0)),Ci}function Ti({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&wi()){let t=(e&_i)!==0,n=(e&vi)!==0,r=(e&yi)!==0,i=(e&bi)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return wi()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Ei=new WeakMap;function Di(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Ei.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Q();switch(r.state){case`active`:case`hover`:{let e=Ti({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}Ei.set(e,{prevStyle:t,styleSheet:n})}function Oi({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=ri({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Y(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?_i:vi;break;case`vertical`:s|=d<0?yi:bi;break}}else K(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&xi:c|=s&xi,t.movementY===0?c|=o&Si:c|=s&Si,fi(c),Di(e)}function ki(e){let t=G(),n=Q();switch(n.state){case`active`:Oi({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Ai(e){if(e.defaultPrevented)return;let t=Q(),n=G();switch(t.state){case`active`:if(e.buttons===0){pi({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=W(e.group.id,!0);K(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}Oi({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=ei(e,n);r.length===0?t.state!==`inactive`&&pi({cursorFlags:0,state:`inactive`}):pi({cursorFlags:0,hitRegions:r,state:`hover`}),Di(e.currentTarget);break}}}function ji(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Q().state){case`hover`:pi({cursorFlags:0,state:`inactive`})}}function Mi(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Q();switch(t.state){case`active`:pi({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Di(e.currentTarget),t.hitRegions.forEach(e=>{let t=W(e.group.id,!0);K(e.group,t)}),e.preventDefault())}}function Ni(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=V(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=V((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Pi(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Er({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:V(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Fi(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ii({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=V(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=V((r[e]??0)/a*l);else{let e=V(l/c.length);for(let t of c)u[t]=e}return u}function Li(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var Ri=new Map;function zi(e){let t=!0;H(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Er({group:e});if(t===0)return;let n=W(e.id);if(!n)return;let r=Dr(e),i=n.defaultLayoutDeferred?Ni(r):n.layout,a=X({layout:Ii({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Y(n.layout,a)&&Fi(n.derivedPanelConstraints,r)&&n.groupSize===t)return;K(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else Pi(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{H(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Er({group:e}),s=Dr(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Li(e.panels,l)||(l=void 0));let u=X({layout:e.mutableState.layouts[c]??l??Ni(s),panelConstraints:s}),d=e.element.ownerDocument;Ri.set(d,(Ri.get(d)??0)+1);let f=new Map;return Ir(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),K(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{H(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,ci)}),Ri.get(d)===1&&(d.addEventListener(`dblclick`,ai,!0),d.addEventListener(`pointerdown`,mi,!0),d.addEventListener(`pointerleave`,ki),d.addEventListener(`pointermove`,Ai),d.addEventListener(`pointerout`,ji),d.addEventListener(`pointerup`,Mi,!0)),function(){t=!1,Ri.set(d,Math.max(0,(Ri.get(d)??0)-1)),zr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ci)}),Ri.get(d)||(d.removeEventListener(`dblclick`,ai,!0),d.removeEventListener(`pointerdown`,mi,!0),d.removeEventListener(`pointerleave`,ki),d.removeEventListener(`pointermove`,Ai),d.removeEventListener(`pointerout`,ji),d.removeEventListener(`pointerup`,Mi,!0)),a.disconnect()}}function Bi(){let[e,t]=(0,N.useState)({});return[e,(0,N.useCallback)(()=>t({}),[])]}function Vi(e){let t=(0,N.useId)();return`${e??t}`}var $=typeof window<`u`?N.useLayoutEffect:N.useEffect;function Hi(e){let t=(0,N.useRef)(e);return $(()=>{t.current=e},[e]),(0,N.useCallback)((...e)=>t.current?.(...e),[t])}function Ui(...e){return Hi(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function Wi(e){let t=(0,N.useRef)({...e});return $(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Gi=(0,N.createContext)(null);function Ki(e,t){let n=(0,N.useRef)({getLayout:()=>({}),setLayout:hi});(0,N.useImperativeHandle)(t,()=>n.current,[]),$(()=>{Object.assign(n.current,si({groupId:e}))})}function qi({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,N.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Hi(e=>{Y(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Hi(e=>{Y(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=Vi(s),v=(0,N.useRef)(null),[y,b]=Bi(),x=(0,N.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Ui(v,a);Ki(_,o);let C=Hi((e,t)=>{let r=Q(),i=Br(e),a=W(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=Wi({defaultLayout:n,disableCursor:r}),T=(0,N.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Or(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Or(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Br(_),i=W(_);r&&i&&K(r,{...i,derivedPanelConstraints:Dr(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,N.useRef)(null);return $(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=zi(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=W(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=Vr(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=q(t.collapsedSize,i[t.panelId]),a=q(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Q().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,N.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,P.jsx)(Gi.Provider,{value:T,children:(0,P.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}qi.displayName=`Group`;function Ji(){let e=(0,N.useContext)(Gi);return H(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Yi(e,t){let{id:n}=Ji(),r=(0,N.useRef)({collapse:gi,expand:gi,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:gi});(0,N.useImperativeHandle)(t,()=>r.current,[]),$(()=>{Object.assign(r.current,ii({groupId:n,panelId:e}))})}function Xi({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=Vi(c),_=Wi({disabled:a}),v=(0,N.useRef)(null),y=Ui(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Ji(),T=d!==null,E=Hi((e,t,n)=>{d?.(e,c,n)});$(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,N.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Yi(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,N.useSyncExternalStore)(e=>Vr(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,P.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Zi,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,P.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Xi.displayName=`Panel`;var Zi={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Qi({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=X({layout:ri({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=X({layout:ri({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function $i({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=Vi(a),l=Wi({disabled:n,disableDoubleClick:r}),[u,d]=(0,N.useState)({}),[f,p]=(0,N.useState)(`inactive`),[m,h]=(0,N.useState)(!1),g=(0,N.useRef)(null),_=Ui(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Ji(),C=b===`horizontal`?`vertical`:`horizontal`;$(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=di(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Vr(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Qi({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,N.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,P.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}$i.displayName=`Separator`;function ea(e,t,n,r){return!(e>0)||!(t>0)||!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)}function ta(e){return Number.isFinite(e)?Math.max(0,Math.min(.5,e)):.25}function na(e,t,n,r){let i=n<0?n:n>e?n-e:0,a=r<0?r:r>t?r-t:0;if(i===0&&a===0)return;let o=Math.abs(i);return o>=Math.abs(a)&&o>0?i<0?`left`:`right`:a<0?`top`:`bottom`}function ra(e,t,n,r,i){let a=i*Math.min(e,t),o=n<a,s=n>e-a,c=r<a,l=r>t-a;return{inLeft:o,inTop:c,activeHoriz:o||s,activeVert:c||l}}function ia(e,t,n,r,i,a){return(i?n/e:(e-n)/e)<=(a?r/t:(t-r)/t)?i?`left`:`right`:a?`top`:`bottom`}function aa(e,t,n,r,i){let{inLeft:a,inTop:o,activeHoriz:s,activeVert:c}=ra(e,t,n,r,i);return!s&&!c?`center`:s&&!c?a?`left`:`right`:c&&!s?o?`top`:`bottom`:ia(e,t,n,r,a,o)}function oa(e,t,n=.25){let{width:r,height:i}=e,{x:a,y:o}=t;if(ea(r,i,a,o))return`center`;let s=ta(n),c=na(r,i,a,o);return c===void 0?aa(r,i,a,o,s):c}function sa(e,t,n){if(e===`center`)return{kind:`move`,panelId:t,destGroupId:n.groupId};let r=e===`left`||e===`right`?`row`:`column`,i=e===`left`||e===`top`?`before`:`after`;return{kind:`split`,atPanelId:n.panelId,dir:r,side:i,newPanelId:t}}function ca(e,t,n,r){return e===n.panelId||r===`center`&&t!==void 0&&t===n.groupId}function la(e,t){if(!Number.isFinite(t))return 0;let n=0;for(let r of e)if(t>=r.left+r.width/2)n+=1;else break;return n}function ua(e,t,n,r){let i=t.indexOf(n),a=i>=0&&r>i,o=t.filter(e=>e!==n),s=e.filter(e=>e!==n),c=a?r-1:r;if(c<0&&(c=0),c>o.length&&(c=o.length),c>=o.length)return s.length;let l=o[c],u=s.indexOf(l);return u>=0?u:s.length}var da=.5;function fa(e){let t=e.reduce((e,t)=>e+(t>0?t:0),0);if(t<=0){let t=e.length>0?100/e.length:100;return e.map(()=>t)}return e.map(e=>(e>0?e:0)/t*100)}function pa(e,t){let n=e.map((e,t)=>t).filter(e=>(t?.[e]??null)===null),r=fa(n.map(t=>e[t]??0)),i=new Map;return n.forEach((e,t)=>{i.set(e,r[t])}),i}function ma(e){return Math.min(1,Math.max(.5,Math.floor(90/Math.max(1,e))))}function ha(e,t){let n=e.filter((e,n)=>(t?.[n]??null)===null).length,r=ma(n);return e.map((e,n)=>(t?.[n]??null)===null?Number.isFinite(e)&&e>=r?e:r:e)}function ga(e,t,n,r=da){let i=new Set(n);for(let t of Object.keys(e))if(!i.has(t))return!1;for(let e of Object.keys(t))if(!i.has(e))return!1;for(let i of n){let n=e[i],a=t[i];if(!Number.isFinite(n)||!Number.isFinite(a)||Math.abs(n-a)>r)return!1}return!0}function _a(e,t,n,r,i){let a=e=>(n?.[e]??null)!==null,o=t=>{let a=n?.[t]??null;if(i&&i.containerPx>0&&a){if(a.fixedPx!=null)return a.fixedPx/i.containerPx*100;if(a.minPx!=null&&!i.trustLiveForMinPx)return a.minPx/i.containerPx*100}let o=r[e[t]];return typeof o==`number`?o:null},s=va(e,a,o);if(s===null)return null;let c=Math.max(0,100-s),l=0,u=0;for(let n=0;n<e.length;n++){if(a(n))continue;let e=t[n]??0;l+=e>0?e:0,u+=1}let d={};for(let n=0;n<e.length;n++){let r=e[n];d[r]=a(n)?o(n):ya(t[n]??0,c,l,u)}return d}function va(e,t,n){let r=0;for(let i=0;i<e.length;i++){if(!t(i))continue;let e=n(i);if(e===null)return null;r+=e}return r}function ya(e,t,n,r){return n<=0?r>0?t/r:t:t*(e>0?e:0)/n}function ba(e,t,n){let r=[],i=[];for(let a=0;a<e.length;a++){if((t?.[a]??null)!==null)continue;let o=n[e[a]];if(typeof o!=`number`||!Number.isFinite(o))return null;r.push(a),i.push(o>0?o:0)}return r.length===0?null:{indices:r,ratios:fa(i)}}function xa(e){let{node:t,ctx:n}=e,r=t.orientation===`row`?`horizontal`:`vertical`,i=pa(t.sizes,t.constraints),a=t.children.filter((e,n)=>(t.constraints?.[n]??null)===null).length,o=String(ma(a)),s=(0,N.useRef)(null),c=(0,N.useRef)(null),l=(0,N.useRef)(t);l.current=t;let u=[];t.children.forEach((e,r)=>{r>0&&u.push((0,P.jsx)($i,{"data-deck-resize-handle":``},`handle-${r}`));let a=t.constraints?.[r]??null;if(a?.fixedPx!=null){let t=`${a.fixedPx}px`;u.push((0,P.jsx)(Xi,{id:e.id,defaultSize:t,minSize:t,maxSize:t,groupResizeBehavior:`preserve-pixel-size`,children:Na(e,n)},Sa(e)))}else if(a?.minPx!=null){let t=`${a.minPx}px`;u.push((0,P.jsx)(Xi,{id:e.id,defaultSize:t,minSize:t,groupResizeBehavior:`preserve-pixel-size`,children:Na(e,n)},Sa(e)))}else{let t=i.get(r);u.push((0,P.jsx)(Xi,{id:e.id,defaultSize:t==null?void 0:String(t),minSize:o,children:Na(e,n)},Sa(e)))}});let d=e=>{let t=l.current,r=t.children.map(e=>e.id),i=e=>(t.constraints?.[e]??null)!==null,a=ba(r,t.constraints,e);if(!a)return;let o=pa(t.sizes,t.constraints),s=a.indices.map(e=>o.get(e)??0);if(!a.ratios.some((e,t)=>Math.abs(e-s[t])>.1))return;let c=r.map((n,r)=>i(r)?t.sizes[r]??1:e[n]);n.onApplyLayout(t.id,ha(c,t.constraints))},f=e=>{c.current=e,e&&(e.__deckApplyLayout=e=>{let t=l.current,r=e=>(t.constraints?.[e]??null)!==null,i=e.map((e,n)=>r(n)?t.sizes[n]??1:e);n.onApplyLayout(t.id,ha(i,t.constraints))},Object.defineProperty(e,`__deckGroupApi`,{configurable:!0,get:()=>s.current??void 0}))},p=(0,N.useCallback)(e=>{let t=s.current;if(!t)return{pushed:!1,stuck:!1};let n=l.current,r=n.children.map(e=>e.id),i=t.getLayout(),a=c.current?.getBoundingClientRect(),o=a?n.orientation===`row`?a.width:a.height:0,u=o>0?{containerPx:o,trustLiveForMinPx:!e}:void 0,d=_a(r,n.sizes,n.constraints,i,u);return d?ga(i,d,r)?{pushed:!1,stuck:!0}:(t.setLayout(d),{pushed:!0,stuck:ga(t.getLayout(),d,r)}):{pushed:!1,stuck:!1}},[]),m=t.sizes.join(`,`),h=t.children.length,g=(0,N.useRef)(null);return(0,N.useEffect)(()=>{let e=g.current!==h;if(g.current=h,!e){p(!1);return}let t=!1,n=0,r=0,i=()=>{if(t)return;r+=1;let{stuck:e}=p(!0);!e&&r<8&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{t=!0,cancelAnimationFrame(n)}},[m,h,p]),(0,P.jsx)(`div`,{ref:f,"data-deck-split":t.id,"data-orientation":t.orientation,"data-deck-sizes":t.sizes.join(`,`),style:{width:`100%`,height:`100%`},children:(0,P.jsx)(qi,{groupRef:s,orientation:r,onLayoutChanged:d,style:{width:`100%`,height:`100%`},children:u},t.children.length)})}function Sa(e){return e.id}function Ca(e,t){let n=e.active;return n?(0,P.jsxs)(N.Fragment,{children:[t.registry.get(n)?.kind===`native`?(0,P.jsx)(wa,{panelId:n,bindNativeSlot:t.bindNativeSlot},n):null,e.panels.filter(e=>t.registry.get(e)?.kind!==`native`).slice().sort((e,t)=>e<t?-1:+(e>t)).map(e=>{let r=e===n;return(0,P.jsx)(`div`,{"data-deck-panel-body":e,style:{display:r?`flex`:`none`,flexDirection:`column`,flex:1,minWidth:0,minHeight:0},children:t.renderDomPanel(e,{active:r})},`dom-${e}`)})]}):null}function wa(e){let{panelId:t,bindNativeSlot:n}=e,r=(0,N.useRef)(n);return r.current=n,(0,P.jsx)(`div`,{ref:(0,N.useCallback)(e=>{r.current(t,e)},[t]),"data-deck-native-slot":t,style:{flex:1,minWidth:0,minHeight:0,height:`100%`}})}var Ta=`application/x-deck-panel`;function Ea(e){let{node:t,ctx:n}=e,[r,i]=(0,N.useState)(null),a=(0,N.useRef)(t);a.current=t;let o=(0,N.useRef)(n.onRedock);o.current=n.onRedock;let s=e=>{e&&(e.__deckHandleDrop=(e,t)=>{let n=a.current;o.current(n.id,n.active,e,t)})},c=e=>{if(!e.dataTransfer?.types.includes(Ta))return;e.preventDefault();let t=n.activeDragPanelId.current;if(n.suppressReorderOnlyDropIndicator&&t!==null&&n.registry.get(t)?.dropPolicy===`reorder-only`){i(null);return}let r=e.currentTarget.getBoundingClientRect();i(oa({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top}))},l=()=>{i(null)},u=e=>{e.preventDefault();let r=e.currentTarget.getBoundingClientRect(),a=oa({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top});i(null);let o=e.dataTransfer?.getData(Ta);if(!o||n.registry.get(o)===void 0||!n.isPanelInTree(o))return;let s=la(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,o,a,s)},d=e=>{e.dataTransfer?.types.includes(Ta)&&(e.preventDefault(),e.stopPropagation(),i(null))},f=e=>{e.preventDefault(),e.stopPropagation(),i(null);let r=e.dataTransfer?.getData(Ta);if(!r||n.registry.get(r)===void 0||!n.isPanelInTree(r))return;let a=la(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,r,`center`,a)},p=t.panels.filter(e=>!n.registry.get(e)?.hideTab);return(0,P.jsxs)(`div`,{ref:s,"data-deck-group":t.id,onDragOver:c,onDragLeave:l,onDrop:u,style:{position:`relative`,display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,minWidth:0,minHeight:0},children:[p.length>0?(0,P.jsx)(`div`,{role:`tablist`,style:{flexShrink:0},onDragOver:d,onDrop:f,children:p.map(e=>{let r=e===t.active,i=n.registry.get(e),a=i?.title??e;return(0,P.jsxs)(`button`,{type:`button`,role:`tab`,draggable:i?.draggable===!1?void 0:`true`,"data-deck-tab":e,"data-active":r?`true`:`false`,onDragStart:t=>{if(t.target instanceof Element&&t.target.closest(`[data-deck-tab-close]`)!==null){t.preventDefault();return}t.dataTransfer.setData(Ta,e),t.dataTransfer.setData(`text/plain`,e),t.dataTransfer.effectAllowed=`move`,n.activeDragPanelId.current=e},onDragEnd:()=>{n.activeDragPanelId.current=null},onClick:()=>{r?n.onActiveTabClick?.(e):n.onActivate(t.id,e)},children:[a,n.canClose&&i?.closable!==!1?(0,P.jsx)(`span`,{role:`button`,tabIndex:0,"data-deck-tab-close":e,"aria-label":`Close ${a}`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),t.preventDefault(),n.onClose(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.stopPropagation(),t.preventDefault(),n.onClose(e))},children:`×`}):null]},e)})}):null,Ca(t,n),r?(0,P.jsx)(Oa,{zone:r}):null]})}function Da(e){let t={position:`absolute`,pointerEvents:`none`,background:`rgba(64, 128, 255, 0.25)`,outline:`2px solid rgba(64, 128, 255, 0.6)`};switch(e){case`left`:return{...t,left:`0`,top:`0`,width:`50%`,height:`100%`};case`right`:return{...t,right:`0`,top:`0`,width:`50%`,height:`100%`};case`top`:return{...t,left:`0`,top:`0`,width:`100%`,height:`50%`};case`bottom`:return{...t,left:`0`,bottom:`0`,width:`100%`,height:`50%`};default:return{...t,left:`0`,top:`0`,width:`100%`,height:`100%`}}}function Oa(e){return(0,P.jsx)(`div`,{"data-deck-drop-zone":e.zone,style:Da(e.zone)})}var ka=(0,N.createContext)(0);function Aa(){return(0,N.useContext)(ka)}function ja(e,t,n){let{groupId:r,activePanelId:i,draggedPanelId:a,draggedGroupId:o,zone:s,reorderIndex:c}=n;if(o===void 0||o!==r||s!==`center`)return;let l=yn(e.get().root,r),u;if(c!==void 0&&l){let e=l.panels.filter(e=>t.get(e)?.hideTab!==!0);u=ua(l.panels,e,a,c)}else u=l?l.panels.indexOf(i):void 0;e.apply(e=>Rn(e,a,{groupId:r,index:u}))}function Ma(e){let{model:t,registry:n,renderDomPanel:r,bindNativeSlot:i,suppressReorderOnlyDropIndicator:a,onActiveTabClick:o}=e,[s,c]=(0,N.useState)(()=>t.get()),[l,u]=(0,N.useState)(0),d=(0,N.useRef)(null);(0,N.useEffect)(()=>(c(t.get()),t.subscribe(e=>{c(e.tree),u(e.revision)})),[t]);let f=(0,N.useCallback)((e,n)=>{t.apply(t=>Mn(t,e,n))},[t]),p=(0,N.useCallback)(e=>{t.apply(t=>Hn(t,e,n))},[t,n]),m=Sn(s.root)>1,h=(0,N.useCallback)(e=>xn(s.root,e)!==void 0,[s]),g=(0,N.useCallback)((e,n)=>{t.apply(t=>An(t,e,n))},[t]),_=(0,N.useCallback)((e,r,i,a,o)=>{let s={groupId:e,panelId:r},c=xn(t.get().root,i);if(n.get(i)?.draggable===!1||n.get(r)?.draggable===!1)return;if(n.get(i)?.dropPolicy===`reorder-only`){ja(t,n,{groupId:e,activePanelId:r,draggedPanelId:i,draggedGroupId:c,zone:a,reorderIndex:o});return}if(ca(i,c,s,a))return;let l=sa(a,i,s);if(l.kind===`move`){t.apply(e=>Rn(e,l.panelId,{groupId:l.destGroupId}));return}t.apply(e=>{let{tree:t}=Fn(e,l.newPanelId);return xn(t.root,l.atPanelId)===void 0?e:B(t,l.atPanelId,l.dir,l.newPanelId,l.side)})},[t,n]);return(0,P.jsx)(ka.Provider,{value:l,children:Na(s.root,{registry:n,renderDomPanel:r,bindNativeSlot:i,onActivate:f,onActiveTabClick:o,onApplyLayout:g,onRedock:_,onClose:p,canClose:m,isPanelInTree:h,suppressReorderOnlyDropIndicator:a??!1,activeDragPanelId:d})})}function Na(e,t){return e.kind===`split`?Pa(e,t):Fa(e,t)}function Pa(e,t){return(0,P.jsx)(xa,{node:e,ctx:t},e.id)}function Fa(e,t){return(0,P.jsx)(Ea,{node:e,ctx:t},e.id)}function Ia({phase:e,code:t,reason:n,onRelaunch:r}){return(0,P.jsx)(`div`,{"data-testid":`sim-runtime-error`,className:`absolute inset-0 flex flex-col items-center justify-center bg-[var(--color-overlay-heavy)] z-10`,children:(0,P.jsxs)(`div`,{className:`text-center p-4`,children:[(0,P.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:e===`crashed`?`小程序已崩溃`:`小程序启动失败`}),(0,P.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words mb-3`,children:n??t??`未知原因`}),(0,P.jsx)(A,{type:`button`,variant:`outline`,size:`xs`,onClick:r,className:`border-status-error text-status-error hover:bg-status-error/10`,children:`重新启动`})]})})}function La({requested:e,resolved:t,onDismiss:n}){return(0,P.jsxs)(`div`,{"data-testid":`sim-fallback-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-warn/15 border-b border-status-warn/40 text-[11px] text-status-warn shrink-0`,children:[(0,P.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`启动页 "`,e,`" 不存在,已回退到 "`,t,`"`]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`shrink-0 text-status-warn/80 hover:text-status-warn px-1`,title:`关闭`,children:`×`})]})}function Ra(){return(0,P.jsx)(`div`,{"data-testid":`sim-watcher-dead-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-error/15 border-b border-status-error/40 text-[11px] text-status-error shrink-0`,children:`文件监听已停止,后续代码修改将不会自动重新编译`})}var za=48;function Ba(e,t,n){if(e.width<=0||e.height<=0)return n;let r=Math.min(e.width/(t.width+za),e.height/(t.height+za));return Math.max(1,Math.min(100,Math.floor(r*100)))}function Va({device:e,zoom:t,onOpenDevicePicker:n,onZoomChange:r,compileStatus:i,currentPage:a,copied:o,onCopyPagePath:s,runtimeStatus:c=null,watcherDead:l=!1,onRelaunch:u=()=>{},onOpenInternalDevtools:d=()=>{}}){let f=(0,N.useRef)(typeof t==`number`?t:100),g=(0,N.useRef)(t),_=(0,N.useRef)(e),v=(0,N.useRef)(null),[b,x]=(0,N.useState)(!1);(0,N.useEffect)(()=>{i.status===`ready`&&x(!0)},[i.status]);let S=c?.phase===`launch-failed`||c?.phase===`crashed`,[C,w]=(0,N.useState)(!1);(0,N.useEffect)(()=>{c||w(!1)},[c]);let T=!!c?.pageFallback&&!S&&!C,E=i.status===`compiling`&&b,D=m(),O=(0,N.useCallback)(e=>{if(e.visible){let t=g.current;f.current=t===`auto`?Ba(e.bounds,ot(_.current,`portrait`),f.current):t}D?.set({viewId:y.simulator,placement:e,layer:h.base,extra:{zoom:f.current}})},[D]),k=(0,N.useCallback)(e=>{let t=v.current;if(t){e?(t.dispose(),v.current=p(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:O})):(t.update({visible:!1,publish:O}),t.dispose(),v.current=null);return}e&&(v.current=p(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:O}))},[O]);return(0,N.useLayoutEffect)(()=>{g.current=t,_.current=e}),(0,N.useLayoutEffect)(()=>{v.current?.update({visible:!0,publish:O})},[t,e,O]),(0,N.useEffect)(()=>{v.current?.pulse(300)},[Aa()]),(0,N.useEffect)(()=>()=>{v.current?.dispose(),v.current=null,D?.remove(y.simulator)},[D]),(0,P.jsxs)(`div`,{className:`bg-sim-bg flex flex-col overflow-hidden h-full w-full`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-2 shrink-0 border-b border-border-subtle`,children:[(0,P.jsx)(A,{variant:`outline`,size:`sm`,"data-testid":`device-picker-button`,className:`h-7 justify-start px-2 text-[13px] font-medium text-text-secondary`,onClick:n,children:e.name}),(0,P.jsxs)(De,{value:t,onChange:r,className:`w-[76px] shrink-0`,children:[ye.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,`%`]},e)),(0,P.jsx)(`option`,{value:be,children:`自适应`})]})]}),l&&(0,P.jsx)(Ra,{}),T&&c?.pageFallback&&(0,P.jsx)(La,{requested:c.pageFallback.requested,resolved:c.pageFallback.resolved,onDismiss:()=>w(!0)}),(0,P.jsxs)(`div`,{ref:k,className:`flex-1 min-h-0 bg-sim-bg relative`,"data-area":`native-simulator`,children:[i.status===`compiling`&&!b&&(0,P.jsx)(`div`,{"data-testid":`sim-compiling-overlay`,className:`absolute inset-0 flex items-center justify-center bg-[var(--color-overlay)] z-10`,children:(0,P.jsx)(`div`,{className:`text-text-dim text-[13px]`,children:`正在编译中...`})}),E&&(0,P.jsxs)(`div`,{"data-testid":`sim-recompiling-indicator`,className:`absolute top-2 right-2 z-10 flex items-center gap-1.5 rounded bg-black/60 px-2 py-0.5 pointer-events-none`,children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent animate-pulse`}),(0,P.jsx)(`span`,{className:`text-text-dim text-[11px]`,children:`编译中…`})]}),i.status===`error`&&(0,P.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-[var(--color-overlay-heavy)] z-10`,children:(0,P.jsxs)(`div`,{className:`text-center p-4`,children:[(0,P.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:`编译失败`}),(0,P.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words`,children:i.message})]})}),i.status!==`error`&&c&&(c.phase===`launch-failed`||c.phase===`crashed`)&&(0,P.jsx)(Ia,{phase:c.phase,code:c.code,reason:c.reason,onRelaunch:u})]}),(0,P.jsxs)(`div`,{className:`flex items-center px-2.5 bg-sim-bottom border-t border-border-subtle shrink-0 h-[30px] min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-[11px] text-text-dim truncate min-w-0`,title:a||void 0,children:a||`—`}),a&&(0,P.jsx)(`button`,{className:ge(`shrink-0 flex items-center justify-center w-4 h-4 rounded transition-colors`,o?`text-accent`:`text-text-dim hover:text-text`),onClick:s,title:`复制路径`,children:o?(0,P.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:(0,P.jsx)(`polyline`,{points:`1.5,5 4,7.5 8.5,2.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}):(0,P.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:[(0,P.jsx)(`rect`,{x:`1`,y:`3`,width:`6`,height:`6.5`,rx:`1`,stroke:`currentColor`,strokeWidth:`1`}),(0,P.jsx)(`path`,{d:`M3 3V2a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H7`,stroke:`currentColor`,strokeWidth:`1`})]})})]}),(0,P.jsx)(`button`,{className:`ml-auto shrink-0 flex items-center justify-center w-4 h-4 rounded text-text-dim hover:text-text transition-colors`,onClick:d,title:`调试开发者工具`,"data-testid":`sim-open-internal-devtools`,children:(0,P.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 11 11`,fill:`none`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3.5`,width:`5`,height:`5.5`,rx:`1.5`,stroke:`currentColor`,strokeWidth:`1`}),(0,P.jsx)(`path`,{d:`M4 3.5V3a1.5 1.5 0 013 0v.5M1.5 5.5H3M8 5.5h1.5M2 8.5l1.3-1M9 8.5l-1.3-1M2 3l1.3 1M9 3L7.7 4`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`})]})})]})]})}function Ha(){let e=(0,N.useRef)(null),t=m(),n=(0,N.useCallback)(e=>{t?.set({viewId:y.workbench,placement:e,layer:h.base})},[t]),r=(0,N.useCallback)(t=>{let r=e.current;if(r){t?(r.dispose(),e.current=p(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n})):(r.update({visible:!1,publish:n}),r.dispose(),e.current=null);return}t&&(e.current=p(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n}))},[n]);return(0,N.useEffect)(()=>{e.current?.pulse(300)},[Aa()]),(0,N.useEffect)(()=>()=>{e.current?.dispose(),e.current=null,t?.remove(y.workbench)},[t]),(0,P.jsx)(`div`,{ref:r,className:`h-full w-full`,"data-area":`editor`})}function Ua(e,t){return!!(t===0||e.tagName===`#shadow-root`||e.tagName.includes(`/`))}function Wa({entries:e}){return(0,P.jsx)(P.Fragment,{children:e.map(([e,t])=>(0,P.jsxs)(`span`,{children:[` `,(0,P.jsx)(`span`,{className:`text-code-blue`,children:e}),(0,P.jsx)(`span`,{className:`text-text-dim`,children:`=`}),(0,P.jsxs)(`span`,{className:`text-code-orange`,children:[`"`,t,`"`]})]},e))})}function Ga({node:e,depth:t}){return(0,P.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2`,style:{paddingLeft:t*16},children:[(0,P.jsx)(`span`,{className:`w-3 inline-block`}),(0,P.jsx)(`span`,{className:`text-text`,children:e.text})]})}function Ka({node:e,depth:t,inspectedSid:n,onInspect:r}){return(0,P.jsx)(P.Fragment,{children:(e.children??[]).map((e,i)=>(0,P.jsx)(Za,{node:e,depth:t,inspectedSid:n,onInspect:r},i))})}function qa({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,N.useState)(()=>Ua(e,t)),o=t*16,s=(e.children??[]).length>0;return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2 cursor-pointer`,style:{paddingLeft:o},onClick:()=>s&&a(!i),children:[(0,P.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 inline-block text-center select-none`,children:s?i?`▾`:`▸`:` `}),(0,P.jsx)(`span`,{className:`text-text-dim italic`,children:`#shadow-root`})]}),i&&e.children.map((e,i)=>(0,P.jsx)(Za,{node:e,depth:t+1,inspectedSid:n,onInspect:r},i))]})}function Ja({node:e,indent:t,attrEntries:n,isInspected:r,onMouseEnter:i,inlineText:a}){return(0,P.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2${r?` bg-surface-2`:``}`,style:{paddingLeft:t},onMouseEnter:i,"data-wxml-sid":e.sid,children:[(0,P.jsx)(`span`,{className:`w-3 inline-block`}),(0,P.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,P.jsx)(Wa,{entries:n}),(0,P.jsx)(`span`,{className:`text-code-keyword`,children:`>`}),(0,P.jsx)(`span`,{className:`text-text`,children:a}),(0,P.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})}function Ya({node:e,depth:t,indent:n,attrEntries:r,hasChildren:i,expanded:a,isInspected:o,inspectedSid:s,onInspect:c,onToggle:l,onMouseEnter:u}){return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-start hover:bg-surface-2 py-px leading-[18px]${i?` cursor-pointer`:``}${o?` bg-surface-2`:``}`,style:{paddingLeft:n},onMouseEnter:u,onClick:()=>{i&&l()},"data-wxml-sid":e.sid,children:[(0,P.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 text-center select-none`,children:i?a?`▾`:`▸`:` `}),(0,P.jsxs)(`span`,{children:[(0,P.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,P.jsx)(Wa,{entries:r}),(0,P.jsx)(`span`,{className:`text-code-keyword`,children:i?`>`:` />`})]})]}),a&&i&&(0,P.jsxs)(P.Fragment,{children:[e.children.map((e,n)=>(0,P.jsx)(Za,{node:e,depth:t+1,inspectedSid:s,onInspect:c},n)),(0,P.jsxs)(`div`,{style:{paddingLeft:n},className:`py-px leading-[18px]`,children:[(0,P.jsx)(`span`,{className:`w-3 inline-block`}),(0,P.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})]})]})}function Xa({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,N.useState)(()=>Ua(e,t)),o=t*16,s=!!(e.sid&&e.sid===n),c=(e.children??[]).length>0,l=Object.entries(e.attrs),u=()=>{e.sid&&r?.(e)},d=c&&e.children.length===1&&e.children[0].tagName===`#text`?e.children[0].text:null;return d?(0,P.jsx)(Ja,{node:e,indent:o,attrEntries:l,isInspected:s,onMouseEnter:u,inlineText:d}):(0,P.jsx)(Ya,{node:e,depth:t,indent:o,attrEntries:l,hasChildren:c,expanded:i,isInspected:s,inspectedSid:n,onInspect:r,onToggle:()=>a(!i),onMouseEnter:u})}function Za({node:e,depth:t,inspectedSid:n,onInspect:r}){return e.tagName===`#text`?(0,P.jsx)(Ga,{node:e,depth:t}):e.tagName===`#fragment`?(0,P.jsx)(Ka,{node:e,depth:t,inspectedSid:n,onInspect:r}):e.tagName===`#shadow-root`?(0,P.jsx)(qa,{node:e,depth:t,inspectedSid:n,onInspect:r}):(0,P.jsx)(Xa,{node:e,depth:t,inspectedSid:n,onInspect:r})}function Qa({inspection:e}){if(!e)return null;let{rect:t,style:n}=e,r=[n.display,n.position===`static`?null:n.position,n.boxSizing].filter(Boolean);return(0,P.jsxs)(`div`,{className:`border-t border-border-subtle bg-bg-panel px-2.5 py-1.5 font-mono text-[11px] text-text-dim shrink-0`,children:[(0,P.jsx)(`span`,{className:`text-text`,children:`box`}),` `,Math.round(t.width),` x `,Math.round(t.height),` @ `,Math.round(t.x),`, `,Math.round(t.y),(0,P.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),r.join(` / `),(0,P.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),`font `,n.fontSize]})}function $a({tree:e,onInspectElement:t,onClearInspection:n,isRuntimeRunning:r=!0}){let[i,a]=(0,N.useState)(null),o=(0,N.useRef)(0),s=(0,N.useRef)(null);(0,N.useEffect)(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let c=(0,N.useCallback)(e=>{if(!e.sid||!t)return;let n=e.sid;s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null;let e=++o.current;t(n).then(t=>{e===o.current&&a(t)}).catch(()=>{e===o.current&&a(null)})})},[t]),l=(0,N.useCallback)(()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),o.current++,a(null),n?.()},[n]);return e?(0,P.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,onMouseLeave:l,"data-testid":`wxml-panel`,children:[(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 font-mono text-[12px]`,children:(0,P.jsx)(Za,{node:e,depth:0,inspectedSid:i?.sid??null,onInspect:c})}),(0,P.jsx)(Qa,{inspection:i})]}):(0,P.jsx)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,"data-testid":`wxml-panel`,children:(0,P.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:r?`等待小程序加载...`:`小程序未运行`})})}function eo(e){let{source:t,enabled:n,active:r}=e,i=(0,N.useRef)({subscribe:e.subscribe,seed:e.seed});(0,N.useEffect)(()=>{i.current={subscribe:e.subscribe,seed:e.seed}}),(0,N.useEffect)(()=>{if(!n)return;let e=i.current.subscribe(t);return()=>{e(),t.setActive(!1)}},[t,n]),(0,N.useEffect)(()=>{n&&t.setActive(r)},[t,n,r]);let a=(0,N.useRef)({source:null,on:!1});(0,N.useEffect)(()=>{let e=n&&r,o=a.current,s=e&&(!o.on||o.source!==t);if(a.current={source:t,on:e},!s)return;let c=!1;return i.current.seed(t,()=>c),()=>{c=!0}},[t,n,r])}function to({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,N.useState)(null);return eo({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(a),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}}),(0,P.jsx)($a,{tree:i,onInspectElement:t=>e.inspect(t),onClearInspection:async()=>{await e.clearInspection()},isRuntimeRunning:r})}var no=`inline-flex items-center justify-center gap-1.5 font-medium transition-colors focus:outline-none disabled:opacity-35 disabled:cursor-not-allowed whitespace-nowrap shrink-0 border border-border text-text-muted hover:text-text rounded h-5 px-2 text-[11px]`;function ro({items:e,onSet:t,onRemove:n,onClear:r,onClearAll:i,getPrefix:a,isRuntimeRunning:o=!0}){let[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(``),[h,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(``);(0,N.useEffect)(()=>{let e=!1,t,n=()=>{a().then(r=>{if(!e){if(r){m(r);return}t=setTimeout(n,300)}})};return n(),()=>{e=!0,t&&clearTimeout(t)}},[a]);async function y(e){f(!0),u(null);try{let t=await e();return t.ok?t:(u(t.error),null)}finally{f(!1)}}function b(e){c({key:e.key,draft:e.value})}async function x(){if(!s)return;let{key:e,draft:n}=s;c(null),await y(()=>t(e,n))}async function S(e){await y(()=>n(e))}async function C(){e.length!==0&&await y(()=>r())}async function w(){i&&(typeof window<`u`&&!window.confirm(`清空所有 appId 的 Storage 数据?该操作不可撤销。`)||await y(()=>i()))}async function T(){let e=h.trim();if(!e){u(`key 不能为空`);return}let n=p+e;await y(()=>t(n,_))&&(g(``),v(``))}return(0,P.jsxs)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`storage-panel`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:d||e.length===0,className:`${no} hover:border-status-error hover:text-status-error`,title:`仅清空当前 appId 的 Storage`,children:`清空`}),i&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:d,className:`${no} hover:border-status-error hover:text-status-error`,title:`清空所有 appId 的 Storage`,children:`清空所有`}),l&&(0,P.jsx)(`span`,{className:`ml-2 text-[11px] text-status-error truncate`,title:l,children:l})]}),(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,P.jsxs)(`table`,{className:`w-full border-collapse text-[12px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10 w-px pr-5`,children:`Key`}),(0,P.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10`,children:`Value`}),(0,P.jsx)(`th`,{className:`w-px sticky top-0 bg-bg-panel z-10 border-b border-border-subtle`})]})}),(0,P.jsx)(`tbody`,{children:e.length===0?(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{colSpan:3,className:`text-[12px] text-text-dim text-center px-4 py-6`,children:o?`暂无 Storage 数据`:`小程序未运行`})}):e.map(e=>{let t=s?.key===e.key,n=p&&e.key.startsWith(p)?e.key.slice(p.length):e.key;return(0,P.jsxs)(`tr`,{className:`hover:[&>td]:bg-surface`,children:[(0,P.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle w-px pr-5 align-top`,children:(0,P.jsx)(`div`,{className:`font-mono text-code-blue max-w-[240px] truncate`,title:e.key,children:n})}),(0,P.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle font-mono text-code-orange break-all align-top cursor-text`,onClick:()=>{t||b(e)},children:t?(0,P.jsx)(`input`,{autoFocus:!0,type:`text`,value:s.draft,onChange:t=>c({key:e.key,draft:t.target.value}),onBlur:()=>void x(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),x()):e.key===`Escape`&&(e.preventDefault(),c(null))},className:`w-full bg-transparent outline-none border border-accent/60 rounded px-1 py-0 font-mono text-code-orange`}):e.value}),(0,P.jsx)(`td`,{className:`px-1 py-0.5 border-b border-border-subtle align-top`,children:(0,P.jsx)(`button`,{type:`button`,onClick:()=>void S(e.key),disabled:d,title:`删除`,className:`text-text-dim hover:text-status-error px-1 leading-none`,children:`×`})})]},e.key)})})]})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-t border-border-subtle shrink-0 bg-bg-panel`,children:[(0,P.jsx)(`input`,{type:`text`,placeholder:`key`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`w-32 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,P.jsx)(`input`,{type:`text`,placeholder:`value`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`flex-1 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:d||!h.trim(),className:`${no} hover:border-accent hover:text-accent`,children:`+ 新增`})]})]})}function io(e,t){switch(t.type){case`added`:case`updated`:{let n=e.findIndex(e=>e.key===t.key);if(n<0)return[...e,{key:t.key,value:t.newValue}];let r=[...e];return r[n]={key:t.key,value:t.newValue},r}case`removed`:return e.filter(e=>e.key!==t.key);case`cleared`:return[]}}function ao({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,N.useState)([]);eo({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{a(t=>io(t,e))}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}});let o=e.clearAll?.bind(e);return(0,P.jsx)(ro,{items:i,onSet:(t,n)=>e.setItem(t,n),onRemove:t=>e.removeItem(t),onClear:()=>e.clear(),onClearAll:o,getPrefix:()=>e.getPrefix(),isRuntimeRunning:r})}function oo(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:`${e}.${t}`}function so(e){return typeof e==`object`&&!!e}function co(e){return Array.isArray(e)?e.map((e,t)=>[t,e]):Object.keys(e).sort().map(t=>[t,e[t]])}function lo(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}var uo=``;function fo(e,t){let n=e.overrides.get(t);return n===void 0?e.baseline===`expanded`?!0:e.baseline===`collapsed`?!1:t===uo:n}function po({path:e,value:t,editable:n,ctx:r}){if(typeof t==`boolean`)return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-code-keyword`,children:[n&&(0,P.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>r.onCommit?.(e,!t,t),className:`accent-accent`}),String(t)]});if(t==null)return(0,P.jsx)(`span`,{className:`text-code-keyword`,children:String(t)});if(r.state.editingPath===e){let n=()=>{let n=t;if(typeof n==`number`){let t=r.state.draft.trim(),i=Number(t);if(r.endEdit(),t===``||!Number.isFinite(i))return;r.onCommit?.(e,i,n);return}let i=r.state.draft;r.endEdit(),r.onCommit?.(e,i,n)};return(0,P.jsx)(`input`,{type:`text`,autoFocus:!0,value:r.state.draft,onChange:e=>r.setDraft(e.target.value),onKeyDown:e=>{e.key===`Enter`?n():e.key===`Escape`&&r.endEdit()},onBlur:n,className:`bg-surface-3 border border-accent rounded px-1 text-[12px] font-mono min-w-0 w-40`})}return(0,P.jsx)(`span`,{"data-testid":`appdata-value`,className:typeof t==`string`?`text-code-orange`:void 0,style:typeof t==`number`?{color:`var(--color-code-number)`}:void 0,onDoubleClick:n?()=>r.beginEdit(e,String(t)):void 0,children:String(t)})}function mo(e){return typeof e==`string`&&(e===``||/[.[\]]/.test(e))}function ho({path:e,label:t,value:n,depth:r,unsafeSegments:i,ctx:a}){let o={paddingLeft:r*14};if(so(n)){let s=fo(a.state,e);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px cursor-pointer hover:bg-surface-3 text-[12px] font-mono`,style:o,onClick:()=>a.toggle(e,n),children:[(0,P.jsx)(`span`,{className:`text-text-secondary w-3 shrink-0 text-center select-none`,children:s?`▾`:`▸`}),(0,P.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,P.jsx)(`span`,{className:`text-text-secondary`,children:lo(n)})]}),s&&co(n).map(([t,n])=>(0,P.jsx)(ho,{path:oo(e,t),label:String(t),value:n,depth:r+1,unsafeSegments:i||mo(t),ctx:a},String(t)))]})}let s=typeof n==`string`||typeof n==`number`||typeof n==`boolean`,c=r>1&&i||t===`__proto__`,l=s&&a.onCommit!==void 0&&!c;return(0,P.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px text-[12px] font-mono`,style:o,...l?{"data-path":e}:{},children:[(0,P.jsx)(`span`,{className:`w-3 shrink-0`}),(0,P.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,P.jsx)(`span`,{className:`text-text-secondary`,children:`:`}),(0,P.jsx)(po,{path:e,value:n,editable:l,ctx:a})]})}function go({root:e,bridgeId:t,command:n,onCommit:r}){let[i,a]=(0,N.useState)(`default`),[o,s]=(0,N.useState)(new Map),[c,l]=(0,N.useState)(0),[u,d]=(0,N.useState)(null),[f,p]=(0,N.useState)(``);n&&n.bridgeId===t&&n.seq!==c&&(a(n.mode),s(new Map),l(n.seq));let m={baseline:i,overrides:o,editingPath:u,draft:f};return(0,P.jsx)(`div`,{"data-testid":`appdata-tree`,className:`py-1`,children:(0,P.jsx)(ho,{path:uo,label:`object`,value:e,depth:0,unsafeSegments:!1,ctx:{state:m,toggle:(e,t)=>{let n=new Map(o),r=!fo(m,e);n.set(e,r),r&&Array.isArray(t)&&t.forEach((t,r)=>{so(t)&&n.set(oo(e,r),!0)}),s(n)},beginEdit:(e,t)=>{d(e),p(t)},setDraft:p,endEdit:()=>d(null),onCommit:r}})})}function _o(e){return e.pagePath??e.id}function vo(e){return e!=null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function yo(e){let t={};for(let n of Object.keys(e)){let r=e[n];if(!(!r||typeof r!=`object`))for(let e of Object.keys(r))Object.defineProperty(t,e,{value:r[e],enumerable:!0,writable:!0,configurable:!0})}return t}function bo({title:e,disabled:t,onClick:n,children:r}){return(0,P.jsx)(`button`,{title:e,disabled:t,onClick:n,className:`px-1.5 py-0.5 text-[12px] rounded text-text-secondary hover:bg-surface-3 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function xo({state:e,onSelectBridge:t,isRuntimeRunning:n=!0,onSetData:r}){let{bridges:i,activeBridgeId:a,entries:o}=e,[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)([]),[d,f]=(0,N.useState)([]),p=(0,N.useRef)(!1),[m,h]=(0,N.useState)(!1),g=n?`暂无页面数据(仅显示 Page 级 data)`:`小程序未运行`,_=e=>{a&&c({seq:(s?.seq??0)+1,mode:e,bridgeId:a})},v=(e,t,n)=>{let i;try{i=r?.(e,t)}catch{n(!1);return}if(vo(i)){Promise.resolve(i).then(e=>e!==!1,()=>!1).then(n);return}n(i!==!1)},y=(e,t,n)=>{p.current||(p.current=!0,h(!0),v(e,t,e=>{p.current=!1,h(!1),n(e)}))},b=e=>(t,n,r)=>{y(e,{[t]:n},i=>{i&&(u(i=>[...i,{bridgeId:e,path:t,before:r,after:n}]),f([]))})},x=e=>i.some(t=>t.id===e),S=(e,t,n)=>{y(e.bridgeId,{[e.path]:t},t=>{t&&n(e)})};return i.length===0?(0,P.jsx)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:(0,P.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})}):(0,P.jsxs)(`div`,{className:`flex overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:[(0,P.jsxs)(`div`,{"data-testid":`appdata-pages`,className:`w-40 shrink-0 border-r border-border-subtle bg-bg-panel flex flex-col overflow-hidden`,children:[(0,P.jsx)(`div`,{className:`px-2 py-1 text-[11px] text-text-secondary border-b border-border-subtle shrink-0`,children:`Pages`}),(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,role:`listbox`,children:i.map(e=>{let n=e.id===a;return(0,P.jsx)(`button`,{"data-testid":`appdata-page-item`,role:`option`,"aria-selected":n,title:e.id,onClick:()=>t(e.id),className:`block w-full text-left px-2 py-1 text-[11px] truncate `+(n?`bg-accent/20 text-accent`:`text-text-dim hover:bg-surface-3`),children:_o(e)},e.id)})})]}),(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,P.jsxs)(`div`,{"data-testid":`appdata-toolbar`,className:`flex items-center gap-1 px-2 py-0.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,P.jsx)(bo,{title:`全部展开`,onClick:()=>_(`expanded`),children:`⊕`}),(0,P.jsx)(bo,{title:`全部收起`,onClick:()=>_(`collapsed`),children:`⊖`}),(0,P.jsx)(bo,{title:`撤销`,disabled:l.length===0||m,onClick:()=>{let e=l.at(-1);if(e){if(!x(e.bridgeId)){u(t=>t.filter(t=>t!==e));return}S(e,e.before,e=>{u(t=>t.filter(t=>t!==e)),f(t=>[...t,e])})}},children:`↶`}),(0,P.jsx)(bo,{title:`重做`,disabled:d.length===0||m,onClick:()=>{let e=d.at(-1);if(e){if(!x(e.bridgeId)){f(t=>t.filter(t=>t!==e));return}S(e,e.after,e=>{f(t=>t.filter(t=>t!==e)),u(t=>[...t,e])})}},children:`↷`})]}),(0,P.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:i.map(e=>{let t=e.id===a,n=o[e.id]??{},i=Object.keys(n).length>0;return(0,P.jsx)(`div`,{"data-bridge-id":e.id,className:`absolute inset-0 flex-col overflow-y-auto`,style:{display:t?`flex`:`none`},children:i?(0,P.jsx)(go,{root:yo(n),bridgeId:e.id,command:s,onCommit:r?b(e.id):void 0}):(0,P.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})},e.id)})})]})]})}function So(e){return(e??``).replace(/^\/+/,``)}function Co(e,t=``){let n=e.map(e=>e.id),r=n.join(`\0`),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(t);if(r!==o){let e=o?o.split(`\0`):[];n.some(t=>!e.includes(t))&&a(null),s(r)}t!==c&&(a(null),l(t));let u=t?e.find(e=>So(e.pagePath)===So(t))?.id??null:null;return{activeBridgeId:i&&n.includes(i)?i:u??n.at(-1)??null,setActiveBridge:e=>{n.includes(e)&&a(e)}}}var wo={bridges:[],entries:{}};function To({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0,activePagePath:i=``}){let[a,o]=(0,N.useState)(wo);eo({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{o(e)}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||o(e)})}});let{activeBridgeId:s,setActiveBridge:c}=Co(a.bridges,i),l=e.setData?.bind(e),u=l?(e,t)=>l(e,t):void 0;return(0,P.jsx)(xo,{state:{bridges:a.bridges,activeBridgeId:s,entries:a.entries},onSelectBridge:c,isRuntimeRunning:r,onSetData:u})}function Eo(...e){return e.filter(Boolean).join(` `)}function Do(e){let t=new Date(e);return[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,`0`)).join(`:`)}function Oo(e){return e===`error`?`text-red-500`:e===`compiling`?`text-amber-500`:e===`ready`?`text-emerald-600`:`text-text-muted`}function ko(e){return e.kind===`event`?e.event.message:e.log.text}function Ao({events:e,logs:t=[],onClear:n}){let r=e.length>0?e[e.length-1]:null,[i,a]=(0,N.useState)(``),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useRef)(!0);(0,N.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;c.current=n-t-r<30};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,N.useEffect)(()=>{c.current&&s.current?.scrollIntoView?.({behavior:`auto`})},[e.length+t.length]);let l=(0,N.useMemo)(()=>{let n=[];e.forEach((t,r)=>{let i=r>0?e[r-1]:null,a=t.status===`ready`&&i?.status===`compiling`?t.at-i.at:null;n.push({kind:`event`,at:t.at,seq:t.seq,event:t,durationMs:a})});for(let e of t)n.push({kind:`log`,at:e.at,seq:e.seq,log:e});return n.sort((e,t)=>e.at===t.at?e.seq!==void 0&&t.seq!==void 0?e.seq-t.seq:0:e.at-t.at)},[e,t]),u=(0,N.useMemo)(()=>{if(!i)return l;let e=i.toLowerCase();return l.filter(t=>ko(t).toLowerCase().includes(e))},[l,i]),d=e.length===0&&t.length===0;return(0,P.jsxs)(`div`,{className:`flex flex-col h-full w-full min-h-0 text-[12px]`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-2 h-8 shrink-0 border-b border-border-subtle`,children:[r?(0,P.jsx)(`span`,{"data-compile-current":!0,"data-status":r.status,className:Eo(`truncate font-medium shrink-0`,Oo(r.status)),children:r.message}):(0,P.jsx)(`span`,{className:`text-text-muted shrink-0`,children:`编译信息`}),(0,P.jsx)(`div`,{className:`flex-1 min-w-0`}),(0,P.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`过滤...`,className:`h-6 px-2 text-[12px] rounded-sm border border-border-subtle bg-surface
|
|
2
|
+
text-text placeholder:text-text-dim
|
|
3
|
+
focus:outline-none focus:border-text-muted
|
|
4
|
+
w-40 shrink-0`}),i&&(0,P.jsxs)(`span`,{className:`text-[11px] text-text-muted tabular-nums shrink-0`,children:[u.length,`/`,l.length]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`px-2 h-6 rounded-sm text-text-muted hover:text-text hover:bg-surface-2 transition-colors shrink-0`,children:`清空`})]}),(0,P.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-auto`,children:d?(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-muted`,children:`暂无编译信息`}):u.length===0?(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-muted`,children:`无匹配日志`}):(0,P.jsxs)(`ul`,{className:`px-2 py-1 space-y-0.5`,children:[u.map((e,t)=>e.kind===`event`?(0,P.jsxs)(`li`,{"data-compile-row":!0,"data-status":e.event.status,className:`flex items-baseline gap-2 leading-5`,children:[(0,P.jsx)(`span`,{className:`text-text-muted tabular-nums shrink-0`,children:Do(e.at)}),(0,P.jsx)(`span`,{className:Eo(`break-all`,Oo(e.event.status)),children:e.event.message}),e.event.hotReload===!0&&(0,P.jsx)(`span`,{className:`shrink-0 px-1 rounded-sm bg-surface-2 text-text-muted`,children:`已重启`}),e.durationMs!==null&&(0,P.jsxs)(`span`,{"data-compile-duration":!0,className:`shrink-0 text-text-muted tabular-nums`,children:[(e.durationMs/1e3).toFixed(1),`s`]})]},`e-${e.at}-${t}`):(0,P.jsxs)(`li`,{"data-compile-log":!0,"data-stream":e.log.stream,className:`flex items-baseline gap-2 leading-5`,children:[(0,P.jsx)(`span`,{className:`text-text-muted tabular-nums shrink-0`,children:Do(e.at)}),(0,P.jsx)(`span`,{className:Eo(`break-all font-mono`,e.log.stream===`stderr`?`text-red-500`:`text-text`),children:e.log.text})]},`l-${e.at}-${t}`)),(0,P.jsx)(`div`,{ref:s})]})})]})}function jo(e){let{tabId:t,wxmlSource:n,wxmlEnabled:r=!0,storageSource:i,storageEnabled:a=!0,appDataSource:o,appDataEnabled:s=!0,activePagePath:c,tabActive:l=!0,compileEvents:u=[],compileLogs:d=[],onClearCompileEvents:f,isRuntimeRunning:p=!0}=e;switch(t){case`wxml`:return(0,P.jsx)(to,{source:n,enabled:r,active:l,isRuntimeRunning:p});case`appdata`:return(0,P.jsx)(To,{source:o,enabled:s,active:l,isRuntimeRunning:p,activePagePath:c});case`storage`:return(0,P.jsx)(ao,{source:i,enabled:a,active:l,isRuntimeRunning:p});case`compile`:return(0,P.jsx)(Ao,{events:u,logs:d,onClear:f??(()=>{})})}}var Mo=new Set([`simulator`,`editor`,`wxml`,`appdata`,`storage`,`console`,`compile`]);function No({project:e}){let t=(0,N.useRef)(null),[n,r]=(0,N.useState)(!1),{session:i,device:a,simulator:o,panelData:s,rightPane:c,popover:l}=Ft({projectPath:e.path}),u=qt(e.path),{state:p}=u,[m]=(0,N.useState)(()=>Qn(p.dockTree??null,a.simPanelWidth,Mo)),v=(0,N.useMemo)(()=>Wn(),[]),x=g(),S=d(0,se,ue),C=_({present:S>0,publish:e=>{let t=S>0&&e.width>0&&e.height>0;x.set({viewId:y.hostToolbar,placement:t?{visible:!0,bounds:e}:{visible:!1},layer:h.hostToolbar})},deps:[S,x]});(0,N.useEffect)(()=>{let t=`Dimina DevTools`;return document.title=`${e.name} - ${t}`,b().then(n=>{n?.appName&&(t=n.appName,document.title=`${e.name} - ${t}`)}).catch(()=>{}),()=>{document.title=t}},[e.name]),(0,N.useEffect)(()=>()=>{t.current!==null&&window.clearTimeout(t.current)},[]);async function w(){if(o.currentRoute)try{await navigator.clipboard.writeText(o.currentRoute),r(!0),t.current!==null&&window.clearTimeout(t.current),t.current=window.setTimeout(()=>r(!1),ve)}catch{r(!1)}}let T={rightPane:c.rightPane,onSelectTab:c.selectRightPane,wxmlSource:s.wxmlSource,wxmlEnabled:s.wxmlEnabled,storageSource:s.storageSource,storageEnabled:s.storageEnabled,appDataSource:s.appDataSource,appDataEnabled:s.appDataEnabled,activePagePath:o.currentPage,compileEvents:i.compileEvents,compileLogs:i.compileLogs,onClearCompileEvents:i.clearCompileEvents,isRuntimeRunning:i.runtimeStatus?.phase===`running`};return(0,P.jsx)(f.Provider,{value:x,children:(0,P.jsxs)(`div`,{className:`flex flex-col h-screen`,children:[(0,P.jsx)(`div`,{ref:C,style:{height:S},className:`shrink-0 w-full`,"data-area":`host-toolbar`}),(0,P.jsx)(yr,{compileDropdownRef:l.compileDropdownRef,showCompilePanel:l.showCompilePanel,onToggleCompilePanel:l.toggleCompilePanel,compileModeLabel:Te(Ee(i.compileModes)),compileModesReady:i.compileModesReady,onRelaunch:()=>i.relaunch(),compileStatus:i.compileStatus,dockModel:m,dockRegistry:v,layout:u,simPanelWidth:a.simPanelWidth}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,P.jsx)(Ro,{dockModel:m,dockRegistry:v,simPanelWidth:a.simPanelWidth,renderDomPanel:(e,t)=>e===`simulator`?(0,P.jsx)(Va,{device:a.device,zoom:a.zoom,onOpenDevicePicker:a.openDevicePicker,onZoomChange:a.handleZoomChange,compileStatus:i.compileStatus,currentPage:o.currentRoute,copied:n,onCopyPagePath:w,runtimeStatus:i.runtimeStatus,watcherDead:i.watcherDead,onRelaunch:()=>i.relaunch(),onOpenInternalDevtools:()=>{Oe()}}):e===`editor`?(0,P.jsx)(Ha,{}):e===`wxml`||e===`appdata`||e===`storage`||e===`compile`?(0,P.jsx)(Lo,{tabId:e,active:t.active,panelProps:T}):null,onPersistTree:u.setDockTree,persistedTree:p.dockTree??null})})]})})}function Po(e){return e.kind===`tabs`?e.panels.includes(`simulator`):e.children.some(Po)}function Fo(e,t){function n(e){if(e.kind===`tabs`)return null;if(e.id===t.splitId)return(e.constraints?.[t.childIndex]??null)?.minPx??null;for(let t of e.children){let e=n(t);if(e!==null)return e}return null}return n(e)}function Io(e){if(e.kind===`tabs`)return null;for(let t=0;t<e.children.length;t++){let n=e.children[t];if((e.constraints?.[t]??null)!==null&&Po(n))return{splitId:e.id,childIndex:t};let r=Io(n);if(r)return r}return null}function Lo({tabId:e,active:t,panelProps:n}){return(0,P.jsx)(jo,{tabId:e,...n,tabActive:t})}function Ro(e){let{dockModel:t,dockRegistry:n,simPanelWidth:r,renderDomPanel:i,onPersistTree:a,persistedTree:o}=e,s=(0,N.useRef)(null),c=m(),l=(0,N.useCallback)(e=>{c?.set({viewId:y.simulatorDevtools,placement:e,layer:h.base})},[c]),u=(0,N.useCallback)((e,t,n)=>{if(e.current){t?(e.current.dispose(),e.current=p(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n})):(e.current.update({visible:!1,publish:n}),e.current.dispose(),e.current=null);return}t&&(e.current=p(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n}))},[]),d=(0,N.useCallback)((e,t)=>{e===`console`&&u(s,t,l)},[u,l]);return(0,N.useEffect)(()=>{let e=t.get().root,n=Io(e);n&&Fo(e,n)!==r&&t.apply(e=>{let t=Io(e.root);return!t||Fo(e.root,t)===r?e:jn(e,t.splitId,t.childIndex,{minPx:r})})},[t,r]),(0,N.useEffect)(()=>()=>{s.current?.dispose(),s.current=null,c?.remove(y.simulatorDevtools)},[c]),(0,N.useEffect)(()=>t.subscribe(e=>{a(rn(e.tree))}),[t,a]),(0,N.useEffect)(()=>{let e=rn(t.get());e!==o&&a(e)},[]),(0,P.jsx)(Ma,{model:t,registry:n,renderDomPanel:i,bindNativeSlot:d,onActiveTabClick:(0,N.useCallback)(e=>{e===`simulator`||e===`editor`||t.apply(t=>Hn(t,e,n))},[t,n])})}function zo(e){console.error(`[devtools] fatal: could not allocate a placement-generation seed before first render`,e);let t=document.getElementById(`root`);t&&(t.textContent=`Dimina DevTools failed to start. Please restart the app.`)}function Bo(){let e=new URLSearchParams(location.search),t=e.get(`path`);return t?{name:e.get(`name`)||t,path:t}:null}function Vo(){return(0,P.jsx)(`div`,{style:{padding:24,fontFamily:`sans-serif`},children:`无法打开项目:窗口地址缺少 path 参数。请关闭此窗口并从项目列表重新打开。`})}function Ho({project:e}){return(0,N.useEffect)(()=>{e&&(document.title=e.name)},[e]),e?(0,P.jsx)(No,{project:e}):(0,P.jsx)(Vo,{})}var Uo=Bo();v().then(()=>{st.createRoot(document.getElementById(`root`)).render((0,P.jsx)(Ho,{project:Uo}))}).catch(zo);
|
|
5
|
+
//# sourceMappingURL=workbench-C0Jkdlps.js.map
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
overflow: hidden;
|
|
27
27
|
}
|
|
28
28
|
</style>
|
|
29
|
-
<script type="module" crossorigin src="../../assets/workbench-
|
|
29
|
+
<script type="module" crossorigin src="../../assets/workbench-C0Jkdlps.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="../../assets/jsx-runtime-DIw5wnYl.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="../../assets/presets-DMZOb9ay.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="../../assets/utils-sEB5OZEQ.js">
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -200,6 +200,8 @@ export interface WorkbenchHostInstance {
|
|
|
200
200
|
* every project window, including windows opened afterwards, and no window
|
|
201
201
|
* closing revokes it. It lives until the app is disposed or the returned
|
|
202
202
|
* Disposable revokes it — which removes only the registration it created.
|
|
203
|
+
* The handler's optional second argument identifies the calling window's
|
|
204
|
+
* project; it is supplied by the main process, separately from miniapp params.
|
|
203
205
|
*/
|
|
204
206
|
registerSimulatorApi(name: string, handler: SimulatorApiHandler): import('@dimina-kit/electron-deck/main').Disposable;
|
|
205
207
|
/**
|