@yu_robotics/remote-cli 1.0.0

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -0
  3. package/bin/remote-cli.js +2 -0
  4. package/dist/client/MessageHandler.d.ts +92 -0
  5. package/dist/client/MessageHandler.d.ts.map +1 -0
  6. package/dist/client/MessageHandler.js +496 -0
  7. package/dist/client/MessageHandler.js.map +1 -0
  8. package/dist/client/WebSocketClient.d.ts +109 -0
  9. package/dist/client/WebSocketClient.d.ts.map +1 -0
  10. package/dist/client/WebSocketClient.js +234 -0
  11. package/dist/client/WebSocketClient.js.map +1 -0
  12. package/dist/commands/config.d.ts +35 -0
  13. package/dist/commands/config.d.ts.map +1 -0
  14. package/dist/commands/config.js +195 -0
  15. package/dist/commands/config.js.map +1 -0
  16. package/dist/commands/init.d.ts +25 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/init.js +112 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/start.d.ts +20 -0
  21. package/dist/commands/start.d.ts.map +1 -0
  22. package/dist/commands/start.js +108 -0
  23. package/dist/commands/start.js.map +1 -0
  24. package/dist/commands/status.d.ts +37 -0
  25. package/dist/commands/status.d.ts.map +1 -0
  26. package/dist/commands/status.js +71 -0
  27. package/dist/commands/status.js.map +1 -0
  28. package/dist/commands/stop.d.ts +23 -0
  29. package/dist/commands/stop.d.ts.map +1 -0
  30. package/dist/commands/stop.js +52 -0
  31. package/dist/commands/stop.js.map +1 -0
  32. package/dist/config/ConfigManager.d.ts +109 -0
  33. package/dist/config/ConfigManager.d.ts.map +1 -0
  34. package/dist/config/ConfigManager.js +262 -0
  35. package/dist/config/ConfigManager.js.map +1 -0
  36. package/dist/executor/ClaudeExecutor.d.ts +89 -0
  37. package/dist/executor/ClaudeExecutor.d.ts.map +1 -0
  38. package/dist/executor/ClaudeExecutor.js +365 -0
  39. package/dist/executor/ClaudeExecutor.js.map +1 -0
  40. package/dist/executor/ClaudePersistentExecutor.d.ts +175 -0
  41. package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -0
  42. package/dist/executor/ClaudePersistentExecutor.js +958 -0
  43. package/dist/executor/ClaudePersistentExecutor.js.map +1 -0
  44. package/dist/executor/index.d.ts +20 -0
  45. package/dist/executor/index.d.ts.map +1 -0
  46. package/dist/executor/index.js +48 -0
  47. package/dist/executor/index.js.map +1 -0
  48. package/dist/hooks/ClaudeCodeHooks.d.ts +281 -0
  49. package/dist/hooks/ClaudeCodeHooks.d.ts.map +1 -0
  50. package/dist/hooks/ClaudeCodeHooks.js +350 -0
  51. package/dist/hooks/ClaudeCodeHooks.js.map +1 -0
  52. package/dist/hooks/FeishuNotificationAdapter.d.ts +87 -0
  53. package/dist/hooks/FeishuNotificationAdapter.d.ts.map +1 -0
  54. package/dist/hooks/FeishuNotificationAdapter.js +280 -0
  55. package/dist/hooks/FeishuNotificationAdapter.js.map +1 -0
  56. package/dist/hooks/index.d.ts +4 -0
  57. package/dist/hooks/index.d.ts.map +1 -0
  58. package/dist/hooks/index.js +10 -0
  59. package/dist/hooks/index.js.map +1 -0
  60. package/dist/index.d.ts +3 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +333 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/security/DirectoryGuard.d.ts +54 -0
  65. package/dist/security/DirectoryGuard.d.ts.map +1 -0
  66. package/dist/security/DirectoryGuard.js +143 -0
  67. package/dist/security/DirectoryGuard.js.map +1 -0
  68. package/dist/types/config.d.ts +46 -0
  69. package/dist/types/config.d.ts.map +1 -0
  70. package/dist/types/config.js +22 -0
  71. package/dist/types/config.js.map +1 -0
  72. package/dist/types/index.d.ts +110 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/dist/types/index.js +3 -0
  75. package/dist/types/index.js.map +1 -0
  76. package/dist/utils/FeishuMessageFormatter.d.ts +84 -0
  77. package/dist/utils/FeishuMessageFormatter.d.ts.map +1 -0
  78. package/dist/utils/FeishuMessageFormatter.js +395 -0
  79. package/dist/utils/FeishuMessageFormatter.js.map +1 -0
  80. package/dist/utils/stripAnsi.d.ts +21 -0
  81. package/dist/utils/stripAnsi.d.ts.map +1 -0
  82. package/dist/utils/stripAnsi.js +30 -0
  83. package/dist/utils/stripAnsi.js.map +1 -0
  84. package/package.json +63 -0
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.claudeCodeHooks = exports.ClaudeCodeHooks = exports.HookEventType = void 0;
4
+ const events_1 = require("events");
5
+ /**
6
+ * Hook event types
7
+ */
8
+ var HookEventType;
9
+ (function (HookEventType) {
10
+ // Authorization hooks
11
+ HookEventType["AUTHORIZATION_REQUIRED"] = "authorization:required";
12
+ HookEventType["AUTHORIZATION_GRANTED"] = "authorization:granted";
13
+ HookEventType["AUTHORIZATION_DENIED"] = "authorization:denied";
14
+ // Task lifecycle hooks
15
+ HookEventType["TASK_STARTED"] = "task:started";
16
+ HookEventType["TASK_COMPLETED"] = "task:completed";
17
+ HookEventType["TASK_FAILED"] = "task:failed";
18
+ HookEventType["TASK_ABORTED"] = "task:aborted";
19
+ // Execution hooks
20
+ HookEventType["TOOL_BEFORE_EXECUTION"] = "tool:beforeExecution";
21
+ HookEventType["TOOL_AFTER_EXECUTION"] = "tool:afterExecution";
22
+ HookEventType["PROGRESS_UPDATE"] = "progress:update";
23
+ // User interaction hooks
24
+ HookEventType["USER_INPUT_REQUIRED"] = "user:inputRequired";
25
+ HookEventType["CONFIRMATION_REQUIRED"] = "user:confirmationRequired";
26
+ })(HookEventType || (exports.HookEventType = HookEventType = {}));
27
+ /**
28
+ * Claude Code Hooks Manager
29
+ *
30
+ * Provides a centralized hook system for customizing Claude Code behavior
31
+ * and receiving notifications at key decision points.
32
+ */
33
+ class ClaudeCodeHooks extends events_1.EventEmitter {
34
+ authorizationHandler;
35
+ confirmationHandler;
36
+ userInputHandler;
37
+ // Stored authorization decisions for caching
38
+ authorizationCache = new Map();
39
+ constructor() {
40
+ super();
41
+ // Increase max listeners to support multiple adapter instances in tests
42
+ this.setMaxListeners(100);
43
+ // Debug: Log all emitted events
44
+ const originalEmit = this.emit.bind(this);
45
+ this.emit = function (event, ...args) {
46
+ const timestamp = new Date().toISOString();
47
+ const eventName = String(event);
48
+ // Don't log full context objects to keep logs readable
49
+ if (args.length > 0) {
50
+ const summary = args.map(arg => {
51
+ if (typeof arg === 'object' && arg !== null) {
52
+ if ('taskId' in arg)
53
+ return `{taskId: ${arg.taskId}}`;
54
+ if ('toolName' in arg)
55
+ return `{toolName: ${arg.toolName}}`;
56
+ if ('actionType' in arg)
57
+ return `{actionType: ${arg.actionType}}`;
58
+ return '{object}';
59
+ }
60
+ return arg;
61
+ });
62
+ console.log(`[ClaudeCodeHooks ${timestamp}] Event emitted: ${eventName}`, summary);
63
+ }
64
+ else {
65
+ console.log(`[ClaudeCodeHooks ${timestamp}] Event emitted: ${eventName}`);
66
+ }
67
+ return originalEmit(event, ...args);
68
+ };
69
+ }
70
+ /**
71
+ * Register authorization handler
72
+ * Called when an operation requires user authorization
73
+ */
74
+ onAuthorizationRequired(handler) {
75
+ this.authorizationHandler = handler;
76
+ }
77
+ /**
78
+ * Register task started handler
79
+ */
80
+ onTaskStarted(handler) {
81
+ this.on(HookEventType.TASK_STARTED, handler);
82
+ }
83
+ /**
84
+ * Register task completed handler
85
+ */
86
+ onTaskCompleted(handler) {
87
+ this.on(HookEventType.TASK_COMPLETED, handler);
88
+ }
89
+ /**
90
+ * Register task failed handler
91
+ */
92
+ onTaskFailed(handler) {
93
+ this.on(HookEventType.TASK_FAILED, handler);
94
+ }
95
+ /**
96
+ * Register task aborted handler
97
+ */
98
+ onTaskAborted(handler) {
99
+ this.on(HookEventType.TASK_ABORTED, handler);
100
+ }
101
+ /**
102
+ * Register tool before execution handler
103
+ * Return false to prevent execution
104
+ */
105
+ onToolBeforeExecution(handler) {
106
+ this.on(HookEventType.TOOL_BEFORE_EXECUTION, handler);
107
+ }
108
+ /**
109
+ * Register tool after execution handler
110
+ */
111
+ onToolAfterExecution(handler) {
112
+ this.on(HookEventType.TOOL_AFTER_EXECUTION, handler);
113
+ }
114
+ /**
115
+ * Register progress handler
116
+ */
117
+ onProgress(handler) {
118
+ this.on(HookEventType.PROGRESS_UPDATE, handler);
119
+ }
120
+ /**
121
+ * Register confirmation handler
122
+ */
123
+ onConfirmationRequired(handler) {
124
+ this.confirmationHandler = handler;
125
+ }
126
+ /**
127
+ * Register user input handler
128
+ */
129
+ onUserInputRequired(handler) {
130
+ this.userInputHandler = handler;
131
+ }
132
+ /**
133
+ * Request authorization for an operation
134
+ */
135
+ async requestAuthorization(context) {
136
+ // Debug: Log authorization request
137
+ const timestamp = new Date().toISOString();
138
+ console.log(`[ClaudeCodeHooks ${timestamp}] Authorization requested:`, {
139
+ actionType: context.actionType,
140
+ description: context.description,
141
+ riskLevel: context.riskLevel,
142
+ details: context.details,
143
+ });
144
+ // Check cache first
145
+ const cacheKey = this.getAuthorizationCacheKey(context);
146
+ const cached = this.authorizationCache.get(cacheKey);
147
+ if (cached && cached.expiresAt > Date.now()) {
148
+ console.log(`[ClaudeCodeHooks ${timestamp}] Using cached authorization decision: granted=${cached.decision.granted}`);
149
+ this.emit(HookEventType.AUTHORIZATION_GRANTED, context, cached.decision);
150
+ return cached.decision;
151
+ }
152
+ // No handler registered, default to deny for safety
153
+ if (!this.authorizationHandler) {
154
+ console.log(`[ClaudeCodeHooks ${timestamp}] No authorization handler registered, denying by default`);
155
+ const denyDecision = {
156
+ granted: false,
157
+ reason: 'No authorization handler registered',
158
+ };
159
+ this.emit(HookEventType.AUTHORIZATION_DENIED, context, denyDecision);
160
+ return denyDecision;
161
+ }
162
+ try {
163
+ console.log(`[ClaudeCodeHooks ${timestamp}] Calling authorization handler...`);
164
+ const decision = await this.authorizationHandler(context);
165
+ console.log(`[ClaudeCodeHooks ${timestamp}] Authorization handler returned: granted=${decision.granted}, reason=${decision.reason || 'none'}`);
166
+ // Emit event
167
+ if (decision.granted) {
168
+ this.emit(HookEventType.AUTHORIZATION_GRANTED, context, decision);
169
+ }
170
+ else {
171
+ this.emit(HookEventType.AUTHORIZATION_DENIED, context, decision);
172
+ }
173
+ // Cache decision if requested
174
+ if (decision.remember && decision.granted) {
175
+ const duration = decision.rememberDuration || 0;
176
+ this.authorizationCache.set(cacheKey, {
177
+ decision,
178
+ expiresAt: duration > 0 ? Date.now() + duration : Number.MAX_SAFE_INTEGER,
179
+ });
180
+ console.log(`[ClaudeCodeHooks ${timestamp}] Cached authorization decision for key: ${cacheKey}`);
181
+ }
182
+ return decision;
183
+ }
184
+ catch (error) {
185
+ // Handler threw error, deny for safety
186
+ console.error(`[ClaudeCodeHooks ${timestamp}] Authorization handler threw error:`, error);
187
+ const denyDecision = {
188
+ granted: false,
189
+ reason: `Authorization handler error: ${error instanceof Error ? error.message : 'Unknown error'}`,
190
+ };
191
+ this.emit(HookEventType.AUTHORIZATION_DENIED, context, denyDecision);
192
+ return denyDecision;
193
+ }
194
+ }
195
+ /**
196
+ * Notify task started
197
+ */
198
+ async notifyTaskStarted(context) {
199
+ this.emit(HookEventType.TASK_STARTED, context);
200
+ }
201
+ /**
202
+ * Notify task completed
203
+ */
204
+ async notifyTaskCompleted(context, result) {
205
+ this.emit(HookEventType.TASK_COMPLETED, context, result);
206
+ }
207
+ /**
208
+ * Notify task failed
209
+ */
210
+ async notifyTaskFailed(context, error) {
211
+ this.emit(HookEventType.TASK_FAILED, context, error);
212
+ }
213
+ /**
214
+ * Notify task aborted
215
+ */
216
+ async notifyTaskAborted(context, reason) {
217
+ this.emit(HookEventType.TASK_ABORTED, context, reason);
218
+ }
219
+ /**
220
+ * Check if tool execution is allowed
221
+ * Returns false to prevent execution
222
+ */
223
+ async checkToolExecution(context) {
224
+ const timestamp = new Date().toISOString();
225
+ console.log(`[ClaudeCodeHooks ${timestamp}] Checking tool execution:`, {
226
+ toolName: context.toolName,
227
+ params: context.params,
228
+ taskId: context.taskId,
229
+ });
230
+ const handlers = this.listeners(HookEventType.TOOL_BEFORE_EXECUTION);
231
+ console.log(`[ClaudeCodeHooks ${timestamp}] Found ${handlers.length} tool before execution handlers`);
232
+ for (const handler of handlers) {
233
+ try {
234
+ const result = await handler(context);
235
+ console.log(`[ClaudeCodeHooks ${timestamp}] Handler returned:`, result);
236
+ // If any handler returns false, prevent execution
237
+ if (result === false) {
238
+ console.log(`[ClaudeCodeHooks ${timestamp}] Tool execution blocked by handler`);
239
+ return false;
240
+ }
241
+ }
242
+ catch (error) {
243
+ // Handler error, log but continue
244
+ console.error('[ClaudeCodeHooks] Tool before execution handler error:', error);
245
+ }
246
+ }
247
+ console.log(`[ClaudeCodeHooks ${timestamp}] Tool execution allowed`);
248
+ return true;
249
+ }
250
+ /**
251
+ * Notify tool after execution
252
+ */
253
+ async notifyToolExecuted(context, result) {
254
+ this.emit(HookEventType.TOOL_AFTER_EXECUTION, context, result);
255
+ }
256
+ /**
257
+ * Update progress
258
+ */
259
+ async updateProgress(update) {
260
+ this.emit(HookEventType.PROGRESS_UPDATE, update);
261
+ }
262
+ /**
263
+ * Request user confirmation
264
+ */
265
+ async requestConfirmation(request) {
266
+ const timestamp = new Date().toISOString();
267
+ console.log(`[ClaudeCodeHooks ${timestamp}] Confirmation requested:`, {
268
+ prompt: request.prompt,
269
+ description: request.description,
270
+ defaultValue: request.defaultValue,
271
+ timeout: request.timeout,
272
+ });
273
+ if (!this.confirmationHandler) {
274
+ // Default to false if no handler
275
+ console.log(`[ClaudeCodeHooks ${timestamp}] No confirmation handler registered, returning false`);
276
+ return false;
277
+ }
278
+ try {
279
+ console.log(`[ClaudeCodeHooks ${timestamp}] Calling confirmation handler...`);
280
+ const result = await this.confirmationHandler(request);
281
+ console.log(`[ClaudeCodeHooks ${timestamp}] Confirmation handler returned: ${result}`);
282
+ return result;
283
+ }
284
+ catch (error) {
285
+ console.error('[ClaudeCodeHooks] Confirmation handler error:', error);
286
+ return false;
287
+ }
288
+ }
289
+ /**
290
+ * Request user input
291
+ */
292
+ async requestUserInput(request) {
293
+ const timestamp = new Date().toISOString();
294
+ console.log(`[ClaudeCodeHooks ${timestamp}] User input requested:`, {
295
+ prompt: request.prompt,
296
+ type: request.type,
297
+ timeout: request.timeout,
298
+ });
299
+ if (!this.userInputHandler) {
300
+ // Default to null if no handler
301
+ console.log(`[ClaudeCodeHooks ${timestamp}] No user input handler registered, returning null`);
302
+ return null;
303
+ }
304
+ try {
305
+ console.log(`[ClaudeCodeHooks ${timestamp}] Calling user input handler...`);
306
+ const result = await this.userInputHandler(request);
307
+ console.log(`[ClaudeCodeHooks ${timestamp}] User input handler returned: ${result ? '<input received>' : 'null'}`);
308
+ return result;
309
+ }
310
+ catch (error) {
311
+ console.error('[ClaudeCodeHooks] User input handler error:', error);
312
+ return null;
313
+ }
314
+ }
315
+ /**
316
+ * Clear authorization cache
317
+ */
318
+ clearAuthorizationCache() {
319
+ this.authorizationCache.clear();
320
+ }
321
+ /**
322
+ * Remove all handlers
323
+ */
324
+ removeAllHandlers() {
325
+ this.authorizationHandler = undefined;
326
+ this.confirmationHandler = undefined;
327
+ this.userInputHandler = undefined;
328
+ this.authorizationCache.clear();
329
+ this.removeAllListeners();
330
+ }
331
+ /**
332
+ * Generate cache key for authorization
333
+ */
334
+ getAuthorizationCacheKey(context) {
335
+ // Create a key based on action type and relevant details
336
+ const parts = [context.actionType];
337
+ if (context.details.filePath) {
338
+ parts.push(context.details.filePath);
339
+ }
340
+ if (context.details.command) {
341
+ // Normalize command by removing arguments for broader matching
342
+ parts.push(context.details.command.split(' ')[0]);
343
+ }
344
+ return parts.join(':');
345
+ }
346
+ }
347
+ exports.ClaudeCodeHooks = ClaudeCodeHooks;
348
+ // Export singleton instance
349
+ exports.claudeCodeHooks = new ClaudeCodeHooks();
350
+ //# sourceMappingURL=ClaudeCodeHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaudeCodeHooks.js","sour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AI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACK,wBAAwB,CAAC,OAA6B;QAC5D,yDAAyD;QACzD,MAAM,KAAK,GAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE7C,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC5B,+DAA+D;YAC/D,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AA3VD,0CA2VC;AAED,4BAA4B;AACf,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { WebSocketClient } from '../client/WebSocketClient';
2
+ /**
3
+ * Feishu Notification Adapter
4
+ *
5
+ * Registers hook handlers to send notifications to Feishu via WebSocket.
6
+ * This allows users to be notified when:
7
+ * - Tasks start/complete/fail/abort
8
+ * - Authorization is required
9
+ * - Progress updates occur
10
+ * - Tools are executed
11
+ */
12
+ export declare class FeishuNotificationAdapter {
13
+ private wsClient;
14
+ private currentOpenId?;
15
+ private enabledNotifications;
16
+ private registeredHandlers;
17
+ /**
18
+ * Create a new Feishu notification adapter
19
+ * @param wsClient WebSocket client for sending notifications
20
+ * @param options Configuration options
21
+ */
22
+ constructor(wsClient: WebSocketClient, options?: {
23
+ enabledNotifications?: string[];
24
+ });
25
+ /**
26
+ * Set the current OpenID for message routing
27
+ */
28
+ setCurrentOpenId(openId: string | undefined): void;
29
+ /**
30
+ * Register all hook handlers
31
+ */
32
+ register(): void;
33
+ /**
34
+ * Unregister all hook handlers
35
+ */
36
+ unregister(): void;
37
+ /**
38
+ * Register a handler and store its reference for cleanup
39
+ */
40
+ private registerHandler;
41
+ /**
42
+ * Register task lifecycle handlers
43
+ */
44
+ private registerTaskHandlers;
45
+ /**
46
+ * Register authorization handler
47
+ */
48
+ private registerAuthorizationHandler;
49
+ /**
50
+ * Register tool execution handlers
51
+ */
52
+ private registerToolExecutionHandlers;
53
+ /**
54
+ * Register progress handler
55
+ */
56
+ private registerProgressHandler;
57
+ /**
58
+ * Register user input handler
59
+ * When Claude requests user input, send notification via Feishu
60
+ */
61
+ private registerUserInputHandler;
62
+ /**
63
+ * Send notification via WebSocket
64
+ */
65
+ private sendNotification;
66
+ /**
67
+ * Get emoji for risk level
68
+ */
69
+ private getRiskLevelEmoji;
70
+ /**
71
+ * Render a simple progress bar
72
+ */
73
+ private renderProgressBar;
74
+ /**
75
+ * Enable specific notification types
76
+ */
77
+ enableNotification(type: string): void;
78
+ /**
79
+ * Disable specific notification types
80
+ */
81
+ disableNotification(type: string): void;
82
+ /**
83
+ * Get list of enabled notifications
84
+ */
85
+ getEnabledNotifications(): string[];
86
+ }
87
+ //# sourceMappingURL=FeishuNotificationAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeishuNotificationAdapter.d.ts","sourceRoot":"","sources":["../../src/hooks/FeishuNotificationAdapter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;;;;;;;;GASG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,oBAAoB,CAAc;IAE1C,OAAO,CAAC,kBAAkB,CAAkE;IAE5F;;;;OAIG;gBAED,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE;QACP,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC5B;IAYR;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIlD;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;OAEG;IACH,UAAU,IAAI,IAAI;IAQlB;;OAEG;IAEH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgD5B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAyDpC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAoBrC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAY/B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAItC;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE;CAGpC"}