@ifc-lite/cli 0.2.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.
- package/LICENSE +373 -0
- package/dist/commands/bcf.d.ts +2 -0
- package/dist/commands/bcf.d.ts.map +1 -0
- package/dist/commands/bcf.js +78 -0
- package/dist/commands/bcf.js.map +1 -0
- package/dist/commands/bsdd.d.ts +2 -0
- package/dist/commands/bsdd.d.ts.map +1 -0
- package/dist/commands/bsdd.js +73 -0
- package/dist/commands/bsdd.js.map +1 -0
- package/dist/commands/convert.d.ts +2 -0
- package/dist/commands/convert.d.ts.map +1 -0
- package/dist/commands/convert.js +49 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +430 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/diff.d.ts +2 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +106 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/eval.d.ts +2 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/eval.js +47 -0
- package/dist/commands/eval.js.map +1 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +62 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/ids.d.ts +2 -0
- package/dist/commands/ids.d.ts.map +1 -0
- package/dist/commands/ids.js +187 -0
- package/dist/commands/ids.js.map +1 -0
- package/dist/commands/info.d.ts +2 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +77 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/merge.d.ts +2 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.js +60 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/props.d.ts +2 -0
- package/dist/commands/props.d.ts.map +1 -0
- package/dist/commands/props.js +40 -0
- package/dist/commands/props.js.map +1 -0
- package/dist/commands/query.d.ts +2 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +124 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/run.d.ts +2 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +43 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/schema.d.ts +2 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +107 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +111 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/headless-backend.d.ts +36 -0
- package/dist/headless-backend.d.ts.map +1 -0
- package/dist/headless-backend.js +441 -0
- package/dist/headless-backend.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +174 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +15 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +46 -0
- package/dist/loader.js.map +1 -0
- package/dist/output.d.ts +30 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +90 -0
- package/dist/output.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite export <file.ifc> --format csv|json|ifc [options]
|
|
6
|
+
*
|
|
7
|
+
* Export IFC data to CSV, JSON, or IFC STEP format.
|
|
8
|
+
* Supports type filtering, column selection, and schema conversion on export.
|
|
9
|
+
*/
|
|
10
|
+
import { writeFile } from 'node:fs/promises';
|
|
11
|
+
import { createHeadlessContext } from '../loader.js';
|
|
12
|
+
import { getFlag, fatal, writeOutput } from '../output.js';
|
|
13
|
+
export async function exportCommand(args) {
|
|
14
|
+
const filePath = args.find(a => !a.startsWith('-'));
|
|
15
|
+
const format = getFlag(args, '--format') ?? 'csv';
|
|
16
|
+
const outPath = getFlag(args, '--out');
|
|
17
|
+
const type = getFlag(args, '--type');
|
|
18
|
+
const columnsStr = getFlag(args, '--columns');
|
|
19
|
+
const separator = getFlag(args, '--separator') ?? ',';
|
|
20
|
+
const limit = getFlag(args, '--limit');
|
|
21
|
+
if (!filePath)
|
|
22
|
+
fatal('Usage: ifc-lite export <file.ifc> --format csv|json|ifc [--type IfcWall] [--columns Name,Type,GlobalId] [--out file]');
|
|
23
|
+
const { bim } = await createHeadlessContext(filePath);
|
|
24
|
+
// Build entity query
|
|
25
|
+
let q = bim.query();
|
|
26
|
+
if (type) {
|
|
27
|
+
q = q.byType(...type.split(','));
|
|
28
|
+
}
|
|
29
|
+
if (limit) {
|
|
30
|
+
q = q.limit(parseInt(limit, 10));
|
|
31
|
+
}
|
|
32
|
+
const entities = q.toArray();
|
|
33
|
+
const refs = entities.map(e => e.ref);
|
|
34
|
+
const columns = columnsStr
|
|
35
|
+
? columnsStr.split(',')
|
|
36
|
+
: ['Type', 'Name', 'GlobalId', 'Description', 'ObjectType'];
|
|
37
|
+
switch (format) {
|
|
38
|
+
case 'csv': {
|
|
39
|
+
const csv = bim.export.csv(refs, { columns, separator });
|
|
40
|
+
await writeOutput(csv, outPath);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'json': {
|
|
44
|
+
const json = bim.export.json(refs, columns);
|
|
45
|
+
const content = JSON.stringify(json, null, 2);
|
|
46
|
+
await writeOutput(content, outPath);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'ifc': {
|
|
50
|
+
const schema = getFlag(args, '--schema');
|
|
51
|
+
const content = bim.export.ifc(refs, { schema });
|
|
52
|
+
if (!outPath)
|
|
53
|
+
fatal('--out is required for IFC export');
|
|
54
|
+
await writeFile(outPath, content, 'utf-8');
|
|
55
|
+
process.stderr.write(`Written to ${outPath}\n`);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
fatal(`Unknown format: ${format}. Supported: csv, json, ifc`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAW,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,KAAK,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,CAAC;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAEvC,IAAI,CAAC,QAAQ;QAAE,KAAK,CAAC,sHAAsH,CAAC,CAAC;IAE7I,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,qBA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YACpC,MAAM;QACR,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAA6C,CAAC;YACrF,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,OAAO;gBAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACxD,MAAM,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,OAAO,IAAI,CAAC,CAAC;YAChD,MAAM;QACR,CAAC;QACD;YACE,KAAK,CAAC,mBAAmB,MAAM,6BAA6B,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/commands/ids.ts"],"names":[],"mappings":"AAsBA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgD9D"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite ids <file.ifc> <rules.ids> [options]
|
|
6
|
+
*
|
|
7
|
+
* Validate an IFC file against IDS (Information Delivery Specification) rules.
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { createHeadlessContext } from '../loader.js';
|
|
11
|
+
import { printJson, hasFlag, getFlag, fatal } from '../output.js';
|
|
12
|
+
import { EntityNode } from '@ifc-lite/query';
|
|
13
|
+
import { extractClassificationsOnDemand, extractMaterialsOnDemand, extractAllEntityAttributes, } from '@ifc-lite/parser';
|
|
14
|
+
import { RelationshipType } from '@ifc-lite/data';
|
|
15
|
+
export async function idsCommand(args) {
|
|
16
|
+
const positional = args.filter(a => !a.startsWith('-'));
|
|
17
|
+
if (positional.length < 2)
|
|
18
|
+
fatal('Usage: ifc-lite ids <file.ifc> <rules.ids> [--json]');
|
|
19
|
+
const [ifcPath, idsPath] = positional;
|
|
20
|
+
const jsonOutput = hasFlag(args, '--json');
|
|
21
|
+
const locale = (getFlag(args, '--locale') ?? 'en');
|
|
22
|
+
const { bim, store } = await createHeadlessContext(ifcPath);
|
|
23
|
+
// Read IDS file
|
|
24
|
+
const idsContent = await readFile(idsPath, 'utf-8');
|
|
25
|
+
// Parse and validate
|
|
26
|
+
const idsDoc = await bim.ids.parse(idsContent);
|
|
27
|
+
// Build accessor for validation
|
|
28
|
+
const accessor = buildIdsAccessor(store);
|
|
29
|
+
const report = await bim.ids.validate(idsDoc, {
|
|
30
|
+
accessor,
|
|
31
|
+
modelInfo: { schemaVersion: store.schemaVersion },
|
|
32
|
+
locale,
|
|
33
|
+
onProgress: (p) => {
|
|
34
|
+
if (!jsonOutput) {
|
|
35
|
+
process.stderr.write(`\r Validating: ${p.specName} (${p.current}/${p.total})`);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (!jsonOutput)
|
|
40
|
+
process.stderr.write('\n');
|
|
41
|
+
const summary = bim.ids.summarize(report);
|
|
42
|
+
if (jsonOutput) {
|
|
43
|
+
printJson({ summary, report });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write(`\n IDS Validation Results\n`);
|
|
47
|
+
process.stdout.write(` ─────────────────────\n`);
|
|
48
|
+
process.stdout.write(` Specifications: ${summary.passedSpecifications}/${summary.totalSpecifications} passed\n`);
|
|
49
|
+
process.stdout.write(` Entities: ${summary.passedEntities}/${summary.totalEntities} passed\n`);
|
|
50
|
+
process.stdout.write(` Failed: ${summary.failedEntities} entities in ${summary.failedSpecifications} specs\n`);
|
|
51
|
+
const exitCode = summary.failedSpecifications > 0 ? 1 : 0;
|
|
52
|
+
process.stdout.write(`\n Result: ${exitCode === 0 ? 'PASS' : 'FAIL'}\n\n`);
|
|
53
|
+
process.exitCode = exitCode;
|
|
54
|
+
}
|
|
55
|
+
const REL_TYPE_MAP = {
|
|
56
|
+
IfcRelAggregates: RelationshipType.Aggregates,
|
|
57
|
+
IfcRelContainedInSpatialStructure: RelationshipType.ContainsElements,
|
|
58
|
+
IfcRelNests: RelationshipType.Aggregates, // closest mapping
|
|
59
|
+
IfcRelVoidsElement: RelationshipType.VoidsElement,
|
|
60
|
+
IfcRelFillsElement: RelationshipType.FillsElement,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Build a complete IFCDataAccessor for the IDS validator.
|
|
64
|
+
* Implements all 12+ methods the validator expects.
|
|
65
|
+
*/
|
|
66
|
+
function buildIdsAccessor(store) {
|
|
67
|
+
return {
|
|
68
|
+
getEntityType(expressId) {
|
|
69
|
+
return store.entities.getTypeName(expressId) || undefined;
|
|
70
|
+
},
|
|
71
|
+
getEntityName(expressId) {
|
|
72
|
+
const node = new EntityNode(store, expressId);
|
|
73
|
+
return node.name || undefined;
|
|
74
|
+
},
|
|
75
|
+
getGlobalId(expressId) {
|
|
76
|
+
const node = new EntityNode(store, expressId);
|
|
77
|
+
return node.globalId || undefined;
|
|
78
|
+
},
|
|
79
|
+
getDescription(expressId) {
|
|
80
|
+
const node = new EntityNode(store, expressId);
|
|
81
|
+
return node.description || undefined;
|
|
82
|
+
},
|
|
83
|
+
getObjectType(expressId) {
|
|
84
|
+
const node = new EntityNode(store, expressId);
|
|
85
|
+
return node.objectType || undefined;
|
|
86
|
+
},
|
|
87
|
+
getEntitiesByType(typeName) {
|
|
88
|
+
const upper = typeName.toUpperCase();
|
|
89
|
+
return [...(store.entityIndex.byType.get(upper) ?? [])];
|
|
90
|
+
},
|
|
91
|
+
getAllEntityIds() {
|
|
92
|
+
const ids = [];
|
|
93
|
+
for (const [, typeIds] of store.entityIndex.byType) {
|
|
94
|
+
for (const id of typeIds)
|
|
95
|
+
ids.push(id);
|
|
96
|
+
}
|
|
97
|
+
return ids;
|
|
98
|
+
},
|
|
99
|
+
getPropertyValue(expressId, propertySetName, propertyName) {
|
|
100
|
+
const node = new EntityNode(store, expressId);
|
|
101
|
+
const psets = node.properties();
|
|
102
|
+
for (const pset of psets) {
|
|
103
|
+
if (pset.name === propertySetName) {
|
|
104
|
+
for (const prop of pset.properties) {
|
|
105
|
+
if (prop.name === propertyName) {
|
|
106
|
+
return {
|
|
107
|
+
value: prop.value ?? null,
|
|
108
|
+
dataType: prop.type ?? 'IFCLABEL',
|
|
109
|
+
propertySetName: pset.name,
|
|
110
|
+
propertyName: prop.name,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
},
|
|
118
|
+
getPropertySets(expressId) {
|
|
119
|
+
const node = new EntityNode(store, expressId);
|
|
120
|
+
return node.properties().map(pset => ({
|
|
121
|
+
name: pset.name,
|
|
122
|
+
properties: pset.properties.map(p => ({
|
|
123
|
+
name: p.name,
|
|
124
|
+
value: p.value ?? null,
|
|
125
|
+
dataType: p.type ?? 'IFCLABEL',
|
|
126
|
+
})),
|
|
127
|
+
}));
|
|
128
|
+
},
|
|
129
|
+
getClassifications(expressId) {
|
|
130
|
+
const classifications = extractClassificationsOnDemand(store, expressId);
|
|
131
|
+
return classifications.map(c => ({
|
|
132
|
+
system: c.system ?? '',
|
|
133
|
+
value: c.identification ?? '',
|
|
134
|
+
name: c.name ?? undefined,
|
|
135
|
+
}));
|
|
136
|
+
},
|
|
137
|
+
getMaterials(expressId) {
|
|
138
|
+
const materialData = extractMaterialsOnDemand(store, expressId);
|
|
139
|
+
if (!materialData)
|
|
140
|
+
return [];
|
|
141
|
+
const materials = [];
|
|
142
|
+
if (materialData.name) {
|
|
143
|
+
materials.push({ name: materialData.name });
|
|
144
|
+
}
|
|
145
|
+
if (materialData.layers) {
|
|
146
|
+
for (const layer of materialData.layers) {
|
|
147
|
+
if (layer.materialName) {
|
|
148
|
+
materials.push({ name: layer.materialName, category: layer.category ?? undefined });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return materials;
|
|
153
|
+
},
|
|
154
|
+
getParent(expressId, relationType) {
|
|
155
|
+
const relEnum = REL_TYPE_MAP[relationType];
|
|
156
|
+
if (relEnum === undefined)
|
|
157
|
+
return undefined;
|
|
158
|
+
const parents = store.relationships.getRelated(expressId, relEnum, 'inverse');
|
|
159
|
+
if (parents.length === 0)
|
|
160
|
+
return undefined;
|
|
161
|
+
const parentId = parents[0];
|
|
162
|
+
const parentType = store.entities.getTypeName(parentId);
|
|
163
|
+
return {
|
|
164
|
+
expressId: parentId,
|
|
165
|
+
entityType: parentType ?? '',
|
|
166
|
+
predefinedType: undefined,
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
getAttribute(expressId, attributeName) {
|
|
170
|
+
const node = new EntityNode(store, expressId);
|
|
171
|
+
switch (attributeName) {
|
|
172
|
+
case 'Name': return node.name || undefined;
|
|
173
|
+
case 'Description': return node.description || undefined;
|
|
174
|
+
case 'ObjectType': return node.objectType || undefined;
|
|
175
|
+
case 'GlobalId': return node.globalId || undefined;
|
|
176
|
+
case 'Tag': return node.tag || undefined;
|
|
177
|
+
default: {
|
|
178
|
+
// Fall back to full attribute extraction
|
|
179
|
+
const attrs = extractAllEntityAttributes(store, expressId);
|
|
180
|
+
const attr = attrs.find(a => a.name === attributeName);
|
|
181
|
+
return attr?.value != null ? String(attr.value) : undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources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Y,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,IAAI,SAAS,CAAC;gBACvD,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,QAAQ,IAAI,SAAS,CAAC;gBACnD,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC;gBACzC,OAAO,CAAC,CAAC,CAAC;oBACR,yCAAyC;oBACzC,MAAM,KAAK,GAAG,0BAA0B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;oBAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;oBACvD,OAAO,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC9D,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAcA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE/D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite info <file.ifc>
|
|
6
|
+
*
|
|
7
|
+
* Print a summary of an IFC file: schema, entity counts, spatial structure.
|
|
8
|
+
*/
|
|
9
|
+
import { loadIfcFile } from '../loader.js';
|
|
10
|
+
import { printJson, formatTable, hasFlag, fatal } from '../output.js';
|
|
11
|
+
import { EntityNode } from '@ifc-lite/query';
|
|
12
|
+
export async function infoCommand(args) {
|
|
13
|
+
const filePath = args.find(a => !a.startsWith('-'));
|
|
14
|
+
if (!filePath)
|
|
15
|
+
fatal('Usage: ifc-lite info <file.ifc> [--format json|table]');
|
|
16
|
+
const jsonOutput = hasFlag(args, '--json') || args.includes('--format') && args[args.indexOf('--format') + 1] === 'json';
|
|
17
|
+
const store = await loadIfcFile(filePath);
|
|
18
|
+
// Collect type counts
|
|
19
|
+
const typeCounts = {};
|
|
20
|
+
for (const [typeName, ids] of store.entityIndex.byType) {
|
|
21
|
+
if (ids.length > 0) {
|
|
22
|
+
// Convert to PascalCase display name
|
|
23
|
+
const displayName = store.entities.getTypeName(ids[0]) || typeName;
|
|
24
|
+
typeCounts[displayName] = (typeCounts[displayName] ?? 0) + ids.length;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Collect storeys
|
|
28
|
+
const storeyIds = store.entityIndex.byType.get('IFCBUILDINGSTOREY') ?? [];
|
|
29
|
+
const storeys = storeyIds.map(id => {
|
|
30
|
+
const node = new EntityNode(store, id);
|
|
31
|
+
return { name: node.name, expressId: id };
|
|
32
|
+
});
|
|
33
|
+
const summary = {
|
|
34
|
+
file: filePath,
|
|
35
|
+
schema: store.schemaVersion,
|
|
36
|
+
fileSize: store.fileSize,
|
|
37
|
+
fileSizeHuman: formatSize(store.fileSize),
|
|
38
|
+
entityCount: store.entityCount,
|
|
39
|
+
parseTime: `${store.parseTime.toFixed(0)}ms`,
|
|
40
|
+
storeys: storeys.map(s => s.name),
|
|
41
|
+
typeCounts,
|
|
42
|
+
};
|
|
43
|
+
if (jsonOutput) {
|
|
44
|
+
printJson(summary);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Table output
|
|
48
|
+
process.stdout.write(`\n File: ${filePath}\n`);
|
|
49
|
+
process.stdout.write(` Schema: ${store.schemaVersion}\n`);
|
|
50
|
+
process.stdout.write(` Size: ${summary.fileSizeHuman}\n`);
|
|
51
|
+
process.stdout.write(` Entities: ${store.entityCount.toLocaleString()}\n`);
|
|
52
|
+
process.stdout.write(` Parsed: ${summary.parseTime}\n`);
|
|
53
|
+
if (storeys.length > 0) {
|
|
54
|
+
process.stdout.write(`\n Storeys:\n`);
|
|
55
|
+
for (const s of storeys) {
|
|
56
|
+
process.stdout.write(` - ${s.name || '(unnamed)'}\n`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Top entity types
|
|
60
|
+
const sorted = Object.entries(typeCounts)
|
|
61
|
+
.filter(([name]) => !name.startsWith('IfcRel') && !name.startsWith('IfcProperty') && !name.startsWith('IfcQuantity'))
|
|
62
|
+
.sort((a, b) => b[1] - a[1])
|
|
63
|
+
.slice(0, 20);
|
|
64
|
+
if (sorted.length > 0) {
|
|
65
|
+
process.stdout.write(`\n Entity types (top ${sorted.length}):\n`);
|
|
66
|
+
process.stdout.write(formatTable(['Type', 'Count'], sorted.map(([name, count]) => [name, count.toLocaleString()])).split('\n').map(l => ' ' + l).join('\n') + '\n');
|
|
67
|
+
}
|
|
68
|
+
process.stdout.write('\n');
|
|
69
|
+
}
|
|
70
|
+
function formatSize(bytes) {
|
|
71
|
+
if (bytes < 1024)
|
|
72
|
+
return `${bytes} B`;
|
|
73
|
+
if (bytes < 1024 * 1024)
|
|
74
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
75
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;A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AAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":"AAgBA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDhE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite merge <file1.ifc> <file2.ifc> [...] --out <merged.ifc>
|
|
6
|
+
*
|
|
7
|
+
* Merge multiple IFC files into a single file.
|
|
8
|
+
* Spatial hierarchy (storeys, buildings) is unified by name/elevation.
|
|
9
|
+
*/
|
|
10
|
+
import { writeFile } from 'node:fs/promises';
|
|
11
|
+
import { basename } from 'node:path';
|
|
12
|
+
import { loadIfcFile } from '../loader.js';
|
|
13
|
+
import { getFlag, hasFlag, fatal, printJson } from '../output.js';
|
|
14
|
+
export async function mergeCommand(args) {
|
|
15
|
+
const outPath = getFlag(args, '--out');
|
|
16
|
+
if (!outPath)
|
|
17
|
+
fatal('--out is required: ifc-lite merge <file1.ifc> <file2.ifc> --out merged.ifc');
|
|
18
|
+
const schema = getFlag(args, '--schema');
|
|
19
|
+
const jsonOutput = hasFlag(args, '--json');
|
|
20
|
+
// Collect all positional args as input files
|
|
21
|
+
const files = [];
|
|
22
|
+
for (let i = 0; i < args.length; i++) {
|
|
23
|
+
if (args[i].startsWith('-')) {
|
|
24
|
+
if (args[i] === '--out' || args[i] === '--schema')
|
|
25
|
+
i++; // skip value
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
files.push(args[i]);
|
|
29
|
+
}
|
|
30
|
+
if (files.length < 2)
|
|
31
|
+
fatal('At least 2 IFC files are required for merge');
|
|
32
|
+
process.stderr.write(`Loading ${files.length} files...\n`);
|
|
33
|
+
const models = [];
|
|
34
|
+
for (let i = 0; i < files.length; i++) {
|
|
35
|
+
const store = await loadIfcFile(files[i]);
|
|
36
|
+
models.push({
|
|
37
|
+
id: `model-${i}`,
|
|
38
|
+
name: basename(files[i]),
|
|
39
|
+
dataStore: store,
|
|
40
|
+
});
|
|
41
|
+
process.stderr.write(` Loaded ${files[i]} (${store.entityCount} entities)\n`);
|
|
42
|
+
}
|
|
43
|
+
// Dynamic import to avoid loading the exporter unless needed
|
|
44
|
+
const { MergedExporter } = await import('@ifc-lite/export');
|
|
45
|
+
const exporter = new MergedExporter(models);
|
|
46
|
+
const result = exporter.export({ schema: (schema ?? 'IFC4') });
|
|
47
|
+
await writeFile(outPath, result.content, 'utf-8');
|
|
48
|
+
if (jsonOutput) {
|
|
49
|
+
printJson({
|
|
50
|
+
file: outPath,
|
|
51
|
+
modelCount: result.stats.modelCount,
|
|
52
|
+
totalEntityCount: result.stats.totalEntityCount,
|
|
53
|
+
fileSize: result.stats.fileSize,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
process.stderr.write(`Merged ${result.stats.modelCount} models → ${outPath} (${result.stats.totalEntityCount} entities)\n`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;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ACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/commands/props.ts"],"names":[],"mappings":"AAaA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BhE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite props <file.ifc> --id <expressId>
|
|
6
|
+
*
|
|
7
|
+
* Show all properties, quantities, materials, and classifications for an entity.
|
|
8
|
+
*/
|
|
9
|
+
import { createHeadlessContext } from '../loader.js';
|
|
10
|
+
import { printJson, getFlag, fatal } from '../output.js';
|
|
11
|
+
export async function propsCommand(args) {
|
|
12
|
+
const filePath = args.find(a => !a.startsWith('-'));
|
|
13
|
+
const idStr = getFlag(args, '--id');
|
|
14
|
+
if (!filePath || !idStr)
|
|
15
|
+
fatal('Usage: ifc-lite props <file.ifc> --id <expressId>');
|
|
16
|
+
const expressId = parseInt(idStr, 10);
|
|
17
|
+
if (isNaN(expressId))
|
|
18
|
+
fatal('--id must be a number');
|
|
19
|
+
const { bim } = await createHeadlessContext(filePath);
|
|
20
|
+
const ref = { modelId: 'default', expressId };
|
|
21
|
+
const entity = bim.entity(ref);
|
|
22
|
+
if (!entity)
|
|
23
|
+
fatal(`Entity #${expressId} not found`);
|
|
24
|
+
const result = {
|
|
25
|
+
type: entity.type,
|
|
26
|
+
name: entity.name,
|
|
27
|
+
globalId: entity.globalId,
|
|
28
|
+
description: entity.description || undefined,
|
|
29
|
+
objectType: entity.objectType || undefined,
|
|
30
|
+
attributes: bim.attributes(ref),
|
|
31
|
+
properties: bim.properties(ref),
|
|
32
|
+
quantities: bim.quantities(ref),
|
|
33
|
+
classifications: bim.classifications(ref),
|
|
34
|
+
materials: bim.materials(ref),
|
|
35
|
+
typeProperties: bim.typeProperties(ref),
|
|
36
|
+
relationships: bim.relationships(ref),
|
|
37
|
+
};
|
|
38
|
+
printJson(result);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/commands/props.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK;QAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAEpF,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,SAAS,CAAC;QAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAErD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM;QAAE,KAAK,CAAC,WAAW,SAAS,YAAY,CAAC,CAAC;IAErD,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,SAAS;QAC5C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,SAAS;QAC1C,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAC/B,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAC/B,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAC/B,eAAe,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;QACzC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC;QAC7B,cAAc,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC;QACvC,aAAa,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC;KACtC,CAAC;IAEF,SAAS,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAeA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAyGhE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* ifc-lite query <file.ifc> [options]
|
|
6
|
+
*
|
|
7
|
+
* Query entities from an IFC file with type and property filters.
|
|
8
|
+
* Supports all entity data: properties, quantities, materials,
|
|
9
|
+
* classifications, attributes, relationships, type properties.
|
|
10
|
+
*/
|
|
11
|
+
import { createHeadlessContext } from '../loader.js';
|
|
12
|
+
import { printJson, formatTable, getFlag, hasFlag, fatal } from '../output.js';
|
|
13
|
+
export async function queryCommand(args) {
|
|
14
|
+
const filePath = args.find(a => !a.startsWith('-'));
|
|
15
|
+
if (!filePath)
|
|
16
|
+
fatal('Usage: ifc-lite query <file.ifc> --type IfcWall [--props] [--limit N]');
|
|
17
|
+
const type = getFlag(args, '--type');
|
|
18
|
+
const limit = getFlag(args, '--limit');
|
|
19
|
+
const offset = getFlag(args, '--offset');
|
|
20
|
+
const propFilter = getFlag(args, '--where');
|
|
21
|
+
const showProps = hasFlag(args, '--props');
|
|
22
|
+
const showQuantities = hasFlag(args, '--quantities');
|
|
23
|
+
const showMaterials = hasFlag(args, '--materials');
|
|
24
|
+
const showClassifications = hasFlag(args, '--classifications');
|
|
25
|
+
const showAttributes = hasFlag(args, '--attributes');
|
|
26
|
+
const showRelationships = hasFlag(args, '--relationships');
|
|
27
|
+
const showTypeProps = hasFlag(args, '--type-props');
|
|
28
|
+
const showDocuments = hasFlag(args, '--documents');
|
|
29
|
+
const showAll = hasFlag(args, '--all');
|
|
30
|
+
const jsonOutput = hasFlag(args, '--json');
|
|
31
|
+
const countOnly = hasFlag(args, '--count');
|
|
32
|
+
const spatial = hasFlag(args, '--spatial');
|
|
33
|
+
const { bim } = await createHeadlessContext(filePath);
|
|
34
|
+
// Spatial tree mode
|
|
35
|
+
if (spatial) {
|
|
36
|
+
const storeys = bim.storeys();
|
|
37
|
+
const tree = {};
|
|
38
|
+
for (const storey of storeys) {
|
|
39
|
+
const contained = bim.contains(storey.ref);
|
|
40
|
+
tree[storey.name || `Storey #${storey.ref.expressId}`] = contained.map(e => ({
|
|
41
|
+
type: e.type,
|
|
42
|
+
name: e.name,
|
|
43
|
+
globalId: e.globalId,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
printJson(tree);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// Build query
|
|
50
|
+
let q = bim.query();
|
|
51
|
+
if (type) {
|
|
52
|
+
const types = type.split(',');
|
|
53
|
+
q = q.byType(...types);
|
|
54
|
+
}
|
|
55
|
+
if (propFilter) {
|
|
56
|
+
// Format: "PsetName.PropName=Value" or "PsetName.PropName"
|
|
57
|
+
const eqIdx = propFilter.indexOf('=');
|
|
58
|
+
const dotIdx = propFilter.indexOf('.');
|
|
59
|
+
if (dotIdx > 0) {
|
|
60
|
+
const psetName = propFilter.slice(0, dotIdx);
|
|
61
|
+
if (eqIdx > dotIdx) {
|
|
62
|
+
const propName = propFilter.slice(dotIdx + 1, eqIdx);
|
|
63
|
+
const value = propFilter.slice(eqIdx + 1);
|
|
64
|
+
q = q.where(psetName, propName, '=', value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const propName = propFilter.slice(dotIdx + 1);
|
|
68
|
+
q = q.where(psetName, propName, 'exists');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (limit)
|
|
73
|
+
q = q.limit(parseInt(limit, 10));
|
|
74
|
+
if (offset)
|
|
75
|
+
q = q.offset(parseInt(offset, 10));
|
|
76
|
+
if (countOnly) {
|
|
77
|
+
const count = q.count();
|
|
78
|
+
if (jsonOutput) {
|
|
79
|
+
printJson({ count });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
process.stdout.write(`${count}\n`);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const entities = q.toArray();
|
|
87
|
+
const needsDetail = showProps || showQuantities || showMaterials || showClassifications
|
|
88
|
+
|| showAttributes || showRelationships || showTypeProps || showDocuments || showAll;
|
|
89
|
+
if (jsonOutput || needsDetail) {
|
|
90
|
+
const result = entities.map(e => {
|
|
91
|
+
const entry = {
|
|
92
|
+
type: e.type,
|
|
93
|
+
name: e.name,
|
|
94
|
+
globalId: e.globalId,
|
|
95
|
+
description: e.description || undefined,
|
|
96
|
+
objectType: e.objectType || undefined,
|
|
97
|
+
};
|
|
98
|
+
if (showAttributes || showAll)
|
|
99
|
+
entry.attributes = bim.attributes(e.ref);
|
|
100
|
+
if (showProps || showAll)
|
|
101
|
+
entry.properties = bim.properties(e.ref);
|
|
102
|
+
if (showQuantities || showAll)
|
|
103
|
+
entry.quantities = bim.quantities(e.ref);
|
|
104
|
+
if (showMaterials || showAll)
|
|
105
|
+
entry.materials = bim.materials(e.ref);
|
|
106
|
+
if (showClassifications || showAll)
|
|
107
|
+
entry.classifications = bim.classifications(e.ref);
|
|
108
|
+
if (showTypeProps || showAll)
|
|
109
|
+
entry.typeProperties = bim.typeProperties(e.ref);
|
|
110
|
+
if (showDocuments || showAll)
|
|
111
|
+
entry.documents = bim.documents(e.ref);
|
|
112
|
+
if (showRelationships || showAll)
|
|
113
|
+
entry.relationships = bim.relationships(e.ref);
|
|
114
|
+
return entry;
|
|
115
|
+
});
|
|
116
|
+
printJson(result);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Table output
|
|
120
|
+
const rows = entities.map(e => [e.type, e.name, e.globalId]);
|
|
121
|
+
process.stdout.write(formatTable(['Type', 'Name', 'GlobalId'], rows) + '\n');
|
|
122
|
+
process.stderr.write(`\n${entities.length} entities\n`);
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CA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