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

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,3830 @@
1
+ import { u as Le, a as f, b as Oe, c as E, d as se, e as so, f as qn, g as Yn, j as l, h as e, F as dn, i as q, k as $, l as ct, o as co, p as fo, m as Nn, n as po, q as ho, t as g, r as jn, s as Sn, v as ze, w as uo, x as go, y as mo, z as yo, A as xo, B as vo, C as Vn, M as bo, D as Cn, E as Ut, G as nn, H as zt, I as Tn, T as Kt, J as on, K as rn, L as an, N as ln, O as Xn, P as Qn, Q as sn, R as Ct, S as Zn, U as Fn, V as vn, W as wo, X as ko, Y as Ln, Z as So, _ as Co, $ as Gn, a0 as To, a1 as en, a2 as Po, a3 as zo, a4 as Ro, a5 as eo, a6 as Fo, a7 as Do, a8 as Wo, a9 as Oo, aa as Pn, ab as Io, ac as Eo, ad as Bo, ae as Mo, af as Ao, ag as Ho, ah as No, ai as jo, aj as Lo } from "./entry-e6L3SQB9.js";
2
+ const Go = ["docs", "doc", "tmp", "temp", "design", "designs"];
3
+ function Ge(t) {
4
+ return String(t || "").replace(/\\/g, "/").replace(/\/+$/, "");
5
+ }
6
+ function zn(t, n) {
7
+ if (!t || !n) return !1;
8
+ const a = Ge(t), i = Ge(n);
9
+ return !a || !i ? !1 : a === i || a.startsWith(i + "/") || i.startsWith(a + "/");
10
+ }
11
+ function $o(t, n) {
12
+ return !t || !n ? !1 : n === t || n.startsWith(t + "/");
13
+ }
14
+ function Ko(t, n) {
15
+ const a = new Set((n ?? Go).map((c) => String(c).toLowerCase()));
16
+ let i = Ge(t);
17
+ for (; ; ) {
18
+ const c = i.split("/").pop() || "";
19
+ if (!c || !a.has(c.toLowerCase())) break;
20
+ const h = i.lastIndexOf("/");
21
+ if (h <= 0) break;
22
+ i = i.slice(0, h);
23
+ }
24
+ return i;
25
+ }
26
+ function Lt(t, n) {
27
+ let a = null;
28
+ for (const i of n) {
29
+ const c = Ge(String(i || ""));
30
+ c && $o(c, t) && (!a || c.length > a.length) && (a = c);
31
+ }
32
+ return a;
33
+ }
34
+ function Uo(t) {
35
+ const n = Ge(t.targetPath || t.targetDir || ""), a = Ge(t.targetDir || t.targetPath || ""), i = Ge(t.currentCwd || "");
36
+ if (!n && !a) return { cwd: i, switched: !1 };
37
+ if (i && (zn(i, n) || a && a !== n && zn(i, a)))
38
+ return { cwd: i, switched: !1 };
39
+ const c = [];
40
+ for (const w of Array.isArray(t.watchPaths) ? t.watchPaths : []) {
41
+ if (typeof w == "string") {
42
+ w && c.push(w);
43
+ continue;
44
+ }
45
+ const T = w ?? {};
46
+ c.push(Ge(T.repoRoot || T.path || ""));
47
+ }
48
+ const h = Lt(n, c) ?? (a && a !== n ? Lt(a, c) : null);
49
+ if (h) return { cwd: h, switched: !!i && h !== i };
50
+ const S = (Array.isArray(t.knownWorkspaces) ? t.knownWorkspaces : []).filter(Boolean), F = Lt(n, S) ?? (a && a !== n ? Lt(a, S) : null);
51
+ if (F) return { cwd: F, switched: !!i && F !== i };
52
+ const s = Ko(a || n, t.excludeNames), L = Lt(s, S) || s || a || n || "";
53
+ return { cwd: L, switched: !!i && L !== i };
54
+ }
55
+ function fn(t, n) {
56
+ const a = t;
57
+ return a.includes(" ") ? `@"${a}" ` : `@${a} `;
58
+ }
59
+ const _o = 6e4, wt = { t: 0, list: [] };
60
+ async function Jo(t, n) {
61
+ const a = Date.now();
62
+ if (a - wt.t < _o) return wt.list;
63
+ try {
64
+ const c = await (await n(t("/api/sessions"), { headers: { accept: "application/json" } })).json().catch(() => null), h = /* @__PURE__ */ new Set();
65
+ for (const S of c?.sessions ?? []) {
66
+ const F = Ge(S?.projectRoot ?? S?.cwd ?? "");
67
+ F && h.add(F);
68
+ }
69
+ wt.list = [...h];
70
+ } catch {
71
+ wt.list = [];
72
+ }
73
+ return wt.t = a, wt.list;
74
+ }
75
+ async function qo(t) {
76
+ const n = Ge(t.targetPath || t.targetDir || ""), a = Ge(t.currentCwd || "");
77
+ if (a && n && zn(a, n) || !t.targetDir && !t.targetPath) return a;
78
+ const i = t.fetchFn ?? ((...h) => fetch(...h)), c = await Jo(t.apiUrl, i);
79
+ try {
80
+ const S = await (await i(t.apiUrl("/api/extensions/aiti-git-trace/new-session-cwd"), {
81
+ method: "POST",
82
+ headers: { "content-type": "application/json" },
83
+ body: JSON.stringify({
84
+ targetDir: t.targetDir,
85
+ targetPath: t.targetPath || "",
86
+ cwd: t.currentCwd || "",
87
+ knownWorkspaces: c
88
+ })
89
+ })).json().catch(() => ({}));
90
+ if (S?.ok && typeof S.cwd == "string" && S.cwd) return S.cwd;
91
+ } catch {
92
+ }
93
+ return Uo({
94
+ targetDir: t.targetDir,
95
+ targetPath: t.targetPath,
96
+ currentCwd: t.currentCwd,
97
+ knownWorkspaces: c
98
+ }).cwd;
99
+ }
100
+ async function Yo(t) {
101
+ const n = t.windowRef !== void 0 ? t.windowRef : typeof window < "u" ? window : null;
102
+ n && (n.__piWebPendingComposer = { text: t.text, at: Date.now() });
103
+ const a = await qo({
104
+ targetDir: t.targetDir,
105
+ targetPath: t.targetPath,
106
+ currentCwd: t.currentCwd,
107
+ apiUrl: t.apiUrl,
108
+ fetchFn: t.fetchFn
109
+ });
110
+ (t.dispatch ?? ((c) => (typeof window < "u" ? window : null)?.dispatchEvent?.(c)))(new CustomEvent("pi-web:new-session", { detail: { cwd: a } }));
111
+ }
112
+ async function pn(t) {
113
+ const n = t.extSvc?.("session-manager.mention");
114
+ if (n?.openNewSession) {
115
+ await n.openNewSession(t.text, { targetDir: t.targetDir, targetPath: t.targetPath, currentCwd: t.currentCwd });
116
+ return;
117
+ }
118
+ await Yo({
119
+ text: t.text,
120
+ targetDir: t.targetDir,
121
+ targetPath: t.targetPath,
122
+ currentCwd: t.currentCwd,
123
+ apiUrl: t.apiUrl,
124
+ fetchFn: t.fetchFn,
125
+ dispatch: t.dispatch,
126
+ windowRef: t.windowRef
127
+ });
128
+ }
129
+ const Vo = "/api/extensions/aiti-git-ops/git";
130
+ function _t({ apiUrl: t = (a) => a, fetchImpl: n = (...a) => fetch(...a) } = {}) {
131
+ const a = async (i, c) => {
132
+ try {
133
+ const h = await n(t(Vo + i), {
134
+ method: "POST",
135
+ headers: { "Content-Type": "application/json" },
136
+ body: JSON.stringify(c ?? {})
137
+ }), S = await h.json().catch(() => ({ ok: !1, error: "HTTP " + h.status }));
138
+ return { status: h.status, data: S };
139
+ } catch (h) {
140
+ return { status: 0, data: { ok: !1, error: h instanceof Error ? h.message : String(h) } };
141
+ }
142
+ };
143
+ return {
144
+ refs: (i) => a("/refs", { cwd: i }),
145
+ log: (i, c) => a("/log", { cwd: i, cursor: c || 0 }),
146
+ checkout: (i, c, h) => a("/checkout", { cwd: i, ref: c, mode: h }),
147
+ branchCreate: (i, c, h, S = !0) => a("/branch-create", { cwd: i, name: c, from: h, checkout: S }),
148
+ branchDelete: (i, c) => a("/branch-delete", { cwd: i, name: c }),
149
+ tagCreate: (i, c, h, S) => a("/tag-create", { cwd: i, name: c, ref: h, ...S }),
150
+ commitShow: (i, c) => a("/commit-show", { cwd: i, sha: c }),
151
+ commitDiff: (i, c, h) => a("/commit-diff", { cwd: i, sha: c, paths: h }),
152
+ cherryPick: (i, c, h) => a("/cherry-pick", { cwd: i, sha: c, ...h }),
153
+ stage: (i, c) => a("/stage", { cwd: i, paths: c }),
154
+ unstage: (i, c) => a("/unstage", { cwd: i, paths: c }),
155
+ discard: (i, c) => a("/discard", { cwd: i, paths: c }),
156
+ commit: (i, c, h) => a("/commit", { cwd: i, message: c, amend: h }),
157
+ planExecute: (i, c) => a("/plan/execute", { cwd: i, groups: c }),
158
+ planRollback: (i, c) => a("/plan/rollback", { cwd: i, baseHEAD: c }),
159
+ stashList: (i) => a("/stash/list", { cwd: i }),
160
+ stashFiles: (i, c) => a("/stash/files", { cwd: i, index: c }),
161
+ stashPush: (i, c) => a("/stash/push", { cwd: i, ...c }),
162
+ stashApply: (i, c, h) => a("/stash/apply", { cwd: i, index: c, ...h }),
163
+ stashDrop: (i, c) => a("/stash/drop", { cwd: i, index: c }),
164
+ stashBranch: (i, c, h) => a("/stash/branch", { cwd: i, index: c, name: h }),
165
+ push: (i, c) => a("/push", { cwd: i, ...c }),
166
+ pull: (i, c) => a("/pull", { cwd: i, mode: c })
167
+ };
168
+ }
169
+ const bn = {
170
+ cn: {
171
+ branchChipTitle: "分支面板",
172
+ current: "当前",
173
+ head: "HEAD",
174
+ dirty: (t) => `● ${t} 未提交`,
175
+ dirtyShort: "未提交",
176
+ wtMode: "以 worktree 打开(结构性零覆盖)",
177
+ wtModeOn: "切换/新建将建 worktree,不原地检出",
178
+ filter: "过滤分支 / tag…",
179
+ branches: "分支",
180
+ remotes: (t) => `远程 ▸ (${t})`,
181
+ currentTag: "当前",
182
+ tags: "Tag",
183
+ tagCheckoutHint: "detached 检出",
184
+ createFromRef: "建分支",
185
+ newBranch: "新建分支",
186
+ newBranchPlaceholder: "新分支名(默认从 HEAD)",
187
+ createCheckout: "创建并检出",
188
+ createWt: "建 worktree",
189
+ graph: "图谱 · 最近 commit",
190
+ graphMore: "↓ 加载更多",
191
+ graphEmpty: "(空仓库)",
192
+ createAt: "在此 commit 创建分支",
193
+ from: "起点",
194
+ worktree: "Worktree",
195
+ worktreeMain: "main",
196
+ newWorktree: "+ 新建 worktree…",
197
+ worktreeBranchPlaceholder: "分支名",
198
+ worktreeRemoveTitle: "移除 worktree",
199
+ worktreeForceConfirm: "有未提交改动,强制移除?",
200
+ stash: "Stash",
201
+ stashEmpty: "(无 stash)",
202
+ stashApply: "应用(条目保留)",
203
+ stashPop: "应用并删除(pop)",
204
+ stashDrop: "丢弃",
205
+ stashExpand: "文件清单(部分提取)",
206
+ stashExtract: "提取勾选文件",
207
+ stashExtractNote: "已跟踪 restore --source / 未跟踪自第三父;条目保留不 drop",
208
+ stashPartTitle: "部分暂存",
209
+ stashPartHint: "stash push -- paths",
210
+ stashPartBtn: "仅暂存勾选文件",
211
+ stashPartNote: "未勾选文件留在工作区",
212
+ stashInteractive: "块级 -p(终端交互)",
213
+ stashInteractiveDone: "已在 aiti-cmd 打开交互终端,请在该终端内逐 hunk y/n/d",
214
+ stashInteractiveFail: "块级终端启动失败",
215
+ dropConfirmTitle: "丢弃 stash 条目",
216
+ dropConfirmNote: "gc 前可用 git stash apply <sha> 找回",
217
+ // ── commit 详情卡(图谱点行;docs/aiti-git-ops-commit-card-plan.md)──
218
+ commitView: "查看 commit",
219
+ commitBack: "← 返回图谱",
220
+ commitMergeNote: (t) => `merge · 与第一父 ${t} 对比`,
221
+ commitFiles: (t) => `变更文件 (${t})`,
222
+ commitCopySha: "复制 sha",
223
+ commitCopySubject: "复制说明",
224
+ commitBranch: "建分支",
225
+ commitTag: "打 tag",
226
+ commitTagPlaceholder: "tag 名",
227
+ commitTagDone: (t) => `tag ${t} 已创建`,
228
+ commitCheckout: "检出",
229
+ commitCheckoutTitle: "检出此 commit(detached HEAD)",
230
+ commitPick: "摘取",
231
+ commitPickTitle: "cherry-pick 到当前分支",
232
+ commitPickDone: "cherry-pick 完成",
233
+ commitPickAbort: "终止 cherry-pick",
234
+ commitPickAbortTitle: "git cherry-pick --abort(回到摘取前状态)",
235
+ commitPickConflict: "cherry-pick 冲突(仓库处于中间态):",
236
+ commitReview: "Git Review",
237
+ commitReviewTitle: "在 Git Review 中审阅此 commit(Monaco 工作区)",
238
+ commitAtNew: "@ 新会话",
239
+ commitAtNewTitle: "新会话引用此 commit(预填解读请求)",
240
+ commitFileDiffTitle: "查看此 commit 中该文件的 diff",
241
+ commitCopyPath: "复制路径",
242
+ commitOpenFile: "打开(工作区版本)",
243
+ commitAtFile: "@ 到新会话",
244
+ commitReviewFile: "Git Review 此文件",
245
+ commitDiffTruncated: "diff 过大已截断——用 Git Review 看完整版",
246
+ commitLoadFail: "commit 读取失败",
247
+ conflictTitle: "切换到",
248
+ conflictDesc: (t) => `会覆盖 ${t} 个未提交文件(dirty ∩ affected 预检):`,
249
+ conflictWt: "以 worktree 打开(推荐)",
250
+ conflictStash: "stash 后切换(可恢复)",
251
+ cancel: "取消",
252
+ close: "关闭",
253
+ detachHint: "detached",
254
+ noRepo: "非 git 目录",
255
+ loading: "加载中…",
256
+ errPrefix: "操作失败",
257
+ // ── 新建会话「分支 / Worktree」选择器(docs/pi-web-new-session-branch-worktree-plan.md)──
258
+ pickerLabel: "分支 / Worktree",
259
+ pickerFollow: "跟随工作区",
260
+ pickerSendExec: "发送时执行",
261
+ pickerWtOn: "worktree 模式:开",
262
+ pickerWtOff: "worktree 模式:关",
263
+ pickerBranchWtHint: "发送时在 worktree 打开",
264
+ pickerBranchCheckoutHint: "发送时切换当前工作区 · 与未提交改动冲突会先询问",
265
+ pickerRemoteHint: "发送时先建同名本地分支,不 checkout",
266
+ pickerManage: "管理分支…",
267
+ pickerClear: "清除(跟随工作区)",
268
+ pickerEngineAbsent: "git 引擎缺席:仅 worktree 可用,worktree 模式强制开启",
269
+ pickerAbortCheckout: "已取消发送:目标分支与未提交改动冲突——先处理改动,或改用 worktree 模式",
270
+ pickerQueryFail: "工作区状态查询失败,无法执行分支/Worktree 意图"
271
+ },
272
+ en: {
273
+ branchChipTitle: "Branch panel",
274
+ current: "current",
275
+ head: "HEAD",
276
+ dirty: (t) => `● ${t} uncommitted`,
277
+ dirtyShort: "uncommitted",
278
+ wtMode: "Open as worktree (structurally zero-overwrite)",
279
+ wtModeOn: "Switch/create will create a worktree instead of in-place checkout",
280
+ filter: "Filter branches / tags…",
281
+ branches: "Branches",
282
+ remotes: (t) => `Remotes ▸ (${t})`,
283
+ currentTag: "current",
284
+ tags: "Tags",
285
+ tagCheckoutHint: "detached checkout",
286
+ createFromRef: "branch",
287
+ newBranch: "New branch",
288
+ newBranchPlaceholder: "Branch name (from HEAD)",
289
+ createCheckout: "Create & checkout",
290
+ createWt: "New worktree",
291
+ graph: "Graph · recent commits",
292
+ graphMore: "↓ Load more",
293
+ graphEmpty: "(empty repo)",
294
+ createAt: "Create branch at this commit",
295
+ from: "from",
296
+ worktree: "Worktrees",
297
+ worktreeMain: "main",
298
+ newWorktree: "+ New worktree…",
299
+ worktreeBranchPlaceholder: "Branch name",
300
+ worktreeRemoveTitle: "Remove worktree",
301
+ worktreeForceConfirm: "Has uncommitted changes. Force remove?",
302
+ stash: "Stash",
303
+ stashEmpty: "(no stash)",
304
+ stashApply: "Apply (keep entry)",
305
+ stashPop: "Apply & drop (pop)",
306
+ stashDrop: "Drop",
307
+ stashExpand: "Files (partial restore)",
308
+ stashExtract: "Restore checked files",
309
+ stashExtractNote: "tracked: restore --source / untracked: 3rd parent; entry kept",
310
+ stashPartTitle: "Partial stash",
311
+ stashPartHint: "stash push -- paths",
312
+ stashPartBtn: "Stash checked only",
313
+ stashPartNote: "Unchecked files stay in worktree",
314
+ stashInteractive: "Hunk-level -p (terminal)",
315
+ stashInteractiveDone: "Interactive terminal opened in aiti-cmd — answer y/n/d per hunk there",
316
+ stashInteractiveFail: "Failed to start interactive terminal",
317
+ dropConfirmTitle: "Drop stash entry",
318
+ dropConfirmNote: "recoverable before gc via git stash apply <sha>",
319
+ // ── Commit card (graph row click) ──
320
+ commitView: "View commit",
321
+ commitBack: "← Back to graph",
322
+ commitMergeNote: (t) => `merge · diff vs first parent ${t}`,
323
+ commitFiles: (t) => `Changed files (${t})`,
324
+ commitCopySha: "Copy sha",
325
+ commitCopySubject: "Copy subject",
326
+ commitBranch: "Branch",
327
+ commitTag: "Tag",
328
+ commitTagPlaceholder: "tag name",
329
+ commitTagDone: (t) => `tag ${t} created`,
330
+ commitCheckout: "Checkout",
331
+ commitCheckoutTitle: "Checkout this commit (detached HEAD)",
332
+ commitPick: "Cherry-pick",
333
+ commitPickTitle: "cherry-pick onto current branch",
334
+ commitPickDone: "cherry-pick done",
335
+ commitPickAbort: "Abort cherry-pick",
336
+ commitPickAbortTitle: "git cherry-pick --abort (restore pre-pick state)",
337
+ commitPickConflict: "cherry-pick conflict (repo in mid-state):",
338
+ commitReview: "Git Review",
339
+ commitReviewTitle: "Review this commit in Git Review (Monaco workspace)",
340
+ commitAtNew: "@ New session",
341
+ commitAtNewTitle: "Reference this commit in a new session (prefilled)",
342
+ commitFileDiffTitle: "View this file's diff in this commit",
343
+ commitCopyPath: "Copy path",
344
+ commitOpenFile: "Open (worktree version)",
345
+ commitAtFile: "@ New session",
346
+ commitReviewFile: "Git Review this file",
347
+ commitDiffTruncated: "diff truncated — open Git Review for the full view",
348
+ commitLoadFail: "Failed to load commit",
349
+ conflictTitle: "Switch to",
350
+ conflictDesc: (t) => `Would overwrite ${t} uncommitted file(s) (dirty ∩ affected precheck):`,
351
+ conflictWt: "Open as worktree (recommended)",
352
+ conflictStash: "Stash then switch (recoverable)",
353
+ cancel: "Cancel",
354
+ close: "Close",
355
+ detachHint: "detached",
356
+ noRepo: "Not a git repo",
357
+ loading: "Loading…",
358
+ errPrefix: "Operation failed",
359
+ // ── New-session branch / worktree picker ──
360
+ pickerLabel: "Branch / Worktree",
361
+ pickerFollow: "Follow workspace",
362
+ pickerSendExec: "applied on send",
363
+ pickerWtOn: "worktree mode: on",
364
+ pickerWtOff: "worktree mode: off",
365
+ pickerBranchWtHint: "Opens in a worktree on send",
366
+ pickerBranchCheckoutHint: "Switches the current workspace on send · asks first when uncommitted changes conflict",
367
+ pickerRemoteHint: "Creates the local branch on send (no checkout)",
368
+ pickerManage: "Manage branches…",
369
+ pickerClear: "Clear (follow workspace)",
370
+ pickerEngineAbsent: "git engine absent: worktrees only, worktree mode forced on",
371
+ pickerAbortCheckout: "Send aborted: the target branch conflicts with uncommitted changes — resolve them or switch to worktree mode",
372
+ pickerQueryFail: "Failed to query workspace state; branch/worktree intent cannot run"
373
+ },
374
+ tw: {
375
+ branchChipTitle: "分支面板",
376
+ current: "當前",
377
+ head: "HEAD",
378
+ dirty: (t) => `● ${t} 未提交`,
379
+ dirtyShort: "未提交",
380
+ wtMode: "以 worktree 開啟(結構性零覆蓋)",
381
+ wtModeOn: "切換/新建將建 worktree,不原地檢出",
382
+ filter: "過濾分支 / tag…",
383
+ branches: "分支",
384
+ remotes: (t) => `遠端 ▸ (${t})`,
385
+ currentTag: "當前",
386
+ tags: "Tag",
387
+ tagCheckoutHint: "detached 檢出",
388
+ createFromRef: "建分支",
389
+ newBranch: "新建分支",
390
+ newBranchPlaceholder: "新分支名(預設從 HEAD)",
391
+ createCheckout: "建立並檢出",
392
+ createWt: "建 worktree",
393
+ graph: "圖譜 · 最近 commit",
394
+ graphMore: "↓ 載入更多",
395
+ graphEmpty: "(空倉庫)",
396
+ createAt: "在此 commit 建立分支",
397
+ from: "起點",
398
+ worktree: "Worktree",
399
+ worktreeMain: "main",
400
+ newWorktree: "+ 新建 worktree…",
401
+ worktreeBranchPlaceholder: "分支名",
402
+ worktreeRemoveTitle: "移除 worktree",
403
+ worktreeForceConfirm: "有未提交變更,強制移除?",
404
+ stash: "Stash",
405
+ stashEmpty: "(無 stash)",
406
+ stashApply: "套用(條目保留)",
407
+ stashPop: "套用並刪除(pop)",
408
+ stashDrop: "丟棄",
409
+ stashExpand: "檔案清單(部分提取)",
410
+ stashExtract: "提取勾選檔案",
411
+ stashExtractNote: "已跟蹤 restore --source / 未跟蹤自第三父;條目保留不 drop",
412
+ stashPartTitle: "部分暫存",
413
+ stashPartHint: "stash push -- paths",
414
+ stashPartBtn: "僅暫存勾選檔案",
415
+ stashPartNote: "未勾選檔案留在工作區",
416
+ stashInteractive: "塊級 -p(終端互動)",
417
+ stashInteractiveDone: "已在 aiti-cmd 開啟互動終端,請在該終端內逐 hunk y/n/d",
418
+ stashInteractiveFail: "塊級終端啟動失敗",
419
+ dropConfirmTitle: "丟棄 stash 條目",
420
+ dropConfirmNote: "gc 前可用 git stash apply <sha> 找回",
421
+ // ── commit 詳情卡(圖譜點行)──
422
+ commitView: "查看 commit",
423
+ commitBack: "← 返回圖譜",
424
+ commitMergeNote: (t) => `merge · 與第一父 ${t} 對比`,
425
+ commitFiles: (t) => `變更檔案 (${t})`,
426
+ commitCopySha: "複製 sha",
427
+ commitCopySubject: "複製說明",
428
+ commitBranch: "建分支",
429
+ commitTag: "打 tag",
430
+ commitTagPlaceholder: "tag 名",
431
+ commitTagDone: (t) => `tag ${t} 已建立`,
432
+ commitCheckout: "檢出",
433
+ commitCheckoutTitle: "檢出此 commit(detached HEAD)",
434
+ commitPick: "摘取",
435
+ commitPickTitle: "cherry-pick 到當前分支",
436
+ commitPickDone: "cherry-pick 完成",
437
+ commitPickAbort: "終止 cherry-pick",
438
+ commitPickAbortTitle: "git cherry-pick --abort(回到摘取前狀態)",
439
+ commitPickConflict: "cherry-pick 衝突(倉庫處於中間態):",
440
+ commitReview: "Git Review",
441
+ commitReviewTitle: "在 Git Review 中審閱此 commit(Monaco 工作區)",
442
+ commitAtNew: "@ 新會話",
443
+ commitAtNewTitle: "新會話引用此 commit(預填解讀請求)",
444
+ commitFileDiffTitle: "查看此 commit 中該檔案的 diff",
445
+ commitCopyPath: "複製路徑",
446
+ commitOpenFile: "開啟(工作區版本)",
447
+ commitAtFile: "@ 到新會話",
448
+ commitReviewFile: "Git Review 此檔案",
449
+ commitDiffTruncated: "diff 過大已截斷——用 Git Review 看完整版",
450
+ commitLoadFail: "commit 讀取失敗",
451
+ conflictTitle: "切換到",
452
+ conflictDesc: (t) => `會覆蓋 ${t} 個未提交檔案(dirty ∩ affected 預檢):`,
453
+ conflictWt: "以 worktree 開啟(推薦)",
454
+ conflictStash: "stash 後切換(可恢復)",
455
+ cancel: "取消",
456
+ close: "關閉",
457
+ detachHint: "detached",
458
+ noRepo: "非 git 目錄",
459
+ loading: "載入中…",
460
+ errPrefix: "操作失敗",
461
+ // ── 新建會話「分支 / Worktree」選擇器 ──
462
+ pickerLabel: "分支 / Worktree",
463
+ pickerFollow: "跟隨工作區",
464
+ pickerSendExec: "發送時執行",
465
+ pickerWtOn: "worktree 模式:開",
466
+ pickerWtOff: "worktree 模式:關",
467
+ pickerBranchWtHint: "發送時在 worktree 開啟",
468
+ pickerBranchCheckoutHint: "發送時切換當前工作區 · 與未提交變更衝突會先詢問",
469
+ pickerRemoteHint: "發送時先建立同名本地分支,不 checkout",
470
+ pickerManage: "管理分支…",
471
+ pickerClear: "清除(跟隨工作區)",
472
+ pickerEngineAbsent: "git 引擎缺席:僅 worktree 可用,worktree 模式強制開啟",
473
+ pickerAbortCheckout: "已取消發送:目標分支與未提交變更衝突——先處理變更,或改用 worktree 模式",
474
+ pickerQueryFail: "工作區狀態查詢失敗,無法執行分支/Worktree 意圖"
475
+ }
476
+ };
477
+ function Xo(t) {
478
+ const n = String(t || "");
479
+ return /^zh-(tw|hk)|^zh_H(TW|HK)/i.test(n) ? bn.tw : /^zh/i.test(n) ? bn.cn : bn.en;
480
+ }
481
+ function Qo(t) {
482
+ const n = Xo(t);
483
+ return (a, ...i) => {
484
+ const c = n[a];
485
+ return typeof c == "function" ? c(...i) : c ?? a;
486
+ };
487
+ }
488
+ const wn = 330;
489
+ function Zo(t) {
490
+ const n = Le(() => Qo(t.locale), [t.locale]), a = Le(() => _t({ apiUrl: t.apiUrl }), [t.apiUrl]), [i, c] = f(null), [h, S] = f(null), [F, s] = f(""), [C, L] = f(() => {
491
+ try {
492
+ return localStorage.getItem("gitops.panel.wtMode") === "1";
493
+ } catch {
494
+ return !1;
495
+ }
496
+ }), [w, T] = f(() => /* @__PURE__ */ new Set()), [p, D] = f(!1), [W, U] = f({ lines: [], nextCursor: null }), [Q, M] = f(0), [z, O] = f([]), [_, J] = f({}), [ae, le] = f(null), [ee, de] = f(() => /* @__PURE__ */ new Set()), [we, he] = f(!1), [b, P] = f(null), [R, j] = f(null), [v, I] = f(null), [A, fe] = f(null), [G, m] = f(""), [K, V] = f(null), [oe, te] = f(null), [ke, B] = f(null), [H, re] = f(null), [ce, Re] = f(!1), [ye, ge] = f(!1), [xe, dt] = f(""), [Jt, Rt] = f(null), [Ft, ft] = f(!1), [He, Dt] = f(""), [Wt, pt] = f(null), [X, ve] = f(!1), [Ot, me] = f(null), [ht, Ee] = f(null), Ae = Oe(null), [$e, Ke] = f(null), qt = E((o) => {
497
+ T((u) => {
498
+ const y = new Set(u);
499
+ return y.has(o) ? y.delete(o) : y.add(o), y;
500
+ });
501
+ }, []), mt = E(async () => {
502
+ if (!t.cwd) return;
503
+ S(null);
504
+ const [o, u, y] = await Promise.all([
505
+ a.refs(t.cwd),
506
+ a.log(t.cwd, 0),
507
+ a.stashList(t.cwd)
508
+ ]);
509
+ if (o.status === 404 || o.status === 0) {
510
+ S(o.data?.error || "HTTP " + o.status);
511
+ return;
512
+ }
513
+ if (o.status !== 200) {
514
+ S(o.data?.error || "HTTP " + o.status), c(null);
515
+ return;
516
+ }
517
+ c(o.data), U({ lines: u.data?.lines ?? [], nextCursor: u.data?.nextCursor ?? null }), M(0), O(y.data?.items ?? []);
518
+ }, [a, t.cwd]);
519
+ se(() => {
520
+ !t.open || !t.cwd || mt();
521
+ }, [t.open, t.cwd, mt]);
522
+ const It = E(async () => {
523
+ if (!t.cwd || W.nextCursor == null) return;
524
+ const o = await a.log(t.cwd, W.nextCursor);
525
+ o.status === 200 && (U((u) => ({ lines: [...u.lines, ...o.data?.lines ?? []], nextCursor: o.data?.nextCursor ?? null })), M(W.nextCursor));
526
+ }, [a, t.cwd, W.nextCursor]);
527
+ so(() => {
528
+ if (!t.open || !t.anchor) return;
529
+ const o = Ae.current, u = Math.min(wn, window.innerWidth - 16);
530
+ let y = t.anchor.right - u, ie = (t.anchor.bottom ?? 0) + 6;
531
+ const De = window.innerHeight - ie - 8;
532
+ if (o) {
533
+ const Be = qn(y, ie, u, Math.min(o.offsetHeight, Math.max(De, 120)), 8);
534
+ y = Be.left, ie = Be.top;
535
+ }
536
+ const Te = Yn(o);
537
+ Ke((Be) => Be && Be.left === y - Te.x && Be.top === ie - Te.y ? Be : { left: y - Te.x, top: ie - Te.y });
538
+ }), se(() => {
539
+ if (!t.open) return;
540
+ const o = (y) => {
541
+ const ie = y.target;
542
+ Ae.current?.contains(ie) || ie && typeof ie.closest == "function" && ie.closest("[data-branch-chip]") || t.onClose();
543
+ }, u = (y) => {
544
+ y.key === "Escape" && t.onClose();
545
+ };
546
+ return document.addEventListener("mousedown", o), document.addEventListener("keydown", u), () => {
547
+ document.removeEventListener("mousedown", o), document.removeEventListener("keydown", u);
548
+ };
549
+ }, [t.open, t.onClose]);
550
+ const Z = E(async (o) => {
551
+ if (!X) {
552
+ ve(!0), me(null);
553
+ try {
554
+ await o();
555
+ } finally {
556
+ ve(!1);
557
+ }
558
+ }
559
+ }, [X]), pe = E(() => {
560
+ mt(), t.onChanged?.();
561
+ }, [mt, t.onChanged]), ut = E((o) => Z(async () => {
562
+ if (C) {
563
+ await rt(o);
564
+ return;
565
+ }
566
+ const u = await a.checkout(t.cwd, o);
567
+ if (u.status === 409 && u.data?.conflict) {
568
+ I({ ref: o, files: u.data.files ?? [] });
569
+ return;
570
+ }
571
+ if (u.status !== 200) {
572
+ me(u.data?.error ?? "HTTP " + u.status);
573
+ return;
574
+ }
575
+ pe();
576
+ }), [Z, C, a, t.cwd, pe]), rt = E(async (o) => {
577
+ if (!t.onCreateWorktree) {
578
+ me("worktree unavailable");
579
+ return;
580
+ }
581
+ const u = (t.worktrees ?? []).find((ie) => ie.branch === o);
582
+ if (u) {
583
+ t.onSelectWorktree?.(u.path), t.onClose();
584
+ return;
585
+ }
586
+ const y = await t.onCreateWorktree(o);
587
+ if (y && typeof y == "object" && y.error) {
588
+ me(y.error);
589
+ return;
590
+ }
591
+ t.onClose();
592
+ }, [t.onCreateWorktree, t.worktrees, t.onSelectWorktree, t.onClose]), yt = E(async (o) => {
593
+ const u = o.replace(/^[^/]+\//, "");
594
+ if ((i?.branches ?? []).includes(u)) return u;
595
+ const y = await a.branchCreate(t.cwd, u, o, !1);
596
+ return y.status !== 200 ? (me(y.data?.error ?? "HTTP " + y.status), null) : u;
597
+ }, [i, a, t.cwd]), xt = E((o, u = !1) => Z(async () => {
598
+ const y = u ? await yt(o) : o;
599
+ y && (C ? await rt(y) : await ut(y));
600
+ }), [Z, yt, C, rt, ut]), Et = E((o) => Z(async () => {
601
+ const u = G.trim();
602
+ if (!u) return;
603
+ if (C) {
604
+ const ie = await a.branchCreate(t.cwd, u, o, !1);
605
+ if (ie.status !== 200) {
606
+ me(ie.data?.error ?? "HTTP " + ie.status);
607
+ return;
608
+ }
609
+ fe(null), m(""), await rt(u);
610
+ return;
611
+ }
612
+ const y = await a.branchCreate(t.cwd, u, o, !0);
613
+ if (y.status !== 200) {
614
+ me(y.data?.error ?? "HTTP " + y.status);
615
+ return;
616
+ }
617
+ fe(null), m(""), pe();
618
+ }), [Z, G, C, a, t.cwd, rt, pe]), Yt = E(() => Z(async () => {
619
+ const o = He.trim();
620
+ if (!o) return;
621
+ const u = await t.onCreateWorktree?.(o);
622
+ if (u && typeof u == "object" && u.error) {
623
+ me(u.error);
624
+ return;
625
+ }
626
+ ft(!1), Dt(""), t.onWorktreeChanged?.(), t.onClose();
627
+ }), [Z, He, t.onCreateWorktree, t.onWorktreeChanged, t.onClose]), Bt = E((o, u) => Z(async () => {
628
+ const y = await t.onRemoveWorktree?.(o, u);
629
+ if (y && typeof y == "object" && y.dirty && !u) {
630
+ pt(o);
631
+ return;
632
+ }
633
+ if (y && typeof y == "object" && y.error) {
634
+ me(y.error);
635
+ return;
636
+ }
637
+ pt(null), t.onWorktreeChanged?.();
638
+ }), [Z, t.onRemoveWorktree, t.onWorktreeChanged]), hn = E((o) => Z(async () => {
639
+ if (ae === o) {
640
+ le(null);
641
+ return;
642
+ }
643
+ const u = await a.stashFiles(t.cwd, o);
644
+ if (u.status !== 200) {
645
+ me(u.data?.error ?? "HTTP " + u.status);
646
+ return;
647
+ }
648
+ J((y) => ({ ...y, [o]: { tracked: u.data.tracked ?? [], untracked: u.data.untracked ?? [] } })), de(/* @__PURE__ */ new Set([...u.data.tracked ?? [], ...u.data.untracked ?? []])), le(o);
649
+ }), [Z, ae, a, t.cwd]), un = E((o) => Z(async () => {
650
+ const u = [...ee];
651
+ if (u.length === 0) return;
652
+ const y = await a.stashApply(t.cwd, o, { paths: u });
653
+ if (y.status !== 200) {
654
+ me(y.data?.error ?? "HTTP " + y.status);
655
+ return;
656
+ }
657
+ le(null), pe();
658
+ }), [Z, ee, a, t.cwd, pe]), Vt = E((o, u = {}) => Z(async () => {
659
+ const y = await a.stashApply(t.cwd, o, u);
660
+ if (y.status !== 200) {
661
+ me(y.data?.error ?? "HTTP " + y.status);
662
+ return;
663
+ }
664
+ pe();
665
+ }), [Z, a, t.cwd, pe]), Fe = E((o) => Z(async () => {
666
+ const u = await a.stashDrop(t.cwd, o);
667
+ if (u.status !== 200) {
668
+ me(u.data?.error ?? "HTTP " + u.status);
669
+ return;
670
+ }
671
+ j(null), pe();
672
+ }), [Z, a, t.cwd, pe]), Xt = E(() => Z(async () => {
673
+ const o = [...b ?? []];
674
+ if (o.length === 0) return;
675
+ const u = i?.dirtyFiles ?? [], y = o.some((De) => u.find((Te) => Te.path === De)?.xy === "??"), ie = await a.stashPush(t.cwd, { message: "aiti-git-ops partial", includeUntracked: y, paths: o });
676
+ if (ie.status !== 200) {
677
+ me(ie.data?.error ?? "HTTP " + ie.status);
678
+ return;
679
+ }
680
+ he(!1), pe();
681
+ }), [Z, b, i, a, t.cwd, pe]), Ne = E((o, u) => Z(async () => {
682
+ const y = await t.pty?.stashInteractive(o, u);
683
+ y?.ok ? Ee(n("stashInteractiveDone")) : me(y?.error || n("stashInteractiveFail"));
684
+ }), [Z, t.pty, n]), Mt = E((o) => Z(async () => {
685
+ V(o), te(null), B(null), re(null), Rt(null), ge(!1), dt("");
686
+ const u = await a.commitShow(t.cwd, o);
687
+ if (u.status !== 200) {
688
+ B(u.data?.error ?? "HTTP " + u.status);
689
+ return;
690
+ }
691
+ te(u.data);
692
+ }), [Z, a, t.cwd]), Se = () => String(oe?.sha || K || ""), Ye = () => String(i?.repo || t.cwd || ""), At = (o) => {
693
+ const u = t.extSvc?.("aiti-git-review.open"), y = t.extSvc?.("aiti-git-review.work");
694
+ if (!u || !y) return !1;
695
+ const ie = Se();
696
+ if (!ie || oe?.parents?.length === 0) return !1;
697
+ u({
698
+ path: Ye(),
699
+ base: ie + "^",
700
+ ref2: ie,
701
+ ...o?.files?.length ? { files: o.files } : {}
702
+ });
703
+ try {
704
+ y();
705
+ } catch {
706
+ }
707
+ return !0;
708
+ }, it = async (o, u) => {
709
+ await pn({
710
+ text: o,
711
+ targetDir: u,
712
+ targetPath: u,
713
+ currentCwd: t.cwd,
714
+ apiUrl: t.apiUrl,
715
+ extSvc: t.extSvc
716
+ });
717
+ }, at = E(async (o, u) => {
718
+ try {
719
+ await navigator.clipboard.writeText(o);
720
+ } catch {
721
+ const y = document.createElement("textarea");
722
+ y.value = o, y.style.position = "fixed", y.style.opacity = "0", document.body.appendChild(y), y.select();
723
+ try {
724
+ document.execCommand("copy");
725
+ } catch {
726
+ }
727
+ y.remove();
728
+ }
729
+ u && Ee(u);
730
+ }, []), je = E(() => Z(async () => {
731
+ const o = xe.trim();
732
+ if (!o || !Se()) return;
733
+ const u = await a.tagCreate(t.cwd, o, Se());
734
+ if (u.status !== 200) {
735
+ me(u.data?.error ?? "HTTP " + u.status);
736
+ return;
737
+ }
738
+ ge(!1), dt(""), Ee(n("commitTagDone", o)), pe();
739
+ }), [Z, xe, a, t.cwd, pe, n]), vt = E(() => Z(async () => {
740
+ const o = await a.cherryPick(t.cwd, Se());
741
+ if (o.status === 409 && o.data?.conflict) {
742
+ Rt(o.data.files ?? []);
743
+ return;
744
+ }
745
+ if (o.status !== 200) {
746
+ me(o.data?.error ?? "HTTP " + o.status);
747
+ return;
748
+ }
749
+ Ee(n("commitPickDone")), pe();
750
+ }), [Z, a, t.cwd, pe, n]), Ue = E(() => Z(async () => {
751
+ const o = await a.cherryPick(t.cwd, "", { abort: !0 });
752
+ if (o.status !== 200) {
753
+ me(o.data?.error ?? "HTTP " + o.status);
754
+ return;
755
+ }
756
+ Rt(null), pe();
757
+ }), [Z, a, t.cwd, pe]), gn = E((o, u) => Z(async () => {
758
+ Re(!0);
759
+ try {
760
+ const y = await a.commitDiff(t.cwd, Se(), u ? [o, u] : [o]);
761
+ if (y.status !== 200) {
762
+ me(y.data?.error ?? "HTTP " + y.status);
763
+ return;
764
+ }
765
+ re({ path: o, oldPath: u, patch: y.data?.patch ?? "", truncated: !!y.data?.truncated });
766
+ } finally {
767
+ Re(!1);
768
+ }
769
+ }), [Z, a, t.cwd]), lt = (o) => Ye().replace(/\/+$/, "") + "/" + o;
770
+ if (!t.open) return null;
771
+ const Ve = (o, u) => /* @__PURE__ */ l(
772
+ "div",
773
+ {
774
+ onClick: () => qt(o),
775
+ style: {
776
+ fontSize: 10,
777
+ fontWeight: 600,
778
+ letterSpacing: "0.06em",
779
+ textTransform: "uppercase",
780
+ color: "var(--text-dim)",
781
+ padding: "9px 12px 3px",
782
+ cursor: "pointer",
783
+ userSelect: "none",
784
+ display: "flex",
785
+ alignItems: "center",
786
+ gap: 4
787
+ },
788
+ children: [
789
+ /* @__PURE__ */ e("span", { style: { fontSize: 8, transform: w.has(o) ? "none" : "rotate(90deg)", transition: "transform 0.15s" }, children: "▶" }),
790
+ u
791
+ ]
792
+ }
793
+ ), Xe = { display: "flex", alignItems: "center", gap: 7, padding: "4px 12px", fontSize: 12, cursor: "pointer", color: "var(--text)" }, Ce = (o) => {
794
+ const u = F.trim().toLowerCase();
795
+ return u ? o.filter((y) => y.toLowerCase().includes(u)) : o;
796
+ }, Ht = Ce(i?.branches ?? []), Nt = Ce(i?.tags ?? []), Qe = Ce(i?.remotes ?? []), mn = (i?.branches?.length ?? 0) + (i?.tags?.length ?? 0) >= 8, bt = i?.dirtyCount ?? 0;
797
+ return /* @__PURE__ */ l(
798
+ "div",
799
+ {
800
+ ref: Ae,
801
+ "data-ext-float": "1",
802
+ "data-ext-float-full": "1",
803
+ "data-ext-float-pos": "asis",
804
+ "data-ext-float-w": Math.min(wn, window.innerWidth - 16),
805
+ "data-ext-float-h": Math.round(Math.min(window.innerHeight * 0.62, 620)),
806
+ ...t.floatKey ? { "data-ext-float-key": t.floatKey } : {},
807
+ style: {
808
+ position: "fixed",
809
+ zIndex: 1e3,
810
+ left: $e ? $e.left : -99999,
811
+ top: $e ? $e.top : -99999,
812
+ width: Math.min(wn, window.innerWidth - 16),
813
+ height: "min(62vh, 620px)",
814
+ display: "flex",
815
+ flexDirection: "column",
816
+ background: "var(--bg)",
817
+ border: "1px solid var(--border)",
818
+ borderRadius: 10,
819
+ boxShadow: "0 14px 36px color-mix(in srgb, var(--text) 14%, transparent)",
820
+ overflow: "hidden",
821
+ fontFamily: "inherit",
822
+ textAlign: "left"
823
+ },
824
+ children: [
825
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "9px 12px", borderBottom: "1px solid var(--border)", flexShrink: 0 }, children: [
826
+ /* @__PURE__ */ l("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11.5, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
827
+ "⎇ ",
828
+ i?.current ?? n(h ? "noRepo" : "loading")
829
+ ] }),
830
+ i?.aheadBehind ? /* @__PURE__ */ l("span", { style: { fontSize: 10, color: "var(--text-dim)", fontFamily: "var(--font-mono)", flexShrink: 0 }, children: [
831
+ "↑",
832
+ i.aheadBehind[0],
833
+ " ↓",
834
+ i.aheadBehind[1]
835
+ ] }) : null,
836
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
837
+ typeof bt == "number" && bt > 0 ? /* @__PURE__ */ e(
838
+ "button",
839
+ {
840
+ type: "button",
841
+ title: n("stashPartTitle"),
842
+ onClick: () => {
843
+ he((o) => !o), P(new Set((i?.dirtyFiles ?? []).map((o) => o.path)));
844
+ },
845
+ style: {
846
+ fontSize: 10,
847
+ color: "var(--text)",
848
+ background: "color-mix(in srgb, var(--accent) 12%, transparent)",
849
+ border: "1px solid color-mix(in srgb, var(--accent) 35%, transparent)",
850
+ borderRadius: 5,
851
+ padding: "1px 6px",
852
+ cursor: "pointer",
853
+ whiteSpace: "nowrap",
854
+ flexShrink: 0
855
+ },
856
+ children: n("dirty", bt)
857
+ }
858
+ ) : null,
859
+ /* @__PURE__ */ e(
860
+ "button",
861
+ {
862
+ type: "button",
863
+ title: n("close"),
864
+ onClick: t.onClose,
865
+ style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 12, padding: "0 2px", flexShrink: 0 },
866
+ children: "✕"
867
+ }
868
+ )
869
+ ] }),
870
+ h ? /* @__PURE__ */ e("div", { style: { padding: "14px 12px", fontSize: 11.5, color: "var(--text-muted)" }, children: h }) : i ? /* @__PURE__ */ l("div", { style: { flex: "1 1 auto", minHeight: 0, overflowY: "auto", overscrollBehavior: "contain" }, children: [
871
+ /* @__PURE__ */ l(
872
+ "label",
873
+ {
874
+ style: { display: "flex", alignItems: "center", gap: 8, padding: "7px 12px", fontSize: 11.5, color: "var(--text-muted)", borderBottom: "1px solid var(--border)", cursor: "pointer" },
875
+ title: n(C ? "wtModeOn" : "wtMode"),
876
+ children: [
877
+ /* @__PURE__ */ e(
878
+ "input",
879
+ {
880
+ type: "checkbox",
881
+ checked: C,
882
+ onChange: (o) => {
883
+ L(o.target.checked);
884
+ try {
885
+ localStorage.setItem("gitops.panel.wtMode", o.target.checked ? "1" : "0");
886
+ } catch {
887
+ }
888
+ },
889
+ style: { accentColor: "var(--accent)", margin: 0, flexShrink: 0 }
890
+ }
891
+ ),
892
+ n("wtMode")
893
+ ]
894
+ }
895
+ ),
896
+ v ? /* @__PURE__ */ l("div", { style: { padding: "10px 12px" }, children: [
897
+ /* @__PURE__ */ l("div", { style: { fontSize: 12, fontWeight: 600, display: "flex", gap: 7, alignItems: "center" }, children: [
898
+ /* @__PURE__ */ e("span", { title: "", children: "⚠" }),
899
+ n("conflictTitle"),
900
+ " ",
901
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)" }, children: v.ref })
902
+ ] }),
903
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-muted)", margin: "5px 0 7px" }, children: n("conflictDesc", v.files.length) }),
904
+ /* @__PURE__ */ e("div", { style: {
905
+ background: "var(--bg-hover)",
906
+ border: "1px solid var(--border)",
907
+ borderRadius: 6,
908
+ padding: "6px 9px",
909
+ fontFamily: "var(--font-mono)",
910
+ fontSize: 10.5,
911
+ color: "var(--text-muted)",
912
+ display: "flex",
913
+ flexDirection: "column",
914
+ gap: 3,
915
+ maxHeight: 96,
916
+ overflowY: "auto"
917
+ }, children: v.files.map((o) => /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o }, o)) }),
918
+ /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 9 }, children: [
919
+ t.onCreateWorktree ? /* @__PURE__ */ e(
920
+ "button",
921
+ {
922
+ type: "button",
923
+ disabled: X,
924
+ onClick: () => Z(async () => {
925
+ await rt(v.ref), I(null);
926
+ }),
927
+ style: er(X),
928
+ children: n("conflictWt")
929
+ }
930
+ ) : null,
931
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => Z(async () => {
932
+ const o = await a.checkout(t.cwd, v.ref, "stash-then-switch");
933
+ if (o.status !== 200) {
934
+ me(o.data?.error ?? "HTTP " + o.status);
935
+ return;
936
+ }
937
+ I(null), pe();
938
+ }), style: tr(), children: n("conflictStash") }),
939
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => I(null), style: $n(), children: n("cancel") })
940
+ ] })
941
+ ] }) : we ? (
942
+ /* 部分暂存卡(mockup ③ 下) */
943
+ /* @__PURE__ */ l("div", { style: { padding: "10px 12px" }, children: [
944
+ /* @__PURE__ */ l("div", { style: { fontSize: 12, fontWeight: 600, display: "flex", alignItems: "center", gap: 7 }, children: [
945
+ n("stashPartTitle"),
946
+ /* @__PURE__ */ e("span", { style: { marginLeft: "auto", color: "var(--text-dim)", fontSize: 10, fontWeight: 400, fontFamily: "var(--font-mono)" }, children: n("stashPartHint") })
947
+ ] }),
948
+ /* @__PURE__ */ e("div", { style: { marginTop: 7, display: "flex", flexDirection: "column", maxHeight: 180, overflowY: "auto" }, children: (i?.dirtyFiles ?? []).map((o) => {
949
+ const u = b?.has(o.path) ?? !1;
950
+ return /* @__PURE__ */ l("label", { style: { display: "flex", alignItems: "center", gap: 7, fontFamily: "var(--font-mono)", fontSize: 10.5, color: "var(--text-muted)", padding: "2.5px 0", cursor: "pointer" }, children: [
951
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: u, onChange: (y) => {
952
+ P((ie) => {
953
+ const De = new Set(ie ?? []);
954
+ return y.target.checked ? De.add(o.path) : De.delete(o.path), De;
955
+ });
956
+ }, style: { accentColor: "var(--accent)", margin: 0, flexShrink: 0 } }),
957
+ /* @__PURE__ */ e("span", { style: { color: o.xy === "??" ? "var(--text-dim)" : "var(--text)", width: 20, flexShrink: 0 }, children: o.xy }),
958
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o.path })
959
+ ] }, o.path);
960
+ }) }),
961
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8, marginTop: 9 }, children: [
962
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || !b?.size, onClick: Xt, style: et(X || !b?.size), children: n("stashPartBtn") }),
963
+ t.pty?.available ? /* @__PURE__ */ e(
964
+ "button",
965
+ {
966
+ type: "button",
967
+ disabled: X,
968
+ onClick: () => Ne("push"),
969
+ style: { fontSize: 10.5, color: "var(--text-dim)", background: "none", border: "none", cursor: "pointer", padding: 0 },
970
+ children: n("stashInteractive")
971
+ }
972
+ ) : null
973
+ ] }),
974
+ /* @__PURE__ */ l("div", { style: { fontSize: 10, color: "var(--text-dim)", marginTop: 7 }, children: [
975
+ n("stashPartNote"),
976
+ ";",
977
+ n("stashExtractNote")
978
+ ] }),
979
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => he(!1), style: { ...$n(), marginTop: 9, width: "100%" }, children: n("cancel") })
980
+ ] })
981
+ ) : /* @__PURE__ */ l(dn, { children: [
982
+ mn && /* @__PURE__ */ e("div", { style: { padding: "8px 12px 0", flexShrink: 0 }, children: /* @__PURE__ */ e(
983
+ "input",
984
+ {
985
+ value: F,
986
+ onChange: (o) => s(o.target.value),
987
+ placeholder: n("filter"),
988
+ onKeyDown: (o) => {
989
+ o.key === "Escape" && s("");
990
+ },
991
+ style: {
992
+ width: "100%",
993
+ height: 26,
994
+ boxSizing: "border-box",
995
+ background: "var(--bg-hover)",
996
+ border: "1px solid var(--border)",
997
+ borderRadius: 6,
998
+ color: "var(--text)",
999
+ fontSize: 11,
1000
+ padding: "0 9px",
1001
+ outline: "none"
1002
+ }
1003
+ }
1004
+ ) }),
1005
+ Ve("branches", n("branches")),
1006
+ !w.has("branches") && /* @__PURE__ */ l("div", { style: { paddingBottom: 2 }, children: [
1007
+ Ht.map((o) => {
1008
+ const u = !i.detached && o === i.current;
1009
+ return /* @__PURE__ */ l("div", { className: "gitops-row", onClick: () => void xt(o), style: Xe, children: [
1010
+ u ? /* @__PURE__ */ e("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__ */ e("polyline", { points: "1.5 5 4 7.5 8.5 2.5" }) }) : /* @__PURE__ */ e("span", { style: { width: 10, flexShrink: 0 } }),
1011
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o }),
1012
+ u && /* @__PURE__ */ e("span", { style: { marginLeft: "auto", color: "var(--text-dim)", fontSize: 10, flexShrink: 0 }, children: n("current") })
1013
+ ] }, o);
1014
+ }),
1015
+ (i?.remotes?.length ?? 0) > 0 && /* @__PURE__ */ l("div", { onClick: () => D((o) => !o), style: { ...Xe, color: "var(--text-muted)", fontSize: 11 }, children: [
1016
+ /* @__PURE__ */ e("span", { style: { width: 10, flexShrink: 0 } }),
1017
+ n("remotes", i.remotes.length)
1018
+ ] }),
1019
+ p && Qe.map((o) => /* @__PURE__ */ e("div", { className: "gitops-row", onClick: () => void xt(o, !0), style: { ...Xe, paddingLeft: 28 }, children: /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o }) }, o))
1020
+ ] }),
1021
+ Ve("tags", n("tags")),
1022
+ !w.has("tags") && Nt.map((o) => /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center" }, children: [
1023
+ /* @__PURE__ */ l("div", { className: "gitops-row", onClick: () => void xt(o), style: { ...Xe, flex: 1, minWidth: 0 }, children: [
1024
+ /* @__PURE__ */ e("span", { style: { width: 10, flexShrink: 0 } }),
1025
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o }),
1026
+ /* @__PURE__ */ e("span", { style: { marginLeft: "auto", color: "var(--text-dim)", fontSize: 10, flexShrink: 0, paddingLeft: 8 }, children: n("tagCheckoutHint") })
1027
+ ] }),
1028
+ /* @__PURE__ */ e(
1029
+ "button",
1030
+ {
1031
+ type: "button",
1032
+ title: n("createFromRef"),
1033
+ onClick: (u) => {
1034
+ u.stopPropagation(), fe({ from: o, suggested: "tag/" + o.replace(/[^\w.-]+/g, "-") }), m("tag/" + o.replace(/[^\w.-]+/g, "-"));
1035
+ },
1036
+ style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: "4px 8px", flexShrink: 0 },
1037
+ children: "⎘"
1038
+ }
1039
+ )
1040
+ ] }, o)),
1041
+ Ve("new", n("newBranch")),
1042
+ !w.has("new") && /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, margin: "4px 12px 0" }, children: [
1043
+ /* @__PURE__ */ e(
1044
+ "input",
1045
+ {
1046
+ value: (A?.from && A.from !== "HEAD", G),
1047
+ onChange: (o) => {
1048
+ m(o.target.value), fe((u) => u ? { ...u } : null);
1049
+ },
1050
+ placeholder: n("newBranchPlaceholder"),
1051
+ onKeyDown: (o) => {
1052
+ o.key === "Enter" && (o.preventDefault(), Et(A?.from));
1053
+ },
1054
+ style: { flex: 1, minWidth: 0, height: 25, boxSizing: "border-box", background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 6, color: "var(--text)", fontSize: 11, fontFamily: "var(--font-mono)", padding: "0 8px", outline: "none" }
1055
+ }
1056
+ ),
1057
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || !G.trim(), onClick: () => void Et(A?.from), style: et(X || !G.trim()), children: n(C ? "createWt" : "createCheckout") })
1058
+ ] }),
1059
+ !w.has("new") && A?.from && A.from !== "HEAD" ? /* @__PURE__ */ l("div", { style: { fontSize: 10, color: "var(--text-dim)", margin: "3px 12px 0" }, children: [
1060
+ n("from"),
1061
+ ": ",
1062
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)" }, children: A.from }),
1063
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => {
1064
+ fe(null), m("");
1065
+ }, style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 10, padding: "0 4px" }, children: "✕" })
1066
+ ] }) : null,
1067
+ t.onCreateWorktree ? Ve("worktree", n("worktree")) : null,
1068
+ !w.has("worktree") && t.onCreateWorktree ? /* @__PURE__ */ l("div", { style: { paddingBottom: 2 }, children: [
1069
+ (t.worktrees ?? []).map((o) => {
1070
+ const u = o.path === t.currentWorktreePath;
1071
+ return Wt === o.path ? /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 12px", background: "color-mix(in srgb, var(--text) 6%, transparent)", fontSize: 11 }, children: [
1072
+ /* @__PURE__ */ e("span", { style: { flex: 1, color: "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: n("worktreeForceConfirm") }),
1073
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => void Bt(o.path, !0), style: et(X), children: "Force" }),
1074
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => pt(null), style: { border: "1px solid var(--border)", background: "var(--bg-hover)", color: "var(--text-muted)", borderRadius: 5, fontSize: 11, padding: "3px 9px", cursor: "pointer" }, children: n("cancel") })
1075
+ ] }, o.path) : /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center" }, children: [
1076
+ /* @__PURE__ */ l("div", { className: "gitops-row", onClick: () => {
1077
+ t.onSelectWorktree?.(o.path), t.onClose();
1078
+ }, title: o.path, style: { ...Xe, flex: 1, minWidth: 0 }, children: [
1079
+ /* @__PURE__ */ e("span", { style: { color: u ? "var(--accent)" : "var(--text-dim)", fontSize: 10, flexShrink: 0 }, children: "●" }),
1080
+ /* @__PURE__ */ l("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
1081
+ o.branch ?? o.path,
1082
+ o.isMain ? ` · ${n("worktreeMain")}` : ""
1083
+ ] })
1084
+ ] }),
1085
+ !o.isMain && /* @__PURE__ */ e(
1086
+ "button",
1087
+ {
1088
+ type: "button",
1089
+ title: n("worktreeRemoveTitle"),
1090
+ onClick: () => void Bt(o.path, !1),
1091
+ style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: "4px 8px", flexShrink: 0 },
1092
+ children: "✕"
1093
+ }
1094
+ )
1095
+ ] }, o.path);
1096
+ }),
1097
+ Ft ? /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, margin: "4px 12px 6px" }, children: [
1098
+ /* @__PURE__ */ e(
1099
+ "input",
1100
+ {
1101
+ value: He,
1102
+ onChange: (o) => Dt(o.target.value),
1103
+ placeholder: n("worktreeBranchPlaceholder"),
1104
+ autoFocus: !0,
1105
+ onKeyDown: (o) => {
1106
+ o.key === "Enter" && (o.preventDefault(), Yt()), o.key === "Escape" && ft(!1);
1107
+ },
1108
+ style: { flex: 1, minWidth: 0, height: 25, boxSizing: "border-box", background: "var(--bg-hover)", border: "1px solid var(--accent)", borderRadius: 6, color: "var(--text)", fontSize: 11, fontFamily: "var(--font-mono)", padding: "0 8px", outline: "none" }
1109
+ }
1110
+ ),
1111
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || !He.trim(), onClick: () => void Yt(), style: et(X || !He.trim()), children: n("createWt") })
1112
+ ] }) : /* @__PURE__ */ e("div", { className: "gitops-row", onClick: () => ft(!0), style: { ...Xe, color: "var(--text-muted)", fontSize: 11 }, children: n("newWorktree") })
1113
+ ] }) : null,
1114
+ Ve("stash", `${n("stash")}${z.length ? ` (${z.length})` : ""}`),
1115
+ !w.has("stash") && /* @__PURE__ */ l("div", { style: { paddingBottom: 6 }, children: [
1116
+ z.length === 0 && /* @__PURE__ */ e("div", { style: { padding: "2px 12px 4px", fontSize: 11, color: "var(--text-dim)" }, children: n("stashEmpty") }),
1117
+ z.map((o, u) => {
1118
+ const y = z.length - 1 - u, ie = z.length - 1 - u, De = _[y];
1119
+ return /* @__PURE__ */ l("div", { children: [
1120
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 7, padding: "4px 12px" }, children: [
1121
+ /* @__PURE__ */ l(
1122
+ "span",
1123
+ {
1124
+ className: "gitops-row",
1125
+ onClick: () => void hn(y),
1126
+ title: n("stashExpand"),
1127
+ style: { display: "flex", alignItems: "center", gap: 7, flex: 1, minWidth: 0, cursor: "pointer", fontSize: 12 },
1128
+ children: [
1129
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--accent)", flexShrink: 0 }, children: `stash@{${ie}}` }),
1130
+ /* @__PURE__ */ e("span", { style: { color: "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontSize: 11 }, children: o.message })
1131
+ ]
1132
+ }
1133
+ ),
1134
+ /* @__PURE__ */ e("button", { type: "button", title: n("stashApply"), onClick: () => void Vt(y), style: tt(), children: "↧" }),
1135
+ /* @__PURE__ */ e("button", { type: "button", title: n("stashPop"), onClick: () => void Vt(y, { pop: !0 }), style: tt(), children: "⤓" }),
1136
+ /* @__PURE__ */ e("button", { type: "button", title: n("stashDrop"), onClick: () => j(y), style: tt(), children: "✕" })
1137
+ ] }),
1138
+ ae === y && De ? /* @__PURE__ */ l("div", { style: { margin: "2px 12px 6px", padding: "6px 9px", background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 6 }, children: [
1139
+ /* @__PURE__ */ e("div", { style: { maxHeight: 110, overflowY: "auto" }, children: [...De.tracked.map((Te) => ({ f: Te, u: !1 })), ...De.untracked.map((Te) => ({ f: Te, u: !0 }))].map(({ f: Te, u: Be }) => {
1140
+ const jt = ee.has(Te);
1141
+ return /* @__PURE__ */ l("label", { style: { display: "flex", alignItems: "center", gap: 7, fontFamily: "var(--font-mono)", fontSize: 10.5, color: "var(--text-muted)", padding: "2px 0", cursor: "pointer" }, children: [
1142
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: jt, onChange: (yn) => {
1143
+ de((Qt) => {
1144
+ const st = new Set(Qt);
1145
+ return yn.target.checked ? st.add(Te) : st.delete(Te), st;
1146
+ });
1147
+ }, style: { accentColor: "var(--accent)", margin: 0, flexShrink: 0 } }),
1148
+ /* @__PURE__ */ e("span", { style: { color: Be ? "var(--text-dim)" : "var(--text)", flexShrink: 0 }, children: Be ? "??" : "M " }),
1149
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: Te })
1150
+ ] }, Te);
1151
+ }) }),
1152
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8, marginTop: 6 }, children: [
1153
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || ee.size === 0, onClick: () => void un(y), style: et(X || ee.size === 0), children: n("stashExtract") }),
1154
+ t.pty?.available ? /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => Ne("apply", y), style: { fontSize: 10.5, color: "var(--text-dim)", background: "none", border: "none", cursor: "pointer", padding: 0 }, children: n("stashInteractive") }) : null
1155
+ ] }),
1156
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, color: "var(--text-dim)", marginTop: 5 }, children: n("stashExtractNote") })
1157
+ ] }) : null,
1158
+ R === y ? /* @__PURE__ */ l("div", { style: { margin: "2px 12px 6px", padding: "8px 10px", background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 6 }, children: [
1159
+ /* @__PURE__ */ l("div", { style: { fontSize: 11.5, fontWeight: 600 }, children: [
1160
+ "⚠ ",
1161
+ n("dropConfirmTitle")
1162
+ ] }),
1163
+ /* @__PURE__ */ l("div", { style: { fontSize: 10.5, color: "var(--text-muted)", margin: "4px 0 8px", fontFamily: "var(--font-mono)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
1164
+ "stash@",
1165
+ `{${y}}`,
1166
+ " ",
1167
+ o.sha,
1168
+ " · ",
1169
+ o.message
1170
+ ] }),
1171
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, color: "var(--text-dim)", marginBottom: 8 }, children: n("dropConfirmNote") }),
1172
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6 }, children: [
1173
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => void Fe(y), style: et(X), children: n("stashDrop") }),
1174
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => j(null), style: { border: "1px solid var(--border)", background: "var(--bg-hover)", color: "var(--text-muted)", borderRadius: 5, fontSize: 11, padding: "3px 9px", cursor: "pointer" }, children: n("cancel") })
1175
+ ] })
1176
+ ] }) : null
1177
+ ] }, o.sha + String(y));
1178
+ })
1179
+ ] }),
1180
+ Ve("graph", n("graph")),
1181
+ !w.has("graph") && /* @__PURE__ */ l("div", { style: { paddingBottom: 2 }, children: [
1182
+ W.lines.length === 0 && /* @__PURE__ */ e("div", { style: { padding: "2px 12px 4px", fontSize: 11, color: "var(--text-dim)" }, children: n("graphEmpty") }),
1183
+ W.lines.map((o, u) => {
1184
+ const y = o.match(/^([*|\\/ ]+\s*)([0-9a-f]{7,})( .*)?$/);
1185
+ if (!y) return /* @__PURE__ */ e("div", { style: { ...Kn, opacity: 0.7 }, children: o }, u);
1186
+ const ie = y[2].slice(0, 7);
1187
+ return /* @__PURE__ */ l(
1188
+ "div",
1189
+ {
1190
+ className: "gitops-row",
1191
+ onClick: () => void Mt(ie),
1192
+ title: n("commitView"),
1193
+ style: { ...Kn, cursor: "pointer" },
1194
+ children: [
1195
+ /* @__PURE__ */ e("span", { style: { color: "var(--text-dim)" }, children: y[1] }),
1196
+ /* @__PURE__ */ e("span", { style: { color: "var(--accent)" }, children: ie }),
1197
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: y[3] ?? "" })
1198
+ ]
1199
+ },
1200
+ u
1201
+ );
1202
+ }),
1203
+ W.nextCursor != null && /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => void It(), style: { display: "block", width: "100%", textAlign: "center", padding: "5px 0", fontSize: 10, color: "var(--text-dim)", background: "none", border: "none", cursor: "pointer" }, children: n("graphMore") })
1204
+ ] })
1205
+ ] })
1206
+ ] }) : /* @__PURE__ */ e("div", { style: { padding: "14px 12px", fontSize: 11.5, color: "var(--text-muted)" }, children: n("loading") }),
1207
+ K && !v && !we ? /* @__PURE__ */ l("div", { style: { position: "absolute", inset: 0, background: "var(--bg)", display: "flex", flexDirection: "column" }, children: [
1208
+ /* @__PURE__ */ l("div", { style: { padding: "8px 12px 8px", borderBottom: "1px solid var(--border)", flexShrink: 0, display: "flex", flexDirection: "column", gap: 6 }, children: [
1209
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
1210
+ /* @__PURE__ */ e("button", { type: "button", title: n("commitBack"), onClick: () => V(null), style: tt(), children: "←" }),
1211
+ /* @__PURE__ */ e(
1212
+ "span",
1213
+ {
1214
+ style: { fontFamily: "var(--font-mono)", fontSize: 11.5, color: "var(--accent)", cursor: "pointer", flexShrink: 0 },
1215
+ title: n("commitCopySha"),
1216
+ onClick: () => void at(Se(), n("commitCopySha")),
1217
+ children: Se().slice(0, 9)
1218
+ }
1219
+ ),
1220
+ /* @__PURE__ */ e(
1221
+ "span",
1222
+ {
1223
+ style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontSize: 11.5, color: "var(--text)" },
1224
+ title: oe?.subject || void 0,
1225
+ children: oe?.subject ?? (ke ? "" : "…")
1226
+ }
1227
+ )
1228
+ ] }),
1229
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 10, fontSize: 10, color: "var(--text-dim)", fontFamily: "var(--font-mono)", flexWrap: "wrap" }, children: [
1230
+ ke ? /* @__PURE__ */ l("span", { style: { color: "var(--text-muted)" }, children: [
1231
+ n("commitLoadFail"),
1232
+ ":",
1233
+ ke
1234
+ ] }) : null,
1235
+ oe ? /* @__PURE__ */ l("span", { children: [
1236
+ oe.author,
1237
+ " · ",
1238
+ String(oe.date || "").slice(0, 10)
1239
+ ] }) : null,
1240
+ oe?.merge ? /* @__PURE__ */ e("span", { children: n("commitMergeNote", String(oe.parents?.[0] || "").slice(0, 8)) }) : null
1241
+ ] }),
1242
+ /* @__PURE__ */ l("div", { style: { display: "flex", flexWrap: "wrap", gap: 5 }, children: [
1243
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("createAt"), onClick: () => {
1244
+ fe({ from: Se() }), m("");
1245
+ }, style: kt(), children: n("commitBranch") }),
1246
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, onClick: () => {
1247
+ ge((o) => !o), dt("");
1248
+ }, style: kt(), children: n("commitTag") }),
1249
+ C ? null : /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("commitCheckoutTitle"), onClick: () => void ut(Se()), style: kt(), children: n("commitCheckout") }),
1250
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("commitPickTitle"), onClick: () => void vt(), style: kt(), children: n("commitPick") }),
1251
+ t.extSvc ? /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("commitReviewTitle"), onClick: () => {
1252
+ At();
1253
+ }, style: kt(), children: n("commitReview") }) : null,
1254
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("commitAtNewTitle"), onClick: () => {
1255
+ const o = oe?.subject ? `(${oe.subject})` : "";
1256
+ it(`请解读 commit ${Se()}${o} 的改动`, Ye());
1257
+ }, style: kt(), children: n("commitAtNew") })
1258
+ ] }),
1259
+ ye ? /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6 }, children: [
1260
+ /* @__PURE__ */ e(
1261
+ "input",
1262
+ {
1263
+ autoFocus: !0,
1264
+ value: xe,
1265
+ onChange: (o) => dt(o.target.value),
1266
+ placeholder: n("commitTagPlaceholder"),
1267
+ onKeyDown: (o) => {
1268
+ o.key === "Enter" && (o.preventDefault(), je()), o.key === "Escape" && ge(!1);
1269
+ },
1270
+ style: { flex: 1, minWidth: 0, height: 25, boxSizing: "border-box", background: "var(--bg-hover)", border: "1px solid var(--accent)", borderRadius: 6, color: "var(--text)", fontSize: 11, fontFamily: "var(--font-mono)", padding: "0 8px", outline: "none" }
1271
+ }
1272
+ ),
1273
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || !xe.trim(), onClick: () => void je(), style: et(X || !xe.trim()), children: "✓" })
1274
+ ] }) : null,
1275
+ Jt ? /* @__PURE__ */ l("div", { style: { padding: "6px 8px", background: "color-mix(in srgb, var(--text) 6%, transparent)", border: "1px solid var(--border)", borderRadius: 6 }, children: [
1276
+ /* @__PURE__ */ e("div", { style: { fontSize: 10.5, color: "var(--text)" }, children: n("commitPickConflict") }),
1277
+ /* @__PURE__ */ e("div", { style: { margin: "4px 0 6px", display: "flex", flexDirection: "column", maxHeight: 72, overflowY: "auto", fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--text-muted)" }, children: Jt.map((o) => /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: o }, o)) }),
1278
+ /* @__PURE__ */ e("button", { type: "button", disabled: X, title: n("commitPickAbortTitle"), onClick: () => void Ue(), style: et(X), children: n("commitPickAbort") })
1279
+ ] }) : null
1280
+ ] }),
1281
+ H ? /* @__PURE__ */ l("div", { style: { flex: "1 1 auto", minHeight: 0, display: "flex", flexDirection: "column" }, children: [
1282
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 5, padding: "5px 12px", borderBottom: "1px solid var(--border)", flexShrink: 0 }, children: [
1283
+ /* @__PURE__ */ e("button", { type: "button", title: n("commitBack"), onClick: () => re(null), style: tt(), children: "←" }),
1284
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--font-mono)", fontSize: 10.5, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: H.oldPath ? `${H.oldPath} → ${H.path}` : H.path, children: H.oldPath ? `${H.oldPath} → ${H.path}` : H.path }),
1285
+ /* @__PURE__ */ e("button", { type: "button", title: n("commitCopyPath"), onClick: () => void at(lt(H.path)), style: tt(), children: "⎘" }),
1286
+ t.openFile ? /* @__PURE__ */ e("button", { type: "button", title: n("commitOpenFile"), onClick: () => t.openFile?.(lt(H.path)), style: tt(), children: "↗" }) : null,
1287
+ /* @__PURE__ */ e("button", { type: "button", title: n("commitAtFile"), onClick: () => {
1288
+ const o = lt(H.path);
1289
+ it(fn(o), o);
1290
+ }, style: tt(), children: "@" }),
1291
+ t.extSvc ? /* @__PURE__ */ e("button", { type: "button", title: n("commitReviewFile"), onClick: () => {
1292
+ At({ files: H.oldPath ? [H.path, H.oldPath] : [H.path] });
1293
+ }, style: tt(), children: "👁" }) : null
1294
+ ] }),
1295
+ /* @__PURE__ */ e("pre", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto", margin: 0, padding: "6px 0 10px", fontFamily: "var(--font-mono)", fontSize: 10, lineHeight: 1.45, whiteSpace: "pre" }, children: H.patch.split(`
1296
+ `).map((o, u) => /* @__PURE__ */ e("div", { style: {
1297
+ padding: "0 12px",
1298
+ color: o.startsWith("+") && !o.startsWith("+++") ? "var(--ok, var(--accent))" : o.startsWith("-") && !o.startsWith("---") ? "var(--danger, var(--text-muted))" : o.startsWith("@@") || o.startsWith("diff ") || o.startsWith("index ") ? "var(--text-dim)" : "var(--text-muted)",
1299
+ background: o.startsWith("+") && !o.startsWith("+++") ? "color-mix(in srgb, var(--ok, var(--accent)) 10%, transparent)" : o.startsWith("-") && !o.startsWith("---") ? "color-mix(in srgb, var(--danger, var(--text-muted)) 10%, transparent)" : void 0
1300
+ }, children: o || " " }, u)) }),
1301
+ H.truncated ? /* @__PURE__ */ e("div", { style: { padding: "4px 12px 8px", fontSize: 10, color: "var(--text-dim)", flexShrink: 0 }, children: n("commitDiffTruncated") }) : null
1302
+ ] }) : /* @__PURE__ */ l("div", { style: { flex: "1 1 auto", minHeight: 0, overflowY: "auto", overscrollBehavior: "contain" }, children: [
1303
+ /* @__PURE__ */ l("div", { style: { padding: "7px 12px 3px", fontSize: 10, fontWeight: 600, letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--text-dim)", display: "flex", alignItems: "baseline", gap: 8 }, children: [
1304
+ /* @__PURE__ */ e("span", { style: { flexShrink: 0 }, children: oe ? n("commitFiles", oe.files?.length ?? 0) : "…" }),
1305
+ oe ? /* @__PURE__ */ l("span", { style: { fontWeight: 400, textTransform: "none", letterSpacing: 0, fontFamily: "var(--font-mono)" }, children: [
1306
+ "+",
1307
+ oe.additions ?? 0,
1308
+ " / −",
1309
+ oe.deletions ?? 0
1310
+ ] }) : null
1311
+ ] }),
1312
+ (oe?.files ?? []).map((o) => /* @__PURE__ */ l(
1313
+ "div",
1314
+ {
1315
+ className: "gitops-row",
1316
+ onClick: () => void gn(o.path, o.oldPath),
1317
+ title: n("commitFileDiffTitle"),
1318
+ style: { display: "flex", alignItems: "center", gap: 7, padding: "3.5px 12px", fontSize: 11, cursor: "pointer" },
1319
+ children: [
1320
+ /* @__PURE__ */ e("span", { style: { width: 12, flexShrink: 0, fontFamily: "var(--font-mono)", color: o.status === "A" ? "var(--ok, var(--accent))" : o.status === "D" ? "var(--danger, var(--text-muted))" : "var(--text-dim)" }, children: o.status }),
1321
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontFamily: "var(--font-mono)", color: "var(--text)" }, title: o.oldPath ? `${o.oldPath} → ${o.path}` : o.path, children: o.oldPath ? `${o.path} ← ${o.oldPath}` : o.path }),
1322
+ /* @__PURE__ */ l("span", { style: { flexShrink: 0, fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--text-dim)" }, children: [
1323
+ o.additions ? `+${o.additions}` : "",
1324
+ o.deletions ? ` −${o.deletions}` : ""
1325
+ ] })
1326
+ ]
1327
+ },
1328
+ o.path
1329
+ )),
1330
+ oe && (oe.files?.length ?? 0) === 0 ? /* @__PURE__ */ e("div", { style: { padding: "4px 12px", fontSize: 11, color: "var(--text-dim)" }, children: "—" }) : null
1331
+ ] })
1332
+ ] }) : null,
1333
+ A && !v && !we ? /* @__PURE__ */ l("div", { style: { position: "absolute", inset: 0, background: "var(--bg)", padding: "12px", display: "flex", flexDirection: "column", gap: 8 }, children: [
1334
+ /* @__PURE__ */ e("div", { style: { fontSize: 12, fontWeight: 600 }, children: n("createAt") }),
1335
+ /* @__PURE__ */ l("div", { style: { fontSize: 10.5, color: "var(--text-muted)" }, children: [
1336
+ n("from"),
1337
+ ": ",
1338
+ /* @__PURE__ */ e("span", { style: { fontFamily: "var(--font-mono)" }, children: A.from })
1339
+ ] }),
1340
+ /* @__PURE__ */ e(
1341
+ "input",
1342
+ {
1343
+ value: G,
1344
+ onChange: (o) => m(o.target.value),
1345
+ placeholder: n("newBranchPlaceholder"),
1346
+ autoFocus: !0,
1347
+ onKeyDown: (o) => {
1348
+ o.key === "Enter" && (o.preventDefault(), Et(A.from)), o.key === "Escape" && fe(null);
1349
+ },
1350
+ style: { height: 27, boxSizing: "border-box", background: "var(--bg-hover)", border: "1px solid var(--accent)", borderRadius: 6, color: "var(--text)", fontSize: 11, fontFamily: "var(--font-mono)", padding: "0 8px", outline: "none" }
1351
+ }
1352
+ ),
1353
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6 }, children: [
1354
+ /* @__PURE__ */ e("button", { type: "button", disabled: X || !G.trim(), onClick: () => void Et(A.from), style: { ...et(X || !G.trim()), flex: 1 }, children: n(C ? "createWt" : "createCheckout") }),
1355
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => fe(null), style: { border: "1px solid var(--border)", background: "var(--bg-hover)", color: "var(--text-muted)", borderRadius: 5, fontSize: 11, padding: "3px 9px", cursor: "pointer" }, children: n("cancel") })
1356
+ ] })
1357
+ ] }) : null,
1358
+ Ot ? /* @__PURE__ */ l("div", { style: { padding: "6px 12px 8px", fontSize: 11, color: "var(--text)", background: "color-mix(in srgb, var(--text) 6%, transparent)", borderTop: "1px solid var(--border)", overflowWrap: "anywhere", flexShrink: 0 }, children: [
1359
+ n("errPrefix"),
1360
+ ":",
1361
+ Ot,
1362
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => me(null), style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: "0 4px" }, children: "✕" })
1363
+ ] }) : null,
1364
+ ht ? /* @__PURE__ */ l("div", { style: { padding: "6px 12px 8px", fontSize: 11, color: "var(--text-muted)", borderTop: "1px solid var(--border)", flexShrink: 0, display: "flex", alignItems: "center", gap: 6 }, children: [
1365
+ /* @__PURE__ */ e("span", { style: { flex: 1 }, children: ht }),
1366
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => Ee(null), style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: 0 }, children: "✕" })
1367
+ ] }) : null
1368
+ ]
1369
+ }
1370
+ );
1371
+ }
1372
+ const er = (t) => ({
1373
+ height: 27,
1374
+ borderRadius: 7,
1375
+ display: "flex",
1376
+ alignItems: "center",
1377
+ justifyContent: "center",
1378
+ gap: 6,
1379
+ fontSize: 11.5,
1380
+ cursor: t ? "not-allowed" : "pointer",
1381
+ fontWeight: 600,
1382
+ background: "var(--accent)",
1383
+ color: "var(--bg)",
1384
+ border: "1px solid var(--accent)",
1385
+ opacity: t ? 0.6 : 1
1386
+ }), tr = () => ({
1387
+ height: 27,
1388
+ borderRadius: 7,
1389
+ display: "flex",
1390
+ alignItems: "center",
1391
+ justifyContent: "center",
1392
+ gap: 6,
1393
+ fontSize: 11.5,
1394
+ cursor: "pointer",
1395
+ background: "var(--bg-hover)",
1396
+ color: "var(--text)",
1397
+ border: "1px solid var(--border)"
1398
+ }), $n = () => ({
1399
+ height: 27,
1400
+ borderRadius: 7,
1401
+ display: "flex",
1402
+ alignItems: "center",
1403
+ justifyContent: "center",
1404
+ fontSize: 11.5,
1405
+ cursor: "pointer",
1406
+ background: "none",
1407
+ color: "var(--text-dim)",
1408
+ border: "none"
1409
+ }), et = (t) => ({
1410
+ height: 25,
1411
+ padding: "0 10px",
1412
+ borderRadius: 6,
1413
+ background: "var(--accent)",
1414
+ color: "var(--bg)",
1415
+ fontSize: 10.5,
1416
+ display: "inline-flex",
1417
+ alignItems: "center",
1418
+ whiteSpace: "nowrap",
1419
+ border: "1px solid var(--accent)",
1420
+ cursor: t ? "not-allowed" : "pointer",
1421
+ opacity: t ? 0.6 : 1
1422
+ }), tt = () => ({
1423
+ border: "none",
1424
+ background: "none",
1425
+ color: "var(--text-dim)",
1426
+ cursor: "pointer",
1427
+ fontSize: 11,
1428
+ padding: "2px 3px",
1429
+ flexShrink: 0
1430
+ }), kt = (t) => ({
1431
+ height: 22,
1432
+ padding: "0 8px",
1433
+ borderRadius: 6,
1434
+ display: "inline-flex",
1435
+ alignItems: "center",
1436
+ gap: 4,
1437
+ fontSize: 10.5,
1438
+ whiteSpace: "nowrap",
1439
+ flexShrink: 0,
1440
+ background: "var(--bg-hover)",
1441
+ color: "var(--text)",
1442
+ border: "1px solid var(--border)",
1443
+ cursor: t ? "not-allowed" : "pointer",
1444
+ opacity: t ? 0.55 : 1
1445
+ }), Kn = {
1446
+ display: "flex",
1447
+ gap: 7,
1448
+ padding: "2.5px 12px",
1449
+ fontFamily: "var(--font-mono)",
1450
+ fontSize: 10.5,
1451
+ color: "var(--text-muted)",
1452
+ overflow: "hidden"
1453
+ }, nr = (t) => t === "??" ? "untracked" : t.includes("D") ? "deleted" : t.includes("A") ? "added" : t.includes("R") || t.includes("C") ? "renamed" : "modified", or = (t) => `color-mix(in srgb, var(--accent) ${[85, 60, 40, 25][t % 4]}%, var(--text))`;
1454
+ function rr(t) {
1455
+ const n = Le(() => _t({ apiUrl: q }), []), [a, i] = f(null), [c, h] = f([]), [S, F] = f(""), [s, C] = f(!1), [L, w] = f(!1), [T, p] = f(!1), [D, W] = f(null), [U, Q] = f(null), [M, z] = f(!1);
1456
+ se(() => {
1457
+ let b = !1;
1458
+ return (async () => {
1459
+ const P = await n.refs(t.root);
1460
+ if (b) return;
1461
+ const R = P.data?.dirtyFiles ?? [];
1462
+ F(P.data?.head ?? "");
1463
+ const j = R.map((m) => ({ path: m.path, status: nr(m.xy) })), v = await fetch(q("/api/extensions/aiti-folder/git-plan-group"), {
1464
+ method: "POST",
1465
+ headers: { "content-type": "application/json" },
1466
+ body: JSON.stringify({ cwd: t.root, files: j })
1467
+ }).then((m) => m.json()).catch(() => null);
1468
+ if (b) return;
1469
+ p(!!v?.aiRefine);
1470
+ let I = (v?.groups ?? []).map((m, K) => ({ key: m.key ?? `g${K}`, message: m.message ?? "", files: m.files ?? [] })), A = v?.excluded ?? [];
1471
+ const G = (await fetch(q("/api/extensions/aiti-folder/git-plan-get"), {
1472
+ method: "POST",
1473
+ headers: { "content-type": "application/json" },
1474
+ body: JSON.stringify({ cwd: t.root })
1475
+ }).then((m) => m.json()).catch(() => null))?.plan;
1476
+ if (G && Array.isArray(G.groups) && G.groups.length > 0 && G.baseHEAD === (P.data?.head ?? "")) {
1477
+ const m = new Set(j.map((V) => V.path)), K = G.groups.map((V) => ({ key: V.id ?? "g", message: V.message ?? "", files: (V.files ?? []).filter((oe) => m.has(oe)) })).filter((V) => V.files.length > 0);
1478
+ K.length > 0 && (I = K, A = G.excluded ?? A);
1479
+ }
1480
+ i(I), h(A);
1481
+ })().catch(() => {
1482
+ b || (W($("i18n.networkError")), i([]), h([]));
1483
+ }), () => {
1484
+ b = !0;
1485
+ };
1486
+ }, [t.root, n]);
1487
+ const O = E((b, P) => {
1488
+ fetch(q("/api/extensions/aiti-folder/git-plan-learn"), {
1489
+ method: "POST",
1490
+ headers: { "content-type": "application/json" },
1491
+ body: JSON.stringify({ cwd: t.root, action: b, ...P })
1492
+ }).catch(() => {
1493
+ });
1494
+ }, [t.root]), _ = E((b, P) => {
1495
+ i((R) => {
1496
+ if (!R || R.length < 2) return R;
1497
+ const j = R.map((A) => ({ ...A, files: A.files.filter((fe) => fe !== P) })), v = (b + 1) % R.length;
1498
+ j[v].files.push(P);
1499
+ const I = j.filter((A) => A.files.length > 0);
1500
+ return O("move", { file: P, toKey: I[v >= I.length ? 0 : v]?.key ?? j[v].key }), I.length > 0 ? I : j;
1501
+ });
1502
+ }, [O]), J = E((b) => {
1503
+ i((P) => P && P.map((R) => ({ ...R, files: R.files.filter((j) => j !== b) })).filter((R) => R.files.length > 0)), h((P) => [...P, b]), O("exclude", { path: b });
1504
+ }, [O]), ae = E((b) => {
1505
+ h((P) => P.filter((R) => R !== b)), i((P) => {
1506
+ if (!P || P.length === 0) return P;
1507
+ const R = [...P];
1508
+ return R[0] = { ...R[0], files: [...R[0].files, b] }, R;
1509
+ });
1510
+ }, []), le = E(() => {
1511
+ i((b) => {
1512
+ if (!b || b.length === 0) return b;
1513
+ const P = b.reduce((j, v) => v.files.length > j.files.length ? v : j, b[0]), R = P.files[P.files.length - 1];
1514
+ return R ? [
1515
+ ...b.map((j) => j === P ? { ...j, files: j.files.slice(0, -1) } : j).filter((j) => j.files.length > 0),
1516
+ { key: "g" + Date.now(), message: $("git.planNewGroupMessage"), files: [R] }
1517
+ ] : b;
1518
+ });
1519
+ }, []), ee = E(async () => {
1520
+ if (!(!a || L)) {
1521
+ w(!0), W(null);
1522
+ try {
1523
+ const b = q("/api/agent/new"), P = b.slice(0, Math.max(0, b.indexOf("/api/"))), R = await fetch(q("/api/extensions/aiti-folder/git-plan-ai-refine"), {
1524
+ method: "POST",
1525
+ headers: { "content-type": "application/json" },
1526
+ body: JSON.stringify({ cwd: t.root, origin: location.origin, basePath: P, groups: a, excluded: c })
1527
+ }).then((v) => v.json());
1528
+ if (!R?.ok) {
1529
+ W(R?.error || "AI refine failed");
1530
+ return;
1531
+ }
1532
+ const j = R.result;
1533
+ i(j.groups.map((v, I) => ({ key: v.key ?? `ai-${I}`, message: v.message ?? "", files: v.files ?? [], note: v.note || void 0 }))), h(j.excluded ?? []);
1534
+ } catch (b) {
1535
+ W(b instanceof Error ? b.message : String(b));
1536
+ } finally {
1537
+ w(!1);
1538
+ }
1539
+ }
1540
+ }, [a, L, t.root, c]), de = E((b = 0) => {
1541
+ if (!a || s) return;
1542
+ const P = a.slice(b);
1543
+ if (P.length === 0) return;
1544
+ const R = P.map((j, v) => `${b + v + 1}. ${j.message} (${j.files.length})`).join(`
1545
+ `);
1546
+ window.confirm($("git.planConfirm", { count: P.length }) + `
1547
+ ` + R) && (C(!0), W(null), Q(null), z(!1), (async () => {
1548
+ await fetch(q("/api/extensions/aiti-folder/git-plan-save"), {
1549
+ method: "POST",
1550
+ headers: { "content-type": "application/json" },
1551
+ body: JSON.stringify({ cwd: t.root, baseHEAD: S, groups: a.map((A) => ({ id: A.key, files: A.files, message: A.message, state: "pending" })), excluded: c })
1552
+ }).catch(() => {
1553
+ });
1554
+ const j = await n.planExecute(t.root, P.map((A) => ({ files: A.files, message: A.message })));
1555
+ if (j.status !== 200) {
1556
+ W(j.data?.error ?? "HTTP " + j.status);
1557
+ return;
1558
+ }
1559
+ const v = j.data, I = v.failedGroup != null ? b + v.failedGroup : null;
1560
+ Q({ completed: b + v.completed, failedGroup: I, shas: v.shas ?? [] }), v.ok ? (t.git.refresh(), t.onClose()) : W(v.error ?? "");
1561
+ })().finally(() => C(!1)));
1562
+ }, [a, s, n, t.root, t.git, t.onClose, S, c]), we = E(() => {
1563
+ !S || s || (C(!0), (async () => {
1564
+ const b = await n.planRollback(t.root, S);
1565
+ if (b.status !== 200) {
1566
+ W(b.data?.error ?? "HTTP " + b.status);
1567
+ return;
1568
+ }
1569
+ z(!0), Q(null), t.git.refresh();
1570
+ })().finally(() => C(!1)));
1571
+ }, [S, s, n, t.root, t.git]), he = (a ?? []).reduce((b, P) => b + P.files.length, 0);
1572
+ return /* @__PURE__ */ e(
1573
+ "div",
1574
+ {
1575
+ onClick: (b) => {
1576
+ b.target === b.currentTarget && !s && t.onClose();
1577
+ },
1578
+ style: { position: "fixed", inset: 0, zIndex: 900, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" },
1579
+ children: /* @__PURE__ */ l("div", { style: { width: 430, maxWidth: "94vw", maxHeight: "84vh", display: "flex", flexDirection: "column", borderRadius: 10, background: "var(--bg)", border: "1px solid var(--border)", boxShadow: "0 14px 36px color-mix(in srgb, var(--text) 16%, transparent)", fontSize: 12 }, children: [
1580
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", padding: "10px 12px", borderBottom: "1px solid var(--border)", fontWeight: 600, gap: 6 }, children: [
1581
+ $("git.planTitle"),
1582
+ a ? /* @__PURE__ */ l("span", { style: { color: "var(--text-dim)", fontSize: 10.5, fontWeight: 400, fontFamily: "var(--font-mono)" }, children: [
1583
+ a.length,
1584
+ " / ",
1585
+ he
1586
+ ] }) : null,
1587
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
1588
+ /* @__PURE__ */ e("button", { type: "button", onClick: t.onClose, style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 12 }, children: "✕" })
1589
+ ] }),
1590
+ /* @__PURE__ */ e("div", { style: { flex: "1 1 auto", minHeight: 0, overflowY: "auto", padding: "8px 12px" }, children: a ? /* @__PURE__ */ l(dn, { children: [
1591
+ a.map((b, P) => /* @__PURE__ */ l("div", { style: { border: "1px solid var(--border)", borderRadius: 8, padding: "7px 9px", marginBottom: 7, background: "var(--bg-hover)" }, children: [
1592
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 5 }, children: [
1593
+ /* @__PURE__ */ e("span", { style: { width: 8, height: 8, borderRadius: "50%", background: or(P), flexShrink: 0 } }),
1594
+ /* @__PURE__ */ e(
1595
+ "input",
1596
+ {
1597
+ value: b.message,
1598
+ onChange: (R) => i((j) => j && j.map((v, I) => I === P ? { ...v, message: R.target.value } : v)),
1599
+ placeholder: $("git.commitPlaceholder"),
1600
+ style: { flex: 1, minWidth: 0, height: 24, boxSizing: "border-box", background: "var(--bg)", border: "1px solid var(--border)", borderRadius: 5, color: "var(--text)", fontSize: 11, fontFamily: "var(--font-mono)", padding: "0 7px", outline: "none" }
1601
+ }
1602
+ ),
1603
+ U && P < U.completed ? /* @__PURE__ */ e("span", { title: "committed", style: { color: "var(--text-dim)", fontSize: 10, flexShrink: 0 }, children: "✓" }) : null,
1604
+ b.note ? /* @__PURE__ */ l("span", { title: b.note, style: { fontSize: 10, flexShrink: 0, color: "var(--text-dim)", maxWidth: 90, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
1605
+ b.note.startsWith("✓") ? "" : "⚠ ",
1606
+ b.note
1607
+ ] }) : null
1608
+ ] }),
1609
+ b.files.map((R) => /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "1.5px 0 1.5px 14px", fontFamily: "var(--font-mono)", fontSize: 10.5, color: "var(--text-muted)" }, children: [
1610
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1, minWidth: 0 }, children: R }),
1611
+ a.length > 1 ? /* @__PURE__ */ e("button", { type: "button", title: $("git.planMoveTo"), onClick: () => _(P, R), style: kn(), children: "→" }) : null,
1612
+ /* @__PURE__ */ e("button", { type: "button", title: $("git.planExclude"), onClick: () => J(R), style: kn(), children: "✕" })
1613
+ ] }, R))
1614
+ ] }, b.key + P)),
1615
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
1616
+ /* @__PURE__ */ e(
1617
+ "button",
1618
+ {
1619
+ type: "button",
1620
+ onClick: le,
1621
+ disabled: he === 0,
1622
+ style: { border: "none", background: "none", color: "var(--text-dim)", cursor: he === 0 ? "default" : "pointer", fontSize: 11, padding: "2px 0" },
1623
+ children: $("git.planAddGroup")
1624
+ }
1625
+ ),
1626
+ T ? /* @__PURE__ */ e(
1627
+ "button",
1628
+ {
1629
+ type: "button",
1630
+ onClick: () => void ee(),
1631
+ disabled: L || !a,
1632
+ style: { border: "none", background: "none", color: L ? "var(--text-dim)" : "var(--accent)", cursor: L ? "default" : "pointer", fontSize: 11, padding: "2px 0" },
1633
+ children: L ? $("git.aiRefineBusy") : $("git.aiRefine")
1634
+ }
1635
+ ) : null
1636
+ ] }),
1637
+ c.length > 0 ? /* @__PURE__ */ l("div", { style: { marginTop: 6, padding: "6px 9px", border: "1px dashed var(--border)", borderRadius: 8 }, children: [
1638
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, color: "var(--text-dim)", marginBottom: 3 }, children: $("git.planExcluded") }),
1639
+ c.map((b) => /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, fontFamily: "var(--font-mono)", fontSize: 10.5, color: "var(--text-dim)", padding: "1.5px 0" }, children: [
1640
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1, minWidth: 0 }, children: b }),
1641
+ /* @__PURE__ */ e("button", { type: "button", title: $("git.planRestore"), onClick: () => ae(b), style: kn(), children: "↩" })
1642
+ ] }, b))
1643
+ ] }) : null
1644
+ ] }) : /* @__PURE__ */ e("div", { style: { color: "var(--text-dim)", fontSize: 11, padding: "8px 0" }, children: "…" }) }),
1645
+ /* @__PURE__ */ l("div", { style: { padding: "8px 12px 10px", borderTop: "1px solid var(--border)", display: "flex", flexDirection: "column", gap: 7 }, children: [
1646
+ D || U && U.failedGroup != null ? /* @__PURE__ */ l("div", { style: { fontSize: 10.5, color: "var(--text)", background: "color-mix(in srgb, var(--text) 6%, transparent)", borderRadius: 5, padding: "5px 8px", overflowWrap: "anywhere" }, children: [
1647
+ "⚠ ",
1648
+ $("git.planStuck", { group: (U?.failedGroup ?? 0) + 1 }),
1649
+ D ? ":" + D : "",
1650
+ M ? " · " + $("git.planRolledBack") : ""
1651
+ ] }) : null,
1652
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6 }, children: [
1653
+ U && U.failedGroup != null && S ? /* @__PURE__ */ e("button", { type: "button", disabled: s, onClick: () => void we(), style: Un(s), children: $("git.planRollback") }) : null,
1654
+ U && U.failedGroup != null ? /* @__PURE__ */ e("button", { type: "button", disabled: s, onClick: () => de(U.failedGroup ?? 0), style: Un(s), children: $("git.planRetry") }) : null,
1655
+ /* @__PURE__ */ e("button", { type: "button", disabled: s || !a || a.length === 0, onClick: () => de(0), style: {
1656
+ flex: 1,
1657
+ height: 27,
1658
+ borderRadius: 7,
1659
+ fontSize: 11.5,
1660
+ fontWeight: 600,
1661
+ background: "var(--accent)",
1662
+ color: "var(--bg)",
1663
+ border: "1px solid var(--accent)",
1664
+ cursor: s || !a || a.length === 0 ? "not-allowed" : "pointer",
1665
+ opacity: s || !a || a.length === 0 ? 0.6 : 1
1666
+ }, children: s ? "…" : $("git.planExecute") }),
1667
+ /* @__PURE__ */ e("button", { type: "button", onClick: t.onClose, style: { border: "1px solid var(--border)", background: "var(--bg-hover)", color: "var(--text-muted)", borderRadius: 7, fontSize: 11, padding: "0 12px", cursor: "pointer" }, children: $("files.cancel") })
1668
+ ] })
1669
+ ] })
1670
+ ] })
1671
+ }
1672
+ );
1673
+ }
1674
+ const kn = () => ({
1675
+ border: "none",
1676
+ background: "none",
1677
+ color: "var(--text-dim)",
1678
+ cursor: "pointer",
1679
+ fontSize: 10.5,
1680
+ padding: "1px 4px",
1681
+ flexShrink: 0
1682
+ }), Un = (t) => ({
1683
+ height: 27,
1684
+ borderRadius: 7,
1685
+ fontSize: 11,
1686
+ padding: "0 10px",
1687
+ cursor: t ? "not-allowed" : "pointer",
1688
+ background: "var(--bg-hover)",
1689
+ color: "var(--text)",
1690
+ border: "1px solid var(--border)",
1691
+ opacity: t ? 0.6 : 1
1692
+ });
1693
+ function ir(t) {
1694
+ const [n, a] = f(null), [i, c] = f(null), [h, S] = f(0), F = Le(() => _t({ apiUrl: q }), []), s = E(async (w) => {
1695
+ const T = await F.refs(w);
1696
+ T.status === 200 && T.data?.ok !== !1 ? (a(!0), c({
1697
+ current: T.data.current ?? null,
1698
+ detached: !!T.data.detached,
1699
+ aheadBehind: T.data.aheadBehind ?? null,
1700
+ dirtyCount: T.data.dirtyCount ?? 0,
1701
+ dirtyFiles: T.data.dirtyFiles ?? []
1702
+ })) : (a(!1), c(null));
1703
+ }, [F]);
1704
+ se(() => {
1705
+ if (!t) {
1706
+ a(null), c(null);
1707
+ return;
1708
+ }
1709
+ let w = !1;
1710
+ return a(null), s(t).catch(() => {
1711
+ w || (a(!1), c(null));
1712
+ }), () => {
1713
+ w = !0;
1714
+ };
1715
+ }, [t, s]), se(() => {
1716
+ const w = ct("aiti-event-bus.subscribe-topics");
1717
+ if (w)
1718
+ return w((T) => {
1719
+ !T || typeof T.repo != "string" || t && (T.repo === t || t.startsWith(T.repo + "/")) && (s(t), S((p) => p + 1));
1720
+ }, ["aiti-git-ops:changed:*"]).off;
1721
+ }, [t, s]);
1722
+ const C = E(() => {
1723
+ t && s(t), S((w) => w + 1);
1724
+ }, [t, s]), L = E(async (w, T) => {
1725
+ const p = w === "stage" ? await F.stage(t, [T]) : w === "unstage" ? await F.unstage(t, [T]) : await F.discard(t, [T]);
1726
+ return s(t), S((D) => D + 1), p.status;
1727
+ }, [F, t, s]);
1728
+ return { avail: n, refs: i, statusBump: h, refresh: C, op: L };
1729
+ }
1730
+ function ar(t) {
1731
+ const { git: n, root: a } = t, [i, c] = f(!1), [h, S] = f(null), [F, s] = f(!1), [C, L] = f(!1), [w, T] = f(!1), [p, D] = f(null), [W, U] = f(null), Q = Le(() => _t({ apiUrl: q }), []), M = n.refs?.aheadBehind ?? null, z = E(async (O, _) => {
1732
+ if (!w) {
1733
+ T(!0), U(null);
1734
+ try {
1735
+ const J = O === "push" ? await Q.push(a, {}) : await Q.pull(a, _ || "ff-only");
1736
+ if (J.status !== 200) {
1737
+ U(J.data?.error ?? "HTTP " + J.status);
1738
+ return;
1739
+ }
1740
+ D(O === "push" ? "push ✓" : "pull ✓" + (J.data?.output ? `
1741
+ ` + J.data.output : "")), n.refresh(), t.onChanged?.();
1742
+ } finally {
1743
+ T(!1);
1744
+ }
1745
+ }
1746
+ }, [w, Q, a, n, t.onChanged]);
1747
+ return n.avail !== !0 || !n.refs?.current ? null : /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 4, padding: "3px 10px 3px", borderBottom: "1px solid var(--border)", fontSize: 11 }, children: [
1748
+ /* @__PURE__ */ l(
1749
+ "span",
1750
+ {
1751
+ "data-folder-git-chip": "1",
1752
+ title: $("git.branchPanelTitle"),
1753
+ onClick: (O) => {
1754
+ const _ = O.currentTarget.getBoundingClientRect();
1755
+ S({ left: _.left, top: _.top, right: _.right, bottom: _.bottom }), c((J) => !J);
1756
+ },
1757
+ style: {
1758
+ display: "inline-flex",
1759
+ alignItems: "center",
1760
+ gap: 4,
1761
+ padding: "1px 6px",
1762
+ borderRadius: 5,
1763
+ cursor: "pointer",
1764
+ fontFamily: "var(--font-mono)",
1765
+ fontSize: 10.5,
1766
+ color: i ? "var(--accent)" : "var(--text)",
1767
+ border: "1px solid " + (i ? "var(--accent)" : "var(--border)"),
1768
+ background: "var(--bg-hover)",
1769
+ maxWidth: 150,
1770
+ overflow: "hidden",
1771
+ whiteSpace: "nowrap",
1772
+ flexShrink: 1,
1773
+ minWidth: 0
1774
+ },
1775
+ children: [
1776
+ /* @__PURE__ */ l("svg", { width: "9", height: "9", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", style: { flexShrink: 0 }, children: [
1777
+ /* @__PURE__ */ e("circle", { cx: "4", cy: "3.5", r: "1.8" }),
1778
+ /* @__PURE__ */ e("circle", { cx: "4", cy: "12.5", r: "1.8" }),
1779
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "3.5", r: "1.8" }),
1780
+ /* @__PURE__ */ e("path", { d: "M4 5.3v5.4M12 5.3c0 3-3 3.6-6 4.1" })
1781
+ ] }),
1782
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis" }, children: n.refs.current })
1783
+ ]
1784
+ }
1785
+ ),
1786
+ M && M[0] > 0 ? /* @__PURE__ */ l(
1787
+ "button",
1788
+ {
1789
+ type: "button",
1790
+ disabled: w,
1791
+ title: $("git.pushTitle"),
1792
+ onClick: () => {
1793
+ window.confirm($("git.pushConfirm", { count: M[0] })) && z("push");
1794
+ },
1795
+ style: _n(),
1796
+ children: [
1797
+ M[0],
1798
+ /* @__PURE__ */ e(lr, {})
1799
+ ]
1800
+ }
1801
+ ) : null,
1802
+ M && M[1] > 0 ? /* @__PURE__ */ l(
1803
+ "button",
1804
+ {
1805
+ type: "button",
1806
+ disabled: w,
1807
+ title: $("git.pullTitle"),
1808
+ onClick: () => {
1809
+ window.confirm($("git.pullConfirm", { count: M[1] })) && z("pull");
1810
+ },
1811
+ style: _n(),
1812
+ children: [
1813
+ /* @__PURE__ */ e(sr, {}),
1814
+ M[1]
1815
+ ]
1816
+ }
1817
+ ) : null,
1818
+ M && M[0] === 0 && M[1] === 0 ? /* @__PURE__ */ e("span", { style: { color: "var(--text-dim)", fontSize: 10, fontFamily: "var(--font-mono)" }, children: "✓" }) : null,
1819
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
1820
+ /* @__PURE__ */ e(
1821
+ "button",
1822
+ {
1823
+ type: "button",
1824
+ title: $("git.planTitle"),
1825
+ onClick: () => {
1826
+ n.refresh(), L(!0);
1827
+ },
1828
+ style: { display: "inline-flex", alignItems: "center", gap: 3, border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: "2px 4px", borderRadius: 4 },
1829
+ children: $("git.planShort")
1830
+ }
1831
+ ),
1832
+ t.onToggleChanges ? /* @__PURE__ */ e(
1833
+ "button",
1834
+ {
1835
+ type: "button",
1836
+ title: $("git.changesToggle"),
1837
+ "aria-pressed": t.changesOpen,
1838
+ onClick: t.onToggleChanges,
1839
+ style: {
1840
+ display: "inline-flex",
1841
+ alignItems: "center",
1842
+ gap: 3,
1843
+ border: "none",
1844
+ background: "none",
1845
+ color: t.changesOpen ? "var(--accent)" : "var(--text-dim)",
1846
+ cursor: "pointer",
1847
+ fontSize: 11,
1848
+ padding: "2px 4px",
1849
+ borderRadius: 4
1850
+ },
1851
+ children: "☰"
1852
+ }
1853
+ ) : null,
1854
+ /* @__PURE__ */ e(
1855
+ "button",
1856
+ {
1857
+ type: "button",
1858
+ title: $("git.commitTitle"),
1859
+ onClick: () => {
1860
+ n.refresh(), s(!0);
1861
+ },
1862
+ style: { display: "inline-flex", alignItems: "center", gap: 3, border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 11, padding: "2px 4px", borderRadius: 4 },
1863
+ children: $("git.commitShort")
1864
+ }
1865
+ ),
1866
+ p || W ? /* @__PURE__ */ e(
1867
+ "span",
1868
+ {
1869
+ title: W ?? p,
1870
+ onClick: () => {
1871
+ D(null), U(null);
1872
+ },
1873
+ style: { fontSize: 10, color: W ? "var(--text)" : "var(--text-dim)", cursor: "pointer", maxWidth: 180, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontFamily: "var(--font-mono)" },
1874
+ children: W ? "⚠ " + W : p
1875
+ }
1876
+ ) : null,
1877
+ /* @__PURE__ */ e(
1878
+ Zo,
1879
+ {
1880
+ apiUrl: q,
1881
+ cwd: a,
1882
+ floatKey: "folder-branch-panel",
1883
+ locale: typeof navigator < "u" ? navigator.language : "en",
1884
+ open: i,
1885
+ onClose: () => c(!1),
1886
+ anchor: h,
1887
+ extSvc: ct,
1888
+ openFile: (O) => co(O, O.split("/").pop()),
1889
+ onChanged: () => {
1890
+ n.refresh(), t.onChanged?.();
1891
+ }
1892
+ }
1893
+ ),
1894
+ F ? /* @__PURE__ */ e(
1895
+ cr,
1896
+ {
1897
+ root: a,
1898
+ dirtyFiles: n.refs.dirtyFiles,
1899
+ onClose: () => s(!1),
1900
+ onDone: () => {
1901
+ s(!1), n.refresh(), t.onChanged?.();
1902
+ }
1903
+ }
1904
+ ) : null,
1905
+ C ? /* @__PURE__ */ e(rr, { root: a, git: n, onClose: () => L(!1) }) : null
1906
+ ] });
1907
+ }
1908
+ const _n = () => ({
1909
+ display: "inline-flex",
1910
+ alignItems: "center",
1911
+ gap: 2,
1912
+ border: "none",
1913
+ background: "none",
1914
+ color: "var(--text-dim)",
1915
+ cursor: "pointer",
1916
+ fontSize: 10.5,
1917
+ padding: "2px 4px",
1918
+ borderRadius: 4,
1919
+ fontFamily: "var(--font-mono)"
1920
+ });
1921
+ function lr() {
1922
+ return /* @__PURE__ */ l("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: [
1923
+ /* @__PURE__ */ e("polyline", { points: "17 11 12 6 7 11" }),
1924
+ /* @__PURE__ */ e("line", { x1: "12", y1: "6", x2: "12", y2: "20" })
1925
+ ] });
1926
+ }
1927
+ function sr() {
1928
+ return /* @__PURE__ */ l("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: [
1929
+ /* @__PURE__ */ e("polyline", { points: "7 13 12 18 17 13" }),
1930
+ /* @__PURE__ */ e("line", { x1: "12", y1: "18", x2: "12", y2: "4" })
1931
+ ] });
1932
+ }
1933
+ function cr(t) {
1934
+ const n = Le(() => _t({ apiUrl: q }), []), a = Le(() => new Set(t.dirtyFiles.filter((z) => z.xy[0] !== " " && z.xy[0] !== "?").map((z) => z.path)), [t.dirtyFiles]), [i, c] = f(a), [h, S] = f(""), [F, s] = f(!1), [C, L] = f(!1), [w, T] = f(null), [p, D] = f(!1), [W, U] = f(!1);
1935
+ se(() => {
1936
+ let z = !1;
1937
+ return fetch(q("/api/extensions/aiti-folder/git-commit-ai-avail"), { method: "POST", headers: { "content-type": "application/json" }, body: "{}" }).then((O) => O.json()).then((O) => {
1938
+ z || D(!!O?.avail);
1939
+ }).catch(() => {
1940
+ z || D(!1);
1941
+ }), () => {
1942
+ z = !0;
1943
+ };
1944
+ }, []);
1945
+ const Q = E(async () => {
1946
+ if (!(W || i.size === 0) && !(h.trim() && !window.confirm($("git.aiMessageOverwrite")))) {
1947
+ U(!0), T(null);
1948
+ try {
1949
+ const z = q("/api/agent/new"), O = z.slice(0, Math.max(0, z.indexOf("/api/"))), _ = await fetch(q("/api/extensions/aiti-folder/git-commit-ai-message"), {
1950
+ method: "POST",
1951
+ headers: { "content-type": "application/json" },
1952
+ body: JSON.stringify({ cwd: t.root, origin: location.origin, basePath: O, files: [...i], amend: F })
1953
+ }).then((J) => J.json()).catch(() => null);
1954
+ if (!_?.ok) {
1955
+ T(_?.error || $("i18n.networkError"));
1956
+ return;
1957
+ }
1958
+ S(String(_.message || ""));
1959
+ } finally {
1960
+ U(!1);
1961
+ }
1962
+ }
1963
+ }, [W, i, h, F, t.root]), M = E(async () => {
1964
+ if (!(C || !h.trim() && !F)) {
1965
+ L(!0), T(null);
1966
+ try {
1967
+ const z = [...i].filter((J) => !a.has(J)), O = [...a].filter((J) => !i.has(J));
1968
+ if (z.length > 0) {
1969
+ const J = await n.stage(t.root, z);
1970
+ if (J.status !== 200) {
1971
+ T(J.data?.error ?? "HTTP " + J.status);
1972
+ return;
1973
+ }
1974
+ }
1975
+ if (O.length > 0) {
1976
+ const J = await n.unstage(t.root, O);
1977
+ if (J.status !== 200) {
1978
+ T(J.data?.error ?? "HTTP " + J.status);
1979
+ return;
1980
+ }
1981
+ }
1982
+ const _ = await n.commit(t.root, h.trim() || void 0, F);
1983
+ if (_.status !== 200) {
1984
+ T(_.data?.error ?? "HTTP " + _.status);
1985
+ return;
1986
+ }
1987
+ t.onDone();
1988
+ } finally {
1989
+ L(!1);
1990
+ }
1991
+ }
1992
+ }, [C, h, F, i, a, n, t.root, t.onDone]);
1993
+ return /* @__PURE__ */ e(
1994
+ "div",
1995
+ {
1996
+ onClick: (z) => {
1997
+ z.target === z.currentTarget && !C && t.onClose();
1998
+ },
1999
+ style: { position: "fixed", inset: 0, zIndex: 900, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" },
2000
+ children: /* @__PURE__ */ l(
2001
+ "div",
2002
+ {
2003
+ "data-ext-float": "1",
2004
+ "data-ext-float-full": "1",
2005
+ "data-ext-float-autoh": "1",
2006
+ "data-ext-float-key": "aiti-folder.commit",
2007
+ "data-ext-float-w": 380,
2008
+ onClick: (z) => z.stopPropagation(),
2009
+ style: { width: 380, maxWidth: "92vw", maxHeight: "80vh", display: "flex", flexDirection: "column", borderRadius: 10, background: "var(--bg)", border: "1px solid var(--border)", boxShadow: "0 14px 36px color-mix(in srgb, var(--text) 16%, transparent)", fontSize: 12 },
2010
+ children: [
2011
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", padding: "10px 12px", borderBottom: "1px solid var(--border)", fontWeight: 600 }, children: [
2012
+ $("git.commitTitle"),
2013
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
2014
+ /* @__PURE__ */ e(
2015
+ "button",
2016
+ {
2017
+ type: "button",
2018
+ onClick: t.onClose,
2019
+ "aria-label": $("i18n.close"),
2020
+ title: $("i18n.close"),
2021
+ style: { border: "none", background: "none", color: "var(--text-dim)", cursor: "pointer", fontSize: 12, padding: "2px 4px" },
2022
+ children: "✕"
2023
+ }
2024
+ )
2025
+ ] }),
2026
+ /* @__PURE__ */ l("div", { style: { flex: "1 1 auto", minHeight: 0, overflowY: "auto", padding: "6px 12px" }, children: [
2027
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, margin: "4px 0" }, children: [
2028
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => c(new Set(t.dirtyFiles.map((z) => z.path))), style: Jn(), children: $("git.stageAll") }),
2029
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => c(new Set(a)), style: Jn(), children: $("git.stageNone") }),
2030
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
2031
+ /* @__PURE__ */ e("span", { style: { fontSize: 10.5, color: "var(--text-dim)", alignSelf: "center", fontFamily: "var(--font-mono)" }, children: $("git.stagedCount", { count: i.size }) })
2032
+ ] }),
2033
+ t.dirtyFiles.map((z) => {
2034
+ const O = i.has(z.path);
2035
+ return /* @__PURE__ */ l("label", { style: { display: "flex", alignItems: "center", gap: 7, padding: "2.5px 0", cursor: "pointer", fontFamily: "var(--font-mono)", fontSize: 10.5, color: "var(--text-muted)" }, children: [
2036
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: O, onChange: (_) => c((J) => {
2037
+ const ae = new Set(J);
2038
+ return _.target.checked ? ae.add(z.path) : ae.delete(z.path), ae;
2039
+ }), style: { accentColor: "var(--accent)", margin: 0, flexShrink: 0 } }),
2040
+ /* @__PURE__ */ e("span", { style: { width: 20, flexShrink: 0, color: "var(--text)" }, children: z.xy }),
2041
+ /* @__PURE__ */ e("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: z.path })
2042
+ ] }, z.path);
2043
+ })
2044
+ ] }),
2045
+ /* @__PURE__ */ l("div", { style: { padding: "8px 12px 10px", borderTop: "1px solid var(--border)", display: "flex", flexDirection: "column", gap: 7 }, children: [
2046
+ /* @__PURE__ */ e(
2047
+ "textarea",
2048
+ {
2049
+ value: h,
2050
+ onChange: (z) => S(z.target.value),
2051
+ placeholder: $("git.commitPlaceholder"),
2052
+ rows: 2,
2053
+ onKeyDown: (z) => {
2054
+ z.key === "Enter" && (z.ctrlKey || z.metaKey) && (z.preventDefault(), M());
2055
+ },
2056
+ style: { width: "100%", boxSizing: "border-box", resize: "vertical", minHeight: 44, background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 6, color: "var(--text)", fontSize: 11.5, padding: "6px 8px", outline: "none", fontFamily: "inherit" }
2057
+ }
2058
+ ),
2059
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
2060
+ /* @__PURE__ */ l("label", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11, color: "var(--text-muted)", cursor: "pointer" }, children: [
2061
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: F, onChange: (z) => s(z.target.checked), style: { accentColor: "var(--accent)", margin: 0 } }),
2062
+ $("git.amend")
2063
+ ] }),
2064
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
2065
+ p ? /* @__PURE__ */ e(
2066
+ "button",
2067
+ {
2068
+ type: "button",
2069
+ disabled: W || i.size === 0,
2070
+ onClick: () => void Q(),
2071
+ title: $("git.aiMessageTitle"),
2072
+ style: {
2073
+ height: 20,
2074
+ padding: "0 8px",
2075
+ borderRadius: 5,
2076
+ fontSize: 10.5,
2077
+ cursor: W || i.size === 0 ? "not-allowed" : "pointer",
2078
+ background: "var(--bg-hover)",
2079
+ color: "var(--text-muted)",
2080
+ border: "1px solid var(--border)",
2081
+ opacity: W || i.size === 0 ? 0.6 : 1
2082
+ },
2083
+ children: W ? $("git.aiMessageBusy") : $("git.aiMessage")
2084
+ }
2085
+ ) : null
2086
+ ] }),
2087
+ w ? /* @__PURE__ */ l("div", { style: { fontSize: 10.5, color: "var(--text)", background: "color-mix(in srgb, var(--text) 6%, transparent)", borderRadius: 5, padding: "4px 8px", overflowWrap: "anywhere" }, children: [
2088
+ "⚠ ",
2089
+ w
2090
+ ] }) : null,
2091
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6 }, children: [
2092
+ /* @__PURE__ */ e("button", { type: "button", disabled: C || !h.trim() && !F || i.size === 0, onClick: () => void M(), style: {
2093
+ flex: 1,
2094
+ height: 27,
2095
+ borderRadius: 7,
2096
+ fontSize: 11.5,
2097
+ fontWeight: 600,
2098
+ cursor: C ? "not-allowed" : "pointer",
2099
+ background: "var(--accent)",
2100
+ color: "var(--bg)",
2101
+ border: "1px solid var(--accent)",
2102
+ opacity: C || !h.trim() && !F || i.size === 0 ? 0.6 : 1
2103
+ }, children: C ? "…" : $("git.commitBtn") }),
2104
+ /* @__PURE__ */ e("button", { type: "button", onClick: t.onClose, style: { border: "1px solid var(--border)", background: "var(--bg-hover)", color: "var(--text-muted)", borderRadius: 7, fontSize: 11, padding: "0 12px", cursor: "pointer" }, children: $("files.cancel") })
2105
+ ] })
2106
+ ] })
2107
+ ]
2108
+ }
2109
+ )
2110
+ }
2111
+ );
2112
+ }
2113
+ const Jn = () => ({
2114
+ height: 22,
2115
+ padding: "0 8px",
2116
+ borderRadius: 5,
2117
+ fontSize: 10.5,
2118
+ cursor: "pointer",
2119
+ background: "var(--bg-hover)",
2120
+ color: "var(--text-muted)",
2121
+ border: "1px solid var(--border)"
2122
+ }), ot = () => ct("aiti-git-review.open") || window.__aitiGitReviewOpen, qe = () => ct("aiti-git-review.work") || window.__aitiGitReviewWork, to = 600 * 1e3, tn = /* @__PURE__ */ new Map();
2123
+ function Gt(t, n) {
2124
+ const a = Date.now();
2125
+ for (const [i, c] of tn) a - c.ts > to && tn.delete(i);
2126
+ n.size !== 0 && tn.set(Fn(t), { expanded: [...n], ts: a });
2127
+ }
2128
+ function $t(t) {
2129
+ if (!t) return null;
2130
+ const n = tn.get(Fn(t));
2131
+ return !n || Date.now() - n.ts > to ? null : new Set(n.expanded);
2132
+ }
2133
+ const dr = (t) => "folder:" + t;
2134
+ function fr({ name: t }) {
2135
+ const n = (ze(t).split(".").pop() || "").toLowerCase(), a = Eo[n], i = a ? Wo[a] : null;
2136
+ return i ? /* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: 2, background: i, flexShrink: 0, display: "inline-block" } }) : /* @__PURE__ */ e(Oo, {});
2137
+ }
2138
+ function nt(t) {
2139
+ return /* @__PURE__ */ e(
2140
+ "button",
2141
+ {
2142
+ type: "button",
2143
+ onClick: t.onClick,
2144
+ disabled: t.disabled,
2145
+ title: t.title,
2146
+ "aria-pressed": t.pressed ? "true" : void 0,
2147
+ style: { width: 28, height: 24, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, border: "none", background: t.bg || "transparent", color: t.color || "var(--text-dim)", cursor: t.disabled ? "default" : "pointer", borderRadius: 4, transition: "color 0.12s, background 0.12s" },
2148
+ children: t.children
2149
+ },
2150
+ t.key
2151
+ );
2152
+ }
2153
+ function Y(t, n, a, i) {
2154
+ return /* @__PURE__ */ l("button", { type: "button", onClick: a, style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "5px 10px", border: "none", background: "transparent", color: "var(--text,#222)", cursor: "pointer", textAlign: "left", fontSize: 12, borderRadius: 6, whiteSpace: "nowrap" }, children: [
2155
+ t ? /* @__PURE__ */ e("span", { style: { display: "inline-flex", flexShrink: 0, width: 13, justifyContent: "center" }, children: t }) : null,
2156
+ n
2157
+ ] }, i);
2158
+ }
2159
+ function Ie(t) {
2160
+ return /* @__PURE__ */ e("div", { style: { height: 1, background: "var(--border,#eee)", margin: "2px 4px" } }, t);
2161
+ }
2162
+ function pr(t) {
2163
+ const { t: n } = t, a = (i, c, h, S) => /* @__PURE__ */ e(
2164
+ "button",
2165
+ {
2166
+ type: "button",
2167
+ title: i,
2168
+ "aria-label": i,
2169
+ onClick: h,
2170
+ onMouseEnter: (F) => {
2171
+ F.currentTarget.style.background = "var(--bg-hover,#f3f4f6)";
2172
+ },
2173
+ onMouseLeave: (F) => {
2174
+ F.currentTarget.style.background = "transparent";
2175
+ },
2176
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", width: 28, height: 28, padding: 0, border: "none", borderRadius: 6, background: "transparent", color: "var(--text-muted,#777)", cursor: "pointer", flexShrink: 0 },
2177
+ children: c
2178
+ },
2179
+ S
2180
+ );
2181
+ return /* @__PURE__ */ l("div", { "data-ext-folder-close-row": "1", style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 16, padding: "5px 10px" }, children: [
2182
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, color: "var(--text-dim,#888)", flexShrink: 0, userSelect: "none" }, children: n("i18n.close") }),
2183
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, marginLeft: "auto", flexShrink: 0 }, children: [
2184
+ a(n("files.closeLeft"), /* @__PURE__ */ e(Bo, { size: 16 }), () => t.batch("left"), "cl"),
2185
+ a(n("i18n.close"), /* @__PURE__ */ e(wo, { size: 16 }), t.closeTab, "ct"),
2186
+ a(n("files.closeRight"), /* @__PURE__ */ e(Mo, { size: 16 }), () => t.batch("right"), "cr"),
2187
+ a(n("files.closeAll"), /* @__PURE__ */ e(Ao, { size: 16 }), () => t.batch("all"), "ca")
2188
+ ] })
2189
+ ] });
2190
+ }
2191
+ function Pe(t, n) {
2192
+ return /* @__PURE__ */ e("div", { style: { fontSize: 10, color: "var(--text-dim,#999)", fontWeight: 600, padding: "3px 6px 1px", letterSpacing: 0.4, userSelect: "none", whiteSpace: "nowrap" }, children: t }, n);
2193
+ }
2194
+ async function Dn(t) {
2195
+ try {
2196
+ if (navigator.clipboard && navigator.clipboard.writeText) {
2197
+ await navigator.clipboard.writeText(t);
2198
+ return;
2199
+ }
2200
+ } catch {
2201
+ }
2202
+ const n = document.createElement("textarea");
2203
+ n.value = t, n.style.position = "fixed", n.style.opacity = "0", document.body.appendChild(n), n.focus(), n.select();
2204
+ try {
2205
+ document.execCommand("copy");
2206
+ } finally {
2207
+ n.remove();
2208
+ }
2209
+ }
2210
+ function hr({ text: t }) {
2211
+ const n = [], a = /<mark>([\s\S]*?)<\/mark>/g;
2212
+ let i = 0, c, h = 0;
2213
+ for (; (c = a.exec(t)) !== null; )
2214
+ c.index > i && n.push(t.slice(i, c.index)), n.push(/* @__PURE__ */ e("span", { style: { background: "rgba(79,142,247,0.22)", borderRadius: 2 }, children: c[1] }, h++)), i = c.index + c[0].length;
2215
+ return i < t.length && n.push(t.slice(i)), /* @__PURE__ */ e(dn, { children: n });
2216
+ }
2217
+ function Wn(t) {
2218
+ const { path: n, onClose: a, t: i, onOpenFolder: c } = t, [h, S] = f(null), [F, s] = f(null);
2219
+ se(() => {
2220
+ let p = !1;
2221
+ return fetch(q("/api/extensions/aiti-folder/entry-info"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n }) }).then((D) => D.json()).then((D) => {
2222
+ p || (D && D.ok ? S(D) : s(D && D.error || "HTTP error"));
2223
+ }).catch((D) => {
2224
+ p || s(String(D));
2225
+ }), () => {
2226
+ p = !0;
2227
+ };
2228
+ }, [n]);
2229
+ const C = (p) => {
2230
+ if (p == null) return "—";
2231
+ if (p < 1024) return p + " B";
2232
+ const D = ["KB", "MB", "GB", "TB"];
2233
+ let W = p / 1024, U = 0;
2234
+ for (; W >= 1024 && U < D.length - 1; )
2235
+ W /= 1024, U++;
2236
+ return W.toFixed(W >= 100 ? 0 : 1) + " " + D[U];
2237
+ }, L = n.slice(0, n.lastIndexOf("/")) || "/", w = (p, D, W) => /* @__PURE__ */ l("div", { style: { display: "flex", gap: 10, alignItems: "baseline" }, children: [
2238
+ /* @__PURE__ */ e("span", { style: { width: 64, flexShrink: 0, color: "var(--text-dim,#888)" }, children: p }),
2239
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, wordBreak: "break-all", fontFamily: W ? "var(--font-mono,ui-monospace,monospace)" : void 0 }, children: D })
2240
+ ] }, p), T = () => /* @__PURE__ */ l("div", { style: { display: "flex", gap: 10, alignItems: "baseline" }, children: [
2241
+ /* @__PURE__ */ e("span", { style: { width: 64, flexShrink: 0, color: "var(--text-dim,#888)" }, children: i("files.infoParent") }),
2242
+ c ? /* @__PURE__ */ e(
2243
+ "button",
2244
+ {
2245
+ type: "button",
2246
+ title: i("files.infoOpenParent"),
2247
+ onClick: () => {
2248
+ a(), c(L, ze(L) || void 0);
2249
+ },
2250
+ style: {
2251
+ flex: 1,
2252
+ minWidth: 0,
2253
+ wordBreak: "break-all",
2254
+ textAlign: "left",
2255
+ padding: 0,
2256
+ border: "none",
2257
+ background: "transparent",
2258
+ cursor: "pointer",
2259
+ color: "var(--accent,#4f8ef7)",
2260
+ fontFamily: "var(--font-mono,ui-monospace,monospace)",
2261
+ textDecoration: "underline",
2262
+ textDecorationStyle: "dotted",
2263
+ textUnderlineOffset: 3
2264
+ },
2265
+ children: L
2266
+ }
2267
+ ) : /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, wordBreak: "break-all", fontFamily: "var(--font-mono,ui-monospace,monospace)" }, children: L })
2268
+ ] }, "dir");
2269
+ return /* @__PURE__ */ e("div", { onClick: (p) => {
2270
+ p.target === p.currentTarget && a();
2271
+ }, style: { position: "fixed", inset: 0, zIndex: 500, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ l("div", { style: { width: 400, maxWidth: "92vw", padding: "16px 18px", borderRadius: 12, background: "var(--bg,#fff)", border: "1px solid var(--border,#ddd)", boxShadow: "0 12px 40px rgba(0,0,0,0.25)", fontSize: 13 }, children: [
2272
+ /* @__PURE__ */ e("div", { style: { fontWeight: 600, fontSize: 14, marginBottom: 10 }, children: i("files.entryInfo") }),
2273
+ F ? /* @__PURE__ */ e("div", { style: { color: "var(--danger, #f87171)", fontSize: 12 }, children: F }) : h ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 7, fontSize: 12 }, children: [
2274
+ w(i("files.infoName"), h.name, !0),
2275
+ w(i("files.infoType"), h.isDir ? i("files.infoTypeDir") : i("files.infoTypeFile")),
2276
+ w(i("files.infoSize"), C(h.size)),
2277
+ w(i("files.infoMtime"), h.mtimeMs ? new Date(h.mtimeMs).toLocaleString() : "—"),
2278
+ T(),
2279
+ h.isDir && h.items != null ? w(i("files.infoItems"), String(h.items)) : null
2280
+ ] }) : /* @__PURE__ */ e("div", { style: { color: "var(--text-dim,#888)", fontSize: 12 }, children: "…" }),
2281
+ /* @__PURE__ */ e("div", { style: { display: "flex", justifyContent: "flex-end", marginTop: 12 }, children: /* @__PURE__ */ e("button", { type: "button", onClick: a, style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: i("files.cancel") }) })
2282
+ ] }) });
2283
+ }
2284
+ const Me = { height: 24, padding: "0 10px", borderRadius: 5, cursor: "pointer", fontSize: 12, fontWeight: 600 };
2285
+ function On(t) {
2286
+ const { path: n, cwd: a, root: i, mode: c = "move", t: h, onClose: S, onMoved: F } = t, s = c === "copy", C = ze(n) || "", [L, w] = f(i), [T, p] = f([]), [D, W] = f(""), [U, Q] = f(!1), [M, z] = f(i), [O, _] = f(null), [J, ae] = f(!1), [le, ee] = f(null), [de, we] = f(!1), [he, b] = f(null), [P, R] = f(!1), j = E((m) => {
2287
+ ae(!0), ee(null), fetch(q("/api/cwd/browse"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: m }) }).then(async (K) => {
2288
+ const V = await K.json();
2289
+ if (!K.ok || V.error) throw new Error(V.error || "HTTP " + K.status);
2290
+ _(V), z(V.path);
2291
+ }).catch((K) => ee(K && K.message ? K.message : String(K))).finally(() => ae(!1));
2292
+ }, []);
2293
+ se(() => {
2294
+ fetch(q("/api/home")).then((m) => m.json()).then((m) => {
2295
+ m.home && W(m.home);
2296
+ }).catch(() => {
2297
+ }), fetch(q("/api/sessions"), { cache: "no-store" }).then((m) => m.json()).then((m) => {
2298
+ const K = Co(m.sessions || []).map((te) => te.root).filter(Boolean), V = /* @__PURE__ */ new Set(), oe = [];
2299
+ for (const te of [i, ...K])
2300
+ V.has(te) || (V.add(te), oe.push(te));
2301
+ p(oe);
2302
+ }).catch(() => {
2303
+ }), j(i);
2304
+ }, []);
2305
+ const v = (m) => {
2306
+ w(m), Q(!1), j(m);
2307
+ }, I = O && O.directories || [], A = O && O.drives, fe = async () => {
2308
+ if (!(de || !M)) {
2309
+ we(!0), b(null);
2310
+ try {
2311
+ const m = await fetch(q(s ? "/api/extensions/aiti-folder/copy" : "/api/extensions/aiti-folder/move"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n, targetDir: M }) }), K = await m.json().catch(() => ({}));
2312
+ !m.ok || !K.ok ? b({ err: K.error || "HTTP " + m.status }) : (F(K.path), S());
2313
+ } catch (m) {
2314
+ b({ err: m && m.message ? m.message : String(m) });
2315
+ } finally {
2316
+ we(!1);
2317
+ }
2318
+ }
2319
+ }, G = { display: "flex", alignItems: "center", gap: 8, width: "100%", padding: "0 12px", height: 26, border: "none", background: "transparent", color: "var(--text)", cursor: "pointer", textAlign: "left", fontSize: 12 };
2320
+ return /* @__PURE__ */ l("div", { onClick: (m) => {
2321
+ m.target === m.currentTarget && !de && S();
2322
+ }, style: { position: "fixed", inset: 0, zIndex: 520, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: [
2323
+ /* @__PURE__ */ l("div", { style: { width: "min(540px,92vw)", maxHeight: "82vh", display: "flex", flexDirection: "column", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 10, boxShadow: "0 12px 40px rgba(0,0,0,0.3)", overflow: "hidden" }, children: [
2324
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: "1px solid var(--border)", background: "var(--bg)", flexShrink: 0 }, children: [
2325
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--text)" }, children: h(s ? "files.copyToTitle" : "files.moveTitle") }),
2326
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--font-mono,ui-monospace,monospace)", fontSize: 12, color: "var(--text-dim)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: n, children: C }),
2327
+ /* @__PURE__ */ e("button", { onClick: () => {
2328
+ de || S();
2329
+ }, title: h("i18n.close"), style: { height: 26, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12, flexShrink: 0 }, children: "✕" })
2330
+ ] }),
2331
+ /* @__PURE__ */ l("div", { style: { position: "relative", display: "flex", alignItems: "center", gap: 6, padding: "6px 12px", borderBottom: "1px solid var(--border)", background: "var(--bg)", flexShrink: 0 }, children: [
2332
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600, flexShrink: 0 }, children: h("files.moveWorkspace") }),
2333
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => Q((m) => !m), title: L, style: { flex: 1, minWidth: 0, display: "flex", alignItems: "center", gap: 6, padding: "5px 8px", background: "var(--bg-hover)", border: "1px solid var(--border)", borderRadius: 5, cursor: "pointer", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", color: "var(--text)", overflow: "hidden" }, children: [
2334
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: Gn(L, D) }),
2335
+ /* @__PURE__ */ e(To, {})
2336
+ ] }),
2337
+ U ? /* @__PURE__ */ l("div", { style: { position: "absolute", top: "calc(100% + 4px)", left: 12, right: 12, zIndex: 120, maxHeight: "min(44vh,300px)", overflowY: "auto", background: "var(--bg,#fff)", border: "1px solid var(--border,#d0d0d0)", borderRadius: 8, boxShadow: "0 6px 20px rgba(0,0,0,0.15)", padding: 4 }, children: [
2338
+ T.map((m) => {
2339
+ const K = m === L;
2340
+ return /* @__PURE__ */ l(
2341
+ "button",
2342
+ {
2343
+ type: "button",
2344
+ onClick: () => v(m),
2345
+ title: m,
2346
+ style: { ...G, fontFamily: "var(--font-mono,ui-monospace,monospace)", color: K ? "var(--accent)" : "var(--text)", fontWeight: K ? 600 : 400 },
2347
+ children: [
2348
+ /* @__PURE__ */ e(en, { open: !1 }),
2349
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: Gn(m, D) }),
2350
+ K ? /* @__PURE__ */ e(Vn, {}) : null
2351
+ ]
2352
+ },
2353
+ m
2354
+ );
2355
+ }),
2356
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => {
2357
+ Q(!1), R(!0);
2358
+ }, style: G, children: [
2359
+ /* @__PURE__ */ l("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: 1.1, strokeLinecap: "round", style: { flexShrink: 0 }, children: [
2360
+ /* @__PURE__ */ e("line", { x1: "5", y1: "1", x2: "5", y2: "9" }),
2361
+ /* @__PURE__ */ e("line", { x1: "1", y1: "5", x2: "9", y2: "5" })
2362
+ ] }),
2363
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, color: "var(--text-dim)" }, children: h("sidebar.customPath") })
2364
+ ] })
2365
+ ] }) : null
2366
+ ] }),
2367
+ /* @__PURE__ */ l("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: [
2368
+ O && O.parentPath != null ? /* @__PURE__ */ e("button", { onClick: () => j(O.parentPath), title: h("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, display: "inline-flex", alignItems: "center" }, children: /* @__PURE__ */ e(Cn, { size: 12 }) }) : null,
2369
+ /* @__PURE__ */ e("span", { title: M, style: { overflow: "hidden", textOverflow: "ellipsis" }, children: M || "/" })
2370
+ ] }),
2371
+ /* @__PURE__ */ l("div", { style: { flex: 1, overflowY: "auto", padding: "4px 0" }, children: [
2372
+ J ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: h("files.loading") }) : null,
2373
+ le ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--danger, #f87171)" }, children: le }) : null,
2374
+ !J && !le && A && A.length > 0 ? A.map((m) => /* @__PURE__ */ l("button", { onClick: () => j(m.path), style: G, children: [
2375
+ /* @__PURE__ */ e(en, { open: !1 }),
2376
+ /* @__PURE__ */ e("span", { style: { fontSize: 12 }, children: m.name })
2377
+ ] }, m.path)) : null,
2378
+ !J && !le && I.length === 0 && (!A || A.length === 0) ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: h("files.noSubdirs") }) : null,
2379
+ !J && !le ? I.map((m) => /* @__PURE__ */ l("button", { onClick: () => j(m.path), title: m.path, style: G, children: [
2380
+ /* @__PURE__ */ e(en, { open: !1 }),
2381
+ /* @__PURE__ */ e("span", { style: { flex: 1, fontSize: 12, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: m.name }),
2382
+ /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "var(--text-dim)" }, children: "→" })
2383
+ ] }, m.path)) : null
2384
+ ] }),
2385
+ /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "8px 12px", borderTop: "1px solid var(--border)", background: "var(--bg)", flexShrink: 0 }, children: [
2386
+ he ? /* @__PURE__ */ e("div", { style: { fontSize: 11, color: he.err ? "var(--danger, #f87171)" : "var(--ok, #4ade80)" }, children: he.err || he.ok }) : null,
2387
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2388
+ /* @__PURE__ */ l("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--font-mono,ui-monospace,monospace)", fontSize: 11, color: "var(--text-dim,#888)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: M, children: [
2389
+ "→ ",
2390
+ h("files.moveTarget"),
2391
+ ": ",
2392
+ M || "/"
2393
+ ] }),
2394
+ /* @__PURE__ */ e("button", { onClick: () => {
2395
+ de || S();
2396
+ }, style: { height: 28, padding: "0 12px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12 }, children: h("files.cancel") }),
2397
+ /* @__PURE__ */ e("button", { onClick: () => void fe(), disabled: de || !M, style: { height: 28, padding: "0 12px", border: "none", borderRadius: 5, background: "var(--accent,#4f8ef7)", color: "#fff", cursor: de ? "default" : "pointer", fontSize: 12, fontWeight: 600, opacity: de || !M ? 0.6 : 1 }, children: de ? "…" : h(s ? "files.copyHere" : "files.moveHere") })
2398
+ ] })
2399
+ ] })
2400
+ ] }),
2401
+ P ? /* @__PURE__ */ e(Po, { initialPath: L, onSelect: (m) => {
2402
+ R(!1), v(m);
2403
+ }, onCancel: () => R(!1) }) : null
2404
+ ] });
2405
+ }
2406
+ function Tt(t, n, a) {
2407
+ Io(q, { path: n, kind: t, cwd: a });
2408
+ }
2409
+ async function St(t, n) {
2410
+ const a = window.opener;
2411
+ if (a && !a.closed)
2412
+ return new Promise((c) => {
2413
+ const h = "ot-" + Date.now() + "-" + Math.random().toString(36).slice(2, 8), S = n || ze(t) || "bash", F = (s) => {
2414
+ if (s.origin !== location.origin || s.source !== a) return;
2415
+ const C = s.data;
2416
+ !C || C.source !== "aiti-cmd" || C.type !== "open-shell-result" || C.reqId !== h || (window.removeEventListener("message", F), c(C.ok ? null : C.error || "创建终端失败"));
2417
+ };
2418
+ window.addEventListener("message", F);
2419
+ try {
2420
+ a.postMessage({ source: "aiti-ext", type: "open-shell", reqId: h, cwd: t, name: S }, location.origin);
2421
+ } catch (s) {
2422
+ window.removeEventListener("message", F), c(s && s.message ? s.message : String(s));
2423
+ return;
2424
+ }
2425
+ setTimeout(() => {
2426
+ window.removeEventListener("message", F), c("主窗口未响应(aiti-cmd 未启用?)");
2427
+ }, 4e3);
2428
+ });
2429
+ try {
2430
+ const h = ct("pi-web.ui")?.get?.("onOpenTerminal");
2431
+ if (typeof h == "function")
2432
+ return h(t), null;
2433
+ } catch {
2434
+ }
2435
+ const i = window.__aitiCmd;
2436
+ if (i && typeof i.openShell == "function") {
2437
+ const c = await i.openShell(t, n || ze(t) || "bash");
2438
+ return c && c.ok ? null : c && c.error || "创建终端失败";
2439
+ }
2440
+ try {
2441
+ const c = await fetch(q("/api/extensions/aiti-folder/open-terminal"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: t }) }), h = await c.json().catch(() => ({}));
2442
+ return !c.ok || !h.ok ? h && h.error || "HTTP " + c.status : null;
2443
+ } catch (c) {
2444
+ return c && c.message ? c.message : String(c);
2445
+ }
2446
+ }
2447
+ function Pt() {
2448
+ return /* @__PURE__ */ l("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
2449
+ /* @__PURE__ */ e("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
2450
+ /* @__PURE__ */ e("polyline", { points: "15 3 21 3 21 9" }),
2451
+ /* @__PURE__ */ e("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
2452
+ ] });
2453
+ }
2454
+ function cn({ size: t = 13 }) {
2455
+ return /* @__PURE__ */ l("svg", { width: t, height: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, "aria-hidden": "true", children: [
2456
+ /* @__PURE__ */ e("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
2457
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "3" })
2458
+ ] });
2459
+ }
2460
+ function ur(t) {
2461
+ const { dir: n, hovered: a, onChanged: i, onRefresh: c, onOpenFile: h, onAtMention: S, onTrash: F, t: s, root: C, cwd: L } = t, [w, T] = f(!1), [p, D] = f(null), [W, U] = f(""), [Q, M] = f(!1), [z, O] = f(null), [_, J] = f(!1), [ae, le] = f(""), [ee, de] = f(null), we = Oe(null), he = Oe(null);
2462
+ se(() => {
2463
+ if (!w) return;
2464
+ const B = (re) => {
2465
+ re.target.closest?.("[data-dirops]") || T(!1);
2466
+ }, H = () => T(!1);
2467
+ return document.addEventListener("mousedown", B), document.addEventListener("wheel", H, { passive: !0 }), () => {
2468
+ document.removeEventListener("mousedown", B), document.removeEventListener("wheel", H);
2469
+ };
2470
+ }, [w]);
2471
+ const b = async () => {
2472
+ const B = W.trim();
2473
+ if (!B || !p || Q) return;
2474
+ const H = p === "file" ? "/api/extensions/aiti-folder/create-file" : "/api/extensions/aiti-folder/create-folder";
2475
+ M(!0);
2476
+ try {
2477
+ const re = await fetch(q(H), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: n, name: B }) }), ce = await re.json().catch(() => ({}));
2478
+ !re.ok || !ce.ok ? O({ err: ce.error || "HTTP " + re.status }) : (O({ ok: s(p === "file" ? "files.newFile" : "files.newFolder") + " ✓" }), T(!1), D(null), U(""), de(null), i?.(n), p === "file" && ce.path && h && h(ce.path));
2479
+ } catch (re) {
2480
+ O({ err: re && re.message ? re.message : String(re) });
2481
+ } finally {
2482
+ M(!1);
2483
+ }
2484
+ }, P = async (B, H) => {
2485
+ const re = Array.from(B.target.files || []);
2486
+ if (B.target.value = "", !(re.length === 0 || Q)) {
2487
+ M(!0), O(null);
2488
+ try {
2489
+ if (H) {
2490
+ const ce = new FormData();
2491
+ ce.append("dir", n);
2492
+ for (const ge of re) {
2493
+ const xe = (ge.webkitRelativePath || ge.name || "").replace(/\\/g, "/");
2494
+ ce.append("files", ge, xe || ge.name);
2495
+ }
2496
+ const Re = await fetch(q("/api/extensions/aiti-folder/upload-tree"), { method: "POST", body: ce }), ye = await Re.json().catch(() => ({}));
2497
+ !Re.ok || !ye.ok ? O({ err: ye.error || "HTTP " + Re.status }) : (O({ ok: "↑" + (ye.uploaded || []).length + " / 跳" + (ye.skipped || []).length }), T(!1), i?.(n));
2498
+ } else {
2499
+ const ce = new FormData();
2500
+ ce.append("directory", n), re.forEach((ge) => ce.append("files", ge, ge.name));
2501
+ const Re = await fetch(q("/api/files/upload?conflict=skip"), { method: "POST", body: ce }), ye = await Re.json().catch(() => ({}));
2502
+ !Re.ok && !ye.conflicts ? O({ err: ye.error || "HTTP " + Re.status }) : (O({ ok: "↑" + (ye.uploaded || []).length + " / 跳" + (ye.skipped || []).length }), T(!1), i?.(n));
2503
+ }
2504
+ } catch (ce) {
2505
+ O({ err: ce && ce.message ? ce.message : String(ce) });
2506
+ } finally {
2507
+ M(!1);
2508
+ }
2509
+ }
2510
+ }, R = () => {
2511
+ S && (S(Ct(n, L), !1), T(!1));
2512
+ }, j = () => {
2513
+ Dn(n).then(() => O({ ok: s("files.copyDone") }), (B) => O({ err: B && B.message ? B.message : s("files.copyFailed") }));
2514
+ }, v = () => {
2515
+ F && (F({ path: n, name: ze(n), isDir: !0 }), T(!1));
2516
+ }, I = async () => {
2517
+ try {
2518
+ const B = await fetch(q("/api/extensions/aiti-folder/archive-ticket"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n }) }), H = await B.json().catch(() => ({}));
2519
+ if (!B.ok || !H.ok || !H.ticket) {
2520
+ O({ err: H.error || "HTTP " + B.status }), T(!1);
2521
+ return;
2522
+ }
2523
+ const re = document.createElement("a");
2524
+ re.href = q("/api/extensions/aiti-folder/archive?ticket=" + encodeURIComponent(H.ticket)), re.download = ze(n) + ".tar.gz", re.click();
2525
+ } catch {
2526
+ }
2527
+ T(!1);
2528
+ }, A = () => {
2529
+ J(!0), le(ze(n) || "");
2530
+ }, fe = async () => {
2531
+ const B = ae.trim();
2532
+ if (!(!B || !_ || Q)) {
2533
+ M(!0);
2534
+ try {
2535
+ const H = await fetch(q("/api/extensions/aiti-folder/rename"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n, newName: B }) }), re = await H.json().catch(() => ({}));
2536
+ !H.ok || !re.ok ? O({ err: re.error || "HTTP " + H.status }) : (O({ ok: s("files.renameSuccess") || "✓" }), J(!1), le(""), T(!1), i?.(n));
2537
+ } catch (H) {
2538
+ O({ err: H && H.message ? H.message : String(H) });
2539
+ } finally {
2540
+ M(!1);
2541
+ }
2542
+ }
2543
+ }, G = async () => {
2544
+ try {
2545
+ const B = n + "/", H = fn(B);
2546
+ await pn({ text: H, targetDir: n, targetPath: n, currentCwd: L, apiUrl: q, extSvc: ct });
2547
+ } catch {
2548
+ }
2549
+ T(!1);
2550
+ }, [m, K] = f(!1), [V, oe] = f(null);
2551
+ return /* @__PURE__ */ l("div", { "data-dirops": 1, onClick: (B) => B.stopPropagation(), style: { position: "absolute", right: 4, top: 1, zIndex: 40, display: a || w || !!V ? void 0 : "none" }, children: [
2552
+ /* @__PURE__ */ e(
2553
+ "button",
2554
+ {
2555
+ type: "button",
2556
+ onClick: (B) => {
2557
+ if (B.stopPropagation(), w) {
2558
+ T(!1);
2559
+ return;
2560
+ }
2561
+ const H = B.currentTarget.getBoundingClientRect(), re = 590, ce = 190, Re = Math.max(8, Math.min(H.right - ce, window.innerWidth - ce - 8)), ye = H.bottom + 4 + re > window.innerHeight, ge = H.top - re - 4 < 0;
2562
+ let xe;
2563
+ ye && !ge ? xe = Math.max(8, H.top - re - 4) : ye && ge ? xe = 8 : xe = H.bottom + 4, de({ left: Re, top: xe }), T(!0);
2564
+ },
2565
+ title: s("files.rename") + " / " + s("files.insertPath") + " / " + s("files.download") + " / " + s("files.trash") + " / " + s("files.newFile"),
2566
+ style: { width: 24, height: 22, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid var(--border)", borderRadius: 4, background: w ? "var(--bg-selected)" : "var(--bg-panel)", color: w ? "var(--accent)" : "var(--text-dim)", cursor: "pointer", fontSize: 14, fontWeight: 700, lineHeight: 1, transition: "color 0.12s, background 0.12s" },
2567
+ children: "⋮"
2568
+ }
2569
+ ),
2570
+ w ? /* @__PURE__ */ l("div", { style: { position: "fixed", left: ee.left, top: ee.top, zIndex: 400, minWidth: 170, padding: 6, background: "var(--bg,#fff)", border: "1px solid var(--border,#d0d0d0)", borderRadius: 10, boxShadow: "0 4px 12px rgba(0,0,0,0.15)", fontSize: 12, display: "flex", flexDirection: "column", gap: 2 }, children: [
2571
+ p ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "2px 2px 4px" }, children: [
2572
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600 }, children: s(p === "file" ? "files.newFile" : "files.newFolder") }),
2573
+ /* @__PURE__ */ e(
2574
+ "input",
2575
+ {
2576
+ autoFocus: !0,
2577
+ value: W,
2578
+ onChange: (B) => U(B.target.value),
2579
+ onKeyDown: (B) => {
2580
+ B.key === "Enter" && b(), B.key === "Escape" && D(null);
2581
+ },
2582
+ placeholder: s("files.namePlaceholderFile"),
2583
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border,#d0d0d0)", borderRadius: 5, outline: "none", background: "var(--bg,#fff)", color: "var(--text,#222)" }
2584
+ }
2585
+ ),
2586
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
2587
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => D(null), style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: s("files.cancel") }),
2588
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void b(), disabled: !W.trim() || Q, style: { ...Me, background: "var(--accent,#4f8ef7)", color: "#fff", border: "none", opacity: !W.trim() || Q ? 0.5 : 1 }, children: Q ? "…" : s("files.create") })
2589
+ ] })
2590
+ ] }) : _ ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "2px 2px 4px" }, children: [
2591
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600 }, children: s("files.rename") }),
2592
+ /* @__PURE__ */ e(
2593
+ "input",
2594
+ {
2595
+ autoFocus: !0,
2596
+ value: ae,
2597
+ onChange: (B) => le(B.target.value),
2598
+ onKeyDown: (B) => {
2599
+ B.key === "Enter" && fe(), B.key === "Escape" && J(!1);
2600
+ },
2601
+ placeholder: s("files.renamePlaceholder") || "输入新文件名",
2602
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border,#d0d0d0)", borderRadius: 5, outline: "none", background: "var(--bg,#fff)", color: "var(--text,#222)" }
2603
+ }
2604
+ ),
2605
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
2606
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => J(!1), style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: s("files.cancel") }),
2607
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void fe(), disabled: !ae.trim() || Q, style: { ...Me, background: "var(--accent,#4f8ef7)", color: "#fff", border: "none", opacity: !ae.trim() || Q ? 0.5 : 1 }, children: Q ? "…" : s("files.confirm") })
2608
+ ] })
2609
+ ] }) : [
2610
+ // ── 打开/查看 ──
2611
+ Pe(s("files.menuOpen"), "h-open"),
2612
+ Y(/* @__PURE__ */ e(Tn, {}), s("files.refresh"), () => {
2613
+ T(!1), c && c();
2614
+ }, "rf"),
2615
+ Y(/* @__PURE__ */ e(Pt, {}), s("files.openNewWindow"), () => {
2616
+ T(!1), Tt("folder", n);
2617
+ }, "nw"),
2618
+ Y(/* @__PURE__ */ e(Kt, {}), s("files.openTerminal"), () => {
2619
+ T(!1), St(n).then((B) => {
2620
+ B && O({ err: B });
2621
+ });
2622
+ }, "ot"),
2623
+ Y(/* @__PURE__ */ e(on, {}), s("files.entryInfo"), () => K(!0), "info"),
2624
+ // 菜单保持开:容器 visible=hovered||open,关菜单会连带隐藏弹层
2625
+ // ── 路径引用(复制路径邻接 @)──
2626
+ Ie("s-ref"),
2627
+ Pe(s("files.menuRef"), "h-ref"),
2628
+ S ? Y(/* @__PURE__ */ e(zt, {}), s("files.insertPath"), R, "at") : null,
2629
+ Y(/* @__PURE__ */ e(nn, {}), s("files.copyPath"), j, "cp"),
2630
+ Y(/* @__PURE__ */ e(zt, {}), s("files.atNewSession"), G, "atn"),
2631
+ // ── 整理(复制到邻接 移动到)──
2632
+ Ie("s-org"),
2633
+ Pe(s("files.menuOrganize"), "h-org"),
2634
+ Y(/* @__PURE__ */ e(rn, {}), s("files.rename"), A, "rn"),
2635
+ Y(/* @__PURE__ */ e(an, {}), s("files.move"), () => {
2636
+ oe("move");
2637
+ }, "mv"),
2638
+ Y(/* @__PURE__ */ e(ln, {}), s("files.copyTo"), () => {
2639
+ oe("copy");
2640
+ }, "cpto"),
2641
+ F ? Y(/* @__PURE__ */ e(Pn, {}), s("files.trash"), v, "tr") : null,
2642
+ // ── 新建 / 上传 ──
2643
+ Ie("s-new"),
2644
+ Pe(s("files.menuCreate"), "h-new"),
2645
+ Y(/* @__PURE__ */ e(Xn, {}), s("files.newFile"), () => {
2646
+ D("file"), U("");
2647
+ }, "nf"),
2648
+ Y(/* @__PURE__ */ e(Qn, {}), s("files.newFolder"), () => {
2649
+ D("folder"), U("");
2650
+ }, "nd"),
2651
+ Y(/* @__PURE__ */ e(sn, {}), s("files.uploadFile"), () => {
2652
+ T(!1), we.current && we.current.click();
2653
+ }, "uf"),
2654
+ Y(/* @__PURE__ */ e(sn, {}), s("files.uploadFolder"), () => {
2655
+ T(!1), he.current && he.current.click();
2656
+ }, "ud"),
2657
+ // ── 导出 ──
2658
+ Ie("s-exp"),
2659
+ Pe(s("files.menuExport"), "h-exp"),
2660
+ Y(/* @__PURE__ */ e(Ut, {}), s("files.download"), I, "dl"),
2661
+ // ── Git ──
2662
+ C ? Ie("s-git") : null,
2663
+ C ? Pe(s("files.menuGit"), "h-git") : null,
2664
+ C ? /* @__PURE__ */ l("button", { type: "button", onClick: (B) => {
2665
+ B.stopPropagation();
2666
+ try {
2667
+ ot() && ot()({ scope: { kind: "directory", path: C } }), qe() && qe();
2668
+ } catch {
2669
+ }
2670
+ T(!1);
2671
+ }, style: { display: "flex", alignItems: "center", gap: 6, width: "100%", padding: "5px 10px", border: "none", background: "transparent", color: "var(--accent)", cursor: "pointer", textAlign: "left", fontSize: 12, borderRadius: 6, whiteSpace: "nowrap" }, children: [
2672
+ /* @__PURE__ */ e(cn, { size: 13 }),
2673
+ "Git Review"
2674
+ ] }, "gr") : null
2675
+ ],
2676
+ z ? /* @__PURE__ */ e("div", { style: { fontSize: 10, color: z.err ? "var(--danger, #f87171)" : "var(--ok, #4ade80)", padding: "2px 4px" }, children: z.err ? z.err : z.ok || "" }) : null
2677
+ ] }) : null,
2678
+ /* @__PURE__ */ e("input", { ref: we, type: "file", multiple: !0, hidden: !0, onChange: (B) => void P(B, !1) }),
2679
+ /* @__PURE__ */ e("input", { ref: he, type: "file", multiple: !0, hidden: !0, webkitdirectory: "", onChange: (B) => void P(B, !0) }),
2680
+ m ? /* @__PURE__ */ e(Wn, { path: n, onClose: () => {
2681
+ K(!1), T(!1);
2682
+ }, t: s, onOpenFolder: t.onOpenFolder }) : null,
2683
+ V ? /* @__PURE__ */ e(On, { path: n, cwd: L, root: C, mode: V, t: s, onClose: () => {
2684
+ oe(null);
2685
+ }, onMoved: (B) => {
2686
+ oe(null), T(!1), i?.(n);
2687
+ } }) : null
2688
+ ] });
2689
+ }
2690
+ function no(t) {
2691
+ const { filePath: n, cwd: a, root: i, onOpenFile: c, onAtMention: h, onTrash: S, hovered: F, t: s, onRefresh: C } = t, [L, w] = f(!1), [T, p] = f(null), [D, W] = f(!1), [U, Q] = f(""), [M, z] = f(null);
2692
+ se(() => {
2693
+ if (!L) return;
2694
+ const v = (A) => {
2695
+ A.target.closest?.("[data-fileops]") || w(!1);
2696
+ }, I = () => w(!1);
2697
+ return document.addEventListener("mousedown", v), document.addEventListener("wheel", I, { passive: !0 }), () => {
2698
+ document.removeEventListener("mousedown", v), document.removeEventListener("wheel", I);
2699
+ };
2700
+ }, [L]);
2701
+ const O = (v) => {
2702
+ if (v.stopPropagation(), L) {
2703
+ w(!1);
2704
+ return;
2705
+ }
2706
+ const I = v.currentTarget.getBoundingClientRect(), A = 460, fe = 168, G = Math.max(8, Math.min(I.right - fe, window.innerWidth - fe - 8)), m = I.bottom + 4 + A > window.innerHeight, K = I.top - A - 4 < 0;
2707
+ let V;
2708
+ m && !K ? V = Math.max(8, I.top - A - 4) : m && K ? V = 8 : V = I.bottom + 4, p({ left: G, top: V }), w(!0);
2709
+ }, _ = () => {
2710
+ h && (h(Ct(n, a), !1), w(!1));
2711
+ }, J = () => {
2712
+ Dn(n).then(() => z({ ok: s("files.copyDone") }), (v) => z({ err: v && v.message ? v.message : s("files.copyFailed") }));
2713
+ }, ae = () => {
2714
+ S && (S({ path: n, name: ze(n), isDir: !1 }), w(!1));
2715
+ }, le = () => {
2716
+ try {
2717
+ fetch(q("/api/files/ticket"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n }) }).then((v) => v.json()).then((v) => {
2718
+ if (!v.ticket) throw new Error(v.error || "no ticket");
2719
+ const I = document.createElement("a");
2720
+ I.href = q("/api/files/_t/" + encodeURIComponent(v.ticket)), I.download = ze(n), document.body.appendChild(I), I.click(), I.remove();
2721
+ }).catch(() => {
2722
+ });
2723
+ } catch {
2724
+ }
2725
+ C && C(), w(!1);
2726
+ }, ee = () => {
2727
+ W(!0), Q(ze(n) || "");
2728
+ }, de = async () => {
2729
+ try {
2730
+ const I = fn(n), A = n.slice(0, n.lastIndexOf("/")) || i;
2731
+ await pn({ text: I, targetDir: A, targetPath: n, currentCwd: a, apiUrl: q, extSvc: ct });
2732
+ } catch {
2733
+ }
2734
+ w(!1);
2735
+ }, [we, he] = f(!1), [b, P] = f(null), R = async () => {
2736
+ const v = U.trim();
2737
+ if (!(!v || !D))
2738
+ try {
2739
+ const I = await fetch(q("/api/extensions/aiti-folder/rename"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: n, newName: v }) }), A = await I.json().catch(() => ({}));
2740
+ if (!I.ok || !A.ok) {
2741
+ alert(A.error || "HTTP " + I.status);
2742
+ return;
2743
+ }
2744
+ W(!1), Q(""), w(!1), C && C();
2745
+ } catch (I) {
2746
+ alert(I && I.message ? I.message : String(I));
2747
+ }
2748
+ };
2749
+ return /* @__PURE__ */ l("div", { "data-fileops": 1, onClick: (v) => v.stopPropagation(), style: { position: "absolute", right: 4, top: 1, display: "flex", alignItems: "center", gap: 3, zIndex: 40, visibility: F || L || !!b ? "visible" : "hidden" }, children: [
2750
+ h ? /* @__PURE__ */ e("button", { onClick: (v) => {
2751
+ v.stopPropagation(), _();
2752
+ }, title: s("files.insertPath"), style: { width: 22, height: 22, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid var(--border)", borderRadius: 4, background: "var(--bg-panel)", color: "var(--accent)", cursor: "pointer", fontSize: 12, fontWeight: 700, lineHeight: 1, flexShrink: 0 }, children: "@" }) : null,
2753
+ S ? /* @__PURE__ */ e("button", { onClick: (v) => {
2754
+ v.stopPropagation(), ae();
2755
+ }, title: s("files.trash"), style: { width: 22, height: 22, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid var(--border)", borderRadius: 4, background: "var(--bg-panel)", color: "var(--danger, #ef4444)", cursor: "pointer", lineHeight: 1, flexShrink: 0 }, children: /* @__PURE__ */ e(Pn, {}) }) : null,
2756
+ /* @__PURE__ */ e("button", { onClick: () => le(), title: s("files.download"), style: { width: 22, height: 22, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid var(--border)", borderRadius: 4, background: "var(--bg-panel)", color: "var(--accent)", cursor: "pointer", fontSize: 12, fontWeight: 700, lineHeight: 1, flexShrink: 0 }, children: /* @__PURE__ */ e(Ut, {}) }),
2757
+ /* @__PURE__ */ e("button", { onClick: O, title: s("files.rename") + " / " + s("files.download") + " / " + s("files.insertPath") + " / " + s("files.trash"), style: { width: 24, height: 22, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid var(--border)", borderRadius: 4, background: L ? "var(--bg-selected)" : "var(--bg-panel)", color: L ? "var(--accent)" : "var(--text-dim)", cursor: "pointer", fontSize: 14, fontWeight: 700, lineHeight: 1, flexShrink: 0, transition: "color 0.12s, background 0.12s" }, children: "⋮" }),
2758
+ L ? /* @__PURE__ */ l("div", { style: { position: "fixed", left: T.left, top: T.top, zIndex: 400, minWidth: 150, padding: 6, background: "var(--bg,#fff)", border: "1px solid var(--border,#d0d0d0)", borderRadius: 10, boxShadow: "0 4px 12px rgba(0,0,0,0.15)", fontSize: 12, display: "flex", flexDirection: "column", gap: 2 }, children: [
2759
+ D ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "2px 2px 4px" }, children: [
2760
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600 }, children: s("files.rename") }),
2761
+ /* @__PURE__ */ e(
2762
+ "input",
2763
+ {
2764
+ autoFocus: !0,
2765
+ value: U,
2766
+ onChange: (v) => Q(v.target.value),
2767
+ onKeyDown: (v) => {
2768
+ v.key === "Enter" && R(), v.key === "Escape" && W(!1);
2769
+ },
2770
+ placeholder: s("files.renamePlaceholder") || "输入新文件名",
2771
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border,#d0d0d0)", borderRadius: 5, outline: "none", background: "var(--bg,#fff)", color: "var(--text,#222)" }
2772
+ }
2773
+ ),
2774
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
2775
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => W(!1), style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: s("files.cancel") }),
2776
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void R(), disabled: !U.trim(), style: { ...Me, background: "var(--accent,#4f8ef7)", color: "#fff", border: "none", opacity: U.trim() ? 1 : 0.5 }, children: s("files.confirm") })
2777
+ ] })
2778
+ ] }, "ri") : [
2779
+ // ── 打开/查看 ──
2780
+ Pe(s("files.menuOpen"), "h-open"),
2781
+ Y(/* @__PURE__ */ e(Pt, {}), s("files.openNewWindow"), () => {
2782
+ w(!1), Tt("file", n);
2783
+ }, "nw"),
2784
+ Y(/* @__PURE__ */ e(Kt, {}), s("files.openTerminal"), () => {
2785
+ w(!1), St(Sn(n), ze(n)).then((v) => {
2786
+ v && alert(v);
2787
+ });
2788
+ }, "ot"),
2789
+ Y(/* @__PURE__ */ e(on, {}), s("files.entryInfo"), () => he(!0), "info"),
2790
+ // 菜单保持开:容器 visibility=hovered||open,关菜单会连带隐藏弹层
2791
+ // ── 路径引用(复制路径邻接 @)──
2792
+ Ie("s-ref"),
2793
+ Pe(s("files.menuRef"), "h-ref"),
2794
+ h ? Y(/* @__PURE__ */ e(zt, {}), s("files.insertPath"), _, "at") : null,
2795
+ Y(/* @__PURE__ */ e(nn, {}), s("files.copyPath"), J, "cp"),
2796
+ Y(/* @__PURE__ */ e(zt, {}), s("files.atNewSession"), de, "atn"),
2797
+ // ── 整理(复制到邻接 移动到)──
2798
+ Ie("s-org"),
2799
+ Pe(s("files.menuOrganize"), "h-org"),
2800
+ Y(/* @__PURE__ */ e(rn, {}), s("files.rename"), ee, "rn"),
2801
+ Y(/* @__PURE__ */ e(an, {}), s("files.move"), () => {
2802
+ P("move");
2803
+ }, "mv"),
2804
+ Y(/* @__PURE__ */ e(ln, {}), s("files.copyTo"), () => {
2805
+ P("copy");
2806
+ }, "cpto"),
2807
+ S ? Y(/* @__PURE__ */ e(Pn, {}), s("files.trash"), ae, "tr") : null,
2808
+ // ── 导出 ──
2809
+ Ie("s-exp"),
2810
+ Pe(s("files.menuExport"), "h-exp"),
2811
+ Y(/* @__PURE__ */ e(Ut, {}), s("files.download"), le, "dl"),
2812
+ // ── Git ──
2813
+ i ? Ie("s-git") : null,
2814
+ i ? Pe(s("files.menuGit"), "h-git") : null,
2815
+ i ? /* @__PURE__ */ l(
2816
+ "button",
2817
+ {
2818
+ type: "button",
2819
+ onClick: (v) => {
2820
+ v.stopPropagation();
2821
+ try {
2822
+ ot() && ot({ scope: { kind: "directory", path: i } }), qe() && qe();
2823
+ } catch {
2824
+ }
2825
+ w(!1);
2826
+ },
2827
+ style: { display: "flex", alignItems: "center", gap: 6, width: "100%", padding: "5px 10px", border: "none", background: "transparent", color: "var(--accent)", cursor: "pointer", textAlign: "left", fontSize: 12, borderRadius: 6, whiteSpace: "nowrap" },
2828
+ children: [
2829
+ /* @__PURE__ */ e(cn, { size: 13 }),
2830
+ "Git Review"
2831
+ ]
2832
+ },
2833
+ "gr"
2834
+ ) : null
2835
+ ],
2836
+ M ? /* @__PURE__ */ e("div", { style: { fontSize: 10, color: M.err ? "var(--danger, #f87171)" : "var(--ok, #4ade80)", padding: "2px 4px" }, children: M.err ? M.err : M.ok || "" }) : null
2837
+ ] }) : null,
2838
+ we ? /* @__PURE__ */ e(Wn, { path: n, onClose: () => {
2839
+ he(!1), w(!1);
2840
+ }, t: s, onOpenFolder: t.onOpenFolder }) : null,
2841
+ b ? /* @__PURE__ */ e(On, { path: n, cwd: a, root: i, mode: b, t: s, onClose: () => {
2842
+ P(null);
2843
+ }, onMoved: (v) => {
2844
+ P(null), w(!1), C && C();
2845
+ } }) : null
2846
+ ] });
2847
+ }
2848
+ function gr(t) {
2849
+ const { st: n, root: a, cwd: i, onOpenFile: c, onAtMention: h, onTrash: S, t: F, onRefresh: s, staged: C, gitOp: L } = t, [w, T] = f(!1), p = Zn(n.filePath, a) || n.filePath, D = (W, U, Q, M, z = "var(--text-dim)") => /* @__PURE__ */ e(
2850
+ "button",
2851
+ {
2852
+ type: "button",
2853
+ title: W,
2854
+ "aria-label": W,
2855
+ onClick: (O) => {
2856
+ O.stopPropagation(), Q();
2857
+ },
2858
+ style: { display: "flex", alignItems: "center", justifyContent: "center", width: 18, height: 18, padding: 0, border: "none", background: "none", color: z, cursor: "pointer", borderRadius: 4, fontSize: 11, lineHeight: 1, flexShrink: 0 },
2859
+ children: U
2860
+ },
2861
+ M
2862
+ );
2863
+ return /* @__PURE__ */ l(
2864
+ "div",
2865
+ {
2866
+ onClick: () => c(n.filePath),
2867
+ title: n.filePath,
2868
+ onMouseEnter: () => T(!0),
2869
+ onMouseLeave: () => T(!1),
2870
+ style: { position: "relative", display: "flex", alignItems: "center", gap: 6, paddingLeft: 10, paddingRight: 8, height: 24, cursor: "pointer", borderRadius: 4, userSelect: "none", background: w ? "var(--bg-hover)" : "transparent" },
2871
+ children: [
2872
+ /* @__PURE__ */ e(eo, { status: n, t: F }),
2873
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, children: p }),
2874
+ L ? /* @__PURE__ */ l("span", { "data-fileops": !0, style: { display: "flex", alignItems: "center", gap: 2, opacity: w ? 1 : 0, transition: "opacity 0.12s", flexShrink: 0 }, children: [
2875
+ D(C ? $("git.unstageTitle") : $("git.stageTitle"), C ? "−" : "+", () => L(C ? "unstage" : "stage", p), "st"),
2876
+ D($("git.diffTitle"), "diff", () => {
2877
+ try {
2878
+ const W = ot();
2879
+ W && W({ scope: { kind: "file", path: n.filePath } }), qe() && qe();
2880
+ } catch {
2881
+ }
2882
+ }, "df"),
2883
+ D($("git.discardTitle"), "✕", () => {
2884
+ window.confirm($("git.discardConfirm", { path: p })) && L("discard", p);
2885
+ }, "ds", "#d6a84b")
2886
+ ] }) : null,
2887
+ /* @__PURE__ */ e(no, { filePath: n.filePath, cwd: i, root: a, onOpenFile: c, onOpenFolder: t.onOpenFolder, onAtMention: h, onTrash: S, hovered: w, t: F, onRefresh: s })
2888
+ ]
2889
+ }
2890
+ );
2891
+ }
2892
+ function Rn(t) {
2893
+ const n = t.node, a = t.depth, i = t.cwd, c = t.expanded, h = t.onToggle, S = t.onOpenFile, F = t.onOpenFolder, s = t.onAtMention, C = t.onTrash, L = t.onChanged, w = t.gitByPath, T = t.changedDirs, p = t.highlightPath, D = t.t, W = t.root, U = t.showIgnored === !0, Q = Oe(U);
2894
+ Q.current = U;
2895
+ const M = t.refreshKey ?? 0, [z, O] = f(n.children || []), [_, J] = f(n.loaded || !1), [ae, le] = f(!1), [ee, de] = f(!1), [we, he] = f(0), b = t.refreshSeq ?? 0, P = c.has(n.fullPath), R = E(async (te) => {
2896
+ if (!(_ && !te)) {
2897
+ le(!0);
2898
+ try {
2899
+ const ke = await Ro(q, n.fullPath, { force: te, showIgnored: Q.current });
2900
+ O(ke), J(!0);
2901
+ } catch {
2902
+ } finally {
2903
+ le(!1);
2904
+ }
2905
+ }
2906
+ }, [_, n.fullPath]);
2907
+ se(() => {
2908
+ P && !_ && R();
2909
+ }, [P, _, R]);
2910
+ const j = Oe(M);
2911
+ se(() => {
2912
+ j.current !== M && (j.current = M, _ && R(!0));
2913
+ }, [M, _, R]);
2914
+ const v = Oe(b), I = Oe(0);
2915
+ se(() => {
2916
+ v.current !== b && (v.current = b, _ && (R(!0), I.current += 1, he(I.current)));
2917
+ }, [b, _, R]);
2918
+ const A = E((te) => {
2919
+ te && (te === n.fullPath || te.startsWith(n.fullPath + "/")) && R(!0), L?.(te);
2920
+ }, [n.fullPath, R, L]), fe = E(() => {
2921
+ _ ? (R(!0), I.current += 1, he(I.current)) : R(!0);
2922
+ }, [_, R]), G = E(() => {
2923
+ if (n.isDir) {
2924
+ const te = !P;
2925
+ h(n.fullPath, te), te && !_ && R();
2926
+ } else
2927
+ S(n.fullPath);
2928
+ }, [n, P, _, R, S, h]), m = E((te) => {
2929
+ if (n.isDir || te.target.closest("[data-fileops]")) return;
2930
+ const ke = te.currentTarget.getBoundingClientRect();
2931
+ if ((te.clientX - ke.left) / ke.width >= 0.6) {
2932
+ de(!0);
2933
+ return;
2934
+ }
2935
+ G();
2936
+ }, [n.isDir, G]), K = Fn(n.fullPath), V = w.get(K), oe = n.isDir && (V !== void 0 || T.has(K));
2937
+ return /* @__PURE__ */ l("div", { children: [
2938
+ /* @__PURE__ */ l(
2939
+ "div",
2940
+ {
2941
+ "data-file-node": n.fullPath,
2942
+ onClick: n.isDir ? G : m,
2943
+ onMouseEnter: () => de(!0),
2944
+ onMouseLeave: () => de(!1),
2945
+ style: { position: "relative", display: "flex", alignItems: "center", gap: 4, paddingLeft: 8 + a * 14, paddingRight: 8, height: 24, cursor: "pointer", background: n.fullPath === p ? "rgba(79,142,247,0.18)" : ee ? "var(--bg-hover)" : "transparent", borderRadius: 4, userSelect: "none" },
2946
+ children: [
2947
+ n.isDir ? /* @__PURE__ */ e("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "var(--text-dim)", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0, transform: P ? "rotate(90deg)" : "none", transition: "transform 0.1s" }, children: /* @__PURE__ */ e("polyline", { points: "3 2 7 5 3 8" }) }) : /* @__PURE__ */ e("span", { style: { width: 10, flexShrink: 0 } }),
2948
+ /* @__PURE__ */ e("span", { style: { flexShrink: 0, display: "flex", alignItems: "center" }, children: n.isDir ? /* @__PURE__ */ e(en, { open: P }) : /* @__PURE__ */ e(fr, { name: n.name }) }),
2949
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, color: n.ignored ? "var(--text-dim, #777)" : "var(--text)", fontStyle: n.ignored ? "italic" : "normal", opacity: n.ignored ? 0.75 : 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, title: n.ignored ? `${n.fullPath}(${n.name === ".git" ? "git 仓库内部,默认隐藏" : "已被 .gitignore/.aitignore 忽略"})` : n.fullPath, children: n.name }),
2950
+ ae ? /* @__PURE__ */ e("svg", { width: 10, height: 10, viewBox: "0 0 24 24", fill: "none", stroke: "var(--text-dim)", strokeWidth: 2, strokeLinecap: "round", style: { animation: "spin 0.8s linear infinite" }, children: /* @__PURE__ */ e("path", { d: "M21 12a9 9 0 1 1-5.7-8.4" }) }) : null,
2951
+ !ee && !n.isDir && V ? /* @__PURE__ */ e(eo, { status: V, t: D }) : null,
2952
+ !ee && oe ? /* @__PURE__ */ e("span", { title: D("files.containsChangedFiles"), "aria-label": D("files.containsChangedFiles"), style: { width: 14, height: 14, flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e("span", { style: { width: 6, height: 6, borderRadius: "50%", background: "#d6a84b" } }) }) : null,
2953
+ n.isDir ? /* @__PURE__ */ e(ur, { dir: n.fullPath, hovered: ee, onChanged: A, onRefresh: fe, onOpenFile: S, onOpenFolder: F, onAtMention: s, onTrash: C, t: D, root: W, cwd: i }) : null,
2954
+ n.isDir && ee && s ? /* @__PURE__ */ e(
2955
+ "button",
2956
+ {
2957
+ onClick: (te) => {
2958
+ te.stopPropagation(), s(Ct(n.fullPath, i), !1);
2959
+ },
2960
+ title: D("files.insertPath"),
2961
+ style: { position: "absolute", right: 80, top: "50%", transform: "translateY(-50%)", display: "flex", alignItems: "center", justifyContent: "center", height: 20, width: 22, padding: 0, background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 4, color: "var(--accent)", cursor: "pointer", fontSize: 11, fontWeight: 700 },
2962
+ children: "@"
2963
+ }
2964
+ ) : null,
2965
+ n.isDir && ee ? /* @__PURE__ */ e(
2966
+ "button",
2967
+ {
2968
+ onClick: (te) => {
2969
+ te.stopPropagation(), Tt("folder", n.fullPath);
2970
+ },
2971
+ title: D("files.openNewWindow"),
2972
+ style: { position: "absolute", right: 104, top: "50%", transform: "translateY(-50%)", display: "flex", alignItems: "center", justifyContent: "center", height: 20, width: 22, padding: 0, background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 4, color: "var(--accent)", cursor: "pointer", fontSize: 11 },
2973
+ children: /* @__PURE__ */ e(Pt, {})
2974
+ }
2975
+ ) : null,
2976
+ n.isDir && ee ? /* @__PURE__ */ e(
2977
+ "button",
2978
+ {
2979
+ onClick: (te) => {
2980
+ te.stopPropagation(), F(n.fullPath, n.name);
2981
+ },
2982
+ title: D("files.openInPanel"),
2983
+ style: { position: "absolute", right: 32, top: "50%", transform: "translateY(-50%)", display: "flex", alignItems: "center", justifyContent: "center", height: 20, padding: "0 8px", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 4, color: "var(--accent)", cursor: "pointer", fontSize: 11, fontWeight: 600, whiteSpace: "nowrap" },
2984
+ children: D("files.open")
2985
+ }
2986
+ ) : null,
2987
+ !n.isDir && (s || C) ? /* @__PURE__ */ e(no, { filePath: n.fullPath, cwd: i, root: W, onOpenFile: S, onOpenFolder: F, onAtMention: s, onTrash: C, hovered: ee, t: D, onRefresh: A }) : null
2988
+ ]
2989
+ },
2990
+ "row-inner"
2991
+ ),
2992
+ n.isDir && P ? /* @__PURE__ */ l("div", { children: [
2993
+ z.map((te) => /* @__PURE__ */ e(Rn, { node: te, depth: a + 1, cwd: i, expanded: c, refreshSeq: we, onToggle: h, onOpenFile: S, onOpenFolder: F, onAtMention: s, onTrash: C, onChanged: L, gitByPath: w, changedDirs: T, highlightPath: p, t: D, root: W, showIgnored: U }, te.fullPath)),
2994
+ z.length === 0 && _ ? /* @__PURE__ */ e("div", { style: { paddingLeft: 8 + (a + 1) * 14, fontSize: 11, color: "var(--text-dim)", height: 22, display: "flex", alignItems: "center" }, children: D("files.noFiles") }, "empty") : null
2995
+ ] }, "tree") : null
2996
+ ] }, "row");
2997
+ }
2998
+ function yr(t) {
2999
+ const n = t.dense === !0, a = t.showIgnored === !0, i = typeof t.dockItemKey == "string" && t.dockItemKey ? t.dockItemKey : void 0, c = !!i, h = t.filePath, S = t.cwd, F = t.onOpenFile || (() => {
3000
+ }), s = t.onOpenFolder || (() => {
3001
+ }), C = t.onAtMention, L = $t(h), w = fo(h, a), T = Nn(h, a), [p, D] = f(h), [W, U] = f(w ?? []), [Q, M] = f(T?.parentPath ?? null), [z, O] = f(!L), [_, J] = f(null), [ae, le] = f(() => L ?? /* @__PURE__ */ new Set()), [ee, de] = f([]), [we, he] = f({ additions: 0, deletions: 0 }), [b, P] = f(0), [R, j] = f(!1), [v, I] = f(!1), [A, fe] = f(!1), [G, m] = f(null), [K, V] = f(!1), [oe, te] = f(null), [ke, B] = f(null), [H, re] = f(""), [ce, Re] = f(!1), [ye, ge] = f(null), [xe, dt] = f(!1), [Jt, Rt] = f(null), Ft = Oe(null), ft = Oe(null), He = Oe(null), Dt = Oe(null), [Wt, pt] = f(null);
3002
+ se(() => {
3003
+ if (!K) return;
3004
+ const r = Dt.current;
3005
+ if (!r) return;
3006
+ const d = oe ?? (He.current ? He.current.getBoundingClientRect() : null);
3007
+ if (!d) return;
3008
+ const x = r.getBoundingClientRect(), k = 4, N = 8;
3009
+ let ne = d.bottom + k;
3010
+ const be = window.innerHeight - N - ne, We = d.top - k - N;
3011
+ x.height > be && We > be && (ne = d.top - k - x.height);
3012
+ const ue = qn(d.left, ne, x.width, x.height, N), Je = Yn(r), gt = { left: ue.left - Je.x, top: ue.top - Je.y };
3013
+ pt((Zt) => Zt && Zt.left === gt.left && Zt.top === gt.top ? Zt : gt);
3014
+ }, [K, ke, oe]), se(() => {
3015
+ if (!K) return;
3016
+ const r = () => V(!1);
3017
+ return window.addEventListener("scroll", r, !0), () => window.removeEventListener("scroll", r, !0);
3018
+ }, [K]);
3019
+ const [X, ve] = f(!1), [Ot, me] = f(null), [ht, Ee] = f(!1), [Ae, $e] = f(""), [Ke, qt] = f(!1), [mt, It] = f(!1), [Z, pe] = f(null), ut = Oe(null), [, rt] = f(0), yt = dr(h), xt = po(h), Yt = ho(xt) !== "closed", Bt = () => vn(h), hn = () => {
3020
+ Lo(h), rt((r) => r + 1), m({ ok: vn(h) ? g("files.pinDone") : g("files.unpinDone") });
3021
+ }, un = () => {
3022
+ Yt ? So(xt) : Ln([yt]);
3023
+ }, Vt = (r) => {
3024
+ const d = ko().filter((N) => N.kind === "folder"), x = d.findIndex((N) => N.id === yt), k = d.filter((N, ne) => {
3025
+ if (N.id === yt) return !1;
3026
+ const be = N.id.startsWith("folder:") ? N.id.slice(7) : "";
3027
+ return N.pinned || be && vn(be) ? !1 : r === "all" ? !0 : r === "left" ? ne < x : r === "right" ? ne > x : !1;
3028
+ });
3029
+ k.length !== 0 && (Ln(k.map((N) => N.id)), m({ ok: g("files.batchClosed", { count: k.length }) }));
3030
+ }, [Fe, Xt] = f(!1), [Ne, Mt] = f(""), [Se, Ye] = f([]), [At, it] = f(/* @__PURE__ */ new Set()), [at, je] = f(!1), [vt, Ue] = f(!1), [gn, lt] = f(/* @__PURE__ */ new Set()), Ve = Oe(null), Xe = Ne.trim().length > 0, [Ce, Ht] = f("files"), [Nt, Qe] = f([]), [mn, bt] = f(null), [o, u] = f(!1), y = Oe({ root: p, expanded: ae });
3031
+ y.current = { root: p, expanded: ae }, se(() => () => Gt(y.current.root, y.current.expanded), []), se(() => {
3032
+ D(h);
3033
+ }, [h]), se(() => {
3034
+ lt(/* @__PURE__ */ new Set()), it(/* @__PURE__ */ new Set()), Qe([]);
3035
+ }, [h]), se(() => {
3036
+ if (!Fe || Ce !== "files") return;
3037
+ const r = Ne.trim();
3038
+ if (!r) {
3039
+ Ye([]), it(/* @__PURE__ */ new Set()), je(!1), Ue(!1);
3040
+ return;
3041
+ }
3042
+ const d = new AbortController();
3043
+ je(!0), Ue(!1);
3044
+ const x = setTimeout(() => {
3045
+ fetch(q("/api/file-index"), {
3046
+ method: "POST",
3047
+ headers: { "content-type": "application/json" },
3048
+ body: JSON.stringify({ cwd: p, q: r }),
3049
+ signal: d.signal
3050
+ }).then((k) => k.ok ? k.json() : Promise.reject(new Error("HTTP " + k.status))).then((k) => {
3051
+ const N = k.matches || [];
3052
+ Ye(N.map((ne) => ne.path)), it(new Set(N.filter((ne) => ne.isDir).map((ne) => ne.path)));
3053
+ }).catch(() => {
3054
+ d.signal.aborted || (Ye([]), Ue(!0));
3055
+ }).finally(() => {
3056
+ d.signal.aborted || je(!1);
3057
+ });
3058
+ }, 150);
3059
+ return () => {
3060
+ clearTimeout(x), d.abort();
3061
+ };
3062
+ }, [p, Fe, Ce, Ne]), se(() => {
3063
+ if (!Fe || Ce !== "fulltext") return;
3064
+ const r = Ne.trim();
3065
+ if (!r) {
3066
+ Qe([]), je(!1), Ue(!1);
3067
+ return;
3068
+ }
3069
+ const d = new AbortController();
3070
+ je(!0), Ue(!1);
3071
+ const x = setTimeout(() => {
3072
+ fetch(q("/api/extensions/aiti-folder/doc-search"), {
3073
+ method: "POST",
3074
+ headers: { "content-type": "application/json" },
3075
+ body: JSON.stringify({ q: r, limit: 200 }),
3076
+ signal: d.signal
3077
+ }).then((k) => k.ok ? k.json() : Promise.reject(new Error("HTTP " + k.status))).then((k) => {
3078
+ if (k.available !== !0) {
3079
+ bt(!1), Ht("files"), Qe([]), m({ err: g("sidebar.docCenterUnavailable") });
3080
+ return;
3081
+ }
3082
+ bt(!0), Qe(Array.isArray(k.items) ? k.items : []);
3083
+ }).catch(() => {
3084
+ d.signal.aborted || (Qe([]), Ue(!0));
3085
+ }).finally(() => {
3086
+ d.signal.aborted || je(!1);
3087
+ });
3088
+ }, 150);
3089
+ return () => {
3090
+ clearTimeout(x), d.abort();
3091
+ };
3092
+ }, [p, Fe, Ce, Ne]), se(() => {
3093
+ Fe && Ve.current?.focus();
3094
+ }, [Fe]), se(() => {
3095
+ if (Se.length === 0) return;
3096
+ const r = /* @__PURE__ */ new Set();
3097
+ for (const d of Se) {
3098
+ const x = d.split("/");
3099
+ let k = "";
3100
+ for (let N = 0; N < x.length - 1; N++)
3101
+ k = k ? k + "/" + x[N] : x[N], r.add(jn(p, k));
3102
+ }
3103
+ lt((d) => {
3104
+ let x = !1;
3105
+ const k = new Set(d);
3106
+ for (const N of r) k.has(N) || (k.add(N), x = !0);
3107
+ return x ? k : d;
3108
+ });
3109
+ }, [p, Se]);
3110
+ const ie = Le(() => {
3111
+ const r = (d) => {
3112
+ const x = At.has(d.path);
3113
+ return { name: d.name, fullPath: jn(p, d.path), isDir: d.isDir || x, size: 0, children: x ? [] : d.children.map(r), loaded: !x };
3114
+ };
3115
+ return zo(Se).map(r);
3116
+ }, [p, Se, At]), De = E(() => {
3117
+ Fe ? (Xt(!1), Mt(""), Ye([]), it(/* @__PURE__ */ new Set()), Qe([]), Ue(!1), je(!1), lt(/* @__PURE__ */ new Set()), Ht("files")) : Xt(!0);
3118
+ }, [Fe]), Te = E((r) => {
3119
+ r !== Ce && (Ht(r), Ye([]), it(/* @__PURE__ */ new Set()), Qe([]), Ue(!1), je(!1));
3120
+ }, [Ce]), Be = Le(() => {
3121
+ if (o) return Nt;
3122
+ const r = (p || "").replace(/\/+$/, "") + "/";
3123
+ return Nt.filter((d) => typeof d.path == "string" && d.path.startsWith(r));
3124
+ }, [Nt, o, p]), jt = E((r, d) => {
3125
+ if (!(d === r || d.startsWith(r + "/"))) return;
3126
+ const x = [d];
3127
+ let k = d === r ? null : Sn(d);
3128
+ for (let be = 0; be < 64 && k; be++) {
3129
+ if (k === r) {
3130
+ x.push(k);
3131
+ break;
3132
+ }
3133
+ if (!k.startsWith(r + "/")) break;
3134
+ x.push(k);
3135
+ const We = Sn(k);
3136
+ if (!We || We === k) break;
3137
+ k = We;
3138
+ }
3139
+ le((be) => /* @__PURE__ */ new Set([...be, ...x])), Rt(d);
3140
+ const N = Date.now(), ne = () => {
3141
+ const be = [...document.querySelectorAll("[data-file-node]")].find((We) => We.getAttribute("data-file-node") === d);
3142
+ if (be) {
3143
+ be.scrollIntoView({ block: "center", behavior: "smooth" });
3144
+ return;
3145
+ }
3146
+ Date.now() - N < 3e3 && setTimeout(ne, 120);
3147
+ };
3148
+ setTimeout(ne, 60);
3149
+ }, []);
3150
+ se(() => {
3151
+ const r = (x) => {
3152
+ const k = x.detail;
3153
+ k && k.root && k.target && jt(k.root, k.target);
3154
+ };
3155
+ window.addEventListener("pi-web:folder-reveal", r);
3156
+ const d = window.__piFolderRevealLast;
3157
+ return d && Date.now() - d.ts < 1e4 && d.root === p && jt(d.root, d.target), () => window.removeEventListener("pi-web:folder-reveal", r);
3158
+ }, [p, jt]), se(() => {
3159
+ if (!K) return;
3160
+ const r = (d) => {
3161
+ He.current && !He.current.contains(d.target) && V(!1);
3162
+ };
3163
+ return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
3164
+ }, [K]), se(() => {
3165
+ if (!X) return;
3166
+ const r = (x) => {
3167
+ ut.current && !ut.current.contains(x.target) && ve(!1);
3168
+ }, d = () => ve(!1);
3169
+ return document.addEventListener("mousedown", r), document.addEventListener("wheel", d, { passive: !0 }), () => {
3170
+ document.removeEventListener("mousedown", r), document.removeEventListener("wheel", d);
3171
+ };
3172
+ }, [X]);
3173
+ const yn = E((r) => {
3174
+ if (X) {
3175
+ ve(!1);
3176
+ return;
3177
+ }
3178
+ const d = r.currentTarget.getBoundingClientRect(), x = 640, k = 210, N = Math.max(8, Math.min(d.right - k, window.innerWidth - k - 8)), ne = d.bottom + 4 + x > window.innerHeight, be = d.top - x - 4 < 0;
3179
+ let We;
3180
+ ne && !be ? We = Math.max(8, d.top - x - 4) : ne && be ? We = 8 : We = d.bottom + 4, me({ left: N, top: We }), ve(!0);
3181
+ }, [X]), Qt = E(() => {
3182
+ Dn(p).then(
3183
+ () => {
3184
+ m({ ok: g("files.copyDone") }), ve(!1);
3185
+ },
3186
+ () => {
3187
+ m({ err: g("files.copyFailed") }), ve(!1);
3188
+ }
3189
+ );
3190
+ }, [p]), st = E(async () => {
3191
+ const r = Ae.trim();
3192
+ if (!(!r || !ht || Ke)) {
3193
+ qt(!0);
3194
+ try {
3195
+ const d = await fetch(q("/api/extensions/aiti-folder/rename"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: p, newName: r }) }), x = await d.json().catch(() => ({}));
3196
+ if (!d.ok || !x.ok) {
3197
+ m({ err: x.error || g("files.renameFailed") });
3198
+ return;
3199
+ }
3200
+ const k = p.slice(0, p.lastIndexOf("/")) || "/";
3201
+ ve(!1), Ee(!1), $e(""), m({ ok: g("files.renameSuccess") }), s(k + "/" + r, r);
3202
+ } catch (d) {
3203
+ m({ err: d && d.message ? d.message : String(d) });
3204
+ } finally {
3205
+ qt(!1);
3206
+ }
3207
+ }
3208
+ }, [p, ht, Ae, Ke, s]), In = E(async () => {
3209
+ try {
3210
+ const r = p + "/", d = fn(r);
3211
+ await pn({ text: d, targetDir: p, targetPath: p, currentCwd: S, apiUrl: q, extSvc: ct });
3212
+ } catch {
3213
+ }
3214
+ ve(!1);
3215
+ }, [p, S]), xn = E(() => {
3216
+ const r = p.slice(0, p.lastIndexOf("/")) || "/";
3217
+ if (ve(!1), r !== p) {
3218
+ s && s(r, ze(r) || void 0);
3219
+ try {
3220
+ const d = { root: r, target: p };
3221
+ window.dispatchEvent(new CustomEvent("pi-web:folder-reveal", { detail: d })), window.__piFolderRevealLast = { ...d, ts: Date.now() };
3222
+ } catch {
3223
+ }
3224
+ }
3225
+ }, [p, s]), En = E(async () => {
3226
+ ve(!1);
3227
+ try {
3228
+ const r = await fetch(q("/api/extensions/aiti-folder/archive-ticket"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ path: p }) }), d = await r.json().catch(() => ({}));
3229
+ if (!r.ok || !d.ok || !d.ticket) {
3230
+ m({ err: d.error || "HTTP " + r.status });
3231
+ return;
3232
+ }
3233
+ const x = document.createElement("a");
3234
+ x.href = q("/api/extensions/aiti-folder/archive?ticket=" + encodeURIComponent(d.ticket)), x.download = ze(p) + ".tar.gz", x.click();
3235
+ } catch {
3236
+ }
3237
+ }, [p]);
3238
+ se(() => {
3239
+ let r = !1;
3240
+ const d = b === 0 ? Nn(p, a) : null;
3241
+ if (d) {
3242
+ U(d.entries), M(d.parentPath ?? null), J(null), O(!1);
3243
+ return;
3244
+ }
3245
+ return O(!0), J(null), uo(q, p, { force: !0, showIgnored: a }).then((x) => {
3246
+ r || (U(x.entries), M(x.parentPath ?? null));
3247
+ }).catch((x) => {
3248
+ r || J(x && x.message ? x.message : String(x));
3249
+ }).finally(() => {
3250
+ r || O(!1);
3251
+ }), () => {
3252
+ r = !0;
3253
+ };
3254
+ }, [p, b, a]);
3255
+ const Bn = Oe(a);
3256
+ se(() => {
3257
+ Bn.current !== a && (Bn.current = a, P((r) => r + 1));
3258
+ }, [a]);
3259
+ const _e = ir(p);
3260
+ se(() => {
3261
+ let r = !1;
3262
+ return fetch(q("/api/git/status"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ cwd: p }) }).then((d) => d.json()).then((d) => {
3263
+ r || (de(d.isGitRepository ? d.files : []), he(d.isGitRepository ? { additions: d.additions || 0, deletions: d.deletions || 0 } : { additions: 0, deletions: 0 }));
3264
+ }).catch(() => {
3265
+ r || (de([]), he({ additions: 0, deletions: 0 }));
3266
+ }), () => {
3267
+ r = !0;
3268
+ };
3269
+ }, [p, b, t.gitRefreshKey, _e.statusBump]);
3270
+ const Mn = Le(() => Do(ee), [ee]), An = Le(() => Fo(ee, p), [ee, p]), oo = E((r, d) => {
3271
+ le((x) => {
3272
+ const k = new Set(x);
3273
+ return d ? k.add(r) : k.delete(r), k;
3274
+ });
3275
+ }, []), Ze = E(() => {
3276
+ P((r) => r + 1), j(!0), setTimeout(() => j(!1), 1800);
3277
+ }, []), ro = E(async (r) => {
3278
+ const d = Array.from(r.target.files || []);
3279
+ if (r.target.value = "", !(d.length === 0 || A)) {
3280
+ fe(!0), m(null);
3281
+ try {
3282
+ const x = new FormData();
3283
+ x.append("directory", p), d.forEach((ne) => x.append("files", ne, ne.name));
3284
+ const k = await fetch(q("/api/files/upload?conflict=skip"), { method: "POST", body: x }), N = await k.json().catch(() => ({}));
3285
+ !k.ok && !N.conflicts ? m({ err: N.error || "HTTP " + k.status }) : (m({ up: (N.uploaded || []).length, skip: (N.skipped || []).length, err: (N.errors || []).length }), P((ne) => ne + 1));
3286
+ } catch (x) {
3287
+ m({ err: x && x.message ? x.message : String(x) });
3288
+ } finally {
3289
+ fe(!1);
3290
+ }
3291
+ }
3292
+ }, [p, A]), io = E(async (r) => {
3293
+ const d = Array.from(r.target.files || []);
3294
+ if (r.target.value = "", !(d.length === 0 || A)) {
3295
+ fe(!0), m(null);
3296
+ try {
3297
+ const x = new FormData();
3298
+ x.append("dir", p);
3299
+ for (const ne of d) {
3300
+ const be = (ne.webkitRelativePath || ne.name || "").replace(/\\/g, "/");
3301
+ x.append("files", ne, be || ne.name);
3302
+ }
3303
+ const k = await fetch(q("/api/extensions/aiti-folder/upload-tree"), { method: "POST", body: x }), N = await k.json().catch(() => ({}));
3304
+ !k.ok || !N.ok ? m({ err: N.error || "HTTP " + k.status }) : (m({ up: (N.uploaded || []).length, skip: (N.skipped || []).length, err: (N.errors || []).length }), P((ne) => ne + 1));
3305
+ } catch (x) {
3306
+ m({ err: x && x.message ? x.message : String(x) });
3307
+ } finally {
3308
+ fe(!1);
3309
+ }
3310
+ }
3311
+ }, [p, A]), ao = E(async () => {
3312
+ if (!(!ye || xe)) {
3313
+ dt(!0);
3314
+ try {
3315
+ const r = await fetch(q("/api/extensions/aiti-folder/trash"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ paths: [ye.path] }) }), d = await r.json().catch(() => ({}));
3316
+ !r.ok || !d.ok ? m({ err: d.error || "HTTP " + r.status }) : d.errors && d.errors.length ? m({ err: d.errors[0].error || g("files.trashFailed") }) : (m({ ok: g("files.trashDone") + " ✓" }), P((x) => x + 1), ye.isDir && le((x) => {
3317
+ const k = new Set(x);
3318
+ return k.delete(ye.path), k;
3319
+ })), ge(null);
3320
+ } catch (r) {
3321
+ m({ err: r && r.message ? r.message : String(r) }), ge(null);
3322
+ } finally {
3323
+ dt(!1);
3324
+ }
3325
+ }
3326
+ }, [ye, xe]), Hn = E(async () => {
3327
+ const r = H.trim();
3328
+ if (!r || !ke || ce) return;
3329
+ const d = ke === "file" ? "/api/extensions/aiti-folder/create-file" : "/api/extensions/aiti-folder/create-folder";
3330
+ Re(!0);
3331
+ try {
3332
+ const x = await fetch(q(d), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: p, name: r }) }), k = await x.json().catch(() => ({}));
3333
+ !x.ok || !k.ok ? m({ err: k.error || "HTTP " + x.status }) : (m({ ok: (ke === "file" ? g("files.newFile") : g("files.newFolder")) + " ✓" }), B(null), re(""), V(!1), P((N) => N + 1), ke === "file" && k.path && F(k.path));
3334
+ } catch (x) {
3335
+ m({ err: x && x.message ? x.message : String(x) });
3336
+ } finally {
3337
+ Re(!1);
3338
+ }
3339
+ }, [ke, H, p, F, ce]), lo = () => {
3340
+ const r = [], d = (x, k, N, ne) => r.push({ kind: "item", id: x, label: k, icon: ne, run: N });
3341
+ return r.push({ kind: "head", label: g("files.menuNav") }), d("op", g("files.openParentDir"), () => xn(), /* @__PURE__ */ e(Cn, {})), r.push({ kind: "sep" }), r.push({ kind: "head", label: g("files.menuExport") }), d("dl", g("files.download"), () => {
3342
+ En();
3343
+ }, /* @__PURE__ */ e(Ut, {})), r.push({ kind: "sep" }), r.push({ kind: "head", label: g("files.menuRef") }), d("cp", g("files.copyPath"), () => {
3344
+ Qt();
3345
+ }, /* @__PURE__ */ e(nn, {})), d("atn", g("files.atNewSession"), () => {
3346
+ In();
3347
+ }, /* @__PURE__ */ e(zt, {})), r.push({ kind: "sep" }), r.push({ kind: "head", label: g("files.menuOpen") }), d("rf", g("files.refresh"), () => Ze(), /* @__PURE__ */ e(Tn, {})), d("nw", g("files.openNewWindow"), () => Tt("folder", p), /* @__PURE__ */ e(Pt, {})), d("ot", g("files.openTerminal"), () => {
3348
+ St(p).then((x) => {
3349
+ x && m({ err: x });
3350
+ });
3351
+ }, /* @__PURE__ */ e(Kt, {})), d("info", g("files.entryInfo"), () => It(!0), /* @__PURE__ */ e(on, {})), r.push({ kind: "sep" }), r.push({ kind: "head", label: g("files.menuOrganize") }), d("rn", g("files.rename"), () => {
3352
+ Ee(!0), $e(ze(p) || "");
3353
+ }, /* @__PURE__ */ e(rn, {})), d("mv", g("files.move"), () => {
3354
+ pe("move");
3355
+ }, /* @__PURE__ */ e(an, {})), d("cpto", g("files.copyTo"), () => {
3356
+ pe("copy");
3357
+ }, /* @__PURE__ */ e(ln, {})), r.push({ kind: "sep" }), r.push({ kind: "head", label: g("files.menuGit") }), d("gr", "Git Review", () => {
3358
+ try {
3359
+ ot() && ot({ scope: { kind: "directory", path: p } }), qe() && qe();
3360
+ } catch {
3361
+ }
3362
+ }, /* @__PURE__ */ e(cn, { size: 13 })), r;
3363
+ };
3364
+ return go(i, i ? {
3365
+ search: () => {
3366
+ try {
3367
+ Ho(i, !1);
3368
+ } catch {
3369
+ }
3370
+ De();
3371
+ },
3372
+ terminal: () => {
3373
+ St(p).then((r) => {
3374
+ r && m({ err: r });
3375
+ });
3376
+ },
3377
+ refresh: () => Ze(),
3378
+ changes: () => I((r) => !r),
3379
+ at: () => {
3380
+ try {
3381
+ C && C(Ct(p, S || p), !1);
3382
+ } catch {
3383
+ }
3384
+ },
3385
+ plus: (r) => {
3386
+ const d = r && typeof r == "object" ? r.anchor : null;
3387
+ te(d && typeof d.left == "number" ? d : null), pt(null), V(!0);
3388
+ },
3389
+ setRoot: (r) => {
3390
+ const d = typeof r == "string" ? r : "";
3391
+ !d || d === p || (Gt(p, ae), M(null), D(d), le($t(d) ?? /* @__PURE__ */ new Set()));
3392
+ },
3393
+ parent: () => xn()
3394
+ } : null), mo(i, i ? {
3395
+ searchOpen: Fe,
3396
+ refreshDone: R,
3397
+ root: p,
3398
+ gitCount: ee.length,
3399
+ changesOpen: v,
3400
+ hasParent: Q != null
3401
+ } : null), yo(i, i ? lo() : null), /* @__PURE__ */ l("div", { style: { height: "100%", display: "flex", flexDirection: "column", background: "var(--bg)" }, children: [
3402
+ !c && /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 4, padding: "4px 8px", borderBottom: "1px solid var(--border)", background: "var(--bg-panel)", flexShrink: 0, ...n ? { overflowX: "auto", flexWrap: "nowrap", minHeight: 33 } : {} }, children: [
3403
+ Q ? /* @__PURE__ */ e(
3404
+ "button",
3405
+ {
3406
+ type: "button",
3407
+ onClick: () => {
3408
+ Gt(p, ae), M(null), D(Q), le($t(Q) ?? /* @__PURE__ */ new Set());
3409
+ },
3410
+ title: g("files.parentDir"),
3411
+ "aria-label": g("files.parentDir"),
3412
+ 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 },
3413
+ children: "↑"
3414
+ }
3415
+ ) : null,
3416
+ /* @__PURE__ */ e(xo, { path: p, onSelect: (r) => {
3417
+ Gt(p, ae), M(null), D(r), le($t(r) ?? /* @__PURE__ */ new Set());
3418
+ } }),
3419
+ /* @__PURE__ */ e("div", { ref: He, style: { position: "relative", flexShrink: 0 }, children: nt({ key: "plus", onClick: () => {
3420
+ K ? V(!1) : (pt(null), V(!0));
3421
+ }, title: g("files.newFile") + " / " + g("files.newFolder") + " / " + g("files.uploadFile") + " / " + g("files.uploadFolder"), color: K ? "var(--accent)" : "var(--text-dim)", bg: K ? "var(--bg-selected)" : "transparent", children: /* @__PURE__ */ e(No, {}) }) }),
3422
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
3423
+ vo.filter((r) => {
3424
+ try {
3425
+ return r.match && r.match(p, { gitFiles: ee });
3426
+ } catch {
3427
+ return !1;
3428
+ }
3429
+ }).map((r) => nt({ key: String(r.id || r.title || (typeof r.label == "string" ? r.label : "act")), onClick: () => {
3430
+ try {
3431
+ r.onClick(p);
3432
+ } catch {
3433
+ }
3434
+ }, title: String(r.title || (typeof r.label == "string" ? r.label : "")), children: r.icon ? r.icon : /* @__PURE__ */ e("span", { style: { fontSize: 13, lineHeight: 1 }, children: r.label }) })),
3435
+ /* @__PURE__ */ e("input", { ref: Ft, type: "file", multiple: !0, hidden: !0, onChange: (r) => void ro(r) }),
3436
+ /* @__PURE__ */ e("input", { ref: ft, type: "file", multiple: !0, hidden: !0, webkitdirectory: "", onChange: (r) => void io(r) }),
3437
+ nt({ key: "srch", onClick: De, title: g("sidebar.searchFiles"), pressed: Fe, color: Fe ? "var(--accent)" : "var(--text-dim)", bg: Fe ? "var(--bg-selected)" : "transparent", children: /* @__PURE__ */ e(jo, {}) }),
3438
+ ee.length > 0 ? nt({
3439
+ key: "ch",
3440
+ onClick: () => I((r) => !r),
3441
+ title: g("sidebar.changedFiles", { count: ee.length }),
3442
+ pressed: v,
3443
+ color: v ? "var(--accent)" : "var(--text-dim)",
3444
+ bg: v ? "var(--bg-selected)" : "transparent",
3445
+ children: /* @__PURE__ */ l("span", { style: { position: "relative", display: "inline-flex" }, children: [
3446
+ /* @__PURE__ */ l("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
3447
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "3" }),
3448
+ /* @__PURE__ */ e("path", { d: "M3 12h6" }),
3449
+ /* @__PURE__ */ e("path", { d: "M15 12h6" })
3450
+ ] }),
3451
+ /* @__PURE__ */ e("span", { style: { position: "absolute", top: -6, right: -8, fontSize: 9, color: "var(--text-muted)", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 6, padding: "0 3px", lineHeight: 1.4 }, children: String(ee.length) })
3452
+ ] })
3453
+ }) : null,
3454
+ nt({ key: "term", onClick: () => void St(p).then((r) => {
3455
+ r && m({ err: r });
3456
+ }), title: g("files.openTerminal"), children: /* @__PURE__ */ e(Kt, {}) }),
3457
+ nt({ key: "nw", onClick: () => Tt("folder", p), title: g("files.openNewWindow"), children: /* @__PURE__ */ e(Pt, {}) }),
3458
+ nt({
3459
+ key: "rf",
3460
+ onClick: Ze,
3461
+ title: g("sidebar.refreshExplorer"),
3462
+ color: R ? "var(--ok, #4ade80)" : "var(--text-dim)",
3463
+ bg: R ? "color-mix(in srgb, var(--ok, #4ade80) 18%, transparent)" : "transparent",
3464
+ children: R ? /* @__PURE__ */ e("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", style: { stroke: "var(--ok, #4ade80)" }, children: /* @__PURE__ */ e("polyline", { points: "20 6 9 17 4 12" }) }) : /* @__PURE__ */ l("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [
3465
+ /* @__PURE__ */ e("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
3466
+ /* @__PURE__ */ e("path", { d: "M3 3v5h5" })
3467
+ ] })
3468
+ }),
3469
+ C ? nt({ key: "at", onClick: () => C(Ct(p, S), !1), title: g("files.insertPath"), color: "var(--accent)", children: /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 700, lineHeight: 1 }, children: "@" }) }) : null,
3470
+ /* @__PURE__ */ l("div", { ref: ut, style: { position: "relative", flexShrink: 0 }, children: [
3471
+ nt({ key: "more", onClick: yn, title: g("files.rename") + " / " + g("files.copyPath") + " / " + g("files.entryInfo") + " / " + g("files.download"), color: X ? "var(--accent)" : "var(--text-dim)", bg: X ? "var(--bg-selected)" : "transparent", children: /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 700, lineHeight: 1 }, children: "⋮" }) }),
3472
+ X ? /* @__PURE__ */ e("div", { style: { position: "fixed", left: Ot.left, top: Ot.top, zIndex: 400, minWidth: 180, padding: 6, background: "var(--bg,#fff)", border: "1px solid var(--border,#d0d0d0)", borderRadius: 10, boxShadow: "0 4px 12px rgba(0,0,0,0.15)", fontSize: 12, display: "flex", flexDirection: "column", gap: 2 }, children: ht ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "2px 2px 4px" }, children: [
3473
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600 }, children: g("files.rename") }),
3474
+ /* @__PURE__ */ e(
3475
+ "input",
3476
+ {
3477
+ autoFocus: !0,
3478
+ value: Ae,
3479
+ onChange: (r) => $e(r.target.value),
3480
+ onKeyDown: (r) => {
3481
+ r.key === "Enter" && st(), r.key === "Escape" && Ee(!1);
3482
+ },
3483
+ placeholder: g("files.renamePlaceholder") || "",
3484
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border,#d0d0d0)", borderRadius: 5, outline: "none", background: "var(--bg,#fff)", color: "var(--text,#222)" }
3485
+ }
3486
+ ),
3487
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
3488
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => Ee(!1), style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: g("files.cancel") }),
3489
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void st(), disabled: !Ae.trim() || Ke, style: { ...Me, background: "var(--accent,#4f8ef7)", color: "#fff", border: "none", opacity: !Ae.trim() || Ke ? 0.5 : 1 }, children: Ke ? "…" : g("files.confirm") })
3490
+ ] })
3491
+ ] }) : [
3492
+ // ── 菜单分组重排(2026-09-16 用户拍板,对齐 aiti-editor ⋯ 菜单):
3493
+ // 钉住 → 关闭图标排 → 导航(上一个目录)→ 导出(下载)→ 路径引用(复制路径/@到新会话)
3494
+ // → 打开/查看 → 整理 → Git。关闭族由 5 条文字项收编为 4 连图标排(同编辑器)。──
3495
+ Pe(g("files.menuTabs"), "h-tabs"),
3496
+ Y(Bt() ? /* @__PURE__ */ e(Vn, {}) : /* @__PURE__ */ e(bo, {}), Bt() ? g("files.unpin") : g("files.pin"), hn, "pin"),
3497
+ /* @__PURE__ */ e(pr, { closeTab: () => {
3498
+ ve(!1), un();
3499
+ }, batch: (r) => {
3500
+ ve(!1), Vt(r);
3501
+ }, t: g }, "close-row"),
3502
+ Ie("s-nav"),
3503
+ Pe(g("files.menuNav"), "h-nav"),
3504
+ Y(/* @__PURE__ */ e(Cn, {}), g("files.openParentDir"), xn, "op"),
3505
+ // ── 导出(≈保存组)──
3506
+ Ie("s-exp"),
3507
+ Pe(g("files.menuExport"), "h-exp"),
3508
+ Y(/* @__PURE__ */ e(Ut, {}), g("files.download"), () => void En(), "dl"),
3509
+ // ── 路径引用(@ 组)──
3510
+ Ie("s-ref"),
3511
+ Pe(g("files.menuRef"), "h-ref"),
3512
+ Y(/* @__PURE__ */ e(nn, {}), g("files.copyPath"), Qt, "cp"),
3513
+ Y(/* @__PURE__ */ e(zt, {}), g("files.atNewSession"), In, "atn"),
3514
+ // ── 打开/查看 ──
3515
+ Ie("s-open"),
3516
+ Pe(g("files.menuOpen"), "h-open"),
3517
+ Y(/* @__PURE__ */ e(Tn, {}), g("files.refresh"), () => {
3518
+ ve(!1), Ze();
3519
+ }, "rf"),
3520
+ Y(/* @__PURE__ */ e(Pt, {}), g("files.openNewWindow"), () => {
3521
+ ve(!1), Tt("folder", p);
3522
+ }, "nw"),
3523
+ Y(/* @__PURE__ */ e(Kt, {}), g("files.openTerminal"), () => {
3524
+ ve(!1), St(p).then((r) => {
3525
+ r && m({ err: r });
3526
+ });
3527
+ }, "ot"),
3528
+ Y(/* @__PURE__ */ e(on, {}), g("files.entryInfo"), () => {
3529
+ ve(!1), It(!0);
3530
+ }, "info"),
3531
+ // ── 整理(重命名/移动到/复制到)──
3532
+ Ie("s-org"),
3533
+ Pe(g("files.menuOrganize"), "h-org"),
3534
+ Y(/* @__PURE__ */ e(rn, {}), g("files.rename"), () => {
3535
+ Ee(!0), $e(ze(p) || "");
3536
+ }, "rn"),
3537
+ Y(/* @__PURE__ */ e(an, {}), g("files.move"), () => {
3538
+ ve(!1), pe("move");
3539
+ }, "mv"),
3540
+ Y(/* @__PURE__ */ e(ln, {}), g("files.copyTo"), () => {
3541
+ ve(!1), pe("copy");
3542
+ }, "cpto"),
3543
+ // ── Git ──
3544
+ Ie("s-git"),
3545
+ Pe(g("files.menuGit"), "h-git"),
3546
+ /* @__PURE__ */ l("button", { type: "button", onClick: (r) => {
3547
+ r.stopPropagation();
3548
+ try {
3549
+ ot() && ot({ scope: { kind: "directory", path: p } }), qe() && qe();
3550
+ } catch {
3551
+ }
3552
+ ve(!1);
3553
+ }, style: { display: "flex", alignItems: "center", gap: 6, width: "100%", padding: "5px 10px", border: "none", background: "transparent", color: "var(--accent)", cursor: "pointer", textAlign: "left", fontSize: 12, borderRadius: 6, whiteSpace: "nowrap" }, children: [
3554
+ /* @__PURE__ */ e(cn, { size: 13 }),
3555
+ "Git Review"
3556
+ ] }, "gr")
3557
+ ] }) : null
3558
+ ] }),
3559
+ G ? /* @__PURE__ */ e("span", { style: { fontSize: 10, color: G.err ? "var(--danger, #f87171)" : G.ok ? "var(--ok, #4ade80)" : "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", marginLeft: 2 }, title: String(G.err || ""), children: G.err ? G.err : G.ok ? G.ok : (G.up || 0) + "↑ / " + (G.skip || 0) + "跳 / " + (G.err || 0) + "错" }) : null
3560
+ ] }),
3561
+ c && G ? /* @__PURE__ */ e("div", { style: { padding: "3px 8px", fontSize: 10, borderBottom: "1px solid var(--border)", background: "var(--bg-panel)", color: G.err ? "var(--danger, #f87171)" : G.ok ? "var(--ok, #4ade80)" : "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flexShrink: 0 }, title: String(G.err || ""), children: G.err ? G.err : G.ok ? G.ok : (G.up || 0) + "↑ / " + (G.skip || 0) + "跳 / " + (G.err || 0) + "错" }) : null,
3562
+ K ? /* @__PURE__ */ e("div", { ref: Dt, style: { position: "fixed", zIndex: 120, minWidth: 180, padding: 6, background: "var(--bg,#fff)", border: "1px solid var(--border,#d0d0d0)", borderRadius: 10, boxShadow: "0 4px 12px rgba(0,0,0,0.15)", fontSize: 12, display: "flex", flexDirection: "column", gap: 2, ...Wt ? { left: Wt.left, top: Wt.top } : { left: -99999, top: -99999 } }, children: ke ? /* @__PURE__ */ l("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: "2px 2px 4px" }, children: [
3563
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "var(--text-dim,#888)", fontWeight: 600 }, children: ke === "file" ? g("files.newFile") : g("files.newFolder") }),
3564
+ /* @__PURE__ */ e(
3565
+ "input",
3566
+ {
3567
+ autoFocus: !0,
3568
+ value: H,
3569
+ onChange: (r) => re(r.target.value),
3570
+ onKeyDown: (r) => {
3571
+ r.key === "Enter" && Hn(), r.key === "Escape" && B(null);
3572
+ },
3573
+ placeholder: ke === "file" ? g("files.namePlaceholderFile") : g("files.namePlaceholderFolder"),
3574
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border,#d0d0d0)", borderRadius: 5, outline: "none", background: "var(--bg,#fff)", color: "var(--text,#222)" }
3575
+ }
3576
+ ),
3577
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
3578
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => B(null), style: { ...Me, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)" }, children: g("files.cancel") }),
3579
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void Hn(), disabled: !H.trim() || ce, style: { ...Me, background: "var(--accent,#4f8ef7)", color: "#fff", border: "none", opacity: !H.trim() || ce ? 0.5 : 1 }, children: ce ? "…" : g("files.create") })
3580
+ ] })
3581
+ ] }) : [
3582
+ Y(/* @__PURE__ */ e(Xn, {}), g("files.newFile"), () => {
3583
+ B("file"), re("");
3584
+ }, "nf"),
3585
+ Y(/* @__PURE__ */ e(Qn, {}), g("files.newFolder"), () => {
3586
+ B("folder"), re("");
3587
+ }, "nd"),
3588
+ /* @__PURE__ */ e("div", { style: { height: 1, background: "var(--border,#eee)", margin: "2px 4px" } }, "sep"),
3589
+ Y(/* @__PURE__ */ e(sn, {}), g("files.uploadFile"), () => {
3590
+ V(!1), Ft.current && Ft.current.click();
3591
+ }, "uf"),
3592
+ Y(/* @__PURE__ */ e(sn, {}), g("files.uploadFolder"), () => {
3593
+ V(!1), ft.current && ft.current.click();
3594
+ }, "ud")
3595
+ ] }) : null,
3596
+ mt ? /* @__PURE__ */ e(Wn, { path: p, onClose: () => It(!1), t: g, onOpenFolder: s }) : null,
3597
+ Z ? /* @__PURE__ */ e(On, { path: p, cwd: S, root: p, mode: Z, t: g, onClose: () => pe(!1), onMoved: (r) => {
3598
+ if (pe(!1), Z === "copy") {
3599
+ m({ ok: g("files.copyDoneAction") + " ✓" });
3600
+ return;
3601
+ }
3602
+ r && r !== p ? (Gt(p, ae), M(null), D(r), le($t(r) ?? /* @__PURE__ */ new Set()), s && s(r, ze(r) || void 0)) : Ze();
3603
+ } }) : null,
3604
+ c && ht ? /* @__PURE__ */ e("div", { onClick: (r) => {
3605
+ r.target === r.currentTarget && Ee(!1);
3606
+ }, style: { position: "fixed", inset: 0, zIndex: 400, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ l("div", { style: { width: "min(420px,92vw)", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 8, boxShadow: "0 8px 32px rgba(0,0,0,0.3)", padding: 12, display: "flex", flexDirection: "column", gap: 8 }, children: [
3607
+ /* @__PURE__ */ e("div", { style: { fontSize: 12, fontWeight: 600, color: "var(--text)" }, children: g("files.rename") }),
3608
+ /* @__PURE__ */ e(
3609
+ "input",
3610
+ {
3611
+ autoFocus: !0,
3612
+ value: Ae,
3613
+ onChange: (r) => $e(r.target.value),
3614
+ onKeyDown: (r) => {
3615
+ r.key === "Enter" && st(), r.key === "Escape" && Ee(!1);
3616
+ },
3617
+ placeholder: g("files.renamePlaceholder") || "",
3618
+ style: { width: "100%", boxSizing: "border-box", fontSize: 12, fontFamily: "var(--font-mono,ui-monospace,monospace)", padding: "5px 8px", border: "1px solid var(--border)", borderRadius: 5, outline: "none", background: "var(--bg)", color: "var(--text)" }
3619
+ }
3620
+ ),
3621
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 6, justifyContent: "flex-end" }, children: [
3622
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => Ee(!1), style: { ...Me, background: "transparent", border: "1px solid var(--border)", color: "var(--text)" }, children: g("files.cancel") }),
3623
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void st(), disabled: !Ae.trim() || Ke, style: { ...Me, background: "var(--accent)", color: "#fff", border: "none", opacity: !Ae.trim() || Ke ? 0.5 : 1 }, children: Ke ? "…" : g("files.confirm") })
3624
+ ] })
3625
+ ] }) }) : null,
3626
+ /* @__PURE__ */ l("div", { style: { flex: 1, overflowY: "auto", overflowX: "hidden", padding: "2px 0" }, children: [
3627
+ Fe ? /* @__PURE__ */ l("div", { style: { padding: "6px 8px", borderBottom: "1px solid var(--border)" }, children: [
3628
+ /* @__PURE__ */ l("div", { style: { position: "relative" }, children: [
3629
+ /* @__PURE__ */ l(
3630
+ "svg",
3631
+ {
3632
+ width: 12,
3633
+ height: 12,
3634
+ viewBox: "0 0 24 24",
3635
+ fill: "none",
3636
+ stroke: "currentColor",
3637
+ strokeWidth: 2,
3638
+ strokeLinecap: "round",
3639
+ strokeLinejoin: "round",
3640
+ "aria-hidden": !0,
3641
+ style: { position: "absolute", left: 8, top: "50%", transform: "translateY(-50%)", color: "var(--text-dim)", pointerEvents: "none" },
3642
+ children: [
3643
+ /* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "7" }),
3644
+ /* @__PURE__ */ e("path", { d: "m20 20-4-4" })
3645
+ ]
3646
+ }
3647
+ ),
3648
+ /* @__PURE__ */ e(
3649
+ "input",
3650
+ {
3651
+ ref: Ve,
3652
+ value: Ne,
3653
+ onChange: (r) => Mt(r.target.value),
3654
+ onKeyDown: (r) => {
3655
+ r.key === "Escape" && De();
3656
+ },
3657
+ placeholder: g("sidebar.searchFilesPlaceholder"),
3658
+ "aria-label": g("sidebar.searchFiles"),
3659
+ style: { width: "100%", boxSizing: "border-box", padding: "6px 24px", border: "1px solid var(--border)", borderRadius: 5, outline: "none", background: "var(--bg)", color: "var(--text)", fontFamily: "var(--font-mono)", fontSize: 11 }
3660
+ }
3661
+ ),
3662
+ Ne ? /* @__PURE__ */ e(
3663
+ "button",
3664
+ {
3665
+ type: "button",
3666
+ onClick: () => Mt(""),
3667
+ title: g("sidebar.clearSearch"),
3668
+ "aria-label": g("sidebar.clearSearch"),
3669
+ style: { position: "absolute", right: 4, top: "50%", transform: "translateY(-50%)", display: "flex", alignItems: "center", justifyContent: "center", width: 18, height: 18, padding: 0, border: "none", borderRadius: 4, background: "none", color: "var(--text-dim)", cursor: "pointer" },
3670
+ children: /* @__PURE__ */ l("svg", { width: 10, height: 10, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.4, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
3671
+ /* @__PURE__ */ e("path", { d: "M18 6 6 18" }),
3672
+ /* @__PURE__ */ e("path", { d: "m6 6 12 12" })
3673
+ ] })
3674
+ }
3675
+ ) : null
3676
+ ] }),
3677
+ mn !== !1 ? /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 2, padding: "4px 2px 0" }, children: [
3678
+ ["files", "fulltext"].map((r) => {
3679
+ const d = r === "files" ? g("sidebar.searchTabFiles") : g("sidebar.searchTabFulltext"), x = Ce === r;
3680
+ return /* @__PURE__ */ e(
3681
+ "button",
3682
+ {
3683
+ type: "button",
3684
+ onClick: () => Te(r),
3685
+ style: {
3686
+ height: 18,
3687
+ padding: "0 8px",
3688
+ fontSize: 10,
3689
+ border: "none",
3690
+ borderRadius: 4,
3691
+ cursor: "pointer",
3692
+ fontWeight: x ? 600 : 400,
3693
+ background: x ? "var(--bg-selected)" : "transparent",
3694
+ color: x ? "var(--accent)" : "var(--text-dim)"
3695
+ },
3696
+ children: d
3697
+ },
3698
+ r
3699
+ );
3700
+ }),
3701
+ Ce === "fulltext" ? /* @__PURE__ */ e(
3702
+ "span",
3703
+ {
3704
+ title: g("sidebar.fulltextHintTitle"),
3705
+ style: { fontSize: 9, color: "var(--text-dim)", opacity: 0.85, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0, flexShrink: 1, marginLeft: 2 },
3706
+ children: g("sidebar.fulltextHint")
3707
+ }
3708
+ ) : null,
3709
+ /* @__PURE__ */ e("span", { style: { flex: 1 } }),
3710
+ Ce === "fulltext" ? /* @__PURE__ */ l("label", { title: g("sidebar.fullScopeAll"), style: { display: "flex", alignItems: "center", gap: 3, fontSize: 10, color: "var(--text-dim)", cursor: "pointer" }, children: [
3711
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: o, onChange: (r) => u(r.target.checked), style: { width: 10, height: 10, margin: 0, accentColor: "var(--accent)" } }),
3712
+ g("sidebar.fullScopeAll")
3713
+ ] }) : null
3714
+ ] }) : null,
3715
+ Xe ? /* @__PURE__ */ l("div", { style: { paddingTop: 3 }, children: [
3716
+ at ? /* @__PURE__ */ e("div", { role: "status", style: { padding: "6px 2px", fontSize: 10, color: "var(--text-dim)" }, children: Ce === "fulltext" ? g("sidebar.searchingDocs") : g("sidebar.searchingFiles") }) : null,
3717
+ !at && vt ? /* @__PURE__ */ e("div", { role: "alert", style: { padding: "6px 2px", fontSize: 10, color: "var(--danger, #f87171)" }, children: g("i18n.networkError") }) : null,
3718
+ !at && !vt && (Ce === "files" ? Se.length === 0 : Be.length === 0) ? /* @__PURE__ */ e("div", { style: { padding: "6px 2px", fontSize: 10, color: "var(--text-dim)" }, children: Ce === "fulltext" ? g("sidebar.noMatchingDocs") : g("sidebar.noMatchingFiles") }) : null,
3719
+ !at && !vt && Ce === "files" && Se.length > 0 ? /* @__PURE__ */ e("div", { children: ie.map((r) => /* @__PURE__ */ e(
3720
+ Rn,
3721
+ {
3722
+ node: r,
3723
+ depth: 0,
3724
+ cwd: S || p,
3725
+ expanded: gn,
3726
+ onToggle: (d, x) => lt((k) => {
3727
+ const N = new Set(k);
3728
+ return x ? N.add(d) : N.delete(d), N;
3729
+ }),
3730
+ onOpenFile: F,
3731
+ onOpenFolder: s,
3732
+ onAtMention: C,
3733
+ onTrash: ge,
3734
+ onChanged: Ze,
3735
+ gitByPath: Mn,
3736
+ changedDirs: An,
3737
+ t: g,
3738
+ root: p
3739
+ },
3740
+ Ne + ":" + r.fullPath
3741
+ )) }) : null,
3742
+ !at && !vt && Ce === "fulltext" && Be.length > 0 ? /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 1 }, children: Be.map((r) => /* @__PURE__ */ l(
3743
+ "div",
3744
+ {
3745
+ onClick: () => F(r.path),
3746
+ title: r.path,
3747
+ style: { display: "flex", flexDirection: "column", gap: 1, padding: "3px 10px", cursor: "pointer", borderRadius: 4, userSelect: "none" },
3748
+ onMouseEnter: (d) => d.currentTarget.style.background = "var(--bg-hover)",
3749
+ onMouseLeave: (d) => d.currentTarget.style.background = "transparent",
3750
+ children: [
3751
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "baseline", gap: 6 }, children: [
3752
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, children: r.title || ze(r.path) }),
3753
+ r.mtimeMs ? /* @__PURE__ */ e("span", { style: { fontSize: 9, color: "var(--text-dim)", flexShrink: 0 }, children: new Date(r.mtimeMs).toLocaleDateString() }) : null
3754
+ ] }),
3755
+ /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "var(--text-dim)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: Ct(r.path, p) || r.path }),
3756
+ r.snippet ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "var(--text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: /* @__PURE__ */ e(hr, { text: r.snippet }) }) : null
3757
+ ]
3758
+ },
3759
+ r.path
3760
+ )) }) : null
3761
+ ] }) : null
3762
+ ] }) : null,
3763
+ /* @__PURE__ */ e(ar, { root: p, git: _e, onChanged: Ze, changesOpen: v, onToggleChanges: () => I((r) => !r) }),
3764
+ v && ee.length > 0 ? /* @__PURE__ */ l("div", { style: { padding: "0 4px 2px", borderBottom: "1px solid var(--border)" }, children: [
3765
+ /* @__PURE__ */ l("div", { style: { display: "flex", alignItems: "center", gap: 6, height: 24, padding: "0 10px", fontSize: 12 }, children: [
3766
+ /* @__PURE__ */ e("span", { style: { color: "var(--text-dim)" }, children: g("files.changedCount", { count: ee.length }) }),
3767
+ /* @__PURE__ */ l("span", { style: { color: "var(--ok, #4ade80)", fontFamily: "var(--font-mono)" }, children: [
3768
+ "+",
3769
+ we.additions
3770
+ ] }),
3771
+ /* @__PURE__ */ l("span", { style: { color: "var(--danger, #f87171)", fontFamily: "var(--font-mono)" }, children: [
3772
+ "-",
3773
+ we.deletions
3774
+ ] })
3775
+ ] }),
3776
+ (() => {
3777
+ const r = new Map((_e.refs?.dirtyFiles ?? []).map((ue) => [ue.path.replace(/\\/g, "/"), ue.xy])), d = (ue) => (Zn(ue, p) || ue).replace(/\\/g, "/"), x = ee.map((ue) => ({ st: ue, rel: d(ue.filePath) })), k = (ue) => {
3778
+ const Je = r.get(ue) ?? r.get(ue + "/");
3779
+ return !!Je && Je[0] !== " " && Je[0] !== "?";
3780
+ }, N = _e.avail === !0 ? x.filter((ue) => k(ue.rel)) : [], ne = x.filter((ue) => !N.includes(ue)), be = (ue, Je, gt) => /* @__PURE__ */ l("div", { style: { padding: "4px 10px 1px", fontSize: 10, fontWeight: 600, letterSpacing: "0.05em", textTransform: "uppercase", color: "var(--text-dim)" }, children: [
3781
+ ue,
3782
+ " (",
3783
+ Je,
3784
+ ")"
3785
+ ] }, gt), We = (ue) => /* @__PURE__ */ e(
3786
+ gr,
3787
+ {
3788
+ st: ue.st,
3789
+ root: p,
3790
+ cwd: S || p,
3791
+ onOpenFile: F,
3792
+ onOpenFolder: s,
3793
+ onAtMention: C,
3794
+ onTrash: ge,
3795
+ t: g,
3796
+ onRefresh: Ze,
3797
+ staged: _e.avail === !0 ? k(ue.rel) : void 0,
3798
+ gitOp: _e.avail === !0 ? (Je, gt) => {
3799
+ _e.op(Je, gt);
3800
+ } : void 0
3801
+ },
3802
+ ue.st.filePath
3803
+ );
3804
+ return /* @__PURE__ */ l(dn, { children: [
3805
+ _e.avail === !0 && N.length > 0 ? be($("git.stagedBucket"), N.length, "staged-head") : null,
3806
+ (_e.avail === !0 ? N : []).map(We),
3807
+ _e.avail === !0 ? be($("git.unstagedBucket"), ne.length, "unstaged-head") : null,
3808
+ ne.map(We)
3809
+ ] });
3810
+ })()
3811
+ ] }) : null,
3812
+ Xe ? null : z ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: g("files.loading") }) : _ ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--danger, #f87171)" }, children: _ }) : W.length === 0 ? /* @__PURE__ */ e("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: g("files.noFiles") }) : W.map((r) => /* @__PURE__ */ e(Rn, { node: r, depth: 0, cwd: S || p, expanded: ae, refreshKey: b, onToggle: oo, onOpenFile: F, onOpenFolder: s, onAtMention: C, onTrash: ge, onChanged: Ze, gitByPath: Mn, changedDirs: An, highlightPath: Jt, t: g, root: p, showIgnored: a }, r.fullPath))
3813
+ ] }),
3814
+ ye ? /* @__PURE__ */ e("div", { onClick: (r) => {
3815
+ r.target === r.currentTarget && !xe && ge(null);
3816
+ }, style: { position: "fixed", inset: 0, zIndex: 400, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ l("div", { style: { width: 360, padding: "16px 18px", borderRadius: 12, background: "var(--bg,#fff)", border: "1px solid var(--border,#ddd)", boxShadow: "0 12px 40px rgba(0,0,0,0.25)", fontSize: 13, display: "flex", flexDirection: "column", gap: 10 }, children: [
3817
+ /* @__PURE__ */ e("div", { style: { fontWeight: 600, fontSize: 14 }, children: g("files.trashConfirmTitle") }),
3818
+ /* @__PURE__ */ e("div", { style: { fontFamily: "var(--font-mono,ui-monospace,monospace)", color: "var(--text-dim,#888)", fontSize: 12, wordBreak: "break-all", lineHeight: 1.5 }, children: ye.name }),
3819
+ /* @__PURE__ */ e("div", { style: { color: "var(--text-dim,#888)", fontSize: 12 }, children: g("files.trashConfirmBody") }),
3820
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: 8, justifyContent: "flex-end" }, children: [
3821
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => ge(null), disabled: xe, style: { height: 28, padding: "0 12px", borderRadius: 5, background: "transparent", border: "1px solid var(--border,#d0d0d0)", color: "var(--text,#222)", cursor: xe ? "default" : "pointer", fontSize: 12 }, children: g("files.cancel") }),
3822
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => void ao(), disabled: xe, style: { height: 28, padding: "0 12px", borderRadius: 5, background: "var(--danger, #ef4444)", border: "none", color: "#fff", cursor: xe ? "default" : "pointer", fontSize: 12, fontWeight: 600, opacity: xe ? 0.6 : 1 }, children: xe ? "…" : g("files.trash") })
3823
+ ] })
3824
+ ] }) }) : null
3825
+ ] });
3826
+ }
3827
+ export {
3828
+ to as FOLDER_STATE_TTL,
3829
+ yr as FolderBrowser
3830
+ };