@memberjunction/ng-query-viewer 0.0.1 → 3.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.
Files changed (34) hide show
  1. package/dist/lib/query-data-grid/models/query-grid-types.d.ts +252 -0
  2. package/dist/lib/query-data-grid/models/query-grid-types.d.ts.map +1 -0
  3. package/dist/lib/query-data-grid/models/query-grid-types.js +206 -0
  4. package/dist/lib/query-data-grid/models/query-grid-types.js.map +1 -0
  5. package/dist/lib/query-data-grid/query-data-grid.component.d.ts +242 -0
  6. package/dist/lib/query-data-grid/query-data-grid.component.d.ts.map +1 -0
  7. package/dist/lib/query-data-grid/query-data-grid.component.js +1122 -0
  8. package/dist/lib/query-data-grid/query-data-grid.component.js.map +1 -0
  9. package/dist/lib/query-info-panel/query-info-panel.component.d.ts +49 -0
  10. package/dist/lib/query-info-panel/query-info-panel.component.d.ts.map +1 -0
  11. package/dist/lib/query-info-panel/query-info-panel.component.js +579 -0
  12. package/dist/lib/query-info-panel/query-info-panel.component.js.map +1 -0
  13. package/dist/lib/query-parameter-form/query-parameter-form.component.d.ts +101 -0
  14. package/dist/lib/query-parameter-form/query-parameter-form.component.d.ts.map +1 -0
  15. package/dist/lib/query-parameter-form/query-parameter-form.component.js +650 -0
  16. package/dist/lib/query-parameter-form/query-parameter-form.component.js.map +1 -0
  17. package/dist/lib/query-row-detail/query-row-detail.component.d.ts +97 -0
  18. package/dist/lib/query-row-detail/query-row-detail.component.d.ts.map +1 -0
  19. package/dist/lib/query-row-detail/query-row-detail.component.js +750 -0
  20. package/dist/lib/query-row-detail/query-row-detail.component.js.map +1 -0
  21. package/dist/lib/query-viewer/query-viewer.component.d.ts +132 -0
  22. package/dist/lib/query-viewer/query-viewer.component.d.ts.map +1 -0
  23. package/dist/lib/query-viewer/query-viewer.component.js +539 -0
  24. package/dist/lib/query-viewer/query-viewer.component.js.map +1 -0
  25. package/dist/lib/query-viewer.module.d.ts +22 -0
  26. package/dist/lib/query-viewer.module.d.ts.map +1 -0
  27. package/dist/lib/query-viewer.module.js +71 -0
  28. package/dist/lib/query-viewer.module.js.map +1 -0
  29. package/dist/public-api.d.ts +8 -0
  30. package/dist/public-api.d.ts.map +1 -0
  31. package/dist/public-api.js +17 -0
  32. package/dist/public-api.js.map +1 -0
  33. package/package.json +49 -6
  34. package/README.md +0 -45
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Types and interfaces for the Query Data Grid component.
3
+ * These are tailored for query results which differ from entity data:
4
+ * - Read-only (no CRUD operations)
5
+ * - Client-side sorting only (query SQL defines ORDER BY)
6
+ * - No smart filter (parameters only)
7
+ * - Support for entity linking via SourceEntityID
8
+ */
9
+ import { QueryFieldInfo } from '@memberjunction/core';
10
+ /**
11
+ * Selection mode for the query grid
12
+ * - 'none': No selection allowed
13
+ * - 'single': Only one row can be selected at a time
14
+ * - 'multiple': Multiple rows can be selected (click to toggle)
15
+ * - 'checkbox': Checkbox column for selection
16
+ */
17
+ export type QueryGridSelectionMode = 'none' | 'single' | 'multiple' | 'checkbox';
18
+ /**
19
+ * Configuration for a query grid column
20
+ * Derived from QueryFieldInfo metadata
21
+ */
22
+ export interface QueryGridColumnConfig {
23
+ /** Field name from query results */
24
+ field: string;
25
+ /** Display title (defaults to field name) */
26
+ title: string;
27
+ /** Description/tooltip for the column header */
28
+ description?: string;
29
+ /** Column width in pixels */
30
+ width?: number;
31
+ /** Minimum width for resizing */
32
+ minWidth?: number;
33
+ /** Maximum width for resizing */
34
+ maxWidth?: number;
35
+ /** Column is visible */
36
+ visible: boolean;
37
+ /** Column is sortable (client-side) */
38
+ sortable: boolean;
39
+ /** Column is resizable */
40
+ resizable: boolean;
41
+ /** Column is reorderable */
42
+ reorderable: boolean;
43
+ /** SQL base type for formatting */
44
+ sqlBaseType: string;
45
+ /** SQL full type for display */
46
+ sqlFullType: string;
47
+ /** Text alignment */
48
+ align?: 'left' | 'center' | 'right';
49
+ /** Order/sequence of this column */
50
+ order: number;
51
+ /** Source entity ID if this column references an entity */
52
+ sourceEntityId?: string;
53
+ /** Source entity name if this column references an entity */
54
+ sourceEntityName?: string;
55
+ /** Source field name in the entity (e.g., 'ID' for primary key) */
56
+ sourceFieldName?: string;
57
+ /** Whether this column contains linkable entity IDs */
58
+ isEntityLink: boolean;
59
+ /**
60
+ * The entity name to navigate to when clicking the link.
61
+ * - For primary keys: this is the source entity itself
62
+ * - For foreign keys: this is the related entity the FK points to
63
+ */
64
+ targetEntityName?: string;
65
+ /**
66
+ * The entity ID to navigate to when clicking the link.
67
+ */
68
+ targetEntityId?: string;
69
+ /**
70
+ * Whether this field is a primary key of the source entity
71
+ */
72
+ isPrimaryKey?: boolean;
73
+ /**
74
+ * Whether this field is a foreign key to another entity
75
+ */
76
+ isForeignKey?: boolean;
77
+ /**
78
+ * Icon class for the target entity (from EntityInfo.Icon)
79
+ * Used to display the entity's icon in the column header
80
+ */
81
+ targetEntityIcon?: string;
82
+ /** Column pinning position */
83
+ pinned?: 'left' | 'right' | null;
84
+ /** Flex grow factor for auto-sizing */
85
+ flex?: number;
86
+ }
87
+ /**
88
+ * Sort state for a column (client-side sorting)
89
+ */
90
+ export interface QueryGridSortState {
91
+ /** Field name being sorted */
92
+ field: string;
93
+ /** Sort direction */
94
+ direction: 'asc' | 'desc';
95
+ /** Index for multi-sort ordering */
96
+ index: number;
97
+ }
98
+ /**
99
+ * Complete grid state for persistence to User Settings
100
+ */
101
+ export interface QueryGridState {
102
+ /** Column states */
103
+ columns: Array<{
104
+ field: string;
105
+ width?: number;
106
+ visible: boolean;
107
+ order: number;
108
+ pinned?: 'left' | 'right' | null;
109
+ }>;
110
+ /** Sort state (client-side) */
111
+ sort: QueryGridSortState[];
112
+ }
113
+ /**
114
+ * Parameter values for a query execution
115
+ */
116
+ export interface QueryParameterValues {
117
+ [parameterName: string]: string | number | boolean | Date | string[] | null;
118
+ }
119
+ /**
120
+ * Header style preset options
121
+ */
122
+ export type QueryGridHeaderStyle = 'flat' | 'elevated' | 'gradient' | 'bold';
123
+ /**
124
+ * Configuration for query grid visual appearance
125
+ */
126
+ export interface QueryGridVisualConfig {
127
+ /** Header style preset */
128
+ headerStyle?: QueryGridHeaderStyle;
129
+ /** Custom header background color */
130
+ headerBackground?: string;
131
+ /** Custom header text color */
132
+ headerTextColor?: string;
133
+ /** Show bottom shadow/border on header */
134
+ headerShadow?: boolean;
135
+ /** Enable alternating row colors (zebra striping) */
136
+ alternateRows?: boolean;
137
+ /** Contrast level for alternating rows */
138
+ alternateRowContrast?: 'subtle' | 'medium' | 'strong';
139
+ /** Enable smooth hover transitions */
140
+ hoverTransitions?: boolean;
141
+ /** Right-align numeric columns automatically */
142
+ rightAlignNumbers?: boolean;
143
+ /** Format dates with a friendly format */
144
+ friendlyDates?: boolean;
145
+ /** Render email cells as clickable mailto links */
146
+ clickableEmails?: boolean;
147
+ /** Render boolean cells as checkmark/x icons */
148
+ booleanIcons?: boolean;
149
+ /** Render URL cells as clickable links */
150
+ clickableUrls?: boolean;
151
+ /** Selection indicator color */
152
+ selectionIndicatorColor?: string;
153
+ /** Selection indicator width */
154
+ selectionIndicatorWidth?: number;
155
+ /** Selection background color */
156
+ selectionBackground?: string;
157
+ /** Checkbox style */
158
+ checkboxStyle?: 'default' | 'rounded' | 'filled';
159
+ /** Checkbox accent color */
160
+ checkboxColor?: string;
161
+ /** Show skeleton loading rows */
162
+ skeletonLoading?: boolean;
163
+ /** Number of skeleton rows */
164
+ skeletonRowCount?: number;
165
+ /** Border radius for container */
166
+ borderRadius?: number;
167
+ /** Cell padding preset */
168
+ cellPadding?: 'compact' | 'normal' | 'comfortable';
169
+ /** Primary accent color */
170
+ accentColor?: string;
171
+ }
172
+ /**
173
+ * Default visual configuration for query grid
174
+ */
175
+ export declare const DEFAULT_QUERY_VISUAL_CONFIG: Required<QueryGridVisualConfig>;
176
+ /**
177
+ * Export options for query results
178
+ */
179
+ export interface QueryExportOptions {
180
+ /** Export only visible columns */
181
+ visibleColumnsOnly?: boolean;
182
+ /** Export only selected rows */
183
+ selectedRowsOnly?: boolean;
184
+ /** Include headers */
185
+ includeHeaders?: boolean;
186
+ /** Custom column mapping */
187
+ columnMapping?: Record<string, string>;
188
+ }
189
+ /**
190
+ * Event fired when a row is clicked
191
+ */
192
+ export interface QueryRowClickEvent {
193
+ /** The row data */
194
+ rowData: Record<string, unknown>;
195
+ /** Row index */
196
+ rowIndex: number;
197
+ /** Column that was clicked */
198
+ column?: QueryGridColumnConfig;
199
+ /** Cell value */
200
+ cellValue?: unknown;
201
+ /** Original mouse event */
202
+ mouseEvent: MouseEvent;
203
+ }
204
+ /**
205
+ * Event fired when an entity link is clicked
206
+ */
207
+ export interface QueryEntityLinkClickEvent {
208
+ /** Entity name */
209
+ entityName: string;
210
+ /** Record ID (primary key value) */
211
+ recordId: string;
212
+ /** The column config (null if clicked from row detail panel) */
213
+ column: QueryGridColumnConfig | null;
214
+ /** The row data */
215
+ rowData: Record<string, unknown>;
216
+ }
217
+ /**
218
+ * Event fired when grid state changes
219
+ */
220
+ export interface QueryGridStateChangedEvent {
221
+ /** The new grid state */
222
+ state: QueryGridState;
223
+ /** What changed */
224
+ changeType: 'column-resize' | 'column-move' | 'column-visibility' | 'sort';
225
+ }
226
+ /**
227
+ * Event fired when selection changes
228
+ */
229
+ export interface QuerySelectionChangedEvent {
230
+ /** Selected row indices */
231
+ selectedIndices: number[];
232
+ /** Selected row data */
233
+ selectedRows: Record<string, unknown>[];
234
+ }
235
+ /**
236
+ * Builds column configs from QueryFieldInfo metadata
237
+ */
238
+ export declare function buildColumnsFromQueryFields(fields: QueryFieldInfo[]): QueryGridColumnConfig[];
239
+ /**
240
+ * Gets the User Settings key for query grid state
241
+ */
242
+ export declare function getQueryGridStateKey(queryId: string): string;
243
+ /**
244
+ * Gets the User Settings key for query parameters
245
+ */
246
+ export declare function getQueryParamsKey(queryId: string): string;
247
+ /**
248
+ * Infers column configuration from actual data when query has no field metadata.
249
+ * Examines the first row to determine column names and types.
250
+ */
251
+ export declare function buildColumnsFromData(data: Record<string, unknown>[]): QueryGridColumnConfig[];
252
+ //# sourceMappingURL=query-grid-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-grid-types.d.ts","sourceRoot":"","sources":["../../../../src/lib/query-data-grid/models/query-grid-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAa,cAAc,EAA6D,MAAM,sBAAsB,CAAC;AAM5H;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAMjF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IAEd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wBAAwB;IACxB,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAElB,0BAA0B;IAC1B,SAAS,EAAE,OAAO,CAAC;IAEnB,4BAA4B;IAC5B,WAAW,EAAE,OAAO,CAAC;IAErB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IAEpB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IAEpB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAEpC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IAEd,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,mEAAmE;IACnE,eAAe,CA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;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,wBAAwB;IACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CAC3C;AAsED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,qBAAqB,EAAE,CAkD7F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,qBAAqB,EAAE,CA2D7F"}
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Types and interfaces for the Query Data Grid component.
3
+ * These are tailored for query results which differ from entity data:
4
+ * - Read-only (no CRUD operations)
5
+ * - Client-side sorting only (query SQL defines ORDER BY)
6
+ * - No smart filter (parameters only)
7
+ * - Support for entity linking via SourceEntityID
8
+ */
9
+ import { Metadata } from '@memberjunction/core';
10
+ /**
11
+ * Default visual configuration for query grid
12
+ */
13
+ export const DEFAULT_QUERY_VISUAL_CONFIG = {
14
+ headerStyle: 'elevated',
15
+ headerBackground: '',
16
+ headerTextColor: '',
17
+ headerShadow: true,
18
+ alternateRows: true,
19
+ alternateRowContrast: 'medium',
20
+ hoverTransitions: true,
21
+ rightAlignNumbers: true,
22
+ friendlyDates: true,
23
+ clickableEmails: true,
24
+ booleanIcons: true,
25
+ clickableUrls: true,
26
+ selectionIndicatorColor: '#f9a825',
27
+ selectionIndicatorWidth: 3,
28
+ selectionBackground: '#fff9e6',
29
+ checkboxStyle: 'rounded',
30
+ checkboxColor: '#2196F3',
31
+ skeletonLoading: true,
32
+ skeletonRowCount: 8,
33
+ borderRadius: 0,
34
+ cellPadding: 'normal',
35
+ accentColor: '#2196F3'
36
+ };
37
+ /**
38
+ * Determines the target entity for navigation based on source entity field metadata.
39
+ * - If the source field is a primary key, target is the source entity itself
40
+ * - If the source field is a foreign key, target is the related entity
41
+ * Also retrieves the target entity's icon for display in column headers.
42
+ */
43
+ function resolveTargetEntity(sourceEntityName, sourceFieldName, md) {
44
+ if (!sourceEntityName || !sourceFieldName) {
45
+ return { isPrimaryKey: false, isForeignKey: false };
46
+ }
47
+ // Look up the source entity
48
+ const sourceEntity = md.Entities.find(e => e.Name === sourceEntityName);
49
+ if (!sourceEntity) {
50
+ return { isPrimaryKey: false, isForeignKey: false };
51
+ }
52
+ // Find the field in the source entity
53
+ const entityField = sourceEntity.Fields.find(f => f.Name === sourceFieldName);
54
+ if (!entityField) {
55
+ return { isPrimaryKey: false, isForeignKey: false };
56
+ }
57
+ // Check if it's a primary key
58
+ if (entityField.IsPrimaryKey) {
59
+ return {
60
+ targetEntityName: sourceEntityName,
61
+ targetEntityId: sourceEntity.ID,
62
+ targetEntityIcon: sourceEntity.Icon || undefined,
63
+ isPrimaryKey: true,
64
+ isForeignKey: false
65
+ };
66
+ }
67
+ // Check if it's a foreign key (has RelatedEntity)
68
+ if (entityField.RelatedEntity && entityField.RelatedEntity.trim().length > 0) {
69
+ const relatedEntity = md.Entities.find(e => e.Name === entityField.RelatedEntity);
70
+ return {
71
+ targetEntityName: entityField.RelatedEntity,
72
+ targetEntityId: relatedEntity?.ID,
73
+ targetEntityIcon: relatedEntity?.Icon || undefined,
74
+ isPrimaryKey: false,
75
+ isForeignKey: true
76
+ };
77
+ }
78
+ return { isPrimaryKey: false, isForeignKey: false };
79
+ }
80
+ /**
81
+ * Builds column configs from QueryFieldInfo metadata
82
+ */
83
+ export function buildColumnsFromQueryFields(fields) {
84
+ const md = new Metadata();
85
+ return fields
86
+ .sort((a, b) => (a.Sequence || 0) - (b.Sequence || 0))
87
+ .map((field, index) => {
88
+ // Resolve the target entity using metadata
89
+ const targetInfo = resolveTargetEntity(field.SourceEntity, field.SourceFieldName, md);
90
+ // Determine if this is an entity link
91
+ // It's linkable if we have a valid target entity (either PK or FK)
92
+ const isEntityLink = !!(targetInfo.targetEntityName && (targetInfo.isPrimaryKey || targetInfo.isForeignKey));
93
+ // Determine alignment based on type
94
+ let align = 'left';
95
+ const baseType = (field.SQLBaseType || '').toLowerCase();
96
+ if (['int', 'bigint', 'decimal', 'numeric', 'float', 'money', 'smallmoney', 'real'].includes(baseType)) {
97
+ align = 'right';
98
+ }
99
+ else if (['bit'].includes(baseType)) {
100
+ align = 'center';
101
+ }
102
+ return {
103
+ field: field.Name,
104
+ title: field.Name, // Could be enhanced to parse CamelCase
105
+ description: field.Description || undefined,
106
+ width: undefined,
107
+ minWidth: 80,
108
+ maxWidth: undefined, // No max width limit - let users resize freely
109
+ visible: true,
110
+ sortable: true,
111
+ resizable: true,
112
+ reorderable: true,
113
+ sqlBaseType: field.SQLBaseType || 'nvarchar',
114
+ sqlFullType: field.SQLFullType || 'nvarchar(max)',
115
+ align,
116
+ order: index,
117
+ sourceEntityId: field.SourceEntityID || undefined,
118
+ sourceEntityName: field.SourceEntity || undefined,
119
+ sourceFieldName: field.SourceFieldName || undefined,
120
+ isEntityLink,
121
+ targetEntityName: targetInfo.targetEntityName,
122
+ targetEntityId: targetInfo.targetEntityId,
123
+ isPrimaryKey: targetInfo.isPrimaryKey,
124
+ isForeignKey: targetInfo.isForeignKey,
125
+ targetEntityIcon: targetInfo.targetEntityIcon,
126
+ pinned: null,
127
+ flex: undefined
128
+ };
129
+ });
130
+ }
131
+ /**
132
+ * Gets the User Settings key for query grid state
133
+ */
134
+ export function getQueryGridStateKey(queryId) {
135
+ return `QueryViewer_${queryId}_GridState`;
136
+ }
137
+ /**
138
+ * Gets the User Settings key for query parameters
139
+ */
140
+ export function getQueryParamsKey(queryId) {
141
+ return `QueryViewer_${queryId}_LastParams`;
142
+ }
143
+ /**
144
+ * Infers column configuration from actual data when query has no field metadata.
145
+ * Examines the first row to determine column names and types.
146
+ */
147
+ export function buildColumnsFromData(data) {
148
+ if (!data || data.length === 0) {
149
+ return [];
150
+ }
151
+ // Get column names from first row
152
+ const firstRow = data[0];
153
+ const columnNames = Object.keys(firstRow);
154
+ return columnNames.map((name, index) => {
155
+ // Infer type from value
156
+ const value = firstRow[name];
157
+ let sqlBaseType = 'nvarchar';
158
+ let align = 'left';
159
+ if (typeof value === 'number') {
160
+ sqlBaseType = Number.isInteger(value) ? 'int' : 'decimal';
161
+ align = 'right';
162
+ }
163
+ else if (typeof value === 'boolean') {
164
+ sqlBaseType = 'bit';
165
+ align = 'center';
166
+ }
167
+ else if (value instanceof Date) {
168
+ sqlBaseType = 'datetime';
169
+ }
170
+ else if (typeof value === 'string') {
171
+ // Check if it looks like a date
172
+ const datePattern = /^\d{4}-\d{2}-\d{2}/;
173
+ if (datePattern.test(value)) {
174
+ sqlBaseType = 'datetime';
175
+ }
176
+ }
177
+ return {
178
+ field: name,
179
+ title: name,
180
+ description: undefined,
181
+ width: undefined,
182
+ minWidth: 80,
183
+ maxWidth: undefined,
184
+ visible: true,
185
+ sortable: true,
186
+ resizable: true,
187
+ reorderable: true,
188
+ sqlBaseType,
189
+ sqlFullType: sqlBaseType,
190
+ align,
191
+ order: index,
192
+ sourceEntityId: undefined,
193
+ sourceEntityName: undefined,
194
+ sourceFieldName: undefined,
195
+ isEntityLink: false,
196
+ targetEntityName: undefined,
197
+ targetEntityId: undefined,
198
+ isPrimaryKey: false,
199
+ isForeignKey: false,
200
+ targetEntityIcon: undefined,
201
+ pinned: null,
202
+ flex: undefined
203
+ };
204
+ });
205
+ }
206
+ //# sourceMappingURL=query-grid-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-grid-types.js","sourceRoot":"","sources":["../../../../src/lib/query-data-grid/models/query-grid-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiD,QAAQ,EAA+B,MAAM,sBAAsB,CAAC;AA2N5H;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA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