@mlightcad/libredwg-converter 3.5.22 → 3.5.24

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.
@@ -1,4 +1,4 @@
1
- import { AcDbFace as v, AcDbArc as O, AcGeVector3d as D, AcDbCircle as m, AcDbEllipse as k, AcDbLine as F, AcGePoint3d as w, AcDbSpline as T, AcDbPoint as R, AcDbTrace as V, AcDbPolyline as N, AcGePoint2d as b, AcDbPolygonMesh as B, AcDbPolyFaceMesh as z, AcDbPoly2dType as A, AcDb2dPolyline as j, AcDbPoly3dType as y, AcDb3dPolyline as W, AcDbHatch as H, AcGePolyline2d as X, AcGeLine2d as U, AcGeCircArc2d as G, AcGeVector2d as Y, AcGeEllipseArc2d as _, AcGeSpline3d as P, AcGeLoop2d as E, AcDbTable as Z, AcDbText as K, AcDbMText as q, AcDbLeader as J, AcDbAlignedDimension as Q, AcDb3PointAngularDimension as $, AcDbOrdinateDimension as ee, AcDbRadialDimension as ne, AcDbDiametricDimension as oe, AcDbRasterImage as te, AcDbWipeout as se, AcDbViewport as re, AcDbRay as ie, AcDbXline as ce, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as M, AcDbAttribute as ae, AcDbAttributeDefinition as le, AcDbBlockReference as de, AcCmTransparency as pe, AcDbDatabaseConverter as ue, createWorkerApi as fe, AcDbLinetypeTableRecord as he, AcDbTextStyleTableRecord as ge, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as De, AcCmColor as Ae, AcDbLayerTableRecord as Ie, AcDbViewportTableRecord as ye, AcDbBlockTableRecord as we, AcDbBatchProcessing as Te, ByLayer as be, AcDbLayout as Pe, AcDbRasterImageDef as Ee } from "@mlightcad/data-model";
1
+ import { AcDbFace as v, AcDbArc as O, AcGeVector3d as D, AcDbCircle as m, AcDbEllipse as k, AcDbLine as R, AcGePoint3d as w, AcDbSpline as T, AcDbPoint as F, AcDbTrace as V, AcDbPolyline as N, AcGePoint2d as b, AcDbPolygonMesh as B, AcDbPolyFaceMesh as z, AcDbPoly2dType as A, AcDb2dPolyline as j, AcDbPoly3dType as y, AcDb3dPolyline as W, AcDbHatch as H, AcGePolyline2d as X, AcGeLine2d as U, AcGeCircArc2d as G, AcGeVector2d as Y, AcGeEllipseArc2d as _, AcGeSpline3d as P, AcGeLoop2d as E, AcDbTable as Z, AcDbText as K, AcDbMText as q, AcDbLeader as J, AcDbAlignedDimension as Q, AcDbRotatedDimension as $, AcDb3PointAngularDimension as ee, AcDbOrdinateDimension as ne, AcDbRadialDimension as oe, AcDbDiametricDimension as te, AcDbRasterImage as se, AcDbWipeout as re, AcDbViewport as ie, AcDbRay as ce, AcDbXline as le, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as M, AcDbAttribute as ae, AcDbAttributeDefinition as de, AcDbBlockReference as pe, AcCmTransparency as ue, AcDbDatabaseConverter as fe, createWorkerApi as he, AcDbLinetypeTableRecord as ge, AcDbTextStyleTableRecord as De, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as Ae, AcCmColor as Ie, AcDbLayerTableRecord as ye, AcDbViewportTableRecord as we, AcDbBlockTableRecord as Te, AcDbBatchProcessing as be, ByLayer as Pe, AcDbLayout as Ee, AcDbRasterImageDef as Me } from "@mlightcad/data-model";
2
2
  class C {
3
3
  convert(e) {
4
4
  const n = this.createEntity(e);
@@ -28,22 +28,22 @@ class C {
28
28
  );
29
29
  }
30
30
  convertEllipse(e) {
31
- const n = new D(e.majorAxisEndPoint), s = n.length();
31
+ const n = new D(e.majorAxisEndPoint), t = n.length();
32
32
  return new k(
33
33
  e.center,
34
34
  e.extrusionDirection ?? D.Z_AXIS,
35
35
  n,
36
- s,
37
- s * e.axisRatio,
36
+ t,
37
+ t * e.axisRatio,
38
38
  e.startAngle,
39
39
  e.endAngle
40
40
  );
41
41
  }
42
42
  convertLine(e) {
43
- const n = e.startPoint, s = e.endPoint;
44
- return new F(
43
+ const n = e.startPoint, t = e.endPoint;
44
+ return new R(
45
45
  new w(n.x, n.y, n.z),
46
- new w(s.x, s.y, s.z)
46
+ new w(t.x, t.y, t.z)
47
47
  );
48
48
  }
49
49
  convertSpline(e) {
@@ -68,7 +68,7 @@ class C {
68
68
  return null;
69
69
  }
70
70
  convertPoint(e) {
71
- const n = new R();
71
+ const n = new F();
72
72
  return n.position = e.position, n;
73
73
  }
74
74
  convertSolid(e) {
@@ -81,19 +81,19 @@ class C {
81
81
  convertLWPolyline(e) {
82
82
  const n = new N();
83
83
  n.closed = !!(e.flag & 512);
84
- const s = e.constantWidth ?? -1;
85
- return e.vertices.forEach((o, t) => {
84
+ const t = e.constantWidth ?? -1;
85
+ return e.vertices.forEach((o, s) => {
86
86
  n.addVertexAt(
87
- t,
87
+ s,
88
88
  new b(o.x, o.y),
89
89
  o.bulge,
90
- o.startWidth ?? s,
91
- o.endWidth ?? s
90
+ o.startWidth ?? t,
91
+ o.endWidth ?? t
92
92
  );
93
93
  }), n;
94
94
  }
95
95
  convertPolyline2d(e) {
96
- const n = !!(e.flag & 1), s = !!(e.flag & 16), o = !!(e.flag & 64), t = !!(e.flag & 32), r = [], l = [], c = [];
96
+ const n = !!(e.flag & 1), t = !!(e.flag & 16), o = !!(e.flag & 64), s = !!(e.flag & 32), r = [], a = [], c = [];
97
97
  if (e.vertices.map((i) => {
98
98
  if (!(i.flag & 16))
99
99
  if (o && i.flag & 128)
@@ -102,7 +102,7 @@ class C {
102
102
  x: i.x,
103
103
  y: i.y,
104
104
  z: i.z
105
- }), l.push(i.bulge ?? 0);
105
+ }), a.push(i.bulge ?? 0);
106
106
  else {
107
107
  const d = [];
108
108
  i.polyfaceIndex0 != null && i.polyfaceIndex0 != 0 && d.push(Math.abs(i.polyfaceIndex0) - 1), i.polyfaceIndex1 != null && i.polyfaceIndex1 != 0 && d.push(Math.abs(i.polyfaceIndex1) - 1), i.polyfaceIndex2 != null && i.polyfaceIndex2 != 0 && d.push(Math.abs(i.polyfaceIndex2) - 1), i.polyfaceIndex3 != null && i.polyfaceIndex3 != 0 && d.push(Math.abs(i.polyfaceIndex3) - 1), d.length >= 3 && c.push(d);
@@ -112,10 +112,10 @@ class C {
112
112
  x: i.x,
113
113
  y: i.y,
114
114
  z: i.z
115
- }), l.push(i.bulge ?? 0);
116
- }), s) {
115
+ }), a.push(i.bulge ?? 0);
116
+ }), t) {
117
117
  const i = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
118
- return new B(i, d, r, n, t);
118
+ return new B(i, d, r, n, s);
119
119
  } else {
120
120
  if (o)
121
121
  return new z(r, c);
@@ -128,37 +128,37 @@ class C {
128
128
  n,
129
129
  e.startWidth,
130
130
  e.endWidth,
131
- l
131
+ a
132
132
  );
133
133
  }
134
134
  }
