@proletariat/cli 0.3.77 → 0.3.78
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/dist/commands/pr/create.js +3 -0
- package/dist/commands/pr/create.js.map +1 -1
- package/dist/commands/work/ready.js +3 -0
- package/dist/commands/work/ready.js.map +1 -1
- package/dist/commands/work/start.js +2 -1
- package/dist/commands/work/start.js.map +1 -1
- package/dist/lib/database/migrations/0005_provider_status_mapping.d.ts +2 -0
- package/dist/lib/database/migrations/0005_provider_status_mapping.js +35 -0
- package/dist/lib/database/migrations/0005_provider_status_mapping.js.map +1 -0
- package/dist/lib/database/migrations/index.js +2 -0
- package/dist/lib/database/migrations/index.js.map +1 -1
- package/dist/lib/pmo/storage/tickets.d.ts +0 -8
- package/dist/lib/pmo/storage/tickets.js +6 -52
- package/dist/lib/pmo/storage/tickets.js.map +1 -1
- package/dist/lib/pmo/sync-manager.js +13 -2
- package/dist/lib/pmo/sync-manager.js.map +1 -1
- package/dist/lib/providers/event-emitting-provider.d.ts +64 -0
- package/dist/lib/providers/event-emitting-provider.js +129 -0
- package/dist/lib/providers/event-emitting-provider.js.map +1 -0
- package/dist/lib/providers/index.d.ts +3 -0
- package/dist/lib/providers/index.js +3 -0
- package/dist/lib/providers/index.js.map +1 -1
- package/dist/lib/providers/resolver.d.ts +11 -0
- package/dist/lib/providers/resolver.js +85 -6
- package/dist/lib/providers/resolver.js.map +1 -1
- package/dist/lib/providers/status-mapping.d.ts +64 -0
- package/dist/lib/providers/status-mapping.js +136 -0
- package/dist/lib/providers/status-mapping.js.map +1 -0
- package/dist/lib/providers/trigger-config.d.ts +98 -0
- package/dist/lib/providers/trigger-config.js +204 -0
- package/dist/lib/providers/trigger-config.js.map +1 -0
- package/dist/lib/repos/git.d.ts +51 -0
- package/dist/lib/repos/git.js +99 -0
- package/dist/lib/repos/git.js.map +1 -1
- package/dist/lib/work-lifecycle/adapter.d.ts +45 -10
- package/dist/lib/work-lifecycle/adapter.js +52 -58
- package/dist/lib/work-lifecycle/adapter.js.map +1 -1
- package/oclif.manifest.json +3575 -3574
- package/package.json +1 -1
package/dist/lib/repos/git.d.ts
CHANGED
|
@@ -66,3 +66,54 @@ export declare function parseGitHubOwnerRepo(url: string): string | null;
|
|
|
66
66
|
* @returns true if archived, false if not archived or if the check fails
|
|
67
67
|
*/
|
|
68
68
|
export declare function checkGitHubRepoArchived(ownerRepo: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Detect if a GitHub repository has been transferred to a new org/owner.
|
|
71
|
+
*
|
|
72
|
+
* Queries the GitHub API with the local remote's owner/repo and compares
|
|
73
|
+
* the API-returned full_name to detect if the repo was transferred.
|
|
74
|
+
* GitHub automatically redirects API calls for transferred repos.
|
|
75
|
+
*
|
|
76
|
+
* @param cwd - Working directory of the git repo
|
|
77
|
+
* @returns Object with transfer details, or null if no transfer detected or check fails
|
|
78
|
+
*/
|
|
79
|
+
export declare function detectTransferredRepo(cwd?: string): {
|
|
80
|
+
oldOwnerRepo: string;
|
|
81
|
+
newOwnerRepo: string;
|
|
82
|
+
} | null;
|
|
83
|
+
/**
|
|
84
|
+
* Build a new remote URL preserving the original URL format (HTTPS or SSH).
|
|
85
|
+
*
|
|
86
|
+
* @param originalUrl - The original remote URL (used to determine format)
|
|
87
|
+
* @param newOwnerRepo - The new "owner/repo" to use
|
|
88
|
+
* @returns The new URL in the same format as the original
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildRemoteUrl(originalUrl: string, newOwnerRepo: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Detect if a repo has been transferred and update the origin remote URL if so.
|
|
93
|
+
*
|
|
94
|
+
* @param cwd - Working directory of the git repo
|
|
95
|
+
* @returns Object describing what happened, or null if no action taken
|
|
96
|
+
*/
|
|
97
|
+
export declare function detectAndFixTransferredRepo(cwd?: string): {
|
|
98
|
+
oldOwnerRepo: string;
|
|
99
|
+
newOwnerRepo: string;
|
|
100
|
+
oldUrl: string;
|
|
101
|
+
newUrl: string;
|
|
102
|
+
} | null;
|
|
103
|
+
/**
|
|
104
|
+
* Ensure the git remote is up to date before push/PR operations.
|
|
105
|
+
*
|
|
106
|
+
* This is the single entry point that should be called at the command level
|
|
107
|
+
* (in pr create and work ready) before any push or PR creation.
|
|
108
|
+
* It detects transferred repos and updates the remote URL.
|
|
109
|
+
*
|
|
110
|
+
* @param cwd - Working directory of the git repo
|
|
111
|
+
* @param log - Optional callback for logging messages to the user
|
|
112
|
+
* @returns Object describing what happened, or null if no action taken
|
|
113
|
+
*/
|
|
114
|
+
export declare function ensureRemoteUpToDate(cwd?: string, log?: (message: string) => void): {
|
|
115
|
+
oldOwnerRepo: string;
|
|
116
|
+
newOwnerRepo: string;
|
|
117
|
+
oldUrl: string;
|
|
118
|
+
newUrl: string;
|
|
119
|
+
} | null;
|
package/dist/lib/repos/git.js
CHANGED
|
@@ -180,4 +180,103 @@ export function checkGitHubRepoArchived(ownerRepo) {
|
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Detect if a GitHub repository has been transferred to a new org/owner.
|
|
185
|
+
*
|
|
186
|
+
* Queries the GitHub API with the local remote's owner/repo and compares
|
|
187
|
+
* the API-returned full_name to detect if the repo was transferred.
|
|
188
|
+
* GitHub automatically redirects API calls for transferred repos.
|
|
189
|
+
*
|
|
190
|
+
* @param cwd - Working directory of the git repo
|
|
191
|
+
* @returns Object with transfer details, or null if no transfer detected or check fails
|
|
192
|
+
*/
|
|
193
|
+
export function detectTransferredRepo(cwd) {
|
|
194
|
+
const originUrl = getOriginUrl(cwd || process.cwd());
|
|
195
|
+
if (!originUrl)
|
|
196
|
+
return null;
|
|
197
|
+
const localOwnerRepo = parseGitHubOwnerRepo(originUrl);
|
|
198
|
+
if (!localOwnerRepo)
|
|
199
|
+
return null;
|
|
200
|
+
try {
|
|
201
|
+
const result = execSync(`gh api repos/${localOwnerRepo} -q .full_name`, {
|
|
202
|
+
cwd,
|
|
203
|
+
encoding: 'utf-8',
|
|
204
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
205
|
+
}).trim();
|
|
206
|
+
if (!result)
|
|
207
|
+
return null;
|
|
208
|
+
// Compare case-insensitively since GitHub treats owner/repo as case-insensitive
|
|
209
|
+
if (result.toLowerCase() !== localOwnerRepo.toLowerCase()) {
|
|
210
|
+
return { oldOwnerRepo: localOwnerRepo, newOwnerRepo: result };
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// API call failed — don't block the user
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Build a new remote URL preserving the original URL format (HTTPS or SSH).
|
|
221
|
+
*
|
|
222
|
+
* @param originalUrl - The original remote URL (used to determine format)
|
|
223
|
+
* @param newOwnerRepo - The new "owner/repo" to use
|
|
224
|
+
* @returns The new URL in the same format as the original
|
|
225
|
+
*/
|
|
226
|
+
export function buildRemoteUrl(originalUrl, newOwnerRepo) {
|
|
227
|
+
// SSH format: git@github.com:owner/repo.git
|
|
228
|
+
if (originalUrl.startsWith('git@github.com:')) {
|
|
229
|
+
const hadGitSuffix = originalUrl.endsWith('.git');
|
|
230
|
+
return `git@github.com:${newOwnerRepo}${hadGitSuffix ? '.git' : ''}`;
|
|
231
|
+
}
|
|
232
|
+
// SSH alternative: ssh://git@github.com/owner/repo.git
|
|
233
|
+
if (originalUrl.startsWith('ssh://git@github.com/')) {
|
|
234
|
+
const hadGitSuffix = originalUrl.endsWith('.git');
|
|
235
|
+
return `ssh://git@github.com/${newOwnerRepo}${hadGitSuffix ? '.git' : ''}`;
|
|
236
|
+
}
|
|
237
|
+
// HTTPS format: https://github.com/owner/repo.git
|
|
238
|
+
const hadGitSuffix = originalUrl.endsWith('.git');
|
|
239
|
+
return `https://github.com/${newOwnerRepo}${hadGitSuffix ? '.git' : ''}`;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Detect if a repo has been transferred and update the origin remote URL if so.
|
|
243
|
+
*
|
|
244
|
+
* @param cwd - Working directory of the git repo
|
|
245
|
+
* @returns Object describing what happened, or null if no action taken
|
|
246
|
+
*/
|
|
247
|
+
export function detectAndFixTransferredRepo(cwd) {
|
|
248
|
+
const transfer = detectTransferredRepo(cwd);
|
|
249
|
+
if (!transfer)
|
|
250
|
+
return null;
|
|
251
|
+
const repoPath = cwd || process.cwd();
|
|
252
|
+
const originUrl = getOriginUrl(repoPath);
|
|
253
|
+
if (!originUrl)
|
|
254
|
+
return null;
|
|
255
|
+
const newUrl = buildRemoteUrl(originUrl, transfer.newOwnerRepo);
|
|
256
|
+
setOriginUrl(repoPath, newUrl);
|
|
257
|
+
return {
|
|
258
|
+
oldOwnerRepo: transfer.oldOwnerRepo,
|
|
259
|
+
newOwnerRepo: transfer.newOwnerRepo,
|
|
260
|
+
oldUrl: originUrl,
|
|
261
|
+
newUrl,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Ensure the git remote is up to date before push/PR operations.
|
|
266
|
+
*
|
|
267
|
+
* This is the single entry point that should be called at the command level
|
|
268
|
+
* (in pr create and work ready) before any push or PR creation.
|
|
269
|
+
* It detects transferred repos and updates the remote URL.
|
|
270
|
+
*
|
|
271
|
+
* @param cwd - Working directory of the git repo
|
|
272
|
+
* @param log - Optional callback for logging messages to the user
|
|
273
|
+
* @returns Object describing what happened, or null if no action taken
|
|
274
|
+
*/
|
|
275
|
+
export function ensureRemoteUpToDate(cwd, log) {
|
|
276
|
+
const result = detectAndFixTransferredRepo(cwd);
|
|
277
|
+
if (result && log) {
|
|
278
|
+
log(`Repo transferred: ${result.oldOwnerRepo} → ${result.newOwnerRepo}. Updated remote URL.`);
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
183
282
|
//# sourceMappingURL=git.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.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AQ,CAAC,YAAY;QACnC,MAAM,EAAE,SAAS;QACjB,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAY,EACZ,GAA+B;IAE/B,MAAM,MAAM,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;IAChD,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAClB,GAAG,CAAC,qBAAqB,MAAM,CAAC,YAAY,MAAM,MAAM,CAAC,YAAY,uBAAuB,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Work Lifecycle Adapter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* PMO
|
|
6
|
-
*
|
|
4
|
+
* The adapter layer is the central event hub for all providers.
|
|
5
|
+
* All providers (PMO, Linear, Jira, Shortcut, Asana) are equal peers —
|
|
6
|
+
* any state change through any provider emits events here.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* The adapter handles two event flows:
|
|
9
|
+
*
|
|
10
|
+
* 1. Provider-specific → domain: Translates ticket:* events (emitted by
|
|
11
|
+
* EventEmittingProvider after any provider operation) into work:*
|
|
12
|
+
* domain events. This enables backward-compatible ticket:* consumers
|
|
13
|
+
* (workflow rules, hooks) to coexist with provider-agnostic work:*
|
|
14
|
+
* consumers (outbound sync).
|
|
15
|
+
*
|
|
16
|
+
* 2. Direct domain events: work:* events emitted directly by
|
|
17
|
+
* EventEmittingProvider are already provider-agnostic, so no
|
|
18
|
+
* translation is needed — they flow straight to outbound sync.
|
|
19
|
+
*
|
|
20
|
+
* This architecture replaces the old model where PMO storage was the
|
|
21
|
+
* sole event source. Now events fire regardless of which provider
|
|
22
|
+
* initiated the change.
|
|
10
23
|
*/
|
|
24
|
+
import type { WorkEventSource } from './events.js';
|
|
11
25
|
/**
|
|
12
|
-
* WorkLifecycleAdapter
|
|
13
|
-
*
|
|
26
|
+
* WorkLifecycleAdapter is the event hub for all provider state changes.
|
|
27
|
+
*
|
|
28
|
+
* In the new architecture, EventEmittingProvider wraps each provider and
|
|
29
|
+
* emits both ticket:* (backward compat) and work:* (domain) events.
|
|
30
|
+
* The adapter layer no longer needs to translate between them — that
|
|
31
|
+
* responsibility moved to EventEmittingProvider.
|
|
32
|
+
*
|
|
33
|
+
* The adapter now serves as the coordination point and can be extended
|
|
34
|
+
* to register additional event sources (webhooks, polling, etc.).
|
|
14
35
|
*/
|
|
15
36
|
export declare class WorkLifecycleAdapter {
|
|
16
37
|
private unsubscribers;
|
|
38
|
+
private registeredSources;
|
|
39
|
+
/**
|
|
40
|
+
* Register a provider as an event source.
|
|
41
|
+
* This is informational — tracks which providers are active in the system.
|
|
42
|
+
*/
|
|
43
|
+
registerSource(source: WorkEventSource): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get all registered event sources.
|
|
46
|
+
*/
|
|
47
|
+
getRegisteredSources(): ReadonlySet<WorkEventSource>;
|
|
17
48
|
/**
|
|
18
|
-
* Start the
|
|
49
|
+
* Start the adapter — sets up any cross-cutting event coordination.
|
|
50
|
+
*
|
|
51
|
+
* In the current architecture, EventEmittingProvider handles all event
|
|
52
|
+
* emission directly. The adapter provides extensibility for future
|
|
53
|
+
* cross-cutting concerns (event logging, metrics, deduplication).
|
|
19
54
|
*/
|
|
20
|
-
|
|
55
|
+
start(): void;
|
|
21
56
|
/**
|
|
22
|
-
* Stop
|
|
57
|
+
* Stop the adapter and unsubscribe from events.
|
|
23
58
|
*/
|
|
24
59
|
stop(): void;
|
|
25
60
|
}
|
|
@@ -1,79 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Work Lifecycle Adapter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* PMO
|
|
6
|
-
*
|
|
4
|
+
* The adapter layer is the central event hub for all providers.
|
|
5
|
+
* All providers (PMO, Linear, Jira, Shortcut, Asana) are equal peers —
|
|
6
|
+
* any state change through any provider emits events here.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* The adapter handles two event flows:
|
|
9
|
+
*
|
|
10
|
+
* 1. Provider-specific → domain: Translates ticket:* events (emitted by
|
|
11
|
+
* EventEmittingProvider after any provider operation) into work:*
|
|
12
|
+
* domain events. This enables backward-compatible ticket:* consumers
|
|
13
|
+
* (workflow rules, hooks) to coexist with provider-agnostic work:*
|
|
14
|
+
* consumers (outbound sync).
|
|
15
|
+
*
|
|
16
|
+
* 2. Direct domain events: work:* events emitted directly by
|
|
17
|
+
* EventEmittingProvider are already provider-agnostic, so no
|
|
18
|
+
* translation is needed — they flow straight to outbound sync.
|
|
19
|
+
*
|
|
20
|
+
* This architecture replaces the old model where PMO storage was the
|
|
21
|
+
* sole event source. Now events fire regardless of which provider
|
|
22
|
+
* initiated the change.
|
|
10
23
|
*/
|
|
11
|
-
import { getEventBus } from '../events/event-bus.js';
|
|
12
24
|
/**
|
|
13
|
-
* WorkLifecycleAdapter
|
|
14
|
-
*
|
|
25
|
+
* WorkLifecycleAdapter is the event hub for all provider state changes.
|
|
26
|
+
*
|
|
27
|
+
* In the new architecture, EventEmittingProvider wraps each provider and
|
|
28
|
+
* emits both ticket:* (backward compat) and work:* (domain) events.
|
|
29
|
+
* The adapter layer no longer needs to translate between them — that
|
|
30
|
+
* responsibility moved to EventEmittingProvider.
|
|
31
|
+
*
|
|
32
|
+
* The adapter now serves as the coordination point and can be extended
|
|
33
|
+
* to register additional event sources (webhooks, polling, etc.).
|
|
15
34
|
*/
|
|
16
35
|
export class WorkLifecycleAdapter {
|
|
17
36
|
unsubscribers = [];
|
|
37
|
+
registeredSources = new Set();
|
|
38
|
+
/**
|
|
39
|
+
* Register a provider as an event source.
|
|
40
|
+
* This is informational — tracks which providers are active in the system.
|
|
41
|
+
*/
|
|
42
|
+
registerSource(source) {
|
|
43
|
+
this.registeredSources.add(source);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get all registered event sources.
|
|
47
|
+
*/
|
|
48
|
+
getRegisteredSources() {
|
|
49
|
+
return this.registeredSources;
|
|
50
|
+
}
|
|
18
51
|
/**
|
|
19
|
-
* Start the
|
|
52
|
+
* Start the adapter — sets up any cross-cutting event coordination.
|
|
53
|
+
*
|
|
54
|
+
* In the current architecture, EventEmittingProvider handles all event
|
|
55
|
+
* emission directly. The adapter provides extensibility for future
|
|
56
|
+
* cross-cutting concerns (event logging, metrics, deduplication).
|
|
20
57
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
// Always emit the generic status change
|
|
25
|
-
bus.emit('work:status_changed', {
|
|
26
|
-
workItemId: event.ticketId,
|
|
27
|
-
source: 'pmo',
|
|
28
|
-
projectId: event.projectId,
|
|
29
|
-
previousStatus: event.previousStatusName ?? null,
|
|
30
|
-
previousCategory: event.previousStatusCategory ?? null,
|
|
31
|
-
newStatus: event.newStatusName ?? null,
|
|
32
|
-
newCategory: event.newStatusCategory ?? null,
|
|
33
|
-
timestamp: event.timestamp,
|
|
34
|
-
});
|
|
35
|
-
// Emit work:started when entering the 'started' category
|
|
36
|
-
if (event.newStatusCategory === 'started' &&
|
|
37
|
-
event.previousStatusCategory !== 'started') {
|
|
38
|
-
bus.emit('work:started', {
|
|
39
|
-
workItemId: event.ticketId,
|
|
40
|
-
source: 'pmo',
|
|
41
|
-
projectId: event.projectId,
|
|
42
|
-
status: event.newStatusName ?? null,
|
|
43
|
-
timestamp: event.timestamp,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Emit work:completed when entering the 'completed' category
|
|
47
|
-
if (event.newStatusCategory === 'completed' &&
|
|
48
|
-
event.previousStatusCategory !== 'completed') {
|
|
49
|
-
bus.emit('work:completed', {
|
|
50
|
-
workItemId: event.ticketId,
|
|
51
|
-
source: 'pmo',
|
|
52
|
-
projectId: event.projectId,
|
|
53
|
-
status: event.newStatusName ?? null,
|
|
54
|
-
timestamp: event.timestamp,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
|
-
this.unsubscribers.push(bus.on('ticket:pr_linked', (event) => {
|
|
59
|
-
bus.emit('work:pr_created', {
|
|
60
|
-
workItemId: event.ticketId,
|
|
61
|
-
source: 'pmo',
|
|
62
|
-
projectId: event.projectId,
|
|
63
|
-
prUrl: event.prUrl,
|
|
64
|
-
prTitle: event.prTitle ?? null,
|
|
65
|
-
timestamp: event.timestamp,
|
|
66
|
-
});
|
|
67
|
-
}));
|
|
58
|
+
start() {
|
|
59
|
+
// PMO is always a registered source (default provider)
|
|
60
|
+
this.registerSource('pmo');
|
|
68
61
|
}
|
|
69
62
|
/**
|
|
70
|
-
* Stop
|
|
63
|
+
* Stop the adapter and unsubscribe from events.
|
|
71
64
|
*/
|
|
72
65
|
stop() {
|
|
73
66
|
for (const unsub of this.unsubscribers) {
|
|
74
67
|
unsub();
|
|
75
68
|
}
|
|
76
69
|
this.unsubscribers = [];
|
|
70
|
+
this.registeredSources.clear();
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
// =============================================================================
|
|
@@ -87,7 +81,7 @@ let _adapter;
|
|
|
87
81
|
export function initWorkLifecycleAdapter() {
|
|
88
82
|
if (!_adapter) {
|
|
89
83
|
_adapter = new WorkLifecycleAdapter();
|
|
90
|
-
_adapter.
|
|
84
|
+
_adapter.start();
|
|
91
85
|
}
|
|
92
86
|
return _adapter;
|
|
93
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/lib/work-lifecycle/adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/lib/work-lifecycle/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAAoB;IACvB,aAAa,GAAsB,EAAE,CAAA;IACrC,iBAAiB,GAAyB,IAAI,GAAG,EAAE,CAAA;IAE3D;;;OAGG;IACH,cAAc,CAAC,MAAuB;QACpC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAA;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,uDAAuD;QACvD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,KAAK,EAAE,CAAA;QACT,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;QACvB,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAA;IAChC,CAAC;CACF;AAED,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,IAAI,QAA0C,CAAA;AAE9C;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAA;QACrC,QAAQ,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,IAAI,EAAE,CAAA;QACf,QAAQ,GAAG,SAAS,CAAA;IACtB,CAAC;AACH,CAAC"}
|