botbrowser-mcp 0.1.3 → 0.1.5

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,211 @@
1
+ let manager;
2
+ export function setManager(m) {
3
+ manager = m;
4
+ }
5
+ async function getActivePage() {
6
+ const context = manager.getActiveContext();
7
+ if (!context) {
8
+ throw new Error('没有活跃的浏览器实例,请先使用 launch_browser 启动');
9
+ }
10
+ const pages = context.pages();
11
+ if (pages.length === 0) {
12
+ return await context.newPage();
13
+ }
14
+ return pages[pages.length - 1];
15
+ }
16
+ export const browserTools = {
17
+ browser_navigate: {
18
+ description: '导航到指定URL',
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {
22
+ url: { type: 'string', description: 'URL地址' },
23
+ },
24
+ required: ['url'],
25
+ },
26
+ handler: async (args) => {
27
+ const page = await getActivePage();
28
+ await page.goto(args.url);
29
+ return {
30
+ content: [{
31
+ type: 'text',
32
+ text: `已导航到 ${args.url}`,
33
+ }],
34
+ };
35
+ },
36
+ },
37
+ browser_click: {
38
+ description: '点击页面元素',
39
+ inputSchema: {
40
+ type: 'object',
41
+ properties: {
42
+ selector: { type: 'string', description: 'CSS选择器或文本选择器' },
43
+ },
44
+ required: ['selector'],
45
+ },
46
+ handler: async (args) => {
47
+ const page = await getActivePage();
48
+ await page.click(args.selector);
49
+ return {
50
+ content: [{
51
+ type: 'text',
52
+ text: `已点击元素: ${args.selector}`,
53
+ }],
54
+ };
55
+ },
56
+ },
57
+ browser_fill: {
58
+ description: '填充输入框',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ selector: { type: 'string', description: 'CSS选择器' },
63
+ value: { type: 'string', description: '填充的值' },
64
+ },
65
+ required: ['selector', 'value'],
66
+ },
67
+ handler: async (args) => {
68
+ const page = await getActivePage();
69
+ await page.fill(args.selector, args.value);
70
+ return {
71
+ content: [{
72
+ type: 'text',
73
+ text: `已填充 ${args.selector}`,
74
+ }],
75
+ };
76
+ },
77
+ },
78
+ browser_screenshot: {
79
+ description: '截取页面截图',
80
+ inputSchema: {
81
+ type: 'object',
82
+ properties: {
83
+ path: { type: 'string', description: '保存路径' },
84
+ fullPage: { type: 'boolean', description: '是否截取整个页面' },
85
+ },
86
+ required: ['path'],
87
+ },
88
+ handler: async (args) => {
89
+ const page = await getActivePage();
90
+ await page.screenshot({
91
+ path: args.path,
92
+ fullPage: args.fullPage || false
93
+ });
94
+ return {
95
+ content: [{
96
+ type: 'text',
97
+ text: `截图已保存到 ${args.path}`,
98
+ }],
99
+ };
100
+ },
101
+ },
102
+ browser_get_text: {
103
+ description: '获取元素文本内容',
104
+ inputSchema: {
105
+ type: 'object',
106
+ properties: {
107
+ selector: { type: 'string', description: 'CSS选择器' },
108
+ },
109
+ required: ['selector'],
110
+ },
111
+ handler: async (args) => {
112
+ const page = await getActivePage();
113
+ const text = await page.textContent(args.selector);
114
+ return {
115
+ content: [{
116
+ type: 'text',
117
+ text: text || '',
118
+ }],
119
+ };
120
+ },
121
+ },
122
+ browser_wait: {
123
+ description: '等待指定时间或元素出现',
124
+ inputSchema: {
125
+ type: 'object',
126
+ properties: {
127
+ selector: { type: 'string', description: 'CSS选择器(等待元素出现)' },
128
+ timeout: { type: 'number', description: '超时时间(毫秒)' },
129
+ },
130
+ },
131
+ handler: async (args) => {
132
+ const page = await getActivePage();
133
+ if (args.selector) {
134
+ await page.waitForSelector(args.selector, { timeout: args.timeout || 30000 });
135
+ return {
136
+ content: [{
137
+ type: 'text',
138
+ text: `元素 ${args.selector} 已出现`,
139
+ }],
140
+ };
141
+ }
142
+ else if (args.timeout) {
143
+ await page.waitForTimeout(args.timeout);
144
+ return {
145
+ content: [{
146
+ type: 'text',
147
+ text: `已等待 ${args.timeout}ms`,
148
+ }],
149
+ };
150
+ }
151
+ throw new Error('必须提供 selector 或 timeout');
152
+ },
153
+ },
154
+ browser_evaluate: {
155
+ description: '在页面中执行JavaScript代码',
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ script: { type: 'string', description: 'JavaScript代码' },
160
+ },
161
+ required: ['script'],
162
+ },
163
+ handler: async (args) => {
164
+ const page = await getActivePage();
165
+ const result = await page.evaluate(args.script);
166
+ return {
167
+ content: [{
168
+ type: 'text',
169
+ text: JSON.stringify(result, null, 2),
170
+ }],
171
+ };
172
+ },
173
+ },
174
+ browser_new_page: {
175
+ description: '打开新标签页',
176
+ inputSchema: {
177
+ type: 'object',
178
+ properties: {},
179
+ },
180
+ handler: async () => {
181
+ const context = manager.getActiveContext();
182
+ if (!context) {
183
+ throw new Error('没有活跃的浏览器实例');
184
+ }
185
+ await context.newPage();
186
+ return {
187
+ content: [{
188
+ type: 'text',
189
+ text: '已打开新标签页',
190
+ }],
191
+ };
192
+ },
193
+ },
194
+ browser_get_url: {
195
+ description: '获取当前页面URL',
196
+ inputSchema: {
197
+ type: 'object',
198
+ properties: {},
199
+ },
200
+ handler: async () => {
201
+ const page = await getActivePage();
202
+ return {
203
+ content: [{
204
+ type: 'text',
205
+ text: page.url(),
206
+ }],
207
+ };
208
+ },
209
+ },
210
+ };
211
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/tools/browser.ts"],"names":[],"mappings":"AAOA,IAAI,OAA0B,CAAC;AAE/B,MAAM,UAAU,UAAU,CAAC,CAAoB;IAC7C,OAAO,GAAG,CAAC,CAAC;AACd,CAAC;AAED,KAAK,UAAU,aAAa;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE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AAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,SAAS;qBAChB,CAAC;aACH,CAAC;QACJ,CAAC;KACF;IAED,eAAe,EAAE;QACf,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,IAAI,GAAG,MAAM,aAAa,EAAE,CAAC;YACnC,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;qBACjB,CAAC;aACH,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * 浏览器实例管理工具
3
+ */
4
+ import { PlaywrightManager } from '../playwright/manager.js';
5
+ export declare function setManager(m: PlaywrightManager): void;
6
+ export declare const instanceTools: {
7
+ launch_browser: {
8
+ description: string;
9
+ inputSchema: {
10
+ type: string;
11
+ properties: {
12
+ profile_alias: {
13
+ type: string;
14
+ description: string;
15
+ };
16
+ account_id: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ };
21
+ required: string[];
22
+ };
23
+ handler: (args: any) => Promise<{
24
+ content: {
25
+ type: string;
26
+ text: string;
27
+ }[];
28
+ }>;
29
+ };
30
+ list_browser_instances: {
31
+ description: string;
32
+ inputSchema: {
33
+ type: string;
34
+ properties: {};
35
+ };
36
+ handler: () => Promise<{
37
+ content: {
38
+ type: string;
39
+ text: string;
40
+ }[];
41
+ }>;
42
+ };
43
+ switch_browser_instance: {
44
+ description: string;
45
+ inputSchema: {
46
+ type: string;
47
+ properties: {
48
+ instance_id: {
49
+ type: string;
50
+ description: string;
51
+ };
52
+ };
53
+ required: string[];
54
+ };
55
+ handler: (args: any) => Promise<{
56
+ content: {
57
+ type: string;
58
+ text: string;
59
+ }[];
60
+ }>;
61
+ };
62
+ stop_browser_instance: {
63
+ description: string;
64
+ inputSchema: {
65
+ type: string;
66
+ properties: {
67
+ instance_id: {
68
+ type: string;
69
+ description: string;
70
+ };
71
+ };
72
+ required: string[];
73
+ };
74
+ handler: (args: any) => Promise<{
75
+ content: {
76
+ type: string;
77
+ text: string;
78
+ }[];
79
+ }>;
80
+ };
81
+ cleanup_orphaned_instances: {
82
+ description: string;
83
+ inputSchema: {
84
+ type: string;
85
+ properties: {};
86
+ };
87
+ handler: () => Promise<{
88
+ content: {
89
+ type: string;
90
+ text: string;
91
+ }[];
92
+ }>;
93
+ };
94
+ };
@@ -0,0 +1,97 @@
1
+ let manager;
2
+ export function setManager(m) {
3
+ manager = m;
4
+ }
5
+ export const instanceTools = {
6
+ launch_browser: {
7
+ description: '启动浏览器实例',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ profile_alias: { type: 'string', description: '浏览器配置别名' },
12
+ account_id: { type: 'number', description: '使用的账号ID(可选)' },
13
+ },
14
+ required: ['profile_alias'],
15
+ },
16
+ handler: async (args) => {
17
+ const id = await manager.launchInstance(args.profile_alias, args.account_id);
18
+ return {
19
+ content: [{
20
+ type: 'text',
21
+ text: `浏览器实例 ${id} 启动成功`,
22
+ }],
23
+ };
24
+ },
25
+ },
26
+ list_browser_instances: {
27
+ description: '列出所有运行中的浏览器实例',
28
+ inputSchema: {
29
+ type: 'object',
30
+ properties: {},
31
+ },
32
+ handler: async () => {
33
+ const instances = manager.listInstances();
34
+ return {
35
+ content: [{
36
+ type: 'text',
37
+ text: JSON.stringify(instances, null, 2),
38
+ }],
39
+ };
40
+ },
41
+ },
42
+ switch_browser_instance: {
43
+ description: '切换活跃的浏览器实例(后续浏览器操作将在此实例执行)',
44
+ inputSchema: {
45
+ type: 'object',
46
+ properties: {
47
+ instance_id: { type: 'number', description: '实例ID' },
48
+ },
49
+ required: ['instance_id'],
50
+ },
51
+ handler: async (args) => {
52
+ await manager.switchActive(args.instance_id);
53
+ return {
54
+ content: [{
55
+ type: 'text',
56
+ text: `已切换到实例 ${args.instance_id}`,
57
+ }],
58
+ };
59
+ },
60
+ },
61
+ stop_browser_instance: {
62
+ description: '停止浏览器实例',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ instance_id: { type: 'number', description: '实例ID' },
67
+ },
68
+ required: ['instance_id'],
69
+ },
70
+ handler: async (args) => {
71
+ await manager.stopInstance(args.instance_id);
72
+ return {
73
+ content: [{
74
+ type: 'text',
75
+ text: `实例 ${args.instance_id} 已停止`,
76
+ }],
77
+ };
78
+ },
79
+ },
80
+ cleanup_orphaned_instances: {
81
+ description: '清理孤立的实例记录(数据库有记录但实例已不存在)',
82
+ inputSchema: {
83
+ type: 'object',
84
+ properties: {},
85
+ },
86
+ handler: async () => {
87
+ const count = await manager.cleanupOrphaned();
88
+ return {
89
+ content: [{
90
+ type: 'text',
91
+ text: `清理了 ${count} 个孤立实例记录`,
92
+ }],
93
+ };
94
+ },
95
+ },
96
+ };
97
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/tools/instance.ts"],"names":[],"mappings":"AAKA,IAAI,OAA0B,CAAC;AAE/B,MAAM,UAAU,UAAU,CAAC,CAAoB;IAC7C,OAAO,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,cAAc,EAAE;QACd,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE;gBACzD,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;aAC3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,EAAE;QACrB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;aACrD;YACD,QAAQ,EAAE,CAAC,aAAa,CAAC;SAC1B;QACD,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;YAC3B,MAAM,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,MAAM,IAAI,CAAC,WAAW,MAAM;qBACnC,CAAC;aACH,CAAC;QACJ,CAAC;KACF;IAED,0BAA0B,EAAE;QAC1B,WAAW,EAAE,0BAA0B;QACvC,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAC9C,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO,KAAK,UAAU;qBAC7B,CAAC;aACH,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,128 @@
1
+ export declare const profileTools: {
2
+ list_browser_profiles: {
3
+ description: string;
4
+ inputSchema: {
5
+ type: string;
6
+ properties: {};
7
+ };
8
+ handler: () => Promise<{
9
+ content: {
10
+ type: string;
11
+ text: string;
12
+ }[];
13
+ }>;
14
+ };
15
+ create_browser_profile: {
16
+ description: string;
17
+ inputSchema: {
18
+ type: string;
19
+ properties: {
20
+ alias: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ executable_path: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ fingerprint_path: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ storage_state_path: {
33
+ type: string;
34
+ description: string;
35
+ };
36
+ description: {
37
+ type: string;
38
+ description: string;
39
+ };
40
+ proxy_server: {
41
+ type: string;
42
+ description: string;
43
+ };
44
+ proxy_username: {
45
+ type: string;
46
+ description: string;
47
+ };
48
+ proxy_password: {
49
+ type: string;
50
+ description: string;
51
+ };
52
+ proxy_bypass: {
53
+ type: string;
54
+ description: string;
55
+ };
56
+ };
57
+ required: string[];
58
+ };
59
+ handler: (args: any) => Promise<{
60
+ content: {
61
+ type: string;
62
+ text: string;
63
+ }[];
64
+ }>;
65
+ };
66
+ update_browser_profile: {
67
+ description: string;
68
+ inputSchema: {
69
+ type: string;
70
+ properties: {
71
+ alias: {
72
+ type: string;
73
+ description: string;
74
+ };
75
+ executable_path: {
76
+ type: string;
77
+ };
78
+ fingerprint_path: {
79
+ type: string;
80
+ };
81
+ storage_state_path: {
82
+ type: string;
83
+ };
84
+ description: {
85
+ type: string;
86
+ };
87
+ proxy_server: {
88
+ type: string;
89
+ };
90
+ proxy_username: {
91
+ type: string;
92
+ };
93
+ proxy_password: {
94
+ type: string;
95
+ };
96
+ proxy_bypass: {
97
+ type: string;
98
+ };
99
+ };
100
+ required: string[];
101
+ };
102
+ handler: (args: any) => Promise<{
103
+ content: {
104
+ type: string;
105
+ text: string;
106
+ }[];
107
+ }>;
108
+ };
109
+ delete_browser_profile: {
110
+ description: string;
111
+ inputSchema: {
112
+ type: string;
113
+ properties: {
114
+ alias: {
115
+ type: string;
116
+ description: string;
117
+ };
118
+ };
119
+ required: string[];
120
+ };
121
+ handler: (args: any) => Promise<{
122
+ content: {
123
+ type: string;
124
+ text: string;
125
+ }[];
126
+ }>;
127
+ };
128
+ };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * 浏览器配置管理工具
3
+ */
4
+ import { ProfileRepository } from '../db/repositories/profile.js';
5
+ const profileRepo = new ProfileRepository();
6
+ export const profileTools = {
7
+ list_browser_profiles: {
8
+ description: '列出所有浏览器配置',
9
+ inputSchema: {
10
+ type: 'object',
11
+ properties: {},
12
+ },
13
+ handler: async () => {
14
+ const profiles = profileRepo.getAll();
15
+ return {
16
+ content: [{
17
+ type: 'text',
18
+ text: JSON.stringify(profiles, null, 2),
19
+ }],
20
+ };
21
+ },
22
+ },
23
+ create_browser_profile: {
24
+ description: '创建新的浏览器配置',
25
+ inputSchema: {
26
+ type: 'object',
27
+ properties: {
28
+ alias: { type: 'string', description: '配置别名(唯一标识)' },
29
+ executable_path: { type: 'string', description: 'Chrome 可执行文件路径' },
30
+ fingerprint_path: { type: 'string', description: '防指纹配置文件路径' },
31
+ storage_state_path: { type: 'string', description: 'Cookie/LocalStorage 存储路径' },
32
+ description: { type: 'string', description: '配置描述' },
33
+ proxy_server: { type: 'string', description: '代理服务器地址' },
34
+ proxy_username: { type: 'string', description: '代理用户名' },
35
+ proxy_password: { type: 'string', description: '代理密码' },
36
+ proxy_bypass: { type: 'string', description: '代理绕过列表' },
37
+ },
38
+ required: ['alias', 'executable_path', 'fingerprint_path', 'storage_state_path'],
39
+ },
40
+ handler: async (args) => {
41
+ profileRepo.create(args);
42
+ return {
43
+ content: [{
44
+ type: 'text',
45
+ text: `浏览器配置 "${args.alias}" 创建成功`,
46
+ }],
47
+ };
48
+ },
49
+ },
50
+ update_browser_profile: {
51
+ description: '更新浏览器配置',
52
+ inputSchema: {
53
+ type: 'object',
54
+ properties: {
55
+ alias: { type: 'string', description: '配置别名' },
56
+ executable_path: { type: 'string' },
57
+ fingerprint_path: { type: 'string' },
58
+ storage_state_path: { type: 'string' },
59
+ description: { type: 'string' },
60
+ proxy_server: { type: 'string' },
61
+ proxy_username: { type: 'string' },
62
+ proxy_password: { type: 'string' },
63
+ proxy_bypass: { type: 'string' },
64
+ },
65
+ required: ['alias'],
66
+ },
67
+ handler: async (args) => {
68
+ const { alias, ...updates } = args;
69
+ profileRepo.update(alias, updates);
70
+ return {
71
+ content: [{
72
+ type: 'text',
73
+ text: `浏览器配置 "${alias}" 更新成功`,
74
+ }],
75
+ };
76
+ },
77
+ },
78
+ delete_browser_profile: {
79
+ description: '删除浏览器配置',
80
+ inputSchema: {
81
+ type: 'object',
82
+ properties: {
83
+ alias: { type: 'string', description: '配置别名' },
84
+ },
85
+ required: ['alias'],
86
+ },
87
+ handler: async (args) => {
88
+ profileRepo.delete(args.alias);
89
+ return {
90
+ content: [{
91
+ type: 'text',
92
+ text: `浏览器配置 "${args.alias}" 删除成功`,
93
+ }],
94
+ };
95
+ },
96
+ },
97
+ };
98
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/tools/profile.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAkB,MAAM,+BAA+B,CAAC;AAElF,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,qBAAqB,EAAE;QACrB,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;YACtC,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;qBACxC,CAAC;aACH,CAAC;QACJ,CAAC;KACF;IAED,sBAAsB,EAAE;QACtB,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE;gBACpD,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;gBAClE,gBAAgB,EAAE,EAAE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