135
135
  }
136
136
  convertPolyline3d(e) {
137
- const n = !!(e.flag & 1), s = [];
138
- e.vertices.map((t) => {
139
- t.flag & 16 || s.push({
140
- x: t.x,
141
- y: t.y,
142
- z: t.z
137
+ const n = !!(e.flag & 1), t = [];
138
+ e.vertices.map((s) => {
139
+ s.flag & 16 || t.push({
140
+ x: s.x,
141
+ y: s.y,
142
+ z: s.z
143
143
  });
144
144
  });
145
145
  let o = y.SimplePoly;
146
- return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new W(o, s, n);
146
+ return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new W(o, t, n);
147
147
  }
148
148
  convertHatch(e) {
149
149
  var o;
150
150
  const n = new H();
151
- return (o = e.definitionLines) == null || o.forEach((t) => {
151
+ return (o = e.definitionLines) == null || o.forEach((s) => {
152
152
  n.definitionLines.push({
153
- angle: t.angle,
154
- base: t.base,
155
- offset: t.offset,
156
- dashLengths: t.numberOfDashLengths > 0 ? t.dashLengths : []
153
+ angle: s.angle,
154
+ base: s.base,
155
+ offset: s.offset,
156
+ dashLengths: s.numberOfDashLengths > 0 ? s.dashLengths : []
157
157
  });
158
- }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((t) => {
159
- if (t.boundaryPathTypeFlag & 2) {
160
- const l = t, c = new X();
161
- c.closed = l.isClosed, l.vertices.forEach((i, d) => {
158
+ }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((s) => {
159
+ if (s.boundaryPathTypeFlag & 2) {
160
+ const a = s, c = new X();
161
+ c.closed = a.isClosed, a.vertices.forEach((i, d) => {
162
162
  c.addVertexAt(d, {
163
163
  x: i.x,
164
164
  y: i.y,
@@ -166,46 +166,46 @@ class C {
166
166
  });
167
167
  }), n.add(c);
168
168
  } else {
169
- const l = t, c = [];
170
- l.edges.forEach((d) => {
169
+ const a = s, c = [];
170
+ a.edges.forEach((d) => {
171
171
  if (d != null) {
172
172
  if (d.type == 1) {
173
- const a = d;
174
- c.push(new U(a.start, a.end));
173
+ const l = d;
174
+ c.push(new U(l.start, l.end));
175
175
  } else if (d.type == 2) {
176
- const a = d;
176
+ const l = d;
177
177
  c.push(
178
178
  new G(
179
- a.center,
180
- a.radius,
181
- a.startAngle,
182
- a.endAngle,
183
- !a.isCCW
179
+ l.center,
180
+ l.radius,
181
+ l.startAngle,
182
+ l.endAngle,
183
+ !l.isCCW
184
184
  )
185
185
  );
186
186
  } else if (d.type == 3) {
187
- const a = d;
188
- new Y().subVectors(a.end, a.center);
187
+ const l = d;
188
+ new Y().subVectors(l.end, l.center);
189
189
  const p = Math.sqrt(
190
- Math.pow(a.end.x, 2) + Math.pow(a.end.y, 2)
191
- ), u = p * a.lengthOfMinorAxis;
192
- let f = a.startAngle, g = a.endAngle;
193
- const x = Math.atan2(a.end.y, a.end.x);
194
- a.isCCW || (f = Math.PI * 2 - f, g = Math.PI * 2 - g), c.push(
190
+ Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
191
+ ), u = p * l.lengthOfMinorAxis;
192
+ let f = l.startAngle, g = l.endAngle;
193
+ const x = Math.atan2(l.end.y, l.end.x);
194
+ l.isCCW || (f = Math.PI * 2 - f, g = Math.PI * 2 - g), c.push(
195
195
  new _(
196
- { ...a.center, z: 0 },
196
+ { ...l.center, z: 0 },
197
197
  p,
198
198
  u,
199
199
  f,
200
200
  g,
201
- !a.isCCW,
201
+ !l.isCCW,
202
202
  x
203
203
  )
204
204
  );
205
205
  } else if (d.type == 4) {
206
- const a = d;
207
- if (a.numberOfControlPoints > 0 && a.numberOfKnots > 0) {
208
- const h = a.controlPoints.map(
206
+ const l = d;
207
+ if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
208
+ const h = l.controlPoints.map(
209
209
  (f) => ({
210
210
  x: f.x,
211
211
  y: f.y,
@@ -213,16 +213,16 @@ class C {
213
213
  })
214
214
  );
215
215
  let p = !0;
216
- const u = a.controlPoints.map((f) => (f.weight == null && (p = !1), f.weight || 1));
216
+ const u = l.controlPoints.map((f) => (f.weight == null && (p = !1), f.weight || 1));
217
217
  c.push(
218
218
  new P(
219
219
  h,
220
- a.knots,
220
+ l.knots,
221
221
  p ? u : void 0
222
222
  )
223
223
  );
224
- } else if (a.numberOfFitData > 0) {
225
- const h = a.fitDatum.map((p) => ({
224
+ } else if (l.numberOfFitData > 0) {
225
+ const h = l.fitDatum.map((p) => ({
226
226
  x: p.x,
227
227
  y: p.y,
228
228
  z: 0
@@ -244,11 +244,11 @@ class C {
244
244
  e.columnCount
245
245
  );
246
246
  return n.tableStyleId = e.tableStyleId, n.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (n.horizontalDirection = new D(e.directionVector)), n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), n.tableValueFlag = e.tableValue, n.tableOverrideFlag = e.overrideFlag, n.borderColorOverrideFlag = e.borderColorOverrideFlag, n.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, n.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
247
- (s, o) => n.setColumnWidth(o, s)
247
+ (t, o) => n.setColumnWidth(o, t)
248
248
  ), e.rowHeightArr.forEach(
249
- (s, o) => n.setRowHeight(o, s)
250
- ), e.cells.forEach((s, o) => {
251
- n.setCell(o, s);
249
+ (t, o) => n.setRowHeight(o, t)
250
+ ), e.cells.forEach((t, o) => {
251
+ n.setCell(o, t);
252
252
  }), n;
253
253
  }
254
254
  convertText(e) {
@@ -261,56 +261,67 @@ class C {
261
261
  }
262
262
  convertLeader(e) {
263
263
  const n = new J();
264
- return e.vertices.forEach((s) => {
265
- n.appendVertex(s);
264
+ return e.vertices.forEach((t) => {
265
+ n.appendVertex(t);
266
266
  }), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
267
267
  }
268
268
  convertDimension(e) {
269
- if (e.subclassMarker == "AcDbAlignedDimension" || e.subclassMarker == "AcDbRotatedDimension") {
270
- const n = e, s = new Q(
269
+ if (e.subclassMarker == "AcDbAlignedDimension") {
270
+ const n = e, t = new Q(
271
271
  n.subDefinitionPoint1,
272
272
  n.subDefinitionPoint2,
273
273
  n.definitionPoint
274
274
  );
275
- return n.insertionPoint && (s.dimBlockPosition = {
275
+ return n.insertionPoint && (t.dimBlockPosition = {
276
276
  x: n.insertionPoint.x,
277
277
  y: n.insertionPoint.y,
278
278
  z: 0
279
- }), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
279
+ }), t.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, t), t;
280
+ } else if (e.subclassMarker == "AcDbRotatedDimension") {
281
+ const n = e, t = new $(
282
+ n.subDefinitionPoint1,
283
+ n.subDefinitionPoint2,
284
+ n.definitionPoint
285
+ );
286
+ return n.insertionPoint && (t.dimBlockPosition = {
287
+ x: n.insertionPoint.x,
288
+ y: n.insertionPoint.y,
289
+ z: 0
290
+ }), t.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, t), t;
280
291
  } else if (e.subclassMarker == "AcDb3PointAngularDimension") {
281
- const n = e, s = new $(
292
+ const n = e, t = new ee(
282
293
  n.centerPoint,
283
294
  n.subDefinitionPoint1,
284
295
  n.subDefinitionPoint2,
285
296
  n.definitionPoint
286
297
  );
287
- return this.processDimensionCommonAttrs(e, s), s;
298
+ return this.processDimensionCommonAttrs(e, t), t;
288
299
  } else if (e.subclassMarker == "AcDbOrdinateDimension") {
289
- const n = e, s = new ee(
300
+ const n = e, t = new ne(
290
301
  n.subDefinitionPoint1,
291
302
  n.subDefinitionPoint2
292
303
  );
293
- return this.processDimensionCommonAttrs(e, s), s;
304
+ return this.processDimensionCommonAttrs(e, t), t;
294
305
  } else if (e.subclassMarker == "AcDbRadialDimension") {
295
- const n = e, s = new ne(
306
+ const n = e, t = new oe(
296
307
  n.definitionPoint,
297
308
  n.centerPoint,
298
309
  n.leaderLength
299
310
  );
300
- return this.processDimensionCommonAttrs(e, s), s;
311
+ return this.processDimensionCommonAttrs(e, t), t;
301
312
  } else if (e.subclassMarker == "AcDbDiametricDimension") {
302
- const n = e, s = new oe(
313
+ const n = e, t = new te(
303
314
  n.definitionPoint,
304
315
  n.centerPoint,
305
316
  n.leaderLength
306
317
  );
307
- return this.processDimensionCommonAttrs(e, s), s;
318
+ return this.processDimensionCommonAttrs(e, t), t;
308
319
  }
309
320
  return null;
310
321
  }
311
322
  processImage(e, n) {
312
- n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((s) => {
313
- n.clipBoundary.push(new b(s));
323
+ n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((t) => {
324
+ n.clipBoundary.push(new b(t));
314
325
  }), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
315
326
  e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
316
327
  ) * e.imageSize.x, n.height = Math.sqrt(
@@ -318,41 +329,41 @@ class C {
318
329
  ) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
319
330
  }
320
331
  convertImage(e) {
321
- const n = new te();
332
+ const n = new se();
322
333
  return this.processImage(e, n), n;
323
334
  }
324
335
  convertWipeout(e) {
325
- const n = new se();
336
+ const n = new re();
326
337
  return this.processImage(e, n), n;
327
338
  }
328
339
  convertViewport(e) {
329
- const n = new re();
340
+ const n = new ie();
330
341
  return n.number = e.viewportId, n.centerPoint.copy(e.viewportCenter), n.height = e.height, n.width = e.width, n.viewCenter.copy(e.displayCenter), n.viewHeight = e.viewHeight, n;
331
342
  }
332
343
  convertRay(e) {
333
- const n = new ie();
344
+ const n = new ce();
334
345
  return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
335
346
  }
336
347
  convertXline(e) {
337
- const n = new ce();
348
+ const n = new le();
338
349
  return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
339
350
  }
340
351
  convertAttributeCommon(e, n) {
341
- const s = e.text;
342
- n.textString = s.text, n.styleName = s.styleName, n.height = s.textHeight, n.position.copy(s.startPoint), n.rotation = s.rotation, n.oblique = s.obliqueAngle ?? 0, n.thickness = s.thickness, n.horizontalMode = s.halign, n.verticalMode = s.valign, n.widthFactor = s.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & M.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & M.ConstMultiLine) !== 0;
352
+ const t = e.text;
353
+ n.textString = t.text, n.styleName = t.styleName, n.height = t.textHeight, n.position.copy(t.startPoint), n.rotation = t.rotation, n.oblique = t.obliqueAngle ?? 0, n.thickness = t.thickness, n.horizontalMode = t.halign, n.verticalMode = t.valign, n.widthFactor = t.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & M.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & M.ConstMultiLine) !== 0;
343
354
  }
344
355
  convertAttribute(e) {
345
356
  const n = new ae();
346
357
  return this.convertAttributeCommon(e, n), n;
347
358
  }
348
359
  convertAttributeDefinition(e) {
349
- const n = new le();
360
+ const n = new de();
350
361
  return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
351
362
  }
352
363
  convertBlockReference(e) {
353
- const n = new de(e.name);
354
- return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((s) => {
355
- const o = this.convertAttribute(s);
364
+ const n = new pe(e.name);
365
+ return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((t) => {
366
+ const o = this.convertAttribute(t);
356
367
  n.appendAttributes(o);
357
368
  }), n;
358
369
  }
@@ -360,26 +371,26 @@ class C {
360
371
  n.dimBlockId = e.name, n.textPosition.copy(e.textPoint), n.textRotation = e.textRotation || 0, e.textLineSpacingFactor && (n.textLineSpacingFactor = e.textLineSpacingFactor), e.textLineSpacingStyle && (n.textLineSpacingStyle = e.textLineSpacingStyle), n.dimensionStyleName = e.styleName, n.dimensionText = e.text || "", n.measurement = e.measurement;
361
372
  }
362
373
  processCommonAttrs(e, n) {
363
- if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
364
- const s = new pe();
365
- s.method = e.transparencyType, (s.isByBlock || s.isByBlock) && (s.alpha = e.transparency), n.transparency = s;
374
+ if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (e.color == null || e.colorIndex === 7) && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
375
+ const t = new ue();
376
+ t.method = e.transparencyType, (t.isByBlock || t.isByBlock) && (t.alpha = e.transparency), n.transparency = t;
366
377
  }
367
378
  }
368
379
  }
369
- const Me = "*MODEL_SPACE";
370
- class Ce extends ue {
380
+ const Le = "*MODEL_SPACE";
381
+ class Se extends fe {
371
382
  constructor(e = {}) {
372
383
  super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
373
384
  }
374
385
  async parse(e, n) {
375
- const s = this.config, o = this.getParserWorkerTimeout(e, n);
376
- if (s.useWorker && s.parserWorkerUrl) {
377
- const t = fe({
378
- workerUrl: s.parserWorkerUrl,
386
+ const t = this.config, o = this.getParserWorkerTimeout(e, n);
387
+ if (t.useWorker && t.parserWorkerUrl) {
388
+ const s = he({
389
+ workerUrl: t.parserWorkerUrl,
379
390
  timeout: o,
380
391
  maxConcurrentWorkers: 1
381
- }), r = await t.execute(e);
382
- if (t.destroy(), r.success)
392
+ }), r = await s.execute(e);
393
+ if (s.destroy(), r.success)
383
394
  return r.data;
384
395
  throw new Error(
385
396
  `Failed to parse drawing due to error: '${r.error}'`
@@ -392,60 +403,60 @@ class Ce extends ue {
392
403
  e.tables.BLOCK_RECORD.entries.forEach((r) => {
393
404
  n.set(r.name, r);
394
405
  });
395
- const s = /* @__PURE__ */ new Map(), o = (r) => {
406
+ const t = /* @__PURE__ */ new Map(), o = (r) => {
396
407
  if (r) {
397
- const l = r.lastIndexOf(".");
398
- return l >= 0 ? r.substring(0, l).toLowerCase() : r.toLowerCase();
408
+ const a = r.lastIndexOf(".");
409
+ return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
399
410
  }
400
411
  };
401
412
  e.tables.STYLE.entries.forEach((r) => {
402
- const l = [];
413
+ const a = [];
403
414
  let c = o(r.font);
404
- c && l.push(c), c = o(r.bigFont), c && l.push(c), s.set(r.name, l);
415
+ c && a.push(c), c = o(r.bigFont), c && a.push(c), t.set(r.name, a);
405
416
  });
406
- const t = /* @__PURE__ */ new Set();
407
- return this.getFontsInBlock(e.entities, n, s, t), Array.from(t);
417
+ const s = /* @__PURE__ */ new Set();
418
+ return this.getFontsInBlock(e.entities, n, t, s), Array.from(s);
408
419
  }
409
- getFontsInBlock(e, n, s, o) {
410
- const t = /\\f(.*?)\|/g;
420
+ getFontsInBlock(e, n, t, o) {
421
+ const s = /\\f(.*?)\|/g;
411
422
  e.forEach((r) => {
412
423
  if (r.type == "MTEXT") {
413
- const l = r;
414
- [...l.text.matchAll(t)].forEach((i) => {
424
+ const a = r;
425
+ [...a.text.matchAll(s)].forEach((i) => {
415
426
  o.add(i[1].toLowerCase());
416
427
  });
417
- const c = s.get(l.styleName);
428
+ const c = t.get(a.styleName);
418
429
  c == null || c.forEach((i) => o.add(i));
419
430
  } else if (r.type == "TEXT") {
420
- const l = r, c = s.get(l.styleName);
431
+ const a = r, c = t.get(a.styleName);
421
432
  c == null || c.forEach((i) => o.add(i));
422
433
  } else if (r.type == "INSERT") {
423
- const l = r, c = n.get(l.name);
424
- c && this.getFontsInBlock(c.entities, n, s, o);
434
+ const a = r, c = n.get(a.name);
435
+ c && this.getFontsInBlock(c.entities, n, t, o);
425
436
  }
426
437
  });
427
438
  }
428
439
  processLineTypes(e, n) {
429
440
  e.tables.LTYPE.entries.forEach((o) => {
430
- const t = {
441
+ const s = {
431
442
  name: o.name,
432
443
  description: o.description,
433
444
  standardFlag: o.standardFlag,
434
445
  totalPatternLength: o.totalPatternLength,
435
446
  pattern: o.pattern
436
- }, r = new he(t);
447
+ }, r = new ge(s);
437
448
  this.processCommonTableEntryAttrs(o, r), r.name = o.name, n.tables.linetypeTable.add(r);
438
449
  });
439
450
  }
440
451
  processTextStyles(e, n) {
441
452
  e.tables.STYLE.entries.forEach((o) => {
442
- const t = new ge(o);
443
- this.processCommonTableEntryAttrs(o, t), n.tables.textStyleTable.add(t);
453
+ const s = new De(o);
454
+ this.processCommonTableEntryAttrs(o, s), n.tables.textStyleTable.add(s);
444
455
  });
445
456
  }
446
457
  processDimStyles(e, n) {
447
458
  e.tables.DIMSTYLE.entries.forEach((o) => {
448
- const t = {
459
+ const s = {
449
460
  name: o.name,
450
461
  ownerId: o.ownerHandle,
451
462
  dimpost: o.DIMPOST || "",
@@ -514,21 +525,21 @@ class Ce extends ue {
514
525
  dimblk2: o.DIMBLK2 || "",
515
526
  dimlwd: o.DIMLWD,
516
527
  dimlwe: o.DIMLWE
517
- }, r = new De(t);
528
+ }, r = new Ae(s);
518
529
  this.processCommonTableEntryAttrs(o, r), n.tables.dimStyleTable.add(r);
519
530
  });
520
531
  }
521
532
  processLayers(e, n) {
522
533
  e.tables.LAYER.entries.forEach((o) => {
523
- const t = new Ae();
524
- t.colorIndex = o.colorIndex;
525
- const r = new Ie({
534
+ const s = new Ie();
535
+ s.colorIndex = o.colorIndex;
536
+ const r = new ye({
526
537
  name: o.name,
527
538
  standardFlags: o.standardFlag,
528
539
  linetype: o.lineType,
529
540
  lineWeight: o.lineweight,
530
541
  isOff: o.off,
531
- color: t,
542
+ color: s,
532
543
  isPlottable: o.plotFlag != 0
533
544
  });
534
545
  this.processCommonTableEntryAttrs(o, r), n.tables.layerTable.add(r);
@@ -536,54 +547,54 @@ class Ce extends ue {
536
547
  }
537
548
  processViewports(e, n) {
538
549
  e.tables.VPORT.entries.forEach((o) => {
539
- const t = new ye();
540
- this.processCommonTableEntryAttrs(o, t), o.circleSides && (t.circleSides = o.circleSides), t.standardFlag = o.standardFlag, t.center.copy(o.center), t.lowerLeftCorner.copy(o.lowerLeftCorner), t.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && t.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (t.snapAngle = o.snapRotationAngle), o.snapSpacing && t.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (t.gridMajor = o.majorGridLines), o.gridSpacing && t.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (t.backgroundObjectId = o.backgroundObjectId), t.gsView.center.copy(o.center), t.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), t.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (t.gsView.lensLength = o.lensLength), o.frontClippingPlane && (t.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (t.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (t.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (t.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (t.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (t.gsView.styleSheet = o.styleSheet), o.renderMode && (t.gsView.renderMode = o.renderMode), o.viewMode && (t.gsView.viewMode = o.viewMode), o.ucsIconSetting && (t.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && t.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && t.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && t.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (t.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (t.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (t.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (t.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (t.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (t.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (t.gsView.brightness = o.brightness), o.contrast && (t.gsView.contrast = o.contrast), o.ambientColor && (t.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(t);
550
+ const s = new we();
551
+ this.processCommonTableEntryAttrs(o, s), o.circleSides && (s.circleSides = o.circleSides), s.standardFlag = o.standardFlag, s.center.copy(o.center), s.lowerLeftCorner.copy(o.lowerLeftCorner), s.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && s.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (s.snapAngle = o.snapRotationAngle), o.snapSpacing && s.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (s.gridMajor = o.majorGridLines), o.gridSpacing && s.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (s.backgroundObjectId = o.backgroundObjectId), s.gsView.center.copy(o.center), s.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), s.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (s.gsView.lensLength = o.lensLength), o.frontClippingPlane && (s.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (s.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (s.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (s.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (s.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (s.gsView.styleSheet = o.styleSheet), o.renderMode && (s.gsView.renderMode = o.renderMode), o.viewMode && (s.gsView.viewMode = o.viewMode), o.ucsIconSetting && (s.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && s.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && s.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && s.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (s.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (s.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (s.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (s.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (s.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (s.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (s.gsView.brightness = o.brightness), o.contrast && (s.gsView.contrast = o.contrast), o.ambientColor && (s.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(s);
541
552
  });
542
553
  }
543
554
  processBlockTables(e, n) {
544
555
  e.tables.BLOCK_RECORD.entries.forEach((o) => {
545
- let t = n.tables.blockTable.getAt(o.name);
546
- t || (t = new we(), t.objectId = o.handle, t.name = o.name, t.ownerId = o.ownerHandle, t.origin.copy(o.basePoint), t.layoutId = o.layout, t.blockInsertUnits = o.insertionUnits, t.explodability = o.explodability, t.blockScaling = o.scalability, o.bmpPreview && (t.bmpPreview = o.bmpPreview), n.tables.blockTable.add(t)), !t.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, t);
556
+ let s = n.tables.blockTable.getAt(o.name);
557
+ s || (s = new Te(), s.objectId = o.handle, s.name = o.name, s.ownerId = o.ownerHandle, s.origin.copy(o.basePoint), s.layoutId = o.layout, s.blockInsertUnits = o.insertionUnits, s.explodability = o.explodability, s.blockScaling = o.scalability, o.bmpPreview && (s.bmpPreview = o.bmpPreview), n.tables.blockTable.add(s)), !s.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, s);
547
558
  });
548
559
  }
549
560
  processBlocks(e, n) {
550
561
  }
551
562
  async processEntitiesInBlock(e, n) {
552
- const s = new C(), o = e.length, t = [];
563
+ const t = new C(), o = e.length, s = [];
553
564
  for (let r = 0; r < o; r++) {
554
- const l = e[r], c = s.convert(l);
555
- c && t.push(c);
565
+ const a = e[r], c = t.convert(a);
566
+ c && s.push(c);
556
567
  }
557
- n.appendEntity(t);
568
+ n.appendEntity(s);
558
569
  }
559
- async processEntities(e, n, s, o, t) {
570
+ async processEntities(e, n, t, o, s) {
560
571
  const r = new C();
561
- let l = [];
562
- e.tables.BLOCK_RECORD.entries.forEach((a) => {
563
- this.isModelSpace(a.name) && (l = a.entities);
572
+ let a = [];
573
+ e.tables.BLOCK_RECORD.entries.forEach((l) => {
574
+ this.isModelSpace(l.name) && (a = l.entities);
564
575
  });
565
- const c = l.length, i = new Te(
576
+ const c = a.length, i = new be(
566
577
  c,
567
578
  100 - o.value,
568
- s
579
+ t
569
580
  );
570
- this.config.convertByEntityType && (l = this.groupAndFlattenByType(l));
581
+ this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
571
582
  const d = n.tables.blockTable.modelSpace;
572
- await i.processChunk(async (a, h) => {
583
+ await i.processChunk(async (l, h) => {
573
584
  const p = [];
574
- for (let u = a; u < h; u++) {
575
- const f = l[u], g = r.convert(f);
585
+ for (let u = l; u < h; u++) {
586
+ const f = a[u], g = r.convert(f);
576
587
  g && p.push(g);
577
588
  }
578
- if (d.appendEntity(p), t) {
589
+ if (d.appendEntity(p), s) {
579
590
  let u = o.value + h / c * (100 - o.value);
580
- u > 100 && (u = 100), await t(u, "ENTITY", "IN-PROGRESS");
591
+ u > 100 && (u = 100), await s(u, "ENTITY", "IN-PROGRESS");
581
592
  }
582
593
  });
583
594
  }
584
595
  processHeader(e, n) {
585
- const s = e.header;
586
- s.CECOLOR && (s.CECOLOR.index >= 0 && s.CECOLOR.index <= 256 ? n.cecolor.colorIndex = s.CECOLOR.index : n.cecolor.setRGBValue(s.CECOLOR.rgb)), n.angBase = s.ANGBASE ?? 0, n.angDir = s.ANGDIR ?? 0, n.aunits = s.AUNITS ?? 0, n.celtype = s.CELTYPE ?? be, n.celtscale = s.CELTSCALE ?? 1, n.ltscale = s.LTSCALE ?? 1, s.EXTMAX && (n.extmax = s.EXTMAX), s.EXTMIN && (n.extmin = s.EXTMIN), n.insunits = s.INSUNITS ?? 1, n.pdmode = s.PDMODE ?? 0, n.pdsize = s.PDSIZE ?? 0, n.textstyle = s.TEXTSTYLE ?? L;
596
+ const t = e.header;
597
+ t.CECOLOR && (t.CECOLOR.index >= 0 && t.CECOLOR.index <= 256 ? n.cecolor.colorIndex = t.CECOLOR.index : n.cecolor.setRGBValue(t.CECOLOR.rgb)), n.angBase = t.ANGBASE ?? 0, n.angDir = t.ANGDIR ?? 0, n.aunits = t.AUNITS ?? 0, n.celtype = t.CELTYPE ?? Pe, n.celtscale = t.CELTSCALE ?? 1, n.ltscale = t.LTSCALE ?? 1, t.EXTMAX && (n.extmax = t.EXTMAX), t.EXTMIN && (n.extmin = t.EXTMIN), n.insunits = t.INSUNITS ?? 1, n.pdmode = t.PDMODE ?? 0, n.pdsize = t.PDSIZE ?? 0, n.textstyle = t.TEXTSTYLE ?? L;
587
598
  }
588
599
  processCommonTableEntryAttrs(e, n) {
589
600
  n.name = e.name, n.objectId = e.handle, n.ownerId = e.ownerHandle;
@@ -592,40 +603,40 @@ class Ce extends ue {
592
603
  this.processLayouts(e, n), this.processImageDefs(e, n);
593
604
  }
594
605
  processLayouts(e, n) {
595
- const s = n.objects.layout;
596
- e.objects.LAYOUT.forEach((t) => {
597
- const r = new Pe();
598
- r.layoutName = t.layoutName, r.tabOrder = t.tabOrder;
599
- const l = n.tables.blockTable.newIterator();
600
- r.objectId = t.handle;
601
- for (const c of l)
606
+ const t = n.objects.layout;
607
+ e.objects.LAYOUT.forEach((s) => {
608
+ const r = new Ee();
609
+ r.layoutName = s.layoutName, r.tabOrder = s.tabOrder;
610
+ const a = n.tables.blockTable.newIterator();
611
+ r.objectId = s.handle;
612
+ for (const c of a)
602
613
  if (c.layoutId === r.objectId) {
603
614
  r.blockTableRecordId = c.objectId;
604
615
  break;
605
616
  }
606
- r.blockTableRecordId || t.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(t.minLimit), r.limits.max.copy(t.maxLimit), r.extents.min.copy(t.minExtent), r.extents.max.copy(t.maxExtent), t.viewportId && r.viewportArray.push(t.viewportId), this.processCommonObjectAttrs(t, r), s.setAt(r.layoutName, r);
617
+ r.blockTableRecordId || s.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(s.minLimit), r.limits.max.copy(s.maxLimit), r.extents.min.copy(s.minExtent), r.extents.max.copy(s.maxExtent), s.viewportId && r.viewportArray.push(s.viewportId), this.processCommonObjectAttrs(s, r), t.setAt(r.layoutName, r);
607
618
  });
608
619
  }
609
620
  processImageDefs(e, n) {
610
- const s = n.objects.imageDefinition;
611
- e.objects.IMAGEDEF.forEach((t) => {
612
- const r = new Ee();
613
- r.sourceFileName = t.fileName, this.processCommonObjectAttrs(t, r), s.setAt(r.objectId, r);
621
+ const t = n.objects.imageDefinition;
622
+ e.objects.IMAGEDEF.forEach((s) => {
623
+ const r = new Me();
624
+ r.sourceFileName = s.fileName, this.processCommonObjectAttrs(s, r), t.setAt(r.objectId, r);
614
625
  });
615
626
  }
616
627
  processCommonObjectAttrs(e, n) {
617
628
  n.objectId = e.handle, n.ownerId = e.ownerHandle;
618
629
  }
619
630
  groupAndFlattenByType(e) {
620
- const n = {}, s = [];
631
+ const n = {}, t = [];
621
632
  for (const o of e)
622
- n[o.type] || (n[o.type] = [], s.push(o.type)), n[o.type].push(o);
623
- return s.flatMap((o) => n[o]);
633
+ n[o.type] || (n[o.type] = [], t.push(o.type)), n[o.type].push(o);
634
+ return t.flatMap((o) => n[o]);
624
635
  }
625
636
  isModelSpace(e) {
626
- return e && e.toUpperCase() == Me;
637
+ return e && e.toUpperCase() == Le;
627
638
  }
628
639
  }
629
640
  export {
630
- Ce as AcDbLibreDwgConverter
641
+ Se as AcDbLibreDwgConverter
631
642
  };