@ifc-lite/viewer 1.25.1 → 1.26.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 (75) hide show
  1. package/.turbo/turbo-build.log +83 -85
  2. package/CHANGELOG.md +104 -0
  3. package/dist/assets/{basketViewActivator-Dkn92C04.js → basketViewActivator-ZpTYWE3K.js} +6 -6
  4. package/dist/assets/{bcf-DP2AK1-_.js → bcf-Ctcu_Sc2.js} +5 -5
  5. package/dist/assets/{deflate-BYqYwhkl.js → deflate-Cnx0il6E.js} +1 -1
  6. package/dist/assets/exporters-DSq76AVM.js +4687 -0
  7. package/dist/assets/geometry.worker-0Q9qEa6p.js +1 -0
  8. package/dist/assets/{geotiff-By06vdeL.js → geotiff-A5UjhI6L.js} +10 -10
  9. package/dist/assets/{ids-DDkkb4mo.js → ids-DiLcGTer.js} +4 -4
  10. package/dist/assets/ifc-lite_bg-CEZnhM2e.wasm +0 -0
  11. package/dist/assets/index-B9Ug2EqU.css +1 -0
  12. package/dist/assets/{index-CqBdDOAZ.js → index-BAH8IJVR.js} +39550 -36936
  13. package/dist/assets/{jpeg-B4IBTphL.js → jpeg-BzSkwo5D.js} +1 -1
  14. package/dist/assets/{lerc-DQ3jI0Ke.js → lerc-Cg2Rz-D5.js} +1 -1
  15. package/dist/assets/{lzw-CtdH775t.js → lzw-BBPPLW-0.js} +1 -1
  16. package/dist/assets/{native-bridge-DA8wxaN_.js → native-bridge-CPojOeGE.js} +1 -1
  17. package/dist/assets/{packbits-DG3zn49C.js → packbits-yLSpjW-V.js} +1 -1
  18. package/dist/assets/parser.worker-8md211IW.js +182 -0
  19. package/dist/assets/raw-BQrAgxwT.js +1 -0
  20. package/dist/assets/{sandbox-D1pQT-5R.js → sandbox-CsRXlgCO.js} +4715 -3081
  21. package/dist/assets/{server-client-D9xO_8yX.js → server-client-Bk4c1CPO.js} +1 -1
  22. package/dist/assets/{webimage-_-qCDjkn.js → webimage-YafxjjGr.js} +1 -1
  23. package/dist/assets/{zstd-DlfgC8gA.js → zstd-CkSLOiuu.js} +1 -1
  24. package/dist/index.html +7 -7
  25. package/package.json +23 -21
  26. package/src/App.tsx +4 -0
  27. package/src/components/extensions/FlavorDialog.tsx +18 -2
  28. package/src/components/extensions/FlavorListView.tsx +12 -3
  29. package/src/components/viewer/ClashBcfExportDialog.tsx +271 -0
  30. package/src/components/viewer/ClashPanel.tsx +370 -0
  31. package/src/components/viewer/ClashSettingsDialog.tsx +407 -0
  32. package/src/components/viewer/CommandPalette.tsx +19 -16
  33. package/src/components/viewer/MainToolbar.tsx +155 -153
  34. package/src/components/viewer/ViewerLayout.tsx +5 -0
  35. package/src/components/viewer/Viewport.tsx +97 -12
  36. package/src/components/viewer/ViewportContainer.tsx +45 -3
  37. package/src/components/viewer/bcf/BCFOverlay.tsx +5 -4
  38. package/src/components/viewer/hierarchy/ifc-icons.ts +60 -0
  39. package/src/components/viewer/useGeometryStreaming.ts +134 -19
  40. package/src/hooks/ingest/resolveDataStoreOrAbort.test.ts +61 -0
  41. package/src/hooks/ingest/resolveDataStoreOrAbort.ts +28 -0
  42. package/src/hooks/ingest/streamCleanup.test.ts +41 -0
  43. package/src/hooks/ingest/streamCleanup.ts +45 -0
  44. package/src/hooks/ingest/viewerModelIngest.ts +118 -52
  45. package/src/hooks/ingest/watchedGeometryStream.test.ts +78 -0
  46. package/src/hooks/ingest/watchedGeometryStream.ts +76 -0
  47. package/src/hooks/useAlignmentLines3D.ts +164 -0
  48. package/src/hooks/useClash.ts +420 -0
  49. package/src/hooks/useIfcCache.ts +44 -18
  50. package/src/hooks/useIfcFederation.ts +16 -2
  51. package/src/hooks/useIfcLoader.ts +6 -30
  52. package/src/hooks/useSymbolicAnnotations.ts +170 -35
  53. package/src/lib/clash/persistence.ts +308 -0
  54. package/src/lib/geo/effective-georef.test.ts +66 -0
  55. package/src/services/extensions/host.ts +13 -0
  56. package/src/store/constants.ts +38 -14
  57. package/src/store/index.ts +29 -7
  58. package/src/store/slices/clashSlice.ts +251 -0
  59. package/src/store/slices/visibilitySlice.test.ts +23 -5
  60. package/src/store/slices/visibilitySlice.ts +19 -8
  61. package/src/store/types.ts +9 -0
  62. package/src/utils/serverDataModel.test.ts +51 -1
  63. package/src/utils/serverDataModel.ts +2 -26
  64. package/vite.config.ts +0 -5
  65. package/dist/assets/exporters-CZe0D8N-.js +0 -5957
  66. package/dist/assets/geometry-controller.worker-pD49_fH6.js +0 -7
  67. package/dist/assets/geometry.worker-D4c-06r5.js +0 -1
  68. package/dist/assets/ifc-lite-DxGqDbjO.js +0 -7
  69. package/dist/assets/ifc-lite_bg-BNeu7R_V.wasm +0 -0
  70. package/dist/assets/ifc-lite_bg-DuxUZomW.wasm +0 -0
  71. package/dist/assets/index-Bws3UAkj.css +0 -1
  72. package/dist/assets/parser.worker-BZZcO7DB.js +0 -182
  73. package/dist/assets/raw-DY7Y_acr.js +0 -1
  74. package/dist/assets/wasm-bridge-DMX8Acuf.js +0 -1
  75. package/dist/assets/workerHelpers-Crstj4Oa.js +0 -36
