@aiti-ai/aiti-acp-agent 0.3.9 → 0.3.10

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,831 @@
1
+ import { u as m, a as S, r as fe, S as he, b as xe, p as Ae, c as a, F as ge, f as Te, l as Oe, d as We, D as we, e as He, g as Pe, w as _e, h as je, i as Fe, A as w, j as $e, k as T, m as f, t as E, n as Ve, o as ie, P as qe, s as me, q as _ } from "./entry-De5iU21x.js";
2
+ function Ue(t) {
3
+ const n = parseFloat(t.zoom || "");
4
+ if (Number.isFinite(n) && n !== 1 || t.transform !== "none" || t.perspective !== "none" || t.filter !== "none" || /transform|perspective|filter/.test(t.willChange || "")) return !0;
5
+ const i = t.contain;
6
+ return i === "strict" || i === "content" || i === "layout" || i === "paint";
7
+ }
8
+ function Ze(t) {
9
+ let n = t.parentElement;
10
+ for (; n && n !== document.documentElement; ) {
11
+ try {
12
+ if (Ue(getComputedStyle(n))) {
13
+ const i = n.getBoundingClientRect();
14
+ return { x: i.left, y: i.top };
15
+ }
16
+ } catch {
17
+ }
18
+ n = n.parentElement;
19
+ }
20
+ return { x: 0, y: 0 };
21
+ }
22
+ function Ye(t) {
23
+ let n = 1, i = t.parentElement;
24
+ for (; i && i !== document.documentElement; ) {
25
+ try {
26
+ const d = parseFloat(getComputedStyle(i).zoom || "");
27
+ Number.isFinite(d) && d > 0 && d !== 1 && (n *= d);
28
+ } catch {
29
+ }
30
+ i = i.parentElement;
31
+ }
32
+ return n;
33
+ }
34
+ function Ke(t, n, i, d, u = 8) {
35
+ const y = window.innerWidth, z = window.innerHeight;
36
+ return {
37
+ left: Math.max(u, Math.min(t, y - u - i)),
38
+ top: Math.max(u, Math.min(n, Math.max(u, z - u - d)))
39
+ };
40
+ }
41
+ const Ge = {
42
+ expand: { "zh-CN": "展开", en: "Expand" },
43
+ collapse: { "zh-CN": "折叠", en: "Collapse" },
44
+ block: { "zh-CN": "区块", en: "Block" },
45
+ position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
46
+ actions: { "zh-CN": "区块操作", en: "Block actions" },
47
+ move: { "zh-CN": "移动", en: "Move" },
48
+ pin: { "zh-CN": "钉住", en: "Pin" },
49
+ unpin: { "zh-CN": "取消钉住", en: "Unpin" },
50
+ moveUp: { "zh-CN": "上移", en: "Move up" },
51
+ moveDown: { "zh-CN": "下移", en: "Move down" },
52
+ tools: { "zh-CN": "工具", en: "Tools" },
53
+ removeInstance: { "zh-CN": "移除本实例", en: "Remove this instance" },
54
+ close: { "zh-CN": "关闭", en: "Close" },
55
+ zones: { "zh-CN": "停靠方位", en: "Dock zones" },
56
+ defaultSuffix: { "zh-CN": "(默认)", en: " (default)" }
57
+ };
58
+ function g(t) {
59
+ let n = "en";
60
+ try {
61
+ n = window.localStorage.getItem("pi-locale") || "en";
62
+ } catch {
63
+ }
64
+ const i = Ge[t];
65
+ return i[n === "zh-CN" ? "zh-CN" : "en"] ?? i.en;
66
+ }
67
+ function j(t, n = 16) {
68
+ return a(
69
+ "svg",
70
+ { width: n, height: n, ...Pe, "aria-hidden": "true" },
71
+ ...we[t].map((i, d) => a(i.tag, { key: d, ...He(i.attrs) }))
72
+ );
73
+ }
74
+ function be(t, n) {
75
+ return a("span", { "aria-hidden": "true", style: {
76
+ display: "inline-block",
77
+ width: n,
78
+ height: n,
79
+ flexShrink: 0,
80
+ background: "currentColor",
81
+ WebkitMaskImage: `url("${t}")`,
82
+ maskImage: `url("${t}")`,
83
+ WebkitMaskRepeat: "no-repeat",
84
+ maskRepeat: "no-repeat",
85
+ WebkitMaskPosition: "center",
86
+ maskPosition: "center",
87
+ WebkitMaskSize: "contain",
88
+ maskSize: "contain"
89
+ } });
90
+ }
91
+ function Je(t, n = 13) {
92
+ if (t == null) return null;
93
+ if (typeof t == "object") {
94
+ const i = t;
95
+ return typeof i.svg == "string" ? a("svg", {
96
+ width: n,
97
+ height: n,
98
+ viewBox: "0 0 24 24",
99
+ fill: "none",
100
+ stroke: "currentColor",
101
+ strokeWidth: 2,
102
+ strokeLinecap: "round",
103
+ strokeLinejoin: "round",
104
+ "aria-hidden": "true",
105
+ dangerouslySetInnerHTML: { __html: i.svg }
106
+ }) : typeof i.url == "string" ? be(i.url, n) : null;
107
+ }
108
+ return typeof t != "string" || !t ? null : /^https?:\/\//.test(t) ? be(t, n) : we[t] ? j(t, n) : t.endsWith(".svg") ? null : a("span", { style: { fontSize: n, lineHeight: 1 } }, t);
109
+ }
110
+ function D() {
111
+ const n = Te()?.dockHeader;
112
+ return n && typeof n.register == "function" ? n : Oe();
113
+ }
114
+ function Qe(t, n, i) {
115
+ return D().request(t, n, i);
116
+ }
117
+ function Q() {
118
+ const [t, n] = m(0);
119
+ return S(() => {
120
+ const i = () => n((d) => d + 1);
121
+ return window.addEventListener(ge, i), () => window.removeEventListener(ge, i);
122
+ }, []), t;
123
+ }
124
+ function Xe(t, n) {
125
+ const i = Q();
126
+ S(() => {
127
+ if (t)
128
+ try {
129
+ D().register(t, { commands: n });
130
+ } catch {
131
+ }
132
+ }), S(() => {
133
+ if (t)
134
+ return () => {
135
+ try {
136
+ D().register(t, { commands: null });
137
+ } catch {
138
+ }
139
+ };
140
+ }, [t, i]);
141
+ }
142
+ function et(t, n) {
143
+ const i = Q();
144
+ S(() => {
145
+ if (t)
146
+ try {
147
+ D().register(t, { state: n });
148
+ } catch {
149
+ }
150
+ }), S(() => {
151
+ if (t)
152
+ return () => {
153
+ try {
154
+ D().register(t, { state: null });
155
+ } catch {
156
+ }
157
+ };
158
+ }, [t, i]);
159
+ }
160
+ function tt(t) {
161
+ const n = Q(), [, i] = m(0);
162
+ return S(() => D().subscribe(t, () => i((u) => u + 1)), [t, n]), D().stateOf(t);
163
+ }
164
+ function nt(t) {
165
+ const n = Q(), [, i] = m(0);
166
+ S(() => D().subscribe(t, () => i((y) => y + 1)), [t, n]);
167
+ const d = D();
168
+ return { actions: d.actionsOf(t), menuItems: d.menuItemsOf(t), hasCommands: !!d.commandsOf(t) };
169
+ }
170
+ function ot(t, n) {
171
+ const i = [], d = /* @__PURE__ */ new Set();
172
+ for (const u of [...t ?? [], ...n ?? []])
173
+ !u || typeof u.id != "string" || d.has(u.id) || (d.add(u.id), i.push(u));
174
+ return i;
175
+ }
176
+ function ve(t) {
177
+ const { itemKey: n, zone: i, title: d, chrome: u = "section", zones: y, defaultZone: z, children: F } = t, M = t.kind ?? "dockable", b = t.blockKey ?? n, $ = m(() => fe(b)), k = t.collapsed ?? $[0], N = $[1];
178
+ S(() => {
179
+ if (t.collapsed !== void 0) return;
180
+ const e = () => N(fe(b));
181
+ return window.addEventListener(he, e), window.addEventListener("storage", e), () => {
182
+ window.removeEventListener(he, e), window.removeEventListener("storage", e);
183
+ };
184
+ }, [b, t.collapsed]);
185
+ const V = (e) => {
186
+ N(e), _e(b, e), t.onToggleCollapsed?.(e);
187
+ }, C = nt(n), [p, v] = m(null), [x, O] = m(null), [W, H] = m(null), [X, ee] = m(null), [B, A] = m(null);
188
+ S(() => {
189
+ if (!p || !x || !p.anchor) return;
190
+ const e = p.anchor.getBoundingClientRect(), c = x.getBoundingClientRect(), r = 4, h = 8;
191
+ let o = e.bottom + r;
192
+ const l = window.innerHeight - h - o, K = e.top - r - h;
193
+ c.height > l && K > l && (o = e.top - r - c.height);
194
+ const P = Ke(e.right - c.width, o, c.width, c.height, h), I = Ze(x), pe = Ye(x), oe = { left: (P.left - I.x) / pe, top: (P.top - I.y) / pe };
195
+ A((G) => G && G.left === oe.left && G.top === oe.top ? G : oe);
196
+ }, [p, x]), S(() => {
197
+ if (!p) return;
198
+ const e = (o) => {
199
+ const l = o.target;
200
+ l && x?.contains(l) || l && p.anchor?.contains(l) || v(null);
201
+ };
202
+ let c = null, r = null;
203
+ try {
204
+ const o = p.anchor?.getBoundingClientRect?.();
205
+ o && (c = o.top, r = o.left);
206
+ } catch {
207
+ }
208
+ const h = (o) => {
209
+ if (!(x && o.target instanceof Node && x.contains(o.target))) {
210
+ try {
211
+ const l = p.anchor?.getBoundingClientRect?.();
212
+ if (l && c !== null && r !== null && Math.abs(l.top - c) < 4 && Math.abs(l.left - r) < 4) return;
213
+ } catch {
214
+ }
215
+ v(null);
216
+ }
217
+ };
218
+ return document.addEventListener("mousedown", e), window.addEventListener("scroll", h, !0), () => {
219
+ document.removeEventListener("mousedown", e), window.removeEventListener("scroll", h, !0);
220
+ };
221
+ }, [p, x]);
222
+ const [L, q] = m(null), [U, s] = m(4);
223
+ S(() => {
224
+ if (!L) return;
225
+ const e = () => {
226
+ const r = L.clientWidth || 0;
227
+ if (r <= 0) return;
228
+ const o = Math.max(0, Math.min(6, Math.floor((r - 154) / 27)));
229
+ s((l) => l === o ? l : o);
230
+ };
231
+ e();
232
+ let c = null;
233
+ try {
234
+ typeof ResizeObserver == "function" && (c = new ResizeObserver(e), c.observe(L));
235
+ } catch {
236
+ }
237
+ return window.addEventListener("resize", e), () => {
238
+ try {
239
+ c && c.disconnect();
240
+ } catch {
241
+ }
242
+ window.removeEventListener("resize", e);
243
+ };
244
+ }, [L]);
245
+ const Z = xe(n), te = y && y.length ? y : i ? [i] : [], Se = M === "dockable" && u === "section" && te.length > 0, Y = {
246
+ background: "none",
247
+ border: "none",
248
+ color: "var(--text-muted, #888)",
249
+ cursor: "pointer",
250
+ fontSize: 11,
251
+ lineHeight: 1,
252
+ padding: "2px 5px",
253
+ flexShrink: 0,
254
+ fontFamily: "inherit"
255
+ }, re = ot(t.headerActions, C.actions).filter((e) => !k || (e.visibility ?? "always") !== "expanded"), le = re.slice(0, U), ne = re.slice(U), Ce = (e) => a(
256
+ "button",
257
+ {
258
+ key: e.id,
259
+ type: "button",
260
+ title: e.title,
261
+ "aria-label": e.title,
262
+ disabled: e.disabled === !0,
263
+ style: {
264
+ ...Y,
265
+ position: "relative",
266
+ color: e.done ? "var(--ok, #4ade80)" : e.active ? "var(--accent, #2563eb)" : "var(--text-muted, #888)",
267
+ opacity: e.disabled ? 0.5 : 1,
268
+ cursor: e.disabled ? "default" : "pointer"
269
+ },
270
+ onClick: (c) => {
271
+ e.disabled !== !0 && e.onClick(c);
272
+ }
273
+ },
274
+ e.icon ? a("span", { style: { display: "inline-flex", alignItems: "center", justifyContent: "center" } }, e.icon) : a("span", { style: { fontSize: 12, fontWeight: 700, lineHeight: 1 } }, "•"),
275
+ e.badge !== void 0 && e.badge !== null && e.badge !== "" ? a("span", {
276
+ style: { position: "absolute", top: -5, right: -4, fontSize: 9, lineHeight: "13px", color: "var(--text-muted, #888)", background: "var(--bg-panel, #1a1a1a)", border: "1px solid var(--border, #444)", borderRadius: 7, padding: "0 3px" }
277
+ }, String(e.badge)) : null
278
+ ), Ee = () => {
279
+ const e = [], c = M !== "reserved", r = () => ({
280
+ type: "icons",
281
+ label: g("move"),
282
+ icon: j("move-diagonal-2", 13),
283
+ items: [
284
+ ...t.moveRowPin ? [{
285
+ key: "pin",
286
+ icon: t.moveRowPin.isPinned() ? "pin-off" : "pin",
287
+ label: t.moveRowPin.isPinned() ? g("unpin") : g("pin"),
288
+ run: () => t.moveRowPin.toggle()
289
+ }] : [],
290
+ { key: "move-up", icon: "chevron-up", label: g("moveUp"), run: () => ye(b, -1) },
291
+ { key: "move-down", icon: "chevron-down", label: g("moveDown"), run: () => ye(b, 1) }
292
+ ]
293
+ });
294
+ if (ne.length > 0) {
295
+ e.push({ type: "head", label: g("tools") });
296
+ for (const o of ne) e.push({ type: "item", label: o.title, icon: o.icon, badge: o.badge, active: o.active, alwaysRun: !0, disabled: o.disabled, run: o.onClick });
297
+ }
298
+ if (C.menuItems && C.menuItems.length > 0) {
299
+ e.length > 0 && e.push({ type: "sep" });
300
+ let o = !1;
301
+ for (const l of C.menuItems) {
302
+ if (l.kind === "moveRow" && c && !o) {
303
+ o = !0, e.push(r());
304
+ continue;
305
+ }
306
+ l.kind === "head" ? e.push({ type: "head", label: l.label }) : l.kind === "sep" ? e.push({ type: "sep" }) : l.kind === "iconsRow" ? e.push({ type: "icons", label: l.label, items: l.items }) : e.push({ type: "item", label: l.label, icon: l.icon, hint: l.hint, active: l.active, alwaysRun: l.alwaysRun, disabled: l.disabled, run: l.run });
307
+ }
308
+ u === "section" && c && !o && e.push(r());
309
+ }
310
+ const h = [];
311
+ if (u === "section" && c && !(C.menuItems || []).some((o) => o.kind === "moveRow") && h.push(r()), M === "reserved" && typeof t.onRemove == "function" && h.push({ type: "item", label: g("removeInstance"), icon: j("trash", 13), run: () => t.onRemove() }), Array.isArray(t.extraMenuItems))
312
+ for (const o of t.extraMenuItems) h.push({ type: "item", label: o.label, icon: o.icon, hint: o.hint, active: o.active, alwaysRun: o.alwaysRun, run: o.run });
313
+ return M === "dockable" && u === "section" && t.hideCloseItem !== !0 && h.push({ type: "item", label: g("close"), icon: j("x", 13), run: () => t.onClose ? t.onClose() : We(n) }), h.length > 0 && (e.length > 0 && e.push({ type: "sep" }), e.push({ type: "head", label: g("block") }), e.push(...h)), e;
314
+ }, ze = p?.kind === "position" ? [{ type: "icons", label: g("zones"), items: Ae(n, te, z, Z, { onNewWindow: t.onNewWindow }) }] : [], Re = p?.kind === "position" ? ze : p?.kind === "main" ? Ee() : [], De = (e, c) => {
315
+ if (e.type === "sep") return a("div", { key: `sep-${c}`, style: { height: 1, background: "var(--border, #444)", margin: "3px 4px", opacity: 0.7, flexShrink: 0 } });
316
+ if (e.type === "head") return a("div", { key: `head-${c}`, style: { fontSize: 10, color: "var(--text-dim, #888)", fontWeight: 600, padding: "4px 10px 2px", letterSpacing: 0.3, userSelect: "none", whiteSpace: "nowrap" } }, e.label);
317
+ if (e.type === "icons") return a(
318
+ "div",
319
+ {
320
+ key: `icons-${c}`,
321
+ role: "group",
322
+ "data-ext-dock-icon-row": "1",
323
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 16, padding: "5px 10px", flexShrink: 0 }
324
+ },
325
+ e.label ? a(
326
+ "span",
327
+ {
328
+ key: "label",
329
+ "data-ext-dock-icon-row-label": "1",
330
+ // 行首图标(可选):带图标 = 动作行(正文字色,与其余 icon+text 行同款);
331
+ // 无图标 = 纯说明名(dim,位置菜单「停靠方位」标题原样)。
332
+ style: {
333
+ display: "inline-flex",
334
+ alignItems: "center",
335
+ gap: 6,
336
+ fontSize: 12,
337
+ color: e.icon ? "var(--text, #ddd)" : "var(--text-dim, #888)",
338
+ flexShrink: 0,
339
+ userSelect: "none",
340
+ whiteSpace: "nowrap"
341
+ }
342
+ },
343
+ e.icon ? a("span", { style: { display: "inline-flex", flexShrink: 0 } }, e.icon) : null,
344
+ e.label
345
+ ) : null,
346
+ a(
347
+ "div",
348
+ {
349
+ key: "group",
350
+ "data-ext-dock-icon-group": "1",
351
+ style: { display: "flex", gap: 6, marginLeft: "auto", flexShrink: 0 }
352
+ },
353
+ ...e.items.map((o, l) => {
354
+ const K = o.active === !0 || o.active === !1, P = o.isDefault ? `${o.label}${g("defaultSuffix")}` : o.label;
355
+ return a(
356
+ "button",
357
+ {
358
+ key: `icon-${l}`,
359
+ type: "button",
360
+ role: K ? "menuitemradio" : "menuitem",
361
+ ...K ? { "aria-checked": o.active ? "true" : "false" } : {},
362
+ title: P,
363
+ "aria-label": P,
364
+ "data-ext-dock-icon": o.key,
365
+ style: {
366
+ position: "relative",
367
+ width: 28,
368
+ height: 28,
369
+ display: "inline-flex",
370
+ alignItems: "center",
371
+ justifyContent: "center",
372
+ border: "none",
373
+ borderRadius: 6,
374
+ padding: 0,
375
+ fontFamily: "inherit",
376
+ cursor: o.active ? "default" : "pointer",
377
+ background: o.active ? "var(--bg-selected, #2a2a2a)" : "none",
378
+ color: o.active ? "var(--accent, #2563eb)" : "var(--text-muted, #888)"
379
+ },
380
+ onClick: () => {
381
+ o.active || (v(null), o.run());
382
+ },
383
+ onMouseEnter: (I) => {
384
+ o.active || (I.currentTarget.style.background = "var(--bg-hover, #262626)", I.currentTarget.style.color = "var(--text, #ddd)");
385
+ },
386
+ onMouseLeave: (I) => {
387
+ o.active || (I.currentTarget.style.background = "none", I.currentTarget.style.color = "var(--text-muted, #888)");
388
+ }
389
+ },
390
+ typeof o.icon == "string" ? j(o.icon, 16) : o.icon,
391
+ o.isDefault ? a("span", { key: "dot", "data-ext-dock-icon-default": "1", style: { position: "absolute", top: 3, right: 3, width: 4, height: 4, borderRadius: "50%", background: "var(--accent, #2563eb)", pointerEvents: "none" } }) : null
392
+ );
393
+ })
394
+ )
395
+ );
396
+ const r = e.disabled === !0, h = e.active === !0 && e.alwaysRun !== !0;
397
+ return a(
398
+ "button",
399
+ {
400
+ key: `item-${c}`,
401
+ type: "button",
402
+ role: "menuitem",
403
+ disabled: r,
404
+ style: {
405
+ background: "none",
406
+ border: "none",
407
+ cursor: r || h ? "default" : "pointer",
408
+ fontSize: 12,
409
+ padding: "6px 12px",
410
+ textAlign: "left",
411
+ borderRadius: 6,
412
+ fontFamily: "inherit",
413
+ color: e.active ? "var(--accent, #2563eb)" : "var(--text, #ddd)",
414
+ display: "flex",
415
+ alignItems: "center",
416
+ gap: 6,
417
+ opacity: r ? 0.5 : 1,
418
+ flexShrink: 0
419
+ },
420
+ onClick: () => {
421
+ v(null), h || e.run();
422
+ },
423
+ onKeyDown: (o) => {
424
+ o.key === "Escape" && v(null);
425
+ }
426
+ },
427
+ e.icon ? a("span", { style: { width: 14, display: "inline-flex", justifyContent: "center", flexShrink: 0 } }, e.icon) : null,
428
+ (e.active ? "✓ " : "") + e.label,
429
+ e.badge !== void 0 && e.badge !== null && e.badge !== "" ? a("span", { style: { marginLeft: "auto", fontSize: 10, color: "var(--text-muted, #888)", border: "1px solid var(--border, #444)", borderRadius: 6, padding: "0 4px" } }, String(e.badge)) : null,
430
+ e.hint ? a("span", { style: { marginLeft: "auto", fontSize: 10, color: "var(--text-muted, #888)", border: "1px solid var(--border, #444)", borderRadius: 4, padding: "0 4px" } }, e.hint) : null
431
+ );
432
+ }, se = p ? a("div", {
433
+ ref: O,
434
+ role: "menu",
435
+ style: {
436
+ position: "fixed",
437
+ zIndex: 2147483600,
438
+ background: "var(--bg-panel, #1a1a1a)",
439
+ border: "1px solid var(--border, #444)",
440
+ borderRadius: 8,
441
+ padding: 4,
442
+ display: "flex",
443
+ flexDirection: "column",
444
+ gap: 2,
445
+ boxShadow: "0 8px 24px rgba(0,0,0,0.4)",
446
+ minWidth: p?.kind === "position" ? 190 : 150,
447
+ maxWidth: "calc(100vw - 16px)",
448
+ // 长菜单滚动契约(v3):视口内可滚 + 防滚动穿透(内部滚动不触发「容器滚动即关」)
449
+ maxHeight: "min(70vh, calc(100vh - 16px))",
450
+ overflowY: "auto",
451
+ overscrollBehavior: "contain",
452
+ // 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
453
+ ...B ? { left: B.left, top: B.top } : { left: -99999, top: -99999 }
454
+ },
455
+ // hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
456
+ // 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
457
+ // 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
458
+ onMouseLeave: () => {
459
+ try {
460
+ if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return;
461
+ } catch {
462
+ }
463
+ v(null);
464
+ }
465
+ }, Re.map(De)) : null, ce = () => V(!k), Ie = (e) => {
466
+ if (e.target && typeof e.target.closest == "function" && e.target.closest("button")) {
467
+ e.preventDefault();
468
+ return;
469
+ }
470
+ J = b;
471
+ try {
472
+ e.dataTransfer.setData("application/x-pi-dock", b), e.dataTransfer.effectAllowed = "move";
473
+ } catch {
474
+ }
475
+ }, de = (e) => {
476
+ try {
477
+ return [...e.dataTransfer?.types ?? []].includes("application/x-pi-dock");
478
+ } catch {
479
+ return !1;
480
+ }
481
+ }, ue = (e, c) => {
482
+ const r = e.currentTarget;
483
+ r && (r.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"), c && r.classList.add(e.clientY - r.getBoundingClientRect().top < r.getBoundingClientRect().height / 2 ? "pi-dock-drop-before" : "pi-dock-drop-after"));
484
+ }, Me = (e) => {
485
+ if (!de(e)) return;
486
+ e.preventDefault();
487
+ const c = e.currentTarget;
488
+ c.classList.remove("pi-dock-drop-before", "pi-dock-drop-after");
489
+ let r = "";
490
+ try {
491
+ r = e.dataTransfer.getData("application/x-pi-dock") || "";
492
+ } catch {
493
+ }
494
+ if (r || (r = J || ""), !r || r === b) return;
495
+ const h = c.getBoundingClientRect();
496
+ it(r, b, e.clientY - h.top < h.height / 2);
497
+ }, R = { ref: q, style: { display: "flex", alignItems: "center", gap: 4, padding: "4px 8px", borderBottom: "1px solid var(--border, #333)", flexShrink: 0, minWidth: 0 }, onClick: (e) => {
498
+ e.target && typeof e.target.closest == "function" && e.target.closest("button") || ce();
499
+ } };
500
+ u === "section" && M !== "reserved" ? (R.draggable = !0, R.title = t.headerHint ?? "拖动排序", R.onDragStart = Ie, R.onDragOver = (e) => {
501
+ de(e) && J !== b && (e.preventDefault(), e.dataTransfer.dropEffect = "move", ue(e, !0));
502
+ }, R.onDragLeave = (e) => {
503
+ try {
504
+ if (e.relatedTarget && e.currentTarget.contains(e.relatedTarget)) return;
505
+ } catch {
506
+ }
507
+ ue(e, !1);
508
+ }, R.onDrop = Me, R.onDragEnd = () => {
509
+ J = null, document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((e) => e.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
510
+ }) : u === "section" && t.headerHint && (R.title = t.headerHint);
511
+ const Le = Je(t.icon, 13), Ne = a(
512
+ "span",
513
+ { style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center", gap: 5 } },
514
+ Le,
515
+ t.renderTitle ? t.renderTitle() : a("span", { style: { fontSize: 13, fontWeight: 500, color: "var(--text, #222)", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, d ?? "")
516
+ ), Be = k && C.hasCommands;
517
+ return a(
518
+ "div",
519
+ {
520
+ "data-ext-float-dock-body": n,
521
+ "data-ext-item": n,
522
+ "data-ext-dock-block": b,
523
+ // 根上带声明属性:TabBar ⇱ 菜单在 face 挂载时可直接读(注册表兜底优先)
524
+ "data-ext-float-dock": te.join(" "),
525
+ ...z ? { "data-ext-float-dock-default": z } : {},
526
+ // 注册按钮数(e2e/调试断言用):当前头行可见 / 溢出
527
+ "data-ext-dock-actions": String(le.length),
528
+ "data-ext-dock-actions-overflow": String(ne.length),
529
+ style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, overflow: "hidden", position: "relative" }
530
+ },
531
+ u === "section" && a(
532
+ "div",
533
+ R,
534
+ a(
535
+ "button",
536
+ {
537
+ type: "button",
538
+ title: g(k ? "expand" : "collapse"),
539
+ "aria-label": (d ?? g("block")) + (k ? " " + g("expand") : " " + g("collapse")),
540
+ "aria-expanded": k ? "false" : "true",
541
+ style: { ...Y, display: "flex", alignItems: "center" },
542
+ onClick: ce
543
+ },
544
+ a(
545
+ "svg",
546
+ {
547
+ width: 9,
548
+ height: 9,
549
+ viewBox: "0 0 10 10",
550
+ fill: "none",
551
+ stroke: "currentColor",
552
+ strokeWidth: 1.8,
553
+ strokeLinecap: "round",
554
+ strokeLinejoin: "round",
555
+ style: { transform: k ? "none" : "rotate(90deg)", transition: "transform 0.15s", flexShrink: 0 }
556
+ },
557
+ a("polyline", { points: "3 2 7 5 3 8" })
558
+ )
559
+ ),
560
+ Ne,
561
+ typeof t.count == "number" && a("span", { style: { color: "var(--text-dim, #777)", fontWeight: 400, fontSize: 10, flexShrink: 0 } }, `(${t.count})`),
562
+ a("span", { style: { flex: 1, minWidth: 0 } }),
563
+ ...le.map(Ce),
564
+ Se ? a(
565
+ "span",
566
+ { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
567
+ a("button", {
568
+ ref: ee,
569
+ type: "button",
570
+ title: g("position"),
571
+ "aria-label": g("position"),
572
+ "aria-haspopup": "menu",
573
+ "aria-expanded": p?.kind === "position" ? "true" : "false",
574
+ style: { ...Y, fontSize: 12 },
575
+ onClick: () => {
576
+ p?.kind === "position" ? v(null) : (A(null), v({ kind: "position", anchor: X ?? W }));
577
+ }
578
+ }, "⇱"),
579
+ p?.kind === "position" ? se : null
580
+ ) : null,
581
+ a(
582
+ "span",
583
+ { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
584
+ a("button", {
585
+ ref: H,
586
+ type: "button",
587
+ title: g("actions"),
588
+ "aria-label": g("actions"),
589
+ "aria-haspopup": "menu",
590
+ "aria-expanded": p?.kind === "main" ? "true" : "false",
591
+ style: { ...Y, fontSize: 12, fontWeight: 700 },
592
+ onClick: () => {
593
+ p?.kind === "main" ? v(null) : (A(null), v({ kind: "main", anchor: W }));
594
+ },
595
+ onKeyDown: (e) => {
596
+ e.key === "Escape" && p?.kind === "main" && v(null);
597
+ }
598
+ }, "⋮"),
599
+ p?.kind === "main" ? se : null
600
+ )
601
+ ),
602
+ (!k || Be) && a("div", { style: { flex: k ? "0 0 0" : 1, minHeight: 0, overflow: "hidden", display: k ? "none" : "flex", flexDirection: "column" } }, F)
603
+ );
604
+ }
605
+ function ye(t, n) {
606
+ try {
607
+ window.dispatchEvent(new CustomEvent(je, { detail: { key: t, delta: n } }));
608
+ } catch {
609
+ }
610
+ }
611
+ function it(t, n, i) {
612
+ try {
613
+ window.dispatchEvent(new CustomEvent(Fe, { detail: { key: t, target: n, before: i } }));
614
+ } catch {
615
+ }
616
+ }
617
+ let J = null;
618
+ if (typeof document < "u" && !document.getElementById("pi-dock-dnd-css"))
619
+ try {
620
+ const t = document.createElement("style");
621
+ t.id = "pi-dock-dnd-css", t.textContent = "[data-ext-dock-block][draggable=true] { cursor: grab; }.pi-dock-drop-before { box-shadow: inset 0 2px 0 var(--accent, #2563eb); }.pi-dock-drop-after { box-shadow: inset 0 -2px 0 var(--accent, #2563eb); }", document.head.appendChild(t);
622
+ } catch {
623
+ }
624
+ if (typeof document < "u" && !document.getElementById("piwe-dock-flash-css"))
625
+ try {
626
+ const t = document.createElement("style");
627
+ t.id = "piwe-dock-flash-css", t.textContent = "@keyframes piwe-dock-flash-kf { 0%,100% { box-shadow: none; } 30% { box-shadow: inset 0 0 0 2px var(--accent, #2563eb); } }.piwe-dock-flash { animation: piwe-dock-flash-kf 2s ease; }", document.head.appendChild(t);
628
+ } catch {
629
+ }
630
+ async function ke() {
631
+ const t = await fetch(ie("/api/extensions/aiti-acp-agent/agents"));
632
+ return t.ok ? t.json() : { agents: [], builtinNames: [] };
633
+ }
634
+ async function at(t) {
635
+ return (await fetch(ie("/api/extensions/aiti-acp-agent/agents"), {
636
+ method: "POST",
637
+ headers: { "Content-Type": "application/json" },
638
+ body: JSON.stringify(t)
639
+ })).ok;
640
+ }
641
+ async function rt(t) {
642
+ return (await fetch(ie(`/api/extensions/aiti-acp-agent/agents?name=${encodeURIComponent(t)}`), { method: "DELETE" })).ok;
643
+ }
644
+ function ct() {
645
+ return ae("float");
646
+ }
647
+ function dt() {
648
+ return ae("left");
649
+ }
650
+ function ut() {
651
+ return ae("right");
652
+ }
653
+ function ae(t) {
654
+ const n = xe(w), i = tt(w), d = t === "float" ? n === "floating" : t === "right" ? n === "docked:right-panel" : $e(n), u = t === "float", y = t === "left" ? w : void 0, [z, F] = m([]), [M, b] = m(/* @__PURE__ */ new Set()), [$, k] = m(!1), [N, V] = m(""), [C, p] = m(""), [v, x] = m(""), [O, W] = m(!1);
655
+ S(() => {
656
+ if (!d) return;
657
+ let s = !0;
658
+ return ke().then((Z) => {
659
+ s && (F(Z.agents ?? []), b(new Set(Z.builtinNames ?? [])), k(!0));
660
+ }).catch(() => {
661
+ }), () => {
662
+ s = !1;
663
+ };
664
+ }, [d]);
665
+ const H = () => ke().then((s) => {
666
+ F(s.agents ?? []), b(new Set(s.builtinNames ?? []));
667
+ }).catch(() => {
668
+ });
669
+ if (Xe(y, y ? { refresh: () => {
670
+ H();
671
+ } } : null), et(y, y ? { count: z.length } : null), !d) return null;
672
+ const X = async () => {
673
+ !N.trim() || !C.trim() || O || (W(!0), await at({
674
+ name: N.trim(),
675
+ bin: C.split(/\s+/)[0],
676
+ args: C.split(/\s+/).slice(1),
677
+ agentKey: v.trim() || void 0
678
+ }), V(""), p(""), x(""), W(!1), H());
679
+ }, ee = async (s) => {
680
+ await rt(s), H();
681
+ }, B = /* @__PURE__ */ T(Ve, { children: [
682
+ u && /* @__PURE__ */ T("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "10px 14px", borderBottom: "1px solid var(--border)", cursor: "grab", userSelect: "none" }, children: [
683
+ /* @__PURE__ */ f("span", { style: { color: "var(--text-muted)", display: "flex" }, children: /* @__PURE__ */ f(qe, { size: 15 }) }),
684
+ /* @__PURE__ */ f("span", { style: { fontSize: 13, fontWeight: 600, flex: 1 }, children: E("acp.manage.dialog.label") }),
685
+ /* @__PURE__ */ f(
686
+ "button",
687
+ {
688
+ title: E("acp.manage.close"),
689
+ "aria-label": "Close",
690
+ onClick: () => me(!1),
691
+ style: { background: "none", border: "none", color: "var(--text-muted)", cursor: "pointer", fontSize: 15, lineHeight: 1, padding: "2px 4px" },
692
+ children: "✕"
693
+ }
694
+ )
695
+ ] }),
696
+ /* @__PURE__ */ f("div", { style: { flex: 1, overflowY: "auto", padding: "8px 14px" }, children: $ ? z.length === 0 ? /* @__PURE__ */ f("div", { style: { padding: "16px 0", color: "var(--text-dim)", fontSize: 12, textAlign: "center" }, children: E("acp.manage.empty") }) : z.map((s) => /* @__PURE__ */ T("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 0", borderBottom: "1px solid var(--border)", fontSize: 12 }, children: [
697
+ /* @__PURE__ */ f("span", { style: { width: 7, height: 7, borderRadius: "50%", background: s.registered ? "var(--ok, #22c55e)" : "#ef444455", flexShrink: 0 } }),
698
+ /* @__PURE__ */ f("strong", { style: { minWidth: 100, color: "var(--text)" }, children: s.name }),
699
+ /* @__PURE__ */ f("span", { style: { color: "var(--text-muted)", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: s.bin + (s.args?.length ? " " + s.args.join(" ") : "") }),
700
+ s.agentKey && /* @__PURE__ */ f("span", { style: { fontSize: 10, color: "var(--accent)", border: "1px solid var(--accent)", borderRadius: 3, padding: "0 4px" }, children: s.agentKey }),
701
+ !M.has(s.name) && /* @__PURE__ */ f(
702
+ "button",
703
+ {
704
+ onClick: () => void ee(s.name),
705
+ title: E("acp.manage.remove", { name: s.name }),
706
+ "aria-label": E("acp.manage.remove", { name: s.name }),
707
+ style: { background: "none", border: "none", color: "var(--danger, #ef4444)", cursor: "pointer", fontSize: 13, padding: "0 2px" },
708
+ children: "✕"
709
+ }
710
+ )
711
+ ] }, s.name)) : /* @__PURE__ */ f("div", { style: { padding: "16px 0", color: "var(--text-dim)", fontSize: 12, textAlign: "center" }, children: "…" }) }),
712
+ /* @__PURE__ */ T("div", { style: { borderTop: "1px solid var(--border)", padding: "10px 14px" }, children: [
713
+ /* @__PURE__ */ T("div", { style: { display: "flex", gap: 5, flexWrap: "wrap", alignItems: "center" }, children: [
714
+ /* @__PURE__ */ f(
715
+ "input",
716
+ {
717
+ placeholder: "name",
718
+ value: N,
719
+ onChange: (s) => V(s.target.value),
720
+ style: { width: 90, padding: "4px 7px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg)", color: "var(--text)", fontSize: 11 }
721
+ }
722
+ ),
723
+ /* @__PURE__ */ f(
724
+ "input",
725
+ {
726
+ placeholder: "binary --args",
727
+ value: C,
728
+ onChange: (s) => p(s.target.value),
729
+ style: { flex: 1, minWidth: 120, padding: "4px 7px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg)", color: "var(--text)", fontSize: 11 }
730
+ }
731
+ ),
732
+ /* @__PURE__ */ f(
733
+ "input",
734
+ {
735
+ placeholder: "key",
736
+ value: v,
737
+ onChange: (s) => x(s.target.value),
738
+ style: { width: 80, padding: "4px 7px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg)", color: "var(--text)", fontSize: 11 }
739
+ }
740
+ ),
741
+ /* @__PURE__ */ f(
742
+ "button",
743
+ {
744
+ onClick: () => void X(),
745
+ disabled: O,
746
+ style: { padding: "4px 12px", border: "none", borderRadius: 5, background: "var(--accent)", color: "#fff", cursor: "pointer", fontSize: 11, fontWeight: 600 },
747
+ children: O ? "…" : E("acp.manage.add")
748
+ }
749
+ )
750
+ ] }),
751
+ /* @__PURE__ */ f("div", { style: { marginTop: 5, fontSize: 10, color: "var(--text-dim)" }, children: E("acp.manage.reloadHint") })
752
+ ] })
753
+ ] });
754
+ if (u)
755
+ return /* @__PURE__ */ f(
756
+ "div",
757
+ {
758
+ style: { position: "fixed", inset: 0, zIndex: 310, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" },
759
+ onClick: () => me(!1),
760
+ children: /* @__PURE__ */ f(
761
+ "div",
762
+ {
763
+ "data-ext-float": "1",
764
+ "data-ext-float-key": w,
765
+ "data-ext-float-dock": `${_(w)} right-panel`,
766
+ "data-ext-float-dock-default": _(w),
767
+ "data-ext-float-w": "420",
768
+ "data-ext-float-h": "360",
769
+ "data-ext-float-min-w": "320",
770
+ "data-ext-float-min-h": "220",
771
+ style: {
772
+ width: 420,
773
+ height: 360,
774
+ display: "flex",
775
+ flexDirection: "column",
776
+ background: "var(--bg-panel)",
777
+ border: "1px solid var(--border)",
778
+ borderRadius: 10,
779
+ color: "var(--text)",
780
+ boxShadow: "0 10px 40px rgba(0,0,0,0.35)",
781
+ overflow: "hidden"
782
+ },
783
+ onClick: (s) => s.stopPropagation(),
784
+ children: B
785
+ }
786
+ )
787
+ }
788
+ );
789
+ const A = /* @__PURE__ */ f("div", { style: { display: "flex", flexDirection: "column", minHeight: 0, height: "100%", color: "var(--text)", fontSize: 12 }, children: B }), L = [_(w), "right-panel"];
790
+ if (t === "right")
791
+ return /* @__PURE__ */ f(
792
+ ve,
793
+ {
794
+ itemKey: w,
795
+ zone: "right-panel",
796
+ title: E("acp.manage.dialog.label"),
797
+ chrome: "tab",
798
+ zones: L,
799
+ defaultZone: _(w),
800
+ children: A
801
+ }
802
+ );
803
+ const q = typeof i.count == "number" ? i.count : 0, U = [
804
+ { id: "refresh", title: E("acp.manage.refresh"), icon: /* @__PURE__ */ T("svg", { width: 12, height: 12, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
805
+ /* @__PURE__ */ f("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
806
+ /* @__PURE__ */ f("path", { d: "M3 3v5h5" })
807
+ ] }), visibility: "always", onClick: () => {
808
+ Qe(w, "refresh");
809
+ } }
810
+ ];
811
+ return /* @__PURE__ */ f(
812
+ ve,
813
+ {
814
+ itemKey: w,
815
+ title: E("acp.manage.dialog.label"),
816
+ icon: "plug",
817
+ chrome: "section",
818
+ kind: "dockable",
819
+ count: q > 0 ? q : void 0,
820
+ zones: L,
821
+ defaultZone: _(w),
822
+ headerActions: U,
823
+ children: A
824
+ }
825
+ );
826
+ }
827
+ export {
828
+ ct as AcpDialog,
829
+ dt as AcpDockLeft,
830
+ ut as AcpDockRight
831
+ };