@aiti-ai/aiti-folder 0.0.0-stage → 0.1.9

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.
@@ -0,0 +1,2411 @@
1
+ function le(e) {
2
+ if (!e) return e;
3
+ const t = e.replace(/[\\/]+$/, ""), n = Math.max(t.lastIndexOf("/"), t.lastIndexOf("\\"));
4
+ return n >= 0 ? t.slice(n + 1) : t;
5
+ }
6
+ function ln(e, t) {
7
+ return e ? e.replace(/[\\/]+$/, "") + "/" + t : t;
8
+ }
9
+ function Ze(e, t) {
10
+ return t && e && e.startsWith(t) ? "~" + e.slice(t.length) : e;
11
+ }
12
+ function q(e) {
13
+ return e && e.replace(/\\/g, "/");
14
+ }
15
+ function cn(e) {
16
+ const t = q(e || "").replace(/\/+$/, "");
17
+ if (!t) return "";
18
+ const n = t.lastIndexOf("/");
19
+ return n < 0 ? "" : n === 0 ? "/" : t.slice(0, n);
20
+ }
21
+ function gt(e) {
22
+ const t = q(e), n = t.lastIndexOf("/");
23
+ return n >= 0 ? t.slice(0, n) : t;
24
+ }
25
+ const Bo = { ts: "typescript", tsx: "typescript", js: "javascript", jsx: "javascript", mjs: "javascript", json: "json", css: "css", scss: "scss", html: "html", md: "markdown", yml: "yaml", yaml: "yaml", xml: "xml", svg: "xml", py: "python", go: "go", rs: "rust", java: "java", c: "c", cpp: "cpp", sh: "shell", sql: "sql", toml: "toml" }, Wo = { typescript: "#3178c6", javascript: "#f1dd2f", json: "#a0a0a0", css: "#42a5f5", scss: "#cd6799", html: "#e44d26", markdown: "#999", yaml: "#cb171e", xml: "#e37935", python: "#3572a5", go: "#00add8", rust: "#dea584", java: "#b07219", c: "#555", cpp: "#f34b7d", shell: "#89e051", sql: "#e38c00", toml: "#9c4221" }, dn = "pi-web:unread-session-ids";
26
+ function un() {
27
+ try {
28
+ const e = localStorage.getItem(dn), t = e ? JSON.parse(e) : [];
29
+ return new Set(Array.isArray(t) ? t : []);
30
+ } catch {
31
+ return /* @__PURE__ */ new Set();
32
+ }
33
+ }
34
+ function Lt(e) {
35
+ return e.projectKey || e.cwd || e.id;
36
+ }
37
+ function fn(e) {
38
+ const t = /* @__PURE__ */ new Map();
39
+ for (const n of e) {
40
+ const o = n.projectRoot || n.cwd;
41
+ if (!o) continue;
42
+ const s = Lt(n), i = t.get(s);
43
+ (!i || n.modified > i.modified) && t.set(s, { root: o, modified: n.modified });
44
+ }
45
+ return [...t.values()].sort((n, o) => (o.modified || "").localeCompare(n.modified || "")).map((n) => ({ key: n.root, root: n.root }));
46
+ }
47
+ function pn(e, t, n) {
48
+ const o = /* @__PURE__ */ new Map();
49
+ for (const s of e) {
50
+ const i = Lt(s);
51
+ if (!i) continue;
52
+ let r = o.get(i);
53
+ r || (r = { running: 0, unread: 0 }, o.set(i, r)), t.has(s.id) && r.running++, n.has(s.id) && r.unread++;
54
+ }
55
+ return o;
56
+ }
57
+ const hn = { modified: "#d6a84b", added: "var(--ok, #4ade80)", deleted: "var(--danger, #f87171)", renamed: "#60a5fa", untracked: "var(--ok, #4ade80)", conflict: "var(--danger, #f87171)" }, mt = { modified: "files.modified", added: "files.added", deleted: "files.deleted", renamed: "files.renamed", untracked: "files.untracked", conflict: "files.conflict" };
58
+ function jo(e) {
59
+ const t = /* @__PURE__ */ new Map();
60
+ for (const n of e) t.set(q(n.filePath), n);
61
+ return t;
62
+ }
63
+ function _o(e, t) {
64
+ const n = /* @__PURE__ */ new Set(), o = q(t || "").replace(/\/$/, "");
65
+ for (const s of e) {
66
+ let i = gt(q(s.filePath));
67
+ for (; (i === o || i.startsWith(o + "/")) && (n.add(i), i !== o); ) {
68
+ const r = gt(i);
69
+ if (r === i) break;
70
+ i = r;
71
+ }
72
+ }
73
+ return n;
74
+ }
75
+ async function gn(e, t, n) {
76
+ const o = await fetch(e(n ? "/api/files/get?hidden=1" : "/api/files/get"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: t, type: "list" }) });
77
+ if (!o.ok) throw new Error("HTTP " + o.status);
78
+ const s = await o.json();
79
+ return {
80
+ entries: (s.entries || []).map((i) => ({ name: i.name, fullPath: ln(t, i.name), isDir: i.isDir, size: i.size, ignored: !!i.ignored || i.hidden === "ignored", children: i.isDir ? [] : void 0, loaded: !i.isDir })),
81
+ // 可上溯的父目录:后端返回 parentPath 时以其为边界(null = 已到可浏览边界);
82
+ // 旧后端未返回该字段则回退 dirOf(保持旧「尽量向上」行为)。「上一个目录」按钮据此显隐。
83
+ parentPath: "parentPath" in s ? s.parentPath == null ? null : s.parentPath : cn(t)
84
+ };
85
+ }
86
+ const mn = 300 * 1e3, ye = /* @__PURE__ */ new Map();
87
+ function Dt(e, t) {
88
+ return q(e) + (t ? "#si1" : "");
89
+ }
90
+ function Ot() {
91
+ const e = Date.now();
92
+ for (const [t, n] of ye) e - n.ts > mn && ye.delete(t);
93
+ }
94
+ function yn(e, t) {
95
+ return Ot(), ye.get(Dt(e, t))?.list ?? null;
96
+ }
97
+ async function vn(e, t, n) {
98
+ const o = Dt(t, n?.showIgnored);
99
+ if (Ot(), !n?.force) {
100
+ const i = ye.get(o);
101
+ if (i) return i.list;
102
+ }
103
+ const s = await gn(e, t, n?.showIgnored);
104
+ return ye.set(o, { list: s, ts: Date.now() }), s;
105
+ }
106
+ function No(e, t) {
107
+ return yn(e, t)?.entries ?? null;
108
+ }
109
+ async function zo(e, t, n) {
110
+ return (await vn(e, t, n)).entries;
111
+ }
112
+ function Ho(e, t) {
113
+ return t && e.startsWith(t) ? e.slice(t.length).replace(/^[/\\]+/, "") : e;
114
+ }
115
+ const bn = typeof navigator < "u" && (/win/i.test(navigator.platform || "") || /windows/i.test(navigator.userAgent || ""));
116
+ function $o(e, t) {
117
+ const n = q(e) || "", o = q(t || "");
118
+ if (!o) return n;
119
+ const s = o.endsWith("/") ? o : o + "/";
120
+ return (bn ? n.toLowerCase().startsWith(s.toLowerCase()) : n.startsWith(s)) ? n.slice(s.length) : n;
121
+ }
122
+ function Vo(e) {
123
+ const t = [], n = /* @__PURE__ */ new Map();
124
+ for (const s of e) {
125
+ const i = s.split("/");
126
+ let r = t, c = "";
127
+ for (let d = 0; d < i.length; d++) {
128
+ c = c ? c + "/" + i[d] : i[d];
129
+ let u = n.get(c);
130
+ u || (u = { name: i[d], path: c, isDir: d < i.length - 1, children: [] }, n.set(c, u), r.push(u)), r = u.children;
131
+ }
132
+ }
133
+ const o = (s) => {
134
+ s.sort((i, r) => i.isDir !== r.isDir ? i.isDir ? -1 : 1 : i.name.localeCompare(r.name)), s.forEach((i) => o(i.children));
135
+ };
136
+ return o(t), t;
137
+ }
138
+ let H = null;
139
+ function wn(e) {
140
+ H = e;
141
+ }
142
+ function At(e) {
143
+ return H?.getExtService?.(e);
144
+ }
145
+ function ee(e) {
146
+ return H?.[e] ?? (() => {
147
+ });
148
+ }
149
+ const I = typeof Symbol < "u" && Symbol.for ? Symbol.for("react.fragment") : 2763;
150
+ function g(...e) {
151
+ return ee("h").call(null, ...e);
152
+ }
153
+ function Tt(e) {
154
+ const [t, n, o, ...s] = e;
155
+ if (n && typeof n == "object") {
156
+ const i = { ...n };
157
+ return o != null && (i.key = o), [t, i, ...s];
158
+ }
159
+ return e;
160
+ }
161
+ const a = (...e) => g(...Tt(e)), p = (...e) => {
162
+ const n = e[1]?.children;
163
+ if (Array.isArray(n))
164
+ for (const o of n)
165
+ o && typeof o == "object" && o._store && (o._store.validated = 1);
166
+ return g(...Tt(e));
167
+ }, v = (e) => ee("useState")(e), w = (e, t) => ee("useEffect")(e, t), xn = (e, t) => ee("useLayoutEffect")(e, t), Ue = (e) => ee("useRef")(e), kn = (e, t) => ee("useCallback")(e, t), Go = (e, t) => ee("useMemo")(e, t);
168
+ function re(e) {
169
+ const t = H?.apiUrl;
170
+ return typeof t == "function" ? t(e) : e;
171
+ }
172
+ function G(e, t) {
173
+ const n = H?.t;
174
+ return typeof n == "function" ? n(e, t) : e;
175
+ }
176
+ function Ko() {
177
+ const e = H?.getFileTabs;
178
+ return typeof e == "function" ? e() || [] : [];
179
+ }
180
+ function Zo(e) {
181
+ const t = H?.closeFileTabs;
182
+ typeof t == "function" && t(e);
183
+ }
184
+ function Sn(e, t) {
185
+ const n = H?.openFile;
186
+ typeof n == "function" && n(e, t ?? le(e));
187
+ }
188
+ function En(e, t) {
189
+ const n = H?.openFolder;
190
+ typeof n == "function" && n(e, le(e));
191
+ }
192
+ function Cn() {
193
+ const e = H?.getFeatures;
194
+ return typeof e == "function" ? e() || {} : {};
195
+ }
196
+ const Ve = [];
197
+ function Mn(e) {
198
+ return Ve.push(e), () => {
199
+ const t = Ve.indexOf(e);
200
+ t >= 0 && Ve.splice(t, 1);
201
+ };
202
+ }
203
+ function In(e) {
204
+ if (e.transform !== "none" || e.perspective !== "none" || e.filter !== "none" || /transform|perspective|filter/.test(e.willChange || "")) return !0;
205
+ const t = e.contain;
206
+ return t === "strict" || t === "content" || t === "layout" || t === "paint";
207
+ }
208
+ function Ft(e) {
209
+ let t = e.parentElement;
210
+ for (; t && t !== document.documentElement; ) {
211
+ try {
212
+ if (In(getComputedStyle(t))) {
213
+ const n = t.getBoundingClientRect();
214
+ return { x: n.left, y: n.top };
215
+ }
216
+ } catch {
217
+ }
218
+ t = t.parentElement;
219
+ }
220
+ return { x: 0, y: 0 };
221
+ }
222
+ function Rt(e, t, n, o, s = 8) {
223
+ const i = window.innerWidth, r = window.innerHeight;
224
+ return {
225
+ left: Math.max(s, Math.min(e, i - s - n)),
226
+ top: Math.max(s, Math.min(t, Math.max(s, r - s - o)))
227
+ };
228
+ }
229
+ const Ln = 2500, oe = /* @__PURE__ */ new Map();
230
+ function Ye(e, t) {
231
+ const n = t?.ttlMs ?? Ln, o = oe.get(e);
232
+ if (o && (o.freshUntil === 0 || Date.now() < o.freshUntil)) return o.promise.then((i) => i.clone());
233
+ const s = fetch(e, t).then((i) => {
234
+ const r = oe.get(e);
235
+ return r && r.promise === s && (i.ok ? r.freshUntil = Date.now() + n : oe.delete(e)), i;
236
+ }).catch((i) => {
237
+ const r = oe.get(e);
238
+ throw r && r.promise === s && oe.delete(e), i;
239
+ });
240
+ return oe.set(e, { promise: s, freshUntil: 0 }), s.then((i) => i.clone());
241
+ }
242
+ const Dn = {
243
+ en: {
244
+ "files.cancel": "Cancel",
245
+ "files.loading": "Loading files...",
246
+ "files.noSubdirs": "No subdirectories",
247
+ "files.parentDir": "Parent directory",
248
+ "files.selectFolder": "Select this folder",
249
+ "i18n.close": "Close",
250
+ "sidebar.customPath": "Custom path…",
251
+ "files.openFolder": "Open Folder",
252
+ "sidebar.filterProjects": "Filter projects…",
253
+ "sidebar.noMatchingProjects": "No matching projects",
254
+ "sidebar.useDefaultDirectory": "Use default directory",
255
+ "git.branchPanelTitle": "Branch panel (branch / tag / stash)",
256
+ "git.pushTitle": "Push commits",
257
+ "git.pullTitle": "Pull (ff-only)",
258
+ "git.pushConfirm": "Push {count} commit(s) to upstream?",
259
+ "git.pullConfirm": "Pull {count} commit(s) from upstream (ff-only)?",
260
+ "git.commitTitle": "Commit",
261
+ "git.commitShort": "Commit",
262
+ "git.stageAll": "Select all",
263
+ "git.stageNone": "Staged only",
264
+ "git.stagedCount": "{count} selected",
265
+ "git.commitPlaceholder": "Commit message…",
266
+ "git.amend": "Amend last commit",
267
+ "git.commitBtn": "Commit",
268
+ "git.planShort": "Group",
269
+ "git.planTitle": "Group & commit plan (staged group-by-group, breakpoint-resumable)",
270
+ "git.planMoveTo": "Move to next group",
271
+ "git.planExclude": "Exclude from plan",
272
+ "git.planRestore": "Restore to first group",
273
+ "git.planAddGroup": "+ New group (takes last file of largest group)",
274
+ "git.planExcluded": "Excluded (won't be committed)",
275
+ "git.planStuck": "Stuck at group {group} — earlier groups already committed",
276
+ "git.planRolledBack": "rolled back to base HEAD",
277
+ "git.planRollback": "Roll back plan (reset --mixed)",
278
+ "git.planExecute": "Commit group by group",
279
+ "git.planConfirm": "Commit {count} group(s), one commit each?",
280
+ "git.planNewGroupMessage": "chore: new group",
281
+ "git.aiRefine": "AI refine",
282
+ "git.aiRefineBusy": "AI grouping… (up to 3 min)",
283
+ "git.aiMessage": "Generate",
284
+ "git.aiMessageBusy": "Generating… (up to 3 min)",
285
+ "git.aiMessageOverwrite": "Message already has content. Overwrite with the generated commit message?",
286
+ "git.aiMessageTitle": "Generate a commit message with AI (reads AGENTS.md and the diff of selected files)",
287
+ "git.stagedBucket": "Staged",
288
+ "git.unstagedBucket": "Changes",
289
+ "git.stageTitle": "Stage",
290
+ "git.unstageTitle": "Unstage",
291
+ "git.discardTitle": "Discard changes",
292
+ "git.discardConfirm": "Discard ALL uncommitted changes of {path}? (untracked files go to quarantine, recoverable by hand)",
293
+ "git.diffTitle": "View diff (git-review)",
294
+ "git.changesToggle": "Toggle changed-files section",
295
+ "git.planRetry": "Retry remaining groups"
296
+ },
297
+ "zh-CN": {
298
+ "files.cancel": "取消",
299
+ "files.loading": "正在加载文件...",
300
+ "files.noSubdirs": "无子目录",
301
+ "files.parentDir": "上级目录",
302
+ "files.selectFolder": "选择此文件夹",
303
+ "i18n.close": "关闭",
304
+ "sidebar.customPath": "自定义路径…",
305
+ "files.openFolder": "打开文件夹",
306
+ "sidebar.filterProjects": "筛选项目…",
307
+ "sidebar.noMatchingProjects": "没有匹配的项目",
308
+ "sidebar.useDefaultDirectory": "使用默认目录",
309
+ "git.branchPanelTitle": "分支面板(分支 / tag / stash)",
310
+ "git.pushTitle": "推送提交",
311
+ "git.pullTitle": "拉取(ff-only)",
312
+ "git.pushConfirm": "推送 {count} 个提交到上游?",
313
+ "git.pullConfirm": "从上游拉取 {count} 个提交(ff-only)?",
314
+ "git.commitTitle": "提交",
315
+ "git.commitShort": "提交",
316
+ "git.stageAll": "全选",
317
+ "git.stageNone": "仅暂存区",
318
+ "git.stagedCount": "已选 {count} 个",
319
+ "git.commitPlaceholder": "提交消息…",
320
+ "git.amend": "修正上一笔(amend)",
321
+ "git.commitBtn": "提交",
322
+ "git.planShort": "分组",
323
+ "git.planTitle": "分组提交计划(逐组提交 · 失败断点可回滚)",
324
+ "git.planMoveTo": "移到下一组",
325
+ "git.planExclude": "剔除出计划",
326
+ "git.planRestore": "恢复到第一组",
327
+ "git.planAddGroup": "+ 新建组(取最大组的最后一个文件)",
328
+ "git.planExcluded": "已剔除(不会提交)",
329
+ "git.planStuck": "卡在第 {group} 组——之前的组已提交",
330
+ "git.planRolledBack": "已回滚到起点 HEAD",
331
+ "git.planRollback": "回滚本计划(reset --mixed)",
332
+ "git.planExecute": "逐组提交",
333
+ "git.planConfirm": "共 {count} 组,每组一笔提交?",
334
+ "git.planNewGroupMessage": "chore: new group",
335
+ "git.aiRefine": "AI 精修",
336
+ "git.aiRefineBusy": "AI 分组中…(最长 3 分钟)",
337
+ "git.aiMessage": "生成",
338
+ "git.aiMessageBusy": "生成中…(最长 3 分钟)",
339
+ "git.aiMessageOverwrite": "输入框已有内容,生成结果将覆盖,是否继续?",
340
+ "git.aiMessageTitle": "AI 生成提交信息(读取 AGENTS.md 与所选文件的 diff)",
341
+ "git.stagedBucket": "已暂存",
342
+ "git.unstagedBucket": "工作区",
343
+ "git.stageTitle": "暂存",
344
+ "git.unstageTitle": "取消暂存",
345
+ "git.discardTitle": "丢弃变更",
346
+ "git.discardConfirm": "丢弃 {path} 的全部未提交改动?(未跟踪文件移入隔离区,可手工找回)",
347
+ "git.diffTitle": "查看 diff(git-review)",
348
+ "git.changesToggle": "开/合变更文件区",
349
+ "git.planRetry": "重试剩余组"
350
+ }
351
+ };
352
+ function On() {
353
+ const e = window.__PI_LOCALE__ || document.documentElement.lang || "en", t = String(e);
354
+ return t.startsWith("zh") ? "zh-CN" : t;
355
+ }
356
+ function R(e, t) {
357
+ const n = Dn[On()];
358
+ let o = n && n[e];
359
+ if (o === void 0 && (o = G(e)), t && typeof o == "string")
360
+ for (const [s, i] of Object.entries(t)) o = o.split("{" + s + "}").join(String(i));
361
+ return o;
362
+ }
363
+ function Uo() {
364
+ return /* @__PURE__ */ p("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "var(--text-dim)", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: [
365
+ /* @__PURE__ */ a("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
366
+ /* @__PURE__ */ a("polyline", { points: "14 2 14 8 20 8" })
367
+ ] });
368
+ }
369
+ function ve({ open: e, size: t }) {
370
+ return /* @__PURE__ */ a("svg", { width: t ?? 14, height: t ?? 14, viewBox: "0 0 24 24", fill: "none", stroke: "var(--text-dim)", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ a("path", { d: e ? "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" : "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z" }) });
371
+ }
372
+ function Pt() {
373
+ return /* @__PURE__ */ a("svg", { width: 9, height: 9, viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ a("polyline", { points: "2 3.5 5 6.5 8 3.5" }) });
374
+ }
375
+ function qe() {
376
+ return /* @__PURE__ */ a("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "var(--accent)", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ a("polyline", { points: "1.5 5 4 7.5 8.5 2.5" }) });
377
+ }
378
+ function An() {
379
+ return /* @__PURE__ */ p("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
380
+ /* @__PURE__ */ a("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
381
+ /* @__PURE__ */ a("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
382
+ ] });
383
+ }
384
+ function Tn() {
385
+ return /* @__PURE__ */ p("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
386
+ /* @__PURE__ */ a("polyline", { points: "4 17 10 11 4 5" }),
387
+ /* @__PURE__ */ a("line", { x1: "12", y1: "19", x2: "20", y2: "19" })
388
+ ] });
389
+ }
390
+ function Fn() {
391
+ return /* @__PURE__ */ p("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
392
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "3" }),
393
+ /* @__PURE__ */ a("path", { d: "M3 12h6" }),
394
+ /* @__PURE__ */ a("path", { d: "M15 12h6" })
395
+ ] });
396
+ }
397
+ function Pe({ text: e, style: t }) {
398
+ return /* @__PURE__ */ a("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", display: "block", minWidth: 0, lineHeight: 1.35, direction: "rtl", textAlign: "left", ...t || {} }, children: /* @__PURE__ */ a("span", { style: { unicodeBidi: "plaintext" }, children: e }) });
399
+ }
400
+ function Rn({ act: e, t }) {
401
+ return !e || e.running === 0 && e.unread === 0 ? null : /* @__PURE__ */ p("span", { style: { display: "inline-flex", alignItems: "center", gap: 5, flexShrink: 0, marginLeft: 6 }, children: [
402
+ e.running > 0 ? /* @__PURE__ */ p("span", { title: t("sidebar.agentRunning"), style: { display: "inline-flex", alignItems: "center", gap: 3, color: "var(--accent)", fontSize: 10, fontFamily: "var(--font-mono)" }, children: [
403
+ /* @__PURE__ */ a("svg", { width: 10, height: 10, viewBox: "0 0 24 24", fill: "none", "aria-hidden": !0, style: { display: "block" }, children: /* @__PURE__ */ p("g", { children: [
404
+ /* @__PURE__ */ a("path", { d: "M21 12a9 9 0 1 1-3.8-7.4", stroke: "currentColor", strokeWidth: 2.8, strokeLinecap: "round" }),
405
+ /* @__PURE__ */ a("animateTransform", { attributeName: "transform", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.9s", repeatCount: "indefinite" })
406
+ ] }) }),
407
+ String(e.running)
408
+ ] }) : null,
409
+ e.unread > 0 ? /* @__PURE__ */ p("span", { title: t("sidebar.newSessionActivity"), style: { display: "inline-flex", alignItems: "center", gap: 3, color: "#0891b2", fontSize: 10, fontFamily: "var(--font-mono)" }, children: [
410
+ /* @__PURE__ */ a("span", { style: { width: 6, height: 6, borderRadius: "50%", background: "currentColor", display: "inline-block" } }),
411
+ String(e.unread)
412
+ ] }) : null
413
+ ] });
414
+ }
415
+ function Yo({ status: e, t }) {
416
+ return /* @__PURE__ */ a(
417
+ "span",
418
+ {
419
+ title: t(mt[e.status] || e.status),
420
+ "aria-label": t(mt[e.status] || e.status),
421
+ style: { width: 14, height: 14, flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center", color: hn[e.status] || "var(--text-dim)", fontFamily: "var(--font-mono)", fontSize: 11, fontWeight: 600 },
422
+ children: e.code
423
+ }
424
+ );
425
+ }
426
+ function L(e) {
427
+ return function({ size: n = 13 }) {
428
+ return /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, "aria-hidden": !0, children: e() });
429
+ };
430
+ }
431
+ const Pn = L(() => /* @__PURE__ */ p(I, { children: [
432
+ /* @__PURE__ */ a("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
433
+ /* @__PURE__ */ a("path", { d: "M3 3v5h5" })
434
+ ] })), qo = L(() => /* @__PURE__ */ a(I, { children: /* @__PURE__ */ a("path", { d: "M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" }) })), Jo = L(() => /* @__PURE__ */ p(I, { children: [
435
+ /* @__PURE__ */ a("polyline", { points: "5 9 2 12 5 15" }),
436
+ /* @__PURE__ */ a("polyline", { points: "9 5 12 2 15 5" }),
437
+ /* @__PURE__ */ a("polyline", { points: "15 19 12 22 9 19" }),
438
+ /* @__PURE__ */ a("polyline", { points: "19 9 22 12 19 15" }),
439
+ /* @__PURE__ */ a("line", { x1: "2", y1: "12", x2: "22", y2: "12" }),
440
+ /* @__PURE__ */ a("line", { x1: "12", y1: "2", x2: "12", y2: "22" })
441
+ ] })), Xo = L(() => /* @__PURE__ */ p(I, { children: [
442
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "4" }),
443
+ /* @__PURE__ */ a("path", { d: "M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8" })
444
+ ] })), Qo = L(() => /* @__PURE__ */ p(I, { children: [
445
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "10" }),
446
+ /* @__PURE__ */ a("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
447
+ /* @__PURE__ */ a("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
448
+ ] })), ei = L(() => /* @__PURE__ */ p(I, { children: [
449
+ /* @__PURE__ */ a("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
450
+ /* @__PURE__ */ a("polyline", { points: "7 10 12 15 17 10" }),
451
+ /* @__PURE__ */ a("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
452
+ ] })), ti = L(() => /* @__PURE__ */ p(I, { children: [
453
+ /* @__PURE__ */ a("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
454
+ /* @__PURE__ */ a("polyline", { points: "17 8 12 3 7 8" }),
455
+ /* @__PURE__ */ a("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
456
+ ] })), ni = L(() => /* @__PURE__ */ p(I, { children: [
457
+ /* @__PURE__ */ a("polyline", { points: "3 6 5 6 21 6" }),
458
+ /* @__PURE__ */ a("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
459
+ /* @__PURE__ */ a("line", { x1: "10", y1: "11", x2: "10", y2: "17" }),
460
+ /* @__PURE__ */ a("line", { x1: "14", y1: "11", x2: "14", y2: "17" })
461
+ ] })), oi = L(() => /* @__PURE__ */ p(I, { children: [
462
+ /* @__PURE__ */ a("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
463
+ /* @__PURE__ */ a("polyline", { points: "14 2 14 8 20 8" }),
464
+ /* @__PURE__ */ a("line", { x1: "12", y1: "18", x2: "12", y2: "12" }),
465
+ /* @__PURE__ */ a("line", { x1: "9", y1: "15", x2: "15", y2: "15" })
466
+ ] })), ii = L(() => /* @__PURE__ */ p(I, { children: [
467
+ /* @__PURE__ */ a("path", { d: "M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" }),
468
+ /* @__PURE__ */ a("line", { x1: "12", y1: "11", x2: "12", y2: "17" }),
469
+ /* @__PURE__ */ a("line", { x1: "9", y1: "14", x2: "15", y2: "14" })
470
+ ] })), ri = L(() => /* @__PURE__ */ p(I, { children: [
471
+ /* @__PURE__ */ a("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
472
+ /* @__PURE__ */ a("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
473
+ ] })), ai = L(() => /* @__PURE__ */ p(I, { children: [
474
+ /* @__PURE__ */ a("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
475
+ /* @__PURE__ */ a("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }),
476
+ /* @__PURE__ */ a("line", { x1: "12", y1: "15.5", x2: "18.5", y2: "15.5" }),
477
+ /* @__PURE__ */ a("polyline", { points: "16 13 18.5 15.5 16 18" })
478
+ ] })), si = L(() => /* @__PURE__ */ p(I, { children: [
479
+ /* @__PURE__ */ a("line", { x1: "12", y1: "19", x2: "12", y2: "5" }),
480
+ /* @__PURE__ */ a("polyline", { points: "5 12 12 5 19 12" })
481
+ ] })), Bn = L(() => /* @__PURE__ */ p(I, { children: [
482
+ /* @__PURE__ */ a("circle", { cx: "11", cy: "11", r: "7" }),
483
+ /* @__PURE__ */ a("path", { d: "m20 20-4-4" })
484
+ ] })), ot = L(() => /* @__PURE__ */ p(I, { children: [
485
+ /* @__PURE__ */ a("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z" }),
486
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "3" })
487
+ ] })), li = L(() => /* @__PURE__ */ p(I, { children: [
488
+ /* @__PURE__ */ a("line", { x1: "12", y1: "17", x2: "12", y2: "22" }),
489
+ /* @__PURE__ */ a("path", { d: "M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z" })
490
+ ] })), ci = L(() => /* @__PURE__ */ p(I, { children: [
491
+ /* @__PURE__ */ a("path", { d: "M18 6 6 18" }),
492
+ /* @__PURE__ */ a("path", { d: "m6 6 12 12" })
493
+ ] })), di = L(() => /* @__PURE__ */ p(I, { children: [
494
+ /* @__PURE__ */ a("line", { x1: "3", y1: "4", x2: "3", y2: "20" }),
495
+ /* @__PURE__ */ a("path", { d: "m12 7-5 5 5 5" }),
496
+ /* @__PURE__ */ a("path", { d: "M17 12H7" })
497
+ ] })), ui = L(() => /* @__PURE__ */ p(I, { children: [
498
+ /* @__PURE__ */ a("line", { x1: "21", y1: "4", x2: "21", y2: "20" }),
499
+ /* @__PURE__ */ a("path", { d: "m12 7 5 5-5 5" }),
500
+ /* @__PURE__ */ a("path", { d: "M7 12h10" })
501
+ ] })), fi = L(() => /* @__PURE__ */ p(I, { children: [
502
+ /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "10" }),
503
+ /* @__PURE__ */ a("path", { d: "m15 9-6 6" }),
504
+ /* @__PURE__ */ a("path", { d: "m9 9 6 6" })
505
+ ] })), yt = { display: "flex", alignItems: "center", gap: 8, width: "100%", padding: "0 12px", height: 26, border: "none", background: "transparent", color: "var(--text)", cursor: "pointer", textAlign: "left" };
506
+ function Wn({ initialPath: e, onSelect: t, onCancel: n }) {
507
+ const [o, s] = v(e || ""), [i, r] = v(null), [c, d] = v(!1), [u, O] = v(null), k = kn((b) => {
508
+ if (c) return;
509
+ d(!0), O(null);
510
+ const m = b ? { path: b } : {};
511
+ fetch(re("/api/cwd/browse"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(m) }).then(async (E) => {
512
+ const A = await E.json();
513
+ if (!E.ok || A.error) throw new Error(A.error || "HTTP " + E.status);
514
+ r(A), s(A.path);
515
+ }).catch((E) => O(E && E.message ? E.message : String(E))).finally(() => d(!1));
516
+ }, [c]);
517
+ w(() => {
518
+ k(e || "");
519
+ }, []), w(() => {
520
+ const b = (m) => {
521
+ m.key === "Escape" && n();
522
+ };
523
+ return document.addEventListener("keydown", b, !0), () => document.removeEventListener("keydown", b, !0);
524
+ }, [n]);
525
+ const M = i && i.directories || [], D = i && i.drives;
526
+ return /* @__PURE__ */ a("div", { onClick: (b) => {
527
+ b.target === b.currentTarget && n();
528
+ }, style: { position: "fixed", inset: 0, zIndex: 400, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ p("div", { style: { width: "min(560px,92vw)", maxHeight: "80vh", display: "flex", flexDirection: "column", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 8, boxShadow: "0 8px 32px rgba(0,0,0,0.3)", overflow: "hidden" }, children: [
529
+ /* @__PURE__ */ p("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: "1px solid var(--border)", background: "var(--bg)", flexShrink: 0 }, children: [
530
+ /* @__PURE__ */ a("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--text)", flex: 1 }, children: R("sidebar.customPath") }),
531
+ /* @__PURE__ */ a("button", { onClick: n, title: R("i18n.close"), style: { height: 28, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12 }, children: "✕" })
532
+ ] }),
533
+ /* @__PURE__ */ p("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 12px", borderBottom: "1px solid var(--border)", flexShrink: 0, fontSize: 12, color: "var(--text-muted)", fontFamily: "var(--font-mono)", overflowX: "auto", whiteSpace: "nowrap" }, children: [
534
+ i && i.parentPath != null ? /* @__PURE__ */ a("button", { onClick: () => k(i.parentPath), title: R("files.parentDir"), style: { height: 22, padding: "0 6px", border: "1px solid var(--border)", borderRadius: 4, background: "var(--bg-panel)", color: "var(--text-muted)", cursor: "pointer", fontSize: 12, flexShrink: 0 }, children: "↑" }) : null,
535
+ /* @__PURE__ */ a("span", { title: o, style: { overflow: "hidden", textOverflow: "ellipsis" }, children: o || "/" })
536
+ ] }),
537
+ /* @__PURE__ */ p("div", { style: { flex: 1, overflowY: "auto", padding: "4px 0" }, children: [
538
+ c ? /* @__PURE__ */ a("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: R("files.loading") }) : null,
539
+ u ? /* @__PURE__ */ a("div", { style: { padding: "12px", fontSize: 12, color: "var(--danger, #f87171)" }, children: u }) : null,
540
+ !c && !u && D && D.length > 0 ? D.map((b) => /* @__PURE__ */ p("button", { onClick: () => k(b.path), style: yt, children: [
541
+ /* @__PURE__ */ a(ve, { open: !1 }),
542
+ /* @__PURE__ */ a("span", { style: { fontSize: 12 }, children: b.name })
543
+ ] }, b.path)) : null,
544
+ !c && !u && M.length === 0 && (!D || D.length === 0) ? /* @__PURE__ */ a("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: R("files.noSubdirs") }) : null,
545
+ !c && !u ? M.map((b) => /* @__PURE__ */ p("button", { onClick: () => k(b.path), onDoubleClick: () => t(b.path), style: yt, children: [
546
+ /* @__PURE__ */ a(ve, { open: !1 }),
547
+ /* @__PURE__ */ a("span", { style: { flex: 1, fontSize: 12, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: b.name }),
548
+ /* @__PURE__ */ a("span", { style: { fontSize: 10, color: "var(--text-dim)" }, children: "→" })
549
+ ] }, b.path)) : null
550
+ ] }),
551
+ /* @__PURE__ */ p("div", { style: { display: "flex", gap: 8, padding: "8px 12px", borderTop: "1px solid var(--border)", flexShrink: 0, background: "var(--bg)" }, children: [
552
+ /* @__PURE__ */ a("button", { onClick: () => o && t(o), disabled: !o, style: { height: 28, padding: "0 12px", border: "none", borderRadius: 5, background: "var(--accent)", color: "#fff", cursor: o ? "pointer" : "not-allowed", fontSize: 12, fontWeight: 600, opacity: o ? 1 : 0.5 }, children: R("files.selectFolder") }),
553
+ /* @__PURE__ */ a("button", { onClick: n, style: { height: 28, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12 }, children: R("files.cancel") })
554
+ ] })
555
+ ] }) });
556
+ }
557
+ function Bt({ selected: e, onSelect: t, onClose: n, align: o = "left", showUseDefault: s = !0, allOption: i, width: r, extraTopItem: c }) {
558
+ const d = e || "", [u, O] = v(""), [k, M] = v([]), [D, b] = v(""), [m, E] = v(/* @__PURE__ */ new Map()), [A, ce] = v(!1), [ke, Se] = v(!1), te = Ue(null), Ee = Ue(null), [K, de] = v(null);
559
+ xn(() => {
560
+ const h = te.current, S = h?.parentElement;
561
+ if (!h || !S) return;
562
+ const P = S.getBoundingClientRect(), T = 4, fe = 8;
563
+ if (r !== void 0) h.style.width = typeof r == "number" ? `${r}px` : r;
564
+ else if (o === "right") h.style.width = "min(320px,80vw)";
565
+ else {
566
+ h.style.width = "max-content";
567
+ const _ = h.getBoundingClientRect().width, pe = Math.min(480, window.innerWidth - fe * 2);
568
+ h.style.width = `${Math.min(Math.max(_, Math.min(P.width, pe)), pe)}px`;
569
+ }
570
+ const V = h.getBoundingClientRect();
571
+ let Me = o === "right" ? P.right - V.width : P.left, X = P.bottom + T;
572
+ const Ie = window.innerHeight - fe - X, He = P.top - T - fe;
573
+ V.height > Ie && He > Ie && (X = P.top - T - V.height);
574
+ const Le = Rt(Me, X, V.width, V.height, fe), De = Ft(h), ne = { left: Le.left - De.x, top: Le.top - De.y, width: V.width };
575
+ de((_) => _ && _.left === ne.left && _.top === ne.top && _.width === ne.width ? _ : ne);
576
+ }), w(() => {
577
+ const h = (S) => {
578
+ te.current && S.target instanceof Node && te.current.contains(S.target) || n();
579
+ };
580
+ return window.addEventListener("scroll", h, !0), () => window.removeEventListener("scroll", h, !0);
581
+ }, [n]), w(() => {
582
+ let h = !0;
583
+ const S = At("pi-web.home");
584
+ return (S?.ensure ? S.ensure() : Ye(re("/api/home")).then((T) => T.json()).then((T) => T?.home ?? null).catch(() => null)).then((T) => {
585
+ h && T && O(T);
586
+ }), () => {
587
+ h = !1;
588
+ };
589
+ }, []), w(() => {
590
+ const h = un();
591
+ Ye(re("/api/sessions"), { cache: "no-store" }).then((S) => S.json()).then((S) => {
592
+ const P = S.sessions || [];
593
+ M(fn(P)), E(pn(P, new Set(S.runningSessionIds || []), h));
594
+ }).catch(() => {
595
+ });
596
+ }, []);
597
+ const $ = k.length >= 8;
598
+ w(() => {
599
+ $ && (typeof window < "u" && window.matchMedia("(max-width: 640px)").matches || Ee.current?.focus());
600
+ }, [$]);
601
+ const ue = $ && D.trim() ? k.filter((h) => Ze(h.root, u).toLowerCase().includes(D.trim().toLowerCase())) : k, Ce = async () => {
602
+ Se(!0);
603
+ try {
604
+ const S = await (await fetch(re("/api/default-cwd"), { method: "POST" })).json();
605
+ S.cwd && (t(S.cwd), n());
606
+ } catch {
607
+ } finally {
608
+ Se(!1);
609
+ }
610
+ }, ze = {
611
+ position: "fixed",
612
+ zIndex: 100,
613
+ background: "var(--bg)",
614
+ border: "1px solid var(--border)",
615
+ borderRadius: 8,
616
+ boxShadow: "0 6px 20px rgba(0,0,0,0.10)",
617
+ overflow: "hidden",
618
+ // 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
619
+ ...K ? { left: K.left, top: K.top, width: K.width } : { left: -99999, top: -99999 }
620
+ };
621
+ return /* @__PURE__ */ p("div", { ref: te, style: ze, children: [
622
+ $ ? /* @__PURE__ */ a("div", { style: { padding: "6px 8px", borderBottom: "1px solid var(--border)" }, children: /* @__PURE__ */ a(
623
+ "input",
624
+ {
625
+ ref: Ee,
626
+ value: D,
627
+ onChange: (h) => b(h.target.value),
628
+ onKeyDown: (h) => {
629
+ h.key === "Escape" && (b(""), n());
630
+ },
631
+ placeholder: R("sidebar.filterProjects"),
632
+ style: { width: "100%", fontSize: 11, fontFamily: "var(--font-mono)", padding: "5px 8px", border: "1px solid var(--border)", borderRadius: 5, outline: "none", background: "var(--bg)", color: "var(--text)", boxSizing: "border-box" }
633
+ }
634
+ ) }) : null,
635
+ /* @__PURE__ */ p("div", { style: { maxHeight: "min(50vh,380px)", overflowY: "auto" }, children: [
636
+ c ? /* @__PURE__ */ a(
637
+ "button",
638
+ {
639
+ type: "button",
640
+ onClick: () => c.onClick(),
641
+ style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "var(--bg)", borderLeft: "none", borderRight: "none", borderTop: "none", borderBottom: "1px solid var(--border)", color: "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11 },
642
+ children: /* @__PURE__ */ a(Pe, { text: c.label, style: { flex: 1 } })
643
+ },
644
+ "__extra_top__"
645
+ ) : null,
646
+ i ? /* @__PURE__ */ p(
647
+ "button",
648
+ {
649
+ type: "button",
650
+ onClick: () => {
651
+ t(""), b(""), n();
652
+ },
653
+ style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "var(--bg)", borderLeft: "none", borderRight: "none", borderTop: "none", borderBottom: "1px solid var(--border)", color: d ? "var(--text-muted)" : "var(--text)", cursor: "pointer", textAlign: "left", fontSize: 11 },
654
+ children: [
655
+ d ? /* @__PURE__ */ a("span", { style: { width: 10, flexShrink: 0 } }) : /* @__PURE__ */ a(qe, {}),
656
+ /* @__PURE__ */ a(ve, { open: !1 }),
657
+ /* @__PURE__ */ a(Pe, { text: i.label, style: { flex: 1 } })
658
+ ]
659
+ },
660
+ "__all__"
661
+ ) : null,
662
+ ue.map((h) => {
663
+ const S = h.root === d;
664
+ return /* @__PURE__ */ p(
665
+ "button",
666
+ {
667
+ type: "button",
668
+ onClick: () => {
669
+ t(h.root), b(""), n();
670
+ },
671
+ title: h.root,
672
+ style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "var(--bg)", borderLeft: "none", borderRight: "none", borderTop: "none", borderBottom: "1px solid var(--border)", color: S ? "var(--text)" : "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11, fontFamily: "var(--font-mono)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
673
+ children: [
674
+ S ? /* @__PURE__ */ a(qe, {}) : /* @__PURE__ */ a("span", { style: { width: 10, flexShrink: 0 } }),
675
+ /* @__PURE__ */ a(Pe, { text: Ze(h.root, u), style: { flex: 1 } }),
676
+ /* @__PURE__ */ a(Rn, { act: m.get(h.key), t: R })
677
+ ]
678
+ },
679
+ h.key
680
+ );
681
+ }),
682
+ ue.length === 0 && D.trim() ? /* @__PURE__ */ a("div", { style: { padding: "8px 10px", fontSize: 11, color: "var(--text-dim)" }, children: R("sidebar.noMatchingProjects") }) : null
683
+ ] }),
684
+ s ? /* @__PURE__ */ p(
685
+ "button",
686
+ {
687
+ type: "button",
688
+ onClick: (h) => {
689
+ h.stopPropagation(), Ce();
690
+ },
691
+ disabled: ke,
692
+ style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "none", borderLeft: "none", borderBottom: "none", borderTop: ue.length > 0 ? "1px solid var(--border)" : "none", color: "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11 },
693
+ children: [
694
+ /* @__PURE__ */ a("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: 1.1, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ a("path", { d: "M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z" }) }),
695
+ R("sidebar.useDefaultDirectory")
696
+ ]
697
+ }
698
+ ) : null,
699
+ /* @__PURE__ */ p(
700
+ "button",
701
+ {
702
+ type: "button",
703
+ onClick: (h) => {
704
+ h.stopPropagation(), ce(!0);
705
+ },
706
+ style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "none", border: "none", color: "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11 },
707
+ children: [
708
+ /* @__PURE__ */ p("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: 1.1, strokeLinecap: "round", style: { flexShrink: 0 }, children: [
709
+ /* @__PURE__ */ a("line", { x1: "5", y1: "1", x2: "5", y2: "9" }),
710
+ /* @__PURE__ */ a("line", { x1: "1", y1: "5", x2: "9", y2: "5" })
711
+ ] }),
712
+ R("sidebar.customPath")
713
+ ]
714
+ }
715
+ ),
716
+ A ? /* @__PURE__ */ a(Wn, { initialPath: d, onSelect: (h) => {
717
+ ce(!1), n(), t(h);
718
+ }, onCancel: () => ce(!1) }) : null
719
+ ] });
720
+ }
721
+ function jn({ path: e, onSelect: t, compact: n }) {
722
+ const o = e || "", s = t || (() => {
723
+ }), i = n === !0, [r, c] = v(!1), [d, u] = v(""), O = Ue(null);
724
+ w(() => {
725
+ let M = !0;
726
+ const D = At("pi-web.home");
727
+ return (D?.ensure ? D.ensure() : Ye(re("/api/home")).then((m) => m.json()).then((m) => m?.home ?? null).catch(() => null)).then((m) => {
728
+ M && m && u(m);
729
+ }), () => {
730
+ M = !1;
731
+ };
732
+ }, []), w(() => {
733
+ if (!r) return;
734
+ const M = (D) => {
735
+ O.current && !O.current.contains(D.target) && c(!1);
736
+ };
737
+ return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
738
+ }, [r]);
739
+ const k = i ? { display: "flex", alignItems: "center", justifyContent: "center", width: 36, height: 36, padding: 0, background: "var(--bg-selected)", borderTop: "none", borderRight: "none", borderBottom: "none", borderLeft: "1px solid var(--border)", color: "var(--text)", cursor: "pointer", flexShrink: 0, transition: "color 0.12s" } : { width: "100%", display: "flex", alignItems: "center", gap: 6, padding: "6px 10px", background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 7, cursor: "pointer", fontSize: 12, color: "var(--text)", textAlign: "left", transition: "border-color 0.15s, background 0.15s" };
740
+ return /* @__PURE__ */ p("div", { ref: O, style: { position: "relative", flex: i ? void 0 : "0 1 auto", minWidth: i ? void 0 : 0, maxWidth: i ? void 0 : "60%" }, children: [
741
+ /* @__PURE__ */ p("button", { type: "button", onClick: () => c((M) => !M), title: i ? R("files.openFolder") : o, "aria-label": i ? R("files.openFolder") : void 0, style: k, children: [
742
+ i ? /* @__PURE__ */ p("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
743
+ /* @__PURE__ */ a("path", { d: "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z" }),
744
+ /* @__PURE__ */ a("line", { x1: "12", y1: "11", x2: "12", y2: "17" }),
745
+ /* @__PURE__ */ a("line", { x1: "9", y1: "14", x2: "15", y2: "14" })
746
+ ] }) : null,
747
+ i ? null : /* @__PURE__ */ a(ve, { open: !0 }),
748
+ i ? null : /* @__PURE__ */ a(Pe, { text: Ze(o, d), style: { flex: 1, fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--text)" } }),
749
+ i ? null : /* @__PURE__ */ a(Pt, {})
750
+ ] }),
751
+ r ? /* @__PURE__ */ a(
752
+ Bt,
753
+ {
754
+ selected: o,
755
+ onSelect: (M) => {
756
+ s(M), c(!1);
757
+ },
758
+ onClose: () => c(!1),
759
+ align: i ? "right" : "left"
760
+ }
761
+ ) : null
762
+ ] });
763
+ }
764
+ const C = (e) => ({ tag: "path", attrs: { d: e } }), Te = (e, t, n, o, s = 2) => ({ tag: "rect", attrs: { x: e, y: t, width: n, height: o, rx: s } }), Wt = {
765
+ /** 浮窗:圆角框 + 标题栏 + 圆点(app-window;用户 2026-09-15 定稿 C)。 */
766
+ float: [
767
+ Te(2, 4, 20, 16, 2),
768
+ C("M10 4v4"),
769
+ C("M2 8h20"),
770
+ C("M6 4v4")
771
+ ],
772
+ /** 新窗口打开:方框 + 右上外斜箭头(square-arrow-out-up-right;
773
+ * 用户 2026-09-15 拍板:B 图形用作「新窗口打开」,且仅支持的面板(文件/文件夹)显示)。 */
774
+ "new-window": [
775
+ C("M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"),
776
+ C("m21 3-9 9"),
777
+ C("M15 3h6v6")
778
+ ],
779
+ /** 左栏:方框 + 左缘粗边。 */
780
+ "panel-left": [Te(3, 3, 18, 18), C("M9 3v18")],
781
+ /** 右栏:方框 + 右缘粗边。 */
782
+ "panel-right": [Te(3, 3, 18, 18), C("M15 3v18")],
783
+ /** 底部(预留位):方框 + 下缘粗边。 */
784
+ "panel-bottom": [Te(3, 3, 18, 18), C("M3 15h18")],
785
+ "chevron-up": [C("m18 15-6-6-6 6")],
786
+ "chevron-down": [C("m6 9 6 6 6-6")],
787
+ "chevron-left": [C("m15 18-6-6 6-6")],
788
+ "chevron-right": [C("m9 18 6-6-6-6")],
789
+ "arrow-up": [C("m5 12 7-7 7 7"), C("M12 19V5")],
790
+ /** 钉住:图钉(lucide pin;⋮ 区块操作「钉住」,与 aiti-folder MiPin 同形)。 */
791
+ pin: [
792
+ { tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
793
+ C("M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z")
794
+ ],
795
+ /** 关闭:×(lucide x;⋮ 区块操作「关闭」)。 */
796
+ x: [C("M18 6 6 18"), C("m6 6 12 12")],
797
+ /** 移除本实例:垃圾桶(lucide trash;多实例区块 ⋮「移除本实例」,与 aiti-folder MiTrash 同形)。 */
798
+ trash: [
799
+ { tag: "polyline", attrs: { points: "3 6 5 6 21 6" } },
800
+ C("M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),
801
+ { tag: "line", attrs: { x1: 10, y1: 11, x2: 10, y2: 17 } },
802
+ { tag: "line", attrs: { x1: 14, y1: 11, x2: 14, y2: 17 } }
803
+ ],
804
+ /** 移动:对角双箭头(lucide move-diagonal-2;⋮「移动」行首图标——左上 + 右下,用户 2026-09-15 指定)。 */
805
+ "move-diagonal-2": [
806
+ C("M5 11V5h6"),
807
+ C("M19 13v6h-6"),
808
+ C("M5 5l14 14")
809
+ ]
810
+ };
811
+ function _n(e) {
812
+ return e === "float" || e === "floating" ? "float" : e === "sidebar-explorer" || e.startsWith("sidebar:") ? "panel-left" : e === "bottom-panel" || e.startsWith("bottom:") ? "panel-bottom" : "panel-right";
813
+ }
814
+ const vt = "http://www.w3.org/2000/svg";
815
+ function Nn(e, t = 16) {
816
+ const n = document.createElementNS(vt, "svg");
817
+ n.setAttribute("viewBox", "0 0 24 24"), n.setAttribute("width", String(t)), n.setAttribute("height", String(t)), n.setAttribute("fill", "none"), n.setAttribute("stroke", "currentColor"), n.setAttribute("stroke-width", "2"), n.setAttribute("stroke-linecap", "round"), n.setAttribute("stroke-linejoin", "round"), n.setAttribute("aria-hidden", "true");
818
+ for (const o of Wt[e] ?? []) {
819
+ const s = document.createElementNS(vt, o.tag);
820
+ for (const [i, r] of Object.entries(o.attrs)) s.setAttribute(i, String(r));
821
+ n.appendChild(s);
822
+ }
823
+ return n;
824
+ }
825
+ const zn = {
826
+ viewBox: "0 0 24 24",
827
+ fill: "none",
828
+ stroke: "currentColor",
829
+ strokeWidth: 2,
830
+ strokeLinecap: "round",
831
+ strokeLinejoin: "round"
832
+ };
833
+ function z(e) {
834
+ return `sidebar:${e}`;
835
+ }
836
+ function it(e) {
837
+ return e === "docked:sidebar-explorer" || e.startsWith("docked:sidebar:");
838
+ }
839
+ const ae = "pi:sidebar-dock:collapsed:", Je = "pi:sidebar-dock:collapsed-changed", Hn = "pi:sidebar-dock:move", $n = "pi:sidebar-dock:drop";
840
+ function bt(e) {
841
+ try {
842
+ return localStorage.getItem(ae + e) === "1";
843
+ } catch {
844
+ return !1;
845
+ }
846
+ }
847
+ function jt(e, t) {
848
+ try {
849
+ localStorage.setItem(ae + e, t ? "1" : "0");
850
+ } catch {
851
+ }
852
+ try {
853
+ window.dispatchEvent(new CustomEvent(Je, { detail: { key: e, collapsed: t } }));
854
+ } catch {
855
+ }
856
+ }
857
+ function Vn(e, t) {
858
+ try {
859
+ const n = ae + e;
860
+ localStorage.getItem(n) === null && localStorage.setItem(n, t ? "1" : "0");
861
+ } catch {
862
+ }
863
+ }
864
+ const wt = "piwe-float-installed", Gn = 1e4;
865
+ function Kn(e) {
866
+ return e ? e.map((t) => `${t.id}|${t.title}|${t.badge ?? ""}|${t.active ? 1 : 0}|${t.done ? 1 : 0}|${t.disabled ? 1 : 0}|${t.visibility ?? "always"}`).join("§") : "";
867
+ }
868
+ function Zn(e) {
869
+ return e ? e.map((t) => t.kind === "item" ? `i:${t.id ?? t.label}:${t.label}:${t.hint ?? ""}:${t.active ? 1 : 0}:${t.alwaysRun ? 1 : 0}:${t.disabled ? 1 : 0}` : t.kind === "head" ? `h:${t.label}` : "s").join("§") : "";
870
+ }
871
+ function Un(e) {
872
+ try {
873
+ return JSON.stringify(e);
874
+ } catch {
875
+ return `keys:${Object.keys(e).length}`;
876
+ }
877
+ }
878
+ function Yn() {
879
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = (i) => {
880
+ let r = e.get(i);
881
+ return r || (r = { actions: null, commands: null, state: {}, menuItems: null, pending: null, sig: { actions: "", state: "{}", menu: "" } }, e.set(i, r)), r;
882
+ }, o = (i) => {
883
+ const r = t.get(i);
884
+ if (r)
885
+ for (const c of [...r])
886
+ try {
887
+ c();
888
+ } catch {
889
+ }
890
+ }, s = (i) => {
891
+ const r = n(i), c = r.pending;
892
+ if (!c) return;
893
+ if (Date.now() - c.at > Gn) {
894
+ r.pending = null;
895
+ return;
896
+ }
897
+ const d = r.commands?.[c.id];
898
+ if (typeof d == "function") {
899
+ r.pending = null;
900
+ try {
901
+ d(c.payload);
902
+ } catch {
903
+ }
904
+ }
905
+ };
906
+ return {
907
+ register(i, r) {
908
+ const c = n(i);
909
+ if ("actions" in r) {
910
+ const d = r.actions ?? null;
911
+ c.actions = d;
912
+ const u = Kn(d);
913
+ u !== c.sig.actions && (c.sig.actions = u, o(i));
914
+ }
915
+ if ("state" in r) {
916
+ const d = r.state ?? {};
917
+ c.state = d;
918
+ const u = Un(d);
919
+ u !== c.sig.state && (c.sig.state = u, o(i));
920
+ }
921
+ if ("menuItems" in r) {
922
+ const d = r.menuItems ?? null;
923
+ c.menuItems = d;
924
+ const u = Zn(d);
925
+ u !== c.sig.menu && (c.sig.menu = u, o(i));
926
+ }
927
+ return "commands" in r && (c.commands = r.commands ?? null, s(i)), () => {
928
+ const d = e.get(i);
929
+ d && ("actions" in r && d.actions === (r.actions ?? null) && (d.actions = null, d.sig.actions = "", o(i)), "menuItems" in r && d.menuItems === (r.menuItems ?? null) && (d.menuItems = null, d.sig.menu = "", o(i)), "commands" in r && d.commands === (r.commands ?? null) && (d.commands = null), "state" in r && (d.state = {}, d.sig.state = "{}", o(i)));
930
+ };
931
+ },
932
+ request(i, r, c) {
933
+ const d = n(i), u = d.commands?.[r];
934
+ if (typeof u == "function") {
935
+ try {
936
+ u(c);
937
+ } catch {
938
+ }
939
+ return !0;
940
+ }
941
+ d.pending = { id: r, at: Date.now(), payload: c };
942
+ try {
943
+ jt(i, !1);
944
+ } catch {
945
+ }
946
+ return !1;
947
+ },
948
+ actionsOf(i) {
949
+ return e.get(i)?.actions ?? null;
950
+ },
951
+ commandsOf(i) {
952
+ return e.get(i)?.commands ?? null;
953
+ },
954
+ stateOf(i) {
955
+ return e.get(i)?.state ?? {};
956
+ },
957
+ menuItemsOf(i) {
958
+ return e.get(i)?.menuItems ?? null;
959
+ },
960
+ subscribe(i, r) {
961
+ let c = t.get(i);
962
+ return c || (c = /* @__PURE__ */ new Set(), t.set(i, c)), c.add(r), () => {
963
+ const d = t.get(i);
964
+ d && (d.delete(r), d.size === 0 && t.delete(i));
965
+ };
966
+ }
967
+ };
968
+ }
969
+ let Ge = null;
970
+ function qn() {
971
+ return Ge || (Ge = Yn()), Ge;
972
+ }
973
+ const Jn = "__piweFloat", Xe = "piwe-float-present-change", be = (e) => `pi-web:ext-float:dockpref:v1:${e}`;
974
+ function j() {
975
+ const e = window[Jn];
976
+ return e && typeof e.present == "function" ? e : null;
977
+ }
978
+ const _t = "pi-web:ext-float:localstates:v1", rt = "pi-web:ext-float:localstates-rev:v1";
979
+ function Nt() {
980
+ try {
981
+ const e = localStorage.getItem(_t), t = e ? JSON.parse(e) : null;
982
+ return new Map(Object.entries(t ?? {}));
983
+ } catch {
984
+ return /* @__PURE__ */ new Map();
985
+ }
986
+ }
987
+ const se = Nt();
988
+ let Be = "";
989
+ try {
990
+ Be = localStorage.getItem(rt) ?? "";
991
+ } catch {
992
+ }
993
+ function zt() {
994
+ let e = "";
995
+ try {
996
+ e = localStorage.getItem(rt) ?? "";
997
+ } catch {
998
+ }
999
+ if (e === Be) return;
1000
+ Be = e;
1001
+ const t = Nt();
1002
+ se.clear();
1003
+ for (const [n, o] of t) se.set(n, o);
1004
+ }
1005
+ function Xn() {
1006
+ const e = String(Date.now()) + "-" + Math.random().toString(36).slice(2, 8);
1007
+ try {
1008
+ localStorage.setItem(_t, JSON.stringify(Object.fromEntries(se))), localStorage.setItem(rt, e);
1009
+ } catch {
1010
+ }
1011
+ Be = e;
1012
+ }
1013
+ const Qe = /* @__PURE__ */ new Set(), Qn = "piwe-float-present-activate";
1014
+ function Ht(e, t, n) {
1015
+ zt();
1016
+ const o = se.get(e) ?? "closed";
1017
+ let s = o;
1018
+ if (t === "open")
1019
+ if (o.startsWith("docked:")) s = o;
1020
+ else {
1021
+ const r = to(e), c = We.get(e) ?? [], d = r && r !== "float" && (c.includes(r) || it(`docked:${r}`)) ? r : Ne.get(e) ?? c[0];
1022
+ s = d ? `docked:${d}` : "floating";
1023
+ }
1024
+ else if (t === "float") s = "floating";
1025
+ else if (t === "close") s = "closed";
1026
+ else if (t.startsWith("dock:")) {
1027
+ const r = t.slice(5);
1028
+ try {
1029
+ localStorage.setItem(be(e), r);
1030
+ } catch {
1031
+ }
1032
+ s = `docked:${r}`;
1033
+ }
1034
+ if (s === o) {
1035
+ if (o.startsWith("docked:"))
1036
+ try {
1037
+ window.dispatchEvent(new CustomEvent(Qn, { detail: { key: e, state: o, ...n?.auto ? { auto: !0 } : {} } }));
1038
+ } catch {
1039
+ }
1040
+ return;
1041
+ }
1042
+ se.set(e, s), Xn();
1043
+ const i = { key: e, state: s, ...n?.auto ? { auto: !0 } : {} };
1044
+ for (const r of Qe)
1045
+ try {
1046
+ r(i);
1047
+ } catch {
1048
+ }
1049
+ try {
1050
+ window.dispatchEvent(new CustomEvent(Xe, { detail: i }));
1051
+ } catch {
1052
+ }
1053
+ }
1054
+ function J(e, t, n) {
1055
+ const o = j();
1056
+ if (o) {
1057
+ o.present(e, t, n);
1058
+ return;
1059
+ }
1060
+ Ht(e, t, n);
1061
+ }
1062
+ function me(e) {
1063
+ const t = j();
1064
+ return t ? t.presented(e) ?? "closed" : (zt(), se.get(e) ?? "closed");
1065
+ }
1066
+ function eo(e) {
1067
+ const t = j();
1068
+ return t ? t.onPresentChange(e) : (Qe.add(e), () => Qe.delete(e));
1069
+ }
1070
+ function to(e) {
1071
+ const t = j();
1072
+ if (t) return t.dockPref(e) ?? null;
1073
+ try {
1074
+ return localStorage.getItem(be(e));
1075
+ } catch {
1076
+ return null;
1077
+ }
1078
+ }
1079
+ if (typeof window < "u")
1080
+ try {
1081
+ window.addEventListener("piwe-float-present-command", ((e) => {
1082
+ j() || !e.detail || !e.detail.key || !e.detail.mode || Ht(e.detail.key, e.detail.mode);
1083
+ }));
1084
+ } catch {
1085
+ }
1086
+ function no(e, t) {
1087
+ J(e, `dock:${t}`);
1088
+ }
1089
+ function oo(e) {
1090
+ J(e, `dock:${z(e)}`);
1091
+ }
1092
+ function io(e) {
1093
+ J(e, "float");
1094
+ }
1095
+ function et(e) {
1096
+ J(e, "close");
1097
+ }
1098
+ function ro(e) {
1099
+ try {
1100
+ localStorage.removeItem(be(e));
1101
+ } catch {
1102
+ }
1103
+ }
1104
+ function ao(e, t) {
1105
+ try {
1106
+ localStorage.getItem(be(e)) || localStorage.setItem(be(e), t);
1107
+ } catch {
1108
+ }
1109
+ const n = j();
1110
+ if (n && typeof n.registerDefaultZone == "function")
1111
+ try {
1112
+ n.registerDefaultZone(e, t);
1113
+ } catch {
1114
+ }
1115
+ Ne.set(e, t);
1116
+ }
1117
+ let ge = null, N = null, Fe = null;
1118
+ if (typeof window < "u")
1119
+ try {
1120
+ window.addEventListener("piwe-float-dock-menu", ((e) => {
1121
+ if (j()) return;
1122
+ const t = e.detail?.key;
1123
+ if (!t) return;
1124
+ if (ge === t || Fe && Fe.key === t && Date.now() - Fe.at < 350) {
1125
+ N && N.remove(), N = null, ge = null;
1126
+ return;
1127
+ }
1128
+ N && N.remove();
1129
+ const n = We.get(t)?.length ? We.get(t) : me(t).startsWith("docked:") ? [me(t).slice(7)] : [], o = Ne.get(t), s = me(t), i = document.createElement("div");
1130
+ i.setAttribute("data-ext-dock-menu", "1"), i.style.cssText = "position:fixed;z-index:2147483600;background:var(--bg-panel,#1a1a1a);border:1px solid var(--border,#444);border-radius:8px;padding:4px;display:flex;flex-direction:column;gap:2px;box-shadow:0 8px 24px rgba(0,0,0,0.4);min-width:190px;";
1131
+ const r = e.detail?.rect;
1132
+ i.style.left = Math.max(8, (r?.left ?? window.innerWidth / 2 - 70) - 60) + "px", i.style.top = (r?.bottom ?? 140) + 4 + "px";
1133
+ const c = $t(t, n, o, s, { onNewWindow: Vt(t) });
1134
+ lo(i, c, { label: "停靠方位", onPick: () => {
1135
+ N === i && (N = null, ge = null);
1136
+ } }), document.body.appendChild(i), ge = t, N = i;
1137
+ const d = (u) => {
1138
+ i.contains(u.target) || (Fe = { key: t, at: Date.now() }, i.remove(), N === i && (N = null, ge = null), document.removeEventListener("mousedown", d, !0));
1139
+ };
1140
+ setTimeout(() => document.addEventListener("mousedown", d, !0), 0);
1141
+ }));
1142
+ } catch {
1143
+ }
1144
+ const xt = {
1145
+ "sidebar-explorer": "左栏 · 区块",
1146
+ "right-panel": "右栏 · 面板"
1147
+ };
1148
+ function so(e, t, n, o) {
1149
+ const s = t.some((r) => r === "sidebar-explorer" || r.startsWith("sidebar:")), i = [];
1150
+ if (s) {
1151
+ const r = n === "sidebar-explorer" || !!n?.startsWith("sidebar:");
1152
+ i.push({
1153
+ key: "sidebar-explorer",
1154
+ icon: "panel-left",
1155
+ label: xt["sidebar-explorer"],
1156
+ hint: r ? "默认" : void 0,
1157
+ isDefault: r,
1158
+ active: it(o),
1159
+ run: () => oo(e)
1160
+ });
1161
+ }
1162
+ for (const r of t)
1163
+ r === "sidebar-explorer" || r.startsWith("sidebar:") || i.push({
1164
+ key: r,
1165
+ icon: _n(r),
1166
+ label: xt[r] ?? r,
1167
+ hint: r === n ? "默认" : void 0,
1168
+ isDefault: r === n,
1169
+ active: o === `docked:${r}`,
1170
+ run: () => no(e, r)
1171
+ });
1172
+ return i;
1173
+ }
1174
+ function $t(e, t, n, o, s) {
1175
+ const i = s?.onNewWindow ?? Vt(e);
1176
+ return [
1177
+ ...i ? [{ key: "new-window", icon: "new-window", label: "新窗口打开", run: i }] : [],
1178
+ { key: "float", icon: "float", label: "浮窗", active: o === "floating", run: () => io(e) },
1179
+ ...so(e, t, n, o)
1180
+ ];
1181
+ }
1182
+ const tt = /* @__PURE__ */ new Map();
1183
+ function at(e, t) {
1184
+ const n = j();
1185
+ if (n && typeof n.registerWindowOpener == "function")
1186
+ try {
1187
+ n.registerWindowOpener(e, t);
1188
+ } catch {
1189
+ }
1190
+ typeof t == "function" ? tt.set(e, t) : tt.delete(e);
1191
+ }
1192
+ function Vt(e) {
1193
+ const t = j();
1194
+ if (t && typeof t.windowOpenerOf == "function")
1195
+ try {
1196
+ const n = t.windowOpenerOf(e);
1197
+ if (typeof n == "function") return n;
1198
+ } catch {
1199
+ }
1200
+ return tt.get(e) ?? null;
1201
+ }
1202
+ function lo(e, t, n) {
1203
+ const o = document.createElement("div");
1204
+ if (o.setAttribute("data-ext-dock-icon-row", "1"), o.style.cssText = "display:flex;align-items:center;justify-content:space-between;gap:16px;padding:5px 10px;", n?.label) {
1205
+ const i = document.createElement("span");
1206
+ i.setAttribute("data-ext-dock-icon-row-label", "1"), i.textContent = n.label, i.style.cssText = "font-size:12px;color:var(--text-dim,#888);flex-shrink:0;user-select:none;white-space:nowrap;", o.appendChild(i);
1207
+ }
1208
+ const s = document.createElement("div");
1209
+ s.setAttribute("data-ext-dock-icon-group", "1"), s.style.cssText = "display:flex;gap:6px;margin-left:auto;flex-shrink:0;";
1210
+ for (const i of t) {
1211
+ const r = document.createElement("button");
1212
+ r.type = "button";
1213
+ const c = i.isDefault ? `${i.label}(默认)` : i.label;
1214
+ if (r.title = c, r.setAttribute("aria-label", c), i.active === !0 || i.active === !1 ? (r.setAttribute("role", "menuitemradio"), r.setAttribute("aria-checked", i.active ? "true" : "false")) : r.setAttribute("role", "menuitem"), r.setAttribute("data-ext-dock-icon", i.key), r.style.cssText = "position:relative;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border:none;background:none;border-radius:6px;padding:0;font-family:inherit;cursor:pointer;color:var(--text-muted,#888);" + (i.active ? "cursor:default;background:var(--bg-selected,#2a2a2a);color:var(--accent,#2563eb);" : ""), r.appendChild(Nn(i.icon, 16)), i.active || (r.addEventListener("mouseenter", () => {
1215
+ r.style.background = "var(--bg-hover,#262626)", r.style.color = "var(--text,#ddd)";
1216
+ }), r.addEventListener("mouseleave", () => {
1217
+ r.style.background = "none", r.style.color = "var(--text-muted,#888)";
1218
+ }), r.addEventListener("click", () => {
1219
+ n?.onPick?.(i), i.run();
1220
+ })), i.isDefault) {
1221
+ const d = document.createElement("span");
1222
+ d.setAttribute("data-ext-dock-icon-default", "1"), d.style.cssText = "position:absolute;top:3px;right:3px;width:4px;height:4px;border-radius:50%;background:var(--accent,#2563eb);pointer-events:none;", r.appendChild(d);
1223
+ }
1224
+ s.appendChild(r);
1225
+ }
1226
+ return o.appendChild(s), e.appendChild(o), o;
1227
+ }
1228
+ const We = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new Map();
1229
+ function co(e, t, n) {
1230
+ const o = j();
1231
+ if (o && typeof o.registerZones == "function") {
1232
+ try {
1233
+ o.registerZones(e, t);
1234
+ } catch {
1235
+ }
1236
+ if (n && typeof o.registerDefaultZone == "function")
1237
+ try {
1238
+ o.registerDefaultZone(e, n);
1239
+ } catch {
1240
+ }
1241
+ }
1242
+ We.set(e, t.filter(Boolean)), n && Ne.set(e, n);
1243
+ }
1244
+ function st(e) {
1245
+ const [t, n] = v(() => me(e));
1246
+ return w(() => {
1247
+ n(me(e));
1248
+ const o = ((i) => {
1249
+ i.detail?.key === e && n(i.detail.state);
1250
+ });
1251
+ window.addEventListener(Xe, o);
1252
+ const s = eo((i) => {
1253
+ i.key === e && n(i.state);
1254
+ });
1255
+ return () => {
1256
+ window.removeEventListener(Xe, o), s();
1257
+ };
1258
+ }, [e]), t;
1259
+ }
1260
+ function Gt(e, t) {
1261
+ const n = st(e);
1262
+ return t === "float" ? n === "floating" : n === `docked:${t.dock}`;
1263
+ }
1264
+ function ie(e, t = 16) {
1265
+ return g(
1266
+ "svg",
1267
+ { width: t, height: t, ...zn, "aria-hidden": "true" },
1268
+ ...Wt[e].map((n, o) => g(n.tag, { key: o, ...n.attrs }))
1269
+ );
1270
+ }
1271
+ function B() {
1272
+ const t = j()?.dockHeader;
1273
+ return t && typeof t.register == "function" ? t : qn();
1274
+ }
1275
+ function Y(e, t, n) {
1276
+ return B().request(e, t, n);
1277
+ }
1278
+ function we() {
1279
+ const [e, t] = v(0);
1280
+ return w(() => {
1281
+ const n = () => t((o) => o + 1);
1282
+ return window.addEventListener(wt, n), () => window.removeEventListener(wt, n);
1283
+ }, []), e;
1284
+ }
1285
+ function pi(e, t) {
1286
+ const n = we();
1287
+ w(() => {
1288
+ if (e)
1289
+ try {
1290
+ B().register(e, { commands: t });
1291
+ } catch {
1292
+ }
1293
+ }), w(() => {
1294
+ if (e)
1295
+ return () => {
1296
+ try {
1297
+ B().register(e, { commands: null });
1298
+ } catch {
1299
+ }
1300
+ };
1301
+ }, [e, n]);
1302
+ }
1303
+ function hi(e, t) {
1304
+ const n = we();
1305
+ w(() => {
1306
+ if (e)
1307
+ try {
1308
+ B().register(e, { state: t });
1309
+ } catch {
1310
+ }
1311
+ }), w(() => {
1312
+ if (e)
1313
+ return () => {
1314
+ try {
1315
+ B().register(e, { state: null });
1316
+ } catch {
1317
+ }
1318
+ };
1319
+ }, [e, n]);
1320
+ }
1321
+ function gi(e, t) {
1322
+ const n = we();
1323
+ w(() => {
1324
+ if (e)
1325
+ try {
1326
+ B().register(e, { menuItems: t });
1327
+ } catch {
1328
+ }
1329
+ }), w(() => {
1330
+ if (e)
1331
+ return () => {
1332
+ try {
1333
+ B().register(e, { menuItems: null });
1334
+ } catch {
1335
+ }
1336
+ };
1337
+ }, [e, n]);
1338
+ }
1339
+ function uo(e) {
1340
+ const t = we(), [, n] = v(0);
1341
+ return w(() => e ? B().subscribe(e, () => n((s) => s + 1)) : void 0, [e, t]), e ? B().stateOf(e) : {};
1342
+ }
1343
+ function fo(e) {
1344
+ const t = we(), [, n] = v(0);
1345
+ w(() => B().subscribe(e, () => n((i) => i + 1)), [e, t]);
1346
+ const o = B();
1347
+ return { actions: o.actionsOf(e), menuItems: o.menuItemsOf(e), hasCommands: !!o.commandsOf(e) };
1348
+ }
1349
+ function po(e, t) {
1350
+ const n = [], o = /* @__PURE__ */ new Set();
1351
+ for (const s of [...e ?? [], ...t ?? []])
1352
+ !s || typeof s.id != "string" || o.has(s.id) || (o.add(s.id), n.push(s));
1353
+ return n;
1354
+ }
1355
+ function Kt(e) {
1356
+ const { itemKey: t, zone: n, title: o, chrome: s = "section", zones: i, defaultZone: r, children: c } = e, d = e.kind ?? "dockable", u = e.blockKey ?? t, O = v(() => bt(u)), k = e.collapsed ?? O[0], M = O[1];
1357
+ w(() => {
1358
+ if (e.collapsed !== void 0) return;
1359
+ const l = () => M(bt(u));
1360
+ return window.addEventListener(Je, l), window.addEventListener("storage", l), () => {
1361
+ window.removeEventListener(Je, l), window.removeEventListener("storage", l);
1362
+ };
1363
+ }, [u, e.collapsed]);
1364
+ const D = (l) => {
1365
+ M(l), jt(u, l), e.onToggleCollapsed?.(l);
1366
+ }, b = fo(t), [m, E] = v(null), [A, ce] = v(null), [ke, Se] = v(null), [te, Ee] = v(null), [K, de] = v(null);
1367
+ w(() => {
1368
+ if (!m || !A || !m.anchor) return;
1369
+ const l = m.anchor.getBoundingClientRect(), y = A.getBoundingClientRect(), f = 4, F = 8;
1370
+ let x = l.bottom + f;
1371
+ const Q = window.innerHeight - F - x, Oe = l.top - f - F;
1372
+ y.height > Q && Oe > Q && (x = l.top - f - y.height);
1373
+ const he = Rt(l.right - y.width, x, y.width, y.height, F), U = Ft(A), $e = { left: he.left - U.x, top: he.top - U.y };
1374
+ de((Ae) => Ae && Ae.left === $e.left && Ae.top === $e.top ? Ae : $e);
1375
+ }, [m, A]), w(() => {
1376
+ if (!m) return;
1377
+ const l = (f) => {
1378
+ const F = f.target;
1379
+ F && A?.contains(F) || F && m.anchor?.contains(F) || E(null);
1380
+ }, y = (f) => {
1381
+ A && f.target instanceof Node && A.contains(f.target) || E(null);
1382
+ };
1383
+ return document.addEventListener("mousedown", l), window.addEventListener("scroll", y, !0), () => {
1384
+ document.removeEventListener("mousedown", l), window.removeEventListener("scroll", y, !0);
1385
+ };
1386
+ }, [m, A]);
1387
+ const [$, ue] = v(null), [Ce, ze] = v(4);
1388
+ w(() => {
1389
+ if (!$) return;
1390
+ const l = () => {
1391
+ const f = $.clientWidth || 0;
1392
+ if (f <= 0) return;
1393
+ const x = Math.max(0, Math.min(6, Math.floor((f - 154) / 27)));
1394
+ ze((Q) => Q === x ? Q : x);
1395
+ };
1396
+ l();
1397
+ let y = null;
1398
+ try {
1399
+ typeof ResizeObserver == "function" && (y = new ResizeObserver(l), y.observe($));
1400
+ } catch {
1401
+ }
1402
+ return window.addEventListener("resize", l), () => {
1403
+ try {
1404
+ y && y.disconnect();
1405
+ } catch {
1406
+ }
1407
+ window.removeEventListener("resize", l);
1408
+ };
1409
+ }, [$]);
1410
+ const h = st(t), S = i && i.length ? i : n ? [n] : [], P = d === "dockable" && s === "section" && S.length > 0, T = {
1411
+ background: "none",
1412
+ border: "none",
1413
+ color: "var(--text-muted, #888)",
1414
+ cursor: "pointer",
1415
+ fontSize: 11,
1416
+ lineHeight: 1,
1417
+ padding: "2px 5px",
1418
+ flexShrink: 0,
1419
+ fontFamily: "inherit"
1420
+ }, V = po(e.headerActions, b.actions).filter((l) => !k || (l.visibility ?? "always") !== "expanded"), Me = V.slice(0, Ce), X = V.slice(Ce), Ie = (l) => g(
1421
+ "button",
1422
+ {
1423
+ key: l.id,
1424
+ type: "button",
1425
+ title: l.title,
1426
+ "aria-label": l.title,
1427
+ disabled: l.disabled === !0,
1428
+ style: {
1429
+ ...T,
1430
+ position: "relative",
1431
+ color: l.done ? "var(--ok, #4ade80)" : l.active ? "var(--accent, #2563eb)" : "var(--text-muted, #888)",
1432
+ opacity: l.disabled ? 0.5 : 1,
1433
+ cursor: l.disabled ? "default" : "pointer"
1434
+ },
1435
+ onClick: (y) => {
1436
+ l.disabled !== !0 && l.onClick(y);
1437
+ }
1438
+ },
1439
+ l.icon ? g("span", { style: { display: "inline-flex", alignItems: "center", justifyContent: "center" } }, l.icon) : g("span", { style: { fontSize: 12, fontWeight: 700, lineHeight: 1 } }, "•"),
1440
+ l.badge !== void 0 && l.badge !== null && l.badge !== "" ? g("span", {
1441
+ style: { position: "absolute", top: -5, right: -4, fontSize: 9, lineHeight: "13px", color: "var(--text-muted, #888)", background: "var(--bg-panel, #1a1a1a)", border: "1px solid var(--border, #444)", borderRadius: 7, padding: "0 3px" }
1442
+ }, String(l.badge)) : null
1443
+ ), He = () => {
1444
+ const l = [];
1445
+ if (X.length > 0) {
1446
+ l.push({ type: "head", label: "工具" });
1447
+ for (const f of X) l.push({ type: "item", label: f.title, icon: f.icon, badge: f.badge, active: f.active, alwaysRun: !0, disabled: f.disabled, run: f.onClick });
1448
+ }
1449
+ if (b.menuItems && b.menuItems.length > 0) {
1450
+ l.length > 0 && l.push({ type: "sep" });
1451
+ for (const f of b.menuItems)
1452
+ f.kind === "head" ? l.push({ type: "head", label: f.label }) : f.kind === "sep" ? l.push({ type: "sep" }) : l.push({ type: "item", label: f.label, icon: f.icon, hint: f.hint, active: f.active, alwaysRun: f.alwaysRun, disabled: f.disabled, run: f.run });
1453
+ }
1454
+ const y = [];
1455
+ if (s === "section" && y.push({ type: "icons", label: "移动", icon: ie("move-diagonal-2", 13), items: [
1456
+ { key: "move-up", icon: "chevron-up", label: "上移", run: () => kt(u, -1) },
1457
+ { key: "move-down", icon: "chevron-down", label: "下移", run: () => kt(u, 1) }
1458
+ ] }), d === "reserved" && typeof e.onRemove == "function" && y.push({ type: "item", label: "移除本实例", icon: ie("trash", 13), run: () => e.onRemove() }), Array.isArray(e.extraMenuItems))
1459
+ for (const f of e.extraMenuItems) y.push({ type: "item", label: f.label, icon: f.icon, hint: f.hint, active: f.active, alwaysRun: f.alwaysRun, run: f.run });
1460
+ return d === "dockable" && s === "section" && y.push({ type: "item", label: "关闭", icon: ie("x", 13), run: () => e.onClose ? e.onClose() : et(t) }), y.length > 0 && (l.length > 0 && l.push({ type: "sep" }), l.push({ type: "head", label: "区块" }), l.push(...y)), l;
1461
+ }, Le = m?.kind === "position" ? [{ type: "icons", label: "停靠方位", items: $t(t, S, r, h, { onNewWindow: e.onNewWindow }) }] : [], De = m?.kind === "position" ? Le : m?.kind === "main" ? He() : [], ne = (l, y) => {
1462
+ if (l.type === "sep") return g("div", { key: `sep-${y}`, style: { height: 1, background: "var(--border, #444)", margin: "3px 4px", opacity: 0.7, flexShrink: 0 } });
1463
+ if (l.type === "head") return g("div", { key: `head-${y}`, style: { fontSize: 10, color: "var(--text-dim, #888)", fontWeight: 600, padding: "4px 10px 2px", letterSpacing: 0.3, userSelect: "none", whiteSpace: "nowrap" } }, l.label);
1464
+ if (l.type === "icons") return g(
1465
+ "div",
1466
+ {
1467
+ key: `icons-${y}`,
1468
+ role: "group",
1469
+ "data-ext-dock-icon-row": "1",
1470
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 16, padding: "5px 10px", flexShrink: 0 }
1471
+ },
1472
+ l.label ? g(
1473
+ "span",
1474
+ {
1475
+ key: "label",
1476
+ "data-ext-dock-icon-row-label": "1",
1477
+ // 行首图标(可选):带图标 = 动作行(正文字色,与其余 icon+text 行同款);
1478
+ // 无图标 = 纯说明名(dim,位置菜单「停靠方位」标题原样)。
1479
+ style: {
1480
+ display: "inline-flex",
1481
+ alignItems: "center",
1482
+ gap: 6,
1483
+ fontSize: 12,
1484
+ color: l.icon ? "var(--text, #ddd)" : "var(--text-dim, #888)",
1485
+ flexShrink: 0,
1486
+ userSelect: "none",
1487
+ whiteSpace: "nowrap"
1488
+ }
1489
+ },
1490
+ l.icon ? g("span", { style: { display: "inline-flex", flexShrink: 0 } }, l.icon) : null,
1491
+ l.label
1492
+ ) : null,
1493
+ g(
1494
+ "div",
1495
+ {
1496
+ key: "group",
1497
+ "data-ext-dock-icon-group": "1",
1498
+ style: { display: "flex", gap: 6, marginLeft: "auto", flexShrink: 0 }
1499
+ },
1500
+ ...l.items.map((x, Q) => {
1501
+ const Oe = x.active === !0 || x.active === !1, he = x.isDefault ? `${x.label}(默认)` : x.label;
1502
+ return g(
1503
+ "button",
1504
+ {
1505
+ key: `icon-${Q}`,
1506
+ type: "button",
1507
+ role: Oe ? "menuitemradio" : "menuitem",
1508
+ ...Oe ? { "aria-checked": x.active ? "true" : "false" } : {},
1509
+ title: he,
1510
+ "aria-label": he,
1511
+ "data-ext-dock-icon": x.key,
1512
+ style: {
1513
+ position: "relative",
1514
+ width: 28,
1515
+ height: 28,
1516
+ display: "inline-flex",
1517
+ alignItems: "center",
1518
+ justifyContent: "center",
1519
+ border: "none",
1520
+ borderRadius: 6,
1521
+ padding: 0,
1522
+ fontFamily: "inherit",
1523
+ cursor: x.active ? "default" : "pointer",
1524
+ background: x.active ? "var(--bg-selected, #2a2a2a)" : "none",
1525
+ color: x.active ? "var(--accent, #2563eb)" : "var(--text-muted, #888)"
1526
+ },
1527
+ onClick: () => {
1528
+ x.active || (E(null), x.run());
1529
+ },
1530
+ onMouseEnter: (U) => {
1531
+ x.active || (U.currentTarget.style.background = "var(--bg-hover, #262626)", U.currentTarget.style.color = "var(--text, #ddd)");
1532
+ },
1533
+ onMouseLeave: (U) => {
1534
+ x.active || (U.currentTarget.style.background = "none", U.currentTarget.style.color = "var(--text-muted, #888)");
1535
+ }
1536
+ },
1537
+ ie(x.icon, 16),
1538
+ x.isDefault ? g("span", { key: "dot", "data-ext-dock-icon-default": "1", style: { position: "absolute", top: 3, right: 3, width: 4, height: 4, borderRadius: "50%", background: "var(--accent, #2563eb)", pointerEvents: "none" } }) : null
1539
+ );
1540
+ })
1541
+ )
1542
+ );
1543
+ const f = l.disabled === !0, F = l.active === !0 && l.alwaysRun !== !0;
1544
+ return g(
1545
+ "button",
1546
+ {
1547
+ key: `item-${y}`,
1548
+ type: "button",
1549
+ role: "menuitem",
1550
+ disabled: f,
1551
+ style: {
1552
+ background: "none",
1553
+ border: "none",
1554
+ cursor: f || F ? "default" : "pointer",
1555
+ fontSize: 12,
1556
+ padding: "6px 12px",
1557
+ textAlign: "left",
1558
+ borderRadius: 6,
1559
+ fontFamily: "inherit",
1560
+ color: l.active ? "var(--accent, #2563eb)" : "var(--text, #ddd)",
1561
+ display: "flex",
1562
+ alignItems: "center",
1563
+ gap: 6,
1564
+ opacity: f ? 0.5 : 1,
1565
+ flexShrink: 0
1566
+ },
1567
+ onClick: () => {
1568
+ E(null), F || l.run();
1569
+ },
1570
+ onKeyDown: (x) => {
1571
+ x.key === "Escape" && E(null);
1572
+ }
1573
+ },
1574
+ l.icon ? g("span", { style: { width: 14, display: "inline-flex", justifyContent: "center", flexShrink: 0 } }, l.icon) : null,
1575
+ (l.active ? "✓ " : "") + l.label,
1576
+ l.badge !== void 0 && l.badge !== null && l.badge !== "" ? g("span", { style: { marginLeft: "auto", fontSize: 10, color: "var(--text-muted, #888)", border: "1px solid var(--border, #444)", borderRadius: 6, padding: "0 4px" } }, String(l.badge)) : null,
1577
+ l.hint ? g("span", { style: { marginLeft: "auto", fontSize: 10, color: "var(--text-muted, #888)", border: "1px solid var(--border, #444)", borderRadius: 4, padding: "0 4px" } }, l.hint) : null
1578
+ );
1579
+ }, _ = m ? g("div", {
1580
+ ref: ce,
1581
+ role: "menu",
1582
+ style: {
1583
+ position: "fixed",
1584
+ zIndex: 2147483600,
1585
+ background: "var(--bg-panel, #1a1a1a)",
1586
+ border: "1px solid var(--border, #444)",
1587
+ borderRadius: 8,
1588
+ padding: 4,
1589
+ display: "flex",
1590
+ flexDirection: "column",
1591
+ gap: 2,
1592
+ boxShadow: "0 8px 24px rgba(0,0,0,0.4)",
1593
+ minWidth: m?.kind === "position" ? 190 : 150,
1594
+ maxWidth: "calc(100vw - 16px)",
1595
+ // 长菜单滚动契约(v3):视口内可滚 + 防滚动穿透(内部滚动不触发「容器滚动即关」)
1596
+ maxHeight: "min(70vh, calc(100vh - 16px))",
1597
+ overflowY: "auto",
1598
+ overscrollBehavior: "contain",
1599
+ // 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
1600
+ ...K ? { left: K.left, top: K.top } : { left: -99999, top: -99999 }
1601
+ },
1602
+ onMouseLeave: () => E(null)
1603
+ }, De.map(ne)) : null, pe = () => D(!k), on = (l) => {
1604
+ if (l.target && typeof l.target.closest == "function" && l.target.closest("button")) {
1605
+ l.preventDefault();
1606
+ return;
1607
+ }
1608
+ Re = u;
1609
+ try {
1610
+ l.dataTransfer.setData("application/x-pi-dock", u), l.dataTransfer.effectAllowed = "move";
1611
+ } catch {
1612
+ }
1613
+ }, pt = (l) => {
1614
+ try {
1615
+ return [...l.dataTransfer?.types ?? []].includes("application/x-pi-dock");
1616
+ } catch {
1617
+ return !1;
1618
+ }
1619
+ }, ht = (l, y) => {
1620
+ const f = l.currentTarget;
1621
+ f && (f.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"), y && f.classList.add(l.clientY - f.getBoundingClientRect().top < f.getBoundingClientRect().height / 2 ? "pi-dock-drop-before" : "pi-dock-drop-after"));
1622
+ }, rn = (l) => {
1623
+ if (!pt(l)) return;
1624
+ l.preventDefault();
1625
+ const y = l.currentTarget;
1626
+ y.classList.remove("pi-dock-drop-before", "pi-dock-drop-after");
1627
+ let f = "";
1628
+ try {
1629
+ f = l.dataTransfer.getData("application/x-pi-dock") || "";
1630
+ } catch {
1631
+ }
1632
+ if (f || (f = Re || ""), !f || f === u) return;
1633
+ const F = y.getBoundingClientRect();
1634
+ ho(f, u, l.clientY - F.top < F.height / 2);
1635
+ }, Z = { ref: ue, style: { display: "flex", alignItems: "center", gap: 4, padding: "4px 8px", borderBottom: "1px solid var(--border, #333)", flexShrink: 0, minWidth: 0 }, onClick: (l) => {
1636
+ l.target && typeof l.target.closest == "function" && l.target.closest("button") || pe();
1637
+ } };
1638
+ s === "section" && (Z.draggable = !0, Z.title = "拖动排序", Z.onDragStart = on, Z.onDragOver = (l) => {
1639
+ pt(l) && Re !== u && (l.preventDefault(), l.dataTransfer.dropEffect = "move", ht(l, !0));
1640
+ }, Z.onDragLeave = (l) => {
1641
+ try {
1642
+ if (l.relatedTarget && l.currentTarget.contains(l.relatedTarget)) return;
1643
+ } catch {
1644
+ }
1645
+ ht(l, !1);
1646
+ }, Z.onDrop = rn, Z.onDragEnd = () => {
1647
+ Re = null, document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((l) => l.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
1648
+ });
1649
+ const an = e.renderTitle ? g("span", { style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center" } }, e.renderTitle()) : g("span", { style: { fontSize: 11, fontWeight: 600, color: "var(--text-muted, #999)", letterSpacing: "0.04em", textTransform: "uppercase", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, o ?? ""), sn = k && b.hasCommands;
1650
+ return g(
1651
+ "div",
1652
+ {
1653
+ "data-ext-float-dock-body": t,
1654
+ "data-ext-item": t,
1655
+ "data-ext-dock-block": u,
1656
+ // 根上带声明属性:TabBar ⇱ 菜单在 face 挂载时可直接读(注册表兜底优先)
1657
+ "data-ext-float-dock": S.join(" "),
1658
+ ...r ? { "data-ext-float-dock-default": r } : {},
1659
+ // 注册按钮数(e2e/调试断言用):当前头行可见 / 溢出
1660
+ "data-ext-dock-actions": String(Me.length),
1661
+ "data-ext-dock-actions-overflow": String(X.length),
1662
+ style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, overflow: "hidden", position: "relative" }
1663
+ },
1664
+ s === "section" && g(
1665
+ "div",
1666
+ Z,
1667
+ g(
1668
+ "button",
1669
+ {
1670
+ type: "button",
1671
+ title: k ? "展开" : "折叠",
1672
+ "aria-label": (o ?? "区块") + (k ? " 展开" : " 折叠"),
1673
+ "aria-expanded": k ? "false" : "true",
1674
+ style: { ...T, display: "flex", alignItems: "center" },
1675
+ onClick: pe
1676
+ },
1677
+ g(
1678
+ "svg",
1679
+ {
1680
+ width: 9,
1681
+ height: 9,
1682
+ viewBox: "0 0 10 10",
1683
+ fill: "none",
1684
+ stroke: "currentColor",
1685
+ strokeWidth: 1.8,
1686
+ strokeLinecap: "round",
1687
+ strokeLinejoin: "round",
1688
+ style: { transform: k ? "none" : "rotate(90deg)", transition: "transform 0.15s", flexShrink: 0 }
1689
+ },
1690
+ g("polyline", { points: "3 2 7 5 3 8" })
1691
+ )
1692
+ ),
1693
+ an,
1694
+ typeof e.count == "number" && g("span", { style: { color: "var(--text-dim, #777)", fontWeight: 400, fontSize: 10, flexShrink: 0 } }, `(${e.count})`),
1695
+ g("span", { style: { flex: 1, minWidth: 0 } }),
1696
+ ...Me.map(Ie),
1697
+ P ? g(
1698
+ "span",
1699
+ { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
1700
+ g("button", {
1701
+ ref: Ee,
1702
+ type: "button",
1703
+ title: "切换停靠位置",
1704
+ "aria-label": "切换停靠位置",
1705
+ "aria-haspopup": "menu",
1706
+ "aria-expanded": m?.kind === "position" ? "true" : "false",
1707
+ style: { ...T, fontSize: 12 },
1708
+ onClick: () => {
1709
+ m?.kind === "position" ? E(null) : (de(null), E({ kind: "position", anchor: te ?? ke }));
1710
+ }
1711
+ }, "⇱"),
1712
+ m?.kind === "position" ? _ : null
1713
+ ) : null,
1714
+ g(
1715
+ "span",
1716
+ { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
1717
+ g("button", {
1718
+ ref: Se,
1719
+ type: "button",
1720
+ title: "区块操作",
1721
+ "aria-label": "区块操作",
1722
+ "aria-haspopup": "menu",
1723
+ "aria-expanded": m?.kind === "main" ? "true" : "false",
1724
+ style: { ...T, fontSize: 12, fontWeight: 700 },
1725
+ onClick: () => {
1726
+ m?.kind === "main" ? E(null) : (de(null), E({ kind: "main", anchor: ke }));
1727
+ },
1728
+ onKeyDown: (l) => {
1729
+ l.key === "Escape" && m?.kind === "main" && E(null);
1730
+ }
1731
+ }, "⋮"),
1732
+ m?.kind === "main" ? _ : null
1733
+ )
1734
+ ),
1735
+ (!k || sn) && g("div", { style: { flex: k ? "0 0 0" : 1, minHeight: 0, overflow: "hidden", display: k ? "none" : "flex", flexDirection: "column" } }, c)
1736
+ );
1737
+ }
1738
+ function kt(e, t) {
1739
+ try {
1740
+ window.dispatchEvent(new CustomEvent(Hn, { detail: { key: e, delta: t } }));
1741
+ } catch {
1742
+ }
1743
+ }
1744
+ function ho(e, t, n) {
1745
+ try {
1746
+ window.dispatchEvent(new CustomEvent($n, { detail: { key: e, target: t, before: n } }));
1747
+ } catch {
1748
+ }
1749
+ }
1750
+ let Re = null;
1751
+ if (typeof document < "u" && !document.getElementById("pi-dock-dnd-css"))
1752
+ try {
1753
+ const e = document.createElement("style");
1754
+ e.id = "pi-dock-dnd-css", e.textContent = "[data-ext-dock-block][draggable=true] { cursor: grab; }.pi-dock-drop-before { box-shadow: inset 0 2px 0 var(--accent, #2563eb); }.pi-dock-drop-after { box-shadow: inset 0 -2px 0 var(--accent, #2563eb); }", document.head.appendChild(e);
1755
+ } catch {
1756
+ }
1757
+ function go(e) {
1758
+ const t = st(e);
1759
+ return it(t) ? t === "docked:sidebar-explorer" ? "sidebar-explorer" : t.slice(7) : null;
1760
+ }
1761
+ if (typeof document < "u" && !document.getElementById("piwe-dock-flash-css"))
1762
+ try {
1763
+ const e = document.createElement("style");
1764
+ e.id = "piwe-dock-flash-css", e.textContent = "@keyframes piwe-dock-flash-kf { 0%,100% { box-shadow: none; } 30% { box-shadow: inset 0 0 0 2px var(--accent, #2563eb); } }.piwe-dock-flash { animation: piwe-dock-flash-kf 2s ease; }", document.head.appendChild(e);
1765
+ } catch {
1766
+ }
1767
+ function mo() {
1768
+ const e = window.screen, t = e.availWidth || 1280, n = e.availHeight || 800, o = Math.round(t * 0.9), s = Math.round(n * 0.9), i = e.availLeft ?? 0, r = e.availTop ?? 0, c = i + Math.max(0, Math.round((t - o) / 2)), d = r + Math.max(0, Math.round((n - s) / 2));
1769
+ return `width=${o},height=${s},left=${c},top=${d}`;
1770
+ }
1771
+ function yo(e, t) {
1772
+ try {
1773
+ const n = t.kind === "folder" ? "list" : void 0;
1774
+ fetch(e("/api/files/ticket"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: t.path, ...n ? { type: n } : {}, kind: t.kind, cwd: t.cwd }) }).then((o) => o.json()).then((o) => {
1775
+ if (!o || !o.ticket) return;
1776
+ let s = null;
1777
+ const i = (r) => {
1778
+ if (r.origin !== location.origin || r.source !== s) return;
1779
+ const c = r.data;
1780
+ c && c.source === "aiti-viewer" && c.type === "ready" && s && !s.closed && (s.postMessage({ source: "aiti-viewer", type: "init", ticket: o.ticket }, location.origin), window.removeEventListener("message", i));
1781
+ };
1782
+ window.addEventListener("message", i), s = window.open(e("/viewer"), "_blank", mo()), s || window.removeEventListener("message", i);
1783
+ }).catch(() => {
1784
+ });
1785
+ } catch {
1786
+ }
1787
+ }
1788
+ const Zt = "pi:sidebar-dock:folders", je = "pi:sidebar-dock:folders-changed", vo = 3;
1789
+ function bo() {
1790
+ let e;
1791
+ try {
1792
+ e = Cn()["behavior.folder-quota"];
1793
+ } catch {
1794
+ }
1795
+ const t = parseInt(String(e ?? ""), 10);
1796
+ return Number.isFinite(t) ? Math.min(9, Math.max(1, t)) : vo;
1797
+ }
1798
+ const Ut = "pi:folder:show-ignored", nt = "pi:folder:show-ignored-changed";
1799
+ function Yt() {
1800
+ try {
1801
+ const e = JSON.parse(localStorage.getItem(Ut) ?? "{}");
1802
+ return e && typeof e == "object" ? e : {};
1803
+ } catch {
1804
+ return {};
1805
+ }
1806
+ }
1807
+ function St(e) {
1808
+ return !!Yt()[e];
1809
+ }
1810
+ function lt(e) {
1811
+ const t = Yt(), n = !t[e], o = { ...t };
1812
+ n ? o[e] = 1 : delete o[e];
1813
+ try {
1814
+ localStorage.setItem(Ut, JSON.stringify(o));
1815
+ } catch {
1816
+ }
1817
+ try {
1818
+ window.dispatchEvent(new Event(nt));
1819
+ } catch {
1820
+ }
1821
+ return n;
1822
+ }
1823
+ function ct(e) {
1824
+ const [t, n] = v(() => St(e));
1825
+ return w(() => {
1826
+ const o = () => n(St(e));
1827
+ return window.addEventListener(nt, o), window.addEventListener("storage", o), () => {
1828
+ window.removeEventListener(nt, o), window.removeEventListener("storage", o);
1829
+ };
1830
+ }, [e]), t;
1831
+ }
1832
+ function wo(e) {
1833
+ if (!Array.isArray(e)) return [];
1834
+ const t = [];
1835
+ for (const n of e)
1836
+ if (typeof n == "string") t.push({ p: n });
1837
+ else if (n && typeof n == "object" && typeof n.p == "string") {
1838
+ const o = n;
1839
+ t.push(o.pin ? { p: o.p, pin: 1 } : { p: o.p });
1840
+ }
1841
+ return t;
1842
+ }
1843
+ function xe() {
1844
+ try {
1845
+ return wo(JSON.parse(localStorage.getItem(Zt) ?? "[]"));
1846
+ } catch {
1847
+ return [];
1848
+ }
1849
+ }
1850
+ function _e(e) {
1851
+ try {
1852
+ localStorage.setItem(Zt, JSON.stringify(e));
1853
+ } catch {
1854
+ }
1855
+ try {
1856
+ window.dispatchEvent(new Event(je));
1857
+ } catch {
1858
+ }
1859
+ }
1860
+ function qt() {
1861
+ return xe().map((e) => e.p);
1862
+ }
1863
+ function xo() {
1864
+ return new Set(xe().filter((e) => e.pin).map((e) => e.p));
1865
+ }
1866
+ function W(e) {
1867
+ return `aiti-folder:folder:${e.replace(/[\\/]+$/, "")}`;
1868
+ }
1869
+ function dt(e, t) {
1870
+ yo(re, { path: e, kind: "folder", cwd: t });
1871
+ }
1872
+ function Jt(e) {
1873
+ const t = W(e), n = [z(t), "right-panel"];
1874
+ Vn(t, !0), ao(t, z(t)), co(t, n, z(t)), at(t, () => dt(e));
1875
+ }
1876
+ function ko(e) {
1877
+ const t = (e || "").trim();
1878
+ if (!t) return;
1879
+ Jt(t);
1880
+ const n = xe();
1881
+ if (n.some((r) => r.p === t)) return;
1882
+ let o = [...n, { p: t }];
1883
+ const s = o.filter((r) => !r.pin), i = s.slice(0, Math.max(0, s.length - bo()));
1884
+ if (i.length > 0) {
1885
+ const r = new Set(i.map((c) => c.p));
1886
+ o = o.filter((c) => !r.has(c.p));
1887
+ for (const c of i) {
1888
+ try {
1889
+ J(W(c.p), "close");
1890
+ } catch {
1891
+ }
1892
+ at(W(c.p), null);
1893
+ }
1894
+ }
1895
+ _e(o);
1896
+ }
1897
+ function Xt(e) {
1898
+ const t = (e || "").trim();
1899
+ if (!t) return;
1900
+ const n = xe();
1901
+ if (!n.some((o) => o.p === t)) {
1902
+ _e([...n, { p: t, pin: 1 }]);
1903
+ return;
1904
+ }
1905
+ _e(n.map((o) => o.p === t ? o.pin ? { p: t } : { p: t, pin: 1 } : o));
1906
+ }
1907
+ function Et(e) {
1908
+ return xo().has((e || "").trim());
1909
+ }
1910
+ function Qt(e, t = "right-panel", n) {
1911
+ const o = (e || "").trim();
1912
+ if (o) {
1913
+ ko(o);
1914
+ try {
1915
+ J(W(o), `dock:${t}`, n);
1916
+ } catch {
1917
+ }
1918
+ }
1919
+ }
1920
+ function So(e) {
1921
+ const t = (e || "").trim();
1922
+ if (t) {
1923
+ _e(xe().filter((n) => n.p !== t));
1924
+ try {
1925
+ J(W(t), "close");
1926
+ } catch {
1927
+ }
1928
+ at(W(t), null);
1929
+ }
1930
+ }
1931
+ function en(e) {
1932
+ const [t, n] = v(() => Et(e));
1933
+ return w(() => {
1934
+ const o = () => n(Et(e));
1935
+ return o(), window.addEventListener(je, o), window.addEventListener("storage", o), () => {
1936
+ window.removeEventListener(je, o), window.removeEventListener("storage", o);
1937
+ };
1938
+ }, [e]), t;
1939
+ }
1940
+ if (typeof window < "u")
1941
+ try {
1942
+ window.addEventListener("piwe-float-present-change", ((e) => {
1943
+ const t = e.detail;
1944
+ !t || t.state !== "closed" || typeof t.key != "string" || !t.key.startsWith("aiti-folder:folder:") || ro(t.key);
1945
+ }));
1946
+ } catch {
1947
+ }
1948
+ let Ct = !1;
1949
+ function Eo() {
1950
+ if (!Ct) {
1951
+ Ct = !0;
1952
+ for (const e of qt()) {
1953
+ const t = `folder:${e.replace(/[\\/]+$/, "")}`, n = W(e);
1954
+ try {
1955
+ const o = localStorage.getItem(ae + t);
1956
+ o !== null && localStorage.getItem(ae + n) === null && localStorage.setItem(ae + n, o);
1957
+ } catch {
1958
+ }
1959
+ }
1960
+ }
1961
+ }
1962
+ let Mt = null;
1963
+ function Co(e) {
1964
+ const [, t] = v(0);
1965
+ w(() => {
1966
+ let o = !0;
1967
+ return import("./folder-browser-dlVFbFla.js").then((s) => {
1968
+ o && (Mt = s.FolderBrowser, t((i) => i + 1));
1969
+ }), () => {
1970
+ o = !1;
1971
+ };
1972
+ }, []);
1973
+ const n = Mt;
1974
+ return n ? /* @__PURE__ */ a(n, { ...e }) : null;
1975
+ }
1976
+ function ut(e) {
1977
+ const t = e.path;
1978
+ return /* @__PURE__ */ a("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column", overflow: "hidden" }, children: /* @__PURE__ */ a(
1979
+ Co,
1980
+ {
1981
+ dense: !0,
1982
+ filePath: t,
1983
+ cwd: e.cwd || t,
1984
+ onOpenFile: e.onOpenFile || ((n) => Sn(n)),
1985
+ onOpenFolder: e.onOpenFolder || ((n) => En(n)),
1986
+ onAtMention: e.onAtMention,
1987
+ gitRefreshKey: e.gitRefreshKey,
1988
+ dockItemKey: e.dockItemKey,
1989
+ showIgnored: e.showIgnored === !0
1990
+ }
1991
+ ) });
1992
+ }
1993
+ function Mo(e) {
1994
+ const [t, n] = v(!1), [o, s] = v(null);
1995
+ w(() => {
1996
+ if (!t) return;
1997
+ const c = (d) => {
1998
+ o && !o.contains(d.target) && n(!1);
1999
+ };
2000
+ return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
2001
+ }, [t, o]);
2002
+ const i = e.path.replace(/[\\/]+$/, ""), r = le(i) || i || "…";
2003
+ return /* @__PURE__ */ p("span", { ref: s, style: { position: "relative", display: "inline-flex", minWidth: 0, flex: "0 1 auto" }, children: [
2004
+ /* @__PURE__ */ p(
2005
+ "button",
2006
+ {
2007
+ type: "button",
2008
+ onClick: () => n((c) => !c),
2009
+ title: e.path,
2010
+ "aria-label": "切换目录:" + e.path,
2011
+ "aria-expanded": t ? "true" : "false",
2012
+ style: { display: "inline-flex", alignItems: "center", gap: 5, minWidth: 0, maxWidth: 170, padding: "2px 4px 2px 0", background: "none", border: "none", borderRadius: 5, color: "var(--text, #222)", cursor: "pointer", fontSize: 13, fontWeight: 500, fontFamily: "inherit" },
2013
+ children: [
2014
+ /* @__PURE__ */ a(ve, { open: !0, size: 13 }),
2015
+ /* @__PURE__ */ a("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", lineHeight: 1 }, children: r }),
2016
+ /* @__PURE__ */ a(Pt, {})
2017
+ ]
2018
+ }
2019
+ ),
2020
+ t ? /* @__PURE__ */ a(
2021
+ Bt,
2022
+ {
2023
+ selected: e.path,
2024
+ onSelect: (c) => {
2025
+ n(!1), c && e.onPick(c);
2026
+ },
2027
+ onClose: () => n(!1),
2028
+ extraTopItem: e.hasParent ? { label: "↑ " + G("files.parentDir"), onClick: () => {
2029
+ n(!1), e.onParent();
2030
+ } } : void 0
2031
+ }
2032
+ ) : null
2033
+ ] });
2034
+ }
2035
+ function Io(e) {
2036
+ try {
2037
+ const t = e?.currentTarget;
2038
+ if (!t || typeof t.getBoundingClientRect != "function") return;
2039
+ const n = t.getBoundingClientRect();
2040
+ return { left: n.left, right: n.right, top: n.top, bottom: n.bottom };
2041
+ } catch {
2042
+ return;
2043
+ }
2044
+ }
2045
+ let tn = null;
2046
+ function Lo(e) {
2047
+ let t;
2048
+ try {
2049
+ const r = tn?.getExtService;
2050
+ t = r ? r("pi-web.ui") : void 0;
2051
+ } catch {
2052
+ }
2053
+ const n = (r) => {
2054
+ try {
2055
+ return t?.get?.(r);
2056
+ } catch {
2057
+ return;
2058
+ }
2059
+ }, o = (r) => String(r || "").replace(/[\\/]+$/, "").split(/[\\/]/).pop() || r, s = e?.onOpenFile ?? n("onOpenFile"), i = e?.onOpenFolder ?? n("onOpenFolder");
2060
+ return {
2061
+ cwd: e?.cwd ?? n("selectedCwd"),
2062
+ gitRefreshKey: e?.gitRefreshKey ?? n("explorerRefreshKey"),
2063
+ onOpenFile: (r) => {
2064
+ try {
2065
+ s?.(r, o(r));
2066
+ } catch {
2067
+ }
2068
+ },
2069
+ onOpenFolder: (r, c) => {
2070
+ try {
2071
+ i?.(r, c || o(r));
2072
+ } catch {
2073
+ }
2074
+ },
2075
+ onAtMention: e?.onAtMention ?? n("onAtMention")
2076
+ };
2077
+ }
2078
+ function Do(e) {
2079
+ const t = e.path, n = t.replace(/[\\/]+$/, ""), o = W(t), s = go(o), i = en(t), r = ct(t), c = uo(o);
2080
+ if (!s) return null;
2081
+ const d = le(n) || n, u = typeof c.gitCount == "number" ? c.gitCount : 0, O = typeof c.root == "string" && c.root ? c.root : n, k = [
2082
+ { id: "search", title: G("sidebar.searchFiles"), icon: /* @__PURE__ */ a(Bn, {}), active: c.searchOpen === !0, visibility: "always", onClick: () => {
2083
+ Y(o, "search");
2084
+ } },
2085
+ { id: "terminal", title: G("files.openTerminal"), icon: /* @__PURE__ */ a(Tn, {}), visibility: "always", onClick: () => {
2086
+ Y(o, "terminal");
2087
+ } },
2088
+ { id: "refresh", title: G("sidebar.refreshExplorer"), icon: c.refreshDone === !0 ? /* @__PURE__ */ a(qe, {}) : /* @__PURE__ */ a(Pn, {}), done: c.refreshDone === !0, visibility: "always", onClick: () => {
2089
+ Y(o, "refresh");
2090
+ } },
2091
+ { id: "plus", title: G("files.newFile") + " / " + G("files.uploadFile"), icon: /* @__PURE__ */ a(An, {}), visibility: "expanded", onClick: (M) => {
2092
+ Y(o, "plus", { anchor: Io(M) });
2093
+ } },
2094
+ { id: "changes", title: G("sidebar.changedFiles", { count: u }), icon: /* @__PURE__ */ a(Fn, {}), badge: u > 0 ? u : void 0, active: c.changesOpen === !0, visibility: "expanded", onClick: () => {
2095
+ Y(o, "changes");
2096
+ } },
2097
+ { id: "at", title: G("files.insertPath"), icon: /* @__PURE__ */ a("span", { style: { fontSize: 12, fontWeight: 700, lineHeight: 1 }, children: "@" }), visibility: "expanded", onClick: () => {
2098
+ Y(o, "at");
2099
+ } }
2100
+ ];
2101
+ return /* @__PURE__ */ a(
2102
+ Kt,
2103
+ {
2104
+ itemKey: o,
2105
+ blockKey: o,
2106
+ title: d,
2107
+ chrome: "section",
2108
+ kind: "dockable",
2109
+ zones: [z(o), "right-panel"],
2110
+ defaultZone: z(o),
2111
+ headerActions: k,
2112
+ renderTitle: () => /* @__PURE__ */ a(
2113
+ Mo,
2114
+ {
2115
+ path: O,
2116
+ hasParent: c.hasParent === !0,
2117
+ onPick: (M) => Y(o, "setRoot", M),
2118
+ onParent: () => Y(o, "parent")
2119
+ }
2120
+ ),
2121
+ extraMenuItems: [
2122
+ { label: "钉住", icon: ie("pin", 13), active: i, alwaysRun: !0, run: () => Xt(t) },
2123
+ { label: "显示忽略项", icon: /* @__PURE__ */ a(ot, {}), active: r, alwaysRun: !0, run: () => lt(t) }
2124
+ ],
2125
+ onNewWindow: () => dt(n, e.cwd),
2126
+ onClose: () => So(t),
2127
+ children: /* @__PURE__ */ a(ut, { ...e, dockItemKey: o, showIgnored: r })
2128
+ }
2129
+ );
2130
+ }
2131
+ function Oo(e) {
2132
+ const t = W(e.path), n = Gt(t, "float"), o = ct(e.path);
2133
+ if (!n) return null;
2134
+ const s = e.path.replace(/[\\/]+$/, "");
2135
+ return /* @__PURE__ */ a(
2136
+ "div",
2137
+ {
2138
+ style: { position: "fixed", inset: 0, zIndex: 311, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" },
2139
+ onClick: () => et(t),
2140
+ children: /* @__PURE__ */ p(
2141
+ "div",
2142
+ {
2143
+ "data-ext-float": "1",
2144
+ "data-ext-float-key": t,
2145
+ "data-ext-float-dock": `${z(t)} right-panel`,
2146
+ "data-ext-float-dock-default": z(t),
2147
+ style: {
2148
+ position: "fixed",
2149
+ width: "min(760px, 94vw)",
2150
+ height: "min(560px, 84vh)",
2151
+ display: "flex",
2152
+ flexDirection: "column",
2153
+ overflow: "hidden",
2154
+ background: "var(--bg-panel, #1a1a1a)",
2155
+ border: "1px solid var(--border, #444)",
2156
+ borderRadius: 12,
2157
+ boxShadow: "0 18px 60px rgba(0,0,0,0.4)",
2158
+ color: "var(--text, #ddd)"
2159
+ },
2160
+ onClick: (i) => i.stopPropagation(),
2161
+ children: [
2162
+ /* @__PURE__ */ p("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "10px 14px 6px", flexShrink: 0 }, children: [
2163
+ /* @__PURE__ */ a("h3", { style: { margin: 0, fontSize: 14, fontWeight: 600, flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: le(s) || s }),
2164
+ /* @__PURE__ */ a(
2165
+ "button",
2166
+ {
2167
+ type: "button",
2168
+ "aria-label": "显示忽略项",
2169
+ title: o ? "隐藏被忽略项" : "显示被忽略项",
2170
+ onClick: () => lt(e.path),
2171
+ style: { background: "none", border: "none", color: o ? "var(--accent, #2563eb)" : "var(--text-muted, #888)", cursor: "pointer", padding: "2px 6px", display: "inline-flex", alignItems: "center", fontFamily: "inherit" },
2172
+ children: /* @__PURE__ */ a(ot, {})
2173
+ }
2174
+ ),
2175
+ /* @__PURE__ */ a(
2176
+ "button",
2177
+ {
2178
+ type: "button",
2179
+ "aria-label": "关闭",
2180
+ title: "关闭",
2181
+ onClick: () => et(t),
2182
+ style: { background: "none", border: "none", color: "var(--text-muted, #888)", cursor: "pointer", fontSize: 14, padding: "2px 8px", fontFamily: "inherit" },
2183
+ children: "✕"
2184
+ }
2185
+ )
2186
+ ] }),
2187
+ /* @__PURE__ */ a(ut, { ...e, showIgnored: o })
2188
+ ]
2189
+ }
2190
+ )
2191
+ }
2192
+ );
2193
+ }
2194
+ function Ao(e) {
2195
+ const t = W(e.path), n = Gt(t, { dock: "right-panel" }), o = ct(e.path), s = en(e.path);
2196
+ return n ? /* @__PURE__ */ a(
2197
+ Kt,
2198
+ {
2199
+ itemKey: t,
2200
+ chrome: "tab",
2201
+ kind: "dockable",
2202
+ zones: [z(t), "right-panel"],
2203
+ defaultZone: z(t),
2204
+ collapsed: !1,
2205
+ extraMenuItems: [
2206
+ { label: "钉住", icon: ie("pin", 13), active: s, alwaysRun: !0, run: () => Xt(e.path) },
2207
+ { label: "显示忽略项", icon: /* @__PURE__ */ a(ot, {}), active: o, alwaysRun: !0, run: () => lt(e.path) }
2208
+ ],
2209
+ onNewWindow: () => dt(e.path.replace(/[\\/]+$/, ""), e.cwd),
2210
+ children: /* @__PURE__ */ a(ut, { ...e, showIgnored: o })
2211
+ }
2212
+ ) : null;
2213
+ }
2214
+ let Ke = null;
2215
+ function nn(e) {
2216
+ return `folder:${e.replace(/[\\/]+$/, "")}`;
2217
+ }
2218
+ const ft = /* @__PURE__ */ new Map();
2219
+ function To(e) {
2220
+ const t = le(e.replace(/[\\/]+$/, "")) || e, n = nn(e), o = (d) => ({ path: e, ...Lo(d) }), c = { stack: {
2221
+ id: n,
2222
+ render: (d) => {
2223
+ const u = o(d);
2224
+ return /* @__PURE__ */ a(Do, { path: u.path, cwd: u.cwd, onOpenFile: u.onOpenFile, onOpenFolder: u.onOpenFolder, onAtMention: u.onAtMention, gitRefreshKey: u.gitRefreshKey });
2225
+ },
2226
+ meta: { title: t, priority: 2 }
2227
+ }, float: {
2228
+ id: n,
2229
+ render: (d) => {
2230
+ const u = o(d);
2231
+ return /* @__PURE__ */ a(Oo, { path: u.path, cwd: u.cwd, onOpenFile: u.onOpenFile, onOpenFolder: u.onOpenFolder, onAtMention: u.onAtMention, gitRefreshKey: u.gitRefreshKey });
2232
+ },
2233
+ meta: { label: "文件夹", title: t }
2234
+ }, right: {
2235
+ id: n,
2236
+ render: (d) => {
2237
+ const u = o(d);
2238
+ return /* @__PURE__ */ a(Ao, { path: u.path, cwd: u.cwd, onOpenFile: u.onOpenFile, onOpenFolder: u.onOpenFolder, onAtMention: u.onAtMention, gitRefreshKey: u.gitRefreshKey });
2239
+ },
2240
+ meta: { title: t }
2241
+ } };
2242
+ return ft.set(e, c), c;
2243
+ }
2244
+ function Fo(e) {
2245
+ return ft.get(e) ?? To(e);
2246
+ }
2247
+ function Ro(e) {
2248
+ tn = e;
2249
+ const t = e.registerItems, n = e.disposeItems;
2250
+ Eo();
2251
+ const o = qt(), s = [], i = [], r = [];
2252
+ for (const c of o) {
2253
+ Jt(c);
2254
+ const { stack: d, float: u, right: O } = Fo(c);
2255
+ s.push(d), i.push(u), r.push(O);
2256
+ }
2257
+ if (Ke)
2258
+ for (const c of Ke) {
2259
+ if (o.includes(c)) continue;
2260
+ ft.delete(c);
2261
+ const d = nn(c);
2262
+ try {
2263
+ n?.("sidebarExplorerDock", [d]), n?.("dialogs", [d]), n?.("rightFileDock", [d]);
2264
+ } catch {
2265
+ }
2266
+ try {
2267
+ J(W(c), "close");
2268
+ } catch {
2269
+ }
2270
+ }
2271
+ try {
2272
+ t?.("sidebarExplorerDock", s);
2273
+ } catch {
2274
+ }
2275
+ try {
2276
+ t?.("dialogs", i);
2277
+ } catch {
2278
+ }
2279
+ try {
2280
+ t?.("rightFileDock", r);
2281
+ } catch {
2282
+ }
2283
+ Ke = o;
2284
+ }
2285
+ let It = null;
2286
+ function Po(e) {
2287
+ const [, t] = v(0);
2288
+ w(() => {
2289
+ let o = !0;
2290
+ return import("./folder-browser-dlVFbFla.js").then((s) => {
2291
+ o && (It = s.FolderBrowser, t((i) => i + 1));
2292
+ }), () => {
2293
+ o = !1;
2294
+ };
2295
+ }, []);
2296
+ const n = It;
2297
+ return n ? /* @__PURE__ */ a(n, { ...e }) : null;
2298
+ }
2299
+ try {
2300
+ window.__aitiFolder = { registerAction: Mn, openFolderDocked: Qt };
2301
+ } catch {
2302
+ }
2303
+ try {
2304
+ window.dispatchEvent(new CustomEvent("aiti-folder:ready"));
2305
+ } catch {
2306
+ }
2307
+ function mi(e) {
2308
+ wn(e), e.registerItems?.("fileViewer", [{
2309
+ id: "aiti-folder",
2310
+ render: (t) => /* @__PURE__ */ a(Po, { ...t }),
2311
+ meta: { label: "文件夹", title: "aiti-folder: folder browser", match: (t, n) => n && n.kind === "folder" }
2312
+ }]), e.registerItems?.("pathPicker", [{
2313
+ id: "aiti-folder-picker",
2314
+ // 选中目录走本扩展 dock 状态机(openFolderDocked)而非宿主 onSelect(handleOpenFolder
2315
+ // 开旧式文件夹 tab——不在 dock 状态机里,tab 条无 ⇱ 浮窗/停靠菜单)。拦截 onSelect
2316
+ // 纯扩展侧闭环:宿主 onSelect 仅用于无本扩展时的兜底路径,此处覆盖后不再触达。
2317
+ render: (t) => /* @__PURE__ */ a(jn, { ...t, onSelect: (n) => Qt(n, "right-panel") }),
2318
+ meta: { label: "目录选择", title: "aiti-folder: directory switcher (no cwd change)" }
2319
+ }]);
2320
+ try {
2321
+ const t = () => {
2322
+ try {
2323
+ Ro(e);
2324
+ } catch {
2325
+ }
2326
+ };
2327
+ t(), window.addEventListener(je, t), window.addEventListener("storage", t);
2328
+ } catch {
2329
+ }
2330
+ try {
2331
+ console.log("[aiti-folder] client 已挂载(fileViewer 文件夹接管 + pathPicker 目录选择器 + registerAction 开放点 + dock faces 多实例)");
2332
+ } catch {
2333
+ }
2334
+ }
2335
+ export {
2336
+ Ze as $,
2337
+ jn as A,
2338
+ Ve as B,
2339
+ qe as C,
2340
+ si as D,
2341
+ ei as E,
2342
+ I as F,
2343
+ ri as G,
2344
+ Xo as H,
2345
+ Pn as I,
2346
+ Qo as J,
2347
+ qo as K,
2348
+ Jo as L,
2349
+ li as M,
2350
+ ai as N,
2351
+ oi as O,
2352
+ ii as P,
2353
+ ti as Q,
2354
+ Ho as R,
2355
+ $o as S,
2356
+ Tn as T,
2357
+ q as U,
2358
+ Et as V,
2359
+ ci as W,
2360
+ Ko as X,
2361
+ Zo as Y,
2362
+ et as Z,
2363
+ fn as _,
2364
+ v as a,
2365
+ Pt as a0,
2366
+ ve as a1,
2367
+ Wn as a2,
2368
+ Vo as a3,
2369
+ zo as a4,
2370
+ Yo as a5,
2371
+ _o as a6,
2372
+ jo as a7,
2373
+ Wo as a8,
2374
+ Uo as a9,
2375
+ ni as aa,
2376
+ yo as ab,
2377
+ Bo as ac,
2378
+ di as ad,
2379
+ ui as ae,
2380
+ fi as af,
2381
+ jt as ag,
2382
+ An as ah,
2383
+ Bn as ai,
2384
+ Xt as aj,
2385
+ mi as ak,
2386
+ Ue as b,
2387
+ kn as c,
2388
+ w as d,
2389
+ xn as e,
2390
+ Rt as f,
2391
+ Ft as g,
2392
+ a as h,
2393
+ re as i,
2394
+ p as j,
2395
+ R as k,
2396
+ At as l,
2397
+ yn as m,
2398
+ W as n,
2399
+ Sn as o,
2400
+ No as p,
2401
+ st as q,
2402
+ ln as r,
2403
+ cn as s,
2404
+ G as t,
2405
+ Go as u,
2406
+ le as v,
2407
+ vn as w,
2408
+ pi as x,
2409
+ hi as y,
2410
+ gi as z
2411
+ };