@@ -0,0 +1,4687 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-bridge-CPojOeGE.js","assets/sandbox-CsRXlgCO.js","assets/lens-PYsLu_MA.js"])))=>i.map(i=>d[i]);
2
+ import { U as Ge, _ as $e, aP as nt, a7 as Ve, a8 as ze, k as tt, l as Ct, aS as Me, E as ke, ai as ee, am as Ye, aj as We, aK as je, W as He, j as ne, i as Xe, __tla as __tla_0 } from "./sandbox-CsRXlgCO.js";
3
+ let rs, is, Le, as, qn, Be, ss, In, cs, ie, os, ns;
4
+ let __tla = Promise.all([
5
+ (()=>{
6
+ try {
7
+ return __tla_0;
8
+ } catch {}
9
+ })()
10
+ ]).then(async ()=>{
11
+ let c;
12
+ function B(r) {
13
+ St === ot.length && ot.push(ot.length + 1);
14
+ const t = St;
15
+ return St = ot[t], ot[t] = r, t;
16
+ }
17
+ function qe(r) {
18
+ if (kt == 1) throw new Error("out of js stack");
19
+ return ot[--kt] = r, kt;
20
+ }
21
+ const de = typeof FinalizationRegistry > "u" ? {
22
+ register: ()=>{},
23
+ unregister: ()=>{}
24
+ } : new FinalizationRegistry((r)=>r.dtor(r.a, r.b));
25
+ function Qe(r) {
26
+ r < 132 || (ot[r] = St, St = r);
27
+ }
28
+ function se(r, t) {
29
+ return r = r >>> 0, Ke().subarray(r / 4, r / 4 + t);
30
+ }
31
+ function Je(r, t) {
32
+ return r = r >>> 0, Ze().subarray(r / 8, r / 8 + t);
33
+ }
34
+ function xe(r, t) {
35
+ return r = r >>> 0, Pe().subarray(r / 4, r / 4 + t);
36
+ }
37
+ let gt = null;
38
+ function A() {
39
+ return (gt === null || gt.buffer.detached === !0 || gt.buffer.detached === void 0 && gt.buffer !== c.memory.buffer) && (gt = new DataView(c.memory.buffer)), gt;
40
+ }
41
+ let Tt = null;
42
+ function Ke() {
43
+ return (Tt === null || Tt.byteLength === 0) && (Tt = new Float32Array(c.memory.buffer)), Tt;
44
+ }
45
+ let wt = null;
46
+ function Ze() {
47
+ return (wt === null || wt.byteLength === 0) && (wt = new Float64Array(c.memory.buffer)), wt;
48
+ }
49
+ function J(r, t) {
50
+ return r = r >>> 0, nn(r, t);
51
+ }
52
+ let Ft = null;
53
+ function Pe() {
54
+ return (Ft === null || Ft.byteLength === 0) && (Ft = new Uint32Array(c.memory.buffer)), Ft;
55
+ }
56
+ let Rt = null;
57
+ function Nt() {
58
+ return (Rt === null || Rt.byteLength === 0) && (Rt = new Uint8Array(c.memory.buffer)), Rt;
59
+ }
60
+ function W(r) {
61
+ return ot[r];
62
+ }
63
+ function Xt(r, t) {
64
+ try {
65
+ return r.apply(this, t);
66
+ } catch (e) {
67
+ c.__wbindgen_export(B(e));
68
+ }
69
+ }
70
+ let ot = new Array(128).fill(void 0);
71
+ ot.push(void 0, null, !0, !1);
72
+ let St = ot.length;
73
+ function $t(r) {
74
+ return r == null;
75
+ }
76
+ function tn(r, t, e, n) {
77
+ const s = {
78
+ a: r,
79
+ b: t,
80
+ cnt: 1,
81
+ dtor: e
82
+ }, i = (...o)=>{
83
+ s.cnt++;
84
+ const a = s.a;
85
+ s.a = 0;
86
+ try {
87
+ return n(a, s.b, ...o);
88
+ } finally{
89
+ s.a = a, i._wbg_cb_unref();
90
+ }
91
+ };
92
+ return i._wbg_cb_unref = ()=>{
93
+ --s.cnt === 0 && (s.dtor(s.a, s.b), s.a = 0, de.unregister(s));
94
+ }, de.register(i, s, s), i;
95
+ }
96
+ function ft(r, t) {
97
+ const e = t(r.length * 4, 4) >>> 0;
98
+ return Pe().set(r, e / 4), $ = r.length, e;
99
+ }
100
+ function It(r, t) {
101
+ const e = t(r.length * 1, 1) >>> 0;
102
+ return Nt().set(r, e / 1), $ = r.length, e;
103
+ }
104
+ function ut(r, t, e) {
105
+ if (e === void 0) {
106
+ const a = At.encode(r), l = t(a.length, 1) >>> 0;
107
+ return Nt().subarray(l, l + a.length).set(a), $ = a.length, l;
108
+ }
109
+ let n = r.length, s = t(n, 1) >>> 0;
110
+ const i = Nt();
111
+ let o = 0;
112
+ for(; o < n; o++){
113
+ const a = r.charCodeAt(o);
114
+ if (a > 127) break;
115
+ i[s + o] = a;
116
+ }
117
+ if (o !== n) {
118
+ o !== 0 && (r = r.slice(o)), s = e(s, n, n = o + r.length * 3, 1) >>> 0;
119
+ const a = Nt().subarray(s + o, s + n), l = At.encodeInto(r, a);
120
+ o += l.written, s = e(s, n, o, 1) >>> 0;
121
+ }
122
+ return $ = o, s;
123
+ }
124
+ let kt = 128;
125
+ function V(r) {
126
+ const t = W(r);
127
+ return Qe(r), t;
128
+ }
129
+ let Yt = new TextDecoder("utf-8", {
130
+ ignoreBOM: !0,
131
+ fatal: !0
132
+ });
133
+ Yt.decode();
134
+ const en = 2146435072;
135
+ let qt = 0;
136
+ function nn(r, t) {
137
+ return qt += t, qt >= en && (Yt = new TextDecoder("utf-8", {
138
+ ignoreBOM: !0,
139
+ fatal: !0
140
+ }), Yt.decode(), qt = t), Yt.decode(Nt().subarray(r, r + t));
141
+ }
142
+ const At = new TextEncoder;
143
+ "encodeInto" in At || (At.encodeInto = function(r, t) {
144
+ const e = At.encode(r);
145
+ return t.set(e), {
146
+ read: r.length,
147
+ written: e.length
148
+ };
149
+ });
150
+ let $ = 0;
151
+ function sn(r, t, e) {
152
+ c.__wasm_bindgen_func_elem_593(r, t, B(e));
153
+ }
154
+ function rn(r, t, e, n) {
155
+ c.__wasm_bindgen_func_elem_627(r, t, B(e), B(n));
156
+ }
157
+ typeof FinalizationRegistry > "u" || new FinalizationRegistry((r)=>c.__wbg_clashrunresult_free(r >>> 0, 1));
158
+ typeof FinalizationRegistry > "u" || new FinalizationRegistry((r)=>c.__wbg_clashsession_free(r >>> 0, 1));
159
+ const fe = typeof FinalizationRegistry > "u" ? {
160
+ register: ()=>{},
161
+ unregister: ()=>{}
162
+ } : new FinalizationRegistry((r)=>c.__wbg_ifcapi_free(r >>> 0, 1)), ue = typeof FinalizationRegistry > "u" ? {
163
+ register: ()=>{},
164
+ unregister: ()=>{}
165
+ } : new FinalizationRegistry((r)=>c.__wbg_meshcollection_free(r >>> 0, 1)), he = typeof FinalizationRegistry > "u" ? {
166
+ register: ()=>{},
167
+ unregister: ()=>{}
168
+ } : new FinalizationRegistry((r)=>c.__wbg_meshdatajs_free(r >>> 0, 1)), pe = typeof FinalizationRegistry > "u" ? {
169
+ register: ()=>{},
170
+ unregister: ()=>{}
171
+ } : new FinalizationRegistry((r)=>c.__wbg_profilecollection_free(r >>> 0, 1)), Ie = typeof FinalizationRegistry > "u" ? {
172
+ register: ()=>{},
173
+ unregister: ()=>{}
174
+ } : new FinalizationRegistry((r)=>c.__wbg_profileentryjs_free(r >>> 0, 1)), ge = typeof FinalizationRegistry > "u" ? {
175
+ register: ()=>{},
176
+ unregister: ()=>{}
177
+ } : new FinalizationRegistry((r)=>c.__wbg_symboliccircle_free(r >>> 0, 1)), _e = typeof FinalizationRegistry > "u" ? {
178
+ register: ()=>{},
179
+ unregister: ()=>{}
180
+ } : new FinalizationRegistry((r)=>c.__wbg_symbolicfillarea_free(r >>> 0, 1)), ye = typeof FinalizationRegistry > "u" ? {
181
+ register: ()=>{},
182
+ unregister: ()=>{}
183
+ } : new FinalizationRegistry((r)=>c.__wbg_symbolicpolyline_free(r >>> 0, 1)), Ee = typeof FinalizationRegistry > "u" ? {
184
+ register: ()=>{},
185
+ unregister: ()=>{}
186
+ } : new FinalizationRegistry((r)=>c.__wbg_symbolicrepresentationcollection_free(r >>> 0, 1)), me = typeof FinalizationRegistry > "u" ? {
187
+ register: ()=>{},
188
+ unregister: ()=>{}
189
+ } : new FinalizationRegistry((r)=>c.__wbg_symbolictext_free(r >>> 0, 1));
190
+ ie = class {
191
+ __destroy_into_raw() {
192
+ const t = this.__wbg_ptr;
193
+ return this.__wbg_ptr = 0, fe.unregister(this), t;
194
+ }
195
+ free() {
196
+ const t = this.__destroy_into_raw();
197
+ c.__wbg_ifcapi_free(t, 0);
198
+ }
199
+ buildPrePassFast(t) {
200
+ const e = It(t, c.__wbindgen_export3), n = $, s = c.ifcapi_buildPrePassFast(this.__wbg_ptr, e, n);
201
+ return V(s);
202
+ }
203
+ buildPrePassOnce(t) {
204
+ const e = It(t, c.__wbindgen_export3), n = $, s = c.ifcapi_buildPrePassOnce(this.__wbg_ptr, e, n);
205
+ return V(s);
206
+ }
207
+ processGeometryBatch(t, e, n, s, i, o, a, l, d, u, f, p) {
208
+ const _ = It(t, c.__wbindgen_export3), h = $, y = ft(e, c.__wbindgen_export3), m = $, b = ft(l, c.__wbindgen_export3), w = $, v = ft(d, c.__wbindgen_export3), L = $, j = ft(u, c.__wbindgen_export3), O = $, U = ft(f, c.__wbindgen_export3), C = $, N = It(p, c.__wbindgen_export3), F = $, E = c.ifcapi_processGeometryBatch(this.__wbg_ptr, _, h, y, m, n, s, i, o, a, b, w, v, L, j, O, U, C, N, F);
209
+ return Ot.__wrap(E);
210
+ }
211
+ buildPrePassStreaming(t, e, n) {
212
+ try {
213
+ const a = c.__wbindgen_add_to_stack_pointer(-16), l = It(t, c.__wbindgen_export3), d = $;
214
+ c.ifcapi_buildPrePassStreaming(a, this.__wbg_ptr, l, d, qe(e), n);
215
+ var s = A().getInt32(a + 0, !0), i = A().getInt32(a + 4, !0), o = A().getInt32(a + 8, !0);
216
+ if (o) throw V(i);
217
+ return V(s);
218
+ } finally{
219
+ c.__wbindgen_add_to_stack_pointer(16), ot[kt++] = void 0;
220
+ }
221
+ }
222
+ parseAlignmentLines(t) {
223
+ const e = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), n = $, s = c.ifcapi_parseAlignmentLines(this.__wbg_ptr, e, n);
224
+ return V(s);
225
+ }
226
+ extractProfiles(t, e) {
227
+ const n = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), s = $, i = c.ifcapi_extractProfiles(this.__wbg_ptr, n, s, e);
228
+ return Mt.__wrap(i);
229
+ }
230
+ getMemory() {
231
+ const t = c.ifcapi_getMemory(this.__wbg_ptr);
232
+ return V(t);
233
+ }
234
+ setEntityIndex(t, e, n) {
235
+ const s = ft(t, c.__wbindgen_export3), i = $, o = ft(e, c.__wbindgen_export3), a = $, l = ft(n, c.__wbindgen_export3), d = $;
236
+ c.ifcapi_setEntityIndex(this.__wbg_ptr, s, i, o, a, l, d);
237
+ }
238
+ setMergeLayers(t) {
239
+ c.ifcapi_setMergeLayers(this.__wbg_ptr, t);
240
+ }
241
+ clearPrePassCache() {
242
+ c.ifcapi_clearPrePassCache(this.__wbg_ptr);
243
+ }
244
+ constructor(){
245
+ const t = c.ifcapi_new();
246
+ return this.__wbg_ptr = t >>> 0, fe.register(this, this.__wbg_ptr, this), this;
247
+ }
248
+ get version() {
249
+ let t, e;
250
+ try {
251
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
252
+ c.ifcapi_version(i, this.__wbg_ptr);
253
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
254
+ return t = n, e = s, J(n, s);
255
+ } finally{
256
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
257
+ }
258
+ }
259
+ get is_ready() {
260
+ return c.ifcapi_is_ready(this.__wbg_ptr) !== 0;
261
+ }
262
+ parseStreaming(t, e) {
263
+ const n = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), s = $, i = c.ifcapi_parseStreaming(this.__wbg_ptr, n, s, B(e));
264
+ return V(i);
265
+ }
266
+ scanEntitiesFast(t) {
267
+ const e = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), n = $, s = c.ifcapi_scanEntitiesFast(this.__wbg_ptr, e, n);
268
+ return V(s);
269
+ }
270
+ scanEntitiesFastBytes(t) {
271
+ const e = It(t, c.__wbindgen_export3), n = $, s = c.ifcapi_scanEntitiesFastBytes(this.__wbg_ptr, e, n);
272
+ return V(s);
273
+ }
274
+ scanGeometryEntitiesFast(t) {
275
+ const e = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), n = $, s = c.ifcapi_scanGeometryEntitiesFast(this.__wbg_ptr, e, n);
276
+ return V(s);
277
+ }
278
+ scanRelevantEntitiesFastBytes(t) {
279
+ const e = It(t, c.__wbindgen_export3), n = $, s = c.ifcapi_scanRelevantEntitiesFastBytes(this.__wbg_ptr, e, n);
280
+ return V(s);
281
+ }
282
+ parse(t) {
283
+ const e = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), n = $, s = c.ifcapi_parse(this.__wbg_ptr, e, n);
284
+ return V(s);
285
+ }
286
+ parseSymbolicRepresentations(t) {
287
+ const e = ut(t, c.__wbindgen_export3, c.__wbindgen_export4), n = $, s = c.ifcapi_parseSymbolicRepresentations(this.__wbg_ptr, e, n);
288
+ return Dt.__wrap(s);
289
+ }
290
+ };
291
+ Symbol.dispose && (ie.prototype[Symbol.dispose] = ie.prototype.free);
292
+ class Ot {
293
+ static __wrap(t) {
294
+ t = t >>> 0;
295
+ const e = Object.create(Ot.prototype);
296
+ return e.__wbg_ptr = t, ue.register(e, e.__wbg_ptr, e), e;
297
+ }
298
+ __destroy_into_raw() {
299
+ const t = this.__wbg_ptr;
300
+ return this.__wbg_ptr = 0, ue.unregister(this), t;
301
+ }
302
+ free() {
303
+ const t = this.__destroy_into_raw();
304
+ c.__wbg_meshcollection_free(t, 0);
305
+ }
306
+ get rtcOffsetX() {
307
+ return c.meshcollection_rtcOffsetX(this.__wbg_ptr);
308
+ }
309
+ get rtcOffsetY() {
310
+ return c.meshcollection_rtcOffsetY(this.__wbg_ptr);
311
+ }
312
+ get rtcOffsetZ() {
313
+ return c.meshcollection_rtcOffsetZ(this.__wbg_ptr);
314
+ }
315
+ hasRtcOffset() {
316
+ return c.meshcollection_hasRtcOffset(this.__wbg_ptr) !== 0;
317
+ }
318
+ localToWorld(t, e, n) {
319
+ try {
320
+ const a = c.__wbindgen_add_to_stack_pointer(-16);
321
+ c.meshcollection_localToWorld(a, this.__wbg_ptr, t, e, n);
322
+ var s = A().getInt32(a + 0, !0), i = A().getInt32(a + 4, !0), o = Je(s, i).slice();
323
+ return c.__wbindgen_export2(s, i * 8, 8), o;
324
+ } finally{
325
+ c.__wbindgen_add_to_stack_pointer(16);
326
+ }
327
+ }
328
+ get totalVertices() {
329
+ return c.meshcollection_totalVertices(this.__wbg_ptr) >>> 0;
330
+ }
331
+ get totalTriangles() {
332
+ return c.meshcollection_totalTriangles(this.__wbg_ptr) >>> 0;
333
+ }
334
+ get buildingRotation() {
335
+ try {
336
+ const n = c.__wbindgen_add_to_stack_pointer(-16);
337
+ c.meshcollection_buildingRotation(n, this.__wbg_ptr);
338
+ var t = A().getInt32(n + 0, !0), e = A().getFloat64(n + 8, !0);
339
+ return t === 0 ? void 0 : e;
340
+ } finally{
341
+ c.__wbindgen_add_to_stack_pointer(16);
342
+ }
343
+ }
344
+ get(t) {
345
+ const e = c.meshcollection_get(this.__wbg_ptr, t);
346
+ return e === 0 ? void 0 : Lt.__wrap(e);
347
+ }
348
+ get length() {
349
+ return c.meshcollection_length(this.__wbg_ptr) >>> 0;
350
+ }
351
+ }
352
+ Symbol.dispose && (Ot.prototype[Symbol.dispose] = Ot.prototype.free);
353
+ class Lt {
354
+ static __wrap(t) {
355
+ t = t >>> 0;
356
+ const e = Object.create(Lt.prototype);
357
+ return e.__wbg_ptr = t, he.register(e, e.__wbg_ptr, e), e;
358
+ }
359
+ __destroy_into_raw() {
360
+ const t = this.__wbg_ptr;
361
+ return this.__wbg_ptr = 0, he.unregister(this), t;
362
+ }
363
+ free() {
364
+ const t = this.__destroy_into_raw();
365
+ c.__wbg_meshdatajs_free(t, 0);
366
+ }
367
+ get expressId() {
368
+ return c.meshdatajs_expressId(this.__wbg_ptr) >>> 0;
369
+ }
370
+ get vertexCount() {
371
+ return c.meshdatajs_vertexCount(this.__wbg_ptr) >>> 0;
372
+ }
373
+ get shadingColor() {
374
+ try {
375
+ const n = c.__wbindgen_add_to_stack_pointer(-16);
376
+ c.meshdatajs_shadingColor(n, this.__wbg_ptr);
377
+ var t = A().getInt32(n + 0, !0), e = A().getInt32(n + 4, !0);
378
+ let s;
379
+ return t !== 0 && (s = se(t, e).slice(), c.__wbindgen_export2(t, e * 4, 4)), s;
380
+ } finally{
381
+ c.__wbindgen_add_to_stack_pointer(16);
382
+ }
383
+ }
384
+ get triangleCount() {
385
+ return c.meshdatajs_triangleCount(this.__wbg_ptr) >>> 0;
386
+ }
387
+ get color() {
388
+ try {
389
+ const s = c.__wbindgen_add_to_stack_pointer(-16);
390
+ c.meshdatajs_color(s, this.__wbg_ptr);
391
+ var t = A().getInt32(s + 0, !0), e = A().getInt32(s + 4, !0), n = se(t, e).slice();
392
+ return c.__wbindgen_export2(t, e * 4, 4), n;
393
+ } finally{
394
+ c.__wbindgen_add_to_stack_pointer(16);
395
+ }
396
+ }
397
+ get indices() {
398
+ const t = c.meshdatajs_indices(this.__wbg_ptr);
399
+ return V(t);
400
+ }
401
+ get normals() {
402
+ const t = c.meshdatajs_normals(this.__wbg_ptr);
403
+ return V(t);
404
+ }
405
+ get ifcType() {
406
+ let t, e;
407
+ try {
408
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
409
+ c.meshdatajs_ifcType(i, this.__wbg_ptr);
410
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
411
+ return t = n, e = s, J(n, s);
412
+ } finally{
413
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
414
+ }
415
+ }
416
+ get positions() {
417
+ const t = c.meshdatajs_positions(this.__wbg_ptr);
418
+ return V(t);
419
+ }
420
+ }
421
+ Symbol.dispose && (Lt.prototype[Symbol.dispose] = Lt.prototype.free);
422
+ class Mt {
423
+ static __wrap(t) {
424
+ t = t >>> 0;
425
+ const e = Object.create(Mt.prototype);
426
+ return e.__wbg_ptr = t, pe.register(e, e.__wbg_ptr, e), e;
427
+ }
428
+ __destroy_into_raw() {
429
+ const t = this.__wbg_ptr;
430
+ return this.__wbg_ptr = 0, pe.unregister(this), t;
431
+ }
432
+ free() {
433
+ const t = this.__destroy_into_raw();
434
+ c.__wbg_profilecollection_free(t, 0);
435
+ }
436
+ get(t) {
437
+ const e = c.profilecollection_get(this.__wbg_ptr, t);
438
+ return e === 0 ? void 0 : xt.__wrap(e);
439
+ }
440
+ get length() {
441
+ return c.profilecollection_length(this.__wbg_ptr) >>> 0;
442
+ }
443
+ }
444
+ Symbol.dispose && (Mt.prototype[Symbol.dispose] = Mt.prototype.free);
445
+ class xt {
446
+ static __wrap(t) {
447
+ t = t >>> 0;
448
+ const e = Object.create(xt.prototype);
449
+ return e.__wbg_ptr = t, Ie.register(e, e.__wbg_ptr, e), e;
450
+ }
451
+ __destroy_into_raw() {
452
+ const t = this.__wbg_ptr;
453
+ return this.__wbg_ptr = 0, Ie.unregister(this), t;
454
+ }
455
+ free() {
456
+ const t = this.__destroy_into_raw();
457
+ c.__wbg_profileentryjs_free(t, 0);
458
+ }
459
+ get expressId() {
460
+ return c.profileentryjs_expressId(this.__wbg_ptr) >>> 0;
461
+ }
462
+ get holeCounts() {
463
+ const t = c.profileentryjs_holeCounts(this.__wbg_ptr);
464
+ return V(t);
465
+ }
466
+ get holePoints() {
467
+ const t = c.profileentryjs_holePoints(this.__wbg_ptr);
468
+ return V(t);
469
+ }
470
+ get modelIndex() {
471
+ return c.profileentryjs_modelIndex(this.__wbg_ptr) >>> 0;
472
+ }
473
+ get outerPoints() {
474
+ const t = c.profileentryjs_outerPoints(this.__wbg_ptr);
475
+ return V(t);
476
+ }
477
+ get extrusionDir() {
478
+ const t = c.profileentryjs_extrusionDir(this.__wbg_ptr);
479
+ return V(t);
480
+ }
481
+ get extrusionDepth() {
482
+ return c.profileentryjs_extrusionDepth(this.__wbg_ptr);
483
+ }
484
+ get ifcType() {
485
+ let t, e;
486
+ try {
487
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
488
+ c.profileentryjs_ifcType(i, this.__wbg_ptr);
489
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
490
+ return t = n, e = s, J(n, s);
491
+ } finally{
492
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
493
+ }
494
+ }
495
+ get transform() {
496
+ const t = c.profileentryjs_transform(this.__wbg_ptr);
497
+ return V(t);
498
+ }
499
+ }
500
+ Symbol.dispose && (xt.prototype[Symbol.dispose] = xt.prototype.free);
501
+ class Pt {
502
+ static __wrap(t) {
503
+ t = t >>> 0;
504
+ const e = Object.create(Pt.prototype);
505
+ return e.__wbg_ptr = t, ge.register(e, e.__wbg_ptr, e), e;
506
+ }
507
+ __destroy_into_raw() {
508
+ const t = this.__wbg_ptr;
509
+ return this.__wbg_ptr = 0, ge.unregister(this), t;
510
+ }
511
+ free() {
512
+ const t = this.__destroy_into_raw();
513
+ c.__wbg_symboliccircle_free(t, 0);
514
+ }
515
+ get expressId() {
516
+ return c.symboliccircle_expressId(this.__wbg_ptr) >>> 0;
517
+ }
518
+ get startAngle() {
519
+ return c.symboliccircle_startAngle(this.__wbg_ptr);
520
+ }
521
+ get isFullCircle() {
522
+ return c.symboliccircle_isFullCircle(this.__wbg_ptr) !== 0;
523
+ }
524
+ get repIdentifier() {
525
+ let t, e;
526
+ try {
527
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
528
+ c.symboliccircle_repIdentifier(i, this.__wbg_ptr);
529
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
530
+ return t = n, e = s, J(n, s);
531
+ } finally{
532
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
533
+ }
534
+ }
535
+ get radius() {
536
+ return c.symboliccircle_radius(this.__wbg_ptr);
537
+ }
538
+ get worldY() {
539
+ return c.symboliccircle_worldY(this.__wbg_ptr);
540
+ }
541
+ get centerX() {
542
+ return c.symboliccircle_centerX(this.__wbg_ptr);
543
+ }
544
+ get centerY() {
545
+ return c.symboliccircle_centerY(this.__wbg_ptr);
546
+ }
547
+ get ifcType() {
548
+ let t, e;
549
+ try {
550
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
551
+ c.symboliccircle_ifcType(i, this.__wbg_ptr);
552
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
553
+ return t = n, e = s, J(n, s);
554
+ } finally{
555
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
556
+ }
557
+ }
558
+ get endAngle() {
559
+ return c.symboliccircle_endAngle(this.__wbg_ptr);
560
+ }
561
+ }
562
+ Symbol.dispose && (Pt.prototype[Symbol.dispose] = Pt.prototype.free);
563
+ class Bt {
564
+ static __wrap(t) {
565
+ t = t >>> 0;
566
+ const e = Object.create(Bt.prototype);
567
+ return e.__wbg_ptr = t, _e.register(e, e.__wbg_ptr, e), e;
568
+ }
569
+ __destroy_into_raw() {
570
+ const t = this.__wbg_ptr;
571
+ return this.__wbg_ptr = 0, _e.unregister(this), t;
572
+ }
573
+ free() {
574
+ const t = this.__destroy_into_raw();
575
+ c.__wbg_symbolicfillarea_free(t, 0);
576
+ }
577
+ get expressId() {
578
+ return c.profileentryjs_expressId(this.__wbg_ptr) >>> 0;
579
+ }
580
+ get holeCount() {
581
+ return c.symbolicfillarea_holeCount(this.__wbg_ptr) >>> 0;
582
+ }
583
+ get hatchAngle() {
584
+ return c.symbolicfillarea_hatchAngle(this.__wbg_ptr);
585
+ }
586
+ get pointCount() {
587
+ return c.symbolicfillarea_pointCount(this.__wbg_ptr) >>> 0;
588
+ }
589
+ get hasHatching() {
590
+ return c.symbolicfillarea_hasHatching(this.__wbg_ptr) !== 0;
591
+ }
592
+ get hatchSpacing() {
593
+ return c.symbolicfillarea_hatchSpacing(this.__wbg_ptr);
594
+ }
595
+ get holesOffsets() {
596
+ const t = c.symbolicfillarea_holesOffsets(this.__wbg_ptr);
597
+ return V(t);
598
+ }
599
+ get repIdentifier() {
600
+ let t, e;
601
+ try {
602
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
603
+ c.symbolicfillarea_repIdentifier(i, this.__wbg_ptr);
604
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
605
+ return t = n, e = s, J(n, s);
606
+ } finally{
607
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
608
+ }
609
+ }
610
+ get hatchLineWidth() {
611
+ return c.symbolicfillarea_hatchLineWidth(this.__wbg_ptr);
612
+ }
613
+ get hatchAngleSecondary() {
614
+ return c.symbolicfillarea_hatchAngleSecondary(this.__wbg_ptr);
615
+ }
616
+ get fillA() {
617
+ return c.symbolicfillarea_fillA(this.__wbg_ptr);
618
+ }
619
+ get fillB() {
620
+ return c.symbolicfillarea_fillB(this.__wbg_ptr);
621
+ }
622
+ get fillG() {
623
+ return c.symbolicfillarea_fillG(this.__wbg_ptr);
624
+ }
625
+ get fillR() {
626
+ return c.symbolicfillarea_fillR(this.__wbg_ptr);
627
+ }
628
+ get points() {
629
+ const t = c.symbolicfillarea_points(this.__wbg_ptr);
630
+ return V(t);
631
+ }
632
+ get worldY() {
633
+ return c.symbolicfillarea_worldY(this.__wbg_ptr);
634
+ }
635
+ get ifcType() {
636
+ let t, e;
637
+ try {
638
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
639
+ c.symbolicfillarea_ifcType(i, this.__wbg_ptr);
640
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
641
+ return t = n, e = s, J(n, s);
642
+ } finally{
643
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
644
+ }
645
+ }
646
+ }
647
+ Symbol.dispose && (Bt.prototype[Symbol.dispose] = Bt.prototype.free);
648
+ class Ut {
649
+ static __wrap(t) {
650
+ t = t >>> 0;
651
+ const e = Object.create(Ut.prototype);
652
+ return e.__wbg_ptr = t, ye.register(e, e.__wbg_ptr, e), e;
653
+ }
654
+ __destroy_into_raw() {
655
+ const t = this.__wbg_ptr;
656
+ return this.__wbg_ptr = 0, ye.unregister(this), t;
657
+ }
658
+ free() {
659
+ const t = this.__destroy_into_raw();
660
+ c.__wbg_symbolicpolyline_free(t, 0);
661
+ }
662
+ get expressId() {
663
+ return c.symbolicpolyline_expressId(this.__wbg_ptr) >>> 0;
664
+ }
665
+ get pointCount() {
666
+ return c.symbolicfillarea_pointCount(this.__wbg_ptr) >>> 0;
667
+ }
668
+ get repIdentifier() {
669
+ let t, e;
670
+ try {
671
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
672
+ c.symbolicpolyline_repIdentifier(i, this.__wbg_ptr);
673
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
674
+ return t = n, e = s, J(n, s);
675
+ } finally{
676
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
677
+ }
678
+ }
679
+ get points() {
680
+ const t = c.symbolicpolyline_points(this.__wbg_ptr);
681
+ return V(t);
682
+ }
683
+ get worldY() {
684
+ return c.symboliccircle_worldY(this.__wbg_ptr);
685
+ }
686
+ get ifcType() {
687
+ let t, e;
688
+ try {
689
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
690
+ c.symbolicpolyline_ifcType(i, this.__wbg_ptr);
691
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
692
+ return t = n, e = s, J(n, s);
693
+ } finally{
694
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
695
+ }
696
+ }
697
+ get isClosed() {
698
+ return c.symbolicpolyline_isClosed(this.__wbg_ptr) !== 0;
699
+ }
700
+ }
701
+ Symbol.dispose && (Ut.prototype[Symbol.dispose] = Ut.prototype.free);
702
+ class Dt {
703
+ static __wrap(t) {
704
+ t = t >>> 0;
705
+ const e = Object.create(Dt.prototype);
706
+ return e.__wbg_ptr = t, Ee.register(e, e.__wbg_ptr, e), e;
707
+ }
708
+ __destroy_into_raw() {
709
+ const t = this.__wbg_ptr;
710
+ return this.__wbg_ptr = 0, Ee.unregister(this), t;
711
+ }
712
+ free() {
713
+ const t = this.__destroy_into_raw();
714
+ c.__wbg_symbolicrepresentationcollection_free(t, 0);
715
+ }
716
+ get fillCount() {
717
+ return c.symbolicrepresentationcollection_fillCount(this.__wbg_ptr) >>> 0;
718
+ }
719
+ getCircle(t) {
720
+ const e = c.symbolicrepresentationcollection_getCircle(this.__wbg_ptr, t);
721
+ return e === 0 ? void 0 : Pt.__wrap(e);
722
+ }
723
+ get textCount() {
724
+ return c.symbolicrepresentationcollection_textCount(this.__wbg_ptr) >>> 0;
725
+ }
726
+ get totalCount() {
727
+ return c.symbolicrepresentationcollection_totalCount(this.__wbg_ptr) >>> 0;
728
+ }
729
+ get circleCount() {
730
+ return c.symbolicrepresentationcollection_circleCount(this.__wbg_ptr) >>> 0;
731
+ }
732
+ getPolyline(t) {
733
+ const e = c.symbolicrepresentationcollection_getPolyline(this.__wbg_ptr, t);
734
+ return e === 0 ? void 0 : Ut.__wrap(e);
735
+ }
736
+ get polylineCount() {
737
+ return c.symbolicrepresentationcollection_polylineCount(this.__wbg_ptr) >>> 0;
738
+ }
739
+ getExpressIds() {
740
+ try {
741
+ const s = c.__wbindgen_add_to_stack_pointer(-16);
742
+ c.symbolicrepresentationcollection_getExpressIds(s, this.__wbg_ptr);
743
+ var t = A().getInt32(s + 0, !0), e = A().getInt32(s + 4, !0), n = xe(t, e).slice();
744
+ return c.__wbindgen_export2(t, e * 4, 4), n;
745
+ } finally{
746
+ c.__wbindgen_add_to_stack_pointer(16);
747
+ }
748
+ }
749
+ getFill(t) {
750
+ const e = c.symbolicrepresentationcollection_getFill(this.__wbg_ptr, t);
751
+ return e === 0 ? void 0 : Bt.__wrap(e);
752
+ }
753
+ getText(t) {
754
+ const e = c.symbolicrepresentationcollection_getText(this.__wbg_ptr, t);
755
+ return e === 0 ? void 0 : vt.__wrap(e);
756
+ }
757
+ get isEmpty() {
758
+ return c.symbolicrepresentationcollection_isEmpty(this.__wbg_ptr) !== 0;
759
+ }
760
+ }
761
+ Symbol.dispose && (Dt.prototype[Symbol.dispose] = Dt.prototype.free);
762
+ class vt {
763
+ static __wrap(t) {
764
+ t = t >>> 0;
765
+ const e = Object.create(vt.prototype);
766
+ return e.__wbg_ptr = t, me.register(e, e.__wbg_ptr, e), e;
767
+ }
768
+ __destroy_into_raw() {
769
+ const t = this.__wbg_ptr;
770
+ return this.__wbg_ptr = 0, me.unregister(this), t;
771
+ }
772
+ free() {
773
+ const t = this.__destroy_into_raw();
774
+ c.__wbg_symbolictext_free(t, 0);
775
+ }
776
+ get expressId() {
777
+ return c.profileentryjs_expressId(this.__wbg_ptr) >>> 0;
778
+ }
779
+ get repIdentifier() {
780
+ let t, e;
781
+ try {
782
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
783
+ c.symbolictext_repIdentifier(i, this.__wbg_ptr);
784
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
785
+ return t = n, e = s, J(n, s);
786
+ } finally{
787
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
788
+ }
789
+ }
790
+ get x() {
791
+ return c.symbolicfillarea_fillR(this.__wbg_ptr);
792
+ }
793
+ get y() {
794
+ return c.symbolicfillarea_fillG(this.__wbg_ptr);
795
+ }
796
+ get dirX() {
797
+ return c.symbolicfillarea_fillB(this.__wbg_ptr);
798
+ }
799
+ get dirY() {
800
+ return c.symbolicfillarea_fillA(this.__wbg_ptr);
801
+ }
802
+ get height() {
803
+ return c.symbolicfillarea_hatchSpacing(this.__wbg_ptr);
804
+ }
805
+ get colorA() {
806
+ return c.symbolictext_colorA(this.__wbg_ptr);
807
+ }
808
+ get colorB() {
809
+ return c.symbolicfillarea_worldY(this.__wbg_ptr);
810
+ }
811
+ get colorG() {
812
+ return c.symbolicfillarea_hatchLineWidth(this.__wbg_ptr);
813
+ }
814
+ get colorR() {
815
+ return c.symbolicfillarea_hatchAngleSecondary(this.__wbg_ptr);
816
+ }
817
+ get content() {
818
+ let t, e;
819
+ try {
820
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
821
+ c.symbolictext_content(i, this.__wbg_ptr);
822
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
823
+ return t = n, e = s, J(n, s);
824
+ } finally{
825
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
826
+ }
827
+ }
828
+ get worldY() {
829
+ return c.symbolicfillarea_hatchAngle(this.__wbg_ptr);
830
+ }
831
+ get ifcType() {
832
+ let t, e;
833
+ try {
834
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
835
+ c.symbolictext_ifcType(i, this.__wbg_ptr);
836
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
837
+ return t = n, e = s, J(n, s);
838
+ } finally{
839
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
840
+ }
841
+ }
842
+ get alignment() {
843
+ let t, e;
844
+ try {
845
+ const i = c.__wbindgen_add_to_stack_pointer(-16);
846
+ c.symbolictext_alignment(i, this.__wbg_ptr);
847
+ var n = A().getInt32(i + 0, !0), s = A().getInt32(i + 4, !0);
848
+ return t = n, e = s, J(n, s);
849
+ } finally{
850
+ c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export2(t, e, 1);
851
+ }
852
+ }
853
+ get targetPx() {
854
+ return c.symbolictext_targetPx(this.__wbg_ptr);
855
+ }
856
+ }
857
+ Symbol.dispose && (vt.prototype[Symbol.dispose] = vt.prototype.free);
858
+ const on = new Set([
859
+ "basic",
860
+ "cors",
861
+ "default"
862
+ ]);
863
+ async function an(r, t) {
864
+ if (typeof Response == "function" && r instanceof Response) {
865
+ if (typeof WebAssembly.instantiateStreaming == "function") try {
866
+ return await WebAssembly.instantiateStreaming(r, t);
867
+ } catch (n) {
868
+ if (r.ok && on.has(r.type) && r.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", n);
869
+ else throw n;
870
+ }
871
+ const e = await r.arrayBuffer();
872
+ return await WebAssembly.instantiate(e, t);
873
+ } else {
874
+ const e = await WebAssembly.instantiate(r, t);
875
+ return e instanceof WebAssembly.Instance ? {
876
+ instance: e,
877
+ module: r
878
+ } : e;
879
+ }
880
+ }
881
+ function cn() {
882
+ const r = {};
883
+ return r.wbg = {}, r.wbg.__wbg_Error_52673b7de5a0ca89 = function(t, e) {
884
+ const n = Error(J(t, e));
885
+ return B(n);
886
+ }, r.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(t) {
887
+ return typeof W(t) == "function";
888
+ }, r.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(t) {
889
+ return W(t) === void 0;
890
+ }, r.wbg.__wbg___wbindgen_memory_a342e963fbcabd68 = function() {
891
+ const t = c.memory;
892
+ return B(t);
893
+ }, r.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(t, e) {
894
+ throw new Error(J(t, e));
895
+ }, r.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(t) {
896
+ W(t)._wbg_cb_unref();
897
+ }, r.wbg.__wbg_call_3020136f7a2d6e44 = function() {
898
+ return Xt(function(t, e, n) {
899
+ const s = W(t).call(W(e), W(n));
900
+ return B(s);
901
+ }, arguments);
902
+ }, r.wbg.__wbg_call_abb4ff46ce38be40 = function() {
903
+ return Xt(function(t, e) {
904
+ const n = W(t).call(W(e));
905
+ return B(n);
906
+ }, arguments);
907
+ }, r.wbg.__wbg_error_7534b8e9a36f1ab4 = function(t, e) {
908
+ let n, s;
909
+ try {
910
+ n = t, s = e, console.error(J(t, e));
911
+ } finally{
912
+ c.__wbindgen_export2(n, s, 1);
913
+ }
914
+ }, r.wbg.__wbg_info_ce6bcc489c22f6f0 = function(t) {
915
+ console.info(W(t));
916
+ }, r.wbg.__wbg_new_1ba21ce319a06297 = function() {
917
+ const t = new Object;
918
+ return B(t);
919
+ }, r.wbg.__wbg_new_25f239778d6112b9 = function() {
920
+ const t = new Array;
921
+ return B(t);
922
+ }, r.wbg.__wbg_new_8a6f238a6ece86ea = function() {
923
+ const t = new Error;
924
+ return B(t);
925
+ }, r.wbg.__wbg_new_ff12d2b041fb48f1 = function(t, e) {
926
+ try {
927
+ var n = {
928
+ a: t,
929
+ b: e
930
+ }, s = (o, a)=>{
931
+ const l = n.a;
932
+ n.a = 0;
933
+ try {
934
+ return rn(l, n.b, o, a);
935
+ } finally{
936
+ n.a = l;
937
+ }
938
+ };
939
+ const i = new Promise(s);
940
+ return B(i);
941
+ } finally{
942
+ n.a = n.b = 0;
943
+ }
944
+ }, r.wbg.__wbg_new_from_slice_41e2764a343e3cb1 = function(t, e) {
945
+ const n = new Float32Array(se(t, e));
946
+ return B(n);
947
+ }, r.wbg.__wbg_new_from_slice_db0691b69e9d3891 = function(t, e) {
948
+ const n = new Uint32Array(xe(t, e));
949
+ return B(n);
950
+ }, r.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(t, e) {
951
+ const n = new Function(J(t, e));
952
+ return B(n);
953
+ }, r.wbg.__wbg_new_with_length_202b3db94ba5fc86 = function(t) {
954
+ const e = new Uint32Array(t >>> 0);
955
+ return B(e);
956
+ }, r.wbg.__wbg_new_with_length_806b9e5b8290af7c = function(t) {
957
+ const e = new Float64Array(t >>> 0);
958
+ return B(e);
959
+ }, r.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(t) {
960
+ const e = new Uint8Array(t >>> 0);
961
+ return B(e);
962
+ }, r.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(t) {
963
+ const e = W(t).queueMicrotask;
964
+ return B(e);
965
+ }, r.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(t) {
966
+ queueMicrotask(W(t));
967
+ }, r.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(t) {
968
+ const e = Promise.resolve(W(t));
969
+ return B(e);
970
+ }, r.wbg.__wbg_set_3f1d0b984ed272ed = function(t, e, n) {
971
+ W(t)[V(e)] = V(n);
972
+ }, r.wbg.__wbg_set_781438a03c0c3c81 = function() {
973
+ return Xt(function(t, e, n) {
974
+ return Reflect.set(W(t), W(e), W(n));
975
+ }, arguments);
976
+ }, r.wbg.__wbg_set_7df433eea03a5c14 = function(t, e, n) {
977
+ W(t)[e >>> 0] = V(n);
978
+ }, r.wbg.__wbg_set_index_021489b2916af13e = function(t, e, n) {
979
+ W(t)[e >>> 0] = n;
980
+ }, r.wbg.__wbg_set_index_04c4b93e64d08a52 = function(t, e, n) {
981
+ W(t)[e >>> 0] = n;
982
+ }, r.wbg.__wbg_set_index_42abe35f117e614e = function(t, e, n) {
983
+ W(t)[e >>> 0] = n >>> 0;
984
+ }, r.wbg.__wbg_stack_0ed75d68575b0f3c = function(t, e) {
985
+ const n = W(e).stack, s = ut(n, c.__wbindgen_export3, c.__wbindgen_export4), i = $;
986
+ A().setInt32(t + 4, i, !0), A().setInt32(t + 0, s, !0);
987
+ }, r.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
988
+ const t = typeof global > "u" ? null : global;
989
+ return $t(t) ? 0 : B(t);
990
+ }, r.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
991
+ const t = typeof globalThis > "u" ? null : globalThis;
992
+ return $t(t) ? 0 : B(t);
993
+ }, r.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
994
+ const t = typeof self > "u" ? null : self;
995
+ return $t(t) ? 0 : B(t);
996
+ }, r.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
997
+ const t = typeof window > "u" ? null : window;
998
+ return $t(t) ? 0 : B(t);
999
+ }, r.wbg.__wbg_then_4f95312d68691235 = function(t, e) {
1000
+ const n = W(t).then(W(e));
1001
+ return B(n);
1002
+ }, r.wbg.__wbg_warn_6e567d0d926ff881 = function(t) {
1003
+ console.warn(W(t));
1004
+ }, r.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(t, e) {
1005
+ const n = J(t, e);
1006
+ return B(n);
1007
+ }, r.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(t) {
1008
+ const e = BigInt.asUintN(64, t);
1009
+ return B(e);
1010
+ }, r.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(t) {
1011
+ return B(t);
1012
+ }, r.wbg.__wbindgen_cast_e7ad0d7b317830d5 = function(t, e) {
1013
+ const n = tn(t, e, c.__wasm_bindgen_func_elem_592, sn);
1014
+ return B(n);
1015
+ }, r.wbg.__wbindgen_object_clone_ref = function(t) {
1016
+ const e = W(t);
1017
+ return B(e);
1018
+ }, r.wbg.__wbindgen_object_drop_ref = function(t) {
1019
+ V(t);
1020
+ }, r;
1021
+ }
1022
+ function ln(r, t) {
1023
+ return c = r.exports, Be.__wbindgen_wasm_module = t, gt = null, Tt = null, wt = null, Ft = null, Rt = null, c.__wbindgen_start(), c;
1024
+ }
1025
+ Be = async function(r) {
1026
+ if (c !== void 0) return c;
1027
+ typeof r < "u" && (Object.getPrototypeOf(r) === Object.prototype ? { module_or_path: r } = r : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof r > "u" && (r = new URL("/assets/ifc-lite_bg-CEZnhM2e.wasm", import.meta.url));
1028
+ const t = cn();
1029
+ (typeof r == "string" || typeof Request == "function" && r instanceof Request || typeof URL == "function" && r instanceof URL) && (r = fetch(r));
1030
+ const { instance: e, module: n } = await an(await r, t);
1031
+ return ln(e, n);
1032
+ };
1033
+ const rt = Ge("Geometry"), dn = "IFC-Lite WASM cannot recover from a fatal runtime error within the same document lifetime. Reload the page or recreate the worker process before calling init() again.";
1034
+ let Qt = null;
1035
+ class fn {
1036
+ ifcApi = null;
1037
+ initialized = !1;
1038
+ mergeLayers = !1;
1039
+ isWasmRuntimeError(t) {
1040
+ return t instanceof WebAssembly.RuntimeError;
1041
+ }
1042
+ markFatalWasmRuntimeError() {
1043
+ Qt = new Error(dn), this.reset();
1044
+ }
1045
+ async init() {
1046
+ if (!this.initialized) {
1047
+ if (Qt) throw Qt;
1048
+ try {
1049
+ await Be(), rt.debug("Geometry processing: single-threaded WASM (N-worker pool handles parallelism)"), this.ifcApi = new ie, this.applyMergeLayers(), this.initialized = !0, rt.info("WASM geometry engine initialized");
1050
+ } catch (t) {
1051
+ throw rt.error("Failed to initialize WASM geometry engine", t, {
1052
+ operation: "init"
1053
+ }), this.isWasmRuntimeError(t) ? this.markFatalWasmRuntimeError() : this.reset(), t;
1054
+ }
1055
+ }
1056
+ }
1057
+ reset() {
1058
+ this.initialized = !1, this.ifcApi = null;
1059
+ }
1060
+ parseSymbolicRepresentations(t) {
1061
+ if (!this.ifcApi) throw new Error("IFC-Lite not initialized. Call init() first.");
1062
+ try {
1063
+ const e = this.ifcApi.parseSymbolicRepresentations(t);
1064
+ return rt.debug(`Parsed ${e.totalCount} symbolic items (${e.polylineCount} polylines, ${e.circleCount} circles)`, {
1065
+ operation: "parseSymbolicRepresentations"
1066
+ }), e;
1067
+ } catch (e) {
1068
+ throw rt.error("Failed to parse symbolic representations", e, {
1069
+ operation: "parseSymbolicRepresentations",
1070
+ data: {
1071
+ contentLength: t.length
1072
+ }
1073
+ }), this.isWasmRuntimeError(e) && this.markFatalWasmRuntimeError(), e;
1074
+ }
1075
+ }
1076
+ parseAlignmentLines(t) {
1077
+ if (!this.ifcApi) throw new Error("IFC-Lite not initialized. Call init() first.");
1078
+ try {
1079
+ const e = this.ifcApi.parseAlignmentLines(t);
1080
+ return rt.debug(`Parsed ${e.length / 3} alignment line vertices`, {
1081
+ operation: "parseAlignmentLines"
1082
+ }), e;
1083
+ } catch (e) {
1084
+ throw rt.error("Failed to parse alignment lines", e, {
1085
+ operation: "parseAlignmentLines",
1086
+ data: {
1087
+ contentLength: t.length
1088
+ }
1089
+ }), this.isWasmRuntimeError(e) && this.markFatalWasmRuntimeError(), e;
1090
+ }
1091
+ }
1092
+ extractProfiles(t, e = 0) {
1093
+ if (!this.ifcApi) throw new Error("IFC-Lite not initialized. Call init() first.");
1094
+ try {
1095
+ const n = this.ifcApi.extractProfiles(t, e);
1096
+ return rt.debug(`Extracted ${n.length} profiles`, {
1097
+ operation: "extractProfiles"
1098
+ }), n;
1099
+ } catch (n) {
1100
+ throw rt.error("Failed to extract profiles", n, {
1101
+ operation: "extractProfiles",
1102
+ data: {
1103
+ contentLength: t.length
1104
+ }
1105
+ }), this.isWasmRuntimeError(n) && this.markFatalWasmRuntimeError(), n;
1106
+ }
1107
+ }
1108
+ getApi() {
1109
+ if (!this.ifcApi) throw new Error("IFC-Lite not initialized. Call init() first.");
1110
+ return this.ifcApi;
1111
+ }
1112
+ isInitialized() {
1113
+ return this.initialized;
1114
+ }
1115
+ getVersion() {
1116
+ return this.ifcApi?.version ?? "unknown";
1117
+ }
1118
+ setMergeLayers(t) {
1119
+ this.mergeLayers = t, this.ifcApi && this.applyMergeLayers();
1120
+ }
1121
+ getMergeLayers() {
1122
+ return this.mergeLayers;
1123
+ }
1124
+ applyMergeLayers() {
1125
+ if (!this.ifcApi) return;
1126
+ const t = this.ifcApi;
1127
+ if (typeof t.setMergeLayers != "function") {
1128
+ rt.warn("setMergeLayers not present on WASM API — flag tracked but suppression is a no-op until WASM is rebuilt", {
1129
+ operation: "setMergeLayers",
1130
+ data: {
1131
+ requested: this.mergeLayers
1132
+ }
1133
+ });
1134
+ return;
1135
+ }
1136
+ t.setMergeLayers(this.mergeLayers), rt.debug(`mergeLayers=${this.mergeLayers}`, {
1137
+ operation: "setMergeLayers"
1138
+ });
1139
+ }
1140
+ }
1141
+ function Ue() {
1142
+ return typeof window < "u" && "__TAURI_INTERNALS__" in window;
1143
+ }
1144
+ async function un() {
1145
+ if (Ue()) {
1146
+ const { NativeBridge: r } = await $e(async ()=>{
1147
+ const { NativeBridge: t } = await import("./native-bridge-CPojOeGE.js").then(async (m)=>{
1148
+ await m.__tla;
1149
+ return m;
1150
+ });
1151
+ return {
1152
+ NativeBridge: t
1153
+ };
1154
+ }, __vite__mapDeps([0,1,2]));
1155
+ return new r;
1156
+ }
1157
+ throw new Error("createPlatformBridge() is native-only; the browser uses the WASM GeometryProcessor path directly.");
1158
+ }
1159
+ class hn {
1160
+ buildInterleavedBuffer(t) {
1161
+ const e = t.positions.length / 3, n = new Float32Array(e * 6);
1162
+ for(let s = 0; s < e; s++){
1163
+ const i = s * 6, o = s * 3, a = s * 3;
1164
+ n[i] = t.positions[o], n[i + 1] = t.positions[o + 1], n[i + 2] = t.positions[o + 2], n[i + 3] = t.normals[a], n[i + 4] = t.normals[a + 1], n[i + 5] = t.normals[a + 2];
1165
+ }
1166
+ return n;
1167
+ }
1168
+ processMeshes(t) {
1169
+ let e = 0, n = 0;
1170
+ for (const s of t)e += s.indices.length / 3, n += s.positions.length / 3;
1171
+ return {
1172
+ meshes: t,
1173
+ totalTriangles: e,
1174
+ totalVertices: n
1175
+ };
1176
+ }
1177
+ }
1178
+ class pn {
1179
+ originShift = {
1180
+ x: 0,
1181
+ y: 0,
1182
+ z: 0
1183
+ };
1184
+ THRESHOLD = 1e4;
1185
+ MAX_REASONABLE_COORD = 1e7;
1186
+ accumulatedBounds = null;
1187
+ shiftCalculated = !1;
1188
+ wasmRtcDetected = !1;
1189
+ NORMAL_COORD_THRESHOLD = 1e4;
1190
+ activeThreshold = 1e7;
1191
+ isReasonableValue(t) {
1192
+ return Number.isFinite(t) && Math.abs(t) < this.MAX_REASONABLE_COORD;
1193
+ }
1194
+ calculateBounds(t, e) {
1195
+ if (this.wasmRtcDetected && this.shiftCalculated) return this.calculateBoundsFast(t);
1196
+ const n = {
1197
+ min: {
1198
+ x: 1 / 0,
1199
+ y: 1 / 0,
1200
+ z: 1 / 0
1201
+ },
1202
+ max: {
1203
+ x: -1 / 0,
1204
+ y: -1 / 0,
1205
+ z: -1 / 0
1206
+ }
1207
+ }, s = e ?? this.MAX_REASONABLE_COORD;
1208
+ for (const i of t){
1209
+ const o = i.positions;
1210
+ for(let a = 0; a < o.length; a += 3){
1211
+ const l = o[a], d = o[a + 1], u = o[a + 2];
1212
+ Number.isFinite(l) && Number.isFinite(d) && Number.isFinite(u) && Math.abs(l) < s && Math.abs(d) < s && Math.abs(u) < s && (n.min.x = Math.min(n.min.x, l), n.min.y = Math.min(n.min.y, d), n.min.z = Math.min(n.min.z, u), n.max.x = Math.max(n.max.x, l), n.max.y = Math.max(n.max.y, d), n.max.z = Math.max(n.max.z, u));
1213
+ }
1214
+ }
1215
+ return n;
1216
+ }
1217
+ calculateBoundsFast(t) {
1218
+ let e = 1 / 0, n = 1 / 0, s = 1 / 0, i = -1 / 0, o = -1 / 0, a = -1 / 0;
1219
+ for (const l of t){
1220
+ const d = l.positions, u = d.length;
1221
+ if (u < 3) continue;
1222
+ const f = d[0], p = d[1], _ = d[2];
1223
+ if (f < e && (e = f), p < n && (n = p), _ < s && (s = _), f > i && (i = f), p > o && (o = p), _ > a && (a = _), u >= 6) {
1224
+ const h = d[u - 3], y = d[u - 2], m = d[u - 1];
1225
+ h < e && (e = h), y < n && (n = y), m < s && (s = m), h > i && (i = h), y > o && (o = y), m > a && (a = m);
1226
+ }
1227
+ }
1228
+ return {
1229
+ min: {
1230
+ x: e,
1231
+ y: n,
1232
+ z: s
1233
+ },
1234
+ max: {
1235
+ x: i,
1236
+ y: o,
1237
+ z: a
1238
+ }
1239
+ };
1240
+ }
1241
+ needsShift(t) {
1242
+ return Math.max(Math.abs(t.min.x), Math.abs(t.max.x), Math.abs(t.min.y), Math.abs(t.max.y), Math.abs(t.min.z), Math.abs(t.max.z)) > this.THRESHOLD;
1243
+ }
1244
+ calculateCentroid(t) {
1245
+ return {
1246
+ x: (t.min.x + t.max.x) / 2,
1247
+ y: (t.min.y + t.max.y) / 2,
1248
+ z: (t.min.z + t.max.z) / 2
1249
+ };
1250
+ }
1251
+ shiftPositions(t, e, n) {
1252
+ const s = n ?? this.MAX_REASONABLE_COORD;
1253
+ for(let i = 0; i < t.length; i += 3){
1254
+ const o = t[i], a = t[i + 1], l = t[i + 2];
1255
+ Number.isFinite(o) && Number.isFinite(a) && Number.isFinite(l) && Math.abs(o) < s && Math.abs(a) < s && Math.abs(l) < s ? (t[i] = o - e.x, t[i + 1] = a - e.y, t[i + 2] = l - e.z) : (t[i] = 0, t[i + 1] = 0, t[i + 2] = 0);
1256
+ }
1257
+ }
1258
+ shiftBounds(t, e) {
1259
+ return {
1260
+ min: {
1261
+ x: t.min.x - e.x,
1262
+ y: t.min.y - e.y,
1263
+ z: t.min.z - e.z
1264
+ },
1265
+ max: {
1266
+ x: t.max.x - e.x,
1267
+ y: t.max.y - e.y,
1268
+ z: t.max.z - e.z
1269
+ }
1270
+ };
1271
+ }
1272
+ processMeshes(t) {
1273
+ const e = {
1274
+ originShift: {
1275
+ x: 0,
1276
+ y: 0,
1277
+ z: 0
1278
+ },
1279
+ originalBounds: {
1280
+ min: {
1281
+ x: 0,
1282
+ y: 0,
1283
+ z: 0
1284
+ },
1285
+ max: {
1286
+ x: 0,
1287
+ y: 0,
1288
+ z: 0
1289
+ }
1290
+ },
1291
+ shiftedBounds: {
1292
+ min: {
1293
+ x: 0,
1294
+ y: 0,
1295
+ z: 0
1296
+ },
1297
+ max: {
1298
+ x: 0,
1299
+ y: 0,
1300
+ z: 0
1301
+ }
1302
+ },
1303
+ hasLargeCoordinates: !1
1304
+ };
1305
+ if (t.length === 0) return e;
1306
+ const n = this.calculateBounds(t);
1307
+ if (!(n.min.x !== 1 / 0 && n.max.x !== -1 / 0)) return console.warn("[CoordinateHandler] No valid coordinates found in geometry"), e;
1308
+ if (n.max.x - n.min.x, n.max.y - n.min.y, n.max.z - n.min.z, !this.needsShift(n)) {
1309
+ const l = {
1310
+ x: 0,
1311
+ y: 0,
1312
+ z: 0
1313
+ };
1314
+ for (const d of t)this.shiftPositions(d.positions, l);
1315
+ return {
1316
+ originShift: l,
1317
+ originalBounds: n,
1318
+ shiftedBounds: n,
1319
+ hasLargeCoordinates: !1
1320
+ };
1321
+ }
1322
+ const o = this.calculateCentroid(n);
1323
+ this.originShift = o;
1324
+ for (const l of t)this.shiftPositions(l.positions, o);
1325
+ const a = this.shiftBounds(n, o);
1326
+ return {
1327
+ originShift: o,
1328
+ originalBounds: n,
1329
+ shiftedBounds: a,
1330
+ hasLargeCoordinates: !0
1331
+ };
1332
+ }
1333
+ toWorldCoordinates(t) {
1334
+ return {
1335
+ x: t.x + this.originShift.x,
1336
+ y: t.y + this.originShift.y,
1337
+ z: t.z + this.originShift.z
1338
+ };
1339
+ }
1340
+ toLocalCoordinates(t) {
1341
+ return {
1342
+ x: t.x - this.originShift.x,
1343
+ y: t.y - this.originShift.y,
1344
+ z: t.z - this.originShift.z
1345
+ };
1346
+ }
1347
+ getOriginShift() {
1348
+ return {
1349
+ ...this.originShift
1350
+ };
1351
+ }
1352
+ processMeshesIncremental(t) {
1353
+ this.activeThreshold = this.wasmRtcDetected ? this.NORMAL_COORD_THRESHOLD : this.MAX_REASONABLE_COORD;
1354
+ const e = this.calculateBounds(t, this.activeThreshold);
1355
+ if (this.accumulatedBounds === null ? this.accumulatedBounds = e : (this.accumulatedBounds.min.x = Math.min(this.accumulatedBounds.min.x, e.min.x), this.accumulatedBounds.min.y = Math.min(this.accumulatedBounds.min.y, e.min.y), this.accumulatedBounds.min.z = Math.min(this.accumulatedBounds.min.z, e.min.z), this.accumulatedBounds.max.x = Math.max(this.accumulatedBounds.max.x, e.max.x), this.accumulatedBounds.max.y = Math.max(this.accumulatedBounds.max.y, e.max.y), this.accumulatedBounds.max.z = Math.max(this.accumulatedBounds.max.z, e.max.z)), !this.shiftCalculated && this.accumulatedBounds) {
1356
+ if (this.accumulatedBounds.min.x !== 1 / 0 && this.accumulatedBounds.max.x !== -1 / 0) {
1357
+ const s = {
1358
+ x: this.accumulatedBounds.max.x - this.accumulatedBounds.min.x,
1359
+ y: this.accumulatedBounds.max.y - this.accumulatedBounds.min.y,
1360
+ z: this.accumulatedBounds.max.z - this.accumulatedBounds.min.z
1361
+ }, i = Math.max(s.x, s.y, s.z), o = this.calculateCentroid(this.accumulatedBounds), a = Math.sqrt(o.x ** 2 + o.y ** 2 + o.z ** 2);
1362
+ let l = 0, d = 0;
1363
+ const u = this.THRESHOLD;
1364
+ for (const _ of t){
1365
+ const h = _.positions;
1366
+ if (h.length >= 3) {
1367
+ const y = Math.abs(h[0]), m = Math.abs(h[1]), b = Math.abs(h[2]);
1368
+ Math.max(y, m, b) < u ? l++ : d++;
1369
+ }
1370
+ }
1371
+ const f = l + d, p = f > 0 && l / f > .5;
1372
+ p && (this.wasmRtcDetected = !0, this.accumulatedBounds = this.calculateBounds(t, this.NORMAL_COORD_THRESHOLD)), (a > this.THRESHOLD || i > this.THRESHOLD) && !p && (this.originShift = o);
1373
+ }
1374
+ this.shiftCalculated = !0;
1375
+ }
1376
+ if (this.originShift.x !== 0 || this.originShift.y !== 0 || this.originShift.z !== 0) for (const n of t)this.shiftPositions(n.positions, this.originShift, this.activeThreshold);
1377
+ }
1378
+ processTrustedMeshesIncremental(t) {
1379
+ const e = this.calculateBoundsFast(t);
1380
+ e.min.x !== 1 / 0 && e.max.x !== -1 / 0 && (this.accumulatedBounds === null ? this.accumulatedBounds = e : (this.accumulatedBounds.min.x = Math.min(this.accumulatedBounds.min.x, e.min.x), this.accumulatedBounds.min.y = Math.min(this.accumulatedBounds.min.y, e.min.y), this.accumulatedBounds.min.z = Math.min(this.accumulatedBounds.min.z, e.min.z), this.accumulatedBounds.max.x = Math.max(this.accumulatedBounds.max.x, e.max.x), this.accumulatedBounds.max.y = Math.max(this.accumulatedBounds.max.y, e.max.y), this.accumulatedBounds.max.z = Math.max(this.accumulatedBounds.max.z, e.max.z)), this.originShift = {
1381
+ x: 0,
1382
+ y: 0,
1383
+ z: 0
1384
+ }, this.wasmRtcDetected = !0, this.shiftCalculated = !0, this.activeThreshold = this.NORMAL_COORD_THRESHOLD);
1385
+ }
1386
+ getCurrentCoordinateInfo() {
1387
+ if (!this.accumulatedBounds || !(this.accumulatedBounds.min.x !== 1 / 0 && this.accumulatedBounds.max.x !== -1 / 0)) return null;
1388
+ const e = this.shiftBounds(this.accumulatedBounds, this.originShift), n = this.originShift.x !== 0 || this.originShift.y !== 0 || this.originShift.z !== 0;
1389
+ return {
1390
+ originShift: {
1391
+ ...this.originShift
1392
+ },
1393
+ originalBounds: {
1394
+ ...this.accumulatedBounds
1395
+ },
1396
+ shiftedBounds: e,
1397
+ hasLargeCoordinates: n
1398
+ };
1399
+ }
1400
+ getFinalCoordinateInfo() {
1401
+ const t = this.getCurrentCoordinateInfo();
1402
+ return t || {
1403
+ originShift: {
1404
+ x: 0,
1405
+ y: 0,
1406
+ z: 0
1407
+ },
1408
+ originalBounds: {
1409
+ min: {
1410
+ x: 0,
1411
+ y: 0,
1412
+ z: 0
1413
+ },
1414
+ max: {
1415
+ x: 0,
1416
+ y: 0,
1417
+ z: 0
1418
+ }
1419
+ },
1420
+ shiftedBounds: {
1421
+ min: {
1422
+ x: 0,
1423
+ y: 0,
1424
+ z: 0
1425
+ },
1426
+ max: {
1427
+ x: 0,
1428
+ y: 0,
1429
+ z: 0
1430
+ }
1431
+ },
1432
+ hasLargeCoordinates: !1
1433
+ };
1434
+ }
1435
+ reset() {
1436
+ this.accumulatedBounds = null, this.shiftCalculated = !1, this.originShift = {
1437
+ x: 0,
1438
+ y: 0,
1439
+ z: 0
1440
+ }, this.wasmRtcDetected = !1, this.activeThreshold = this.MAX_REASONABLE_COORD;
1441
+ }
1442
+ }
1443
+ In = ((r)=>(r.Fast = "fast", r.Balanced = "balanced", r.High = "high", r))(In || {});
1444
+ function gn(r) {
1445
+ const t = Math.max(0, r.fileSizeMB), e = Math.max(1, Math.floor(r.cores)), n = Math.max(1, r.deviceMemoryGB), s = e >= 10 ? Math.max(n, 16) : n, i = Math.max(0, Math.floor(r.totalJobs)), o = Math.max(1, Math.floor(r.minWorkers ?? 1)), a = Math.max(o, Math.floor(r.maxWorkers ?? 8));
1446
+ if (i === 0) return {
1447
+ count: 0,
1448
+ reason: "jobs"
1449
+ };
1450
+ let l;
1451
+ e >= 16 && s >= 16 ? l = Math.min(a, Math.floor(e / 2)) : e >= 12 && s >= 8 ? l = t > 512 ? 4 : 5 : e >= 10 && s >= 8 ? l = t > 512 ? 3 : 4 : e >= 8 && s >= 8 ? l = t > 512 ? 2 : 3 : l = Math.max(1, Math.min(2, Math.floor(e / 2)));
1452
+ const d = s * 1024, u = Math.max(1024, d * .25), f = t * 2.5, p = Math.max(64, t * 1.5), _ = d - u - f, h = _ > 0 ? Math.max(1, Math.floor(_ / p)) : 1, y = [
1453
+ {
1454
+ value: l,
1455
+ reason: "cores"
1456
+ },
1457
+ {
1458
+ value: h,
1459
+ reason: "memory"
1460
+ },
1461
+ {
1462
+ value: i,
1463
+ reason: "jobs"
1464
+ },
1465
+ {
1466
+ value: a,
1467
+ reason: "max"
1468
+ }
1469
+ ];
1470
+ let m = y[0];
1471
+ for(let b = 1; b < y.length; b++)y[b].value < m.value && (m = y[b]);
1472
+ return m.value < o ? {
1473
+ count: o,
1474
+ reason: "min"
1475
+ } : {
1476
+ count: m.value,
1477
+ reason: m.reason
1478
+ };
1479
+ }
1480
+ function _n(r) {
1481
+ return gn(r).count;
1482
+ }
1483
+ const yn = 3e4, En = 15e3, mn = 15e3, Cn = 5e3, bn = 60, Tn = 30, wn = 30, Fn = 15;
1484
+ ns = function(r) {
1485
+ const t = r.desktopStableWasm === !0, e = Math.max(0, Math.floor(r.batchCount)), n = Math.max(0, r.fileSizeMB), s = e > 0 ? t ? Cn : mn : t ? En : yn, i = e > 0 ? t ? Fn : wn : t ? Tn : bn;
1486
+ return Math.max(s, Math.round(s + n * i));
1487
+ };
1488
+ function Rn(r, t) {
1489
+ if (typeof t == "number") return t;
1490
+ const e = t.fileSizeMB ? t.fileSizeMB : r.length / (1024 * 1024);
1491
+ return e < 10 ? 100 : e < 50 ? 200 : e < 100 ? 300 : e < 300 ? 500 : e < 500 ? 1500 : 3e3;
1492
+ }
1493
+ function Ce(r) {
1494
+ const t = [];
1495
+ try {
1496
+ for(let e = 0; e < r.length; e++){
1497
+ const n = r.get(e);
1498
+ if (n) try {
1499
+ const s = n.shadingColor, i = s && s.length === 4 ? [
1500
+ s[0],
1501
+ s[1],
1502
+ s[2],
1503
+ s[3]
1504
+ ] : void 0;
1505
+ t.push({
1506
+ expressId: n.expressId,
1507
+ ifcType: n.ifcType,
1508
+ positions: n.positions,
1509
+ normals: n.normals,
1510
+ indices: n.indices,
1511
+ color: [
1512
+ n.color[0],
1513
+ n.color[1],
1514
+ n.color[2],
1515
+ n.color[3]
1516
+ ],
1517
+ ...i ? {
1518
+ shadingColor: i
1519
+ } : {}
1520
+ });
1521
+ } finally{
1522
+ n.free();
1523
+ }
1524
+ }
1525
+ } finally{
1526
+ r.free();
1527
+ }
1528
+ return t;
1529
+ }
1530
+ function Vt(r, t) {
1531
+ return t !== void 0 ? {
1532
+ ...r,
1533
+ buildingRotation: t
1534
+ } : r;
1535
+ }
1536
+ const Nn = 8, Sn = 32768, An = 4, On = 8192, Ln = 10;
1537
+ function be() {
1538
+ const r = globalThis.scheduler;
1539
+ return typeof r?.yield == "function" ? r.yield() : new Promise((t)=>{
1540
+ globalThis.setTimeout(t, 0);
1541
+ });
1542
+ }
1543
+ function Te(r, t, e) {
1544
+ if (t.type === "colorUpdate") {
1545
+ const i = r[r.length - 1];
1546
+ if (i?.type === "colorUpdate") {
1547
+ for (const [o, a] of t.updates)i.updates.set(o, a);
1548
+ return;
1549
+ }
1550
+ r.push(t);
1551
+ return;
1552
+ }
1553
+ const n = r[r.length - 1];
1554
+ if (n?.type === "batch" && (r.length >= Nn || e.queuedMeshes >= Sn)) {
1555
+ for(let i = 0; i < t.meshes.length; i++)n.meshes.push(t.meshes[i]);
1556
+ n.nativeTelemetry = t.nativeTelemetry, e.coalescedBatchCount += 1;
1557
+ } else r.push(t);
1558
+ e.queuedMeshes += t.meshes.length;
1559
+ }
1560
+ async function* we(r, t, e, n) {
1561
+ e.reset(), yield {
1562
+ type: "start",
1563
+ totalEstimate: t
1564
+ }, await be(), yield {
1565
+ type: "model-open",
1566
+ modelID: 0
1567
+ };
1568
+ const s = [], i = {
1569
+ queuedMeshes: 0,
1570
+ coalescedBatchCount: 0
1571
+ };
1572
+ let o = null, a = !1, l = null, d, u = 0;
1573
+ const f = ()=>{
1574
+ o && (o(), o = null);
1575
+ }, p = r({
1576
+ onBatch: (h)=>{
1577
+ Te(s, {
1578
+ type: "batch",
1579
+ meshes: h.meshes,
1580
+ nativeTelemetry: h.nativeTelemetry
1581
+ }, i), f();
1582
+ },
1583
+ onColorUpdate: (h)=>{
1584
+ Te(s, {
1585
+ type: "colorUpdate",
1586
+ updates: new Map(h)
1587
+ }, i), f();
1588
+ },
1589
+ onComplete: (h)=>{
1590
+ n(h), d = h.totalMeshes, a = !0, f();
1591
+ },
1592
+ onError: (h)=>{
1593
+ l = h, a = !0, f();
1594
+ }
1595
+ });
1596
+ for(; !a || s.length > 0;){
1597
+ let h = 0, y = 0, m = performance.now();
1598
+ for(; s.length > 0;){
1599
+ const b = s.shift();
1600
+ if (b.type === "colorUpdate") {
1601
+ yield {
1602
+ type: "colorUpdate",
1603
+ updates: b.updates
1604
+ };
1605
+ continue;
1606
+ }
1607
+ i.queuedMeshes = Math.max(0, i.queuedMeshes - b.meshes.length), e.processTrustedMeshesIncremental(b.meshes), u += b.meshes.length;
1608
+ const w = e.getCurrentCoordinateInfo();
1609
+ yield {
1610
+ type: "batch",
1611
+ meshes: b.meshes,
1612
+ totalSoFar: u,
1613
+ coordinateInfo: w || void 0,
1614
+ nativeTelemetry: b.nativeTelemetry
1615
+ }, h += 1, y += b.meshes.length, s.length > 0 && (h >= An || y >= On || performance.now() - m >= Ln) && (await be(), h = 0, y = 0, m = performance.now());
1616
+ }
1617
+ if (l) throw l;
1618
+ a || await new Promise((b)=>{
1619
+ o = b;
1620
+ });
1621
+ }
1622
+ await p, i.coalescedBatchCount > 0 && console.info(`[GeometryProcessor] Coalesced ${i.coalescedBatchCount} native batches while JS drained the queue`);
1623
+ const _ = e.getFinalCoordinateInfo();
1624
+ yield {
1625
+ type: "complete",
1626
+ totalMeshes: d ?? u,
1627
+ coordinateInfo: _
1628
+ };
1629
+ }
1630
+ async function* Mn(r, t, e, n, s) {
1631
+ t.reset(), yield {
1632
+ type: "start",
1633
+ totalEstimate: r.length / 1e3
1634
+ }, yield {
1635
+ type: "model-open",
1636
+ modelID: 0
1637
+ };
1638
+ let i;
1639
+ const o = r.buffer;
1640
+ n && n.byteLength === r.byteLength ? i = n : typeof SharedArrayBuffer < "u" && o instanceof SharedArrayBuffer && r.byteOffset === 0 && r.byteLength === o.byteLength ? i = o : (i = new SharedArrayBuffer(r.byteLength), new Uint8Array(i).set(r));
1641
+ const a = ()=>new Worker(new URL("/assets/geometry.worker-0Q9qEa6p.js", import.meta.url), {
1642
+ type: "module"
1643
+ }), l = ()=>new Worker(new URL("/assets/geometry.worker-0Q9qEa6p.js", import.meta.url), {
1644
+ type: "module"
1645
+ }), d = [];
1646
+ let u = null;
1647
+ const f = ()=>{
1648
+ u && (u(), u = null);
1649
+ };
1650
+ let p = null, _ = 0, h = !1, y = null, m = null, b = 0, w = 0, v = !1, L = !1;
1651
+ const j = [];
1652
+ let O = !1, U = !1;
1653
+ const C = [], N = (M, X)=>{
1654
+ M.onmessage = (P)=>{
1655
+ const x = P.data;
1656
+ if (x.type === "ready") {
1657
+ console.log(`[stream] worker[${X}] WASM ready @ ${Q()}ms`);
1658
+ return;
1659
+ }
1660
+ if (x.type === "memory") {
1661
+ d.push({
1662
+ type: "workerMemory",
1663
+ workerIndex: X,
1664
+ wasmHeapBytes: x.wasmHeapBytes,
1665
+ meshBytes: x.meshBytes
1666
+ }), f();
1667
+ return;
1668
+ }
1669
+ if (x.type === "batch") {
1670
+ C[X] === void 0 && (C[X] = Q(), console.log(`[stream] worker[${X}] first batch @ ${Q()}ms (${x.meshes?.length ?? 0} meshes)`));
1671
+ const q = x.meshes.map((D)=>({
1672
+ expressId: D.expressId,
1673
+ ifcType: D.ifcType,
1674
+ positions: D.positions instanceof Float32Array ? D.positions : new Float32Array(D.positions),
1675
+ normals: D.normals instanceof Float32Array ? D.normals : new Float32Array(D.normals),
1676
+ indices: D.indices instanceof Uint32Array ? D.indices : new Uint32Array(D.indices),
1677
+ color: D.color
1678
+ }));
1679
+ if (q.length > 0) {
1680
+ w += q.length, t.processMeshesIncremental(q);
1681
+ const D = t.getCurrentCoordinateInfo();
1682
+ d.push({
1683
+ type: "batch",
1684
+ meshes: q,
1685
+ totalSoFar: w,
1686
+ coordinateInfo: D || void 0
1687
+ }), f();
1688
+ }
1689
+ return;
1690
+ }
1691
+ if (x.type === "complete") {
1692
+ b++, M.terminate(), f();
1693
+ return;
1694
+ }
1695
+ if (x.type === "error") {
1696
+ m = new Error(`Geometry worker error: ${x.message}`), b++, M.terminate(), f();
1697
+ return;
1698
+ }
1699
+ }, M.onerror = (P)=>{
1700
+ m = new Error(`Geometry worker failed: ${P.message}`), b++, M.terminate(), f();
1701
+ };
1702
+ }, F = typeof navigator < "u" ? navigator.hardwareConcurrency ?? 2 : 2, E = typeof navigator < "u" ? navigator.deviceMemory ?? 8 : 8, g = r.byteLength / (1024 * 1024), T = Math.max(1, Math.ceil(g * 100)), I = _n({
1703
+ fileSizeMB: g,
1704
+ cores: F,
1705
+ deviceMemoryGB: E,
1706
+ totalJobs: T
1707
+ }), R = [];
1708
+ for(let M = 0; M < I; M++){
1709
+ const X = a();
1710
+ R.push(X), N(X, M);
1711
+ const P = s?.wasmUrls?.wasm;
1712
+ X.postMessage({
1713
+ type: "init",
1714
+ ...P ? {
1715
+ wasmUrl: P
1716
+ } : {}
1717
+ }), X.postMessage({
1718
+ type: "set-merge-layers",
1719
+ enabled: s?.mergeLayers === !0
1720
+ });
1721
+ }
1722
+ const S = ()=>{
1723
+ if (!v) {
1724
+ v = !0;
1725
+ for (const M of R)try {
1726
+ M.postMessage({
1727
+ type: "stream-end"
1728
+ });
1729
+ } catch {}
1730
+ }
1731
+ }, G = ()=>{
1732
+ if (L || !p) return;
1733
+ L = !0;
1734
+ const M = e != null, X = M ? e.x : p.rtcOffset[0], P = M ? e.y : p.rtcOffset[1], x = M ? e.z : p.rtcOffset[2], q = M ? !0 : p.needsShift;
1735
+ d.push({
1736
+ type: "rtcOffset",
1737
+ rtcOffset: {
1738
+ x: X,
1739
+ y: P,
1740
+ z: x
1741
+ },
1742
+ hasRtc: q
1743
+ }), f();
1744
+ const D = new Uint32Array(0), st = new Uint8Array(0);
1745
+ for (const pt of R)pt.postMessage({
1746
+ type: "stream-start",
1747
+ sharedBuffer: i,
1748
+ unitScale: p.unitScale,
1749
+ rtcX: X,
1750
+ rtcY: P,
1751
+ rtcZ: x,
1752
+ needsShift: q,
1753
+ voidKeys: D,
1754
+ voidCounts: D,
1755
+ voidValues: D,
1756
+ styleIds: D,
1757
+ styleColors: st
1758
+ });
1759
+ };
1760
+ function z(M) {
1761
+ if (R.length === 0 || M.length === 0) return;
1762
+ const X = Math.floor(M.length / 3);
1763
+ if (X === 0) return;
1764
+ const P = Math.ceil(X / R.length);
1765
+ try {
1766
+ for(let x = 0; x < R.length; x++){
1767
+ const q = x * P * 3, D = Math.min(q + P * 3, M.length);
1768
+ if (q >= D) continue;
1769
+ const st = M.slice(q, D);
1770
+ R[x].postMessage({
1771
+ type: "stream-chunk",
1772
+ jobsFlat: st
1773
+ }, [
1774
+ st.buffer
1775
+ ]);
1776
+ }
1777
+ } catch (x) {
1778
+ m = new Error(`Failed to dispatch jobs chunk: ${x instanceof Error ? x.message : String(x)}`), f();
1779
+ }
1780
+ }
1781
+ const k = (M)=>{
1782
+ if (!L || !O || !U) {
1783
+ j.push(M);
1784
+ return;
1785
+ }
1786
+ z(M);
1787
+ }, H = ()=>{
1788
+ if (!(!L || !O || !U)) for(; j.length > 0;)z(j.shift());
1789
+ }, Y = performance.now(), Q = ()=>Math.round(performance.now() - Y);
1790
+ console.log(`[stream] processParallel start, fileSizeMB=${g.toFixed(1)} workerCount=${I}`);
1791
+ const K = l();
1792
+ s?.wasmUrls?.wasm && K.postMessage({
1793
+ type: "init",
1794
+ wasmUrl: s.wasmUrls.wasm
1795
+ });
1796
+ let at = 0, ht = 0, it = -1;
1797
+ K.onmessage = (M)=>{
1798
+ const X = M.data;
1799
+ if (X.type === "prepass-progress") {
1800
+ d.push({
1801
+ type: "progress",
1802
+ phase: "prepass"
1803
+ }), f();
1804
+ return;
1805
+ }
1806
+ if (X.type === "prepass-stream") {
1807
+ const P = X.event;
1808
+ if (P.type === "meta") p = {
1809
+ unitScale: P.unitScale,
1810
+ rtcOffset: P.rtcOffset,
1811
+ needsShift: P.needsShift,
1812
+ buildingRotation: P.buildingRotation ?? null
1813
+ }, console.log(`[stream] meta @ ${Q()}ms unitScale=${p.unitScale} rtc=[${p.rtcOffset[0].toFixed(0)},${p.rtcOffset[1].toFixed(0)},${p.rtcOffset[2].toFixed(0)}]`), G(), f();
1814
+ else if (P.type === "jobs") {
1815
+ const x = P.jobs, q = Math.floor(x.length / 3);
1816
+ at++, ht += q, it < 0 && (it = Q(), console.log(`[stream] first jobs chunk @ ${it}ms (${q} jobs)`)), (at % 10 === 1 || q < 1e3) && console.log(`[stream] chunk #${at} @ ${Q()}ms (+${q} jobs, total ${ht})`), k(x);
1817
+ } else if (P.type === "styles") {
1818
+ const x = P.styleIds, q = P.styleColors, D = P.voidKeys, st = P.voidCounts, pt = P.voidValues;
1819
+ console.log(`[stream] styles @ ${Q()}ms (${x.length} styled, ${D.length} void hosts), draining ${j.length} queued chunks`);
1820
+ for (const Ht of R)try {
1821
+ const dt = x.slice(), yt = q.slice(), Et = D.slice(), mt = st.slice(), Gt = pt.slice();
1822
+ Ht.postMessage({
1823
+ type: "set-styles",
1824
+ styleIds: dt,
1825
+ styleColors: yt,
1826
+ voidKeys: Et,
1827
+ voidCounts: mt,
1828
+ voidValues: Gt
1829
+ }, [
1830
+ dt.buffer,
1831
+ yt.buffer,
1832
+ Et.buffer,
1833
+ mt.buffer,
1834
+ Gt.buffer
1835
+ ]);
1836
+ } catch (dt) {
1837
+ console.warn("[stream] set-styles dispatch failed:", dt);
1838
+ }
1839
+ O = !0, H();
1840
+ } else if (P.type === "entity-index") {
1841
+ const x = P.ids, q = P.starts, D = P.lengths;
1842
+ if (console.log(`[stream] entity-index @ ${Q()}ms (${x.length} entries)`), typeof SharedArrayBuffer < "u") {
1843
+ const st = x.byteLength, pt = q.byteLength, Ht = D.byteLength, dt = new SharedArrayBuffer(st), yt = new SharedArrayBuffer(pt), Et = new SharedArrayBuffer(Ht);
1844
+ new Uint32Array(dt).set(x), new Uint32Array(yt).set(q), new Uint32Array(Et).set(D);
1845
+ for (const mt of R)try {
1846
+ mt.postMessage({
1847
+ type: "set-entity-index",
1848
+ ids: new Uint32Array(dt),
1849
+ starts: new Uint32Array(yt),
1850
+ lengths: new Uint32Array(Et)
1851
+ });
1852
+ } catch (Gt) {
1853
+ console.warn("[stream] set-entity-index dispatch failed:", Gt);
1854
+ }
1855
+ if (s?.onEntityIndex) try {
1856
+ s.onEntityIndex(new Uint32Array(dt), new Uint32Array(yt), new Uint32Array(Et));
1857
+ } catch (mt) {
1858
+ console.warn("[stream] onEntityIndex callback failed:", mt);
1859
+ }
1860
+ } else {
1861
+ for (const st of R)try {
1862
+ st.postMessage({
1863
+ type: "set-entity-index",
1864
+ ids: x.slice(),
1865
+ starts: q.slice(),
1866
+ lengths: D.slice()
1867
+ });
1868
+ } catch (pt) {
1869
+ console.warn("[stream] set-entity-index dispatch failed:", pt);
1870
+ }
1871
+ if (s?.onEntityIndex) try {
1872
+ s.onEntityIndex(x.slice(), q.slice(), D.slice());
1873
+ } catch (st) {
1874
+ console.warn("[stream] onEntityIndex callback failed:", st);
1875
+ }
1876
+ }
1877
+ U = !0, H();
1878
+ } else P.type === "complete" && (_ = P.totalJobs, console.log(`[stream] prepass complete @ ${Q()}ms totalJobs=${_} chunks=${at}`), ct || (ct = !0, lt()));
1879
+ return;
1880
+ }
1881
+ if (X.type === "error") {
1882
+ y = new Error(X.message), h = !0, K.terminate(), f();
1883
+ return;
1884
+ }
1885
+ }, K.onerror = (M)=>{
1886
+ y = new Error(`Pre-pass worker failed: ${M.message}`), h = !0, K.terminate(), f();
1887
+ };
1888
+ const lt = ()=>{
1889
+ h = !0, L && S(), K.terminate(), f();
1890
+ };
1891
+ K.postMessage({
1892
+ type: "prepass-streaming",
1893
+ sharedBuffer: i,
1894
+ chunkSize: 5e4
1895
+ });
1896
+ let ct = !1;
1897
+ for(;;){
1898
+ for(; d.length > 0;)yield d.shift();
1899
+ if (m) {
1900
+ for (const M of R)try {
1901
+ M.terminate();
1902
+ } catch {}
1903
+ try {
1904
+ K.terminate();
1905
+ } catch {}
1906
+ throw m;
1907
+ }
1908
+ if (y) {
1909
+ for (const M of R)try {
1910
+ M.terminate();
1911
+ } catch {}
1912
+ throw y;
1913
+ }
1914
+ if (h && !L && _ === 0) {
1915
+ for (const X of R)try {
1916
+ X.terminate();
1917
+ } catch {}
1918
+ yield {
1919
+ type: "complete",
1920
+ totalMeshes: 0,
1921
+ coordinateInfo: t.getFinalCoordinateInfo()
1922
+ };
1923
+ return;
1924
+ }
1925
+ if (h && L && b >= R.length && d.length === 0) break;
1926
+ await new Promise((M)=>{
1927
+ u = M;
1928
+ });
1929
+ }
1930
+ const _t = t.getFinalCoordinateInfo();
1931
+ yield {
1932
+ type: "complete",
1933
+ totalMeshes: w,
1934
+ coordinateInfo: _t
1935
+ };
1936
+ }
1937
+ let bt = null;
1938
+ function xn(r) {
1939
+ if (bt) throw new Error(`GeometryProcessor ${r} cannot start while ${bt} is still running. Wait for the active stream to finish, or cancel it before starting another geometry operation.`);
1940
+ return bt = r, ()=>{
1941
+ bt === r && (bt = null);
1942
+ };
1943
+ }
1944
+ ss = class {
1945
+ static largeFileByteStreamingThreshold = 256 * 1024 * 1024;
1946
+ bridge = null;
1947
+ platformBridge = null;
1948
+ bufferBuilder;
1949
+ coordinateHandler;
1950
+ isNative = !1;
1951
+ lastNativeStats = null;
1952
+ mergeLayers;
1953
+ constructor(t = {}){
1954
+ this.bufferBuilder = new hn, this.coordinateHandler = new pn, this.isNative = t.preferNative !== !1 && Ue(), this.mergeLayers = t.mergeLayers === !0, t.quality, this.isNative || (this.bridge = new fn, this.bridge.setMergeLayers(this.mergeLayers));
1955
+ }
1956
+ async init() {
1957
+ this.isNative ? (this.platformBridge = await un(), await this.platformBridge.init(), console.log("[GeometryProcessor] Native bridge initialized")) : this.bridge && await this.bridge.init();
1958
+ }
1959
+ async process(t, e) {
1960
+ let n;
1961
+ if (this.isNative && this.platformBridge) console.time("[GeometryProcessor] native-processing"), n = (await this.platformBridge.processGeometry(t)).meshes, console.timeEnd("[GeometryProcessor] native-processing");
1962
+ else {
1963
+ this.bridge?.isInitialized() || await this.init();
1964
+ const a = await this.collectMeshesMainThread(t);
1965
+ n = a.meshes;
1966
+ const l = this.coordinateHandler.processMeshes(n), d = a.buildingRotation, u = {
1967
+ ...l,
1968
+ buildingRotation: d
1969
+ }, f = this.bufferBuilder.processMeshes(n);
1970
+ return {
1971
+ meshes: f.meshes,
1972
+ totalTriangles: f.totalTriangles,
1973
+ totalVertices: f.totalVertices,
1974
+ coordinateInfo: u
1975
+ };
1976
+ }
1977
+ const s = this.coordinateHandler.processMeshes(n), i = this.bufferBuilder.processMeshes(n);
1978
+ return {
1979
+ meshes: i.meshes,
1980
+ totalTriangles: i.totalTriangles,
1981
+ totalVertices: i.totalVertices,
1982
+ coordinateInfo: s
1983
+ };
1984
+ }
1985
+ async processPath(t) {
1986
+ if (!this.isNative) throw new Error("Path-based geometry processing is only available in native desktop builds");
1987
+ if (this.platformBridge || await this.init(), !this.platformBridge?.processGeometryPath) throw new Error("Native platform bridge does not support file-path geometry processing");
1988
+ const e = await this.platformBridge.processGeometryPath(t), n = this.coordinateHandler.processMeshes(e.meshes);
1989
+ return {
1990
+ meshes: e.meshes,
1991
+ totalTriangles: e.totalTriangles,
1992
+ totalVertices: e.totalVertices,
1993
+ coordinateInfo: n
1994
+ };
1995
+ }
1996
+ collectMeshesViaPrePass(t) {
1997
+ if (!this.bridge) throw new Error("WASM bridge not initialized");
1998
+ const e = this.bridge.getApi(), n = e.buildPrePassOnce(t);
1999
+ try {
2000
+ const s = [], i = n.totalJobs ?? 0;
2001
+ if (n.jobs && i > 0) {
2002
+ const o = e.processGeometryBatch(t, n.jobs, n.unitScale, n.rtcOffset?.[0] ?? 0, n.rtcOffset?.[1] ?? 0, n.rtcOffset?.[2] ?? 0, n.needsShift, n.voidKeys, n.voidCounts, n.voidValues, n.styleIds, n.styleColors);
2003
+ s.push(...Ce(o));
2004
+ }
2005
+ return {
2006
+ meshes: s,
2007
+ buildingRotation: n.buildingRotation ?? void 0
2008
+ };
2009
+ } finally{
2010
+ e.clearPrePassCache?.();
2011
+ }
2012
+ }
2013
+ async collectMeshesMainThread(t, e) {
2014
+ return this.collectMeshesViaPrePass(t);
2015
+ }
2016
+ async *processStreamingBytes(t, e) {
2017
+ if (!this.bridge) throw new Error("WASM bridge not initialized");
2018
+ const n = this.bridge.getApi(), s = n.buildPrePassOnce(t);
2019
+ try {
2020
+ yield {
2021
+ type: "model-open",
2022
+ modelID: 0
2023
+ }, s.rtcOffset && (yield {
2024
+ type: "rtcOffset",
2025
+ rtcOffset: {
2026
+ x: s.rtcOffset[0] ?? 0,
2027
+ y: s.rtcOffset[1] ?? 0,
2028
+ z: s.rtcOffset[2] ?? 0
2029
+ },
2030
+ hasRtc: !!s.needsShift
2031
+ });
2032
+ const i = s.buildingRotation ?? void 0;
2033
+ if (!s.jobs || s.totalJobs === 0) {
2034
+ yield {
2035
+ type: "complete",
2036
+ totalMeshes: 0,
2037
+ coordinateInfo: Vt(this.coordinateHandler.getFinalCoordinateInfo(), i)
2038
+ };
2039
+ return;
2040
+ }
2041
+ const o = Rn(t, e), l = Math.max(o, Math.ceil(s.totalJobs / 30));
2042
+ let d = 0;
2043
+ for(let f = 0; f < s.totalJobs; f += l){
2044
+ const p = Math.min(f + l, s.totalJobs), _ = s.jobs.slice(f * 3, p * 3), h = n.processGeometryBatch(t, _, s.unitScale, s.rtcOffset?.[0] ?? 0, s.rtcOffset?.[1] ?? 0, s.rtcOffset?.[2] ?? 0, s.needsShift, s.voidKeys, s.voidCounts, s.voidValues, s.styleIds, s.styleColors), y = Ce(h);
2045
+ if (y.length === 0) {
2046
+ await new Promise((w)=>setTimeout(w, 0));
2047
+ continue;
2048
+ }
2049
+ this.coordinateHandler.processMeshesIncremental(y), d += y.length;
2050
+ const m = this.coordinateHandler.getCurrentCoordinateInfo(), b = m ? Vt(m, i) : null;
2051
+ yield {
2052
+ type: "batch",
2053
+ meshes: y,
2054
+ totalSoFar: d,
2055
+ coordinateInfo: b || void 0
2056
+ }, await new Promise((w)=>setTimeout(w, 0));
2057
+ }
2058
+ const u = Vt(this.coordinateHandler.getFinalCoordinateInfo(), i);
2059
+ yield {
2060
+ type: "complete",
2061
+ totalMeshes: d,
2062
+ coordinateInfo: u
2063
+ };
2064
+ } finally{
2065
+ n.clearPrePassCache?.();
2066
+ }
2067
+ }
2068
+ async *processStreaming(t, e, n = 25, s) {
2069
+ const i = this.isNative ? null : xn("processStreaming");
2070
+ try {
2071
+ yield* this.processStreamingUnlocked(t, e, n, s);
2072
+ } finally{
2073
+ i?.();
2074
+ }
2075
+ }
2076
+ async *processStreamingUnlocked(t, e, n = 25, s) {
2077
+ if (this.isNative ? this.platformBridge || await this.init() : this.bridge?.isInitialized() || await this.init(), this.coordinateHandler.reset(), yield {
2078
+ type: "start",
2079
+ totalEstimate: t.length / 1e3
2080
+ }, await new Promise((i)=>setTimeout(i, 0)), this.isNative && this.platformBridge) {
2081
+ yield {
2082
+ type: "model-open",
2083
+ modelID: 0
2084
+ }, console.time("[GeometryProcessor] native-streaming");
2085
+ const i = [];
2086
+ let o = null, a = !1, l = null, d, u = 0;
2087
+ const f = ()=>{
2088
+ o && (o(), o = null);
2089
+ }, p = this.platformBridge.processGeometryStreaming(t, {
2090
+ onBatch: (h)=>{
2091
+ i.push({
2092
+ type: "batch",
2093
+ meshes: h.meshes,
2094
+ nativeTelemetry: h.nativeTelemetry
2095
+ }), f();
2096
+ },
2097
+ onColorUpdate: (h)=>{
2098
+ i.push({
2099
+ type: "colorUpdate",
2100
+ updates: new Map(h)
2101
+ }), f();
2102
+ },
2103
+ onComplete: (h)=>{
2104
+ this.lastNativeStats = h, d = h.totalMeshes, a = !0, f();
2105
+ },
2106
+ onError: (h)=>{
2107
+ l = h, a = !0, f();
2108
+ }
2109
+ });
2110
+ for(; !a || i.length > 0;){
2111
+ for(; i.length > 0;){
2112
+ const h = i.shift();
2113
+ if (h.type === "colorUpdate") {
2114
+ yield {
2115
+ type: "colorUpdate",
2116
+ updates: h.updates
2117
+ };
2118
+ continue;
2119
+ }
2120
+ this.coordinateHandler.processMeshesIncremental(h.meshes), u += h.meshes.length;
2121
+ const y = this.coordinateHandler.getCurrentCoordinateInfo();
2122
+ yield {
2123
+ type: "batch",
2124
+ meshes: h.meshes,
2125
+ totalSoFar: u,
2126
+ coordinateInfo: y || void 0,
2127
+ nativeTelemetry: h.nativeTelemetry
2128
+ };
2129
+ }
2130
+ if (l) throw l;
2131
+ a || await new Promise((h)=>{
2132
+ o = h;
2133
+ });
2134
+ }
2135
+ await p;
2136
+ const _ = this.coordinateHandler.getFinalCoordinateInfo();
2137
+ yield {
2138
+ type: "complete",
2139
+ totalMeshes: d ?? u,
2140
+ coordinateInfo: _
2141
+ }, console.timeEnd("[GeometryProcessor] native-streaming");
2142
+ } else {
2143
+ if (!this.bridge) throw new Error("WASM bridge not initialized");
2144
+ yield* this.processStreamingBytes(t, n);
2145
+ }
2146
+ }
2147
+ async *processStreamingPath(t, e = 0, n) {
2148
+ if (!this.isNative) throw new Error("File-path geometry streaming is only available in native desktop builds");
2149
+ if (this.platformBridge || await this.init(), !this.platformBridge?.processGeometryStreamingPath) throw new Error("Native platform bridge does not support file-path streaming");
2150
+ yield* we((s)=>this.platformBridge.processGeometryStreamingPath(t, s, n), e > 0 ? e / 1e3 : 0, this.coordinateHandler, (s)=>{
2151
+ this.lastNativeStats = s;
2152
+ });
2153
+ }
2154
+ async *processStreamingCache(t) {
2155
+ if (!this.isNative) throw new Error("Native cached geometry streaming is only available in native desktop builds");
2156
+ if (this.platformBridge || await this.init(), !this.platformBridge?.processGeometryStreamingCache) throw new Error("Native platform bridge does not support cached geometry streaming");
2157
+ yield* we((e)=>this.platformBridge.processGeometryStreamingCache(t, e), 0, this.coordinateHandler, (e)=>{
2158
+ this.lastNativeStats = e;
2159
+ });
2160
+ }
2161
+ async *processParallel(t, e, n, s, i) {
2162
+ this.bridge?.isInitialized() || await this.init(), yield* Mn(t, this.coordinateHandler, e, n, {
2163
+ onEntityIndex: s,
2164
+ mergeLayers: this.mergeLayers,
2165
+ wasmUrls: i
2166
+ });
2167
+ }
2168
+ async *processAdaptive(t, e = {}) {
2169
+ const n = e.sizeThreshold ?? 2097152, s = e.batchSize ?? 25;
2170
+ if (this.isNative ? this.platformBridge || await this.init() : this.bridge?.isInitialized() || await this.init(), this.coordinateHandler.reset(), t.length < n) {
2171
+ yield {
2172
+ type: "start",
2173
+ totalEstimate: t.length / 1e3
2174
+ }, yield {
2175
+ type: "model-open",
2176
+ modelID: 0
2177
+ };
2178
+ let i, o;
2179
+ if (this.isNative && this.platformBridge) console.time("[GeometryProcessor] native-adaptive-sync"), i = (await this.platformBridge.processGeometry(t)).meshes, console.timeEnd("[GeometryProcessor] native-adaptive-sync");
2180
+ else {
2181
+ const l = this.collectMeshesViaPrePass(t);
2182
+ i = l.meshes, o = l.buildingRotation;
2183
+ }
2184
+ this.coordinateHandler.processMeshesIncremental(i);
2185
+ const a = Vt(this.coordinateHandler.getFinalCoordinateInfo(), o);
2186
+ yield {
2187
+ type: "batch",
2188
+ meshes: i,
2189
+ totalSoFar: i.length,
2190
+ coordinateInfo: a || void 0
2191
+ }, yield {
2192
+ type: "complete",
2193
+ totalMeshes: i.length,
2194
+ coordinateInfo: a
2195
+ };
2196
+ } else typeof SharedArrayBuffer < "u" && typeof Worker < "u" && typeof navigator < "u" && (navigator.hardwareConcurrency ?? 1) > 1 ? yield* this.processParallel(t, e.sharedRtcOffset, e.existingSab, e.onEntityIndex, e.wasmUrls) : yield* this.processStreaming(t, e.entityIndex, s, e.sharedRtcOffset);
2197
+ }
2198
+ getApi() {
2199
+ return !this.bridge || !this.bridge.isInitialized() ? null : this.bridge.getApi();
2200
+ }
2201
+ getLastNativeStats() {
2202
+ return this.lastNativeStats;
2203
+ }
2204
+ parseSymbolicRepresentations(t) {
2205
+ if (!this.bridge || !this.bridge.isInitialized()) return null;
2206
+ const e = nt(t);
2207
+ return this.bridge.parseSymbolicRepresentations(e);
2208
+ }
2209
+ parseAlignmentLines(t) {
2210
+ if (!this.bridge || !this.bridge.isInitialized()) return null;
2211
+ const e = nt(t);
2212
+ return this.bridge.parseAlignmentLines(e);
2213
+ }
2214
+ extractProfiles(t, e = 0) {
2215
+ if (!this.bridge || !this.bridge.isInitialized()) return null;
2216
+ const n = nt(t);
2217
+ return this.bridge.extractProfiles(n, e);
2218
+ }
2219
+ dispose() {}
2220
+ };
2221
+ is = class {
2222
+ geometryResult;
2223
+ constructor(t){
2224
+ this.geometryResult = t;
2225
+ }
2226
+ exportGLB(t = {}) {
2227
+ const e = this.buildGLTF(t);
2228
+ return this.packGLB(e.json, e.buffers);
2229
+ }
2230
+ exportGLTF(t = {}) {
2231
+ const e = this.buildGLTF(t);
2232
+ return {
2233
+ json: JSON.stringify(e.json, null, 2),
2234
+ bin: this.combineBuffers(e.buffers)
2235
+ };
2236
+ }
2237
+ buildGLTF(t) {
2238
+ const e = this.geometryResult.meshes, n = t.colorSource ?? "rendering", s = t.visibleOnly === !0, i = t.hiddenEntityIds ?? null, o = t.isolatedEntityIds ?? null, a = o !== null && o.size > 0, l = t.hiddenIfcTypes ?? null, d = (I)=>s ? !(l && I.ifcType && l.has(I.ifcType) || a && !o.has(I.expressId) || i && i.has(I.expressId)) : !0, u = (I)=>n === "shading" ? I.shadingColor ?? I.color : I.color, f = {
2239
+ asset: {
2240
+ version: "2.0",
2241
+ generator: "IFC-Lite"
2242
+ },
2243
+ scene: 0,
2244
+ scenes: [
2245
+ {
2246
+ nodes: []
2247
+ }
2248
+ ],
2249
+ nodes: [],
2250
+ meshes: [],
2251
+ accessors: [],
2252
+ bufferViews: [],
2253
+ buffers: [
2254
+ {
2255
+ byteLength: 0
2256
+ }
2257
+ ]
2258
+ };
2259
+ t.includeMetadata && (f.asset.extras = {
2260
+ meshCount: e.length,
2261
+ vertexCount: this.geometryResult.totalVertices,
2262
+ triangleCount: this.geometryResult.totalTriangles
2263
+ });
2264
+ const p = new Map, _ = [];
2265
+ function h(I) {
2266
+ const R = `${Math.round(I[0] * 100)},${Math.round(I[1] * 100)},${Math.round(I[2] * 100)},${Math.round(I[3] * 100)}`, S = p.get(R);
2267
+ if (S !== void 0) return S;
2268
+ const G = _.length;
2269
+ return _.push({
2270
+ pbrMetallicRoughness: {
2271
+ baseColorFactor: [
2272
+ I[0],
2273
+ I[1],
2274
+ I[2],
2275
+ I[3]
2276
+ ],
2277
+ metallicFactor: 0,
2278
+ roughnessFactor: 1
2279
+ },
2280
+ extensions: {
2281
+ KHR_materials_unlit: {}
2282
+ },
2283
+ ...I[3] < 1 ? {
2284
+ alphaMode: "BLEND"
2285
+ } : {}
2286
+ }), p.set(R, G), G;
2287
+ }
2288
+ const y = [];
2289
+ let m = 0, b = 0, w = 0;
2290
+ for(let I = 0; I < e.length; I++){
2291
+ const R = e[I];
2292
+ if (!d(R)) continue;
2293
+ const S = R.positions, G = R.normals, z = R.indices;
2294
+ if (!S.length || !G.length || !z.length || S.length % 3 !== 0 || G.length % 3 !== 0 || S.length !== G.length) continue;
2295
+ let k = S[0], H = S[1], Y = S[2], Q = S[0], K = S[1], at = S[2];
2296
+ for(let it = 3; it < S.length; it += 3){
2297
+ const lt = S[it], ct = S[it + 1], _t = S[it + 2];
2298
+ lt < k && (k = lt), lt > Q && (Q = lt), ct < H && (H = ct), ct > K && (K = ct), _t < Y && (Y = _t), _t > at && (at = _t);
2299
+ }
2300
+ const ht = u(R);
2301
+ y.push({
2302
+ meshIndex: I,
2303
+ posCount: S.length,
2304
+ normCount: G.length,
2305
+ idxCount: z.length,
2306
+ posByteOffset: m * 4,
2307
+ normByteOffset: b * 4,
2308
+ idxByteOffset: w * 4,
2309
+ bounds: {
2310
+ min: [
2311
+ k,
2312
+ H,
2313
+ Y
2314
+ ],
2315
+ max: [
2316
+ Q,
2317
+ K,
2318
+ at
2319
+ ]
2320
+ },
2321
+ materialIdx: ht ? h(ht) : void 0
2322
+ }), m += S.length, b += G.length, w += z.length;
2323
+ }
2324
+ if (m === 0 || b === 0 || w === 0) throw new Error("Cannot export GLB: no valid geometry data found");
2325
+ const v = new Float32Array(m), L = new Float32Array(b), j = new Uint32Array(w);
2326
+ let O = 0, U = 0, C = 0;
2327
+ const N = [];
2328
+ for (const I of y){
2329
+ const R = e[I.meshIndex];
2330
+ v.set(R.positions, O), L.set(R.normals, U), j.set(R.indices, C), O += I.posCount, U += I.normCount, C += I.idxCount;
2331
+ const S = f.accessors.length;
2332
+ f.accessors.push({
2333
+ bufferView: 0,
2334
+ byteOffset: I.posByteOffset,
2335
+ componentType: 5126,
2336
+ count: I.posCount / 3,
2337
+ type: "VEC3",
2338
+ min: I.bounds.min,
2339
+ max: I.bounds.max
2340
+ });
2341
+ const G = f.accessors.length;
2342
+ f.accessors.push({
2343
+ bufferView: 1,
2344
+ byteOffset: I.normByteOffset,
2345
+ componentType: 5126,
2346
+ count: I.normCount / 3,
2347
+ type: "VEC3"
2348
+ });
2349
+ const z = f.accessors.length;
2350
+ f.accessors.push({
2351
+ bufferView: 2,
2352
+ byteOffset: I.idxByteOffset,
2353
+ componentType: 5125,
2354
+ count: I.idxCount,
2355
+ type: "SCALAR"
2356
+ });
2357
+ const k = f.meshes.length;
2358
+ f.meshes.push({
2359
+ primitives: [
2360
+ {
2361
+ attributes: {
2362
+ POSITION: S,
2363
+ NORMAL: G
2364
+ },
2365
+ indices: z,
2366
+ ...I.materialIdx !== void 0 ? {
2367
+ material: I.materialIdx
2368
+ } : {}
2369
+ }
2370
+ ]
2371
+ });
2372
+ const H = f.nodes.length, Y = {
2373
+ mesh: k
2374
+ };
2375
+ t.includeMetadata && R.expressId !== void 0 && (Y.extras = R.modelIndex !== void 0 ? {
2376
+ expressId: R.expressId,
2377
+ modelIndex: R.modelIndex
2378
+ } : {
2379
+ expressId: R.expressId
2380
+ }), f.nodes.push(Y), N.push(H);
2381
+ }
2382
+ f.scenes[0].nodes = N, _.length > 0 && (f.materials = _, f.extensionsUsed = [
2383
+ "KHR_materials_unlit"
2384
+ ]);
2385
+ const F = v.buffer, E = L.buffer, g = j.buffer, T = F.byteLength + E.byteLength + g.byteLength;
2386
+ f.bufferViews.push({
2387
+ buffer: 0,
2388
+ byteOffset: 0,
2389
+ byteLength: F.byteLength,
2390
+ byteStride: 12,
2391
+ target: 34962
2392
+ }), f.bufferViews.push({
2393
+ buffer: 0,
2394
+ byteOffset: F.byteLength,
2395
+ byteLength: E.byteLength,
2396
+ byteStride: 12,
2397
+ target: 34962
2398
+ }), f.bufferViews.push({
2399
+ buffer: 0,
2400
+ byteOffset: F.byteLength + E.byteLength,
2401
+ byteLength: g.byteLength,
2402
+ target: 34963
2403
+ }), f.buffers[0].byteLength = T;
2404
+ for (const I of f.accessors){
2405
+ const R = f.bufferViews[I.bufferView];
2406
+ if (!R) throw new Error(`Accessor references invalid bufferView ${I.bufferView}`);
2407
+ let S = 0;
2408
+ if (I.componentType === 5126) S = 4;
2409
+ else if (I.componentType === 5125) S = 4;
2410
+ else if (I.componentType === 5123) S = 2;
2411
+ else if (I.componentType === 5120) S = 1;
2412
+ else throw new Error(`Unsupported component type: ${I.componentType}`);
2413
+ let G = 1;
2414
+ if (I.type === "VEC3") G = 3;
2415
+ else if (I.type === "VEC2") G = 2;
2416
+ else if (I.type === "SCALAR") G = 1;
2417
+ else throw new Error(`Unsupported accessor type: ${I.type}`);
2418
+ const z = I.count * G * S, k = (I.byteOffset || 0) + z;
2419
+ if (k > R.byteLength) throw new Error(`Accessor exceeds bufferView bounds: accessor byteOffset=${I.byteOffset || 0}, length=${z}, bufferView byteLength=${R.byteLength}, end=${k}`);
2420
+ }
2421
+ return {
2422
+ json: f,
2423
+ buffers: [
2424
+ new Uint8Array(F),
2425
+ new Uint8Array(E),
2426
+ new Uint8Array(g)
2427
+ ]
2428
+ };
2429
+ }
2430
+ combineBuffers(t) {
2431
+ const e = t.reduce((i, o)=>i + o.byteLength, 0), n = new Uint8Array(e);
2432
+ let s = 0;
2433
+ for (const i of t)n.set(i, s), s += i.byteLength;
2434
+ return n;
2435
+ }
2436
+ packGLB(t, e) {
2437
+ const n = JSON.stringify(t), s = new TextEncoder().encode(n), i = (4 - s.byteLength % 4) % 4, o = s.byteLength + i, a = this.combineBuffers(e), l = (4 - a.byteLength % 4) % 4, d = a.byteLength + l, u = 20 + o + 8 + d, f = new ArrayBuffer(u), p = new DataView(f), _ = new Uint8Array(f);
2438
+ let h = 0;
2439
+ p.setUint32(h, 1179937895, !0), h += 4, p.setUint32(h, 2, !0), h += 4, p.setUint32(h, u, !0), h += 4, p.setUint32(h, o, !0), h += 4, p.setUint32(h, 1313821514, !0), h += 4, _.set(s, h), h += s.byteLength;
2440
+ for(let y = 0; y < i; y++)_[h++] = 32;
2441
+ return p.setUint32(h, d, !0), h += 4, p.setUint32(h, 5130562, !0), h += 4, _.set(a, h), new Uint8Array(f);
2442
+ }
2443
+ };
2444
+ rs = class {
2445
+ store;
2446
+ constructor(t){
2447
+ this.store = t;
2448
+ }
2449
+ getPropertiesForEntity(t) {
2450
+ return this.store.onDemandPropertyMap && this.store.source?.length > 0 ? Ve(this.store, t) : this.store.properties?.getForEntity(t) ?? [];
2451
+ }
2452
+ getQuantitiesForEntity(t) {
2453
+ return this.store.onDemandQuantityMap && this.store.source?.length > 0 ? ze(this.store, t) : this.store.quantities?.getForEntity(t) ?? [];
2454
+ }
2455
+ exportEntities(t, e = {}) {
2456
+ const n = e.delimiter ?? ",", s = e.includeProperties ?? !1, i = e.flattenProperties ?? !1, o = [
2457
+ "expressId",
2458
+ "globalId",
2459
+ "name",
2460
+ "type",
2461
+ "description",
2462
+ "objectType",
2463
+ "hasGeometry"
2464
+ ], a = new Map;
2465
+ if (s && i) {
2466
+ const u = t ?? this.getAllEntityIds();
2467
+ for (const f of u){
2468
+ const p = this.getPropertiesForEntity(f);
2469
+ for (const _ of p){
2470
+ a.has(_.name) || a.set(_.name, new Set);
2471
+ for (const h of _.properties)a.get(_.name).add(h.name);
2472
+ }
2473
+ }
2474
+ for (const [f, p] of a)for (const _ of p)o.push(`${f}_${_}`);
2475
+ }
2476
+ const l = [
2477
+ this.joinRow(o.map((u)=>this.escapeValue(u)), n)
2478
+ ], d = t ?? this.getAllEntityIds();
2479
+ for (const u of d){
2480
+ const f = [
2481
+ this.escapeValue(u),
2482
+ this.escapeValue(this.store.entities.getGlobalId(u) || ""),
2483
+ this.escapeValue(this.store.entities.getName(u) || ""),
2484
+ this.escapeValue(this.store.entities.getTypeName(u) || ""),
2485
+ this.escapeValue(this.store.entities.getDescription(u) || ""),
2486
+ this.escapeValue(this.store.entities.getObjectType(u) || ""),
2487
+ this.escapeValue(this.store.entities.hasGeometry(u) ? "true" : "false")
2488
+ ];
2489
+ if (s && i) {
2490
+ const p = this.getPropertiesForEntity(u), _ = new Map;
2491
+ for (const h of p){
2492
+ const y = new Map;
2493
+ for (const m of h.properties)y.set(m.name, m.value);
2494
+ _.set(h.name, y);
2495
+ }
2496
+ for (const [h, y] of a)for (const m of y){
2497
+ const b = _.get(h)?.get(m) ?? "";
2498
+ f.push(this.escapeValue(b));
2499
+ }
2500
+ }
2501
+ l.push(this.joinRow(f, n));
2502
+ }
2503
+ return l.join(`
2504
+ `);
2505
+ }
2506
+ exportProperties(t, e = {}) {
2507
+ const n = e.delimiter ?? ",", s = [
2508
+ "entityId",
2509
+ "globalId",
2510
+ "entityName",
2511
+ "entityType",
2512
+ "psetName",
2513
+ "propName",
2514
+ "value",
2515
+ "type"
2516
+ ], i = [
2517
+ this.joinRow(s.map((a)=>this.escapeValue(a)), n)
2518
+ ], o = t ?? this.getAllEntityIds();
2519
+ for (const a of o){
2520
+ const l = this.getPropertiesForEntity(a);
2521
+ if (!l || l.length === 0) continue;
2522
+ const d = this.store.entities.getGlobalId(a) || "", u = this.store.entities.getName(a) || "", f = this.store.entities.getTypeName(a) || "";
2523
+ for (const p of l)if (!(!p.properties || p.properties.length === 0)) for (const _ of p.properties){
2524
+ const h = [
2525
+ this.escapeValue(a),
2526
+ this.escapeValue(d),
2527
+ this.escapeValue(u),
2528
+ this.escapeValue(f),
2529
+ this.escapeValue(p.name || ""),
2530
+ this.escapeValue(_.name || ""),
2531
+ this.escapeValue(_.value),
2532
+ this.escapeValue(_.type ?? "")
2533
+ ];
2534
+ i.push(this.joinRow(h, n));
2535
+ }
2536
+ }
2537
+ return i.join(`
2538
+ `);
2539
+ }
2540
+ exportQuantities(t, e = {}) {
2541
+ const n = e.delimiter ?? ",", s = [
2542
+ "entityId",
2543
+ "globalId",
2544
+ "entityName",
2545
+ "entityType",
2546
+ "qsetName",
2547
+ "quantityName",
2548
+ "value",
2549
+ "type"
2550
+ ], o = [
2551
+ this.joinRow(s.map((l)=>this.escapeValue(l)), n)
2552
+ ], a = t ?? this.getAllEntityIds();
2553
+ for (const l of a){
2554
+ const d = this.getQuantitiesForEntity(l);
2555
+ if (!d || d.length === 0) continue;
2556
+ const u = this.store.entities.getGlobalId(l) || "", f = this.store.entities.getName(l) || "", p = this.store.entities.getTypeName(l) || "";
2557
+ for (const _ of d)if (!(!_.quantities || _.quantities.length === 0)) for (const h of _.quantities){
2558
+ const y = [
2559
+ this.escapeValue(l),
2560
+ this.escapeValue(u),
2561
+ this.escapeValue(f),
2562
+ this.escapeValue(p),
2563
+ this.escapeValue(_.name || ""),
2564
+ this.escapeValue(h.name || ""),
2565
+ this.escapeValue(h.value),
2566
+ this.escapeValue(h.type ?? "")
2567
+ ];
2568
+ o.push(this.joinRow(y, n));
2569
+ }
2570
+ }
2571
+ return o.join(`
2572
+ `);
2573
+ }
2574
+ exportSpatialHierarchy(t = {}) {
2575
+ const e = t.delimiter ?? ",", n = [
2576
+ "expressId",
2577
+ "globalId",
2578
+ "name",
2579
+ "type",
2580
+ "parentId",
2581
+ "level"
2582
+ ], s = [
2583
+ this.joinRow(n.map((a)=>this.escapeValue(a)), e)
2584
+ ], i = this.store.spatialHierarchy;
2585
+ if (!i?.project) return s[0];
2586
+ const o = (a, l, d)=>{
2587
+ const u = [
2588
+ this.escapeValue(a.expressId),
2589
+ this.escapeValue(this.store.entities.getGlobalId(a.expressId) || ""),
2590
+ this.escapeValue(a.name || ""),
2591
+ this.escapeValue(this.store.entities.getTypeName(a.expressId) || ""),
2592
+ this.escapeValue(l ?? ""),
2593
+ this.escapeValue(d)
2594
+ ];
2595
+ if (s.push(this.joinRow(u, e)), a.children) for (const f of a.children)o(f, a.expressId, d + 1);
2596
+ };
2597
+ return o(i.project, null, 0), s.join(`
2598
+ `);
2599
+ }
2600
+ getAllEntityIds() {
2601
+ const t = [], e = this.store.entities?.count ?? 0;
2602
+ for(let n = 0; n < e; n++)t.push(this.store.entities.expressId[n]);
2603
+ return t;
2604
+ }
2605
+ escapeValue(t) {
2606
+ if (t == null) return "";
2607
+ const e = String(t);
2608
+ return e.includes(",") || e.includes('"') || e.includes(`
2609
+ `) || e.includes("\r") ? `"${e.replace(/"/g, '""')}"` : e;
2610
+ }
2611
+ joinRow(t, e) {
2612
+ return t.join(e);
2613
+ }
2614
+ };
2615
+ const Pn = 35, zt = 48, Fe = 57, Bn = new Set([
2616
+ "IFCOWNERHISTORY",
2617
+ "IFCAPPLICATION",
2618
+ "IFCPERSON",
2619
+ "IFCORGANIZATION",
2620
+ "IFCPERSONANDORGANIZATION",
2621
+ "IFCUNITASSIGNMENT",
2622
+ "IFCSIUNIT",
2623
+ "IFCDERIVEDUNIT",
2624
+ "IFCDERIVEDUNITELEMENT",
2625
+ "IFCCONVERSIONBASEDUNIT",
2626
+ "IFCMEASUREWITHUNIT",
2627
+ "IFCDIMENSIONALEXPONENTS",
2628
+ "IFCMONETARYUNIT",
2629
+ "IFCGEOMETRICREPRESENTATIONCONTEXT",
2630
+ "IFCGEOMETRICREPRESENTATIONSUBCONTEXT"
2631
+ ]), Un = new Set([
2632
+ "IFCPROJECT",
2633
+ "IFCSITE",
2634
+ "IFCBUILDING",
2635
+ "IFCBUILDINGSTOREY",
2636
+ "IFCBRIDGE",
2637
+ "IFCBRIDGEPART",
2638
+ "IFCFACILITY",
2639
+ "IFCFACILITYPART",
2640
+ "IFCFACILITYPARTCOMMON",
2641
+ "IFCMARINEFACILITY",
2642
+ "IFCMARINEPART",
2643
+ "IFCRAILWAY",
2644
+ "IFCRAILWAYPART",
2645
+ "IFCROAD",
2646
+ "IFCROADPART",
2647
+ "IFCSPATIALELEMENT",
2648
+ "IFCSPATIALSTRUCTUREELEMENT",
2649
+ "IFCSPATIALZONE",
2650
+ "IFCEXTERNALSPATIALELEMENT",
2651
+ "IFCEXTERNALSPATIALSTRUCTUREELEMENT"
2652
+ ]), Dn = new Set([
2653
+ "IFCBEAM",
2654
+ "IFCBEAMSTANDARDCASE",
2655
+ "IFCBUILDINGELEMENT",
2656
+ "IFCBUILDINGELEMENTPART",
2657
+ "IFCBUILDINGELEMENTPROXY",
2658
+ "IFCBUILTELEMENT",
2659
+ "IFCCHIMNEY",
2660
+ "IFCCOLUMN",
2661
+ "IFCCOLUMNSTANDARDCASE",
2662
+ "IFCCOVERING",
2663
+ "IFCCURTAINWALL",
2664
+ "IFCDEEPFOUNDATION",
2665
+ "IFCDOOR",
2666
+ "IFCDOORSTANDARDCASE",
2667
+ "IFCFOOTING",
2668
+ "IFCMEMBER",
2669
+ "IFCMEMBERSTANDARDCASE",
2670
+ "IFCPILE",
2671
+ "IFCPLATE",
2672
+ "IFCPLATESTANDARDCASE",
2673
+ "IFCRAILING",
2674
+ "IFCRAMP",
2675
+ "IFCRAMPFLIGHT",
2676
+ "IFCROOF",
2677
+ "IFCSHADINGDEVICE",
2678
+ "IFCSLAB",
2679
+ "IFCSLABELEMENTEDCASE",
2680
+ "IFCSLABSTANDARDCASE",
2681
+ "IFCSTAIR",
2682
+ "IFCSTAIRFLIGHT",
2683
+ "IFCWALL",
2684
+ "IFCWALLELEMENTEDCASE",
2685
+ "IFCWALLSTANDARDCASE",
2686
+ "IFCWINDOW",
2687
+ "IFCWINDOWSTANDARDCASE",
2688
+ "IFCDISTRIBUTIONELEMENT",
2689
+ "IFCDISTRIBUTIONCONTROLELEMENT",
2690
+ "IFCDISTRIBUTIONFLOWELEMENT",
2691
+ "IFCDISTRIBUTIONCHAMBERELEMENT",
2692
+ "IFCDISTRIBUTIONPORT",
2693
+ "IFCDISTRIBUTIONBOARD",
2694
+ "IFCACTUATOR",
2695
+ "IFCALARM",
2696
+ "IFCCONTROLLER",
2697
+ "IFCFLOWINSTRUMENT",
2698
+ "IFCPROTECTIVEDEVICETRIPPINGUNIT",
2699
+ "IFCSENSOR",
2700
+ "IFCUNITARYCONTROLELEMENT",
2701
+ "IFCAIRTERMINALBOX",
2702
+ "IFCDAMPER",
2703
+ "IFCELECTRICDISTRIBUTIONBOARD",
2704
+ "IFCELECTRICTIMECONTROL",
2705
+ "IFCFLOWCONTROLLER",
2706
+ "IFCFLOWMETER",
2707
+ "IFCPROTECTIVEDEVICE",
2708
+ "IFCSWITCHINGDEVICE",
2709
+ "IFCVALVE",
2710
+ "IFCCABLECARRIERFITTING",
2711
+ "IFCCABLEFITTING",
2712
+ "IFCDUCTFITTING",
2713
+ "IFCFLOWFITTING",
2714
+ "IFCJUNCTIONBOX",
2715
+ "IFCPIPEFITTING",
2716
+ "IFCCOMPRESSOR",
2717
+ "IFCFAN",
2718
+ "IFCFLOWMOVINGDEVICE",
2719
+ "IFCPUMP",
2720
+ "IFCCABLECARRIERSEGMENT",
2721
+ "IFCCABLESEGMENT",
2722
+ "IFCCONVEYORSEGMENT",
2723
+ "IFCDUCTSEGMENT",
2724
+ "IFCFLOWSEGMENT",
2725
+ "IFCPIPESEGMENT",
2726
+ "IFCELECTRICFLOWSTORAGEDEVICE",
2727
+ "IFCFLOWSTORAGEDEVICE",
2728
+ "IFCTANK",
2729
+ "IFCAIRTERMINAL",
2730
+ "IFCAUDIOVISUALAPPLIANCE",
2731
+ "IFCCOMMUNICATIONSAPPLIANCE",
2732
+ "IFCELECTRICAPPLIANCE",
2733
+ "IFCFIRESUPPRESSIONTERMINAL",
2734
+ "IFCFLOWTERMINAL",
2735
+ "IFCLAMP",
2736
+ "IFCLIGHTFIXTURE",
2737
+ "IFCLIQUIDTERMINAL",
2738
+ "IFCMEDICALDEVICE",
2739
+ "IFCMOBILETELECOMMUNICATIONSAPPLIANCE",
2740
+ "IFCOUTLET",
2741
+ "IFCSANITARYTERMINAL",
2742
+ "IFCSPACEHEATER",
2743
+ "IFCSTACKTERMINAL",
2744
+ "IFCWASTETERMINAL",
2745
+ "IFCDUCTSILENCER",
2746
+ "IFCELECTRICFLOWTREATMENTDEVICE",
2747
+ "IFCFILTER",
2748
+ "IFCFLOWTREATMENTDEVICE",
2749
+ "IFCINTERCEPTOR",
2750
+ "IFCAIRTOAIRHEATRECOVERY",
2751
+ "IFCBOILER",
2752
+ "IFCBURNER",
2753
+ "IFCCHILLER",
2754
+ "IFCCOIL",
2755
+ "IFCCONDENSER",
2756
+ "IFCCOOLEDBEAM",
2757
+ "IFCCOOLINGTOWER",
2758
+ "IFCELECTRICGENERATOR",
2759
+ "IFCELECTRICMOTOR",
2760
+ "IFCENERGYCONVERSIONDEVICE",
2761
+ "IFCENGINE",
2762
+ "IFCEVAPORATIVECOOLER",
2763
+ "IFCEVAPORATOR",
2764
+ "IFCHEATEXCHANGER",
2765
+ "IFCHUMIDIFIER",
2766
+ "IFCMOTORCONNECTION",
2767
+ "IFCSOLARDEVICE",
2768
+ "IFCTRANSFORMER",
2769
+ "IFCTUBEBUNDLE",
2770
+ "IFCUNITARYEQUIPMENT",
2771
+ "IFCELEMENT",
2772
+ "IFCELEMENTASSEMBLY",
2773
+ "IFCELEMENTCOMPONENT",
2774
+ "IFCFASTENER",
2775
+ "IFCMECHANICALFASTENER",
2776
+ "IFCDISCRETEACCESSORY",
2777
+ "IFCVIBRATIONDAMPER",
2778
+ "IFCVIBRATIONISOLATOR",
2779
+ "IFCIMPACTPROTECTIONDEVICE",
2780
+ "IFCFEATUREELEMENT",
2781
+ "IFCFEATUREELEMENTADDITION",
2782
+ "IFCFEATUREELEMENTSUBTRACTION",
2783
+ "IFCOPENINGELEMENT",
2784
+ "IFCOPENINGSTANDARDCASE",
2785
+ "IFCPROJECTIONELEMENT",
2786
+ "IFCSURFACEFEATURE",
2787
+ "IFCVOIDINGFEATURE",
2788
+ "IFCFURNISHINGELEMENT",
2789
+ "IFCFURNITURE",
2790
+ "IFCSYSTEMFURNITUREELEMENT",
2791
+ "IFCGEOGRAPHICELEMENT",
2792
+ "IFCCIVILELEMENT",
2793
+ "IFCTRANSPORTELEMENT",
2794
+ "IFCTRANSPORTATIONDEVICE",
2795
+ "IFCVEHICLE",
2796
+ "IFCREINFORCINGELEMENT",
2797
+ "IFCREINFORCINGBAR",
2798
+ "IFCREINFORCINGMESH",
2799
+ "IFCTENDON",
2800
+ "IFCTENDONANCHOR",
2801
+ "IFCTENDONCONDUIT",
2802
+ "IFCBEARING",
2803
+ "IFCCAISSONFOUNDATION",
2804
+ "IFCCOURSE",
2805
+ "IFCEARTHWORKSCUT",
2806
+ "IFCEARTHWORKSELEMENT",
2807
+ "IFCEARTHWORKSFILL",
2808
+ "IFCKERB",
2809
+ "IFCMOORINGDEVICE",
2810
+ "IFCNAVIGATIONELEMENT",
2811
+ "IFCPAVEMENT",
2812
+ "IFCRAIL",
2813
+ "IFCREINFORCEDSOIL",
2814
+ "IFCSIGN",
2815
+ "IFCSIGNAL",
2816
+ "IFCTRACKELEMENT",
2817
+ "IFCALIGNMENT",
2818
+ "IFCALIGNMENTCANT",
2819
+ "IFCALIGNMENTHORIZONTAL",
2820
+ "IFCALIGNMENTSEGMENT",
2821
+ "IFCALIGNMENTVERTICAL",
2822
+ "IFCLINEARELEMENT",
2823
+ "IFCLINEARPOSITIONINGELEMENT",
2824
+ "IFCPOSITIONINGELEMENT",
2825
+ "IFCREFERENT",
2826
+ "IFCBOREHOLE",
2827
+ "IFCGEOMODEL",
2828
+ "IFCGEOSLICE",
2829
+ "IFCGEOTECHNICALASSEMBLY",
2830
+ "IFCGEOTECHNICALELEMENT",
2831
+ "IFCGEOTECHNICALSTRATUM",
2832
+ "IFCANNOTATION",
2833
+ "IFCGRID",
2834
+ "IFCPORT",
2835
+ "IFCPROXY",
2836
+ "IFCSPACE",
2837
+ "IFCVIRTUALELEMENT",
2838
+ "IFCSTRUCTURALACTION",
2839
+ "IFCSTRUCTURALACTIVITY",
2840
+ "IFCSTRUCTURALCONNECTION",
2841
+ "IFCSTRUCTURALCURVEACTION",
2842
+ "IFCSTRUCTURALCURVECONNECTION",
2843
+ "IFCSTRUCTURALCURVEMEMBER",
2844
+ "IFCSTRUCTURALCURVEMEMBERVARYING",
2845
+ "IFCSTRUCTURALCURVEREACTION",
2846
+ "IFCSTRUCTURALITEM",
2847
+ "IFCSTRUCTURALLINEARACTION",
2848
+ "IFCSTRUCTURALMEMBER",
2849
+ "IFCSTRUCTURALPLANARACTION",
2850
+ "IFCSTRUCTURALPOINTACTION",
2851
+ "IFCSTRUCTURALPOINTCONNECTION",
2852
+ "IFCSTRUCTURALPOINTREACTION",
2853
+ "IFCSTRUCTURALREACTION",
2854
+ "IFCSTRUCTURALSURFACEACTION",
2855
+ "IFCSTRUCTURALSURFACECONNECTION",
2856
+ "IFCSTRUCTURALSURFACEMEMBER",
2857
+ "IFCSTRUCTURALSURFACEMEMBERVARYING",
2858
+ "IFCSTRUCTURALSURFACEREACTION"
2859
+ ]);
2860
+ function Wt(r, t, e, n) {
2861
+ const s = t + e;
2862
+ let i = t;
2863
+ for(; i < s;)if (r[i] === Pn) {
2864
+ if (i++, i < s && r[i] >= zt && r[i] <= Fe) {
2865
+ let o = r[i] - zt;
2866
+ for(i++; i < s && r[i] >= zt && r[i] <= Fe;)o = o * 10 + (r[i] - zt), i++;
2867
+ n.push(o);
2868
+ }
2869
+ } else i++;
2870
+ }
2871
+ function re(r, t, e, n) {
2872
+ const s = new Set, i = [];
2873
+ for (const a of r)e.has(a) && !s.has(a) && (s.add(a), i.push(a));
2874
+ const o = [];
2875
+ for(; i.length > 0;){
2876
+ const a = i.pop(), l = e.get(a);
2877
+ if (l) {
2878
+ o.length = 0, Wt(t, l.byteOffset, l.byteLength, o);
2879
+ for(let d = 0; d < o.length; d++){
2880
+ const u = o[d];
2881
+ if (!s.has(u) && e.has(u)) {
2882
+ if (n && n.has(u)) continue;
2883
+ s.add(u), i.push(u);
2884
+ }
2885
+ }
2886
+ }
2887
+ }
2888
+ return s;
2889
+ }
2890
+ function oe(r, t, e) {
2891
+ const n = new Set, s = new Set;
2892
+ for (const [i, o] of r.entityIndex.byId){
2893
+ const a = o.type.toUpperCase();
2894
+ if (Bn.has(a)) {
2895
+ n.add(i);
2896
+ continue;
2897
+ }
2898
+ if (Un.has(a)) {
2899
+ n.add(i);
2900
+ continue;
2901
+ }
2902
+ if (a.startsWith("IFCREL")) {
2903
+ n.add(i);
2904
+ continue;
2905
+ }
2906
+ if (Dn.has(a)) {
2907
+ const l = t.has(i), d = e !== null && !e.has(i);
2908
+ l || d ? s.add(i) : n.add(i);
2909
+ continue;
2910
+ }
2911
+ if (t.has(i)) {
2912
+ s.add(i);
2913
+ continue;
2914
+ }
2915
+ if (e !== null && e.has(i)) {
2916
+ n.add(i);
2917
+ continue;
2918
+ }
2919
+ }
2920
+ return vn(r, n, s), {
2921
+ roots: n,
2922
+ hiddenProductIds: s
2923
+ };
2924
+ }
2925
+ function vn(r, t, e) {
2926
+ const n = r.source;
2927
+ if (!n) return;
2928
+ const s = r.entityIndex.byType.get("IFCRELVOIDSELEMENT") ?? [];
2929
+ if (s.length === 0) return;
2930
+ const i = [];
2931
+ for (const o of s){
2932
+ const a = r.entityIndex.byId.get(o);
2933
+ if (!a) continue;
2934
+ let l = a.byteOffset;
2935
+ const d = a.byteOffset + a.byteLength;
2936
+ for(; l < d && n[l] !== 40;)l++;
2937
+ if (l >= d || (i.length = 0, Wt(n, l, d - l, i), i.length < 2)) continue;
2938
+ const u = i[i.length - 2], f = i[i.length - 1];
2939
+ e.has(u) && (e.add(f), t.delete(o), t.delete(f));
2940
+ }
2941
+ }
2942
+ function ae(r, t, e) {
2943
+ const n = [], s = [], i = e.byType.get("IFCSTYLEDITEM") ?? [], o = e.byType.get("IFCSTYLEDREPRESENTATION") ?? [];
2944
+ for (const a of [
2945
+ i,
2946
+ o
2947
+ ])for (const l of a){
2948
+ if (r.has(l)) continue;
2949
+ const d = e.byId.get(l);
2950
+ if (!d) continue;
2951
+ s.length = 0, Wt(t, d.byteOffset, d.byteLength, s);
2952
+ let u = !1;
2953
+ for(let f = 0; f < s.length; f++)if (r.has(s[f])) {
2954
+ u = !0;
2955
+ break;
2956
+ }
2957
+ u && (r.add(l), n.push(l));
2958
+ }
2959
+ for(; n.length > 0;){
2960
+ const a = n.pop(), l = e.byId.get(a);
2961
+ if (l) {
2962
+ s.length = 0, Wt(t, l.byteOffset, l.byteLength, s);
2963
+ for(let d = 0; d < s.length; d++){
2964
+ const u = s[d];
2965
+ !r.has(u) && e.byId.has(u) && (r.add(u), n.push(u));
2966
+ }
2967
+ }
2968
+ }
2969
+ }
2970
+ const Re = new Map([
2971
+ [
2972
+ "IFCELECTRICDISTRIBUTIONPOINT",
2973
+ "IFCELECTRICDISTRIBUTIONBOARD"
2974
+ ],
2975
+ [
2976
+ "IFCGASTERMINALTYPE",
2977
+ "IFCBURNERTYPE"
2978
+ ],
2979
+ [
2980
+ "IFCEQUIPMENTELEMENT",
2981
+ "IFCBUILDINGELEMENTPROXY"
2982
+ ]
2983
+ ]), Ne = new Map([
2984
+ [
2985
+ "IFCELECTRICDISTRIBUTIONBOARD",
2986
+ "IFCELECTRICDISTRIBUTIONPOINT"
2987
+ ],
2988
+ [
2989
+ "IFCBURNERTYPE",
2990
+ "IFCGASTERMINALTYPE"
2991
+ ],
2992
+ [
2993
+ "IFCCHIMNEY",
2994
+ "IFCBUILDINGELEMENTPROXY"
2995
+ ],
2996
+ [
2997
+ "IFCSHADINGDEVICE",
2998
+ "IFCBUILDINGELEMENTPROXY"
2999
+ ],
3000
+ [
3001
+ "IFCCIVILELEMENT",
3002
+ "IFCBUILDINGELEMENTPROXY"
3003
+ ],
3004
+ [
3005
+ "IFCGEOGRAPHICELEMENT",
3006
+ "IFCBUILDINGELEMENTPROXY"
3007
+ ],
3008
+ [
3009
+ "IFCBEARING",
3010
+ "IFCBUILDINGELEMENTPROXY"
3011
+ ],
3012
+ [
3013
+ "IFCDEEPFOUNDATION",
3014
+ "IFCFOOTING"
3015
+ ],
3016
+ [
3017
+ "IFCCOURSE",
3018
+ "IFCBUILDINGELEMENTPROXY"
3019
+ ],
3020
+ [
3021
+ "IFCPAVEMENT",
3022
+ "IFCSLAB"
3023
+ ],
3024
+ [
3025
+ "IFCKERB",
3026
+ "IFCBUILDINGELEMENTPROXY"
3027
+ ],
3028
+ [
3029
+ "IFCFACILITY",
3030
+ "IFCBUILDING"
3031
+ ],
3032
+ [
3033
+ "IFCFACILITYPART",
3034
+ "IFCBUILDINGSTOREY"
3035
+ ],
3036
+ [
3037
+ "IFCFACILITYPARTCOMMON",
3038
+ "IFCBUILDINGSTOREY"
3039
+ ],
3040
+ [
3041
+ "IFCBRIDGE",
3042
+ "IFCBUILDING"
3043
+ ],
3044
+ [
3045
+ "IFCBRIDGEPART",
3046
+ "IFCBUILDINGSTOREY"
3047
+ ],
3048
+ [
3049
+ "IFCROAD",
3050
+ "IFCBUILDING"
3051
+ ],
3052
+ [
3053
+ "IFCROADPART",
3054
+ "IFCBUILDINGSTOREY"
3055
+ ],
3056
+ [
3057
+ "IFCRAILWAY",
3058
+ "IFCBUILDING"
3059
+ ],
3060
+ [
3061
+ "IFCRAILWAYPART",
3062
+ "IFCBUILDINGSTOREY"
3063
+ ],
3064
+ [
3065
+ "IFCMARINEFACILITY",
3066
+ "IFCBUILDING"
3067
+ ],
3068
+ [
3069
+ "IFCMARINEPART",
3070
+ "IFCBUILDINGSTOREY"
3071
+ ],
3072
+ [
3073
+ "IFCBUILTELEMENT",
3074
+ "IFCBUILDINGELEMENTPROXY"
3075
+ ]
3076
+ ]), Jt = new Map([]), Kt = new Map([
3077
+ [
3078
+ "IFCFACILITY",
3079
+ "IFCBUILDING"
3080
+ ],
3081
+ [
3082
+ "IFCFACILITYPART",
3083
+ "IFCBUILDINGSTOREY"
3084
+ ],
3085
+ [
3086
+ "IFCFACILITYPARTCOMMON",
3087
+ "IFCBUILDINGSTOREY"
3088
+ ],
3089
+ [
3090
+ "IFCBRIDGE",
3091
+ "IFCBUILDING"
3092
+ ],
3093
+ [
3094
+ "IFCBRIDGEPART",
3095
+ "IFCBUILDINGSTOREY"
3096
+ ],
3097
+ [
3098
+ "IFCROAD",
3099
+ "IFCBUILDING"
3100
+ ],
3101
+ [
3102
+ "IFCROADPART",
3103
+ "IFCBUILDINGSTOREY"
3104
+ ],
3105
+ [
3106
+ "IFCRAILWAY",
3107
+ "IFCBUILDING"
3108
+ ],
3109
+ [
3110
+ "IFCRAILWAYPART",
3111
+ "IFCBUILDINGSTOREY"
3112
+ ],
3113
+ [
3114
+ "IFCMARINEFACILITY",
3115
+ "IFCBUILDING"
3116
+ ],
3117
+ [
3118
+ "IFCMARINEPART",
3119
+ "IFCBUILDINGSTOREY"
3120
+ ],
3121
+ [
3122
+ "IFCBUILTELEMENT",
3123
+ "IFCBUILDINGELEMENTPROXY"
3124
+ ],
3125
+ [
3126
+ "IFCEARTHWORKSCUT",
3127
+ "IFCBUILDINGELEMENTPROXY"
3128
+ ],
3129
+ [
3130
+ "IFCEARTHWORKSELEMENT",
3131
+ "IFCBUILDINGELEMENTPROXY"
3132
+ ],
3133
+ [
3134
+ "IFCEARTHWORKSFILL",
3135
+ "IFCBUILDINGELEMENTPROXY"
3136
+ ],
3137
+ [
3138
+ "IFCCAISSONFOUNDATION",
3139
+ "IFCFOOTING"
3140
+ ],
3141
+ [
3142
+ "IFCNAVIGATIONELEMENT",
3143
+ "IFCBUILDINGELEMENTPROXY"
3144
+ ],
3145
+ [
3146
+ "IFCMOORINGDEVICE",
3147
+ "IFCBUILDINGELEMENTPROXY"
3148
+ ],
3149
+ [
3150
+ "IFCPAVEMENT",
3151
+ "IFCSLAB"
3152
+ ],
3153
+ [
3154
+ "IFCRAIL",
3155
+ "IFCBUILDINGELEMENTPROXY"
3156
+ ],
3157
+ [
3158
+ "IFCREINFORCEDSOIL",
3159
+ "IFCBUILDINGELEMENTPROXY"
3160
+ ],
3161
+ [
3162
+ "IFCSIGN",
3163
+ "IFCBUILDINGELEMENTPROXY"
3164
+ ],
3165
+ [
3166
+ "IFCSIGNAL",
3167
+ "IFCBUILDINGELEMENTPROXY"
3168
+ ],
3169
+ [
3170
+ "IFCTRACKELEMENT",
3171
+ "IFCBUILDINGELEMENTPROXY"
3172
+ ],
3173
+ [
3174
+ "IFCKERB",
3175
+ "IFCBUILDINGELEMENTPROXY"
3176
+ ],
3177
+ [
3178
+ "IFCCOURSE",
3179
+ "IFCBUILDINGELEMENTPROXY"
3180
+ ],
3181
+ [
3182
+ "IFCLINEARPOSITIONINGELEMENT",
3183
+ "IFCPROXY"
3184
+ ],
3185
+ [
3186
+ "IFCPOSITIONINGELEMENT",
3187
+ "IFCPROXY"
3188
+ ],
3189
+ [
3190
+ "IFCREFERENT",
3191
+ "IFCPROXY"
3192
+ ],
3193
+ [
3194
+ "IFCALIGNMENT",
3195
+ "IFCPROXY"
3196
+ ],
3197
+ [
3198
+ "IFCLINEARELEMENT",
3199
+ "IFCPROXY"
3200
+ ],
3201
+ [
3202
+ "IFCCONVEYORSEGMENT",
3203
+ "IFCFLOWSEGMENT"
3204
+ ],
3205
+ [
3206
+ "IFCLIQUIDTERMINAL",
3207
+ "IFCFLOWTERMINAL"
3208
+ ],
3209
+ [
3210
+ "IFCMOBILETELECOMMUNICATIONSAPPLIANCE",
3211
+ "IFCCOMMUNICATIONSAPPLIANCE"
3212
+ ],
3213
+ [
3214
+ "IFCDISTRIBUTIONBOARD",
3215
+ "IFCELECTRICDISTRIBUTIONBOARD"
3216
+ ],
3217
+ [
3218
+ "IFCELECTRICFLOWTREATMENTDEVICE",
3219
+ "IFCFLOWTREATMENTDEVICE"
3220
+ ]
3221
+ ]), Gn = new Map([
3222
+ [
3223
+ "IFCWALL",
3224
+ 8
3225
+ ],
3226
+ [
3227
+ "IFCBEAM",
3228
+ 8
3229
+ ],
3230
+ [
3231
+ "IFCCOLUMN",
3232
+ 8
3233
+ ],
3234
+ [
3235
+ "IFCROOF",
3236
+ 9
3237
+ ],
3238
+ [
3239
+ "IFCSTAIR",
3240
+ 9
3241
+ ],
3242
+ [
3243
+ "IFCRAMP",
3244
+ 9
3245
+ ],
3246
+ [
3247
+ "IFCRAILING",
3248
+ 9
3249
+ ],
3250
+ [
3251
+ "IFCMEMBER",
3252
+ 8
3253
+ ],
3254
+ [
3255
+ "IFCPLATE",
3256
+ 8
3257
+ ],
3258
+ [
3259
+ "IFCFOOTING",
3260
+ 9
3261
+ ],
3262
+ [
3263
+ "IFCPILE",
3264
+ 11
3265
+ ],
3266
+ [
3267
+ "IFCCOVERING",
3268
+ 9
3269
+ ],
3270
+ [
3271
+ "IFCOPENINGELEMENT",
3272
+ 8
3273
+ ],
3274
+ [
3275
+ "IFCDOOR",
3276
+ 10
3277
+ ],
3278
+ [
3279
+ "IFCWINDOW",
3280
+ 10
3281
+ ],
3282
+ [
3283
+ "IFCFURNISHINGELEMENT",
3284
+ 8
3285
+ ],
3286
+ [
3287
+ "IFCBUILDINGELEMENTPROXY",
3288
+ 9
3289
+ ],
3290
+ [
3291
+ "IFCCURTAINWALL",
3292
+ 8
3293
+ ],
3294
+ [
3295
+ "IFCFLOWSEGMENT",
3296
+ 8
3297
+ ],
3298
+ [
3299
+ "IFCFLOWTERMINAL",
3300
+ 8
3301
+ ],
3302
+ [
3303
+ "IFCFLOWCONTROLLER",
3304
+ 8
3305
+ ],
3306
+ [
3307
+ "IFCFLOWFITTING",
3308
+ 8
3309
+ ],
3310
+ [
3311
+ "IFCFLOWMOVINGDEVICE",
3312
+ 8
3313
+ ],
3314
+ [
3315
+ "IFCFLOWSTORAGEDEVICE",
3316
+ 8
3317
+ ],
3318
+ [
3319
+ "IFCFLOWTREATMENTDEVICE",
3320
+ 8
3321
+ ],
3322
+ [
3323
+ "IFCENERGYCONVERSIONDEVICE",
3324
+ 8
3325
+ ],
3326
+ [
3327
+ "IFCDISTRIBUTIONELEMENT",
3328
+ 8
3329
+ ],
3330
+ [
3331
+ "IFCDISTRIBUTIONFLOWELEMENT",
3332
+ 8
3333
+ ],
3334
+ [
3335
+ "IFCDISTRIBUTIONCONTROLELEMENT",
3336
+ 8
3337
+ ],
3338
+ [
3339
+ "IFCDISTRIBUTIONCHAMBERELEMENT",
3340
+ 8
3341
+ ]
3342
+ ]);
3343
+ function De(r, t, e) {
3344
+ if (t === e) return r;
3345
+ const n = r.toUpperCase();
3346
+ return $n(t, e)?.get(n) ?? n;
3347
+ }
3348
+ function $n(r, t) {
3349
+ return r === "IFC2X3" && t === "IFC4" ? Re : r === "IFC4" && t === "IFC2X3" ? Ne : r === "IFC4" && t === "IFC4X3" ? Jt : r === "IFC4X3" && t === "IFC4" ? Kt : r === "IFC5" && t === "IFC4X3" || r === "IFC4X3" && t === "IFC5" ? null : r === "IFC5" && t === "IFC4" ? Kt : r === "IFC4" && t === "IFC5" ? Jt : r === "IFC2X3" && (t === "IFC4X3" || t === "IFC5") ? Se(Re, Jt) : (r === "IFC4X3" || r === "IFC5") && t === "IFC2X3" ? Se(Kt, Ne) : null;
3350
+ }
3351
+ function Se(r, t) {
3352
+ const e = new Map;
3353
+ for (const [n, s] of r)e.set(n, t.get(s) ?? s);
3354
+ for (const [n, s] of t)e.has(n) || e.set(n, s);
3355
+ return e;
3356
+ }
3357
+ function jt(r, t, e) {
3358
+ if (t === e) return r;
3359
+ const n = r.match(/^(#\d+=)(\w+)\((.*)?\);?\s*$/);
3360
+ if (!n) return r;
3361
+ const s = n[1], i = n[2].toUpperCase(), o = n[3] ?? "", a = De(i, t, e);
3362
+ if (Vn(a, e)) return `${s}IFCPROXY('${Yn()}',$,'${i}',$,$,$,$,.NOTDEFINED.,$);`;
3363
+ let l = o;
3364
+ if (e === "IFC2X3") {
3365
+ const d = Gn.get(a);
3366
+ d !== void 0 && (l = zn(o, d));
3367
+ }
3368
+ return `${s}${a}(${l});`;
3369
+ }
3370
+ function Vn(r, t) {
3371
+ return t === "IFC4X3" || t === "IFC5" ? !1 : new Set([
3372
+ "IFCALIGNMENTCANT",
3373
+ "IFCALIGNMENTHORIZONTAL",
3374
+ "IFCALIGNMENTVERTICAL",
3375
+ "IFCALIGNMENTSEGMENT"
3376
+ ]).has(r);
3377
+ }
3378
+ function zn(r, t) {
3379
+ if (!r.trim()) return r;
3380
+ const e = [];
3381
+ let n = 0, s = !1, i = "";
3382
+ for(let o = 0; o < r.length; o++){
3383
+ const a = r[o];
3384
+ if (a === "'" && !s) s = !0, i += a;
3385
+ else if (a === "'" && s) {
3386
+ if (o + 1 < r.length && r[o + 1] === "'") {
3387
+ i += "''", o++;
3388
+ continue;
3389
+ }
3390
+ s = !1, i += a;
3391
+ } else if (s) i += a;
3392
+ else if (a === "(") n++, i += a;
3393
+ else if (a === ")") n--, i += a;
3394
+ else if (a === "," && n === 0) {
3395
+ if (e.push(i), i = "", e.length >= t) return e.join(",");
3396
+ } else i += a;
3397
+ }
3398
+ return e.push(i), e.length > t ? e.slice(0, t).join(",") : e.join(",");
3399
+ }
3400
+ function ce(r, t) {
3401
+ return r !== t;
3402
+ }
3403
+ let kn = 0;
3404
+ function Yn() {
3405
+ const r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$", t = kn++;
3406
+ let e = "PROXY_", n = t;
3407
+ for(let s = 0; s < 16; s++)e += r[n % 64], n = Math.floor(n / 64) + s;
3408
+ return e;
3409
+ }
3410
+ function et(r) {
3411
+ return r.replace(/\\/g, "\\\\").replace(/'/g, "''");
3412
+ }
3413
+ function Z(r) {
3414
+ if (!Number.isFinite(r)) return "0.";
3415
+ const t = r.toString();
3416
+ return t.includes(".") ? t : t + ".";
3417
+ }
3418
+ function Wn(r) {
3419
+ switch(r){
3420
+ case Ct.Length:
3421
+ return "IFCQUANTITYLENGTH";
3422
+ case Ct.Area:
3423
+ return "IFCQUANTITYAREA";
3424
+ case Ct.Volume:
3425
+ return "IFCQUANTITYVOLUME";
3426
+ case Ct.Count:
3427
+ return "IFCQUANTITYCOUNT";
3428
+ case Ct.Weight:
3429
+ return "IFCQUANTITYWEIGHT";
3430
+ case Ct.Time:
3431
+ return "IFCQUANTITYTIME";
3432
+ default:
3433
+ return "IFCQUANTITYCOUNT";
3434
+ }
3435
+ }
3436
+ function ve(r, t) {
3437
+ if (r == null) return "$";
3438
+ switch(t){
3439
+ case tt.String:
3440
+ case tt.Label:
3441
+ case tt.Text:
3442
+ return `IFCLABEL('${et(String(r))}')`;
3443
+ case tt.Identifier:
3444
+ return `IFCIDENTIFIER('${et(String(r))}')`;
3445
+ case tt.Real:
3446
+ {
3447
+ const e = Number(r);
3448
+ return Number.isFinite(e) ? `IFCREAL(${e.toString().includes(".") ? e : e + "."})` : "$";
3449
+ }
3450
+ case tt.Integer:
3451
+ return `IFCINTEGER(${Math.round(Number(r))})`;
3452
+ case tt.Boolean:
3453
+ case tt.Logical:
3454
+ return r === !0 ? "IFCBOOLEAN(.T.)" : r === !1 ? "IFCBOOLEAN(.F.)" : "IFCLOGICAL(.U.)";
3455
+ case tt.Enum:
3456
+ return `.${String(r).toUpperCase()}.`;
3457
+ case tt.List:
3458
+ return Array.isArray(r) ? `(${r.map((n)=>ve(n, tt.String)).join(",")})` : "$";
3459
+ default:
3460
+ return `IFCLABEL('${et(String(r))}')`;
3461
+ }
3462
+ }
3463
+ function jn(r, t) {
3464
+ const e = r.trim(), n = t.trim();
3465
+ if (r === "") return "$";
3466
+ if (e === "$" || e === "*" || /^#\d+$/.test(e)) return e;
3467
+ if (/^\.[A-Z0-9_]+\.$/i.test(n) || /^\.[A-Z0-9_]+\.$/i.test(e)) return `.${e.replace(/^\./, "").replace(/\.$/, "").toUpperCase()}.`;
3468
+ if (/^(?:\.T\.|\.F\.|\.U\.)$/i.test(n)) {
3469
+ const s = e.toLowerCase();
3470
+ return s === "true" || s === ".t." ? ".T." : s === "false" || s === ".f." ? ".F." : ".U.";
3471
+ }
3472
+ if (/^-?\d+(?:\.\d+)?(?:E[+-]?\d+)?$/i.test(e) && /^-?\d/.test(n)) {
3473
+ const s = Number(e);
3474
+ return Number.isFinite(s) ? n.includes(".") || /E/i.test(n) ? Z(s) : String(s) : "$";
3475
+ }
3476
+ return Me(r);
3477
+ }
3478
+ function le(r) {
3479
+ if (r == null) return "$";
3480
+ if (typeof r == "boolean") return r ? ".T." : ".F.";
3481
+ if (typeof r == "number") return Number.isFinite(r) ? Number.isInteger(r) ? String(r) : Z(r) : "$";
3482
+ if (Array.isArray(r)) return `(${r.map(le).join(",")})`;
3483
+ const t = String(r).trim();
3484
+ return t === "$" || t === "*" || /^#\d+$/.test(t) ? t : /^\.[A-Z0-9_]+\.$/i.test(t) ? t.toUpperCase() : `'${et(String(r))}'`;
3485
+ }
3486
+ function Hn(r) {
3487
+ return r.map(le).join(",");
3488
+ }
3489
+ function Ae(r) {
3490
+ const t = [];
3491
+ let e = "", n = 0, s = !1;
3492
+ for(let i = 0; i < r.length; i++){
3493
+ const o = r[i];
3494
+ if (e += o, s) {
3495
+ o === "'" && (r[i + 1] === "'" ? (e += r[i + 1], i++) : s = !1);
3496
+ continue;
3497
+ }
3498
+ if (o === "'") {
3499
+ s = !0;
3500
+ continue;
3501
+ }
3502
+ if (o === "(") {
3503
+ n++;
3504
+ continue;
3505
+ }
3506
+ if (o === ")") {
3507
+ n--;
3508
+ continue;
3509
+ }
3510
+ o === "," && n === 0 && (t.push(e.slice(0, -1).trim()), e = "");
3511
+ }
3512
+ return e.trim() && t.push(e.trim()), t;
3513
+ }
3514
+ function Xn(r) {
3515
+ const t = [];
3516
+ let e = "", n = 0, s = !1;
3517
+ for(let i = 0; i < r.length; i++){
3518
+ const o = r[i];
3519
+ if (o === "'") {
3520
+ if (e += o, s && i + 1 < r.length && r[i + 1] === "'") {
3521
+ e += r[i + 1], i++;
3522
+ continue;
3523
+ }
3524
+ s = !s;
3525
+ continue;
3526
+ }
3527
+ if (!s) {
3528
+ if (o === "(") n++;
3529
+ else if (o === ")") n--;
3530
+ else if (o === "," && n === 0) {
3531
+ t.push(e), e = "";
3532
+ continue;
3533
+ }
3534
+ }
3535
+ e += o;
3536
+ }
3537
+ return t.push(e), t;
3538
+ }
3539
+ qn = class {
3540
+ dataStore;
3541
+ mutationView;
3542
+ nextExpressId;
3543
+ entityExtractor;
3544
+ constructor(t, e){
3545
+ this.dataStore = t, this.mutationView = e || null;
3546
+ const n = this.findMaxExpressId(), s = typeof e?.peekNextExpressId == "function" ? e.peekNextExpressId() - 1 : 0;
3547
+ this.nextExpressId = Math.max(n, s) + 1, this.entityExtractor = t.source ? new ke(t.source) : null;
3548
+ }
3549
+ export(t) {
3550
+ const e = [];
3551
+ let n = 0, s = 0;
3552
+ const i = t.schema || this.dataStore.schemaVersion || "IFC4", o = this.dataStore.schemaVersion || "IFC4", a = ce(o, i);
3553
+ if (i === "IFC2X3" && t.applyMutations !== !1 && t.georefMutations && (Object.keys(t.georefMutations.projectedCRS ?? {}).length > 0 || Object.keys(t.georefMutations.mapConversion ?? {}).length > 0)) throw new Error("Georeferencing creation and editing requires IFC4 or newer. IFC2X3 does not support IfcProjectedCRS or IfcMapConversion.");
3554
+ const l = ee({
3555
+ schema: i,
3556
+ description: t.description || "Exported from ifc-lite",
3557
+ author: t.author || "",
3558
+ organization: t.organization || "",
3559
+ application: t.application || "ifc-lite",
3560
+ filename: t.filename || "export.ifc"
3561
+ }), d = new Set, u = new Map, f = new Map, p = [], _ = [], h = new Map, y = new Map, m = new Set, b = new Map, w = new Set, v = new Set;
3562
+ if (this.mutationView && t.applyMutations !== !1) {
3563
+ const C = this.mutationView.getMutations(), N = new Map, F = new Map;
3564
+ for (const g of C){
3565
+ if (g.type === "UPDATE_ATTRIBUTE" && g.attributeName) {
3566
+ d.add(g.entityId), f.has(g.entityId) || f.set(g.entityId, new Map), f.get(g.entityId).set(g.attributeName, g.newValue == null ? "" : String(g.newValue));
3567
+ continue;
3568
+ }
3569
+ if (!g.psetName) continue;
3570
+ const I = g.type === "CREATE_QUANTITY" || g.type === "UPDATE_QUANTITY" || g.type === "DELETE_QUANTITY" ? F : N;
3571
+ I.has(g.entityId) || I.set(g.entityId, new Set), I.get(g.entityId).add(g.psetName);
3572
+ }
3573
+ const E = this.buildRelDefinesByPropertiesIndex();
3574
+ for (const [g, T] of N){
3575
+ d.add(g), u.set(g, T), s++;
3576
+ const R = this.mutationView.getForEntity(g).filter((z)=>T.has(z.name)), S = new Set;
3577
+ R.length > 0 && p.push({
3578
+ entityId: g,
3579
+ psets: R
3580
+ });
3581
+ const G = E.get(g);
3582
+ if (G) for (const { relId: z, psetId: k } of G){
3583
+ const H = this.getPropertySetName(k);
3584
+ if (H && S.add(H), H && T.has(H)) {
3585
+ v.add(z), w.add(k);
3586
+ const Y = this.getPropertyIdsInSet(k);
3587
+ for (const Q of Y)w.add(Q);
3588
+ }
3589
+ }
3590
+ if (this.isTypeEntity(g)) {
3591
+ const z = this.getTypeOwnedHasPropertySetIds(g), k = new Set;
3592
+ for (const H of z){
3593
+ const Y = this.getPropertySetName(H);
3594
+ if (!Y || !T.has(Y)) continue;
3595
+ k.add(Y), w.add(H);
3596
+ const Q = this.getPropertyIdsInSet(H);
3597
+ for (const K of Q)w.add(K);
3598
+ }
3599
+ for (const H of T)S.has(H) || k.add(H);
3600
+ k.size > 0 && (h.set(g, k), y.set(g, z), m.add(g));
3601
+ }
3602
+ }
3603
+ t.includeQuantities === !1 && F.clear();
3604
+ for (const [g, T] of F){
3605
+ d.add(g), u.has(g) || s++;
3606
+ const R = this.mutationView.getQuantitiesForEntity(g).filter((G)=>T.has(G.name));
3607
+ R.length > 0 && _.push({
3608
+ entityId: g,
3609
+ qsets: R
3610
+ });
3611
+ const S = E.get(g);
3612
+ if (S) for (const { relId: G, psetId: z } of S){
3613
+ const k = this.getElementQuantityName(z);
3614
+ if (k && T.has(k)) {
3615
+ v.add(G), w.add(z);
3616
+ const H = this.getPropertyIdsInSet(z);
3617
+ for (const Y of H)w.add(Y);
3618
+ }
3619
+ }
3620
+ }
3621
+ for (const [g] of f)!N.has(g) && !F.has(g) && s++;
3622
+ }
3623
+ const L = [];
3624
+ if (t.applyMutations !== !1 && t.georefMutations) {
3625
+ const C = t.georefMutations, N = this.dataStore.entityIndex.byType.get("IFCPROJECTEDCRS"), F = this.dataStore.entityIndex.byType.get("IFCMAPCONVERSION");
3626
+ if (C.projectedCRS && N?.length) {
3627
+ const E = N[0];
3628
+ f.has(E) || f.set(E, new Map);
3629
+ const g = f.get(E), T = C.projectedCRS;
3630
+ let I = !1;
3631
+ if (T.name !== void 0 && (g.set("Name", String(T.name)), I = !0), T.description !== void 0 && (g.set("Description", String(T.description)), I = !0), T.geodeticDatum !== void 0 && (g.set("GeodeticDatum", String(T.geodeticDatum)), I = !0), T.verticalDatum !== void 0 && (g.set("VerticalDatum", String(T.verticalDatum)), I = !0), T.mapProjection !== void 0 && (g.set("MapProjection", String(T.mapProjection)), I = !0), T.mapZone !== void 0 && (g.set("MapZone", String(T.mapZone)), I = !0), T.mapUnit !== void 0) {
3632
+ const R = this.resolveMapUnitReference(String(T.mapUnit), L);
3633
+ g.set("MapUnit", `#${R}`), I = !0;
3634
+ }
3635
+ I && !d.has(E) && (d.add(E), s++);
3636
+ }
3637
+ if (C.mapConversion && F?.length) {
3638
+ const E = F[0];
3639
+ f.has(E) || f.set(E, new Map);
3640
+ const g = f.get(E), T = C.mapConversion;
3641
+ let I = !1;
3642
+ T.eastings !== void 0 && (g.set("Eastings", String(T.eastings)), I = !0), T.northings !== void 0 && (g.set("Northings", String(T.northings)), I = !0), T.orthogonalHeight !== void 0 && (g.set("OrthogonalHeight", String(T.orthogonalHeight)), I = !0), T.xAxisAbscissa !== void 0 && (g.set("XAxisAbscissa", String(T.xAxisAbscissa)), I = !0), T.xAxisOrdinate !== void 0 && (g.set("XAxisOrdinate", String(T.xAxisOrdinate)), I = !0), T.scale !== void 0 && (g.set("Scale", String(T.scale)), I = !0), I && !d.has(E) && (d.add(E), s++);
3643
+ }
3644
+ if (C.projectedCRS && !N?.length) {
3645
+ const E = C.projectedCRS, g = this.nextExpressId++, T = E.name ? `'${et(String(E.name))}'` : "$", I = E.description ? `'${et(String(E.description))}'` : "$", R = E.geodeticDatum ? `'${et(String(E.geodeticDatum))}'` : "$", S = E.verticalDatum ? `'${et(String(E.verticalDatum))}'` : "$", G = E.mapProjection ? `'${et(String(E.mapProjection))}'` : "$", z = E.mapZone ? `'${et(String(E.mapZone))}'` : "$", k = E.mapUnit ? `#${this.resolveMapUnitReference(String(E.mapUnit), L)}` : "$";
3646
+ L.push(`#${g}=IFCPROJECTEDCRS(${T},${I},${R},${S},${G},${z},${k});`), n++;
3647
+ const H = this.findPreferredGeometricRepresentationContextId();
3648
+ if (H) {
3649
+ const Y = C.mapConversion || {}, Q = this.nextExpressId++, K = Z(Number(Y.eastings) || 0), at = Z(Number(Y.northings) || 0), ht = Z(Number(Y.orthogonalHeight) || 0), it = Y.xAxisAbscissa !== void 0 ? Z(Number(Y.xAxisAbscissa)) : "$", lt = Y.xAxisOrdinate !== void 0 ? Z(Number(Y.xAxisOrdinate)) : "$", ct = Y.scale !== void 0 ? Z(Number(Y.scale)) : "$";
3650
+ L.push(`#${Q}=IFCMAPCONVERSION(#${H},#${g},${K},${at},${ht},${it},${lt},${ct});`), n++;
3651
+ } else console.warn("[StepExporter] Cannot create IfcMapConversion: no IfcGeometricRepresentationContext found in source file");
3652
+ } else if (C.mapConversion && !F?.length && N?.length) {
3653
+ const E = this.findPreferredGeometricRepresentationContextId();
3654
+ if (E) {
3655
+ const g = C.mapConversion, T = this.nextExpressId++, I = Z(Number(g.eastings) || 0), R = Z(Number(g.northings) || 0), S = Z(Number(g.orthogonalHeight) || 0), G = g.xAxisAbscissa !== void 0 ? Z(Number(g.xAxisAbscissa)) : "$", z = g.xAxisOrdinate !== void 0 ? Z(Number(g.xAxisOrdinate)) : "$", k = g.scale !== void 0 ? Z(Number(g.scale)) : "$";
3656
+ L.push(`#${T}=IFCMAPCONVERSION(#${E},#${N[0]},${I},${R},${S},${G},${z},${k});`), n++;
3657
+ } else console.warn("[StepExporter] Cannot create IfcMapConversion: no IfcGeometricRepresentationContext found in source file");
3658
+ }
3659
+ }
3660
+ const j = this.mutationView && t.applyMutations !== !1 && typeof this.mutationView.getNewEntities == "function" ? this.mutationView.getNewEntities().length : 0;
3661
+ if (t.deltaOnly && d.size === 0 && j === 0 && L.length === 0) {
3662
+ const C = new TextEncoder().encode(l + `DATA;
3663
+ ENDSEC;
3664
+ END-ISO-10303-21;
3665
+ `);
3666
+ return {
3667
+ content: C,
3668
+ stats: {
3669
+ entityCount: 0,
3670
+ newEntityCount: 0,
3671
+ modifiedEntityCount: 0,
3672
+ fileSize: C.byteLength
3673
+ }
3674
+ };
3675
+ }
3676
+ let O = null;
3677
+ if (t.visibleOnly && this.dataStore.source) {
3678
+ const { roots: C, hiddenProductIds: N } = oe(this.dataStore, t.hiddenEntityIds ?? new Set, t.isolatedEntityIds ?? null);
3679
+ O = re(C, this.dataStore.source, this.dataStore.entityIndex.byId, N), ae(O, this.dataStore.source, this.dataStore.entityIndex);
3680
+ }
3681
+ if (!t.deltaOnly && this.dataStore.source) {
3682
+ const C = this.dataStore.source, N = !!this.mutationView && t.applyMutations !== !1;
3683
+ for (const [F, E] of this.dataStore.entityIndex.byId){
3684
+ if (N && typeof this.mutationView.isDeleted == "function" && this.mutationView.isDeleted(F) || E.byteLength === 0 || E.byteOffset < 0 || O !== null && !O.has(F) || w.has(F) || v.has(F) || m.has(F)) continue;
3685
+ const g = E.type.toUpperCase();
3686
+ if (t.includeGeometry === !1 && this.isGeometryEntity(g)) continue;
3687
+ const T = nt(C, E.byteOffset, E.byteOffset + E.byteLength);
3688
+ let I = f.has(F) ? this.applyAttributeMutations(T, g, f.get(F)) : T;
3689
+ const R = N && typeof this.mutationView.getPositionalMutationsForEntity == "function" ? this.mutationView.getPositionalMutationsForEntity(F) : null;
3690
+ if (R && R.size > 0 && (I = this.applyPositionalMutations(I, R), d.has(F) || (d.add(F), s++)), a) {
3691
+ const S = jt(I, o, i);
3692
+ S !== null && e.push(S);
3693
+ } else e.push(I);
3694
+ }
3695
+ }
3696
+ for (const { entityId: C, psets: N } of p){
3697
+ const F = this.generatePropertySetEntities(C, N, h.get(C));
3698
+ e.push(...F.lines), n += F.count;
3699
+ const E = h.get(C);
3700
+ if (E && E.size > 0) {
3701
+ const g = this.rewriteTypeEntityHasPropertySets(C, y.get(C) ?? [], E, F.generatedTypeOwnedPsetIds);
3702
+ g && b.set(C, g);
3703
+ }
3704
+ }
3705
+ for (const [C, N] of h){
3706
+ if (b.has(C)) continue;
3707
+ const F = this.rewriteTypeEntityHasPropertySets(C, y.get(C) ?? [], N, new Map);
3708
+ F && b.set(C, F);
3709
+ }
3710
+ for (const { entityId: C, qsets: N } of _){
3711
+ const F = this.generateQuantitySetEntities(C, N);
3712
+ e.push(...F.lines), n += F.count;
3713
+ }
3714
+ for (const C of b.values())e.push(C);
3715
+ for (const C of L)e.push(C);
3716
+ if (this.mutationView && t.applyMutations !== !1 && typeof this.mutationView.getNewEntities == "function") for (const C of this.mutationView.getNewEntities()){
3717
+ const N = C.type.toUpperCase();
3718
+ if (t.includeGeometry === !1 && this.isGeometryEntity(N) || O !== null && !O.has(C.expressId)) continue;
3719
+ const F = `#${C.expressId}=${N}(${Hn(C.attributes)});`;
3720
+ if (a) {
3721
+ const E = jt(F, o, i);
3722
+ E !== null && (e.push(E), n++);
3723
+ } else e.push(F), n++;
3724
+ }
3725
+ const U = Qn(l, e);
3726
+ return {
3727
+ content: U,
3728
+ stats: {
3729
+ entityCount: e.length,
3730
+ newEntityCount: n,
3731
+ modifiedEntityCount: s,
3732
+ fileSize: U.byteLength
3733
+ }
3734
+ };
3735
+ }
3736
+ async exportAsync(t) {
3737
+ const e = t.onProgress, n = this.dataStore.entityIndex.byId.size;
3738
+ e && e({
3739
+ phase: "preparing",
3740
+ percent: 0,
3741
+ entitiesProcessed: 0,
3742
+ entitiesTotal: n
3743
+ }), await new Promise((i)=>setTimeout(i, 0)), e && e({
3744
+ phase: "entities",
3745
+ percent: .1,
3746
+ entitiesProcessed: 0,
3747
+ entitiesTotal: n
3748
+ }), await new Promise((i)=>setTimeout(i, 0));
3749
+ const s = this.export(t);
3750
+ return e && e({
3751
+ phase: "assembling",
3752
+ percent: .95,
3753
+ entitiesProcessed: n,
3754
+ entitiesTotal: n
3755
+ }), await new Promise((i)=>setTimeout(i, 0)), s;
3756
+ }
3757
+ exportPropertiesOnly(t) {
3758
+ return this.export({
3759
+ ...t,
3760
+ includeGeometry: !1,
3761
+ deltaOnly: !0
3762
+ });
3763
+ }
3764
+ generatePropertySetEntities(t, e, n) {
3765
+ const s = [];
3766
+ let i = 0;
3767
+ const o = new Map;
3768
+ for (const a of e){
3769
+ const l = [];
3770
+ for (const _ of a.properties){
3771
+ const h = this.nextExpressId++;
3772
+ i++;
3773
+ const y = ve(_.value, _.type), m = _.unit ? this.findUnitId(_.unit) : null, b = m !== null ? je(m) : null, w = `#${h}=IFCPROPERTYSINGLEVALUE('${et(_.name)}',$,${y},${b ? Me(b) : "$"});`;
3774
+ s.push(w), l.push(h);
3775
+ }
3776
+ const d = this.nextExpressId++;
3777
+ i++;
3778
+ const u = l.map((_)=>`#${_}`).join(","), f = this.generateGlobalId(), p = `#${d}=IFCPROPERTYSET('${f}',$,'${et(a.name)}',$,(${u}));`;
3779
+ if (s.push(p), n?.has(a.name)) o.set(a.name, d);
3780
+ else {
3781
+ const _ = this.nextExpressId++;
3782
+ i++;
3783
+ const h = this.generateGlobalId(), y = `#${_}=IFCRELDEFINESBYPROPERTIES('${h}',$,$,$,(#${t}),#${d});`;
3784
+ s.push(y);
3785
+ }
3786
+ }
3787
+ return {
3788
+ lines: s,
3789
+ count: i,
3790
+ generatedTypeOwnedPsetIds: o
3791
+ };
3792
+ }
3793
+ generateQuantitySetEntities(t, e) {
3794
+ const n = [];
3795
+ let s = 0;
3796
+ for (const i of e){
3797
+ const o = [];
3798
+ for (const h of i.quantities){
3799
+ const y = this.nextExpressId++;
3800
+ s++;
3801
+ const m = Wn(h.type), b = Z(h.value), w = `#${y}=${m}('${et(h.name)}',$,$,${b},$);`;
3802
+ n.push(w), o.push(y);
3803
+ }
3804
+ const a = this.nextExpressId++;
3805
+ s++;
3806
+ const l = o.map((h)=>`#${h}`).join(","), d = this.generateGlobalId(), u = `#${a}=IFCELEMENTQUANTITY('${d}',$,'${et(i.name)}',$,$,(${l}));`;
3807
+ n.push(u);
3808
+ const f = this.nextExpressId++;
3809
+ s++;
3810
+ const p = this.generateGlobalId(), _ = `#${f}=IFCRELDEFINESBYPROPERTIES('${p}',$,$,$,(#${t}),#${a});`;
3811
+ n.push(_);
3812
+ }
3813
+ return {
3814
+ lines: n,
3815
+ count: s
3816
+ };
3817
+ }
3818
+ applyAttributeMutations(t, e, n) {
3819
+ const s = t.indexOf("("), i = t.lastIndexOf(");");
3820
+ if (s < 0 || i < s) return t;
3821
+ const o = Ye(e);
3822
+ if (o.length === 0) return t;
3823
+ const a = Ae(t.slice(s + 1, i));
3824
+ let l = !1;
3825
+ for (const [d, u] of n){
3826
+ const f = o.indexOf(d);
3827
+ f < 0 || f >= a.length || (a[f] = jn(u, a[f]), l = !0);
3828
+ }
3829
+ return l ? `${t.slice(0, s + 1)}${a.join(",")}${t.slice(i)}` : t;
3830
+ }
3831
+ applyPositionalMutations(t, e) {
3832
+ const n = t.indexOf("("), s = t.lastIndexOf(");");
3833
+ if (n < 0 || s < n) return t;
3834
+ const i = Ae(t.slice(n + 1, s));
3835
+ let o = !1;
3836
+ for (const [a, l] of e)a < 0 || a >= i.length || (i[a] = le(l), o = !0);
3837
+ return o ? `${t.slice(0, n + 1)}${i.join(",")}${t.slice(s)}` : t;
3838
+ }
3839
+ resolveMapUnitReference(t, e) {
3840
+ const n = this.normalizeMapUnitName(t), s = this.findLengthUnitReference(n);
3841
+ if (s !== null) return s;
3842
+ if (n === "METRE") {
3843
+ const o = this.nextExpressId++;
3844
+ return e.push(`#${o}=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);`), o;
3845
+ }
3846
+ if (n === "FOOT" || n === "US SURVEY FOOT") {
3847
+ const o = this.nextExpressId++, a = this.nextExpressId++, l = this.nextExpressId++, d = this.nextExpressId++, u = n === "US SURVEY FOOT" ? 1200 / 3937 : .3048, f = n === "US SURVEY FOOT" ? "US SURVEY FOOT" : "FOOT";
3848
+ return e.push(`#${o}=IFCDIMENSIONALEXPONENTS(1,0,0,0,0,0,0);`), e.push(`#${a}=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);`), e.push(`#${l}=IFCMEASUREWITHUNIT(IFCLENGTHMEASURE(${Z(u)}),#${a});`), e.push(`#${d}=IFCCONVERSIONBASEDUNIT(#${o},.LENGTHUNIT.,'${f}',#${l});`), d;
3849
+ }
3850
+ const i = this.nextExpressId++;
3851
+ return e.push(`#${i}=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);`), i;
3852
+ }
3853
+ normalizeMapUnitName(t) {
3854
+ const e = t.trim().toUpperCase().replace(/\s+/g, " ");
3855
+ return e.includes("US SURVEY FOOT") ? "US SURVEY FOOT" : e.includes("METER") || e.includes("METRE") ? "METRE" : e.includes("FOOT") || e.includes("FEET") ? "FOOT" : e;
3856
+ }
3857
+ findLengthUnitReference(t) {
3858
+ if (!this.entityExtractor) return null;
3859
+ const e = this.dataStore.entityIndex.byType.get("IFCPROJECT") ?? [], n = e[0] ? this.dataStore.entityIndex.byId.get(e[0]) : void 0, i = (n ? this.entityExtractor.extractEntity(n) : null)?.attributes?.[8];
3860
+ if (typeof i != "number") return null;
3861
+ const o = this.dataStore.entityIndex.byId.get(i), l = (o ? this.entityExtractor.extractEntity(o) : null)?.attributes?.[0];
3862
+ if (!Array.isArray(l)) return null;
3863
+ for (const d of l){
3864
+ if (typeof d != "number") continue;
3865
+ const u = this.dataStore.entityIndex.byId.get(d), f = u ? this.entityExtractor.extractEntity(u) : null;
3866
+ if (!f) continue;
3867
+ const p = f.type.toUpperCase(), _ = f.attributes ?? [];
3868
+ if ((typeof _[1] == "string" ? _[1].replace(/\./g, "").toUpperCase() : "") === "LENGTHUNIT") {
3869
+ if (p === "IFCSIUNIT") {
3870
+ const y = typeof _[2] == "string" ? _[2].replace(/\./g, "").toUpperCase() : "", m = typeof _[3] == "string" ? _[3].replace(/\./g, "").toUpperCase() : "", b = y ? `${y}${m}` : m;
3871
+ if (t === "METRE" && (b === "METRE" || b === "METER")) return d;
3872
+ }
3873
+ if (p === "IFCCONVERSIONBASEDUNIT" && (typeof _[2] == "string" ? this.normalizeMapUnitName(_[2]) : "") === t) return d;
3874
+ }
3875
+ }
3876
+ return null;
3877
+ }
3878
+ findPreferredGeometricRepresentationContextId() {
3879
+ if (!this.entityExtractor) return null;
3880
+ const t = this.dataStore.entityIndex.byType.get("IFCGEOMETRICREPRESENTATIONCONTEXT") ?? [];
3881
+ let e = null;
3882
+ for (const n of t){
3883
+ const s = this.dataStore.entityIndex.byId.get(n), i = s ? this.entityExtractor.extractEntity(s) : null;
3884
+ if (!i) continue;
3885
+ const o = i.attributes ?? [], a = typeof o[1] == "string" ? o[1].trim().toUpperCase() : "", l = typeof o[2] == "number" ? o[2] : null;
3886
+ if (l === 3 && e === null && (e = n), a === "MODEL" && l === 3) return n;
3887
+ }
3888
+ return e ?? t[0] ?? null;
3889
+ }
3890
+ generateGlobalId() {
3891
+ return We();
3892
+ }
3893
+ findMaxExpressId() {
3894
+ let t = 0;
3895
+ for (const [e] of this.dataStore.entityIndex.byId)e > t && (t = e);
3896
+ return t;
3897
+ }
3898
+ findUnitId(t) {
3899
+ return this.findLengthUnitReference(this.normalizeMapUnitName(t));
3900
+ }
3901
+ isGeometryEntity(t) {
3902
+ return new Set([
3903
+ "IFCCARTESIANPOINT",
3904
+ "IFCDIRECTION",
3905
+ "IFCAXIS2PLACEMENT2D",
3906
+ "IFCAXIS2PLACEMENT3D",
3907
+ "IFCLOCALPLACEMENT",
3908
+ "IFCSHAPEREPRESENTATION",
3909
+ "IFCPRODUCTDEFINITIONSHAPE",
3910
+ "IFCGEOMETRICREPRESENTATIONCONTEXT",
3911
+ "IFCGEOMETRICREPRESENTATIONSUBCONTEXT",
3912
+ "IFCEXTRUDEDAREASOLID",
3913
+ "IFCFACETEDBREP",
3914
+ "IFCPOLYLOOP",
3915
+ "IFCFACE",
3916
+ "IFCFACEOUTERBOUND",
3917
+ "IFCCLOSEDSHELL",
3918
+ "IFCRECTANGLEPROFILEDEF",
3919
+ "IFCCIRCLEPROFILEDEF",
3920
+ "IFCARBITRARYCLOSEDPROFILEDEF",
3921
+ "IFCPOLYLINE",
3922
+ "IFCTRIMMEDCURVE",
3923
+ "IFCBSPLINECURVE",
3924
+ "IFCBSPLINESURFACE",
3925
+ "IFCTRIANGULATEDFACESET",
3926
+ "IFCPOLYGONALFACE",
3927
+ "IFCINDEXEDPOLYGONALFACE",
3928
+ "IFCPOLYGONALFACESET",
3929
+ "IFCSTYLEDITEM",
3930
+ "IFCPRESENTATIONSTYLEASSIGNMENT",
3931
+ "IFCSURFACESTYLE",
3932
+ "IFCSURFACESTYLERENDERING",
3933
+ "IFCCOLOURRGB"
3934
+ ]).has(t);
3935
+ }
3936
+ buildRelDefinesByPropertiesIndex() {
3937
+ const t = new Map;
3938
+ for (const [e, n] of this.dataStore.entityIndex.byId){
3939
+ if (n.type.toUpperCase() !== "IFCRELDEFINESBYPROPERTIES") continue;
3940
+ const s = this.getRelatedPropertySet(e);
3941
+ if (s) for (const i of this.getRelatedEntities(e)){
3942
+ let o = t.get(i);
3943
+ o || (o = [], t.set(i, o)), o.push({
3944
+ relId: e,
3945
+ psetId: s
3946
+ });
3947
+ }
3948
+ }
3949
+ return t;
3950
+ }
3951
+ getRelatedEntities(t) {
3952
+ const e = this.dataStore.entityIndex.byId.get(t);
3953
+ if (!e || !this.dataStore.source) return [];
3954
+ const s = nt(this.dataStore.source, e.byteOffset, e.byteOffset + e.byteLength).match(/\(([^)]+)\)\s*,\s*#(\d+)\s*\)\s*;/);
3955
+ if (!s) return [];
3956
+ const i = s[1], o = [], a = i.matchAll(/#(\d+)/g);
3957
+ for (const l of a)o.push(parseInt(l[1], 10));
3958
+ return o;
3959
+ }
3960
+ getRelatedPropertySet(t) {
3961
+ const e = this.dataStore.entityIndex.byId.get(t);
3962
+ if (!e || !this.dataStore.source) return null;
3963
+ const s = nt(this.dataStore.source, e.byteOffset, e.byteOffset + e.byteLength).match(/,\s*#(\d+)\s*\)\s*;$/);
3964
+ return s ? parseInt(s[1], 10) : null;
3965
+ }
3966
+ getPropertySetName(t) {
3967
+ const e = this.dataStore.entityIndex.byId.get(t);
3968
+ if (!e || !this.dataStore.source) return null;
3969
+ const s = nt(this.dataStore.source, e.byteOffset, e.byteOffset + e.byteLength).match(/IFCPROPERTYSET\s*\([^,]*,[^,]*,'([^']*)'/i);
3970
+ return s ? s[1] : null;
3971
+ }
3972
+ getElementQuantityName(t) {
3973
+ const e = this.dataStore.entityIndex.byId.get(t);
3974
+ if (!e || !this.dataStore.source) return null;
3975
+ const s = nt(this.dataStore.source, e.byteOffset, e.byteOffset + e.byteLength).match(/IFCELEMENTQUANTITY\s*\([^,]*,[^,]*,'([^']*)'/i);
3976
+ return s ? s[1] : null;
3977
+ }
3978
+ getPropertyIdsInSet(t) {
3979
+ const e = this.dataStore.entityIndex.byId.get(t);
3980
+ if (!e || !this.dataStore.source) return [];
3981
+ const s = nt(this.dataStore.source, e.byteOffset, e.byteOffset + e.byteLength).match(/\(\s*(#[^)]+)\s*\)\s*\)\s*;$/);
3982
+ if (!s) return [];
3983
+ const i = s[1], o = [], a = i.matchAll(/#(\d+)/g);
3984
+ for (const l of a)o.push(parseInt(l[1], 10));
3985
+ return o;
3986
+ }
3987
+ isTypeEntity(t) {
3988
+ return this.dataStore.entityIndex.byId.get(t)?.type.toUpperCase().endsWith("TYPE") ?? !1;
3989
+ }
3990
+ getTypeOwnedHasPropertySetIds(t) {
3991
+ if (!this.entityExtractor) return [];
3992
+ const e = this.dataStore.entityIndex.byId.get(t);
3993
+ if (!e) return [];
3994
+ const s = this.entityExtractor.extractEntity(e)?.attributes?.[5];
3995
+ return Array.isArray(s) ? s.filter((i)=>typeof i == "number") : [];
3996
+ }
3997
+ rewriteTypeEntityHasPropertySets(t, e, n, s) {
3998
+ const i = [], o = new Set;
3999
+ for (const l of e){
4000
+ const d = this.getPropertySetName(l);
4001
+ if (d && n.has(d)) {
4002
+ const u = s.get(d);
4003
+ u !== void 0 && (i.push(u), o.add(d));
4004
+ continue;
4005
+ }
4006
+ i.push(l);
4007
+ }
4008
+ for (const [l, d] of s)o.has(l) || i.push(d);
4009
+ const a = i.length > 0 ? `(${i.map((l)=>`#${l}`).join(",")})` : "$";
4010
+ return this.replaceEntityAttribute(t, 5, a);
4011
+ }
4012
+ replaceEntityAttribute(t, e, n) {
4013
+ const s = this.dataStore.entityIndex.byId.get(t);
4014
+ if (!s || !this.dataStore.source) return null;
4015
+ const o = nt(this.dataStore.source, s.byteOffset, s.byteOffset + s.byteLength).match(/^(#\d+\s*=\s*\w+\()([\s\S]*)(\)\s*;)\s*$/);
4016
+ if (!o) return null;
4017
+ const [, a, l, d] = o, u = Xn(l);
4018
+ return e >= u.length ? null : (u[e] = n, `${a}${u.join(",")}${d}`);
4019
+ }
4020
+ };
4021
+ os = function(r, t) {
4022
+ const n = new qn(r).export({
4023
+ schema: "IFC4",
4024
+ ...t
4025
+ });
4026
+ return new TextDecoder().decode(n.content);
4027
+ };
4028
+ function Qn(r, t) {
4029
+ const e = new TextEncoder, n = e.encode(`${r}DATA;
4030
+ `), s = e.encode(`ENDSEC;
4031
+ END-ISO-10303-21;
4032
+ `), i = e.encode(`
4033
+ `);
4034
+ let o = n.byteLength + s.byteLength;
4035
+ const a = new Array(t.length);
4036
+ for(let u = 0; u < t.length; u++)a[u] = e.encode(t[u]), o += a[u].byteLength + i.byteLength;
4037
+ const l = new Uint8Array(o);
4038
+ let d = 0;
4039
+ l.set(n, d), d += n.byteLength;
4040
+ for(let u = 0; u < a.length; u++)l.set(a[u], d), d += a[u].byteLength, l.set(i, d), d += i.byteLength;
4041
+ return l.set(s, d), l;
4042
+ }
4043
+ const Jn = /#(\d+)/g, Kn = new Set([
4044
+ "IFCUNITASSIGNMENT",
4045
+ "IFCGEOMETRICREPRESENTATIONCONTEXT",
4046
+ "IFCGEOMETRICREPRESENTATIONSUBCONTEXT"
4047
+ ]);
4048
+ as = class {
4049
+ models;
4050
+ constructor(t){
4051
+ if (t.length === 0) throw new Error("MergedExporter requires at least one model");
4052
+ this.models = t;
4053
+ }
4054
+ export(t) {
4055
+ const e = t.onProgress, n = t.schema || "IFC4", s = ee({
4056
+ schema: n,
4057
+ description: t.description || `Merged export of ${this.models.length} models from ifc-lite`,
4058
+ author: t.author || "",
4059
+ organization: t.organization || "",
4060
+ application: t.application || "ifc-lite",
4061
+ filename: t.filename || "merged.ifc"
4062
+ }), i = [];
4063
+ let o = 1;
4064
+ const a = new Map;
4065
+ for (const y of this.models){
4066
+ a.set(y.id, o - 1);
4067
+ let m = 0;
4068
+ for (const [b] of y.dataStore.entityIndex.byId)b > m && (m = b);
4069
+ o += m;
4070
+ }
4071
+ const l = this.models[0], d = a.get(l.id), u = this.findInfrastructureEntities(l.dataStore), f = this.findEntitiesByType(l.dataStore, "IFCPROJECT"), p = this.buildSpatialLookup(l.dataStore);
4072
+ let _ = !0;
4073
+ for (const y of this.models){
4074
+ const m = a.get(y.id), b = y.dataStore.source;
4075
+ if (!b || b.length === 0) continue;
4076
+ let w = null;
4077
+ if (t.visibleOnly) {
4078
+ const j = t.hiddenEntityIdsByModel?.get(y.id) ?? new Set, O = t.isolatedEntityIdsByModel?.get(y.id) ?? null, { roots: U, hiddenProductIds: C } = oe(y.dataStore, j, O);
4079
+ w = re(U, b, y.dataStore.entityIndex.byId, C), ae(w, b, y.dataStore.entityIndex);
4080
+ }
4081
+ const v = new Map, L = new Set;
4082
+ if (!_) {
4083
+ const j = this.findEntitiesByType(y.dataStore, "IFCPROJECT");
4084
+ if (f.length > 0) for (const U of j)v.set(U, f[0] + d), L.add(U);
4085
+ const O = this.findInfrastructureEntities(y.dataStore);
4086
+ for (const [U, C] of u){
4087
+ const N = O.get(U);
4088
+ N && C.length > 0 && N.length > 0 && (v.set(N[0], C[0] + d), L.add(N[0]));
4089
+ }
4090
+ this.unifySpatialEntities(y.dataStore, p, d, v, L), this.skipRedundantRelAggregates(y.dataStore, v, L);
4091
+ }
4092
+ for (const [j, O] of y.dataStore.entityIndex.byId){
4093
+ if (w !== null && !w.has(j) || L.has(j)) continue;
4094
+ const U = nt(b, O.byteOffset, O.byteOffset + O.byteLength);
4095
+ let C;
4096
+ m === 0 && v.size === 0 ? C = U : C = this.remapEntityText(U, m, v);
4097
+ const N = y.dataStore.schemaVersion || "IFC4";
4098
+ if (ce(N, n)) {
4099
+ const F = jt(C, N, n);
4100
+ F !== null && i.push(F);
4101
+ } else i.push(C);
4102
+ }
4103
+ _ = !1;
4104
+ }
4105
+ e && e({
4106
+ phase: "assembling",
4107
+ percent: .9,
4108
+ entitiesProcessed: i.length,
4109
+ entitiesTotal: i.length
4110
+ });
4111
+ const h = Oe(s, i);
4112
+ return {
4113
+ content: h,
4114
+ stats: {
4115
+ modelCount: this.models.length,
4116
+ totalEntityCount: i.length,
4117
+ fileSize: h.byteLength
4118
+ }
4119
+ };
4120
+ }
4121
+ async exportAsync(t) {
4122
+ const e = t.onProgress, n = t.schema || "IFC4", s = ee({
4123
+ schema: n,
4124
+ description: t.description || `Merged export of ${this.models.length} models from ifc-lite`,
4125
+ author: t.author || "",
4126
+ organization: t.organization || "",
4127
+ application: t.application || "ifc-lite",
4128
+ filename: t.filename || "merged.ifc"
4129
+ }), i = [];
4130
+ let o = 0;
4131
+ for (const w of this.models)o += w.dataStore.entityIndex.byId.size;
4132
+ let a = 1;
4133
+ const l = new Map;
4134
+ for (const w of this.models){
4135
+ l.set(w.id, a - 1);
4136
+ let v = 0;
4137
+ for (const [L] of w.dataStore.entityIndex.byId)L > v && (v = L);
4138
+ a += v;
4139
+ }
4140
+ const d = this.models[0], u = l.get(d.id), f = this.findInfrastructureEntities(d.dataStore), p = this.findEntitiesByType(d.dataStore, "IFCPROJECT"), _ = this.buildSpatialLookup(d.dataStore);
4141
+ let h = !0, y = 0;
4142
+ const m = 2e3;
4143
+ e && e({
4144
+ phase: "preparing",
4145
+ percent: 0,
4146
+ entitiesProcessed: 0,
4147
+ entitiesTotal: o
4148
+ });
4149
+ for (const w of this.models){
4150
+ const v = l.get(w.id), L = w.dataStore.source;
4151
+ if (!L || L.length === 0) continue;
4152
+ e && e({
4153
+ phase: "entities",
4154
+ percent: o > 0 ? y / o * .85 : 0,
4155
+ entitiesProcessed: y,
4156
+ entitiesTotal: o,
4157
+ currentModel: w.name
4158
+ });
4159
+ let j = null;
4160
+ if (t.visibleOnly) {
4161
+ const N = t.hiddenEntityIdsByModel?.get(w.id) ?? new Set, F = t.isolatedEntityIdsByModel?.get(w.id) ?? null, { roots: E, hiddenProductIds: g } = oe(w.dataStore, N, F);
4162
+ j = re(E, L, w.dataStore.entityIndex.byId, g), ae(j, L, w.dataStore.entityIndex);
4163
+ }
4164
+ const O = new Map, U = new Set;
4165
+ if (!h) {
4166
+ const N = this.findEntitiesByType(w.dataStore, "IFCPROJECT");
4167
+ if (p.length > 0) for (const E of N)O.set(E, p[0] + u), U.add(E);
4168
+ const F = this.findInfrastructureEntities(w.dataStore);
4169
+ for (const [E, g] of f){
4170
+ const T = F.get(E);
4171
+ T && g.length > 0 && T.length > 0 && (O.set(T[0], g[0] + u), U.add(T[0]));
4172
+ }
4173
+ this.unifySpatialEntities(w.dataStore, _, u, O, U), this.skipRedundantRelAggregates(w.dataStore, O, U);
4174
+ }
4175
+ let C = 0;
4176
+ for (const [N, F] of w.dataStore.entityIndex.byId){
4177
+ if (j !== null && !j.has(N) || U.has(N)) continue;
4178
+ const E = nt(L, F.byteOffset, F.byteOffset + F.byteLength);
4179
+ let g;
4180
+ v === 0 && O.size === 0 ? g = E : g = this.remapEntityText(E, v, O);
4181
+ const T = w.dataStore.schemaVersion || "IFC4";
4182
+ if (ce(T, n)) {
4183
+ const I = jt(g, T, n);
4184
+ I !== null && i.push(I);
4185
+ } else i.push(g);
4186
+ C++, y++, C % m === 0 && (e && e({
4187
+ phase: "entities",
4188
+ percent: o > 0 ? y / o * .85 : 0,
4189
+ entitiesProcessed: y,
4190
+ entitiesTotal: o,
4191
+ currentModel: w.name
4192
+ }), await new Promise((I)=>setTimeout(I, 0)));
4193
+ }
4194
+ h = !1;
4195
+ }
4196
+ e && e({
4197
+ phase: "assembling",
4198
+ percent: .9,
4199
+ entitiesProcessed: o,
4200
+ entitiesTotal: o
4201
+ }), await new Promise((w)=>setTimeout(w, 0));
4202
+ const b = Oe(s, i);
4203
+ return e && e({
4204
+ phase: "assembling",
4205
+ percent: 1,
4206
+ entitiesProcessed: o,
4207
+ entitiesTotal: o
4208
+ }), {
4209
+ content: b,
4210
+ stats: {
4211
+ modelCount: this.models.length,
4212
+ totalEntityCount: i.length,
4213
+ fileSize: b.byteLength
4214
+ }
4215
+ };
4216
+ }
4217
+ remapEntityText(t, e, n) {
4218
+ return t.replace(Jn, (s, i)=>{
4219
+ const o = parseInt(i, 10), a = n.get(o);
4220
+ return a !== void 0 ? `#${a}` : `#${o + e}`;
4221
+ });
4222
+ }
4223
+ findInfrastructureEntities(t) {
4224
+ const e = new Map;
4225
+ for (const n of Kn){
4226
+ const s = t.entityIndex.byType.get(n) ?? [];
4227
+ s.length > 0 && e.set(n, [
4228
+ ...s
4229
+ ]);
4230
+ }
4231
+ return e;
4232
+ }
4233
+ findEntitiesByType(t, e) {
4234
+ return t.entityIndex.byType.get(e) ?? [];
4235
+ }
4236
+ buildSpatialLookup(t) {
4237
+ const e = {
4238
+ sitesByName: new Map,
4239
+ buildingsByName: new Map,
4240
+ storeysByName: new Map,
4241
+ storeysByElevation: [],
4242
+ siteIds: [],
4243
+ buildingIds: []
4244
+ };
4245
+ for (const n of this.findEntitiesByType(t, "IFCSITE")){
4246
+ e.siteIds.push(n);
4247
+ const s = this.extractEntityName(n, t);
4248
+ s && e.sitesByName.set(s.toLowerCase(), n);
4249
+ }
4250
+ for (const n of this.findEntitiesByType(t, "IFCBUILDING")){
4251
+ e.buildingIds.push(n);
4252
+ const s = this.extractEntityName(n, t);
4253
+ s && e.buildingsByName.set(s.toLowerCase(), n);
4254
+ }
4255
+ for (const n of this.findEntitiesByType(t, "IFCBUILDINGSTOREY")){
4256
+ const s = this.extractEntityName(n, t);
4257
+ s && e.storeysByName.set(s.toLowerCase(), n);
4258
+ const i = this.extractStoreyElevation(n, t);
4259
+ i !== void 0 && e.storeysByElevation.push({
4260
+ expressId: n,
4261
+ elevation: i
4262
+ });
4263
+ }
4264
+ return e;
4265
+ }
4266
+ unifySpatialEntities(t, e, n, s, i) {
4267
+ const o = this.findEntitiesByType(t, "IFCSITE");
4268
+ for (const d of o){
4269
+ const u = this.extractEntityName(d, t);
4270
+ let f;
4271
+ u && (f = e.sitesByName.get(u.toLowerCase())), f === void 0 && o.length === 1 && e.siteIds.length === 1 && (f = e.siteIds[0]), f !== void 0 && (s.set(d, f + n), i.add(d));
4272
+ }
4273
+ const a = this.findEntitiesByType(t, "IFCBUILDING");
4274
+ for (const d of a){
4275
+ const u = this.extractEntityName(d, t);
4276
+ let f;
4277
+ u && (f = e.buildingsByName.get(u.toLowerCase())), f === void 0 && a.length === 1 && e.buildingIds.length === 1 && (f = e.buildingIds[0]), f !== void 0 && (s.set(d, f + n), i.add(d));
4278
+ }
4279
+ const l = new Set;
4280
+ for (const d of this.findEntitiesByType(t, "IFCBUILDINGSTOREY")){
4281
+ const u = this.extractEntityName(d, t);
4282
+ let f;
4283
+ if (u) {
4284
+ const p = e.storeysByName.get(u.toLowerCase());
4285
+ p !== void 0 && !l.has(p) && (f = p);
4286
+ }
4287
+ if (f === void 0) {
4288
+ const p = this.extractStoreyElevation(d, t);
4289
+ if (p !== void 0) for (const _ of e.storeysByElevation){
4290
+ if (l.has(_.expressId)) continue;
4291
+ const h = Math.max(.5, Math.abs(_.elevation) * .01);
4292
+ if (Math.abs(p - _.elevation) <= h) {
4293
+ f = _.expressId;
4294
+ break;
4295
+ }
4296
+ }
4297
+ }
4298
+ f !== void 0 && (l.add(f), s.set(d, f + n), i.add(d));
4299
+ }
4300
+ }
4301
+ skipRedundantRelAggregates(t, e, n) {
4302
+ for (const s of this.findEntitiesByType(t, "IFCRELAGGREGATES")){
4303
+ const i = this.extractStepAttribute(s, t, 4);
4304
+ if (!i) continue;
4305
+ const o = i.match(/^#(\d+)$/);
4306
+ if (!o || !e.has(parseInt(o[1], 10))) continue;
4307
+ const a = this.extractStepAttribute(s, t, 5);
4308
+ if (!a) continue;
4309
+ const l = [], d = /#(\d+)/g;
4310
+ let u;
4311
+ for(; (u = d.exec(a)) !== null;)l.push(parseInt(u[1], 10));
4312
+ l.length !== 0 && l.every((f)=>e.has(f)) && n.add(s);
4313
+ }
4314
+ }
4315
+ extractEntityName(t, e) {
4316
+ const n = this.extractStepAttribute(t, e, 2);
4317
+ if (!n || n === "$") return null;
4318
+ if (n.startsWith("'") && n.endsWith("'")) {
4319
+ const s = n.slice(1, -1).replace(/''/g, "'");
4320
+ return He(s);
4321
+ }
4322
+ return null;
4323
+ }
4324
+ extractStoreyElevation(t, e) {
4325
+ const n = this.extractStepAttribute(t, e, 9);
4326
+ if (!n || n === "$") return;
4327
+ const s = n.match(/^[A-Z_]+\(([^)]+)\)$/i), i = s ? s[1] : n, o = parseFloat(i);
4328
+ return isNaN(o) ? void 0 : o;
4329
+ }
4330
+ extractStepAttribute(t, e, n) {
4331
+ const s = e.source;
4332
+ if (!s) return null;
4333
+ const i = e.entityIndex.byId.get(t);
4334
+ if (!i) return null;
4335
+ const o = nt(s, i.byteOffset, i.byteOffset + i.byteLength), a = o.indexOf("(");
4336
+ if (a === -1) return null;
4337
+ let l = 0, d = 0, u = a + 1, f = !1;
4338
+ for(let p = a + 1; p < o.length; p++){
4339
+ const _ = o[p];
4340
+ if (_ === "'" && !f) f = !0;
4341
+ else if (_ === "'" && f) {
4342
+ if (p + 1 < o.length && o[p + 1] === "'") {
4343
+ p++;
4344
+ continue;
4345
+ }
4346
+ f = !1;
4347
+ } else if (!f) {
4348
+ if (_ === "(") l++;
4349
+ else if (_ === ")") {
4350
+ if (l === 0) return d === n ? o.substring(u, p).trim() : null;
4351
+ l--;
4352
+ } else if (_ === "," && l === 0) {
4353
+ if (d === n) return o.substring(u, p).trim();
4354
+ d++, u = p + 1;
4355
+ }
4356
+ }
4357
+ }
4358
+ return null;
4359
+ }
4360
+ };
4361
+ function Oe(r, t) {
4362
+ const e = new TextEncoder, n = e.encode(`${r}DATA;
4363
+ `), s = e.encode(`ENDSEC;
4364
+ END-ISO-10303-21;
4365
+ `), i = e.encode(`
4366
+ `);
4367
+ let o = n.byteLength + s.byteLength;
4368
+ const a = new Array(t.length);
4369
+ for(let u = 0; u < t.length; u++)a[u] = e.encode(t[u]), o += a[u].byteLength + i.byteLength;
4370
+ const l = new Uint8Array(o);
4371
+ let d = 0;
4372
+ l.set(n, d), d += n.byteLength;
4373
+ for(let u = 0; u < a.length; u++)l.set(a[u], d), d += a[u].byteLength, l.set(i, d), d += i.byteLength;
4374
+ return l.set(s, d), l;
4375
+ }
4376
+ let Zt;
4377
+ Zt = {
4378
+ IFC_CORE: "https://ifcx.dev/@standards.buildingsmart.org/ifc/core/ifc@v5a.ifcx",
4379
+ IFC_PROP: "https://ifcx.dev/@standards.buildingsmart.org/ifc/core/prop@v5a.ifcx",
4380
+ USD: "https://ifcx.dev/@openusd.org/usd@v1.ifcx"
4381
+ };
4382
+ Le = new Set([
4383
+ "UsageType",
4384
+ "TypeName",
4385
+ "IsExternal",
4386
+ "RefElevation",
4387
+ "ElevationOfRefHeight",
4388
+ "ElevationOfTerrain",
4389
+ "NumberOfStoreys",
4390
+ "Height",
4391
+ "Width",
4392
+ "Length",
4393
+ "Depth",
4394
+ "Volume",
4395
+ "NetVolume",
4396
+ "NetArea",
4397
+ "NetSideArea",
4398
+ "CrossSectionArea",
4399
+ "Station"
4400
+ ]);
4401
+ cs = class {
4402
+ dataStore;
4403
+ mutationView;
4404
+ geometryResult;
4405
+ idOffset;
4406
+ childNames = new Map;
4407
+ spatialNodeNames = new Map;
4408
+ spatialChildIds = new Map;
4409
+ entityUuids = new Map;
4410
+ constructor(t, e, n, s){
4411
+ this.dataStore = t, this.geometryResult = e ?? null, this.mutationView = n ?? null, this.idOffset = s ?? 0;
4412
+ }
4413
+ export(t = {}) {
4414
+ const e = this.dataStore.schemaVersion || "IFC4";
4415
+ this.buildEntityMaps();
4416
+ const n = this.buildMeshLookup(t), s = this.buildVisibleSet(t), i = t.onlyTreeEntities !== !1 ? this.buildTreeEntitySet() : null, o = [];
4417
+ let a = 0, l = 0;
4418
+ const { entities: d, strings: u } = this.dataStore;
4419
+ let f = null;
4420
+ for(let y = 0; y < d.count; y++){
4421
+ const m = d.expressId[y];
4422
+ if (s && !s.has(m) || i && !i.has(m)) continue;
4423
+ const b = d.typeEnum[y], w = ne(b) || "IfcElement", v = De(w.toUpperCase(), e, "IFC5"), L = ts(v);
4424
+ L === "IfcProject" && (f = m);
4425
+ const j = this.entityUuids.get(m) || te(m), O = {};
4426
+ O["bsi::ifc::class"] = {
4427
+ code: L,
4428
+ uri: `https://identifier.buildingsmart.org/uri/buildingsmart/ifc/5/class/${L}`
4429
+ };
4430
+ const U = u.get(d.name[y]) || this.spatialNodeNames.get(m);
4431
+ U && (O["bsi::ifc::prop::Name"] = U);
4432
+ const C = u.get(d.description[y]);
4433
+ if (C && (O["bsi::ifc::prop::Description"] = C), t.includeProperties !== !1) {
4434
+ const E = this.getPropertiesForEntity(m, t);
4435
+ for (const [g, T] of Object.entries(E))O[g] = T, a++;
4436
+ }
4437
+ const N = {
4438
+ path: j
4439
+ }, F = this.getChildrenForEntity(m);
4440
+ if (Object.keys(F).length > 0 && (N.children = F), t.includeGeometry !== !1) {
4441
+ const E = n.get(m);
4442
+ if (E && E.length > 0) {
4443
+ const g = this.convertToUsdMesh(E);
4444
+ O["usd::usdgeom::mesh"] = g;
4445
+ const [T, I, R, S] = E[0].color;
4446
+ O["bsi::ifc::presentation::diffuseColor"] = [
4447
+ T,
4448
+ I,
4449
+ R
4450
+ ], S < 1 && (O["bsi::ifc::presentation::opacity"] = S), l++;
4451
+ }
4452
+ }
4453
+ Object.keys(O).length > 0 && (N.attributes = O), o.push(N);
4454
+ }
4455
+ if (f !== null) {
4456
+ const y = this.entityUuids.get(f);
4457
+ if (y) {
4458
+ const m = this.childNames.get(f) || u.get(d.name[this.findEntityIndex(f)]) || "Project", b = te(0);
4459
+ o.unshift({
4460
+ path: b,
4461
+ children: {
4462
+ [m]: y
4463
+ },
4464
+ attributes: {}
4465
+ });
4466
+ }
4467
+ }
4468
+ const p = Zn(o), _ = {
4469
+ header: {
4470
+ id: `ifcx_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
4471
+ ifcxVersion: "ifcx_alpha",
4472
+ dataVersion: t.dataVersion || "1.0.0",
4473
+ author: t.author || "ifc-lite",
4474
+ timestamp: new Date().toISOString()
4475
+ },
4476
+ imports: p,
4477
+ schemas: {},
4478
+ data: o
4479
+ }, h = t.prettyPrint !== !1 ? JSON.stringify(_, null, 2) : JSON.stringify(_);
4480
+ return {
4481
+ content: h,
4482
+ stats: {
4483
+ nodeCount: o.length,
4484
+ propertyCount: a,
4485
+ meshCount: l,
4486
+ fileSize: new TextEncoder().encode(h).length
4487
+ }
4488
+ };
4489
+ }
4490
+ findEntityIndex(t) {
4491
+ const { entities: e } = this.dataStore;
4492
+ for(let n = 0; n < e.count; n++)if (e.expressId[n] === t) return n;
4493
+ return 0;
4494
+ }
4495
+ buildEntityMaps() {
4496
+ const { spatialHierarchy: t, entities: e, strings: n } = this.dataStore;
4497
+ this.entityUuids.clear();
4498
+ for(let l = 0; l < e.count; l++){
4499
+ const d = e.expressId[l], u = n.get(e.globalId[l]);
4500
+ this.entityUuids.set(d, u || te(d));
4501
+ }
4502
+ const s = new Map, i = (l, d)=>{
4503
+ if (d) for (const u of d)s.set(u, l);
4504
+ };
4505
+ if (this.spatialChildIds.clear(), this.spatialNodeNames.clear(), t?.project) {
4506
+ const l = (d)=>{
4507
+ d.name && this.spatialNodeNames.set(d.expressId, d.name);
4508
+ const u = [];
4509
+ for (const f of d.children)s.set(f.expressId, d.expressId), u.push(f.expressId), l(f);
4510
+ this.spatialChildIds.set(d.expressId, u);
4511
+ };
4512
+ l(t.project);
4513
+ }
4514
+ if (t) {
4515
+ for (const l of [
4516
+ t.bySite,
4517
+ t.byBuilding,
4518
+ t.byStorey,
4519
+ t.bySpace
4520
+ ])if (l) for (const [d, u] of l)i(d, u);
4521
+ }
4522
+ const o = new Map;
4523
+ for(let l = 0; l < e.count; l++){
4524
+ const d = e.expressId[l];
4525
+ let u = n.get(e.name[l]) || "";
4526
+ if (u || (u = this.spatialNodeNames.get(d) || ""), !u) {
4527
+ const f = ne(e.typeEnum[l]);
4528
+ f !== "Unknown" && (u = f);
4529
+ }
4530
+ o.set(d, u);
4531
+ }
4532
+ const a = new Map;
4533
+ for (const [l, d] of s)a.has(d) || a.set(d, []), a.get(d).push(l);
4534
+ for(let l = 0; l < e.count; l++){
4535
+ const d = e.expressId[l];
4536
+ s.has(d) || (a.has(void 0) || a.set(void 0, []), a.get(void 0).push(d));
4537
+ }
4538
+ this.childNames.clear();
4539
+ for (const [, l] of a){
4540
+ const d = new Map;
4541
+ for (const u of l){
4542
+ const p = (o.get(u) || `e${u}`).replace(/[/\\]/g, "_").replace(/\s+/g, "_");
4543
+ d.set(p, (d.get(p) || 0) + 1);
4544
+ }
4545
+ for (const u of l){
4546
+ const p = (o.get(u) || `e${u}`).replace(/[/\\]/g, "_").replace(/\s+/g, "_");
4547
+ this.childNames.set(u, d.get(p) > 1 ? `${p}_${u}` : p);
4548
+ }
4549
+ }
4550
+ }
4551
+ getPropertiesForEntity(t, e) {
4552
+ const n = {};
4553
+ if (this.mutationView && e.applyMutations !== !1) {
4554
+ const s = this.mutationView.getForEntity(t);
4555
+ for (const i of s)for (const o of i.properties){
4556
+ if (e.onlyKnownProperties !== !1 && !Le.has(o.name)) continue;
4557
+ const a = `bsi::ifc::prop::${o.name}`;
4558
+ n[a] = this.convertPropertyValue(o.value, o.type);
4559
+ }
4560
+ } else if (this.dataStore.properties) {
4561
+ const s = this.dataStore.properties.getForEntity(t);
4562
+ for (const i of s)for (const o of i.properties){
4563
+ if (e.onlyKnownProperties !== !1 && !Le.has(o.name)) continue;
4564
+ const a = `bsi::ifc::prop::${o.name}`;
4565
+ n[a] = this.convertPropertyValue(o.value, o.type);
4566
+ }
4567
+ }
4568
+ return n;
4569
+ }
4570
+ convertPropertyValue(t, e) {
4571
+ if (t == null) return null;
4572
+ switch(e){
4573
+ case tt.Real:
4574
+ return Number(t);
4575
+ case tt.Integer:
4576
+ return Math.round(Number(t));
4577
+ case tt.Boolean:
4578
+ case tt.Logical:
4579
+ return !!t;
4580
+ default:
4581
+ return t;
4582
+ }
4583
+ }
4584
+ getChildrenForEntity(t) {
4585
+ const e = {}, n = (o)=>{
4586
+ const a = this.entityUuids.get(o);
4587
+ if (!a) return;
4588
+ const l = this.childNames.get(o) || `e${o}`;
4589
+ e[l] = a;
4590
+ }, s = this.spatialChildIds.get(t);
4591
+ if (s) for (const o of s)n(o);
4592
+ const { spatialHierarchy: i } = this.dataStore;
4593
+ if (i) {
4594
+ const o = [
4595
+ i.bySite?.get(t),
4596
+ i.byBuilding?.get(t),
4597
+ i.byStorey?.get(t),
4598
+ i.bySpace?.get(t)
4599
+ ];
4600
+ for (const a of o)if (a) for (const l of a)n(l);
4601
+ }
4602
+ return e;
4603
+ }
4604
+ buildMeshLookup(t) {
4605
+ const e = new Map;
4606
+ if (!this.geometryResult || t.includeGeometry === !1) return e;
4607
+ for (const n of this.geometryResult.meshes){
4608
+ const s = n.expressId - this.idOffset, i = s > 0 ? s : n.expressId;
4609
+ e.has(i) || e.set(i, []), e.get(i).push(n);
4610
+ }
4611
+ return e;
4612
+ }
4613
+ convertToUsdMesh(t) {
4614
+ const e = [], n = [];
4615
+ let s = 0;
4616
+ for (const i of t){
4617
+ for(let o = 0; o < i.positions.length; o += 3){
4618
+ const a = i.positions[o], l = i.positions[o + 1], d = i.positions[o + 2];
4619
+ e.push([
4620
+ a,
4621
+ -d,
4622
+ l
4623
+ ]);
4624
+ }
4625
+ for(let o = 0; o < i.indices.length; o += 3)n.push(i.indices[o] + s, i.indices[o + 1] + s, i.indices[o + 2] + s);
4626
+ s += i.positions.length / 3;
4627
+ }
4628
+ return {
4629
+ points: e,
4630
+ faceVertexIndices: n
4631
+ };
4632
+ }
4633
+ buildTreeEntitySet() {
4634
+ const t = new Set, { spatialHierarchy: e } = this.dataStore;
4635
+ if (e?.project) {
4636
+ const n = (s)=>{
4637
+ t.add(s.expressId);
4638
+ for (const i of s.children)n(i);
4639
+ };
4640
+ n(e.project);
4641
+ }
4642
+ if (e) {
4643
+ for (const n of [
4644
+ e.bySite,
4645
+ e.byBuilding,
4646
+ e.byStorey,
4647
+ e.bySpace
4648
+ ])if (n) for (const s of n.values())for (const i of s)t.add(i);
4649
+ }
4650
+ return t;
4651
+ }
4652
+ buildVisibleSet(t) {
4653
+ if (!t.visibleOnly) return null;
4654
+ const e = t.hiddenEntityIds ?? new Set, n = t.isolatedEntityIds ?? null, s = new Set, { entities: i } = this.dataStore;
4655
+ for(let o = 0; o < i.count; o++){
4656
+ const a = i.expressId[o];
4657
+ n ? n.has(a) && s.add(a) : e.has(a) || s.add(a);
4658
+ }
4659
+ return s;
4660
+ }
4661
+ };
4662
+ function Zn(r) {
4663
+ let t = !1, e = !1, n = !1;
4664
+ for (const i of r)if (i.attributes) {
4665
+ for (const o of Object.keys(i.attributes))if (!t && (o === "bsi::ifc::class" || o.startsWith("bsi::ifc::presentation::") || o === "bsi::ifc::material" || o === "bsi::ifc::spaceBoundary") && (t = !0), !e && o.startsWith("bsi::ifc::prop::") && (e = !0), !n && o.startsWith("usd::") && (n = !0), t && e && n) break;
4666
+ if (t && e && n) break;
4667
+ }
4668
+ const s = [];
4669
+ return t && s.push({
4670
+ uri: Zt.IFC_CORE
4671
+ }), e && s.push({
4672
+ uri: Zt.IFC_PROP
4673
+ }), n && s.push({
4674
+ uri: Zt.USD
4675
+ }), s;
4676
+ }
4677
+ function te(r) {
4678
+ return `00000000-0000-4000-8000-${r.toString(16).padStart(12, "0")}`;
4679
+ }
4680
+ function ts(r) {
4681
+ const t = Xe(r), e = ne(t);
4682
+ if (e !== "Unknown") return e;
4683
+ const n = r.toLowerCase();
4684
+ return n.startsWith("ifc") ? "Ifc" + n.charAt(3).toUpperCase() + n.slice(4) : r;
4685
+ }
4686
+ });
4687
+ export { rs as C, is as G, Le as I, as as M, qn as S, Be as _, ss as a, In as b, cs as c, ie as d, os as e, ns as g, __tla };