@mlightcad/dxf-json-converter 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1062 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ var __read = (this && this.__read) || function (o, n) {
53
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
54
+ if (!m) return o;
55
+ var i = m.call(o), r, ar = [], e;
56
+ try {
57
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
58
+ }
59
+ catch (error) { e = { error: error }; }
60
+ finally {
61
+ try {
62
+ if (r && !r.done && (m = i["return"])) m.call(i);
63
+ }
64
+ finally { if (e) throw e.error; }
65
+ }
66
+ return ar;
67
+ };
68
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
69
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
70
+ if (ar || !(i in from)) {
71
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
72
+ ar[i] = from[i];
73
+ }
74
+ }
75
+ return to.concat(ar || Array.prototype.slice.call(from));
76
+ };
77
+ var __values = (this && this.__values) || function(o) {
78
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
79
+ if (m) return m.call(o);
80
+ if (o && typeof o.length === "number") return {
81
+ next: function () {
82
+ if (o && i >= o.length) o = void 0;
83
+ return { value: o && o[i++], done: !o };
84
+ }
85
+ };
86
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
87
+ };
88
+ import { AcCmColor, AcDbBatchProcessing, AcDbBlockTableRecord, AcDbDatabaseConverter, AcDbDimStyleTableRecord, AcDbLayerTableRecord, AcDbLinetypeTableRecord, AcDbSystemVariables, AcDbSysVarManager, AcDbTextStyleTableRecord, AcDbViewportTableRecord, ByLayer, createWorkerApi, DEFAULT_MLEADER_STYLE, DEFAULT_MLINE_STYLE, DEFAULT_TEXT_STYLE, VPORT_FALLBACK_CENTER_2D, VPORT_FALLBACK_LLC, VPORT_FALLBACK_URC, VPORT_FALLBACK_VIEW_DIR, VPORT_FALLBACK_VIEW_TARGET } from '@mlightcad/data-model';
89
+ import { AcDbEntityConverter } from './AcDbEntitiyConverter';
90
+ import { AcDbObjectConverter } from './AcDbObjectConverter';
91
+ /**
92
+ * Default database converter for DXF files.
93
+ *
94
+ * This class extends AcDbDatabaseConverter to provide specialized functionality
95
+ * for converting DXF (Drawing Exchange Format) files into AcDbDatabase objects.
96
+ * It handles parsing DXF data, processing entities, blocks, tables, and other
97
+ * DXF-specific structures.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const converter = new AcDbDxfConverter();
102
+ * const database = await converter.convert(dxfData);
103
+ * ```
104
+ */
105
+ var AcDbDxfConverter = /** @class */ (function (_super) {
106
+ __extends(AcDbDxfConverter, _super);
107
+ function AcDbDxfConverter(config) {
108
+ if (config === void 0) { config = {}; }
109
+ var _this = _super.call(this, config) || this;
110
+ if (!_this.config.parserWorkerUrl) {
111
+ _this.config.parserWorkerUrl = '/assets/dxf-parser-worker.js';
112
+ }
113
+ return _this;
114
+ }
115
+ /**
116
+ * Parses DXF data into a ParsedDxf object.
117
+ *
118
+ * @param data - The DXF data
119
+ * @returns Parsed DXF object containing all the parsed data
120
+ *
121
+ */
122
+ AcDbDxfConverter.prototype.parse = function (data, timeout) {
123
+ return __awaiter(this, void 0, void 0, function () {
124
+ var effectiveConfig, resolvedTimeout, api, result;
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0:
128
+ effectiveConfig = this.config;
129
+ resolvedTimeout = this.getParserWorkerTimeout(data, timeout);
130
+ if (!(effectiveConfig.useWorker && effectiveConfig.parserWorkerUrl)) return [3 /*break*/, 2];
131
+ api = createWorkerApi({
132
+ workerUrl: effectiveConfig.parserWorkerUrl,
133
+ timeout: resolvedTimeout,
134
+ // One concurrent worker needed for parser
135
+ maxConcurrentWorkers: 1
136
+ });
137
+ return [4 /*yield*/, api.execute(data)
138
+ // Release worker
139
+ ];
140
+ case 1:
141
+ result = _a.sent();
142
+ // Release worker
143
+ api.destroy();
144
+ if (result.success) {
145
+ return [2 /*return*/, {
146
+ model: result.data,
147
+ data: {
148
+ unknownEntityCount: 0
149
+ }
150
+ }];
151
+ }
152
+ else {
153
+ throw new Error("Failed to parse drawing due to error: '".concat(result.error, "'"));
154
+ }
155
+ return [3 /*break*/, 3];
156
+ case 2: throw new Error('dxf converter can run in web worker only!');
157
+ case 3: return [2 /*return*/];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ /**
163
+ * Gets all fonts used by entities in model space and paper space.
164
+ *
165
+ * This method analyzes the DXF data to extract all font names used by
166
+ * text entities, MText entities, and insert entities throughout the drawing.
167
+ *
168
+ * @param dxf - Input parsed DXF model
169
+ * @returns Array of font names used in the drawing
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const fonts = converter.getFonts(parsedDxf);
174
+ * console.log('Used fonts:', fonts);
175
+ * ```
176
+ */
177
+ AcDbDxfConverter.prototype.getFonts = function (dxf) {
178
+ var _a;
179
+ // Build text style map. The key is text style name, and the value is font name list.
180
+ var styleMap = new Map();
181
+ var getFontName = function (fontFileName) {
182
+ if (fontFileName) {
183
+ var lastDotIndex = fontFileName.lastIndexOf('.');
184
+ if (lastDotIndex >= 0) {
185
+ return fontFileName.substring(0, lastDotIndex).toLowerCase();
186
+ }
187
+ else {
188
+ return fontFileName.toLowerCase();
189
+ }
190
+ }
191
+ };
192
+ (_a = dxf.tables.STYLE) === null || _a === void 0 ? void 0 : _a.entries.forEach(function (style) {
193
+ var fontNames = [];
194
+ if (style.font) {
195
+ var fontName = getFontName(style.font);
196
+ if (fontName)
197
+ fontNames.push(fontName);
198
+ }
199
+ if (style.bigFont) {
200
+ var fontName = getFontName(style.bigFont);
201
+ if (fontName)
202
+ fontNames.push(fontName);
203
+ }
204
+ if (style.extendedFont) {
205
+ var fontName = getFontName(style.extendedFont);
206
+ if (fontName)
207
+ fontNames.push(fontName);
208
+ }
209
+ styleMap.set(style.name, fontNames);
210
+ });
211
+ var fonts = new Set();
212
+ this.getFontsInBlock(dxf.entities, dxf.blocks, styleMap, fonts);
213
+ return Array.from(fonts);
214
+ };
215
+ /**
216
+ * Iterates through entities in a block to get fonts used by text, MText, and insert entities.
217
+ *
218
+ * This is a helper method that recursively processes entities to extract font information
219
+ * from text-based entities and block references.
220
+ *
221
+ * @param entities - Array of DXF entities to process
222
+ * @param blockMap - Map of block definitions
223
+ * @param styleMap - Map of text styles to font names
224
+ * @param fonts - Set to collect font names
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const fonts = new Set<string>();
229
+ * converter.getFontsInBlock(entities, blocks, styleMap, fonts);
230
+ * ```
231
+ */
232
+ AcDbDxfConverter.prototype.getFontsInBlock = function (entities, blockMap, styleMap, fonts) {
233
+ var _this = this;
234
+ var regex = /\\f(.*?)\|/g;
235
+ entities.forEach(function (entity) {
236
+ if (entity.type == 'MTEXT') {
237
+ var mtext = entity;
238
+ var text = mtext.text;
239
+ __spreadArray([], __read(text.matchAll(regex)), false).forEach(function (match) {
240
+ fonts.add(match[1].toLowerCase());
241
+ });
242
+ var fontNames = styleMap.get(mtext.styleName);
243
+ fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
244
+ }
245
+ else if (entity.type == 'TEXT') {
246
+ var text = entity;
247
+ var fontNames = styleMap.get(text.styleName);
248
+ fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
249
+ }
250
+ else if (entity.type == 'MULTILEADER' || entity.type == 'MLEADER') {
251
+ var mleader = entity;
252
+ var text = typeof mleader.textContent === 'string' ? mleader.textContent : '';
253
+ __spreadArray([], __read(text.matchAll(regex)), false).forEach(function (match) {
254
+ fonts.add(match[1].toLowerCase());
255
+ });
256
+ var styleName = typeof mleader.textStyleName === 'string'
257
+ ? mleader.textStyleName
258
+ : typeof mleader.styleName === 'string'
259
+ ? mleader.styleName
260
+ : undefined;
261
+ var fontNames = styleName ? styleMap.get(styleName) : undefined;
262
+ fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
263
+ }
264
+ else if (entity.type == 'INSERT') {
265
+ var insert = entity;
266
+ var block = blockMap[insert.name];
267
+ if (block && block.entities)
268
+ _this.getFontsInBlock(block.entities, blockMap, styleMap, fonts);
269
+ }
270
+ });
271
+ };
272
+ /**
273
+ * Processes entities in batches to maintain UI responsiveness.
274
+ *
275
+ * This method breaks up the entity processing work into smaller chunks that are
276
+ * executed asynchronously. This is often referred to as "batch processing" or
277
+ * "cooperative multitasking," where the time-consuming task is broken into
278
+ * smaller pieces and executed in small intervals to allow the UI to remain responsive.
279
+ *
280
+ * @param dxf - Parsed DXF data
281
+ * @param db - Target database to add entities to
282
+ * @param minimumChunkSize - Minimum number of entities to process in each chunk
283
+ * @param startPercentage - Object containing the starting percentage for progress tracking
284
+ * @param progress - Optional callback for progress updates
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * await converter.processEntities(dxf, database, 100, { value: 0 }, progressCallback);
289
+ * ```
290
+ */
291
+ AcDbDxfConverter.prototype.processEntities = function (dxf, db, minimumChunkSize, startPercentage, progress) {
292
+ return __awaiter(this, void 0, void 0, function () {
293
+ var converter, entities, entityCount, batchProcessor, attributeMap, i, entity, dbEntity, attributes, modelSpaceBlockTableRecord;
294
+ var _this = this;
295
+ return __generator(this, function (_a) {
296
+ switch (_a.label) {
297
+ case 0:
298
+ converter = new AcDbEntityConverter();
299
+ entities = dxf.entities;
300
+ entityCount = entities.length;
301
+ batchProcessor = new AcDbBatchProcessing(entityCount, 100 - startPercentage.value, minimumChunkSize);
302
+ // Groups entities by their `type` property and flattens the result into a single array.
303
+ if (this.config.convertByEntityType) {
304
+ entities = this.groupAndFlattenByType(entities);
305
+ }
306
+ attributeMap = new Map();
307
+ for (i = 0; i < entityCount; i++) {
308
+ entity = entities[i];
309
+ if (entity.type === 'ATTRIB') {
310
+ dbEntity = converter.convert(entity);
311
+ if (dbEntity && dbEntity.ownerId && dbEntity.ownerId !== '0') {
312
+ attributes = attributeMap.get(dbEntity === null || dbEntity === void 0 ? void 0 : dbEntity.ownerId);
313
+ if (attributes == null) {
314
+ attributes = [];
315
+ attributeMap.set(dbEntity.ownerId, attributes);
316
+ }
317
+ attributes.push(dbEntity);
318
+ }
319
+ }
320
+ }
321
+ modelSpaceBlockTableRecord = db.tables.blockTable.modelSpace;
322
+ return [4 /*yield*/, batchProcessor.processChunk(function (start, end) { return __awaiter(_this, void 0, void 0, function () {
323
+ var dbEntities, entityType, _loop_1, this_1, i, percentage;
324
+ return __generator(this, function (_a) {
325
+ switch (_a.label) {
326
+ case 0:
327
+ dbEntities = [];
328
+ entityType = start < end ? entities[start].type : '';
329
+ _loop_1 = function (i) {
330
+ var entity = entities[i];
331
+ if (entity.ownerBlockRecordSoftId &&
332
+ entity.ownerBlockRecordSoftId !== modelSpaceBlockTableRecord.objectId) {
333
+ return "continue";
334
+ }
335
+ if (entity.type !== 'ATTRIB') {
336
+ var dbEntity_1 = converter.convert(entity);
337
+ if (dbEntity_1) {
338
+ if (this_1.config.convertByEntityType && entity.type !== entityType) {
339
+ modelSpaceBlockTableRecord.appendEntity(dbEntities);
340
+ dbEntities = [];
341
+ entityType = entity.type;
342
+ }
343
+ if (entity.type === 'INSERT') {
344
+ var attributes = attributeMap.get(dbEntity_1.objectId);
345
+ if (attributes && attributes.length > 0) {
346
+ attributes.forEach(function (attribute) {
347
+ ;
348
+ dbEntity_1.appendAttributes(attribute);
349
+ });
350
+ }
351
+ }
352
+ dbEntities.push(dbEntity_1);
353
+ }
354
+ }
355
+ };
356
+ this_1 = this;
357
+ for (i = start; i < end; i++) {
358
+ _loop_1(i);
359
+ }
360
+ // Use batch append to improve performance
361
+ modelSpaceBlockTableRecord.appendEntity(dbEntities);
362
+ percentage = startPercentage.value +
363
+ (end / entityCount) * (100 - startPercentage.value);
364
+ if (percentage > 100)
365
+ percentage = 100;
366
+ if (!progress) return [3 /*break*/, 2];
367
+ return [4 /*yield*/, progress(percentage, 'ENTITY', 'IN-PROGRESS')];
368
+ case 1:
369
+ _a.sent();
370
+ _a.label = 2;
371
+ case 2: return [2 /*return*/];
372
+ }
373
+ });
374
+ }); })];
375
+ case 1:
376
+ _a.sent();
377
+ return [2 /*return*/];
378
+ }
379
+ });
380
+ });
381
+ };
382
+ /**
383
+ * Processes entities within a specific block.
384
+ *
385
+ * This method handles the conversion and addition of entities to a specific
386
+ * block table record.
387
+ *
388
+ * @param entities - Array of DXF entities to process
389
+ * @param blockTableRecord - The block table record to use
390
+ * @param checkOwner - The flag whether to check the owner of entity is the passed
391
+ * blockTableRecord. If yes, convert it and append it to the block table record.
392
+ * Otherwise, ignore the entity.
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * await converter.processEntitiesInBlock(entities, blockRecord);
397
+ * ```
398
+ */
399
+ AcDbDxfConverter.prototype.processEntitiesInBlock = function (entities_1, blockTableRecord_1) {
400
+ return __awaiter(this, arguments, void 0, function (entities, blockTableRecord, checkOwner) {
401
+ var converter, entityCount, dbEntities, btrId, attributes, i, entity, dbEntity;
402
+ if (checkOwner === void 0) { checkOwner = false; }
403
+ return __generator(this, function (_a) {
404
+ converter = new AcDbEntityConverter();
405
+ entityCount = entities.length;
406
+ dbEntities = [];
407
+ btrId = blockTableRecord.objectId;
408
+ attributes = [];
409
+ for (i = 0; i < entityCount; i++) {
410
+ entity = entities[i];
411
+ dbEntity = converter.convert(entity);
412
+ if (dbEntity) {
413
+ if (entity.type === 'ATTRIB') {
414
+ attributes.push(dbEntity);
415
+ }
416
+ else if (!checkOwner || entity.ownerBlockRecordSoftId === btrId) {
417
+ dbEntities.push(dbEntity);
418
+ }
419
+ }
420
+ }
421
+ // Use batch append to improve performance
422
+ blockTableRecord.appendEntity(dbEntities);
423
+ attributes.forEach(function (attribute) {
424
+ var owner = blockTableRecord.getIdAt(attribute.ownerId);
425
+ if (owner) {
426
+ owner.appendAttributes(attribute);
427
+ }
428
+ });
429
+ return [2 /*return*/];
430
+ });
431
+ });
432
+ };
433
+ /**
434
+ * Processes blocks defined in the DXF file.
435
+ *
436
+ * This method iterates through all blocks in the DXF data and creates
437
+ * corresponding AcDbBlockTableRecord objects in the database.
438
+ *
439
+ * @param model - Parsed DXF model containing block definitions
440
+ * @param db - Target database to add blocks to
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * converter.processBlocks(parsedDxf, database);
445
+ * ```
446
+ */
447
+ AcDbDxfConverter.prototype.processBlocks = function (model, db) {
448
+ var e_1, _a;
449
+ var blocks = model.blocks;
450
+ try {
451
+ for (var _b = __values(Object.entries(blocks)), _c = _b.next(); !_c.done; _c = _b.next()) {
452
+ var _d = __read(_c.value, 2), name_1 = _d[0], block = _d[1];
453
+ var dbBlock = db.tables.blockTable.getAt(block.name);
454
+ if (!dbBlock) {
455
+ dbBlock = new AcDbBlockTableRecord();
456
+ if (block.handle != null) {
457
+ dbBlock.objectId = String(block.handle);
458
+ }
459
+ // dbBlock.ownerId = block.ownerHandle
460
+ dbBlock.name = name_1;
461
+ dbBlock.origin.copy(block.position);
462
+ db.tables.blockTable.add(dbBlock);
463
+ }
464
+ if (block.entities) {
465
+ // Process entities in user-defined blocks
466
+ this.processEntitiesInBlock(block.entities, dbBlock);
467
+ }
468
+ else {
469
+ // Process paper space block definiton. Entities in model space are
470
+ // handled in method processEntities
471
+ if (dbBlock.isPaperSapce) {
472
+ this.processEntitiesInBlock(model.entities, dbBlock, true);
473
+ }
474
+ }
475
+ }
476
+ }
477
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
478
+ finally {
479
+ try {
480
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
481
+ }
482
+ finally { if (e_1) throw e_1.error; }
483
+ }
484
+ };
485
+ /**
486
+ * Processes header variables from the DXF file.
487
+ *
488
+ * This method extracts and sets various header variables such as color settings,
489
+ * angle base, angle direction, units, and point display settings.
490
+ *
491
+ * @param model - Parsed DXF model containing header information
492
+ * @param db - Target database to set header variables on
493
+ *
494
+ * @example
495
+ * ```typescript
496
+ * converter.processHeader(parsedDxf, database);
497
+ * ```
498
+ */
499
+ AcDbDxfConverter.prototype.processHeader = function (model, db) {
500
+ var _a;
501
+ var header = model.header;
502
+ if (header['$ACADVER']) {
503
+ db.version = header['$ACADVER'];
504
+ }
505
+ // Color index 256 is 'ByLayer'
506
+ db.cecolor.colorIndex = header['$CECOLOR'] || 256;
507
+ db.angbase = header['$ANGBASE'] || 0;
508
+ db.angdir = header['$ANGDIR'] || 0;
509
+ if (header['$AUNITS'] != null)
510
+ db.aunits = header['$AUNITS'];
511
+ if (header['$AUPREC'] != null)
512
+ db.auprec = header['$AUPREC'];
513
+ if (header['$LUNITS'] != null)
514
+ db.lunits = header['$LUNITS'];
515
+ if (header['$LUPREC'] != null)
516
+ db.luprec = header['$LUPREC'];
517
+ if (header['$UNITMODE'] != null)
518
+ db.unitmode = header['$UNITMODE'];
519
+ if (header['$MEASUREMENT'] != null)
520
+ db.measurement = header['$MEASUREMENT'];
521
+ db.celtype = header['$CELTYPE'] || ByLayer;
522
+ AcDbSysVarManager.instance().setVar(AcDbSystemVariables.CETRANSPARENCY, header['$CETRANSPARENCY'] || 'ByLayer', db);
523
+ db.celtscale = header['$CELTSCALE'] || 1;
524
+ var cmlStyle = this.normalizeHeaderStringValue(header['$CMLSTYLE']) ||
525
+ this.normalizeHeaderStringValue(header['CMLSTYLE']) ||
526
+ DEFAULT_MLINE_STYLE;
527
+ db.cmlstyle = cmlStyle;
528
+ var cmlScale = (_a = header['$CMLSCALE']) !== null && _a !== void 0 ? _a : header['CMLSCALE'];
529
+ if (typeof cmlScale === 'number' && Number.isFinite(cmlScale)) {
530
+ db.cmlscale = cmlScale;
531
+ }
532
+ var cmleaderStyle = this.normalizeHeaderStringValue(header['$CMLEADERSTYLE']) ||
533
+ this.normalizeHeaderStringValue(header['CMLEADERSTYLE']) ||
534
+ DEFAULT_MLEADER_STYLE;
535
+ db.cmleaderstyle = cmleaderStyle;
536
+ // db.hpcolor = this.parseHpColor(
537
+ // this.normalizeHeaderStringValue(header['$HPCOLOR']) ||
538
+ // this.normalizeHeaderStringValue(header['HPCOLOR']),
539
+ // db.cecolor
540
+ // )
541
+ // db.hpbackgroundcolor = this.parseHpBackgroundColor(
542
+ // this.normalizeHeaderStringValue(header['$HPBACKGROUNDCOLOR']) ||
543
+ // this.normalizeHeaderStringValue(header['HPBACKGROUNDCOLOR'])
544
+ // )
545
+ db.hplayer =
546
+ this.normalizeHeaderStringValue(header['$HPLAYER']) ||
547
+ this.normalizeHeaderStringValue(header['HPLAYER']) ||
548
+ '.';
549
+ // db.hptransparency = this.parseHpTransparency(
550
+ // this.normalizeHeaderStringValue(header['$HPTRANSPARENCY']) ||
551
+ // this.normalizeHeaderStringValue(header['HPTRANSPARENCY'])
552
+ // )
553
+ db.ltscale = header['$LTSCALE'] || 1;
554
+ if (header['$EXTMAX'])
555
+ db.extmax = header['$EXTMAX'];
556
+ if (header['$EXTMIN'])
557
+ db.extmin = header['$EXTMIN'];
558
+ if (header['$INSUNITS'] != null)
559
+ db.insunits = header['$INSUNITS'];
560
+ db.osmode = header['$OSMODE'] || 0;
561
+ db.orthomode = header['$ORTHOMODE'] || 0;
562
+ db.pdmode = header['$PDMODE'] || 0;
563
+ db.pdsize = header['$PDSIZE'] || 0.0;
564
+ db.textstyle = header['$TEXTSTYLE'] || DEFAULT_TEXT_STYLE;
565
+ };
566
+ /**
567
+ * Processes block table records from the DXF file.
568
+ *
569
+ * This method creates AcDbBlockTableRecord objects for each block record
570
+ * defined in the DXF tables section.
571
+ *
572
+ * @param dxf - Parsed DXF data
573
+ * @param db - Target database to add block table records to
574
+ *
575
+ * @example
576
+ * ```typescript
577
+ * converter.processBlockTables(parsedDxf, database);
578
+ * ```
579
+ */
580
+ AcDbDxfConverter.prototype.processBlockTables = function (dxf, db) {
581
+ var _a;
582
+ var btrs = (_a = dxf.tables.BLOCK_RECORD) === null || _a === void 0 ? void 0 : _a.entries;
583
+ if (btrs && btrs.length > 0) {
584
+ db.tables.blockTable.removeAll();
585
+ btrs.forEach(function (btr) {
586
+ var dbBlock = new AcDbBlockTableRecord();
587
+ dbBlock.objectId = btr.handle;
588
+ dbBlock.name = btr.name;
589
+ dbBlock.layoutId = btr.layoutObjects;
590
+ dbBlock.blockInsertUnits = btr.insertionUnits;
591
+ dbBlock.explodability = btr.explodability;
592
+ dbBlock.blockScaling = btr.scalability;
593
+ if (btr.bmpPreview) {
594
+ dbBlock.bmpPreview = btr.bmpPreview;
595
+ }
596
+ db.tables.blockTable.add(dbBlock);
597
+ });
598
+ }
599
+ };
600
+ /**
601
+ * Processes objects defined in the DXF file.
602
+ *
603
+ * This method handles the conversion of DXF objects such as layouts and
604
+ * image definitions into their corresponding AcDb objects.
605
+ *
606
+ * @param model - Parsed DXF model containing object definitions
607
+ * @param db - Target database to add objects to
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * converter.processObjects(parsedDxf, database);
612
+ * ```
613
+ */
614
+ AcDbDxfConverter.prototype.processObjects = function (model, db) {
615
+ var objects = model.objects.byName;
616
+ var objectConverter = new AcDbObjectConverter();
617
+ if ('LAYOUT' in objects) {
618
+ var layoutDict_1 = db.objects.layout;
619
+ objects['LAYOUT'].forEach(function (layout) {
620
+ var dbLayout = objectConverter.convertLayout(layout, model);
621
+ layoutDict_1.setAt(dbLayout.layoutName, dbLayout);
622
+ });
623
+ }
624
+ if ('IMAGEDEF' in objects) {
625
+ var imageDefDict_1 = db.objects.imageDefinition;
626
+ objects['IMAGEDEF'].forEach(function (imageDef) {
627
+ var dbImageDef = objectConverter.convertImageDef(imageDef);
628
+ imageDefDict_1.setAt(dbImageDef.objectId, dbImageDef);
629
+ });
630
+ }
631
+ if ('MLEADERSTYLE' in objects) {
632
+ var mleaderStyleDict_1 = db.objects.mleaderStyle;
633
+ objects['MLEADERSTYLE'].forEach(function (style) {
634
+ var dbStyle = objectConverter.convertMLeaderStyle(style);
635
+ mleaderStyleDict_1.setAt(dbStyle.objectId, dbStyle);
636
+ });
637
+ }
638
+ if ('MLINESTYLE' in objects) {
639
+ var mlineStyleDict_1 = db.objects.mlineStyle;
640
+ objects['MLINESTYLE'].forEach(function (style) {
641
+ var dbStyle = objectConverter.convertMLineStyle(style);
642
+ mlineStyleDict_1.setAt(dbStyle.styleName || dbStyle.objectId, dbStyle);
643
+ });
644
+ }
645
+ };
646
+ /**
647
+ * Processes viewport table records from the DXF file.
648
+ *
649
+ * This method creates AcDbViewportTableRecord objects for each viewport
650
+ * defined in the DXF tables section, including their properties like
651
+ * center, corners, snap settings, and grid settings.
652
+ *
653
+ * @param model - Parsed DXF model containing viewport definitions
654
+ * @param db - Target database to add viewport table records to
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * converter.processViewports(parsedDxf, database);
659
+ * ```
660
+ */
661
+ AcDbDxfConverter.prototype.processViewports = function (model, db) {
662
+ var _this = this;
663
+ var _a;
664
+ var viewportTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.VPORT;
665
+ if (viewportTable) {
666
+ this.processCommonTableAttrs(viewportTable, db.tables.viewportTable);
667
+ var viewports = viewportTable.entries;
668
+ if (viewports && viewports.length > 0) {
669
+ viewports.forEach(function (item) {
670
+ var _a, _b, _c, _d, _e, _f;
671
+ var record = new AcDbViewportTableRecord();
672
+ _this.processCommonTableEntryAttrs(item, record);
673
+ if (item.circleSides) {
674
+ record.circleSides = item.circleSides;
675
+ }
676
+ record.standardFlag = item.standardFlag;
677
+ record.center.copy((_a = item.center) !== null && _a !== void 0 ? _a : VPORT_FALLBACK_CENTER_2D);
678
+ record.lowerLeftCorner.copy((_b = item.lowerLeftCorner) !== null && _b !== void 0 ? _b : VPORT_FALLBACK_LLC);
679
+ record.upperRightCorner.copy((_c = item.upperRightCorner) !== null && _c !== void 0 ? _c : VPORT_FALLBACK_URC);
680
+ if (item.snapBasePoint) {
681
+ record.snapBase.copy(item.snapBasePoint);
682
+ }
683
+ if (item.snapRotationAngle) {
684
+ record.snapAngle = item.snapRotationAngle;
685
+ }
686
+ if (item.snapSpacing) {
687
+ record.snapIncrements.copy(item.snapSpacing);
688
+ }
689
+ if (item.majorGridLines) {
690
+ record.gridMajor = item.majorGridLines;
691
+ }
692
+ if (item.gridSpacing) {
693
+ record.gridIncrements.copy(item.gridSpacing);
694
+ }
695
+ if (item.backgroundObjectId) {
696
+ record.backgroundObjectId = item.backgroundObjectId;
697
+ }
698
+ record.gsView.center.copy((_d = item.center) !== null && _d !== void 0 ? _d : VPORT_FALLBACK_CENTER_2D);
699
+ record.gsView.viewDirectionFromTarget.copy((_e = item.viewDirectionFromTarget) !== null && _e !== void 0 ? _e : VPORT_FALLBACK_VIEW_DIR);
700
+ record.gsView.viewTarget.copy((_f = item.viewTarget) !== null && _f !== void 0 ? _f : VPORT_FALLBACK_VIEW_TARGET);
701
+ if (item.lensLength) {
702
+ record.gsView.lensLength = item.lensLength;
703
+ }
704
+ if (item.frontClippingPlane) {
705
+ record.gsView.frontClippingPlane = item.frontClippingPlane;
706
+ }
707
+ if (item.backClippingPlane) {
708
+ record.gsView.backClippingPlane = item.backClippingPlane;
709
+ }
710
+ if (item.viewHeight) {
711
+ record.gsView.viewHeight = item.viewHeight;
712
+ }
713
+ if (item.aspectRatio != null &&
714
+ Number.isFinite(item.aspectRatio) &&
715
+ item.aspectRatio > 0) {
716
+ record.gsView.aspectRatio = item.aspectRatio;
717
+ }
718
+ if (item.viewTwistAngle) {
719
+ record.gsView.viewTwistAngle = item.viewTwistAngle;
720
+ }
721
+ if (item.frozenLayers) {
722
+ record.gsView.frozenLayers = item.frozenLayers;
723
+ }
724
+ if (item.styleSheet) {
725
+ record.gsView.styleSheet = item.styleSheet;
726
+ }
727
+ if (item.renderMode) {
728
+ record.gsView.renderMode =
729
+ item.renderMode;
730
+ }
731
+ if (item.viewMode) {
732
+ record.gsView.viewMode = item.viewMode;
733
+ }
734
+ if (item.ucsIconSetting) {
735
+ record.gsView.ucsIconSetting = item.ucsIconSetting;
736
+ }
737
+ if (item.ucsOrigin) {
738
+ record.gsView.ucsOrigin.copy(item.ucsOrigin);
739
+ }
740
+ if (item.ucsXAxis) {
741
+ record.gsView.ucsXAxis.copy(item.ucsXAxis);
742
+ }
743
+ if (item.ucsYAxis) {
744
+ record.gsView.ucsYAxis.copy(item.ucsYAxis);
745
+ }
746
+ if (item.orthographicType) {
747
+ record.gsView.orthographicType =
748
+ item.orthographicType;
749
+ }
750
+ if (item.shadePlotSetting) {
751
+ record.gsView.shadePlotSetting = item.shadePlotSetting;
752
+ }
753
+ if (item.shadePlotObjectId) {
754
+ record.gsView.shadePlotObjectId = item.shadePlotObjectId;
755
+ }
756
+ if (item.visualStyleObjectId) {
757
+ record.gsView.visualStyleObjectId = item.visualStyleObjectId;
758
+ }
759
+ if (item.isDefaultLightingOn) {
760
+ record.gsView.isDefaultLightingOn = item.isDefaultLightingOn;
761
+ }
762
+ if (item.defaultLightingType) {
763
+ record.gsView.defaultLightingType =
764
+ item.defaultLightingType;
765
+ }
766
+ if (item.brightness) {
767
+ record.gsView.brightness = item.brightness;
768
+ }
769
+ if (item.contrast) {
770
+ record.gsView.contrast = item.contrast;
771
+ }
772
+ if (item.ambientColor) {
773
+ record.gsView.ambientColor = item.ambientColor;
774
+ }
775
+ db.tables.viewportTable.add(record);
776
+ });
777
+ }
778
+ }
779
+ };
780
+ /**
781
+ * Processes layer table records from the DXF file.
782
+ *
783
+ * This method creates AcDbLayerTableRecord objects for each layer
784
+ * defined in the DXF tables section, including their properties like
785
+ * color, linetype, lineweight, and visibility settings.
786
+ *
787
+ * @param model - Parsed DXF model containing layer definitions
788
+ * @param db - Target database to add layer table records to
789
+ *
790
+ * @example
791
+ * ```typescript
792
+ * converter.processLayers(parsedDxf, database);
793
+ * ```
794
+ */
795
+ AcDbDxfConverter.prototype.processLayers = function (model, db) {
796
+ var _this = this;
797
+ var _a;
798
+ var layerTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.LAYER;
799
+ if (layerTable) {
800
+ this.processCommonTableAttrs(layerTable, db.tables.layerTable);
801
+ var layers = layerTable.entries;
802
+ if (layers && layers.length > 0) {
803
+ layers.forEach(function (item) {
804
+ var color = new AcCmColor();
805
+ color.colorIndex = item.colorIndex;
806
+ var record = new AcDbLayerTableRecord({
807
+ name: item.name,
808
+ standardFlags: item.standardFlag,
809
+ linetype: item.lineType,
810
+ lineWeight: item.lineweight,
811
+ isOff: item.colorIndex < 0,
812
+ color: color,
813
+ isPlottable: item.isPlotting
814
+ });
815
+ _this.processCommonTableEntryAttrs(item, record);
816
+ db.tables.layerTable.add(record);
817
+ });
818
+ }
819
+ }
820
+ };
821
+ /**
822
+ * Processes linetype table records from the DXF file.
823
+ *
824
+ * This method creates AcDbLinetypeTableRecord objects for each linetype
825
+ * defined in the DXF tables section.
826
+ *
827
+ * @param model - Parsed DXF model containing linetype definitions
828
+ * @param db - Target database to add linetype table records to
829
+ *
830
+ * @example
831
+ * ```typescript
832
+ * converter.processLineTypes(parsedDxf, database);
833
+ * ```
834
+ */
835
+ AcDbDxfConverter.prototype.processLineTypes = function (model, db) {
836
+ var _this = this;
837
+ var _a;
838
+ var lineTypeTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.LTYPE;
839
+ if (lineTypeTable) {
840
+ this.processCommonTableAttrs(lineTypeTable, db.tables.linetypeTable);
841
+ var lineTypes = lineTypeTable.entries;
842
+ if (lineTypes && lineTypes.length > 0) {
843
+ lineTypes.forEach(function (item) {
844
+ var record = new AcDbLinetypeTableRecord(item);
845
+ _this.processCommonTableEntryAttrs(item, record);
846
+ record.name = item.name;
847
+ db.tables.linetypeTable.add(record);
848
+ });
849
+ }
850
+ }
851
+ };
852
+ /**
853
+ * Processes text style table records from the DXF file.
854
+ *
855
+ * This method creates AcDbTextStyleTableRecord objects for each text style
856
+ * defined in the DXF tables section.
857
+ *
858
+ * @param model - Parsed DXF model containing text style definitions
859
+ * @param db - Target database to add text style table records to
860
+ *
861
+ * @example
862
+ * ```typescript
863
+ * converter.processTextStyles(parsedDxf, database);
864
+ * ```
865
+ */
866
+ AcDbDxfConverter.prototype.processTextStyles = function (model, db) {
867
+ var _this = this;
868
+ var _a;
869
+ var textStyleTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.STYLE;
870
+ if (textStyleTable) {
871
+ this.processCommonTableAttrs(textStyleTable, db.tables.textStyleTable);
872
+ var textStyles = textStyleTable.entries;
873
+ if (textStyles && textStyles.length > 0) {
874
+ textStyles.forEach(function (item) {
875
+ var record = new AcDbTextStyleTableRecord(item);
876
+ _this.processCommonTableEntryAttrs(item, record);
877
+ db.tables.textStyleTable.add(record);
878
+ });
879
+ }
880
+ }
881
+ db.ensureTextStyleDefaults();
882
+ };
883
+ /**
884
+ * Processes dimension style table records from the DXF file.
885
+ *
886
+ * This method creates AcDbDimStyleTableRecord objects for each dimension style
887
+ * defined in the DXF tables section, including all dimension-related properties
888
+ * like text positioning, arrow settings, and tolerance settings.
889
+ *
890
+ * @param model - Parsed DXF model containing dimension style definitions
891
+ * @param db - Target database to add dimension style table records to
892
+ *
893
+ * @example
894
+ * ```typescript
895
+ * converter.processDimStyles(parsedDxf, database);
896
+ * ```
897
+ */
898
+ AcDbDxfConverter.prototype.processDimStyles = function (model, db) {
899
+ var _this = this;
900
+ var _a;
901
+ var dimStyleTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.DIMSTYLE;
902
+ if (dimStyleTable) {
903
+ this.processCommonTableAttrs(dimStyleTable, db.tables.dimStyleTable);
904
+ var dimStyles = dimStyleTable.entries;
905
+ if (dimStyles && dimStyles.length > 0) {
906
+ dimStyles.forEach(function (item) {
907
+ var attrs = {
908
+ name: item.name,
909
+ ownerId: item.ownerObjectId,
910
+ dimpost: item.DIMPOST || '',
911
+ dimapost: item.DIMAPOST || '',
912
+ dimscale: item.DIMSCALE,
913
+ dimasz: item.DIMASZ,
914
+ dimexo: item.DIMEXO,
915
+ dimdli: item.DIMDLI,
916
+ dimexe: item.DIMEXE,
917
+ dimrnd: item.DIMRND,
918
+ dimdle: item.DIMDLE,
919
+ dimtp: item.DIMTP,
920
+ dimtm: item.DIMTM,
921
+ dimtxt: item.DIMTXT,
922
+ dimcen: item.DIMCEN,
923
+ dimtsz: item.DIMTSZ,
924
+ dimaltf: item.DIMALTF,
925
+ dimlfac: item.DIMLFAC,
926
+ dimtvp: item.DIMTVP,
927
+ dimtfac: item.DIMTFAC,
928
+ dimgap: item.DIMGAP,
929
+ dimaltrnd: item.DIMALTRND,
930
+ dimtol: item.DIMTOL == null || item.DIMTOL == 0 ? 0 : 1,
931
+ dimlim: item.DIMLIM == null || item.DIMLIM == 0 ? 0 : 1,
932
+ dimtih: item.DIMTIH == null || item.DIMTIH == 0 ? 0 : 1,
933
+ dimtoh: item.DIMTOH == null || item.DIMTOH == 0 ? 0 : 1,
934
+ dimse1: item.DIMSE1 == null || item.DIMSE1 == 0 ? 0 : 1,
935
+ dimse2: item.DIMSE2 == null || item.DIMSE2 == 0 ? 0 : 1,
936
+ dimtad: item.DIMTAD,
937
+ dimzin: item.DIMZIN,
938
+ dimazin: item.DIMAZIN,
939
+ dimalt: item.DIMALT,
940
+ dimaltd: item.DIMALTD,
941
+ dimtofl: item.DIMTOFL,
942
+ dimsah: item.DIMSAH,
943
+ dimtix: item.DIMTIX,
944
+ dimsoxd: item.DIMSOXD,
945
+ dimclrd: item.DIMCLRD,
946
+ dimclre: item.DIMCLRE,
947
+ dimclrt: item.DIMCLRT,
948
+ dimadec: item.DIMADEC || 0,
949
+ dimunit: item.DIMUNIT || 2,
950
+ dimdec: item.DIMDEC,
951
+ dimtdec: item.DIMTDEC,
952
+ dimaltu: item.DIMALTU,
953
+ dimalttd: item.DIMALTTD,
954
+ dimaunit: item.DIMAUNIT,
955
+ dimfrac: item.DIMFRAC,
956
+ dimlunit: item.DIMLUNIT,
957
+ dimdsep: item.DIMDSEP ? item.DIMDSEP.toString() : '.',
958
+ dimtmove: item.DIMTMOVE || 0,
959
+ dimjust: item.DIMJUST,
960
+ dimsd1: item.DIMSD1,
961
+ dimsd2: item.DIMSD2,
962
+ dimtolj: item.DIMTOLJ,
963
+ dimtzin: item.DIMTZIN,
964
+ dimaltz: item.DIMALTZ,
965
+ dimalttz: item.DIMALTTZ,
966
+ dimfit: item.DIMFIT || 0,
967
+ dimupt: item.DIMUPT,
968
+ dimatfit: item.DIMATFIT,
969
+ dimtxsty: item.DIMTXSTY || DEFAULT_TEXT_STYLE,
970
+ dimldrblk: item.DIMLDRBLK || '',
971
+ dimblk: item.DIMBLK || '',
972
+ dimblk1: item.DIMBLK1 || '',
973
+ dimblk2: item.DIMBLK2 || '',
974
+ dimlwd: item.DIMLWD,
975
+ dimlwe: item.DIMLWE
976
+ };
977
+ var record = new AcDbDimStyleTableRecord(attrs);
978
+ _this.processCommonTableEntryAttrs(item, record);
979
+ db.tables.dimStyleTable.add(record);
980
+ });
981
+ }
982
+ }
983
+ };
984
+ AcDbDxfConverter.prototype.processCommonTableAttrs = function (table, dbTable) {
985
+ if (table.handle != null) {
986
+ dbTable.objectId = table.handle;
987
+ }
988
+ if (table.ownerObjectId != null) {
989
+ dbTable.ownerId = table.ownerObjectId;
990
+ }
991
+ };
992
+ /**
993
+ * Processes common table entry attributes from DXF data.
994
+ *
995
+ * This helper method sets the common attributes (name, objectId, ownerId)
996
+ * that are shared across all table entries.
997
+ *
998
+ * @param entry - DXF table entry containing the source data
999
+ * @param dbEntry - AcDbSymbolTableRecord to populate with the data
1000
+ *
1001
+ * @example
1002
+ * ```typescript
1003
+ * converter.processCommonTableEntryAttrs(dxfEntry, dbRecord);
1004
+ * ```
1005
+ */
1006
+ AcDbDxfConverter.prototype.processCommonTableEntryAttrs = function (entry, dbEntry) {
1007
+ dbEntry.name = 'name' in entry ? entry.name : '';
1008
+ // All of objects in drawing database should have handle. However, some VPORT objects in DXF file
1009
+ // don't have handle. In this time, just use objectId created in constructor of AcDbObject.
1010
+ // https://github.com/mlightcad/cad-viewer/issues/101
1011
+ if (entry.handle != null)
1012
+ dbEntry.objectId = entry.handle;
1013
+ if (entry.ownerObjectId != null) {
1014
+ dbEntry.ownerId = entry.ownerObjectId;
1015
+ }
1016
+ };
1017
+ /**
1018
+ * Groups entities by their `type` property and flattens the result into a single array.
1019
+ *
1020
+ * The order of `type` groups follows the order in which they first appear in the input array.
1021
+ * Items within each group preserve their original order.
1022
+ *
1023
+ * This runs in O(n) time, which is generally faster than sorting when you
1024
+ * don't care about alphabetical order of types.
1025
+ *
1026
+ * @param entities - The array of entities to group and flatten.
1027
+ *
1028
+ * @returns A new array of entities grouped by their `type` property.
1029
+ */
1030
+ AcDbDxfConverter.prototype.groupAndFlattenByType = function (entities) {
1031
+ var e_2, _a;
1032
+ var groups = {};
1033
+ var order = [];
1034
+ try {
1035
+ for (var entities_1 = __values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
1036
+ var entity = entities_1_1.value;
1037
+ if (!groups[entity.type]) {
1038
+ groups[entity.type] = [];
1039
+ order.push(entity.type);
1040
+ }
1041
+ groups[entity.type].push(entity);
1042
+ }
1043
+ }
1044
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1045
+ finally {
1046
+ try {
1047
+ if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
1048
+ }
1049
+ finally { if (e_2) throw e_2.error; }
1050
+ }
1051
+ return order.flatMap(function (type) { return groups[type]; });
1052
+ };
1053
+ AcDbDxfConverter.prototype.normalizeHeaderStringValue = function (value) {
1054
+ if (typeof value !== 'string')
1055
+ return undefined;
1056
+ var trimmed = value.trim();
1057
+ return trimmed.length > 0 ? trimmed : undefined;
1058
+ };
1059
+ return AcDbDxfConverter;
1060
+ }(AcDbDatabaseConverter));
1061
+ export { AcDbDxfConverter };
1062
+ //# sourceMappingURL=AcDbDxfConverter.js.map