@ifc-lite/ids 1.15.51 → 1.15.53
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/README.md +5 -0
- package/dist/audit/coherence/cardinality.d.ts +19 -0
- package/dist/audit/coherence/cardinality.d.ts.map +1 -0
- package/dist/audit/coherence/cardinality.js +130 -0
- package/dist/audit/coherence/cardinality.js.map +1 -0
- package/dist/audit/coherence/index.d.ts +1 -0
- package/dist/audit/coherence/index.d.ts.map +1 -1
- package/dist/audit/coherence/index.js +18 -121
- package/dist/audit/coherence/index.js.map +1 -1
- package/dist/audit/xsd/index.d.ts.map +1 -1
- package/dist/audit/xsd/index.js +60 -2
- package/dist/audit/xsd/index.js.map +1 -1
- package/dist/bridge/data-accessor.d.ts.map +1 -1
- package/dist/bridge/data-accessor.js +7 -1
- package/dist/bridge/data-accessor.js.map +1 -1
- package/dist/bridge/properties.d.ts +5 -3
- package/dist/bridge/properties.d.ts.map +1 -1
- package/dist/bridge/properties.js +31 -23
- package/dist/bridge/properties.js.map +1 -1
- package/dist/bridge/units.d.ts +61 -3
- package/dist/bridge/units.d.ts.map +1 -1
- package/dist/bridge/units.js +154 -38
- package/dist/bridge/units.js.map +1 -1
- package/dist/constraint-types.d.ts +4 -0
- package/dist/constraint-types.d.ts.map +1 -1
- package/dist/constraints/describe.d.ts.map +1 -1
- package/dist/constraints/describe.js +26 -0
- package/dist/constraints/describe.js.map +1 -1
- package/dist/constraints/digit-facets.d.ts +43 -0
- package/dist/constraints/digit-facets.d.ts.map +1 -0
- package/dist/constraints/digit-facets.js +89 -0
- package/dist/constraints/digit-facets.js.map +1 -0
- package/dist/constraints/match-family.d.ts.map +1 -1
- package/dist/constraints/match-family.js +9 -3
- package/dist/constraints/match-family.js.map +1 -1
- package/dist/constraints/xsd-cast.d.ts +10 -0
- package/dist/constraints/xsd-cast.d.ts.map +1 -1
- package/dist/constraints/xsd-cast.js +48 -15
- package/dist/constraints/xsd-cast.js.map +1 -1
- package/dist/constraints/xsd-datetime.d.ts +16 -0
- package/dist/constraints/xsd-datetime.d.ts.map +1 -0
- package/dist/constraints/xsd-datetime.js +118 -0
- package/dist/constraints/xsd-datetime.js.map +1 -0
- package/dist/facets/attribute-facet.js +10 -2
- package/dist/facets/attribute-facet.js.map +1 -1
- package/dist/facets/entity-facet.d.ts +12 -0
- package/dist/facets/entity-facet.d.ts.map +1 -1
- package/dist/facets/entity-facet.js +12 -0
- package/dist/facets/entity-facet.js.map +1 -1
- package/dist/parser/parse-restriction.d.ts +18 -0
- package/dist/parser/parse-restriction.d.ts.map +1 -0
- package/dist/parser/parse-restriction.js +149 -0
- package/dist/parser/parse-restriction.js.map +1 -0
- package/dist/parser/xml-parser.d.ts.map +1 -1
- package/dist/parser/xml-parser.js +2 -139
- package/dist/parser/xml-parser.js.map +1 -1
- package/package.json +7 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { extractPropertiesOnDemand, extractQuantitiesOnDemand, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractAllEntityAttributes, extractMaterialPropertiesForMaterialId, mergeInheritedPropertySets, } from '@ifc-lite/parser';
|
|
5
5
|
import { RelationshipType } from '@ifc-lite/data';
|
|
6
6
|
import { idsDataTypeForProperty, idsDataTypeForQuantity } from './data-types.js';
|
|
7
|
-
import { applyUnitConversion } from './units.js';
|
|
7
|
+
import { applyUnitConversion, resolveEntityMeasureScales } from './units.js';
|
|
8
8
|
/**
|
|
9
9
|
* IDS treats `IfcElementQuantity` (Qto_*) and `IfcPropertySet` (Pset_*)
|
|
10
10
|
* uniformly — both surface as "property sets" with named values. The
|
|
@@ -17,25 +17,27 @@ import { applyUnitConversion } from './units.js';
|
|
|
17
17
|
* the entity's schema-defined attributes act as property names.
|
|
18
18
|
* 3. Inherited property sets from `IfcRelDefinesByType`.
|
|
19
19
|
*
|
|
20
|
-
* Length-typed properties are converted to base SI
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Length-, area- and volume-typed properties are converted to base SI
|
|
21
|
+
* units per the ENTITY'S OWN OWNING `IFCPROJECT`'s declared units — see
|
|
22
|
+
* `resolveEntityMeasureScales` — so IDS literals (always metre / m² / m³)
|
|
23
|
+
* compare correctly even for an entity belonging to a later `IFCPROJECT`
|
|
24
|
+
* in a multi-project (federated-merge) file.
|
|
23
25
|
*/
|
|
24
26
|
export function collectAllPropertySets(store, expressId) {
|
|
25
27
|
const own = [];
|
|
26
|
-
const scale = store
|
|
27
|
-
appendInstancePropertySets(store, expressId, scale, own);
|
|
28
|
-
appendQuantitySets(store, expressId, own);
|
|
28
|
+
const { length: scale, ...measureScales } = resolveEntityMeasureScales(store, expressId);
|
|
29
|
+
appendInstancePropertySets(store, expressId, scale, measureScales, own);
|
|
30
|
+
appendQuantitySets(store, expressId, scale, measureScales, own);
|
|
29
31
|
appendPredefinedPropertySets(store, expressId, own);
|
|
30
|
-
appendMaterialOwnPropertySets(store, expressId, scale, own);
|
|
32
|
+
appendMaterialOwnPropertySets(store, expressId, scale, measureScales, own);
|
|
31
33
|
// Merged per property, not per set — see `mergeInheritedPropertySets`.
|
|
32
|
-
const out = mergeInheritedPropertySets(own, inheritedPropertySets(store, expressId, scale));
|
|
34
|
+
const out = mergeInheritedPropertySets(own, inheritedPropertySets(store, expressId, scale, measureScales));
|
|
33
35
|
if (out.length === 0) {
|
|
34
36
|
appendTypeEntityOwnProperties(store, expressId, out);
|
|
35
37
|
}
|
|
36
38
|
return out;
|
|
37
39
|
}
|
|
38
|
-
function appendInstancePropertySets(store, expressId, scale, out) {
|
|
40
|
+
function appendInstancePropertySets(store, expressId, scale, measureScales, out) {
|
|
39
41
|
let props = store.properties?.getForEntity?.(expressId);
|
|
40
42
|
if (!props || props.length === 0) {
|
|
41
43
|
props = extractPropertiesOnDemand(store, expressId);
|
|
@@ -45,11 +47,21 @@ function appendInstancePropertySets(store, expressId, scale, out) {
|
|
|
45
47
|
for (const pset of props) {
|
|
46
48
|
out.push({
|
|
47
49
|
name: pset.name,
|
|
48
|
-
properties: (pset.properties || []).map((p) => projectProperty(p, scale)),
|
|
50
|
+
properties: (pset.properties || []).map((p) => projectProperty(p, scale, measureScales)),
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
|
|
54
|
+
/**
|
|
55
|
+
* `IfcPhysicalQuantity` (Qto_*) values are stored in the project's raw
|
|
56
|
+
* author unit exactly like `IfcPropertySingleValue` (Pset_*) — an
|
|
57
|
+
* `IfcQuantityLength`/`IfcQuantityArea`/`IfcQuantityVolume` is just as
|
|
58
|
+
* much an IFC measure as a length/area/volume-typed property, so it
|
|
59
|
+
* needs the same base-SI conversion `projectProperty` already applies
|
|
60
|
+
* there. Route through it here too rather than building the value
|
|
61
|
+
* inline, so the two paths can't drift again — see `applyUnitConversion`
|
|
62
|
+
* in `units.ts` for the length/area/volume exponents.
|
|
63
|
+
*/
|
|
64
|
+
function appendQuantitySets(store, expressId, scale, measureScales, out) {
|
|
53
65
|
let quantities = store.quantities?.getForEntity?.(expressId);
|
|
54
66
|
if (!quantities || quantities.length === 0) {
|
|
55
67
|
quantities = extractQuantitiesOnDemand(store, expressId);
|
|
@@ -59,11 +71,7 @@ function appendQuantitySets(store, expressId, out) {
|
|
|
59
71
|
for (const qset of quantities) {
|
|
60
72
|
out.push({
|
|
61
73
|
name: qset.name,
|
|
62
|
-
properties: (qset.quantities || []).map((q) => ({
|
|
63
|
-
name: q.name,
|
|
64
|
-
value: q.value,
|
|
65
|
-
dataType: idsDataTypeForQuantity(q.type),
|
|
66
|
-
})),
|
|
74
|
+
properties: (qset.quantities || []).map((q) => projectProperty({ name: q.name, value: q.value, type: undefined, dataType: idsDataTypeForQuantity(q.type) }, scale, measureScales)),
|
|
67
75
|
});
|
|
68
76
|
}
|
|
69
77
|
}
|
|
@@ -123,7 +131,7 @@ function appendPredefinedPropertySets(store, expressId, out) {
|
|
|
123
131
|
* common "element that has a material" shape; that path goes through
|
|
124
132
|
* the material facet, not this one.
|
|
125
133
|
*/
|
|
126
|
-
function appendMaterialOwnPropertySets(store, expressId, scale, out) {
|
|
134
|
+
function appendMaterialOwnPropertySets(store, expressId, scale, measureScales, out) {
|
|
127
135
|
if (resolveEntityTypeName(store, expressId)?.toUpperCase() !== 'IFCMATERIAL')
|
|
128
136
|
return;
|
|
129
137
|
const groups = extractMaterialPropertiesForMaterialId(store, expressId);
|
|
@@ -133,7 +141,7 @@ function appendMaterialOwnPropertySets(store, expressId, scale, out) {
|
|
|
133
141
|
continue;
|
|
134
142
|
out.push({
|
|
135
143
|
name: pset.name,
|
|
136
|
-
properties: pset.properties.map((p) => projectProperty(p, scale)),
|
|
144
|
+
properties: pset.properties.map((p) => projectProperty(p, scale, measureScales)),
|
|
137
145
|
});
|
|
138
146
|
}
|
|
139
147
|
}
|
|
@@ -155,7 +163,7 @@ function resolveEntityTypeName(store, expressId) {
|
|
|
155
163
|
return undefined;
|
|
156
164
|
return typeof entry === 'object' && 'type' in entry ? String(entry.type) : undefined;
|
|
157
165
|
}
|
|
158
|
-
function inheritedPropertySets(store, expressId, scale) {
|
|
166
|
+
function inheritedPropertySets(store, expressId, scale, measureScales) {
|
|
159
167
|
// Source-backed extraction (WASM/columnar parse) first; it bails on stores
|
|
160
168
|
// with no `source` buffer — i.e. server-parsed stores — so fall back to the
|
|
161
169
|
// prebuilt property table keyed by the element's IfcTypeProduct id (issue
|
|
@@ -164,7 +172,7 @@ function inheritedPropertySets(store, expressId, scale) {
|
|
|
164
172
|
typePropertySetsFromTable(store, expressId);
|
|
165
173
|
return inheritedPsets.map((pset) => ({
|
|
166
174
|
name: pset.name,
|
|
167
|
-
properties: (pset.properties || []).map((p) => projectProperty(p, scale)),
|
|
175
|
+
properties: (pset.properties || []).map((p) => projectProperty(p, scale, measureScales)),
|
|
168
176
|
}));
|
|
169
177
|
}
|
|
170
178
|
/** Type-inherited property sets for server-parsed stores: resolve the element's
|
|
@@ -211,7 +219,7 @@ function appendTypeEntityOwnProperties(store, expressId, out) {
|
|
|
211
219
|
* (lists, enumerations, table values) suppress dataType so the
|
|
212
220
|
* validator's dataType gate falls through to the value match.
|
|
213
221
|
*/
|
|
214
|
-
function projectProperty(p, scale) {
|
|
222
|
+
function projectProperty(p, scale, measureScales) {
|
|
215
223
|
const hasMultiValue = Array.isArray(p.values) && p.values.length > 0;
|
|
216
224
|
const dataType = p.dataType ??
|
|
217
225
|
(hasMultiValue ? undefined : idsDataTypeForProperty(p.type));
|
|
@@ -219,7 +227,7 @@ function projectProperty(p, scale) {
|
|
|
219
227
|
? JSON.stringify(p.value)
|
|
220
228
|
: p.value;
|
|
221
229
|
const baseValues = hasMultiValue ? p.values : undefined;
|
|
222
|
-
const converted = applyUnitConversion(baseValue, baseValues, dataType, scale);
|
|
230
|
+
const converted = applyUnitConversion(baseValue, baseValues, dataType, scale, measureScales);
|
|
223
231
|
return {
|
|
224
232
|
name: p.name,
|
|
225
233
|
value: converted.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/bridge/properties.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAEL,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,sCAAsC,EACtC,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/bridge/properties.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAEL,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,sCAAsC,EACtC,0BAA0B,GAC3B,MAAM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C,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
package/dist/bridge/units.d.ts
CHANGED
|
@@ -1,17 +1,75 @@
|
|
|
1
|
+
import { type IfcDataStore } from '@ifc-lite/parser';
|
|
1
2
|
/**
|
|
2
3
|
* Per IDS spec, IDS literal values for IFC measure types are always in
|
|
3
4
|
* base SI units. The IFC store keeps the raw author value, so when the
|
|
4
5
|
* project's length unit is `MILLI`, a stored `1000` length means
|
|
5
6
|
* `1.0 metre` and the IDS check `1` should match. This helper applies
|
|
6
7
|
* the project's `lengthUnitScale` to numeric values for length
|
|
7
|
-
* measures.
|
|
8
|
+
* measures, and the analogous area/volume scale to area/volume measures.
|
|
8
9
|
*
|
|
9
10
|
* Properties without a declared dataType (notably `IfcPropertyTableValue`,
|
|
10
11
|
* where columns mix labels and measures) get a conservative double-up:
|
|
11
12
|
* every numeric candidate is surfaced both raw and scaled, so an IDS
|
|
12
|
-
* check using either unit space matches.
|
|
13
|
+
* check using either unit space matches. That double-up only ever uses
|
|
14
|
+
* the length scale — an untyped table has no dataType to key an
|
|
15
|
+
* area/volume exponent off, so it is out of scope here as before.
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Declared AREAUNIT / VOLUMEUNIT scale for a project, when explicitly
|
|
19
|
+
* present in the file's `IfcUnitAssignment`. IFC does not require these to
|
|
20
|
+
* be derivable from the length unit — a project can declare `LENGTHUNIT`
|
|
21
|
+
* in millimetres and `AREAUNIT` as an explicit square-metre `IFCSIUNIT`
|
|
22
|
+
* (or an `IFCCONVERSIONBASEDUNIT`) with no arithmetic relationship to the
|
|
23
|
+
* length scale. Callers should read this first and fall back to
|
|
24
|
+
* `lengthScale ** 2` / `lengthScale ** 3` only when the corresponding
|
|
25
|
+
* field is `undefined` (no such unit declared).
|
|
26
|
+
*/
|
|
27
|
+
export interface MeasureScales {
|
|
28
|
+
area?: number;
|
|
29
|
+
volume?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the file-declared area/volume scale for `store`, reusing the
|
|
33
|
+
* canonical `ProjectUnits` resolver (`@ifc-lite/parser`, mirror of
|
|
34
|
+
* `rust/core/src/project_units`) that already backs unit *display* in the
|
|
35
|
+
* viewer and MCP tools (`packages/mcp/src/tools/geometry.ts`,
|
|
36
|
+
* `apps/viewer/src/hooks/zoneFacts.ts`). Memoised per store so repeated
|
|
37
|
+
* property lookups on the same model don't re-walk `IfcUnitAssignment`.
|
|
38
|
+
*
|
|
39
|
+
* `undefined` fields mean "no explicit AREAUNIT/VOLUMEUNIT declared" —
|
|
40
|
+
* the caller is expected to fall back to `lengthScale ** 2` / `** 3`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveMeasureScales(store: IfcDataStore): MeasureScales;
|
|
43
|
+
/** Per-entity resolved scales: `length` mirrors `store.lengthUnitScale`'s
|
|
44
|
+
* meaning (metres-per-raw-unit), `area`/`volume` mirror {@link MeasureScales}. */
|
|
45
|
+
export interface EntityMeasureScales extends MeasureScales {
|
|
46
|
+
length: number | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve length/area/volume scales for `expressId`'s OWN `IFCPROJECT`,
|
|
50
|
+
* not necessarily the file's first one.
|
|
51
|
+
*
|
|
52
|
+
* An ordinary IFC file has exactly one `IFCPROJECT` (EXPRESS invariant), so
|
|
53
|
+
* `store.lengthUnitScale` / {@link resolveMeasureScales} — both resolved
|
|
54
|
+
* once from the file's first `IFCPROJECT` at parse time — are correct for
|
|
55
|
+
* every entity and this is a zero-cost fast path back to them.
|
|
56
|
+
*
|
|
57
|
+
* A multi-project file (the shape `MergedExporter`'s documented `auto`
|
|
58
|
+
* unit-reconciliation mode produces for a federated merge of
|
|
59
|
+
* differently-unit'd models, see issue #1332) can contain a SECOND
|
|
60
|
+
* `IFCPROJECT` with its own, different declared units. An entity belonging
|
|
61
|
+
* to that later project was previously scaled by the FIRST project's units
|
|
62
|
+
* regardless — silently wrong, not absent, and compliance-critical for IDS
|
|
63
|
+
* (a `Width >= 100mm` requirement evaluates against the wrongly-scaled raw
|
|
64
|
+
* value). This resolves the entity's OWN owning project via the shared
|
|
65
|
+
* `resolveOwningIfcProjectId` (`@ifc-lite/parser`'s `owning-project.ts`,
|
|
66
|
+
* also used by `resolveEntityLengthUnitScale` for #3554's material-layer
|
|
67
|
+
* fix — one containment walk, not a per-caller copy) and reads THAT
|
|
68
|
+
* project's units, falling back to the store-wide default when the walk
|
|
69
|
+
* can't place the entity (matches prior behaviour).
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveEntityMeasureScales(store: IfcDataStore, expressId: number): EntityMeasureScales;
|
|
72
|
+
export declare function applyUnitConversion(rawValue: string | number | boolean | null, rawValues: string[] | undefined, dataType: string | undefined, scale: number | undefined, measureScales?: MeasureScales): {
|
|
15
73
|
value: string | number | boolean | null;
|
|
16
74
|
values: string[] | undefined;
|
|
17
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/bridge/units.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/bridge/units.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAWvE;AAED;mFACmF;AACnF,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,GAChB,mBAAmB,CA2DrB;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,EAC1C,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,aAAa,CAAC,EAAE,aAAa,GAC5B;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CA+D3E"}
|
package/dist/bridge/units.js
CHANGED
|
@@ -1,55 +1,171 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { extractLengthUnitScale, extractProjectUnits, resolveOwningIfcProjectId, } from '@ifc-lite/parser';
|
|
5
|
+
const projectUnitsCache = new WeakMap();
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Resolve the file-declared area/volume scale for `store`, reusing the
|
|
8
|
+
* canonical `ProjectUnits` resolver (`@ifc-lite/parser`, mirror of
|
|
9
|
+
* `rust/core/src/project_units`) that already backs unit *display* in the
|
|
10
|
+
* viewer and MCP tools (`packages/mcp/src/tools/geometry.ts`,
|
|
11
|
+
* `apps/viewer/src/hooks/zoneFacts.ts`). Memoised per store so repeated
|
|
12
|
+
* property lookups on the same model don't re-walk `IfcUnitAssignment`.
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* every numeric candidate is surfaced both raw and scaled, so an IDS
|
|
15
|
-
* check using either unit space matches.
|
|
14
|
+
* `undefined` fields mean "no explicit AREAUNIT/VOLUMEUNIT declared" —
|
|
15
|
+
* the caller is expected to fall back to `lengthScale ** 2` / `** 3`.
|
|
16
16
|
*/
|
|
17
|
-
export function
|
|
18
|
-
if (!
|
|
19
|
-
return {
|
|
17
|
+
export function resolveMeasureScales(store) {
|
|
18
|
+
if (!store.source?.length || !store.entityIndex)
|
|
19
|
+
return {};
|
|
20
|
+
let units = projectUnitsCache.get(store);
|
|
21
|
+
if (!units) {
|
|
22
|
+
units = extractProjectUnits(store.source, store.entityIndex);
|
|
23
|
+
projectUnitsCache.set(store, units);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
area: units.resolvedForUnitType('AREAUNIT')?.siScale,
|
|
27
|
+
volume: units.resolvedForUnitType('VOLUMEUNIT')?.siScale,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const entityProjectScaleCache = new WeakMap();
|
|
31
|
+
/**
|
|
32
|
+
* Resolve length/area/volume scales for `expressId`'s OWN `IFCPROJECT`,
|
|
33
|
+
* not necessarily the file's first one.
|
|
34
|
+
*
|
|
35
|
+
* An ordinary IFC file has exactly one `IFCPROJECT` (EXPRESS invariant), so
|
|
36
|
+
* `store.lengthUnitScale` / {@link resolveMeasureScales} — both resolved
|
|
37
|
+
* once from the file's first `IFCPROJECT` at parse time — are correct for
|
|
38
|
+
* every entity and this is a zero-cost fast path back to them.
|
|
39
|
+
*
|
|
40
|
+
* A multi-project file (the shape `MergedExporter`'s documented `auto`
|
|
41
|
+
* unit-reconciliation mode produces for a federated merge of
|
|
42
|
+
* differently-unit'd models, see issue #1332) can contain a SECOND
|
|
43
|
+
* `IFCPROJECT` with its own, different declared units. An entity belonging
|
|
44
|
+
* to that later project was previously scaled by the FIRST project's units
|
|
45
|
+
* regardless — silently wrong, not absent, and compliance-critical for IDS
|
|
46
|
+
* (a `Width >= 100mm` requirement evaluates against the wrongly-scaled raw
|
|
47
|
+
* value). This resolves the entity's OWN owning project via the shared
|
|
48
|
+
* `resolveOwningIfcProjectId` (`@ifc-lite/parser`'s `owning-project.ts`,
|
|
49
|
+
* also used by `resolveEntityLengthUnitScale` for #3554's material-layer
|
|
50
|
+
* fix — one containment walk, not a per-caller copy) and reads THAT
|
|
51
|
+
* project's units, falling back to the store-wide default when the walk
|
|
52
|
+
* can't place the entity (matches prior behaviour).
|
|
53
|
+
*/
|
|
54
|
+
export function resolveEntityMeasureScales(store, expressId) {
|
|
55
|
+
const fallback = () => ({
|
|
56
|
+
length: store.lengthUnitScale,
|
|
57
|
+
...resolveMeasureScales(store),
|
|
58
|
+
});
|
|
59
|
+
if (!store.source?.length || !store.entityIndex)
|
|
60
|
+
return fallback();
|
|
61
|
+
const projectIds = store.entityIndex.byType.get('IFCPROJECT') ?? [];
|
|
62
|
+
if (projectIds.length <= 1)
|
|
63
|
+
return fallback();
|
|
64
|
+
const ownerId = resolveOwningIfcProjectId(store.entityIndex, store.relationships, expressId);
|
|
65
|
+
if (ownerId === undefined)
|
|
66
|
+
return fallback();
|
|
67
|
+
let byProject = entityProjectScaleCache.get(store);
|
|
68
|
+
if (!byProject) {
|
|
69
|
+
byProject = new Map();
|
|
70
|
+
entityProjectScaleCache.set(store, byProject);
|
|
20
71
|
}
|
|
72
|
+
let scales = byProject.get(ownerId);
|
|
73
|
+
if (!scales) {
|
|
74
|
+
const units = extractProjectUnits(store.source, store.entityIndex, ownerId);
|
|
75
|
+
// `extractLengthUnitScale` answers an unconfirmed 1.0 both for "this
|
|
76
|
+
// project declares metres" and "this project declares no LENGTHUNIT at
|
|
77
|
+
// all" - absence reading as success. `UnitsInContext` is OPTIONAL on
|
|
78
|
+
// `IfcContext`, so a federated model CAN arrive with none, and taking the
|
|
79
|
+
// 1.0 would silently rescale a millimetre value by 1000x. `ProjectUnits`
|
|
80
|
+
// tells the two apart, so only a DECLARED length unit overrides the
|
|
81
|
+
// store-wide scale; an undeclared one keeps the file-wide answer, which is
|
|
82
|
+
// the same safe-miss direction the walk-failed fallback already takes.
|
|
83
|
+
const declaresLengthUnit = units.resolvedForUnitType('LENGTHUNIT') !== undefined;
|
|
84
|
+
if (!declaresLengthUnit) {
|
|
85
|
+
// The owner's UnitsInContext is missing or declares no LENGTHUNIT at
|
|
86
|
+
// all, so it has no AREAUNIT/VOLUMEUNIT either (both are read off that
|
|
87
|
+
// same, absent-or-empty assignment). Falling back to
|
|
88
|
+
// store.lengthUnitScale for length ALONE while leaving area/volume
|
|
89
|
+
// undefined would make callers derive area/volume from THIS scale
|
|
90
|
+
// squared/cubed - the file-wide length scale, not the file-wide
|
|
91
|
+
// area/volume scale, which IFC does not require to be related by that
|
|
92
|
+
// exponent (see the module doc above). Take the file-wide answer for
|
|
93
|
+
// all three together, matching the walk-failed fallback exactly.
|
|
94
|
+
scales = fallback();
|
|
95
|
+
byProject.set(ownerId, scales);
|
|
96
|
+
return scales;
|
|
97
|
+
}
|
|
98
|
+
// Deliberately re-derives the scale via extractLengthUnitScale rather
|
|
99
|
+
// than reading units.resolvedForUnitType('LENGTHUNIT').siScale: for an
|
|
100
|
+
// IfcConversionBasedUnit the two resolvers can disagree - this one
|
|
101
|
+
// prefers a name-keyed table (e.g. 'FOOT' -> 0.3048) over a non-standard
|
|
102
|
+
// declared ConversionFactor, while ProjectUnits always computes the
|
|
103
|
+
// declared factor (proven, with the disagreeing case, in
|
|
104
|
+
// length-unit-resolvers-agreement.test.ts).
|
|
105
|
+
scales = {
|
|
106
|
+
length: extractLengthUnitScale(store.source, store.entityIndex, ownerId),
|
|
107
|
+
area: units.resolvedForUnitType('AREAUNIT')?.siScale,
|
|
108
|
+
volume: units.resolvedForUnitType('VOLUMEUNIT')?.siScale,
|
|
109
|
+
};
|
|
110
|
+
byProject.set(ownerId, scales);
|
|
111
|
+
}
|
|
112
|
+
return scales;
|
|
113
|
+
}
|
|
114
|
+
export function applyUnitConversion(rawValue, rawValues, dataType, scale, measureScales) {
|
|
21
115
|
const upper = dataType ? dataType.toUpperCase() : '';
|
|
22
116
|
const isLength = upper === 'IFCLENGTHMEASURE' || upper === 'IFCPOSITIVELENGTHMEASURE';
|
|
117
|
+
const isArea = upper === 'IFCAREAMEASURE';
|
|
118
|
+
const isVolume = upper === 'IFCVOLUMEMEASURE';
|
|
23
119
|
const isUntypedTable = !dataType && Array.isArray(rawValues) && rawValues.length > 0;
|
|
24
|
-
if (!isLength && !isUntypedTable) {
|
|
120
|
+
if (!isLength && !isArea && !isVolume && !isUntypedTable) {
|
|
121
|
+
return { value: rawValue, values: rawValues };
|
|
122
|
+
}
|
|
123
|
+
if (isUntypedTable) {
|
|
124
|
+
if (!scale || scale === 1) {
|
|
125
|
+
return { value: rawValue, values: rawValues };
|
|
126
|
+
}
|
|
127
|
+
const convertNum = (v) => {
|
|
128
|
+
const n = typeof v === 'number' ? v : parseFloat(String(v));
|
|
129
|
+
return Number.isFinite(n) ? n * scale : null;
|
|
130
|
+
};
|
|
131
|
+
// Untyped table — keep raw values and append scaled copies for every
|
|
132
|
+
// numeric candidate so either unit space matches.
|
|
133
|
+
const expanded = [];
|
|
134
|
+
for (const v of rawValues) {
|
|
135
|
+
expanded.push(String(v));
|
|
136
|
+
const c = convertNum(v);
|
|
137
|
+
if (c != null && String(c) !== String(v))
|
|
138
|
+
expanded.push(String(c));
|
|
139
|
+
}
|
|
140
|
+
return { value: rawValue, values: expanded };
|
|
141
|
+
}
|
|
142
|
+
// Area scales by the SQUARE of the length factor and volume by the
|
|
143
|
+
// CUBE (a millimetre-authored 1 m² is stored as 1e6 mm², not 1e3) —
|
|
144
|
+
// NOT the raw length scale. Prefer the file's explicitly declared
|
|
145
|
+
// AREAUNIT/VOLUMEUNIT when present; only derive from the length scale
|
|
146
|
+
// when the file declares none (see `resolveMeasureScales` above).
|
|
147
|
+
const effectiveScale = isLength
|
|
148
|
+
? scale
|
|
149
|
+
: isArea
|
|
150
|
+
? (measureScales?.area ?? (scale != null ? scale ** 2 : undefined))
|
|
151
|
+
: (measureScales?.volume ?? (scale != null ? scale ** 3 : undefined));
|
|
152
|
+
if (!effectiveScale || effectiveScale === 1) {
|
|
25
153
|
return { value: rawValue, values: rawValues };
|
|
26
154
|
}
|
|
27
155
|
const convertNum = (v) => {
|
|
28
156
|
const n = typeof v === 'number' ? v : parseFloat(String(v));
|
|
29
|
-
return Number.isFinite(n) ? n *
|
|
157
|
+
return Number.isFinite(n) ? n * effectiveScale : null;
|
|
30
158
|
};
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return { value: converted, values };
|
|
43
|
-
}
|
|
44
|
-
// Untyped table — keep raw values and append scaled copies for every
|
|
45
|
-
// numeric candidate so either unit space matches.
|
|
46
|
-
const expanded = [];
|
|
47
|
-
for (const v of rawValues) {
|
|
48
|
-
expanded.push(String(v));
|
|
49
|
-
const c = convertNum(v);
|
|
50
|
-
if (c != null && String(c) !== String(v))
|
|
51
|
-
expanded.push(String(c));
|
|
52
|
-
}
|
|
53
|
-
return { value: rawValue, values: expanded };
|
|
159
|
+
const converted = (() => {
|
|
160
|
+
const c = convertNum(rawValue);
|
|
161
|
+
return c == null ? rawValue : c;
|
|
162
|
+
})();
|
|
163
|
+
const values = Array.isArray(rawValues)
|
|
164
|
+
? rawValues.map((v) => {
|
|
165
|
+
const c = convertNum(v);
|
|
166
|
+
return c == null ? String(v) : String(c);
|
|
167
|
+
})
|
|
168
|
+
: rawValues;
|
|
169
|
+
return { value: converted, values };
|
|
54
170
|
}
|
|
55
171
|
//# sourceMappingURL=units.js.map
|
package/dist/bridge/units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/bridge/units.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D
|
|
1
|
+
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/bridge/units.ts"],"names":[],"m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IDSBoundsConstraint {
|
|
|
85
85
|
minLength?: number;
|
|
86
86
|
/** xs:maxLength — maximum string length */
|
|
87
87
|
maxLength?: number;
|
|
88
|
+
/** xs:totalDigits — maximum number of significant decimal digits */
|
|
89
|
+
totalDigits?: number;
|
|
90
|
+
/** xs:fractionDigits — maximum number of digits after the decimal point */
|
|
91
|
+
fractionDigits?: number;
|
|
88
92
|
/**
|
|
89
93
|
* The originating `xs:restriction @base` (e.g. `xs:double`,
|
|
90
94
|
* `xs:integer`). Set when the constraint came from an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-types.d.ts","sourceRoot":"","sources":["../src/constraint-types.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,oCAAoC;AACpC,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,mBAAmB,CAAC;AAExB,iCAAiC;AACjC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC;AAED,uDAAuD;AACvD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,aAAa,CAAC;IACpB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,QAAQ,CAAC;IACf,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC"}
|
|
1
|
+
{"version":3,"file":"constraint-types.d.ts","sourceRoot":"","sources":["../src/constraint-types.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,oCAAoC;AACpC,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,mBAAmB,CAAC;AAExB,iCAAiC;AACjC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC;AAED,uDAAuD;AACvD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,aAAa,CAAC;IACpB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,QAAQ,CAAC;IACf,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/constraints/describe.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/constraints/describe.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,aAAa,CAAC;AA+BrB;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GACxD,MAAM,CA6BR;AAyED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAOlE"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
import { conjunctiveFacetsOf, matchOneFamily, NUMERIC_TOLERANCE, } from './match-family.js';
|
|
5
|
+
import { matchDigitFacets, countDecimalDigits, toFixedDecimalString, } from './digit-facets.js';
|
|
6
|
+
import { isStrictNumericLiteral } from './comparators.js';
|
|
5
7
|
/**
|
|
6
8
|
* Cap enumeration rendering. These strings are embedded in per-entity
|
|
7
9
|
* validation results — an uncapped 800-value code list produced ~20KB
|
|
@@ -71,6 +73,24 @@ function getBoundsMismatchReason(constraint, actualValue) {
|
|
|
71
73
|
if (constraint.maxExclusive !== undefined && num >= constraint.maxExclusive) {
|
|
72
74
|
violations.push(`must be < ${constraint.maxExclusive}`);
|
|
73
75
|
}
|
|
76
|
+
if (matchDigitFacets(constraint, actualValue) === false) {
|
|
77
|
+
const decimalStr = typeof actualValue === 'number'
|
|
78
|
+
? toFixedDecimalString(actualValue)
|
|
79
|
+
: String(actualValue);
|
|
80
|
+
if (!isStrictNumericLiteral(decimalStr)) {
|
|
81
|
+
violations.push('must be a valid decimal literal');
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const { total, fraction } = countDecimalDigits(decimalStr);
|
|
85
|
+
if (constraint.totalDigits !== undefined && total > constraint.totalDigits) {
|
|
86
|
+
violations.push(`must have at most ${constraint.totalDigits} total digits`);
|
|
87
|
+
}
|
|
88
|
+
if (constraint.fractionDigits !== undefined &&
|
|
89
|
+
fraction > constraint.fractionDigits) {
|
|
90
|
+
violations.push(`must have at most ${constraint.fractionDigits} fraction digits`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
74
94
|
return `${num} ${violations.join(' and ')}`;
|
|
75
95
|
}
|
|
76
96
|
/**
|
|
@@ -135,6 +155,12 @@ function formatBounds(constraint) {
|
|
|
135
155
|
if (constraint.maxExclusive !== undefined) {
|
|
136
156
|
parts.push(`< ${constraint.maxExclusive}`);
|
|
137
157
|
}
|
|
158
|
+
if (constraint.totalDigits !== undefined) {
|
|
159
|
+
parts.push(`<= ${constraint.totalDigits} total digits`);
|
|
160
|
+
}
|
|
161
|
+
if (constraint.fractionDigits !== undefined) {
|
|
162
|
+
parts.push(`<= ${constraint.fractionDigits} fraction digits`);
|
|
163
|
+
}
|
|
138
164
|
return parts.join(' and ') || 'any value';
|
|
139
165
|
}
|
|
140
166
|
//# sourceMappingURL=describe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/constraints/describe.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAc/D,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/constraints/describe.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAc/D,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,gBAAgB,CAAC,MAAgB;IACxC,MAAM,KAAK,GAAG,MAAM;SACjB,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,uBA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