@bernierllc/content-workflow-ai-review-step 0.1.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.
@@ -0,0 +1,162 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+ /**
9
+ * Default system prompt for AI content review
10
+ */
11
+ export const DEFAULT_REVIEW_PROMPT = `You are an expert content reviewer and editor. Analyze the provided content for:
12
+
13
+ 1. Grammar and spelling errors
14
+ 2. SEO optimization (keyword usage, readability, structure)
15
+ 3. Tone consistency and appropriateness
16
+ 4. Engagement potential (hooks, call-to-actions, readability)
17
+ 5. Clarity and readability
18
+
19
+ Provide actionable, specific suggestions for improvement with exact locations.`;
20
+ /**
21
+ * Build a comprehensive review prompt for AI
22
+ */
23
+ export function buildReviewPrompt(content, customPrompt) {
24
+ const basePrompt = customPrompt || DEFAULT_REVIEW_PROMPT;
25
+ const contentSection = formatContentSection(content);
26
+ const instructionsSection = formatInstructionsSection();
27
+ const outputFormatSection = formatOutputFormatSection();
28
+ return `${basePrompt}
29
+
30
+ ${contentSection}
31
+
32
+ ${instructionsSection}
33
+
34
+ ${outputFormatSection}`;
35
+ }
36
+ /**
37
+ * Format the content section of the prompt
38
+ */
39
+ function formatContentSection(content) {
40
+ const title = content.title || 'Untitled';
41
+ const body = content.body.trim();
42
+ return `## Content to Review
43
+
44
+ **Title:** ${title}
45
+
46
+ **Body:**
47
+ ${body}`;
48
+ }
49
+ /**
50
+ * Format the instructions section
51
+ */
52
+ function formatInstructionsSection() {
53
+ return `## Review Instructions
54
+
55
+ Analyze the content and provide:
56
+ 1. An overall quality score (0-100)
57
+ 2. Individual scores for each category (grammar, SEO, tone, engagement, readability)
58
+ 3. Specific, actionable suggestions with:
59
+ - Type of issue (grammar/seo/tone/engagement/readability/clarity)
60
+ - Severity (critical/warning/suggestion)
61
+ - Original text
62
+ - Suggested replacement
63
+ - Reason for the suggestion
64
+ - Location (line number, character offset if possible)
65
+ 4. A brief summary of the review`;
66
+ }
67
+ /**
68
+ * Format the output format section with JSON schema
69
+ */
70
+ function formatOutputFormatSection() {
71
+ return `## Output Format
72
+
73
+ Return your response as valid JSON matching this structure:
74
+
75
+ \`\`\`json
76
+ {
77
+ "overallScore": <number 0-100>,
78
+ "scores": {
79
+ "grammar": <number 0-100>,
80
+ "seo": <number 0-100>,
81
+ "tone": <number 0-100>,
82
+ "engagement": <number 0-100>,
83
+ "readability": <number 0-100>
84
+ },
85
+ "suggestions": [
86
+ {
87
+ "type": "grammar|seo|tone|engagement|readability|clarity",
88
+ "severity": "critical|warning|suggestion",
89
+ "original": "the problematic text",
90
+ "suggestion": "the improved text",
91
+ "reason": "explanation of why this change improves the content",
92
+ "location": {
93
+ "line": <line number>,
94
+ "column": <column number>,
95
+ "offset": <character offset>,
96
+ "length": <text length>
97
+ }
98
+ }
99
+ ],
100
+ "summary": "A brief summary of the overall review and key findings"
101
+ }
102
+ \`\`\`
103
+
104
+ **Important:**
105
+ - Return ONLY valid JSON, no markdown code fences or additional text
106
+ - All scores must be numbers between 0 and 100
107
+ - Include at least 3-5 suggestions if issues are found
108
+ - Provide specific locations when possible
109
+ - Make suggestions actionable and specific`;
110
+ }
111
+ /**
112
+ * Build a simplified prompt for quick reviews
113
+ */
114
+ export function buildQuickReviewPrompt(content, focusAreas) {
115
+ const areas = focusAreas || ['grammar', 'clarity'];
116
+ const areaList = areas.join(', ');
117
+ return `Review this content focusing on ${areaList}.
118
+
119
+ **Title:** ${content.title || 'Untitled'}
120
+
121
+ **Content:**
122
+ ${content.body}
123
+
124
+ Provide a score (0-100) and top 3 suggestions as JSON:
125
+
126
+ \`\`\`json
127
+ {
128
+ "score": <number>,
129
+ "suggestions": [
130
+ {
131
+ "type": "${areas[0]}",
132
+ "severity": "critical|warning|suggestion",
133
+ "original": "text",
134
+ "suggestion": "improved text",
135
+ "reason": "explanation"
136
+ }
137
+ ]
138
+ }
139
+ \`\`\`
140
+
141
+ Return only valid JSON, no markdown.`;
142
+ }
143
+ /**
144
+ * Validate that a prompt is well-formed
145
+ */
146
+ export function validatePrompt(prompt) {
147
+ if (!prompt || prompt.trim().length === 0) {
148
+ return { valid: false, error: 'Prompt cannot be empty' };
149
+ }
150
+ if (prompt.length > 50000) {
151
+ return { valid: false, error: 'Prompt exceeds maximum length of 50,000 characters' };
152
+ }
153
+ return { valid: true };
154
+ }
155
+ /**
156
+ * Estimate token count for a prompt (rough approximation)
157
+ */
158
+ export function estimateTokenCount(prompt) {
159
+ // Rough estimate: ~4 characters per token
160
+ return Math.ceil(prompt.length / 4);
161
+ }
162
+ //# sourceMappingURL=prompt-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../src/prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;+EAQ0C,CAAC;AAEhF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAwB,EACxB,YAAqB;IAErB,MAAM,UAAU,GAAG,YAAY,IAAI,qBAAqB,CAAC;IAEzD,MAAM,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,CAAC;IACxD,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,CAAC;IAExD,OAAO,GAAG,UAAU;;EAEpB,cAAc;;EAEd,mBAAmB;;EAEnB,mBAAmB,EAAE,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,OAAwB;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;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 +1,13 @@
1
+ import type { AIReviewResult } from './types.js';
2
+ /**
3
+ * Parse AI response into structured review result
4
+ */
5
+ export declare function parseReviewResponse(responseContent: string, provider: string, model: string, tokensUsed: number, costUsd: number): AIReviewResult;
6
+ /**
7
+ * Validate that a parsed result is well-formed
8
+ */
9
+ export declare function validateReviewResult(result: AIReviewResult): {
10
+ valid: boolean;
11
+ errors: string[];
12
+ };
13
+ //# sourceMappingURL=response-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-parser.d.ts","sourceRoot":"","sources":["../src/response-parser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EAKf,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,cAAc,CAuChB;AAyOD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG;IAC5D,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA6CA"}
@@ -0,0 +1,277 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+ import { calculateOverallScore } from './scoring.js';
9
+ /**
10
+ * Parse AI response into structured review result
11
+ */
12
+ export function parseReviewResponse(responseContent, provider, model, tokensUsed, costUsd) {
13
+ try {
14
+ // Clean the response - remove markdown code fences if present
15
+ const cleanedContent = cleanResponseContent(responseContent);
16
+ // Parse JSON
17
+ const parsed = JSON.parse(cleanedContent);
18
+ // Validate and extract data
19
+ const scores = parseScores(parsed.scores);
20
+ const suggestions = parseSuggestions(parsed.suggestions || []);
21
+ const summary = parseSummary(parsed.summary);
22
+ // Use provided overall score or calculate from category scores
23
+ const overallScore = typeof parsed.overallScore === 'number'
24
+ ? clampScore(parsed.overallScore)
25
+ : calculateOverallScore(scores);
26
+ return {
27
+ overallScore,
28
+ scores,
29
+ suggestions,
30
+ summary,
31
+ provider,
32
+ model,
33
+ tokensUsed,
34
+ costUsd,
35
+ };
36
+ }
37
+ catch (error) {
38
+ // If parsing fails, return a fallback result
39
+ return createFallbackResult(error instanceof Error ? error.message : 'Unknown parsing error', provider, model, tokensUsed, costUsd);
40
+ }
41
+ }
42
+ /**
43
+ * Clean response content by removing markdown code fences and extra whitespace
44
+ */
45
+ function cleanResponseContent(content) {
46
+ let cleaned = content.trim();
47
+ // Remove markdown code fences
48
+ cleaned = cleaned.replace(/^```json\s*/i, '');
49
+ cleaned = cleaned.replace(/^```\s*/i, '');
50
+ cleaned = cleaned.replace(/\s*```\s*$/i, '');
51
+ // Try to find JSON object if there's extra text
52
+ const jsonMatch = cleaned.match(/\{[\s\S]*\}/);
53
+ if (jsonMatch) {
54
+ cleaned = jsonMatch[0];
55
+ }
56
+ return cleaned.trim();
57
+ }
58
+ /**
59
+ * Parse and validate scores object
60
+ */
61
+ function parseScores(scoresData) {
62
+ const defaultScores = {
63
+ grammar: 50,
64
+ seo: 50,
65
+ tone: 50,
66
+ engagement: 50,
67
+ readability: 50,
68
+ };
69
+ if (!scoresData || typeof scoresData !== 'object') {
70
+ return defaultScores;
71
+ }
72
+ const scores = scoresData;
73
+ return {
74
+ grammar: parseScore(scores.grammar, defaultScores.grammar),
75
+ seo: parseScore(scores.seo, defaultScores.seo),
76
+ tone: parseScore(scores.tone, defaultScores.tone),
77
+ engagement: parseScore(scores.engagement, defaultScores.engagement),
78
+ readability: parseScore(scores.readability, defaultScores.readability),
79
+ };
80
+ }
81
+ /**
82
+ * Parse and validate a single score value
83
+ */
84
+ function parseScore(value, defaultValue) {
85
+ if (typeof value === 'number') {
86
+ return clampScore(value);
87
+ }
88
+ if (typeof value === 'string') {
89
+ const parsed = parseFloat(value);
90
+ if (!isNaN(parsed)) {
91
+ return clampScore(parsed);
92
+ }
93
+ }
94
+ return defaultValue;
95
+ }
96
+ /**
97
+ * Clamp a score to valid range (0-100)
98
+ */
99
+ function clampScore(score) {
100
+ return Math.max(0, Math.min(100, Math.round(score)));
101
+ }
102
+ /**
103
+ * Parse suggestions array
104
+ */
105
+ function parseSuggestions(suggestionsData) {
106
+ if (!Array.isArray(suggestionsData)) {
107
+ return [];
108
+ }
109
+ return suggestionsData
110
+ .map((item) => parseSingleSuggestion(item))
111
+ .filter((suggestion) => suggestion !== null);
112
+ }
113
+ /**
114
+ * Parse a single suggestion object
115
+ */
116
+ function parseSingleSuggestion(data) {
117
+ if (!data || typeof data !== 'object') {
118
+ return null;
119
+ }
120
+ const suggestion = data;
121
+ // Required fields
122
+ const type = parseSuggestionType(suggestion.type);
123
+ const severity = parseSeverityLevel(suggestion.severity);
124
+ const original = parseString(suggestion.original);
125
+ const suggestionText = parseString(suggestion.suggestion);
126
+ const reason = parseString(suggestion.reason);
127
+ if (!type || !severity || !original || !suggestionText || !reason) {
128
+ return null;
129
+ }
130
+ // Optional location
131
+ const location = suggestion.location
132
+ ? parseLocation(suggestion.location)
133
+ : undefined;
134
+ // Optional accepted flag
135
+ const accepted = typeof suggestion.accepted === 'boolean' ? suggestion.accepted : undefined;
136
+ return {
137
+ type,
138
+ severity,
139
+ original,
140
+ suggestion: suggestionText,
141
+ reason,
142
+ location,
143
+ accepted,
144
+ };
145
+ }
146
+ /**
147
+ * Parse suggestion type
148
+ */
149
+ function parseSuggestionType(value) {
150
+ const validTypes = [
151
+ 'grammar',
152
+ 'seo',
153
+ 'tone',
154
+ 'engagement',
155
+ 'readability',
156
+ 'clarity',
157
+ ];
158
+ if (typeof value === 'string' && validTypes.includes(value)) {
159
+ return value;
160
+ }
161
+ return null;
162
+ }
163
+ /**
164
+ * Parse severity level
165
+ */
166
+ function parseSeverityLevel(value) {
167
+ const validLevels = ['critical', 'warning', 'suggestion'];
168
+ if (typeof value === 'string' && validLevels.includes(value)) {
169
+ return value;
170
+ }
171
+ return null;
172
+ }
173
+ /**
174
+ * Parse location object
175
+ */
176
+ function parseLocation(data) {
177
+ if (!data || typeof data !== 'object') {
178
+ return undefined;
179
+ }
180
+ const loc = data;
181
+ return {
182
+ line: typeof loc.line === 'number' ? Math.max(1, loc.line) : undefined,
183
+ column: typeof loc.column === 'number' ? Math.max(1, loc.column) : undefined,
184
+ offset: typeof loc.offset === 'number' ? Math.max(0, loc.offset) : undefined,
185
+ length: typeof loc.length === 'number' ? Math.max(1, loc.length) : undefined,
186
+ };
187
+ }
188
+ /**
189
+ * Parse string value
190
+ */
191
+ function parseString(value) {
192
+ if (typeof value === 'string') {
193
+ return value.trim();
194
+ }
195
+ return '';
196
+ }
197
+ /**
198
+ * Parse summary text
199
+ */
200
+ function parseSummary(value) {
201
+ if (typeof value === 'string' && value.trim().length > 0) {
202
+ return value.trim();
203
+ }
204
+ return 'AI review completed';
205
+ }
206
+ /**
207
+ * Create a fallback result when parsing fails
208
+ */
209
+ function createFallbackResult(errorMessage, provider, model, tokensUsed, costUsd) {
210
+ return {
211
+ overallScore: 0,
212
+ scores: {
213
+ grammar: 0,
214
+ seo: 0,
215
+ tone: 0,
216
+ engagement: 0,
217
+ readability: 0,
218
+ },
219
+ suggestions: [
220
+ {
221
+ type: 'clarity',
222
+ severity: 'critical',
223
+ original: 'AI response parsing',
224
+ suggestion: 'Failed to parse AI response',
225
+ reason: `Response parsing error: ${errorMessage}`,
226
+ },
227
+ ],
228
+ summary: `Failed to parse AI response: ${errorMessage}`,
229
+ provider,
230
+ model,
231
+ tokensUsed,
232
+ costUsd,
233
+ };
234
+ }
235
+ /**
236
+ * Validate that a parsed result is well-formed
237
+ */
238
+ export function validateReviewResult(result) {
239
+ const errors = [];
240
+ // Check overall score
241
+ if (result.overallScore < 0 || result.overallScore > 100) {
242
+ errors.push('Overall score must be between 0 and 100');
243
+ }
244
+ // Check category scores
245
+ const scoreKeys = [
246
+ 'grammar',
247
+ 'seo',
248
+ 'tone',
249
+ 'engagement',
250
+ 'readability',
251
+ ];
252
+ for (const key of scoreKeys) {
253
+ const score = result.scores[key];
254
+ if (score < 0 || score > 100) {
255
+ errors.push(`${key} score must be between 0 and 100`);
256
+ }
257
+ }
258
+ // Check suggestions
259
+ if (!Array.isArray(result.suggestions)) {
260
+ errors.push('Suggestions must be an array');
261
+ }
262
+ // Check required strings
263
+ if (!result.summary || result.summary.trim().length === 0) {
264
+ errors.push('Summary is required');
265
+ }
266
+ if (!result.provider || result.provider.trim().length === 0) {
267
+ errors.push('Provider is required');
268
+ }
269
+ if (!result.model || result.model.trim().length === 0) {
270
+ errors.push('Model is required');
271
+ }
272
+ return {
273
+ valid: errors.length === 0,
274
+ errors,
275
+ };
276
+ }
277
+ //# sourceMappingURL=response-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-parser.js","sourceRoot":"","sources":["../src/response-parser.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AASF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,eAAuB,EACvB,QAAgB,EAChB,KAAa,EACb,UAAkB,EAClB,OAAe;IAEf,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,cAAc,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAE7D,aAAa;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAE1C,4BAA4B;QAC5B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE7C,+DAA+D;QAC/D,MAAM,YAAY,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5D,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { ReviewScores } from './types.js';
2
+ /**
3
+ * Calculate overall score from category scores
4
+ * Uses weighted average based on importance
5
+ */
6
+ export declare function calculateOverallScore(scores: ReviewScores): number;
7
+ /**
8
+ * Calculate a simple average of all category scores
9
+ */
10
+ export declare function calculateSimpleAverage(scores: ReviewScores): number;
11
+ /**
12
+ * Determine quality level from overall score
13
+ */
14
+ export declare function getQualityLevel(score: number): {
15
+ level: 'excellent' | 'good' | 'fair' | 'poor' | 'critical';
16
+ description: string;
17
+ };
18
+ /**
19
+ * Calculate score improvement potential
20
+ */
21
+ export declare function calculateImprovementPotential(currentScore: number, targetScore?: number): {
22
+ potential: number;
23
+ effort: 'low' | 'medium' | 'high';
24
+ achievable: boolean;
25
+ };
26
+ /**
27
+ * Compare two score sets and calculate improvement
28
+ */
29
+ export declare function compareScores(oldScores: ReviewScores, newScores: ReviewScores): {
30
+ overall: number;
31
+ byCategory: Record<keyof ReviewScores, number>;
32
+ improved: boolean;
33
+ };
34
+ /**
35
+ * Get the weakest category that needs most improvement
36
+ */
37
+ export declare function getWeakestCategory(scores: ReviewScores): {
38
+ category: keyof ReviewScores;
39
+ score: number;
40
+ priority: 'high' | 'medium' | 'low';
41
+ };
42
+ /**
43
+ * Get the strongest category
44
+ */
45
+ export declare function getStrongestCategory(scores: ReviewScores): {
46
+ category: keyof ReviewScores;
47
+ score: number;
48
+ };
49
+ /**
50
+ * Calculate consistency score across categories
51
+ * Returns 100 if all scores are similar, lower if there's high variance
52
+ */
53
+ export declare function calculateConsistencyScore(scores: ReviewScores): number;
54
+ //# sourceMappingURL=scoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../src/scoring.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAiBlE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CASnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG;IAC9C,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;CACrB,CAiCA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,EACpB,WAAW,GAAE,MAAW,GACvB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAqBA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,YAAY,GACtB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,EAAE,OAAO,CAAC;CACnB,CAeA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG;IACxD,QAAQ,EAAE,MAAM,YAAY,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACrC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