@agentick/angular 0.0.1 → 0.1.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentick/angular",
3
- "version": "0.0.1",
3
+ "version": "0.1.9",
4
4
  "description": "Angular services and utilities for Agentick applications",
5
5
  "files": [
6
6
  "dist",
@@ -16,8 +16,8 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@agentick/client": "0.0.1",
20
- "@agentick/shared": "0.0.1"
19
+ "@agentick/client": "0.1.9",
20
+ "@agentick/shared": "0.1.9"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@angular/core": "^19.0.0",
@@ -30,6 +30,11 @@
30
30
  "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0",
31
31
  "rxjs": "^7.0.0"
32
32
  },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/agenticklabs/agentick.git",
36
+ "directory": "packages/angular"
37
+ },
33
38
  "scripts": {
34
39
  "build": "tsc -p tsconfig.build.json",
35
40
  "dev": "tsc --watch",
@@ -1,210 +0,0 @@
1
- /**
2
- * TentickleService - Modern Angular service for Tentickle.
3
- *
4
- * Uses Angular signals for reactive state management with RxJS interop.
5
- *
6
- * @module @tentickle/angular/service
7
- */
8
- import { InjectionToken, type OnDestroy } from "@angular/core";
9
- import { Observable } from "rxjs";
10
- import { type TentickleClient, type ConnectionState, type StreamEvent, type StreamingTextState, type SessionStreamEvent, type SessionAccessor, type ClientExecutionHandle } from "@tentickle/client";
11
- import type { TentickleConfig } from "./types";
12
- /**
13
- * Injection token for Tentickle configuration.
14
- */
15
- export declare const TENTICKLE_CONFIG: InjectionToken<TentickleConfig>;
16
- /**
17
- * Provides TentickleService with configuration at component level.
18
- *
19
- * Use this to create isolated service instances for different components,
20
- * each with their own connection and state.
21
- *
22
- * @example Multiple agents in one app
23
- * ```typescript
24
- * // Each component gets its own TentickleService instance
25
- *
26
- * @Component({
27
- * selector: 'app-support-chat',
28
- * providers: [provideTentickle({ baseUrl: '/api/support-agent' })],
29
- * template: `<div>{{ tentickle.text() }}</div>`,
30
- * })
31
- * export class SupportChatComponent {
32
- * tentickle = inject(TentickleService);
33
- * }
34
- *
35
- * @Component({
36
- * selector: 'app-sales-chat',
37
- * providers: [provideTentickle({ baseUrl: '/api/sales-agent' })],
38
- * template: `<div>{{ tentickle.text() }}</div>`,
39
- * })
40
- * export class SalesChatComponent {
41
- * tentickle = inject(TentickleService);
42
- * }
43
- * ```
44
- *
45
- * @param config - Configuration for this service instance
46
- * @returns Provider array to spread into component's providers
47
- */
48
- export declare function provideTentickle(config: TentickleConfig): (typeof TentickleService | {
49
- provide: InjectionToken<TentickleConfig>;
50
- useValue: TentickleConfig;
51
- })[];
52
- /**
53
- * Modern Angular service for Tentickle.
54
- *
55
- * Uses signals for state, with RxJS observables available for compatibility.
56
- *
57
- * @example Standalone setup
58
- * ```typescript
59
- * import { TentickleService, TENTICKLE_CONFIG } from '@tentickle/angular';
60
- *
61
- * bootstrapApplication(AppComponent, {
62
- * providers: [
63
- * { provide: TENTICKLE_CONFIG, useValue: { baseUrl: 'https://api.example.com' } },
64
- * ],
65
- * });
66
- * ```
67
- *
68
- * @example Component with signals
69
- * ```typescript
70
- * @Component({
71
- * template: `
72
- * @if (tentickle.isConnected()) {
73
- * <div class="response">
74
- * {{ tentickle.text() }}
75
- * @if (tentickle.isStreaming()) {
76
- * <span class="cursor">|</span>
77
- * }
78
- * </div>
79
- * <input #input />
80
- * <button (click)="send(input.value)">Send</button>
81
- * } @else {
82
- * <p>Connecting...</p>
83
- * }
84
- * `,
85
- * })
86
- * export class ChatComponent {
87
- * tentickle = inject(TentickleService);
88
- *
89
- * constructor() {
90
- * this.tentickle.subscribe("conv-123");
91
- * }
92
- *
93
- * async send(message: string) {
94
- * const handle = this.tentickle.send(message);
95
- * await handle.result;
96
- * }
97
- * }
98
- * ```
99
- *
100
- * @example With RxJS (for compatibility)
101
- * ```typescript
102
- * @Component({
103
- * template: `{{ text$ | async }}`,
104
- * })
105
- * export class LegacyComponent {
106
- * tentickle = inject(TentickleService);
107
- * text$ = this.tentickle.text$;
108
- * }
109
- * ```
110
- */
111
- export declare class TentickleService implements OnDestroy {
112
- private readonly client;
113
- private readonly destroy$;
114
- private currentSession?;
115
- /** Current connection state */
116
- readonly connectionState: import("@angular/core").WritableSignal<ConnectionState>;
117
- /** Current session ID */
118
- readonly sessionId: import("@angular/core").WritableSignal<string | undefined>;
119
- /** Connection error, if any */
120
- readonly error: import("@angular/core").WritableSignal<Error | undefined>;
121
- /** Streaming text state from the client */
122
- readonly streamingText: import("@angular/core").WritableSignal<StreamingTextState>;
123
- /** Whether currently connected */
124
- readonly isConnected: import("@angular/core").Signal<boolean>;
125
- /** Whether currently connecting */
126
- readonly isConnecting: import("@angular/core").Signal<boolean>;
127
- /** Current streaming text */
128
- readonly text: import("@angular/core").Signal<string>;
129
- /** Whether currently streaming */
130
- readonly isStreaming: import("@angular/core").Signal<boolean>;
131
- /** Observable of connection state (for RxJS users) */
132
- readonly connectionState$: Observable<ConnectionState>;
133
- /** Observable of whether connected (for RxJS users) */
134
- readonly isConnected$: Observable<boolean>;
135
- /** Observable of streaming text state (for RxJS users) */
136
- readonly streamingText$: Observable<StreamingTextState>;
137
- /** Observable of just the text (for RxJS users) */
138
- readonly text$: Observable<string>;
139
- /** Observable of whether streaming (for RxJS users) */
140
- readonly isStreaming$: Observable<boolean>;
141
- /** Subject for raw stream events */
142
- private readonly eventsSubject;
143
- /** Observable of all stream events */
144
- readonly events$: Observable<StreamEvent | SessionStreamEvent>;
145
- /** Subject for execution results */
146
- private readonly resultSubject;
147
- /** Observable of execution results */
148
- readonly result$: Observable<{
149
- response: string;
150
- outputs: Record<string, unknown>;
151
- usage: {
152
- inputTokens: number;
153
- outputTokens: number;
154
- totalTokens: number;
155
- };
156
- stopReason?: string;
157
- }>;
158
- /**
159
- * Creates a new TentickleService.
160
- *
161
- * @param configOrInjected - Config passed directly (for testing) or undefined to use DI
162
- */
163
- constructor(configOrInjected?: TentickleConfig);
164
- private setupSubscriptions;
165
- /**
166
- * Get a cold session accessor.
167
- */
168
- session(sessionId: string): SessionAccessor;
169
- /**
170
- * Subscribe to a session and make it the active session.
171
- */
172
- subscribe(sessionId: string): SessionAccessor;
173
- /**
174
- * Unsubscribe from the active session.
175
- */
176
- unsubscribe(): void;
177
- /**
178
- * Send a message to the session.
179
- */
180
- send(input: Parameters<TentickleClient["send"]>[0]): ClientExecutionHandle;
181
- /**
182
- * Abort the current execution.
183
- */
184
- abort(reason?: string): Promise<void>;
185
- /**
186
- * Close the active session on the server.
187
- */
188
- close(): Promise<void>;
189
- /**
190
- * Clear the accumulated streaming text.
191
- */
192
- clearStreamingText(): void;
193
- /**
194
- * Get a channel accessor for custom pub/sub.
195
- */
196
- channel(name: string): import("@tentickle/client").ChannelAccessor;
197
- /**
198
- * Create an Observable from a channel.
199
- */
200
- channel$(name: string): Observable<{
201
- type: string;
202
- payload: unknown;
203
- }>;
204
- /**
205
- * Filter events by type.
206
- */
207
- eventsOfType(...types: StreamEvent["type"][]): Observable<StreamEvent>;
208
- ngOnDestroy(): void;
209
- }
210
- //# sourceMappingURL=tentickle.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tentickle.service.d.ts","sourceRoot":"","sources":["../src/tentickle.service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,cAAc,EACd,KAAK,SAAS,EAIf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAA8B,MAAM,MAAM,CAAC;AAC9D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE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pB"}
@@ -1,354 +0,0 @@
1
- /**
2
- * TentickleService - Modern Angular service for Tentickle.
3
- *
4
- * Uses Angular signals for reactive state management with RxJS interop.
5
- *
6
- * @module @tentickle/angular/service
7
- */
8
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
- return c > 3 && r && Object.defineProperty(target, key, r), r;
13
- };
14
- var __metadata = (this && this.__metadata) || function (k, v) {
15
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16
- };
17
- import { Injectable, InjectionToken, computed, signal, inject, } from "@angular/core";
18
- import { toObservable } from "@angular/core/rxjs-interop";
19
- import { Observable, Subject, filter, takeUntil } from "rxjs";
20
- import { createClient, } from "@tentickle/client";
21
- /**
22
- * Injection token for Tentickle configuration.
23
- */
24
- export const TENTICKLE_CONFIG = new InjectionToken("TENTICKLE_CONFIG");
25
- /**
26
- * Provides TentickleService with configuration at component level.
27
- *
28
- * Use this to create isolated service instances for different components,
29
- * each with their own connection and state.
30
- *
31
- * @example Multiple agents in one app
32
- * ```typescript
33
- * // Each component gets its own TentickleService instance
34
- *
35
- * @Component({
36
- * selector: 'app-support-chat',
37
- * providers: [provideTentickle({ baseUrl: '/api/support-agent' })],
38
- * template: `<div>{{ tentickle.text() }}</div>`,
39
- * })
40
- * export class SupportChatComponent {
41
- * tentickle = inject(TentickleService);
42
- * }
43
- *
44
- * @Component({
45
- * selector: 'app-sales-chat',
46
- * providers: [provideTentickle({ baseUrl: '/api/sales-agent' })],
47
- * template: `<div>{{ tentickle.text() }}</div>`,
48
- * })
49
- * export class SalesChatComponent {
50
- * tentickle = inject(TentickleService);
51
- * }
52
- * ```
53
- *
54
- * @param config - Configuration for this service instance
55
- * @returns Provider array to spread into component's providers
56
- */
57
- export function provideTentickle(config) {
58
- return [{ provide: TENTICKLE_CONFIG, useValue: config }, TentickleService];
59
- }
60
- /**
61
- * Modern Angular service for Tentickle.
62
- *
63
- * Uses signals for state, with RxJS observables available for compatibility.
64
- *
65
- * @example Standalone setup
66
- * ```typescript
67
- * import { TentickleService, TENTICKLE_CONFIG } from '@tentickle/angular';
68
- *
69
- * bootstrapApplication(AppComponent, {
70
- * providers: [
71
- * { provide: TENTICKLE_CONFIG, useValue: { baseUrl: 'https://api.example.com' } },
72
- * ],
73
- * });
74
- * ```
75
- *
76
- * @example Component with signals
77
- * ```typescript
78
- * @Component({
79
- * template: `
80
- * @if (tentickle.isConnected()) {
81
- * <div class="response">
82
- * {{ tentickle.text() }}
83
- * @if (tentickle.isStreaming()) {
84
- * <span class="cursor">|</span>
85
- * }
86
- * </div>
87
- * <input #input />
88
- * <button (click)="send(input.value)">Send</button>
89
- * } @else {
90
- * <p>Connecting...</p>
91
- * }
92
- * `,
93
- * })
94
- * export class ChatComponent {
95
- * tentickle = inject(TentickleService);
96
- *
97
- * constructor() {
98
- * this.tentickle.subscribe("conv-123");
99
- * }
100
- *
101
- * async send(message: string) {
102
- * const handle = this.tentickle.send(message);
103
- * await handle.result;
104
- * }
105
- * }
106
- * ```
107
- *
108
- * @example With RxJS (for compatibility)
109
- * ```typescript
110
- * @Component({
111
- * template: `{{ text$ | async }}`,
112
- * })
113
- * export class LegacyComponent {
114
- * tentickle = inject(TentickleService);
115
- * text$ = this.tentickle.text$;
116
- * }
117
- * ```
118
- */
119
- let TentickleService = class TentickleService {
120
- // ══════════════════════════════════════════════════════════════════════════
121
- // Constructor
122
- // ══════════════════════════════════════════════════════════════════════════
123
- /**
124
- * Creates a new TentickleService.
125
- *
126
- * @param configOrInjected - Config passed directly (for testing) or undefined to use DI
127
- */
128
- constructor(configOrInjected) {
129
- this.destroy$ = new Subject();
130
- // ══════════════════════════════════════════════════════════════════════════
131
- // Signals - Primary State
132
- // ══════════════════════════════════════════════════════════════════════════
133
- /** Current connection state */
134
- this.connectionState = signal("disconnected");
135
- /** Current session ID */
136
- this.sessionId = signal(undefined);
137
- /** Connection error, if any */
138
- this.error = signal(undefined);
139
- /** Streaming text state from the client */
140
- this.streamingText = signal({ text: "", isStreaming: false });
141
- // ══════════════════════════════════════════════════════════════════════════
142
- // Computed Signals - Derived State
143
- // ══════════════════════════════════════════════════════════════════════════
144
- /** Whether currently connected */
145
- this.isConnected = computed(() => this.connectionState() === "connected");
146
- /** Whether currently connecting */
147
- this.isConnecting = computed(() => this.connectionState() === "connecting");
148
- /** Current streaming text */
149
- this.text = computed(() => this.streamingText().text);
150
- /** Whether currently streaming */
151
- this.isStreaming = computed(() => this.streamingText().isStreaming);
152
- /** Subject for raw stream events */
153
- this.eventsSubject = new Subject();
154
- /** Observable of all stream events */
155
- this.events$ = this.eventsSubject.asObservable();
156
- /** Subject for execution results */
157
- this.resultSubject = new Subject();
158
- /** Observable of execution results */
159
- this.result$ = this.resultSubject.asObservable();
160
- // Support both direct config (for testing) and DI injection
161
- let config = configOrInjected;
162
- if (!config) {
163
- try {
164
- config = inject(TENTICKLE_CONFIG, { optional: true }) ?? undefined;
165
- }
166
- catch {
167
- // Not in injection context - config must be passed directly
168
- }
169
- }
170
- if (!config) {
171
- throw new Error("TentickleService requires TENTICKLE_CONFIG to be provided");
172
- }
173
- this.client = createClient(config);
174
- // Initialize observables from signals
175
- // Note: toObservable requires injection context, so we create them conditionally
176
- try {
177
- this.connectionState$ = toObservable(this.connectionState);
178
- this.isConnected$ = toObservable(this.isConnected);
179
- this.streamingText$ = toObservable(this.streamingText);
180
- this.text$ = toObservable(this.text);
181
- this.isStreaming$ = toObservable(this.isStreaming);
182
- }
183
- catch {
184
- // Not in injection context - create manual observables for testing
185
- this.connectionState$ = new Observable((subscriber) => {
186
- subscriber.next(this.connectionState());
187
- const interval = setInterval(() => {
188
- subscriber.next(this.connectionState());
189
- }, 10);
190
- return () => clearInterval(interval);
191
- });
192
- this.isConnected$ = new Observable((subscriber) => {
193
- subscriber.next(this.isConnected());
194
- const interval = setInterval(() => {
195
- subscriber.next(this.isConnected());
196
- }, 10);
197
- return () => clearInterval(interval);
198
- });
199
- this.streamingText$ = new Observable((subscriber) => {
200
- subscriber.next(this.streamingText());
201
- const interval = setInterval(() => {
202
- subscriber.next(this.streamingText());
203
- }, 10);
204
- return () => clearInterval(interval);
205
- });
206
- this.text$ = new Observable((subscriber) => {
207
- subscriber.next(this.text());
208
- const interval = setInterval(() => {
209
- subscriber.next(this.text());
210
- }, 10);
211
- return () => clearInterval(interval);
212
- });
213
- this.isStreaming$ = new Observable((subscriber) => {
214
- subscriber.next(this.isStreaming());
215
- const interval = setInterval(() => {
216
- subscriber.next(this.isStreaming());
217
- }, 10);
218
- return () => clearInterval(interval);
219
- });
220
- }
221
- this.setupSubscriptions();
222
- }
223
- setupSubscriptions() {
224
- // Connection state → signal
225
- this.client.onConnectionChange((state) => {
226
- this.connectionState.set(state);
227
- });
228
- // Streaming text → signal
229
- this.client.onStreamingText((state) => {
230
- this.streamingText.set(state);
231
- });
232
- // Events → subject (for filtering)
233
- this.client.onEvent((event) => {
234
- this.eventsSubject.next(event);
235
- });
236
- // Results → subject
237
- this.client.onEvent((event) => {
238
- if (event.type === "result") {
239
- this.resultSubject.next(event.result);
240
- }
241
- });
242
- }
243
- // ══════════════════════════════════════════════════════════════════════════
244
- // Session Access
245
- // ══════════════════════════════════════════════════════════════════════════
246
- /**
247
- * Get a cold session accessor.
248
- */
249
- session(sessionId) {
250
- return this.client.session(sessionId);
251
- }
252
- /**
253
- * Subscribe to a session and make it the active session.
254
- */
255
- subscribe(sessionId) {
256
- const accessor = this.client.subscribe(sessionId);
257
- this.currentSession = accessor;
258
- this.sessionId.set(sessionId);
259
- return accessor;
260
- }
261
- /**
262
- * Unsubscribe from the active session.
263
- */
264
- unsubscribe() {
265
- this.currentSession?.unsubscribe();
266
- this.currentSession = undefined;
267
- this.sessionId.set(undefined);
268
- }
269
- // ══════════════════════════════════════════════════════════════════════════
270
- // Messaging
271
- // ══════════════════════════════════════════════════════════════════════════
272
- /**
273
- * Send a message to the session.
274
- */
275
- send(input) {
276
- if (this.currentSession) {
277
- return this.currentSession.send(input);
278
- }
279
- return this.client.send(input);
280
- }
281
- /**
282
- * Abort the current execution.
283
- */
284
- async abort(reason) {
285
- if (this.currentSession) {
286
- await this.currentSession.abort(reason);
287
- return;
288
- }
289
- const id = this.sessionId();
290
- if (id) {
291
- await this.client.abort(id, reason);
292
- }
293
- }
294
- /**
295
- * Close the active session on the server.
296
- */
297
- async close() {
298
- if (this.currentSession) {
299
- await this.currentSession.close();
300
- this.currentSession = undefined;
301
- this.sessionId.set(undefined);
302
- }
303
- }
304
- /**
305
- * Clear the accumulated streaming text.
306
- */
307
- clearStreamingText() {
308
- this.client.clearStreamingText();
309
- }
310
- // ══════════════════════════════════════════════════════════════════════════
311
- // Channels
312
- // ══════════════════════════════════════════════════════════════════════════
313
- /**
314
- * Get a channel accessor for custom pub/sub.
315
- */
316
- channel(name) {
317
- if (!this.currentSession) {
318
- throw new Error("No active session. Call subscribe(sessionId) first.");
319
- }
320
- return this.currentSession.channel(name);
321
- }
322
- /**
323
- * Create an Observable from a channel.
324
- */
325
- channel$(name) {
326
- return new Observable((subscriber) => {
327
- const channel = this.channel(name);
328
- const unsubscribe = channel.subscribe((payload, event) => {
329
- subscriber.next({ type: event.type, payload });
330
- });
331
- return () => unsubscribe();
332
- }).pipe(takeUntil(this.destroy$));
333
- }
334
- /**
335
- * Filter events by type.
336
- */
337
- eventsOfType(...types) {
338
- return this.events$.pipe(filter((event) => types.includes(event.type)));
339
- }
340
- // ══════════════════════════════════════════════════════════════════════════
341
- // Cleanup
342
- // ══════════════════════════════════════════════════════════════════════════
343
- ngOnDestroy() {
344
- this.destroy$.next();
345
- this.destroy$.complete();
346
- this.client.destroy();
347
- }
348
- };
349
- TentickleService = __decorate([
350
- Injectable({ providedIn: "root" }),
351
- __metadata("design:paramtypes", [Object])
352
- ], TentickleService);
353
- export { TentickleService };
354
- //# sourceMappingURL=tentickle.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tentickle.service.js","sourceRoot":"","sources":["../src/tentickle.service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;AAEH,OAAO,EACL,UAAU,EACV,cAAc,EAEd,QAAQ,EACR,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EACL,YAAY,GAQb,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,cAAc,CAAkB,kBAAkB,CAAC,CAAC;AAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAyE3B,6EAA6E;IAC7E,cAAc;IACd,6EAA6E;IAE7E;;;;OAIG;IACH,YAAY,gBAAkC;QAhF7B,aAAQ,GAAG,IAAI,OAAO,EAAQ,CAAC;QAGhD,6EAA6E;QAC7E,0BAA0B;QAC1B,6EAA6E;QAE7E,+BAA+B;QACtB,oBAAe,GAAG,MAAM,CAAkB,cAAc,CAAC,CAAC;QAEnE,yBAAyB;QAChB,cAAS,GAAG,MAAM,CAAqB,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