@page-agent/ui 0.0.7

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,1072 @@
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode("._wrapper_1j0ct_1 {\n position: fixed;\n bottom: 100px;\n left: 50%;\n transform: translateX(-50%) translateY(20px);\n opacity: 0;\n z-index: 2147483642; /* 比 SimulatorMask 高一层 */\n box-sizing: border-box;\n\n overflow: visible;\n\n * {\n box-sizing: border-box;\n }\n\n --width: 360px;\n --height: 40px;\n --border-radius: 12px;\n\n --side-space: 12px; /* 控制栏两侧的间距 */\n --history-width: calc(var(--width) - var(--side-space) * 2);\n\n --color-1: rgb(57, 182, 255);\n --color-2: rgb(189, 69, 251);\n --color-3: rgb(255, 87, 51);\n --color-4: rgb(255, 214, 0);\n\n width: var(--width);\n height: var(--height);\n\n transition: all 0.3s ease-in-out;\n\n /* 响应式设计 */\n @media (max-width: 480px) {\n width: calc(100vw - 40px);\n --width: calc(100vw - 40px);\n }\n\n ._background_1j0ct_39 {\n position: absolute;\n inset: -2px -8px;\n border-radius: calc(var(--border-radius) + 4px);\n filter: blur(16px);\n overflow: hidden;\n /* mix-blend-mode: lighten; */\n /* display: none; */\n\n &::before {\n content: '';\n z-index: -1;\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n /* left: -100%; */\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-1),\n var(--color-2),\n var(--color-1)\n );\n animation: _mask-running_1j0ct_1 2s linear infinite;\n }\n &::after {\n content: '';\n z-index: -1;\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-2),\n var(--color-1),\n var(--color-2)\n );\n animation: _mask-running_1j0ct_1 2s linear infinite;\n animation-delay: 1s;\n }\n }\n}\n\n@keyframes _mask-running_1j0ct_1 {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(100%);\n }\n}\n\n/* 控制栏 */\n._header_1j0ct_99 {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n user-select: none;\n\n position: absolute;\n inset: 0;\n\n cursor: pointer;\n flex-shrink: 0; /* 防止 header 被压缩 */\n\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(10px);\n border-radius: var(--border-radius);\n background-clip: padding-box;\n\n box-shadow:\n 0 0 0px 2px rgba(255, 255, 255, 0.4),\n 0 0 5px 1px rgba(255, 255, 255, 0.3);\n\n ._statusSection_1j0ct_121 {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-height: 24px; /* 确保垂直居中 */\n\n ._indicator_1j0ct_128 {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.5);\n flex-shrink: 0;\n animation: none; /* 默认无动画 */\n\n /* 运行状态 - 有动画 */\n &._thinking_1j0ct_137 {\n background: rgb(57, 182, 255);\n animation: _pulse_1j0ct_1 0.8s ease-in-out infinite;\n }\n\n &._tool_executing_1j0ct_142 {\n background: rgb(189, 69, 251);\n animation: _pulse_1j0ct_1 0.6s ease-in-out infinite;\n }\n\n &._retry_1j0ct_147 {\n background: rgb(255, 214, 0);\n animation: _retryPulse_1j0ct_1 1s ease-in-out infinite;\n }\n\n /* 静止状态 - 无动画 */\n &._completed_1j0ct_153,\n &._input_1j0ct_154,\n &._output_1j0ct_155 {\n background: rgb(34, 197, 94);\n animation: none;\n }\n\n &._error_1j0ct_160 {\n background: rgb(239, 68, 68);\n animation: none;\n }\n }\n\n ._statusText_1j0ct_166 {\n color: white;\n font-size: 12px;\n line-height: 1;\n font-weight: 500;\n transition: all 0.3s ease-in-out;\n position: relative;\n overflow: hidden;\n display: flex;\n align-items: center;\n min-height: 24px; /* 确保垂直居中 */\n\n &._fadeOut_1j0ct_178 {\n animation: _statusTextFadeOut_1j0ct_1 0.3s ease forwards;\n }\n\n &._fadeIn_1j0ct_182 {\n animation: _statusTextFadeIn_1j0ct_1 0.3s ease forwards;\n }\n }\n }\n\n ._controls_1j0ct_188 {\n display: flex;\n align-items: center;\n gap: 4px;\n\n ._controlButton_1j0ct_193 {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n line-height: 1;\n\n &:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n }\n\n ._pauseButton_1j0ct_212 {\n font-weight: 600;\n &._paused_1j0ct_214 {\n background: rgba(34, 197, 94, 0.2); /* 绿色背景表示可以继续 */\n color: rgb(34, 197, 94);\n\n &:hover {\n background: rgba(34, 197, 94, 0.3);\n }\n }\n }\n\n ._stopButton_1j0ct_224 {\n background: rgba(239, 68, 68, 0.2);\n color: rgb(255, 41, 41);\n font-weight: 600;\n\n &:hover {\n background: rgba(239, 68, 68, 0.3);\n }\n }\n }\n}\n\n@keyframes _statusTextFadeIn_1j0ct_1 {\n 0% {\n opacity: 0;\n transform: translateY(5px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes _statusTextFadeOut_1j0ct_1 {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 100% {\n opacity: 0;\n transform: translateY(-5px);\n }\n}\n\n._historySectionWrapper_1j0ct_258 {\n position: absolute;\n width: var(--history-width);\n bottom: var(--height);\n left: var(--side-space);\n z-index: -2;\n\n padding-top: 0px;\n visibility: collapse;\n overflow: hidden;\n\n transition: all 0.2s;\n\n background: rgba(2, 0, 20, 0.5);\n /* background: rgba(186, 186, 186, 0.2); */\n backdrop-filter: blur(10px);\n\n text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);\n\n border-top-left-radius: calc(var(--border-radius) + 4px);\n border-top-right-radius: calc(var(--border-radius) + 4px);\n\n /* border: 2px solid rgba(255, 255, 255, 0.8); */\n border: 2px solid rgba(255, 255, 255, 0.4);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);\n\n /* @media (prefers-color-scheme: dark) {\n box-shadow:\n 0 8px 32px 0 rgba(0, 0, 0, 0.85),\n 0 2px 12px 0 rgba(57, 182, 255, 0.1);\n } */\n\n ._expanded_1j0ct_290 & {\n padding-top: 8px;\n visibility: visible;\n }\n\n ._historySection_1j0ct_258 {\n position: relative;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: none;\n max-height: 0;\n padding-inline: 8px;\n\n transition: max-height 0.2s;\n\n ._expanded_1j0ct_290 & {\n max-height: 400px;\n }\n\n ._historyItem_1j0ct_309 {\n /* backdrop-filter: blur(10px); */\n padding: 8px 10px;\n margin-bottom: 6px;\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));\n border-radius: 8px;\n border-left: 2px solid rgba(57, 182, 255, 0.5);\n font-size: 12px;\n color: white;\n /* color: black; */\n line-height: 1.3;\n position: relative;\n overflow: hidden;\n\n /* 微妙的内阴影 */\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, 0.1),\n 0 1px 3px rgba(0, 0, 0, 0.1);\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);\n }\n\n &:hover {\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));\n /* transform: translateY(-1px); */\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 2px 4px rgba(0, 0, 0, 0.15);\n }\n\n &:last-child {\n margin-bottom: 10px;\n }\n\n &._completed_1j0ct_153,\n &._input_1j0ct_154,\n &._output_1j0ct_155 {\n border-left-color: rgb(34, 197, 94);\n background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));\n }\n\n &._error_1j0ct_160 {\n border-left-color: rgb(239, 68, 68);\n background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));\n }\n\n &._retry_1j0ct_147 {\n border-left-color: rgb(255, 214, 0);\n background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(255, 214, 0, 0.05));\n }\n\n /* 突出显示 done 成功结果 */\n &._doneSuccess_1j0ct_368 {\n background: linear-gradient(\n 135deg,\n rgba(34, 197, 94, 0.25),\n rgba(34, 197, 94, 0.15),\n rgba(34, 197, 94, 0.08)\n );\n border: none;\n border-left: 4px solid rgb(34, 197, 94);\n box-shadow:\n 0 4px 12px rgba(34, 197, 94, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(34, 197, 94, 0.1);\n font-weight: 600;\n color: rgb(220, 252, 231);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent);\n }\n\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: -100%;\n width: 100%;\n height: 100%;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);\n animation: _shimmer_1j0ct_1 2s ease-in-out infinite;\n }\n\n ._historyContent_1j0ct_404 {\n ._statusIcon_1j0ct_405 {\n font-size: 16px;\n animation: _celebrate_1j0ct_1 0.8s ease-in-out;\n filter: drop-shadow(0 2px 4px rgba(34, 197, 94, 0.5));\n }\n }\n }\n\n /* 突出显示 done 失败结果 */\n &._doneError_1j0ct_414 {\n background: linear-gradient(\n 135deg,\n rgba(239, 68, 68, 0.25),\n rgba(239, 68, 68, 0.15),\n rgba(239, 68, 68, 0.08)\n );\n border: none;\n border-left: 4px solid rgb(239, 68, 68);\n box-shadow:\n 0 4px 12px rgba(239, 68, 68, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(239, 68, 68, 0.1);\n font-weight: 600;\n color: rgb(254, 226, 226);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.4), transparent);\n }\n\n ._historyContent_1j0ct_404 {\n ._statusIcon_1j0ct_405 {\n font-size: 16px;\n filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.5));\n }\n }\n }\n\n ._historyContent_1j0ct_404 {\n display: flex;\n align-items: center;\n gap: 8px;\n\n word-break: break-all;\n white-space: pre-wrap;\n\n /* overflow-x: auto; */\n\n ._statusIcon_1j0ct_405 {\n font-size: 12px;\n flex-shrink: 0;\n line-height: 1;\n transition: all 0.3s ease;\n }\n }\n\n ._historyMeta_1j0ct_465 {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n /* color: rgb(61, 61, 61); */\n margin-top: 8px;\n line-height: 1;\n }\n }\n }\n}\n\n/* 动画关键帧 - 更快的闪烁 */\n@keyframes _pulse_1j0ct_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n 50% {\n opacity: 0.4;\n transform: scale(1.3);\n }\n}\n\n/* 重试动画 - 旋转脉冲 */\n@keyframes _retryPulse_1j0ct_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1) rotate(0deg);\n }\n 25% {\n opacity: 0.6;\n transform: scale(1.2) rotate(90deg);\n }\n 50% {\n opacity: 0.8;\n transform: scale(1.1) rotate(180deg);\n }\n 75% {\n opacity: 0.6;\n transform: scale(1.2) rotate(270deg);\n }\n}\n\n/* 庆祝动画 */\n@keyframes _celebrate_1j0ct_1 {\n 0%,\n 100% {\n transform: scale(1);\n }\n 25% {\n transform: scale(1.2) rotate(-5deg);\n }\n 75% {\n transform: scale(1.2) rotate(5deg);\n }\n}\n\n/* done 卡片的光泽效果 */\n@keyframes _shimmer_1j0ct_1 {\n 0% {\n left: -100%;\n }\n 100% {\n left: 100%;\n }\n}\n\n/* 输入区域样式 */\n._inputSectionWrapper_1j0ct_535 {\n position: absolute;\n width: var(--history-width);\n top: var(--height);\n left: var(--side-space);\n z-index: -1;\n\n visibility: visible;\n overflow: hidden;\n\n height: 48px;\n\n transition: all 0.2s;\n\n background: rgba(186, 186, 186, 0.2);\n backdrop-filter: blur(10px);\n\n border-bottom-left-radius: calc(var(--border-radius) + 4px);\n border-bottom-right-radius: calc(var(--border-radius) + 4px);\n\n border: 2px solid rgba(255, 255, 255, 0.3);\n box-shadow: 0 1px 16px rgba(0, 0, 0, 0.4);\n\n &._hidden_1j0ct_558 {\n visibility: collapse;\n height: 0;\n }\n\n ._inputSection_1j0ct_535 {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px 8px;\n\n ._taskInput_1j0ct_569 {\n flex: 1;\n background: rgba(255, 255, 255, 0.4);\n border: 1px solid rgba(255, 255, 255, 0.3);\n border-radius: 10px;\n padding-inline: 10px;\n color: rgb(20, 20, 20);\n font-size: 12px;\n height: 28px;\n line-height: 1;\n outline: none;\n transition: all 0.2s ease;\n\n /* text-shadow: 0 0 2px rgba(255, 255, 255, 0.8); */\n\n /* border-color: rgba(57, 182, 255, 0.3); */\n\n &::placeholder {\n color: rgb(53, 53, 53);\n }\n\n &:focus {\n background: rgba(255, 255, 255, 0.8);\n border-color: rgba(57, 182, 255, 0.6);\n box-shadow: 0 0 0 2px rgba(57, 182, 255, 0.2);\n }\n }\n }\n}\n._wrapper_1oy2s_1 {\n position: fixed;\n inset: 0;\n z-index: 2147483641; /* 确保在所有元素之上,除了 panel */\n /* pointer-events: none; */\n cursor: not-allowed;\n overflow: hidden;\n\n display: none;\n}\n/* AI 光标样式 */\n._cursor_1vrf3_2 {\n position: absolute;\n width: var(--cursor-size, 75px);\n height: var(--cursor-size, 75px);\n pointer-events: none;\n z-index: 10000;\n transform: translate(-30%, -30%);\n\n animation: _cursor-enter_1vrf3_1 300ms ease-out forwards;\n}\n\n._cursorBorder_1vrf3_13 {\n position: absolute;\n inset: 0;\n background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));\n mask-image: url(https://img.alicdn.com/imgextra/i1/O1CN01YHLVYR1LvqWIyo5kH_!!6000000001362-2-tps-202-202.png);\n mask-size: 100% 100%;\n mask-repeat: no-repeat;\n animation: _cursor-breathe_1vrf3_1 2s ease-in-out infinite;\n}\n\n._cursorFilling_1vrf3_23 {\n position: absolute;\n inset: 0;\n background: url(https://img.alicdn.com/imgextra/i3/O1CN01JZOqOS1Tu1sIKbPLW_!!6000000002441-2-tps-202-202.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n}\n\n._cursorRipple_1vrf3_31 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n._cursor_1vrf3_2._clicking_1vrf3_37 ._cursorRipple_1vrf3_31::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n left: -30%;\n top: -30%;\n border: 4px solid rgba(57, 182, 255, 1);\n border-radius: 50%;\n animation: _cursor-ripple_1vrf3_1 300ms ease-out forwards;\n}\n\n/* 光标动画关键帧 */\n@keyframes _cursor-breathe_1vrf3_1 {\n 0%,\n 100% {\n transform: scale(1);\n opacity: 0.9;\n }\n 50% {\n transform: scale(1.05);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-rotate_1vrf3_1 {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n@keyframes _cursor-enter_1vrf3_1 {\n 0% {\n transform: translate(-30%, -30%) scale(0.5);\n opacity: 0;\n }\n 100% {\n transform: translate(-30%, -30%) scale(1);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-ripple_1vrf3_1 {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n}"));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
13
+ var __defProp = Object.defineProperty;
14
+ var __typeError = (msg) => {
15
+ throw TypeError(msg);
16
+ };
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
21
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
22
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
23
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
24
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
25
+ var _wrapper, _indicator, _statusText, _historySection, _expandButton, _pauseButton, _stopButton, _inputSection, _taskInput, _state, _isExpanded, _config, _i18n, _userAnswerResolver, _isWaitingForUserAnswer, _headerUpdateTimer, _pendingHeaderText, _isAnimating, _Panel_instances, toStepData_fn, getToolExecutingText_fn, getToolCompletedText_fn, updateInternal_fn, togglePause_fn, updatePauseButton_fn, stopAgent_fn, submitTask_fn, handleUserAnswer_fn, showInputArea_fn, hideInputArea_fn, shouldShowInputArea_fn, createWrapper_fn, setupEventListeners_fn, toggle_fn, expand_fn, collapse_fn, startHeaderUpdateLoop_fn, stopHeaderUpdateLoop_fn, checkAndUpdateHeader_fn, animateTextChange_fn, updateStatusIndicator_fn, updateHistory_fn, scrollToBottom_fn, createHistoryItem_fn, _cursor, _currentCursorX, _currentCursorY, _targetCursorX, _targetCursorY, _SimulatorMask_instances, createCursor_fn, moveCursorToTarget_fn;
26
+ import { Motion } from "ai-motion";
27
+ const _UIState = class _UIState {
28
+ steps = [];
29
+ currentStep = null;
30
+ status = "idle";
31
+ stepCounter = 0;
32
+ addStep(stepData) {
33
+ const step = {
34
+ id: this.generateId(),
35
+ stepNumber: ++this.stepCounter,
36
+ timestamp: /* @__PURE__ */ new Date(),
37
+ ...stepData
38
+ };
39
+ this.steps.push(step);
40
+ this.currentStep = step;
41
+ this.updateStatus(step.type);
42
+ return step;
43
+ }
44
+ updateCurrentStep(updates) {
45
+ if (!this.currentStep) return null;
46
+ Object.assign(this.currentStep, updates);
47
+ return this.currentStep;
48
+ }
49
+ getCurrentStep() {
50
+ return this.currentStep;
51
+ }
52
+ getAllSteps() {
53
+ return [...this.steps];
54
+ }
55
+ getStatus() {
56
+ return this.status;
57
+ }
58
+ reset() {
59
+ this.steps = [];
60
+ this.currentStep = null;
61
+ this.status = "idle";
62
+ this.stepCounter = 0;
63
+ }
64
+ updateStatus(stepType) {
65
+ switch (stepType) {
66
+ case "thinking":
67
+ case "tool_executing":
68
+ case "output":
69
+ case "input":
70
+ case "retry":
71
+ this.status = "running";
72
+ break;
73
+ case "completed":
74
+ this.status = "completed";
75
+ break;
76
+ case "error":
77
+ this.status = "error";
78
+ break;
79
+ }
80
+ }
81
+ generateId() {
82
+ return `step_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
83
+ }
84
+ };
85
+ __name(_UIState, "UIState");
86
+ let UIState = _UIState;
87
+ const enUS = {
88
+ ui: {
89
+ panel: {
90
+ ready: "Ready",
91
+ thinking: "Thinking...",
92
+ paused: "Paused",
93
+ taskInput: "Enter new task, describe steps in detail, press Enter to submit",
94
+ userAnswerPrompt: "Please answer the question above, press Enter to submit",
95
+ taskTerminated: "Task terminated",
96
+ taskCompleted: "Task completed",
97
+ continueExecution: "Continue execution",
98
+ userAnswer: "User answer: {{input}}",
99
+ question: "Question: {{question}}",
100
+ waitingPlaceholder: "Waiting for task to start...",
101
+ pause: "Pause",
102
+ continue: "Continue",
103
+ stop: "Stop",
104
+ expand: "Expand history",
105
+ collapse: "Collapse history",
106
+ step: "Step {{number}} · {{time}}{{duration}}"
107
+ },
108
+ tools: {
109
+ clicking: "Clicking element [{{index}}]...",
110
+ inputting: "Inputting text to element [{{index}}]...",
111
+ selecting: 'Selecting option "{{text}}"...',
112
+ scrolling: "Scrolling page...",
113
+ waiting: "Waiting {{seconds}} seconds...",
114
+ done: "Task done",
115
+ clicked: "🖱️ Clicked element [{{index}}]",
116
+ inputted: '⌨️ Inputted text "{{text}}"',
117
+ selected: '☑️ Selected option "{{text}}"',
118
+ scrolled: "🛞 Page scrolled",
119
+ waited: "⌛️ Wait completed",
120
+ executing: "Executing {{toolName}}...",
121
+ resultSuccess: "success",
122
+ resultFailure: "failed",
123
+ resultError: "error"
124
+ },
125
+ errors: {
126
+ elementNotFound: "No interactive element found at index {{index}}",
127
+ taskRequired: "Task description is required",
128
+ executionFailed: "Task execution failed",
129
+ notInputElement: "Element is not an input or textarea",
130
+ notSelectElement: "Element is not a select element",
131
+ optionNotFound: 'Option "{{text}}" not found'
132
+ }
133
+ }
134
+ };
135
+ const zhCN = {
136
+ ui: {
137
+ panel: {
138
+ ready: "准备就绪",
139
+ thinking: "正在思考...",
140
+ paused: "暂停中,稍后",
141
+ taskInput: "输入新任务,详细描述步骤,回车提交",
142
+ userAnswerPrompt: "请回答上面问题,回车提交",
143
+ taskTerminated: "任务已终止",
144
+ taskCompleted: "任务结束",
145
+ continueExecution: "继续执行",
146
+ userAnswer: "用户回答: {{input}}",
147
+ question: "询问: {{question}}",
148
+ waitingPlaceholder: "等待任务开始...",
149
+ pause: "暂停",
150
+ continue: "继续",
151
+ stop: "终止",
152
+ expand: "展开历史",
153
+ collapse: "收起历史",
154
+ step: "步骤 {{number}} · {{time}}{{duration}}"
155
+ },
156
+ tools: {
157
+ clicking: "正在点击元素 [{{index}}]...",
158
+ inputting: "正在输入文本到元素 [{{index}}]...",
159
+ selecting: '正在选择选项 "{{text}}"...',
160
+ scrolling: "正在滚动页面...",
161
+ waiting: "等待 {{seconds}} 秒...",
162
+ done: "结束任务",
163
+ clicked: "🖱️ 已点击元素 [{{index}}]",
164
+ inputted: '⌨️ 已输入文本 "{{text}}"',
165
+ selected: '☑️ 已选择选项 "{{text}}"',
166
+ scrolled: "🛞 页面滚动完成",
167
+ waited: "⌛️ 等待完成",
168
+ executing: "正在执行 {{toolName}}...",
169
+ resultSuccess: "成功",
170
+ resultFailure: "失败",
171
+ resultError: "错误"
172
+ },
173
+ errors: {
174
+ elementNotFound: "未找到索引为 {{index}} 的交互元素",
175
+ taskRequired: "任务描述不能为空",
176
+ executionFailed: "任务执行失败",
177
+ notInputElement: "元素不是输入框或文本域",
178
+ notSelectElement: "元素不是选择框",
179
+ optionNotFound: '未找到选项 "{{text}}"'
180
+ }
181
+ }
182
+ };
183
+ const locales = {
184
+ "en-US": enUS,
185
+ "zh-CN": zhCN
186
+ };
187
+ const _I18n = class _I18n {
188
+ language;
189
+ translations;
190
+ constructor(language = "en-US") {
191
+ this.language = language in locales ? language : "en-US";
192
+ this.translations = locales[language];
193
+ }
194
+ // 类型安全的翻译方法
195
+ t(key, params) {
196
+ const value = this.getNestedValue(this.translations, key);
197
+ if (!value) {
198
+ console.warn(`Translation key "${key}" not found for language "${this.language}"`);
199
+ return key;
200
+ }
201
+ if (params) {
202
+ return this.interpolate(value, params);
203
+ }
204
+ return value;
205
+ }
206
+ getNestedValue(obj, path) {
207
+ return path.split(".").reduce((current, key) => current?.[key], obj);
208
+ }
209
+ interpolate(template, params) {
210
+ return template.replace(/\{\{(\w+)\}\}/g, (match, key) => {
211
+ return params[key] != null ? params[key].toString() : match;
212
+ });
213
+ }
214
+ getLanguage() {
215
+ return this.language;
216
+ }
217
+ };
218
+ __name(_I18n, "I18n");
219
+ let I18n = _I18n;
220
+ function truncate(text, maxLength) {
221
+ if (text.length > maxLength) {
222
+ return text.substring(0, maxLength) + "...";
223
+ }
224
+ return text;
225
+ }
226
+ __name(truncate, "truncate");
227
+ const wrapper$1 = "_wrapper_1j0ct_1";
228
+ const background = "_background_1j0ct_39";
229
+ const header = "_header_1j0ct_99";
230
+ const pulse = "_pulse_1j0ct_1";
231
+ const retryPulse = "_retryPulse_1j0ct_1";
232
+ const statusTextFadeOut = "_statusTextFadeOut_1j0ct_1";
233
+ const statusTextFadeIn = "_statusTextFadeIn_1j0ct_1";
234
+ const statusSection = "_statusSection_1j0ct_121";
235
+ const indicator = "_indicator_1j0ct_128";
236
+ const thinking = "_thinking_1j0ct_137";
237
+ const tool_executing = "_tool_executing_1j0ct_142";
238
+ const retry = "_retry_1j0ct_147";
239
+ const completed = "_completed_1j0ct_153";
240
+ const input = "_input_1j0ct_154";
241
+ const output = "_output_1j0ct_155";
242
+ const error = "_error_1j0ct_160";
243
+ const statusText = "_statusText_1j0ct_166";
244
+ const fadeOut = "_fadeOut_1j0ct_178";
245
+ const fadeIn = "_fadeIn_1j0ct_182";
246
+ const controls = "_controls_1j0ct_188";
247
+ const controlButton = "_controlButton_1j0ct_193";
248
+ const pauseButton = "_pauseButton_1j0ct_212";
249
+ const paused = "_paused_1j0ct_214";
250
+ const stopButton = "_stopButton_1j0ct_224";
251
+ const historySectionWrapper = "_historySectionWrapper_1j0ct_258";
252
+ const shimmer = "_shimmer_1j0ct_1";
253
+ const celebrate = "_celebrate_1j0ct_1";
254
+ const expanded = "_expanded_1j0ct_290";
255
+ const historySection = "_historySection_1j0ct_258";
256
+ const historyItem = "_historyItem_1j0ct_309";
257
+ const doneSuccess = "_doneSuccess_1j0ct_368";
258
+ const historyContent = "_historyContent_1j0ct_404";
259
+ const statusIcon = "_statusIcon_1j0ct_405";
260
+ const doneError = "_doneError_1j0ct_414";
261
+ const historyMeta = "_historyMeta_1j0ct_465";
262
+ const inputSectionWrapper = "_inputSectionWrapper_1j0ct_535";
263
+ const hidden = "_hidden_1j0ct_558";
264
+ const inputSection = "_inputSection_1j0ct_535";
265
+ const taskInput = "_taskInput_1j0ct_569";
266
+ const styles$1 = {
267
+ wrapper: wrapper$1,
268
+ "mask-running": "_mask-running_1j0ct_1",
269
+ background,
270
+ header,
271
+ pulse,
272
+ retryPulse,
273
+ statusTextFadeOut,
274
+ statusTextFadeIn,
275
+ statusSection,
276
+ indicator,
277
+ thinking,
278
+ tool_executing,
279
+ retry,
280
+ completed,
281
+ input,
282
+ output,
283
+ error,
284
+ statusText,
285
+ fadeOut,
286
+ fadeIn,
287
+ controls,
288
+ controlButton,
289
+ pauseButton,
290
+ paused,
291
+ stopButton,
292
+ historySectionWrapper,
293
+ shimmer,
294
+ celebrate,
295
+ expanded,
296
+ historySection,
297
+ historyItem,
298
+ doneSuccess,
299
+ historyContent,
300
+ statusIcon,
301
+ doneError,
302
+ historyMeta,
303
+ inputSectionWrapper,
304
+ hidden,
305
+ inputSection,
306
+ taskInput
307
+ };
308
+ const _Panel = class _Panel {
309
+ constructor(config) {
310
+ __privateAdd(this, _Panel_instances);
311
+ __privateAdd(this, _wrapper);
312
+ __privateAdd(this, _indicator);
313
+ __privateAdd(this, _statusText);
314
+ __privateAdd(this, _historySection);
315
+ __privateAdd(this, _expandButton);
316
+ __privateAdd(this, _pauseButton);
317
+ __privateAdd(this, _stopButton);
318
+ __privateAdd(this, _inputSection);
319
+ __privateAdd(this, _taskInput);
320
+ __privateAdd(this, _state, new UIState());
321
+ __privateAdd(this, _isExpanded, false);
322
+ __privateAdd(this, _config);
323
+ __privateAdd(this, _i18n);
324
+ __privateAdd(this, _userAnswerResolver, null);
325
+ __privateAdd(this, _isWaitingForUserAnswer, false);
326
+ __privateAdd(this, _headerUpdateTimer, null);
327
+ __privateAdd(this, _pendingHeaderText, null);
328
+ __privateAdd(this, _isAnimating, false);
329
+ __privateSet(this, _config, config);
330
+ __privateSet(this, _i18n, new I18n(config.language ?? "en-US"));
331
+ __privateSet(this, _wrapper, __privateMethod(this, _Panel_instances, createWrapper_fn).call(this));
332
+ __privateSet(this, _indicator, __privateGet(this, _wrapper).querySelector(`.${styles$1.indicator}`));
333
+ __privateSet(this, _statusText, __privateGet(this, _wrapper).querySelector(`.${styles$1.statusText}`));
334
+ __privateSet(this, _historySection, __privateGet(this, _wrapper).querySelector(`.${styles$1.historySection}`));
335
+ __privateSet(this, _expandButton, __privateGet(this, _wrapper).querySelector(`.${styles$1.expandButton}`));
336
+ __privateSet(this, _pauseButton, __privateGet(this, _wrapper).querySelector(`.${styles$1.pauseButton}`));
337
+ __privateSet(this, _stopButton, __privateGet(this, _wrapper).querySelector(`.${styles$1.stopButton}`));
338
+ __privateSet(this, _inputSection, __privateGet(this, _wrapper).querySelector(`.${styles$1.inputSectionWrapper}`));
339
+ __privateSet(this, _taskInput, __privateGet(this, _wrapper).querySelector(`.${styles$1.taskInput}`));
340
+ __privateMethod(this, _Panel_instances, setupEventListeners_fn).call(this);
341
+ __privateMethod(this, _Panel_instances, startHeaderUpdateLoop_fn).call(this);
342
+ __privateMethod(this, _Panel_instances, showInputArea_fn).call(this);
343
+ }
344
+ get wrapper() {
345
+ return __privateGet(this, _wrapper);
346
+ }
347
+ /**
348
+ * Ask for user input
349
+ */
350
+ async askUser(question) {
351
+ return new Promise((resolve) => {
352
+ __privateSet(this, _isWaitingForUserAnswer, true);
353
+ __privateSet(this, _userAnswerResolver, resolve);
354
+ __privateMethod(this, _Panel_instances, updateInternal_fn).call(this, {
355
+ type: "output",
356
+ displayText: __privateGet(this, _i18n).t("ui.panel.question", { question })
357
+ });
358
+ if (!__privateGet(this, _isExpanded)) {
359
+ __privateMethod(this, _Panel_instances, expand_fn).call(this);
360
+ }
361
+ __privateMethod(this, _Panel_instances, showInputArea_fn).call(this, __privateGet(this, _i18n).t("ui.panel.userAnswerPrompt"));
362
+ });
363
+ }
364
+ // ========== Public control methods ==========
365
+ show() {
366
+ this.wrapper.style.display = "block";
367
+ void this.wrapper.offsetHeight;
368
+ this.wrapper.style.opacity = "1";
369
+ this.wrapper.style.transform = "translateX(-50%) translateY(0)";
370
+ }
371
+ hide() {
372
+ this.wrapper.style.opacity = "0";
373
+ this.wrapper.style.transform = "translateX(-50%) translateY(20px)";
374
+ this.wrapper.style.display = "none";
375
+ }
376
+ reset() {
377
+ __privateGet(this, _state).reset();
378
+ __privateGet(this, _statusText).textContent = __privateGet(this, _i18n).t("ui.panel.ready");
379
+ __privateMethod(this, _Panel_instances, updateStatusIndicator_fn).call(this, "thinking");
380
+ __privateMethod(this, _Panel_instances, updateHistory_fn).call(this);
381
+ __privateMethod(this, _Panel_instances, collapse_fn).call(this);
382
+ if (__privateGet(this, _config).getPaused()) {
383
+ __privateGet(this, _config).onPauseToggle();
384
+ }
385
+ __privateMethod(this, _Panel_instances, updatePauseButton_fn).call(this);
386
+ __privateSet(this, _isWaitingForUserAnswer, false);
387
+ __privateSet(this, _userAnswerResolver, null);
388
+ __privateMethod(this, _Panel_instances, showInputArea_fn).call(this);
389
+ }
390
+ expand() {
391
+ __privateMethod(this, _Panel_instances, expand_fn).call(this);
392
+ }
393
+ collapse() {
394
+ __privateMethod(this, _Panel_instances, collapse_fn).call(this);
395
+ }
396
+ /**
397
+ * Update panel with semantic data - i18n handled internally
398
+ */
399
+ update(data) {
400
+ const stepData = __privateMethod(this, _Panel_instances, toStepData_fn).call(this, data);
401
+ __privateMethod(this, _Panel_instances, updateInternal_fn).call(this, stepData);
402
+ }
403
+ /**
404
+ * Dispose panel
405
+ */
406
+ dispose() {
407
+ __privateSet(this, _isWaitingForUserAnswer, false);
408
+ __privateMethod(this, _Panel_instances, stopHeaderUpdateLoop_fn).call(this);
409
+ this.wrapper.remove();
410
+ }
411
+ };
412
+ _wrapper = new WeakMap();
413
+ _indicator = new WeakMap();
414
+ _statusText = new WeakMap();
415
+ _historySection = new WeakMap();
416
+ _expandButton = new WeakMap();
417
+ _pauseButton = new WeakMap();
418
+ _stopButton = new WeakMap();
419
+ _inputSection = new WeakMap();
420
+ _taskInput = new WeakMap();
421
+ _state = new WeakMap();
422
+ _isExpanded = new WeakMap();
423
+ _config = new WeakMap();
424
+ _i18n = new WeakMap();
425
+ _userAnswerResolver = new WeakMap();
426
+ _isWaitingForUserAnswer = new WeakMap();
427
+ _headerUpdateTimer = new WeakMap();
428
+ _pendingHeaderText = new WeakMap();
429
+ _isAnimating = new WeakMap();
430
+ _Panel_instances = new WeakSet();
431
+ // ========== Private methods ==========
432
+ /**
433
+ * Convert semantic update to step data with i18n
434
+ */
435
+ toStepData_fn = /* @__PURE__ */ __name(function(data) {
436
+ switch (data.type) {
437
+ case "thinking":
438
+ return { type: "thinking", displayText: data.text ?? __privateGet(this, _i18n).t("ui.panel.thinking") };
439
+ case "input":
440
+ return { type: "input", displayText: data.task };
441
+ case "question":
442
+ return {
443
+ type: "output",
444
+ displayText: __privateGet(this, _i18n).t("ui.panel.question", { question: data.question })
445
+ };
446
+ case "userAnswer":
447
+ return {
448
+ type: "input",
449
+ displayText: __privateGet(this, _i18n).t("ui.panel.userAnswer", { input: data.input })
450
+ };
451
+ case "retry":
452
+ return { type: "retry", displayText: `retry-ing (${data.current} / ${data.max})` };
453
+ case "error":
454
+ return { type: "error", displayText: data.message };
455
+ case "output":
456
+ return { type: "output", displayText: data.text };
457
+ case "completed":
458
+ return { type: "completed", displayText: __privateGet(this, _i18n).t("ui.panel.taskCompleted") };
459
+ case "toolExecuting":
460
+ return {
461
+ type: "tool_executing",
462
+ toolName: data.toolName,
463
+ toolArgs: data.args,
464
+ displayText: __privateMethod(this, _Panel_instances, getToolExecutingText_fn).call(this, data.toolName, data.args)
465
+ };
466
+ case "toolCompleted": {
467
+ const displayText = __privateMethod(this, _Panel_instances, getToolCompletedText_fn).call(this, data.toolName, data.args);
468
+ if (!displayText) return { type: "tool_executing", displayText: "" };
469
+ return {
470
+ type: "tool_executing",
471
+ toolName: data.toolName,
472
+ toolArgs: data.args,
473
+ toolResult: data.result,
474
+ displayText,
475
+ duration: data.duration
476
+ };
477
+ }
478
+ }
479
+ }, "#toStepData");
480
+ getToolExecutingText_fn = /* @__PURE__ */ __name(function(toolName, args) {
481
+ switch (toolName) {
482
+ case "click_element_by_index":
483
+ return __privateGet(this, _i18n).t("ui.tools.clicking", { index: args.index });
484
+ case "input_text":
485
+ return __privateGet(this, _i18n).t("ui.tools.inputting", { index: args.index });
486
+ case "select_dropdown_option":
487
+ return __privateGet(this, _i18n).t("ui.tools.selecting", { text: args.text });
488
+ case "scroll":
489
+ return __privateGet(this, _i18n).t("ui.tools.scrolling");
490
+ case "wait":
491
+ return __privateGet(this, _i18n).t("ui.tools.waiting", { seconds: args.seconds });
492
+ case "done":
493
+ return __privateGet(this, _i18n).t("ui.tools.done");
494
+ default:
495
+ return __privateGet(this, _i18n).t("ui.tools.executing", { toolName });
496
+ }
497
+ }, "#getToolExecutingText");
498
+ getToolCompletedText_fn = /* @__PURE__ */ __name(function(toolName, args) {
499
+ switch (toolName) {
500
+ case "click_element_by_index":
501
+ return __privateGet(this, _i18n).t("ui.tools.clicked", { index: args.index });
502
+ case "input_text":
503
+ return __privateGet(this, _i18n).t("ui.tools.inputted", { text: args.text });
504
+ case "select_dropdown_option":
505
+ return __privateGet(this, _i18n).t("ui.tools.selected", { text: args.text });
506
+ case "scroll":
507
+ return __privateGet(this, _i18n).t("ui.tools.scrolled");
508
+ case "wait":
509
+ return __privateGet(this, _i18n).t("ui.tools.waited");
510
+ case "done":
511
+ return null;
512
+ default:
513
+ return null;
514
+ }
515
+ }, "#getToolCompletedText");
516
+ /**
517
+ * Update status (internal)
518
+ */
519
+ updateInternal_fn = /* @__PURE__ */ __name(function(stepData) {
520
+ if (!stepData.displayText) return;
521
+ const step = __privateGet(this, _state).addStep(stepData);
522
+ const headerText = truncate(step.displayText, 20);
523
+ __privateSet(this, _pendingHeaderText, headerText);
524
+ __privateMethod(this, _Panel_instances, updateStatusIndicator_fn).call(this, step.type);
525
+ __privateMethod(this, _Panel_instances, updateHistory_fn).call(this);
526
+ if (step.type === "completed" || step.type === "error") {
527
+ if (!__privateGet(this, _isExpanded)) {
528
+ __privateMethod(this, _Panel_instances, expand_fn).call(this);
529
+ }
530
+ }
531
+ if (__privateMethod(this, _Panel_instances, shouldShowInputArea_fn).call(this)) {
532
+ __privateMethod(this, _Panel_instances, showInputArea_fn).call(this);
533
+ } else {
534
+ __privateMethod(this, _Panel_instances, hideInputArea_fn).call(this);
535
+ }
536
+ }, "#updateInternal");
537
+ /**
538
+ * Toggle pause state
539
+ */
540
+ togglePause_fn = /* @__PURE__ */ __name(function() {
541
+ const paused2 = __privateGet(this, _config).onPauseToggle();
542
+ __privateMethod(this, _Panel_instances, updatePauseButton_fn).call(this);
543
+ if (paused2) {
544
+ __privateGet(this, _statusText).textContent = __privateGet(this, _i18n).t("ui.panel.paused");
545
+ __privateMethod(this, _Panel_instances, updateStatusIndicator_fn).call(this, "thinking");
546
+ } else {
547
+ __privateGet(this, _statusText).textContent = __privateGet(this, _i18n).t("ui.panel.continueExecution");
548
+ __privateMethod(this, _Panel_instances, updateStatusIndicator_fn).call(this, "tool_executing");
549
+ }
550
+ }, "#togglePause");
551
+ /**
552
+ * Update pause button state
553
+ */
554
+ updatePauseButton_fn = /* @__PURE__ */ __name(function() {
555
+ const paused2 = __privateGet(this, _config).getPaused();
556
+ if (paused2) {
557
+ __privateGet(this, _pauseButton).textContent = "▶";
558
+ __privateGet(this, _pauseButton).title = __privateGet(this, _i18n).t("ui.panel.continue");
559
+ __privateGet(this, _pauseButton).classList.add(styles$1.paused);
560
+ } else {
561
+ __privateGet(this, _pauseButton).textContent = "⏸︎";
562
+ __privateGet(this, _pauseButton).title = __privateGet(this, _i18n).t("ui.panel.pause");
563
+ __privateGet(this, _pauseButton).classList.remove(styles$1.paused);
564
+ }
565
+ }, "#updatePauseButton");
566
+ /**
567
+ * Stop Agent
568
+ */
569
+ stopAgent_fn = /* @__PURE__ */ __name(function() {
570
+ __privateMethod(this, _Panel_instances, updateInternal_fn).call(this, {
571
+ type: "error",
572
+ displayText: __privateGet(this, _i18n).t("ui.panel.taskTerminated")
573
+ });
574
+ __privateGet(this, _config).onStop();
575
+ }, "#stopAgent");
576
+ /**
577
+ * Submit task
578
+ */
579
+ submitTask_fn = /* @__PURE__ */ __name(function() {
580
+ const input2 = __privateGet(this, _taskInput).value.trim();
581
+ if (!input2) return;
582
+ __privateMethod(this, _Panel_instances, hideInputArea_fn).call(this);
583
+ if (__privateGet(this, _isWaitingForUserAnswer)) {
584
+ __privateMethod(this, _Panel_instances, handleUserAnswer_fn).call(this, input2);
585
+ } else {
586
+ __privateGet(this, _config).onExecuteTask(input2);
587
+ }
588
+ }, "#submitTask");
589
+ /**
590
+ * Handle user answer
591
+ */
592
+ handleUserAnswer_fn = /* @__PURE__ */ __name(function(input2) {
593
+ __privateMethod(this, _Panel_instances, updateInternal_fn).call(this, {
594
+ type: "input",
595
+ displayText: __privateGet(this, _i18n).t("ui.panel.userAnswer", { input: input2 })
596
+ });
597
+ __privateSet(this, _isWaitingForUserAnswer, false);
598
+ if (__privateGet(this, _userAnswerResolver)) {
599
+ __privateGet(this, _userAnswerResolver).call(this, input2);
600
+ __privateSet(this, _userAnswerResolver, null);
601
+ }
602
+ }, "#handleUserAnswer");
603
+ /**
604
+ * Show input area
605
+ */
606
+ showInputArea_fn = /* @__PURE__ */ __name(function(placeholder) {
607
+ __privateGet(this, _taskInput).value = "";
608
+ __privateGet(this, _taskInput).placeholder = placeholder || __privateGet(this, _i18n).t("ui.panel.taskInput");
609
+ __privateGet(this, _inputSection).classList.remove(styles$1.hidden);
610
+ setTimeout(() => {
611
+ __privateGet(this, _taskInput).focus();
612
+ }, 100);
613
+ }, "#showInputArea");
614
+ /**
615
+ * Hide input area
616
+ */
617
+ hideInputArea_fn = /* @__PURE__ */ __name(function() {
618
+ __privateGet(this, _inputSection).classList.add(styles$1.hidden);
619
+ }, "#hideInputArea");
620
+ /**
621
+ * Check if input area should be shown
622
+ */
623
+ shouldShowInputArea_fn = /* @__PURE__ */ __name(function() {
624
+ if (__privateGet(this, _isWaitingForUserAnswer)) return true;
625
+ const steps = __privateGet(this, _state).getAllSteps();
626
+ if (steps.length === 0) {
627
+ return true;
628
+ }
629
+ const lastStep = steps[steps.length - 1];
630
+ return lastStep.type === "completed" || lastStep.type === "error";
631
+ }, "#shouldShowInputArea");
632
+ createWrapper_fn = /* @__PURE__ */ __name(function() {
633
+ const wrapper2 = document.createElement("div");
634
+ wrapper2.id = "page-agent-runtime_agent-panel";
635
+ wrapper2.className = `${styles$1.wrapper} ${styles$1.collapsed}`;
636
+ wrapper2.setAttribute("data-browser-use-ignore", "true");
637
+ wrapper2.innerHTML = `
638
+ <div class="${styles$1.background}"></div>
639
+ <div class="${styles$1.historySectionWrapper}">
640
+ <div class="${styles$1.historySection}">
641
+ ${__privateMethod(this, _Panel_instances, createHistoryItem_fn).call(this, {
642
+ id: "placeholder",
643
+ stepNumber: 0,
644
+ timestamp: /* @__PURE__ */ new Date(),
645
+ type: "thinking",
646
+ displayText: __privateGet(this, _i18n).t("ui.panel.waitingPlaceholder")
647
+ })}
648
+ </div>
649
+ </div>
650
+ <div class="${styles$1.header}">
651
+ <div class="${styles$1.statusSection}">
652
+ <div class="${styles$1.indicator} ${styles$1.thinking}"></div>
653
+ <div class="${styles$1.statusText}">${__privateGet(this, _i18n).t("ui.panel.ready")}</div>
654
+ </div>
655
+ <div class="${styles$1.controls}">
656
+ <button class="${styles$1.controlButton} ${styles$1.expandButton}" title="${__privateGet(this, _i18n).t("ui.panel.expand")}">
657
+
658
+ </button>
659
+ <button class="${styles$1.controlButton} ${styles$1.pauseButton}" title="${__privateGet(this, _i18n).t("ui.panel.pause")}">
660
+ ⏸︎
661
+ </button>
662
+ <button class="${styles$1.controlButton} ${styles$1.stopButton}" title="${__privateGet(this, _i18n).t("ui.panel.stop")}">
663
+ X
664
+ </button>
665
+ </div>
666
+ </div>
667
+ <div class="${styles$1.inputSectionWrapper} ${styles$1.hidden}">
668
+ <div class="${styles$1.inputSection}">
669
+ <input
670
+ type="text"
671
+ class="${styles$1.taskInput}"
672
+ maxlength="200"
673
+ />
674
+ </div>
675
+ </div>
676
+ `;
677
+ document.body.appendChild(wrapper2);
678
+ return wrapper2;
679
+ }, "#createWrapper");
680
+ setupEventListeners_fn = /* @__PURE__ */ __name(function() {
681
+ const header2 = this.wrapper.querySelector(`.${styles$1.header}`);
682
+ header2.addEventListener("click", (e) => {
683
+ if (e.target.closest(`.${styles$1.controlButton}`)) {
684
+ return;
685
+ }
686
+ __privateMethod(this, _Panel_instances, toggle_fn).call(this);
687
+ });
688
+ __privateGet(this, _expandButton).addEventListener("click", (e) => {
689
+ e.stopPropagation();
690
+ __privateMethod(this, _Panel_instances, toggle_fn).call(this);
691
+ });
692
+ __privateGet(this, _pauseButton).addEventListener("click", (e) => {
693
+ e.stopPropagation();
694
+ __privateMethod(this, _Panel_instances, togglePause_fn).call(this);
695
+ });
696
+ __privateGet(this, _stopButton).addEventListener("click", (e) => {
697
+ e.stopPropagation();
698
+ __privateMethod(this, _Panel_instances, stopAgent_fn).call(this);
699
+ });
700
+ __privateGet(this, _taskInput).addEventListener("keydown", (e) => {
701
+ if (e.isComposing) return;
702
+ if (e.key === "Enter") {
703
+ e.preventDefault();
704
+ __privateMethod(this, _Panel_instances, submitTask_fn).call(this);
705
+ }
706
+ });
707
+ __privateGet(this, _inputSection).addEventListener("click", (e) => {
708
+ e.stopPropagation();
709
+ });
710
+ }, "#setupEventListeners");
711
+ toggle_fn = /* @__PURE__ */ __name(function() {
712
+ if (__privateGet(this, _isExpanded)) {
713
+ __privateMethod(this, _Panel_instances, collapse_fn).call(this);
714
+ } else {
715
+ __privateMethod(this, _Panel_instances, expand_fn).call(this);
716
+ }
717
+ }, "#toggle");
718
+ expand_fn = /* @__PURE__ */ __name(function() {
719
+ __privateSet(this, _isExpanded, true);
720
+ this.wrapper.classList.remove(styles$1.collapsed);
721
+ this.wrapper.classList.add(styles$1.expanded);
722
+ __privateGet(this, _expandButton).textContent = "▲";
723
+ }, "#expand");
724
+ collapse_fn = /* @__PURE__ */ __name(function() {
725
+ __privateSet(this, _isExpanded, false);
726
+ this.wrapper.classList.remove(styles$1.expanded);
727
+ this.wrapper.classList.add(styles$1.collapsed);
728
+ __privateGet(this, _expandButton).textContent = "▼";
729
+ }, "#collapse");
730
+ /**
731
+ * Start periodic header update loop
732
+ */
733
+ startHeaderUpdateLoop_fn = /* @__PURE__ */ __name(function() {
734
+ __privateSet(this, _headerUpdateTimer, setInterval(() => {
735
+ __privateMethod(this, _Panel_instances, checkAndUpdateHeader_fn).call(this);
736
+ }, 450));
737
+ }, "#startHeaderUpdateLoop");
738
+ /**
739
+ * Stop periodic header update loop
740
+ */
741
+ stopHeaderUpdateLoop_fn = /* @__PURE__ */ __name(function() {
742
+ if (__privateGet(this, _headerUpdateTimer)) {
743
+ clearInterval(__privateGet(this, _headerUpdateTimer));
744
+ __privateSet(this, _headerUpdateTimer, null);
745
+ }
746
+ }, "#stopHeaderUpdateLoop");
747
+ /**
748
+ * Check if header needs update and trigger animation if not currently animating
749
+ */
750
+ checkAndUpdateHeader_fn = /* @__PURE__ */ __name(function() {
751
+ if (!__privateGet(this, _pendingHeaderText) || __privateGet(this, _isAnimating)) {
752
+ return;
753
+ }
754
+ if (__privateGet(this, _statusText).textContent === __privateGet(this, _pendingHeaderText)) {
755
+ __privateSet(this, _pendingHeaderText, null);
756
+ return;
757
+ }
758
+ const textToShow = __privateGet(this, _pendingHeaderText);
759
+ __privateSet(this, _pendingHeaderText, null);
760
+ __privateMethod(this, _Panel_instances, animateTextChange_fn).call(this, textToShow);
761
+ }, "#checkAndUpdateHeader");
762
+ /**
763
+ * Animate text change with fade out/in effect
764
+ */
765
+ animateTextChange_fn = /* @__PURE__ */ __name(function(newText) {
766
+ __privateSet(this, _isAnimating, true);
767
+ __privateGet(this, _statusText).classList.add(styles$1.fadeOut);
768
+ setTimeout(() => {
769
+ __privateGet(this, _statusText).textContent = newText;
770
+ __privateGet(this, _statusText).classList.remove(styles$1.fadeOut);
771
+ __privateGet(this, _statusText).classList.add(styles$1.fadeIn);
772
+ setTimeout(() => {
773
+ __privateGet(this, _statusText).classList.remove(styles$1.fadeIn);
774
+ __privateSet(this, _isAnimating, false);
775
+ }, 300);
776
+ }, 150);
777
+ }, "#animateTextChange");
778
+ updateStatusIndicator_fn = /* @__PURE__ */ __name(function(type) {
779
+ __privateGet(this, _indicator).className = styles$1.indicator;
780
+ __privateGet(this, _indicator).classList.add(styles$1[type]);
781
+ }, "#updateStatusIndicator");
782
+ updateHistory_fn = /* @__PURE__ */ __name(function() {
783
+ const steps = __privateGet(this, _state).getAllSteps();
784
+ __privateGet(this, _historySection).innerHTML = steps.map((step) => __privateMethod(this, _Panel_instances, createHistoryItem_fn).call(this, step)).join("");
785
+ __privateMethod(this, _Panel_instances, scrollToBottom_fn).call(this);
786
+ }, "#updateHistory");
787
+ scrollToBottom_fn = /* @__PURE__ */ __name(function() {
788
+ setTimeout(() => {
789
+ __privateGet(this, _historySection).scrollTop = __privateGet(this, _historySection).scrollHeight;
790
+ }, 0);
791
+ }, "#scrollToBottom");
792
+ createHistoryItem_fn = /* @__PURE__ */ __name(function(step) {
793
+ const time = step.timestamp.toLocaleTimeString("zh-CN", {
794
+ hour12: false,
795
+ hour: "2-digit",
796
+ minute: "2-digit",
797
+ second: "2-digit"
798
+ });
799
+ let typeClass = "";
800
+ let statusIcon2 = "";
801
+ if (step.type === "completed") {
802
+ if (step.toolName === "done") {
803
+ const failureKeyword = __privateGet(this, _i18n).t("ui.tools.resultFailure");
804
+ const errorKeyword = __privateGet(this, _i18n).t("ui.tools.resultError");
805
+ const isSuccess = !step.toolResult || !step.toolResult.includes(failureKeyword) && !step.toolResult.includes(errorKeyword);
806
+ typeClass = isSuccess ? styles$1.doneSuccess : styles$1.doneError;
807
+ statusIcon2 = isSuccess ? "🎉" : "❌";
808
+ } else {
809
+ typeClass = styles$1.completed;
810
+ statusIcon2 = "✅";
811
+ }
812
+ } else if (step.type === "error") {
813
+ typeClass = styles$1.error;
814
+ statusIcon2 = "❌";
815
+ } else if (step.type === "tool_executing") {
816
+ statusIcon2 = "⚙️";
817
+ } else if (step.type === "output") {
818
+ typeClass = styles$1.output;
819
+ statusIcon2 = "🤖";
820
+ } else if (step.type === "input") {
821
+ typeClass = styles$1.input;
822
+ statusIcon2 = "🎯";
823
+ } else if (step.type === "retry") {
824
+ typeClass = styles$1.retry;
825
+ statusIcon2 = "🔄";
826
+ } else {
827
+ statusIcon2 = "🧠";
828
+ }
829
+ const durationText = step.duration ? ` · ${step.duration}ms` : "";
830
+ const stepLabel = __privateGet(this, _i18n).t("ui.panel.step", {
831
+ number: step.stepNumber.toString(),
832
+ time,
833
+ duration: durationText || ""
834
+ // Explicitly pass empty string to replace template
835
+ });
836
+ return `
837
+ <div class="${styles$1.historyItem} ${typeClass}">
838
+ <div class="${styles$1.historyContent}">
839
+ <span class="${styles$1.statusIcon}">${statusIcon2}</span>
840
+ <span>${step.displayText}</span>
841
+ </div>
842
+ <div class="${styles$1.historyMeta}">
843
+ ${stepLabel}
844
+ </div>
845
+ </div>
846
+ `;
847
+ }, "#createHistoryItem");
848
+ __name(_Panel, "Panel");
849
+ let Panel = _Panel;
850
+ function hasDarkModeClass() {
851
+ const DFEAULT_DARK_MODE_CLASSES = ["dark", "dark-mode", "theme-dark", "night", "night-mode"];
852
+ const htmlElement = document.documentElement;
853
+ const bodyElement = document.body;
854
+ for (const className of DFEAULT_DARK_MODE_CLASSES) {
855
+ if (htmlElement.classList.contains(className) || bodyElement.classList.contains(className)) {
856
+ return true;
857
+ }
858
+ }
859
+ const darkThemeAttribute = htmlElement.getAttribute("data-theme");
860
+ if (darkThemeAttribute?.toLowerCase().includes("dark")) {
861
+ return true;
862
+ }
863
+ return false;
864
+ }
865
+ __name(hasDarkModeClass, "hasDarkModeClass");
866
+ function parseRgbColor(colorString) {
867
+ const rgbMatch = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(colorString);
868
+ if (!rgbMatch) {
869
+ return null;
870
+ }
871
+ return {
872
+ r: parseInt(rgbMatch[1]),
873
+ g: parseInt(rgbMatch[2]),
874
+ b: parseInt(rgbMatch[3])
875
+ };
876
+ }
877
+ __name(parseRgbColor, "parseRgbColor");
878
+ function isColorDark(colorString, threshold = 128) {
879
+ if (!colorString || colorString === "transparent" || colorString.startsWith("rgba(0, 0, 0, 0)")) {
880
+ return false;
881
+ }
882
+ const rgb = parseRgbColor(colorString);
883
+ if (!rgb) {
884
+ return false;
885
+ }
886
+ const luminance = 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;
887
+ return luminance < threshold;
888
+ }
889
+ __name(isColorDark, "isColorDark");
890
+ function isBackgroundDark() {
891
+ const htmlStyle = window.getComputedStyle(document.documentElement);
892
+ const bodyStyle = window.getComputedStyle(document.body);
893
+ const htmlBgColor = htmlStyle.backgroundColor;
894
+ const bodyBgColor = bodyStyle.backgroundColor;
895
+ if (isColorDark(bodyBgColor)) {
896
+ return true;
897
+ } else if (bodyBgColor === "transparent" || bodyBgColor.startsWith("rgba(0, 0, 0, 0)")) {
898
+ return isColorDark(htmlBgColor);
899
+ }
900
+ return false;
901
+ }
902
+ __name(isBackgroundDark, "isBackgroundDark");
903
+ function isPageDark() {
904
+ if (hasDarkModeClass()) {
905
+ return true;
906
+ }
907
+ if (isBackgroundDark()) {
908
+ return true;
909
+ }
910
+ return false;
911
+ }
912
+ __name(isPageDark, "isPageDark");
913
+ const wrapper = "_wrapper_1oy2s_1";
914
+ const styles = {
915
+ wrapper
916
+ };
917
+ const cursor = "_cursor_1vrf3_2";
918
+ const cursorBorder = "_cursorBorder_1vrf3_13";
919
+ const cursorFilling = "_cursorFilling_1vrf3_23";
920
+ const cursorRipple = "_cursorRipple_1vrf3_31";
921
+ const clicking = "_clicking_1vrf3_37";
922
+ const cursorStyles = {
923
+ cursor,
924
+ cursorBorder,
925
+ cursorFilling,
926
+ cursorRipple,
927
+ clicking
928
+ };
929
+ const _SimulatorMask = class _SimulatorMask {
930
+ constructor() {
931
+ __privateAdd(this, _SimulatorMask_instances);
932
+ __publicField(this, "wrapper", document.createElement("div"));
933
+ __publicField(this, "motion", new Motion({
934
+ mode: isPageDark() ? "dark" : "light",
935
+ styles: {
936
+ position: "absolute",
937
+ inset: "0"
938
+ }
939
+ }));
940
+ __privateAdd(this, _cursor, document.createElement("div"));
941
+ __privateAdd(this, _currentCursorX, 0);
942
+ __privateAdd(this, _currentCursorY, 0);
943
+ __privateAdd(this, _targetCursorX, 0);
944
+ __privateAdd(this, _targetCursorY, 0);
945
+ this.wrapper.id = "page-agent-runtime_simulator-mask";
946
+ this.wrapper.className = styles.wrapper;
947
+ this.wrapper.setAttribute("data-browser-use-ignore", "true");
948
+ this.wrapper.appendChild(this.motion.element);
949
+ this.motion.autoResize(this.wrapper);
950
+ this.wrapper.addEventListener("click", (e) => {
951
+ e.stopPropagation();
952
+ e.preventDefault();
953
+ });
954
+ this.wrapper.addEventListener("mousedown", (e) => {
955
+ e.stopPropagation();
956
+ e.preventDefault();
957
+ });
958
+ this.wrapper.addEventListener("mouseup", (e) => {
959
+ e.stopPropagation();
960
+ e.preventDefault();
961
+ });
962
+ this.wrapper.addEventListener("mousemove", (e) => {
963
+ e.stopPropagation();
964
+ e.preventDefault();
965
+ });
966
+ this.wrapper.addEventListener("wheel", (e) => {
967
+ e.stopPropagation();
968
+ e.preventDefault();
969
+ });
970
+ this.wrapper.addEventListener("keydown", (e) => {
971
+ e.stopPropagation();
972
+ e.preventDefault();
973
+ });
974
+ this.wrapper.addEventListener("keyup", (e) => {
975
+ e.stopPropagation();
976
+ e.preventDefault();
977
+ });
978
+ __privateMethod(this, _SimulatorMask_instances, createCursor_fn).call(this);
979
+ document.body.appendChild(this.wrapper);
980
+ __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this);
981
+ window.addEventListener("PageAgent::MovePointerTo", (event) => {
982
+ const { x, y } = event.detail;
983
+ this.setCursorPosition(x, y);
984
+ });
985
+ window.addEventListener("PageAgent::ClickPointer", (event) => {
986
+ this.triggerClickAnimation();
987
+ });
988
+ }
989
+ setCursorPosition(x, y) {
990
+ __privateSet(this, _targetCursorX, x);
991
+ __privateSet(this, _targetCursorY, y);
992
+ }
993
+ triggerClickAnimation() {
994
+ __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
995
+ void __privateGet(this, _cursor).offsetHeight;
996
+ __privateGet(this, _cursor).classList.add(cursorStyles.clicking);
997
+ }
998
+ show() {
999
+ this.motion.start();
1000
+ this.motion.fadeIn();
1001
+ this.wrapper.style.display = "block";
1002
+ __privateSet(this, _currentCursorX, window.innerWidth / 2);
1003
+ __privateSet(this, _currentCursorY, window.innerHeight / 2);
1004
+ __privateSet(this, _targetCursorX, __privateGet(this, _currentCursorX));
1005
+ __privateSet(this, _targetCursorY, __privateGet(this, _currentCursorY));
1006
+ __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
1007
+ __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
1008
+ }
1009
+ hide() {
1010
+ this.motion.fadeOut();
1011
+ this.motion.pause();
1012
+ __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
1013
+ setTimeout(() => {
1014
+ this.wrapper.style.display = "none";
1015
+ }, 800);
1016
+ }
1017
+ dispose() {
1018
+ this.motion.dispose();
1019
+ this.wrapper.remove();
1020
+ }
1021
+ };
1022
+ _cursor = new WeakMap();
1023
+ _currentCursorX = new WeakMap();
1024
+ _currentCursorY = new WeakMap();
1025
+ _targetCursorX = new WeakMap();
1026
+ _targetCursorY = new WeakMap();
1027
+ _SimulatorMask_instances = new WeakSet();
1028
+ createCursor_fn = /* @__PURE__ */ __name(function() {
1029
+ __privateGet(this, _cursor).className = cursorStyles.cursor;
1030
+ const rippleContainer = document.createElement("div");
1031
+ rippleContainer.className = cursorStyles.cursorRipple;
1032
+ __privateGet(this, _cursor).appendChild(rippleContainer);
1033
+ const fillingLayer = document.createElement("div");
1034
+ fillingLayer.className = cursorStyles.cursorFilling;
1035
+ __privateGet(this, _cursor).appendChild(fillingLayer);
1036
+ const borderLayer = document.createElement("div");
1037
+ borderLayer.className = cursorStyles.cursorBorder;
1038
+ __privateGet(this, _cursor).appendChild(borderLayer);
1039
+ this.wrapper.appendChild(__privateGet(this, _cursor));
1040
+ }, "#createCursor");
1041
+ moveCursorToTarget_fn = /* @__PURE__ */ __name(function() {
1042
+ const newX = __privateGet(this, _currentCursorX) + (__privateGet(this, _targetCursorX) - __privateGet(this, _currentCursorX)) * 0.2;
1043
+ const newY = __privateGet(this, _currentCursorY) + (__privateGet(this, _targetCursorY) - __privateGet(this, _currentCursorY)) * 0.2;
1044
+ const xDistance = Math.abs(newX - __privateGet(this, _targetCursorX));
1045
+ if (xDistance > 0) {
1046
+ if (xDistance < 2) {
1047
+ __privateSet(this, _currentCursorX, __privateGet(this, _targetCursorX));
1048
+ } else {
1049
+ __privateSet(this, _currentCursorX, newX);
1050
+ }
1051
+ __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
1052
+ }
1053
+ const yDistance = Math.abs(newY - __privateGet(this, _targetCursorY));
1054
+ if (yDistance > 0) {
1055
+ if (yDistance < 2) {
1056
+ __privateSet(this, _currentCursorY, __privateGet(this, _targetCursorY));
1057
+ } else {
1058
+ __privateSet(this, _currentCursorY, newY);
1059
+ }
1060
+ __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
1061
+ }
1062
+ requestAnimationFrame(() => __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this));
1063
+ }, "#moveCursorToTarget");
1064
+ __name(_SimulatorMask, "SimulatorMask");
1065
+ let SimulatorMask = _SimulatorMask;
1066
+ export {
1067
+ I18n,
1068
+ Panel,
1069
+ SimulatorMask,
1070
+ UIState
1071
+ };
1072
+ //# sourceMappingURL=page-agent-ui.js.map