@mlightcad/libredwg-converter 3.5.27 → 3.5.29

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,57 +1,57 @@
1
- import { AcDbFace as m, AcGeVector3d as D, AcDbArc as k, transformOcsPointToWcs as w, AcDbCircle as F, AcDbEllipse as R, AcDbLine as V, AcGePoint3d as T, AcDbSpline as b, AcDbPoint as N, AcDbTrace as B, AcDbPolyline as z, AcGePoint2d as P, AcDbPolygonMesh as j, AcDbPolyFaceMesh as W, AcDbPoly2dType as A, AcDb2dPolyline as H, AcDbPoly3dType as y, AcDb3dPolyline as X, AcDbHatch as G, AcGePolyline2d as U, AcGeLine2d as Y, AcGeCircArc2d as _, AcGeVector2d as Z, AcGeEllipseArc2d as K, AcGeSpline3d as E, AcGeLoop2d as M, AcDbHatchObjectType as q, AcDbTable as J, AcDbText as Q, AcDbMText as $, AcDbLeader as ee, AcDbAlignedDimension as ne, AcDbRotatedDimension as oe, AcDb3PointAngularDimension as te, AcDbOrdinateDimension as se, AcDbRadialDimension as re, AcDbDiametricDimension as ie, AcDbRasterImage as ce, AcDbWipeout as ae, AcDbViewport as le, AcDbRay as de, AcDbXline as pe, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as C, AcDbAttribute as L, AcDbAttributeDefinition as fe, AcDbBlockReference as ue, AcCmTransparency as he, AcDbDatabaseConverter as ge, createWorkerApi as De, AcDbLinetypeTableRecord as Ae, AcDbTextStyleTableRecord as Ie, DEFAULT_TEXT_STYLE as S, AcDbDimStyleTableRecord as ye, AcCmColor as we, AcDbLayerTableRecord as Te, AcDbViewportTableRecord as be, AcDbBlockTableRecord as Pe, AcDbBatchProcessing as Ee, ByLayer as Me, AcDbLayout as Ce, AcDbRasterImageDef as Le } from "@mlightcad/data-model";
2
- class x {
1
+ import { AcDbFace as H, AcGeVector3d as A, AcDbArc as j, transformOcsPointToWcs as E, AcDbCircle as W, AcDbEllipse as z, AcDbLine as X, AcGePoint3d as S, AcDbSpline as M, AcDbPoint as U, AcDbTrace as G, AcDbPolyline as Y, AcGePoint2d as m, AcDbPolygonMesh as _, AcDbPolyFaceMesh as Z, AcDbPoly2dType as b, AcDb2dPolyline as K, AcDbPoly3dType as T, AcDb3dPolyline as q, AcDbHatch as J, AcGePolyline2d as Q, AcGeLine2d as $, AcGeCircArc2d as ee, AcGeVector2d as te, AcGeEllipseArc2d as ne, AcGeSpline3d as v, AcGeLoop2d as k, AcDbHatchObjectType as oe, AcDbTable as re, AcDbText as ie, AcDbMText as se, AcDbLeader as ce, AcDbMLine as ae, AcDbMLeader as le, AcDbMLeaderLineType as de, AcDbMLeaderContentType as w, AcDbAlignedDimension as fe, AcDbRotatedDimension as pe, AcDb3PointAngularDimension as ue, AcDbOrdinateDimension as ge, AcDbRadialDimension as he, AcDbDiametricDimension as De, AcDbRasterImage as ye, AcDbWipeout as Ae, AcDbViewport as be, AcDbRay as Ie, AcDbXline as Te, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as O, AcDbAttribute as N, AcDbAttributeDefinition as we, AcDbBlockReference as Pe, AcCmTransparency as Le, AcDbDatabaseConverter as xe, createWorkerApi as Ce, AcDbLinetypeTableRecord as Ee, AcDbTextStyleTableRecord as Se, DEFAULT_TEXT_STYLE as R, AcDbDimStyleTableRecord as Me, AcCmColor as me, AcDbLayerTableRecord as ve, AcDbViewportTableRecord as ke, AcDbBlockTableRecord as Oe, AcDbBatchProcessing as Ne, ByLayer as Re, AcDbLayout as Ve, AcDbRasterImageDef as Fe } from "@mlightcad/data-model";
2
+ class V {
3
3
  convert(e) {
4
- const n = this.createEntity(e);
5
- return n && this.processCommonAttrs(e, n), n;
4
+ const t = this.createEntity(e);
5
+ return t && this.processCommonAttrs(e, t), t;
6
6
  }
7
7
  createEntity(e) {
8
- return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "ATTRIB" ? this.convertAttribute(e) : e.type == "CIRCLE" ? this.convertCirle(e) : e.type == "DIMENSION" ? this.convertDimension(e) : e.type == "ELLIPSE" ? this.convertEllipse(e) : e.type == "HATCH" ? this.convertHatch(e) : e.type == "IMAGE" ? this.convertImage(e) : e.type == "LEADER" ? this.convertLeader(e) : e.type == "LINE" ? this.convertLine(e) : e.type == "LWPOLYLINE" ? this.convertLWPolyline(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "POINT" ? this.convertPoint(e) : e.type == "POLYLINE2D" ? this.convertPolyline2d(e) : e.type == "POLYLINE3D" ? this.convertPolyline3d(e) : e.type == "RAY" ? this.convertRay(e) : e.type == "SPLINE" ? this.convertSpline(e) : e.type == "ACAD_TABLE" ? this.convertTable(e) : e.type == "TEXT" ? this.convertText(e) : e.type == "SOLID" ? this.convertSolid(e) : e.type == "VIEWPORT" ? this.convertViewport(e) : e.type == "WIPEOUT" ? this.convertWipeout(e) : e.type == "XLINE" ? this.convertXline(e) : e.type == "INSERT" ? this.convertBlockReference(e) : null;
8
+ return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "ATTRIB" ? this.convertAttribute(e) : e.type == "CIRCLE" ? this.convertCirle(e) : e.type == "DIMENSION" ? this.convertDimension(e) : e.type == "ELLIPSE" ? this.convertEllipse(e) : e.type == "HATCH" ? this.convertHatch(e) : e.type == "IMAGE" ? this.convertImage(e) : e.type == "LEADER" ? this.convertLeader(e) : e.type == "LINE" ? this.convertLine(e) : e.type == "LWPOLYLINE" ? this.convertLWPolyline(e) : e.type == "MLINE" ? this.convertMLine(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "MULTILEADER" || e.type == "MLEADER" ? this.convertMLeader(e) : e.type == "POINT" ? this.convertPoint(e) : e.type == "POLYLINE2D" ? this.convertPolyline2d(e) : e.type == "POLYLINE3D" ? this.convertPolyline3d(e) : e.type == "RAY" ? this.convertRay(e) : e.type == "SPLINE" ? this.convertSpline(e) : e.type == "ACAD_TABLE" ? this.convertTable(e) : e.type == "TEXT" ? this.convertText(e) : e.type == "SOLID" ? this.convertSolid(e) : e.type == "VIEWPORT" ? this.convertViewport(e) : e.type == "WIPEOUT" ? this.convertWipeout(e) : e.type == "XLINE" ? this.convertXline(e) : e.type == "INSERT" ? this.convertBlockReference(e) : null;
9
9
  }
10
10
  convertFace(e) {
11
- const n = new m();
12
- return e.corner1 && n.setVertexAt(0, e.corner1), e.corner2 && n.setVertexAt(1, e.corner2), e.corner3 && n.setVertexAt(2, e.corner3), e.corner4 && n.setVertexAt(3, e.corner4), n.setEdgeInvisibilities(e.flag), n;
11
+ const t = new H();
12
+ return e.corner1 && t.setVertexAt(0, e.corner1), e.corner2 && t.setVertexAt(1, e.corner2), e.corner3 && t.setVertexAt(2, e.corner3), e.corner4 && t.setVertexAt(3, e.corner4), t.setEdgeInvisibilities(e.flag), t;
13
13
  }
14
14
  convertArc(e) {
15
- const n = e.extrusionDirection ?? D.Z_AXIS;
16
- return new k(
17
- w(e.center, n),
15
+ const t = e.extrusionDirection ?? A.Z_AXIS;
16
+ return new j(
17
+ E(e.center, t),
18
18
  e.radius,
19
19
  e.startAngle,
20
20
  e.endAngle,
21
- n
21
+ t
22
22
  );
23
23
  }
24
24
  convertCirle(e) {
25
- const n = e.extrusionDirection ?? D.Z_AXIS;
26
- return new F(
27
- w(e.center, n),
25
+ const t = e.extrusionDirection ?? A.Z_AXIS;
26
+ return new W(
27
+ E(e.center, t),
28
28
  e.radius,
29
- n
29
+ t
30
30
  );
31
31
  }
32
32
  convertEllipse(e) {
33
- const n = new D(e.majorAxisEndPoint), s = n.length();
34
- return new R(
33
+ const t = new A(e.majorAxisEndPoint), o = t.length();
34
+ return new z(
35
35
  e.center,
36
- e.extrusionDirection ?? D.Z_AXIS,
37
- n,
38
- s,
39
- s * e.axisRatio,
36
+ e.extrusionDirection ?? A.Z_AXIS,
37
+ t,
38
+ o,
39
+ o * e.axisRatio,
40
40
  e.startAngle,
41
41
  e.endAngle
42
42
  );
43
43
  }
44
44
  convertLine(e) {
45
- const n = e.startPoint, s = e.endPoint;
46
- return new V(
47
- new T(n.x, n.y, n.z),
48
- new T(s.x, s.y, s.z)
45
+ const t = e.startPoint, o = e.endPoint;
46
+ return new X(
47
+ new S(t.x, t.y, t.z),
48
+ new S(o.x, o.y, o.z)
49
49
  );
50
50
  }
51
51
  convertSpline(e) {
52
52
  try {
53
53
  if (e.numberOfControlPoints > 0 && e.numberOfKnots > 0)
54
- return new b(
54
+ return new M(
55
55
  e.controlPoints,
56
56
  e.knots,
57
57
  e.weights,
@@ -59,7 +59,7 @@ class x {
59
59
  !!(e.flag & 1)
60
60
  );
61
61
  if (e.numberOfFitPoints > 0)
62
- return new b(
62
+ return new M(
63
63
  e.fitPoints,
64
64
  "Uniform",
65
65
  e.degree,
@@ -70,582 +70,752 @@ class x {
70
70
  return null;
71
71
  }
72
72
  convertPoint(e) {
73
- const n = new N();
74
- return n.position = e.position, n;
73
+ const t = new U();
74
+ return t.position = e.position, t;
75
75
  }
76
76
  convertSolid(e) {
77
- const n = new B();
78
- return n.setPointAt(0, { ...e.corner1, z: 0 }), n.setPointAt(1, { ...e.corner2, z: 0 }), n.setPointAt(2, { ...e.corner3, z: 0 }), n.setPointAt(
77
+ const t = new G();
78
+ return t.setPointAt(0, { ...e.corner1, z: 0 }), t.setPointAt(1, { ...e.corner2, z: 0 }), t.setPointAt(2, { ...e.corner3, z: 0 }), t.setPointAt(
79
79
  3,
80
80
  e.corner4 ? { ...e.corner4, z: 0 } : { ...e.corner3, z: 0 }
81
- ), n.thickness = e.thickness, n;
81
+ ), t.thickness = e.thickness, t;
82
82
  }
83
83
  convertLWPolyline(e) {
84
- const n = new z();
85
- n.closed = !!(e.flag & 512);
86
- const s = e.constantWidth ?? -1;
87
- return e.vertices.forEach((o, t) => {
88
- n.addVertexAt(
89
- t,
90
- new P(o.x, o.y),
91
- o.bulge,
92
- o.startWidth ?? s,
93
- o.endWidth ?? s
84
+ const t = new Y();
85
+ t.closed = !!(e.flag & 512);
86
+ const o = e.constantWidth ?? -1;
87
+ return e.vertices.forEach((n, r) => {
88
+ t.addVertexAt(
89
+ r,
90
+ new m(n.x, n.y),
91
+ n.bulge,
92
+ n.startWidth ?? o,
93
+ n.endWidth ?? o
94
94
  );
95
- }), n;
95
+ }), t;
96
96
  }
97
97
  convertPolyline2d(e) {
98
- const n = !!(e.flag & 1), s = !!(e.flag & 16), o = !!(e.flag & 64), t = !!(e.flag & 32), r = [], l = [], c = [];
99
- if (e.vertices.map((i) => {
100
- if (!(i.flag & 16))
101
- if (o && i.flag & 128)
102
- if (i.flag & 64)
103
- r.push({
104
- x: i.x,
105
- y: i.y,
106
- z: i.z
107
- }), l.push(i.bulge ?? 0);
98
+ const t = !!(e.flag & 1), o = !!(e.flag & 16), n = !!(e.flag & 64), r = !!(e.flag & 32), i = [], a = [], s = [];
99
+ if (e.vertices.map((c) => {
100
+ if (!(c.flag & 16))
101
+ if (n && c.flag & 128)
102
+ if (c.flag & 64)
103
+ i.push({
104
+ x: c.x,
105
+ y: c.y,
106
+ z: c.z
107
+ }), a.push(c.bulge ?? 0);
108
108
  else {
109
109
  const d = [];
110
- 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);
110
+ c.polyfaceIndex0 != null && c.polyfaceIndex0 != 0 && d.push(Math.abs(c.polyfaceIndex0) - 1), c.polyfaceIndex1 != null && c.polyfaceIndex1 != 0 && d.push(Math.abs(c.polyfaceIndex1) - 1), c.polyfaceIndex2 != null && c.polyfaceIndex2 != 0 && d.push(Math.abs(c.polyfaceIndex2) - 1), c.polyfaceIndex3 != null && c.polyfaceIndex3 != 0 && d.push(Math.abs(c.polyfaceIndex3) - 1), d.length >= 3 && s.push(d);
111
111
  }
112
112
  else
113
- r.push({
114
- x: i.x,
115
- y: i.y,
116
- z: i.z
117
- }), l.push(i.bulge ?? 0);
118
- }), s) {
119
- const i = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
120
- return new j(i, d, r, n, t);
113
+ i.push({
114
+ x: c.x,
115
+ y: c.y,
116
+ z: c.z
117
+ }), a.push(c.bulge ?? 0);
118
+ }), o) {
119
+ const c = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
120
+ return new _(c, d, i, t, r);
121
121
  } else {
122
- if (o)
123
- return new W(r, c);
122
+ if (n)
123
+ return new Z(i, s);
124
124
  {
125
- let i = A.SimplePoly;
126
- return e.flag & 2 ? i = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? i = A.CubicSplinePoly : e.smoothType == 5 && (i = A.QuadSplinePoly)), new H(
125
+ let c = b.SimplePoly;
126
+ return e.flag & 2 ? c = b.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? c = b.CubicSplinePoly : e.smoothType == 5 && (c = b.QuadSplinePoly)), new K(
127
+ c,
127
128
  i,
128
- r,
129
129
  0,
130
- n,
130
+ t,
131
131
  e.startWidth,
132
132
  e.endWidth,
133
- l
133
+ a
134
134
  );
135
135
  }
136
136
  }
137
137
  }
138
138
  convertPolyline3d(e) {
139
- const n = !!(e.flag & 1), s = [];
140
- e.vertices.map((t) => {
141
- t.flag & 16 || s.push({
142
- x: t.x,
143
- y: t.y,
144
- z: t.z
139
+ const t = !!(e.flag & 1), o = [];
140
+ e.vertices.map((r) => {
141
+ r.flag & 16 || o.push({
142
+ x: r.x,
143
+ y: r.y,
144
+ z: r.z
145
145
  });
146
146
  });
147
- let o = y.SimplePoly;
148
- return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new X(o, s, n);
147
+ let n = T.SimplePoly;
148
+ return e.flag & 4 && (e.smoothType == 6 ? n = T.CubicSplinePoly : e.smoothType == 5 && (n = T.QuadSplinePoly)), new q(n, o, t);
149
149
  }
150
150
  convertHatch(e) {
151
- var o;
152
- const n = new G();
153
- if ((o = e.definitionLines) == null || o.forEach((t) => {
154
- n.definitionLines.push({
155
- angle: t.angle,
156
- base: t.base,
157
- offset: t.offset,
158
- dashLengths: t.numberOfDashLengths > 0 ? t.dashLengths : []
151
+ var n;
152
+ const t = new J();
153
+ if ((n = e.definitionLines) == null || n.forEach((r) => {
154
+ t.definitionLines.push({
155
+ angle: r.angle,
156
+ base: r.base,
157
+ offset: r.offset,
158
+ dashLengths: r.numberOfDashLengths > 0 ? r.dashLengths : []
159
159
  });
160
- }), 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) => {
161
- if (t.boundaryPathTypeFlag & 2) {
162
- const l = t, c = new U();
163
- c.closed = l.isClosed, l.vertices.forEach((i, d) => {
164
- c.addVertexAt(d, {
165
- x: i.x,
166
- y: i.y,
167
- bulge: i.bulge
160
+ }), t.isSolidFill = e.solidFill == 1, t.hatchStyle = e.hatchStyle, t.patternName = e.patternName, t.patternType = e.patternType, t.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, t.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((r) => {
161
+ if (r.boundaryPathTypeFlag & 2) {
162
+ const a = r, s = new Q();
163
+ s.closed = a.isClosed, a.vertices.forEach((c, d) => {
164
+ s.addVertexAt(d, {
165
+ x: c.x,
166
+ y: c.y,
167
+ bulge: c.bulge
168
168
  });
169
- }), n.add(c);
169
+ }), t.add(s);
170
170
  } else {
171
- const l = t, c = [];
172
- l.edges.forEach((d) => {
171
+ const a = r, s = [];
172
+ a.edges.forEach((d) => {
173
173
  if (d != null) {
174
174
  if (d.type == 1) {
175
- const a = d;
176
- c.push(new Y(a.start, a.end));
175
+ const l = d;
176
+ s.push(new $(l.start, l.end));
177
177
  } else if (d.type == 2) {
178
- const a = d;
179
- c.push(
180
- new _(
181
- a.center,
182
- a.radius,
183
- a.startAngle,
184
- a.endAngle,
185
- !a.isCCW
178
+ const l = d;
179
+ s.push(
180
+ new ee(
181
+ l.center,
182
+ l.radius,
183
+ l.startAngle,
184
+ l.endAngle,
185
+ !l.isCCW
186
186
  )
187
187
  );
188
188
  } else if (d.type == 3) {
189
- const a = d;
190
- new Z().subVectors(a.end, a.center);
189
+ const l = d;
190
+ new te().subVectors(l.end, l.center);
191
191
  const p = Math.sqrt(
192
- Math.pow(a.end.x, 2) + Math.pow(a.end.y, 2)
193
- ), f = p * a.lengthOfMinorAxis;
194
- let u = a.startAngle, g = a.endAngle;
195
- const O = Math.atan2(a.end.y, a.end.x);
196
- a.isCCW || (u = Math.PI * 2 - u, g = Math.PI * 2 - g), c.push(
197
- new K(
198
- { ...a.center, z: 0 },
192
+ Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
193
+ ), u = p * l.lengthOfMinorAxis;
194
+ let g = l.startAngle, y = l.endAngle;
195
+ const h = Math.atan2(l.end.y, l.end.x);
196
+ l.isCCW || (g = Math.PI * 2 - g, y = Math.PI * 2 - y), s.push(
197
+ new ne(
198
+ { ...l.center, z: 0 },
199
199
  p,
200
- f,
201
200
  u,
202
201
  g,
203
- !a.isCCW,
204
- O
202
+ y,
203
+ !l.isCCW,
204
+ h
205
205
  )
206
206
  );
207
207
  } else if (d.type == 4) {
208
- const a = d;
209
- if (a.numberOfControlPoints > 0 && a.numberOfKnots > 0) {
210
- const h = a.controlPoints.map(
211
- (u) => ({
212
- x: u.x,
213
- y: u.y,
208
+ const l = d;
209
+ if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
210
+ const f = l.controlPoints.map(
211
+ (g) => ({
212
+ x: g.x,
213
+ y: g.y,
214
214
  z: 0
215
215
  })
216
216
  );
217
217
  let p = !0;
218
- const f = a.controlPoints.map((u) => (u.weight == null && (p = !1), u.weight || 1));
219
- c.push(
220
- new E(
221
- h,
222
- a.knots,
223
- p ? f : void 0
218
+ const u = l.controlPoints.map((g) => (g.weight == null && (p = !1), g.weight || 1));
219
+ s.push(
220
+ new v(
221
+ f,
222
+ l.knots,
223
+ p ? u : void 0
224
224
  )
225
225
  );
226
- } else if (a.numberOfFitData > 0) {
227
- const h = a.fitDatum.map((p) => ({
226
+ } else if (l.numberOfFitData > 0) {
227
+ const f = l.fitDatum.map((p) => ({
228
228
  x: p.x,
229
229
  y: p.y,
230
230
  z: 0
231
231
  }));
232
- c.push(new E(h, "Uniform"));
232
+ s.push(new v(f, "Uniform"));
233
233
  }
234
234
  }
235
235
  }
236
236
  });
237
- const i = M.buildFromEdges(c);
238
- i.length == 0 && c.length > 0 ? n.add(new M(c)) : i.forEach((d) => n.add(d));
237
+ const c = k.buildFromEdges(s);
238
+ c.length == 0 && s.length > 0 ? t.add(new k(s)) : c.forEach((d) => t.add(d));
239
239
  }
240
240
  }), e.gradientFlag) {
241
- const t = e;
242
- if (n.hatchObjectType = q.GradientObject, n.gradientName = t.gradientName, n.gradientAngle = t.gradientRotation ?? 0, n.gradientShift = t.gradientDefinition ?? 0, n.gradientOneColorMode = t.gradientColorFlag == 1, n.shadeTintValue = t.colorTint ?? 0, t.gradientColors) {
243
- const r = t.gradientColors.length;
244
- r > 1 ? (n.gradientStartColor = t.gradientColors[0].rgb, n.gradientEndColor = t.gradientColors[1].rgb) : r > 0 && (n.gradientStartColor = t.gradientColors[0].rgb);
241
+ const r = e;
242
+ if (t.hatchObjectType = oe.GradientObject, t.gradientName = r.gradientName, t.gradientAngle = r.gradientRotation ?? 0, t.gradientShift = r.gradientDefinition ?? 0, t.gradientOneColorMode = r.gradientColorFlag == 1, t.shadeTintValue = r.colorTint ?? 0, r.gradientColors) {
243
+ const i = r.gradientColors.length;
244
+ i > 1 ? (t.gradientStartColor = r.gradientColors[0].rgb, t.gradientEndColor = r.gradientColors[1].rgb) : i > 0 && (t.gradientStartColor = r.gradientColors[0].rgb);
245
245
  }
246
246
  }
247
- return n;
247
+ return t;
248
248
  }
249
249
  convertTable(e) {
250
- const n = new J(
250
+ const t = new re(
251
251
  e.name,
252
252
  e.rowCount,
253
253
  e.columnCount
254
254
  );
255
- 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(
256
- (s, o) => n.setColumnWidth(o, s)
255
+ return t.tableStyleId = e.tableStyleId, t.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (t.horizontalDirection = new A(e.directionVector)), t.attachmentPoint = e.attachmentPoint, t.position.copy(e.startPoint), t.tableValueFlag = e.tableValue, t.tableOverrideFlag = e.overrideFlag, t.borderColorOverrideFlag = e.borderColorOverrideFlag, t.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, t.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
256
+ (o, n) => t.setColumnWidth(n, o)
257
257
  ), e.rowHeightArr.forEach(
258
- (s, o) => n.setRowHeight(o, s)
259
- ), e.cells.forEach((s, o) => {
260
- n.setCell(o, s);
261
- }), n;
258
+ (o, n) => t.setRowHeight(n, o)
259
+ ), e.cells.forEach((o, n) => {
260
+ t.setCell(n, o);
261
+ }), t;
262
262
  }
263
263
  convertText(e) {
264
- const n = new Q();
265
- return n.textString = e.text, n.styleName = e.styleName, n.height = e.textHeight, n.position.copy(e.startPoint), n.rotation = e.rotation, n.oblique = e.obliqueAngle ?? 0, n.thickness = e.thickness, n.horizontalMode = e.halign, n.verticalMode = e.valign, n.widthFactor = e.xScale ?? 1, n;
264
+ const t = new ie();
265
+ return t.textString = e.text, t.styleName = e.styleName, t.height = e.textHeight, t.position.copy(e.startPoint), t.rotation = e.rotation, t.oblique = e.obliqueAngle ?? 0, t.thickness = e.thickness, t.horizontalMode = e.halign, t.verticalMode = e.valign, t.widthFactor = e.xScale ?? 1, t;
266
266
  }
267
267
  convertMText(e) {
268
- const n = new $();
269
- return n.contents = e.text, e.styleName != null && (n.styleName = e.styleName), n.height = e.textHeight, n.width = e.rectWidth, n.rotation = e.rotation || 0, n.location = e.insertionPoint, n.attachmentPoint = e.attachmentPoint, e.direction && (n.direction = new D(e.direction)), n.drawingDirection = e.drawingDirection, n;
268
+ const t = new se();
269
+ return t.contents = e.text, e.styleName != null && (t.styleName = e.styleName), t.height = e.textHeight, t.width = e.rectWidth, t.rotation = e.rotation || 0, t.location = e.insertionPoint, t.attachmentPoint = e.attachmentPoint, e.direction && (t.direction = new A(e.direction)), t.drawingDirection = e.drawingDirection, t;
270
270
  }
271
271
  convertLeader(e) {
272
- const n = new ee();
273
- return e.vertices.forEach((s) => {
274
- n.appendVertex(s);
275
- }), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
272
+ const t = new ce();
273
+ return e.vertices.forEach((o) => {
274
+ t.appendVertex(o);
275
+ }), t.hasArrowHead = e.isArrowheadEnabled, t.hasHookLine = e.isHooklineExists, t.isSplined = e.isSpline, t.dimensionStyle = e.styleName, t.annoType = e.leaderCreationFlag, t;
276
+ }
277
+ convertMLine(e) {
278
+ const t = new ae();
279
+ return t.styleName = e.mlineStyle || "STANDARD", t.scale = e.scale, t.flags = e.flags, t.justification = e.justification, t.startPosition = e.startPoint, t.normal = e.extrusionDirection ?? A.Z_AXIS, t.styleCount = e.numberOfLines ?? 0, t.segments = (e.vertices ?? []).map((o) => ({
280
+ position: o.vertex,
281
+ direction: o.vertexDirection,
282
+ miterDirection: o.miterDirection,
283
+ elements: (o.lines ?? []).map((n) => ({
284
+ parameterCount: n.numberOfSegmentParams,
285
+ parameters: n.segmentParams ?? [],
286
+ fillCount: n.numberOfAreaFillParams,
287
+ fillParameters: n.areaFillParams ?? []
288
+ }))
289
+ })), t;
290
+ }
291
+ convertMLeader(e) {
292
+ var p, u, g, y;
293
+ const t = new le(), o = e;
294
+ t.leaderLineType = this.readNumber(o, [
295
+ "multileaderType",
296
+ "leaderLineType",
297
+ "leaderType"
298
+ ]) ?? de.StraightLeader;
299
+ const n = this.readNumber(o, ["contentType"]) ?? (e.textContent ? w.MTextContent : e.blockContent ? w.BlockContent : w.NoneContent);
300
+ t.contentType = n, t.doglegEnabled = this.readBoolean(o, ["doglegEnabled", "enableDogleg"]) ?? !1, t.doglegLength = this.readNumber(o, ["doglegLength"]) ?? 0, e.landingPoint && (t.landingPoint = e.landingPoint), e.doglegVector && (t.doglegVector = e.doglegVector);
301
+ const r = this.readString(o, [
302
+ "mleaderStyleId",
303
+ "mLeaderStyleId",
304
+ "mleaderStyleHandle",
305
+ "styleHandle",
306
+ "styleName"
307
+ ]);
308
+ r && (t.mleaderStyleId = r);
309
+ const i = this.readPoint(o, ["normal", "extrusionDirection"]);
310
+ i && (t.normal = i);
311
+ const a = e.textContent, s = this.readString(a ?? {}, ["styleName", "textStyleName"]) ?? this.readString(o, ["textStyleName", "textStyle", "styleName"]);
312
+ s && (t.textStyleName = s), t.textHeight = this.readNumber(a ?? {}, ["textHeight", "height"]) ?? this.readNumber(o, [
313
+ "textHeight",
314
+ "mtextHeight",
315
+ "textContentHeight"
316
+ ]) ?? t.textHeight, t.textWidth = this.readNumber(a ?? {}, ["textWidth", "width"]) ?? this.readNumber(o, ["textWidth", "mtextWidth", "textContentWidth"]) ?? t.textWidth;
317
+ const c = this.readNumber(a ?? {}, ["textRotation", "rotation"]) ?? this.readNumber(o, [
318
+ "textRotation",
319
+ "mtextRotation",
320
+ "textContentRotation"
321
+ ]);
322
+ c != null && (t.textRotation = c);
323
+ const d = this.readPoint(o, [
324
+ "textDirection",
325
+ "mtextDirection",
326
+ "textDirectionVector"
327
+ ]);
328
+ d && (t.textDirection = d);
329
+ const l = this.readNumber(o, [
330
+ "textAttachmentPoint",
331
+ "attachmentPoint"
332
+ ]);
333
+ l != null && (t.textAttachmentPoint = l);
334
+ const f = this.readNumber(o, [
335
+ "textDrawingDirection",
336
+ "drawingDirection"
337
+ ]);
338
+ if (f != null && (t.textDrawingDirection = f), ((p = e.textContent) == null ? void 0 : p.text) != null && e.textContent.anchorPoint)
339
+ t.mtextContent = {
340
+ text: e.textContent.text,
341
+ anchorPoint: e.textContent.anchorPoint
342
+ };
343
+ else {
344
+ const h = this.readString(o, ["text", "contents", "mtext"]), D = this.readPoint(o, [
345
+ "textLocation",
346
+ "textPosition",
347
+ "textAnchorPoint"
348
+ ]);
349
+ h != null && D && (t.mtextContent = { text: h, anchorPoint: D });
350
+ }
351
+ if ((u = e.blockContent) != null && u.blockHandle && e.blockContent.position)
352
+ t.blockContent = {
353
+ blockHandle: e.blockContent.blockHandle,
354
+ position: e.blockContent.position
355
+ };
356
+ else {
357
+ const h = this.readString(o, [
358
+ "blockHandle",
359
+ "blockContentHandle",
360
+ "blockId"
361
+ ]), D = this.readPoint(o, [
362
+ "blockPosition",
363
+ "blockContentPosition"
364
+ ]);
365
+ h && D && (t.blockContent = {
366
+ blockHandle: h,
367
+ position: D
368
+ });
369
+ }
370
+ return (g = e.leaders) == null || g.forEach((h) => {
371
+ var P;
372
+ const D = t.addLeader({
373
+ landingPoint: h.landingPoint ?? e.landingPoint,
374
+ doglegVector: h.doglegVector ?? e.doglegVector,
375
+ doglegLength: h.doglegLength ?? e.doglegLength
376
+ });
377
+ (P = h.leaderLines) == null || P.forEach((L) => {
378
+ var x;
379
+ const B = t.addLeaderLine(
380
+ D,
381
+ L.vertices ?? []
382
+ );
383
+ (x = L.breaks) == null || x.forEach((C) => {
384
+ t.addBreak(D, B, C.start, C.end);
385
+ });
386
+ });
387
+ }), t.numberOfLeaders === 0 && ((y = this.readLeaderLineArray(o)) == null || y.forEach((h) => {
388
+ const D = t.addLeader({
389
+ landingPoint: e.landingPoint,
390
+ doglegVector: e.doglegVector,
391
+ doglegLength: e.doglegLength
392
+ });
393
+ t.addLeaderLine(D, h);
394
+ })), t;
276
395
  }
277
396
  convertDimension(e) {
278
397
  if (e.subclassMarker == "AcDbAlignedDimension") {
279
- const n = e, s = new ne(
280
- n.subDefinitionPoint1,
281
- n.subDefinitionPoint2,
282
- n.definitionPoint
398
+ const t = e, o = new fe(
399
+ t.subDefinitionPoint1,
400
+ t.subDefinitionPoint2,
401
+ t.definitionPoint
283
402
  );
284
- return n.insertionPoint && (s.dimBlockPosition = {
285
- x: n.insertionPoint.x,
286
- y: n.insertionPoint.y,
403
+ return t.insertionPoint && (o.dimBlockPosition = {
404
+ x: t.insertionPoint.x,
405
+ y: t.insertionPoint.y,
287
406
  z: 0
288
- }), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
407
+ }), o.rotation = t.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
289
408
  } else if (e.subclassMarker == "AcDbRotatedDimension") {
290
- const n = e, s = new oe(
291
- n.subDefinitionPoint1,
292
- n.subDefinitionPoint2,
293
- n.definitionPoint
409
+ const t = e, o = new pe(
410
+ t.subDefinitionPoint1,
411
+ t.subDefinitionPoint2,
412
+ t.definitionPoint
294
413
  );
295
- return n.insertionPoint && (s.dimBlockPosition = {
296
- x: n.insertionPoint.x,
297
- y: n.insertionPoint.y,
414
+ return t.insertionPoint && (o.dimBlockPosition = {
415
+ x: t.insertionPoint.x,
416
+ y: t.insertionPoint.y,
298
417
  z: 0
299
- }), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
418
+ }), o.rotation = t.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
300
419
  } else if (e.subclassMarker == "AcDb3PointAngularDimension") {
301
- const n = e, s = new te(
302
- n.centerPoint,
303
- n.subDefinitionPoint1,
304
- n.subDefinitionPoint2,
305
- n.definitionPoint
420
+ const t = e, o = new ue(
421
+ t.centerPoint,
422
+ t.subDefinitionPoint1,
423
+ t.subDefinitionPoint2,
424
+ t.definitionPoint
306
425
  );
307
- return this.processDimensionCommonAttrs(e, s), s;
426
+ return this.processDimensionCommonAttrs(e, o), o;
308
427
  } else if (e.subclassMarker == "AcDbOrdinateDimension") {
309
- const n = e, s = new se(
310
- n.subDefinitionPoint1,
311
- n.subDefinitionPoint2
428
+ const t = e, o = new ge(
429
+ t.subDefinitionPoint1,
430
+ t.subDefinitionPoint2
312
431
  );
313
- return this.processDimensionCommonAttrs(e, s), s;
432
+ return this.processDimensionCommonAttrs(e, o), o;
314
433
  } else if (e.subclassMarker == "AcDbRadialDimension") {
315
- const n = e, s = new re(
316
- n.definitionPoint,
317
- n.centerPoint,
318
- n.leaderLength
434
+ const t = e, o = new he(
435
+ t.definitionPoint,
436
+ t.centerPoint,
437
+ t.leaderLength
319
438
  );
320
- return this.processDimensionCommonAttrs(e, s), s;
439
+ return this.processDimensionCommonAttrs(e, o), o;
321
440
  } else if (e.subclassMarker == "AcDbDiametricDimension") {
322
- const n = e, s = new ie(
323
- n.definitionPoint,
324
- n.centerPoint,
325
- n.leaderLength
441
+ const t = e, o = new De(
442
+ t.definitionPoint,
443
+ t.centerPoint,
444
+ t.leaderLength
326
445
  );
327
- return this.processDimensionCommonAttrs(e, s), s;
446
+ return this.processDimensionCommonAttrs(e, o), o;
328
447
  }
329
448
  return null;
330
449
  }
331
- processImage(e, n) {
332
- 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) => {
333
- n.clipBoundary.push(new P(s));
334
- }), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
450
+ processImage(e, t) {
451
+ t.position.copy(e.position), t.brightness = e.brightness, t.contrast = e.contrast, t.fade = e.fade, t.imageSize.copy(e.imageSize), t.imageDefId = e.imageDefHandle, t.isClipped = e.clipping > 0, t.isShownClipped = (e.flags | 4) > 0, t.isImageShown = (e.flags | 3) > 0, t.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((o) => {
452
+ t.clipBoundary.push(new m(o));
453
+ }), t.clipBoundaryType = e.clippingBoundaryType, t.width = Math.sqrt(
335
454
  e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
336
- ) * e.imageSize.x, n.height = Math.sqrt(
455
+ ) * e.imageSize.x, t.height = Math.sqrt(
337
456
  e.vPixel.x ** 2 + e.vPixel.y ** 2 + e.vPixel.z ** 2
338
- ) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
457
+ ) * e.imageSize.y, t.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
339
458
  }
340
459
  convertImage(e) {
341
- const n = new ce();
342
- return this.processImage(e, n), n;
460
+ const t = new ye();
461
+ return this.processImage(e, t), t;
343
462
  }
344
463
  convertWipeout(e) {
345
- const n = new ae();
346
- return this.processImage(e, n), n;
464
+ const t = new Ae();
465
+ return this.processImage(e, t), t;
347
466
  }
348
467
  convertViewport(e) {
349
- const n = new le();
350
- 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;
468
+ const t = new be();
469
+ return t.number = e.viewportId, t.centerPoint.copy(e.viewportCenter), t.height = e.height, t.width = e.width, t.viewCenter.copy(e.displayCenter), t.viewHeight = e.viewHeight, t;
351
470
  }
352
471
  convertRay(e) {
353
- const n = new de();
354
- return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
472
+ const t = new Ie();
473
+ return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
355
474
  }
356
475
  convertXline(e) {
357
- const n = new pe();
358
- return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
476
+ const t = new Te();
477
+ return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
359
478
  }
360
- convertAttributeCommon(e, n) {
361
- const s = e.text;
362
- 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 & C.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & C.ConstMultiLine) !== 0;
479
+ convertAttributeCommon(e, t) {
480
+ const o = e.text;
481
+ t.textString = o.text, t.styleName = o.styleName, t.height = o.textHeight, t.position.copy(o.startPoint), t.rotation = o.rotation, t.oblique = o.obliqueAngle ?? 0, t.thickness = o.thickness, t.horizontalMode = o.halign, t.verticalMode = o.valign, t.widthFactor = o.xScale ?? 1, t.tag = e.tag, t.fieldLength = e.fieldLength, t.isInvisible = (e.flags & I.Invisible) !== 0, t.isConst = (e.flags & I.Const) !== 0, t.isVerifiable = (e.flags & I.Verifiable) !== 0, t.isPreset = (e.flags & I.Preset) !== 0, t.lockPositionInBlock = e.lockPositionFlag, t.isReallyLocked = e.isReallyLocked, t.isMTextAttribute = (e.mtextFlag & O.MultiLine) !== 0, t.isConstMTextAttribute = (e.mtextFlag & O.ConstMultiLine) !== 0;
363
482
  }
364
483
  convertAttribute(e) {
365
- const n = new L();
366
- return this.convertAttributeCommon(e, n), n;
484
+ const t = new N();
485
+ return this.convertAttributeCommon(e, t), t;
367
486
  }
368
487
  convertAttributeDefinition(e) {
369
- const n = new fe();
370
- return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
488
+ const t = new we();
489
+ return this.convertAttributeCommon(e, t), t.prompt = e.prompt, t;
371
490
  }
372
491
  convertBlockReference(e) {
373
- const n = new ue(e.name);
374
- 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.handle != null && (n.objectId = e.handle), e.attribs && e.attribs.forEach((s) => {
375
- const o = this.convert(s);
376
- o instanceof L && n.appendAttributes(o);
377
- }), n;
378
- }
379
- processDimensionCommonAttrs(e, n) {
380
- 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;
381
- }
382
- processCommonAttrs(e, n) {
383
- if (n.layer = e.layer || "0", n.objectId = e.handle, e.ownerBlockRecordSoftId != null && (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) {
384
- const s = new he();
385
- s.method = e.transparencyType, (s.isByBlock || s.isByBlock) && (s.alpha = e.transparency), n.transparency = s;
492
+ const t = new Pe(e.name);
493
+ return e.insertionPoint && t.position.copy(e.insertionPoint), t.scaleFactors.x = e.xScale, t.scaleFactors.y = e.yScale, t.scaleFactors.z = e.zScale, t.rotation = e.rotation, t.normal.copy(e.extrusionDirection), e.handle != null && (t.objectId = e.handle), e.attribs && e.attribs.forEach((o) => {
494
+ const n = this.convert(o);
495
+ n instanceof N && t.appendAttributes(n);
496
+ }), t;
497
+ }
498
+ processDimensionCommonAttrs(e, t) {
499
+ t.dimBlockId = e.name, t.textPosition.copy(e.textPoint), t.textRotation = e.textRotation || 0, e.textLineSpacingFactor && (t.textLineSpacingFactor = e.textLineSpacingFactor), e.textLineSpacingStyle && (t.textLineSpacingStyle = e.textLineSpacingStyle), t.dimensionStyleName = e.styleName, t.dimensionText = e.text || "", t.measurement = e.measurement;
500
+ }
501
+ processCommonAttrs(e, t) {
502
+ if (t.layer = e.layer || "0", t.objectId = e.handle, e.ownerBlockRecordSoftId != null && (t.ownerId = e.ownerBlockRecordSoftId), e.lineType != null && (t.lineType = e.lineType), e.lineweight != null && (t.lineWeight = e.lineweight), e.lineTypeScale != null && (t.linetypeScale = e.lineTypeScale), e.color != null && t.color.setRGBValue(e.color), e.colorIndex != null && (e.color == null || e.colorIndex === 7) && (t.color.colorIndex = e.colorIndex), e.colorName && (t.color.colorName = e.colorName), e.isVisible != null && (t.visibility = e.isVisible), e.transparency != null) {
503
+ const o = new Le();
504
+ o.method = e.transparencyType, (o.isByBlock || o.isByBlock) && (o.alpha = e.transparency), t.transparency = o;
505
+ }
506
+ }
507
+ readNumber(e, t) {
508
+ for (const o of t) {
509
+ const n = e[o];
510
+ if (typeof n == "number" && Number.isFinite(n)) return n;
386
511
  }
387
512
  }
513
+ readString(e, t) {
514
+ for (const o of t) {
515
+ const n = e[o];
516
+ if (typeof n == "string") return n;
517
+ }
518
+ }
519
+ readBoolean(e, t) {
520
+ for (const o of t) {
521
+ const n = e[o];
522
+ if (typeof n == "boolean") return n;
523
+ if (typeof n == "number") return n !== 0;
524
+ }
525
+ }
526
+ readPoint(e, t) {
527
+ for (const o of t) {
528
+ const n = e[o];
529
+ if (this.isPointLike(n)) return n;
530
+ if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "number")
531
+ return { x: n[0], y: n[1], z: n[2] ?? 0 };
532
+ }
533
+ }
534
+ readLeaderLineArray(e) {
535
+ const t = e.leaderLines;
536
+ if (Array.isArray(t))
537
+ return t.map((n) => {
538
+ if (!n || typeof n != "object") return;
539
+ const r = n.vertices;
540
+ return Array.isArray(r) ? r.filter((i) => this.isPointLike(i)) : void 0;
541
+ }).filter((n) => !!n && n.length > 0);
542
+ const o = e.vertices;
543
+ if (Array.isArray(o)) {
544
+ const n = o.filter((r) => this.isPointLike(r));
545
+ return n.length > 0 ? [n] : void 0;
546
+ }
547
+ }
548
+ isPointLike(e) {
549
+ return !!e && typeof e == "object" && typeof e.x == "number" && typeof e.y == "number";
550
+ }
388
551
  }
389
- const Se = "*MODEL_SPACE";
390
- class ve extends ge {
552
+ const Be = "*MODEL_SPACE";
553
+ class je extends xe {
391
554
  constructor(e = {}) {
392
555
  super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
393
556
  }
394
- async parse(e, n) {
395
- const s = this.config, o = this.getParserWorkerTimeout(e, n);
396
- if (s.useWorker && s.parserWorkerUrl) {
397
- const t = De({
398
- workerUrl: s.parserWorkerUrl,
399
- timeout: o,
557
+ async parse(e, t) {
558
+ const o = this.config, n = this.getParserWorkerTimeout(e, t);
559
+ if (o.useWorker && o.parserWorkerUrl) {
560
+ const r = Ce({
561
+ workerUrl: o.parserWorkerUrl,
562
+ timeout: n,
400
563
  maxConcurrentWorkers: 1
401
- }), r = await t.execute(e);
402
- if (t.destroy(), r.success)
403
- return r.data;
564
+ }), i = await r.execute(e);
565
+ if (r.destroy(), i.success)
566
+ return i.data;
404
567
  throw new Error(
405
- `Failed to parse drawing due to error: '${r.error}'`
568
+ `Failed to parse drawing due to error: '${i.error}'`
406
569
  );
407
570
  } else
408
571
  throw new Error("dwg converter can run in web worker only!");
409
572
  }
410
573
  getFonts(e) {
411
- const n = /* @__PURE__ */ new Map();
412
- e.tables.BLOCK_RECORD.entries.forEach((r) => {
413
- n.set(r.name, r);
574
+ const t = /* @__PURE__ */ new Map();
575
+ e.tables.BLOCK_RECORD.entries.forEach((i) => {
576
+ t.set(i.name, i);
414
577
  });
415
- const s = /* @__PURE__ */ new Map(), o = (r) => {
416
- if (r) {
417
- const l = r.lastIndexOf(".");
418
- return l >= 0 ? r.substring(0, l).toLowerCase() : r.toLowerCase();
578
+ const o = /* @__PURE__ */ new Map(), n = (i) => {
579
+ if (i) {
580
+ const a = i.lastIndexOf(".");
581
+ return a >= 0 ? i.substring(0, a).toLowerCase() : i.toLowerCase();
419
582
  }
420
583
  };
421
- e.tables.STYLE.entries.forEach((r) => {
422
- const l = [];
423
- let c = o(r.font);
424
- c && l.push(c), c = o(r.bigFont), c && l.push(c), s.set(r.name, l);
584
+ e.tables.STYLE.entries.forEach((i) => {
585
+ const a = [];
586
+ let s = n(i.font);
587
+ s && a.push(s), s = n(i.bigFont), s && a.push(s), o.set(i.name, a);
425
588
  });
426
- const t = /* @__PURE__ */ new Set();
427
- return this.getFontsInBlock(e.entities, n, s, t), Array.from(t);
428
- }
429
- getFontsInBlock(e, n, s, o) {
430
- const t = /\\f(.*?)\|/g;
431
- e.forEach((r) => {
432
- if (r.type == "MTEXT") {
433
- const l = r;
434
- [...l.text.matchAll(t)].forEach((i) => {
435
- o.add(i[1].toLowerCase());
589
+ const r = /* @__PURE__ */ new Set();
590
+ return this.getFontsInBlock(e.entities, t, o, r), Array.from(r);
591
+ }
592
+ getFontsInBlock(e, t, o, n) {
593
+ const r = /\\f(.*?)\|/g;
594
+ e.forEach((i) => {
595
+ if (i.type == "MTEXT") {
596
+ const a = i;
597
+ [...a.text.matchAll(r)].forEach((c) => {
598
+ n.add(c[1].toLowerCase());
436
599
  });
437
- const c = s.get(l.styleName);
438
- c == null || c.forEach((i) => o.add(i));
439
- } else if (r.type == "TEXT") {
440
- const l = r, c = s.get(l.styleName);
441
- c == null || c.forEach((i) => o.add(i));
442
- } else if (r.type == "INSERT") {
443
- const l = r, c = n.get(l.name);
444
- c && this.getFontsInBlock(c.entities, n, s, o);
600
+ const s = o.get(a.styleName);
601
+ s == null || s.forEach((c) => n.add(c));
602
+ } else if (i.type == "TEXT") {
603
+ const a = i, s = o.get(a.styleName);
604
+ s == null || s.forEach((c) => n.add(c));
605
+ } else if (i.type == "MULTILEADER" || i.type == "MLEADER") {
606
+ const a = i, s = a.textContent;
607
+ [...(typeof (s == null ? void 0 : s.text) == "string" ? s.text : "").matchAll(r)].forEach((f) => {
608
+ n.add(f[1].toLowerCase());
609
+ });
610
+ const d = typeof (s == null ? void 0 : s.styleName) == "string" ? s.styleName : typeof a.textStyleName == "string" ? a.textStyleName : typeof a.styleName == "string" ? a.styleName : void 0, l = d ? o.get(d) : void 0;
611
+ l == null || l.forEach((f) => n.add(f));
612
+ } else if (i.type == "INSERT") {
613
+ const a = i, s = t.get(a.name);
614
+ s && this.getFontsInBlock(s.entities, t, o, n);
445
615
  }
446
616
  });
447
617
  }
448
- processLineTypes(e, n) {
449
- e.tables.LTYPE.entries.forEach((o) => {
450
- const t = {
451
- name: o.name,
452
- description: o.description,
453
- standardFlag: o.standardFlag,
454
- totalPatternLength: o.totalPatternLength,
455
- pattern: o.pattern
456
- }, r = new Ae(t);
457
- this.processCommonTableEntryAttrs(o, r), r.name = o.name, n.tables.linetypeTable.add(r);
618
+ processLineTypes(e, t) {
619
+ e.tables.LTYPE.entries.forEach((n) => {
620
+ const r = {
621
+ name: n.name,
622
+ description: n.description,
623
+ standardFlag: n.standardFlag,
624
+ totalPatternLength: n.totalPatternLength,
625
+ pattern: n.pattern
626
+ }, i = new Ee(r);
627
+ this.processCommonTableEntryAttrs(n, i), i.name = n.name, t.tables.linetypeTable.add(i);
458
628
  });
459
629
  }
460
- processTextStyles(e, n) {
461
- e.tables.STYLE.entries.forEach((o) => {
462
- const t = new Ie(o);
463
- this.processCommonTableEntryAttrs(o, t), n.tables.textStyleTable.add(t);
630
+ processTextStyles(e, t) {
631
+ e.tables.STYLE.entries.forEach((n) => {
632
+ const r = new Se(n);
633
+ this.processCommonTableEntryAttrs(n, r), t.tables.textStyleTable.add(r);
464
634
  });
465
635
  }
466
- processDimStyles(e, n) {
467
- e.tables.DIMSTYLE.entries.forEach((o) => {
468
- const t = {
469
- name: o.name,
470
- ownerId: o.ownerHandle,
471
- dimpost: o.DIMPOST || "",
472
- dimapost: o.DIMAPOST || "",
473
- dimscale: o.DIMSCALE,
474
- dimasz: o.DIMASZ,
475
- dimexo: o.DIMEXO,
476
- dimdli: o.DIMDLI,
477
- dimexe: o.DIMEXE,
478
- dimrnd: o.DIMRND,
479
- dimdle: o.DIMDLE,
480
- dimtp: o.DIMTP,
481
- dimtm: o.DIMTM,
482
- dimtxt: o.DIMTXT,
483
- dimcen: o.DIMCEN,
484
- dimtsz: o.DIMTSZ,
485
- dimaltf: o.DIMALTF,
486
- dimlfac: o.DIMLFAC,
487
- dimtvp: o.DIMTVP,
488
- dimtfac: o.DIMTFAC,
489
- dimgap: o.DIMGAP,
490
- dimaltrnd: o.DIMALTRND,
491
- dimtol: o.DIMTOL == null || o.DIMTOL == 0 ? 0 : 1,
492
- dimlim: o.DIMLIM == null || o.DIMLIM == 0 ? 0 : 1,
493
- dimtih: o.DIMTIH == null || o.DIMTIH == 0 ? 0 : 1,
494
- dimtoh: o.DIMTOH == null || o.DIMTOH == 0 ? 0 : 1,
495
- dimse1: o.DIMSE1 == null || o.DIMSE1 == 0 ? 0 : 1,
496
- dimse2: o.DIMSE2 == null || o.DIMSE2 == 0 ? 0 : 1,
497
- dimtad: o.DIMTAD,
498
- dimzin: o.DIMZIN,
499
- dimazin: o.DIMAZIN,
500
- dimalt: o.DIMALT,
501
- dimaltd: o.DIMALTD,
502
- dimtofl: o.DIMTOFL,
503
- dimsah: o.DIMSAH,
504
- dimtix: o.DIMTIX,
505
- dimsoxd: o.DIMSOXD,
506
- dimclrd: o.DIMCLRD,
507
- dimclre: o.DIMCLRE,
508
- dimclrt: o.DIMCLRT,
509
- dimadec: o.DIMADEC || 0,
510
- dimunit: o.DIMUNIT || 2,
511
- dimdec: o.DIMDEC,
512
- dimtdec: o.DIMTDEC,
513
- dimaltu: o.DIMALTU,
514
- dimalttd: o.DIMALTTD,
515
- dimaunit: o.DIMAUNIT,
516
- dimfrac: o.DIMFRAC,
517
- dimlunit: o.DIMLUNIT,
518
- dimdsep: o.DIMDSEP || ".",
519
- dimtmove: o.DIMTMOVE || 0,
520
- dimjust: o.DIMJUST,
521
- dimsd1: o.DIMSD1,
522
- dimsd2: o.DIMSD2,
523
- dimtolj: o.DIMTOLJ,
524
- dimtzin: o.DIMTZIN,
525
- dimaltz: o.DIMALTZ,
526
- dimalttz: o.DIMALTTZ,
527
- dimfit: o.DIMFIT || 0,
528
- dimupt: o.DIMUPT,
529
- dimatfit: o.DIMATFIT,
530
- dimtxsty: S,
636
+ processDimStyles(e, t) {
637
+ e.tables.DIMSTYLE.entries.forEach((n) => {
638
+ const r = {
639
+ name: n.name,
640
+ ownerId: n.ownerHandle,
641
+ dimpost: n.DIMPOST || "",
642
+ dimapost: n.DIMAPOST || "",
643
+ dimscale: n.DIMSCALE,
644
+ dimasz: n.DIMASZ,
645
+ dimexo: n.DIMEXO,
646
+ dimdli: n.DIMDLI,
647
+ dimexe: n.DIMEXE,
648
+ dimrnd: n.DIMRND,
649
+ dimdle: n.DIMDLE,
650
+ dimtp: n.DIMTP,
651
+ dimtm: n.DIMTM,
652
+ dimtxt: n.DIMTXT,
653
+ dimcen: n.DIMCEN,
654
+ dimtsz: n.DIMTSZ,
655
+ dimaltf: n.DIMALTF,
656
+ dimlfac: n.DIMLFAC,
657
+ dimtvp: n.DIMTVP,
658
+ dimtfac: n.DIMTFAC,
659
+ dimgap: n.DIMGAP,
660
+ dimaltrnd: n.DIMALTRND,
661
+ dimtol: n.DIMTOL == null || n.DIMTOL == 0 ? 0 : 1,
662
+ dimlim: n.DIMLIM == null || n.DIMLIM == 0 ? 0 : 1,
663
+ dimtih: n.DIMTIH == null || n.DIMTIH == 0 ? 0 : 1,
664
+ dimtoh: n.DIMTOH == null || n.DIMTOH == 0 ? 0 : 1,
665
+ dimse1: n.DIMSE1 == null || n.DIMSE1 == 0 ? 0 : 1,
666
+ dimse2: n.DIMSE2 == null || n.DIMSE2 == 0 ? 0 : 1,
667
+ dimtad: n.DIMTAD,
668
+ dimzin: n.DIMZIN,
669
+ dimazin: n.DIMAZIN,
670
+ dimalt: n.DIMALT,
671
+ dimaltd: n.DIMALTD,
672
+ dimtofl: n.DIMTOFL,
673
+ dimsah: n.DIMSAH,
674
+ dimtix: n.DIMTIX,
675
+ dimsoxd: n.DIMSOXD,
676
+ dimclrd: n.DIMCLRD,
677
+ dimclre: n.DIMCLRE,
678
+ dimclrt: n.DIMCLRT,
679
+ dimadec: n.DIMADEC || 0,
680
+ dimunit: n.DIMUNIT || 2,
681
+ dimdec: n.DIMDEC,
682
+ dimtdec: n.DIMTDEC,
683
+ dimaltu: n.DIMALTU,
684
+ dimalttd: n.DIMALTTD,
685
+ dimaunit: n.DIMAUNIT,
686
+ dimfrac: n.DIMFRAC,
687
+ dimlunit: n.DIMLUNIT,
688
+ dimdsep: n.DIMDSEP || ".",
689
+ dimtmove: n.DIMTMOVE || 0,
690
+ dimjust: n.DIMJUST,
691
+ dimsd1: n.DIMSD1,
692
+ dimsd2: n.DIMSD2,
693
+ dimtolj: n.DIMTOLJ,
694
+ dimtzin: n.DIMTZIN,
695
+ dimaltz: n.DIMALTZ,
696
+ dimalttz: n.DIMALTTZ,
697
+ dimfit: n.DIMFIT || 0,
698
+ dimupt: n.DIMUPT,
699
+ dimatfit: n.DIMATFIT,
700
+ dimtxsty: R,
531
701
  dimldrblk: "",
532
- dimblk: o.DIMBLK || "",
533
- dimblk1: o.DIMBLK1 || "",
534
- dimblk2: o.DIMBLK2 || "",
535
- dimlwd: o.DIMLWD,
536
- dimlwe: o.DIMLWE
537
- }, r = new ye(t);
538
- this.processCommonTableEntryAttrs(o, r), n.tables.dimStyleTable.add(r);
702
+ dimblk: n.DIMBLK || "",
703
+ dimblk1: n.DIMBLK1 || "",
704
+ dimblk2: n.DIMBLK2 || "",
705
+ dimlwd: n.DIMLWD,
706
+ dimlwe: n.DIMLWE
707
+ }, i = new Me(r);
708
+ this.processCommonTableEntryAttrs(n, i), t.tables.dimStyleTable.add(i);
539
709
  });
540
710
  }
541
- processLayers(e, n) {
542
- e.tables.LAYER.entries.forEach((o) => {
543
- const t = new we();
544
- t.colorIndex = o.colorIndex;
545
- const r = new Te({
546
- name: o.name,
547
- standardFlags: o.standardFlag,
548
- linetype: o.lineType,
549
- lineWeight: o.lineweight,
550
- isOff: o.off,
551
- color: t,
552
- isPlottable: o.plotFlag != 0
711
+ processLayers(e, t) {
712
+ e.tables.LAYER.entries.forEach((n) => {
713
+ const r = new me();
714
+ r.colorIndex = n.colorIndex;
715
+ const i = new ve({
716
+ name: n.name,
717
+ standardFlags: n.standardFlag,
718
+ linetype: n.lineType,
719
+ lineWeight: n.lineweight,
720
+ isOff: n.off,
721
+ color: r,
722
+ isPlottable: n.plotFlag != 0
553
723
  });
554
- this.processCommonTableEntryAttrs(o, r), n.tables.layerTable.add(r);
724
+ this.processCommonTableEntryAttrs(n, i), t.tables.layerTable.add(i);
555
725
  });
556
726
  }
557
- processViewports(e, n) {
558
- e.tables.VPORT.entries.forEach((o) => {
559
- const t = new be();
560
- 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);
727
+ processViewports(e, t) {
728
+ e.tables.VPORT.entries.forEach((n) => {
729
+ const r = new ke();
730
+ this.processCommonTableEntryAttrs(n, r), n.circleSides && (r.circleSides = n.circleSides), r.standardFlag = n.standardFlag, r.center.copy(n.center), r.lowerLeftCorner.copy(n.lowerLeftCorner), r.upperRightCorner.copy(n.upperRightCorner), n.snapBasePoint && r.snapBase.copy(n.snapBasePoint), n.snapRotationAngle && (r.snapAngle = n.snapRotationAngle), n.snapSpacing && r.snapIncrements.copy(n.snapSpacing), n.majorGridLines && (r.gridMajor = n.majorGridLines), n.gridSpacing && r.gridIncrements.copy(n.gridSpacing), n.backgroundObjectId && (r.backgroundObjectId = n.backgroundObjectId), r.gsView.center.copy(n.center), r.gsView.viewDirectionFromTarget.copy(n.viewDirectionFromTarget), r.gsView.viewTarget.copy(n.viewTarget), n.lensLength && (r.gsView.lensLength = n.lensLength), n.frontClippingPlane && (r.gsView.frontClippingPlane = n.frontClippingPlane), n.backClippingPlane && (r.gsView.backClippingPlane = n.backClippingPlane), n.viewHeight && (r.gsView.viewHeight = n.viewHeight), n.viewTwistAngle && (r.gsView.viewTwistAngle = n.viewTwistAngle), n.frozenLayers && (r.gsView.frozenLayers = n.frozenLayers), n.styleSheet && (r.gsView.styleSheet = n.styleSheet), n.renderMode && (r.gsView.renderMode = n.renderMode), n.viewMode && (r.gsView.viewMode = n.viewMode), n.ucsIconSetting && (r.gsView.ucsIconSetting = n.ucsIconSetting), n.ucsOrigin && r.gsView.ucsOrigin.copy(n.ucsOrigin), n.ucsXAxis && r.gsView.ucsXAxis.copy(n.ucsXAxis), n.ucsYAxis && r.gsView.ucsYAxis.copy(n.ucsYAxis), n.orthographicType && (r.gsView.orthographicType = n.orthographicType), n.shadePlotSetting && (r.gsView.shadePlotSetting = n.shadePlotSetting), n.shadePlotObjectId && (r.gsView.shadePlotObjectId = n.shadePlotObjectId), n.visualStyleObjectId && (r.gsView.visualStyleObjectId = n.visualStyleObjectId), n.isDefaultLightingOn && (r.gsView.isDefaultLightingOn = n.isDefaultLightingOn), n.defaultLightingType && (r.gsView.defaultLightingType = n.defaultLightingType), n.brightness && (r.gsView.brightness = n.brightness), n.contrast && (r.gsView.contrast = n.contrast), n.ambientColor && (r.gsView.ambientColor = n.ambientColor), t.tables.viewportTable.add(r);
561
731
  });
562
732
  }
563
- processBlockTables(e, n) {
564
- e.tables.BLOCK_RECORD.entries.forEach((o) => {
565
- let t = n.tables.blockTable.getAt(o.name);
566
- t || (t = new Pe(), 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);
733
+ processBlockTables(e, t) {
734
+ e.tables.BLOCK_RECORD.entries.forEach((n) => {
735
+ let r = t.tables.blockTable.getAt(n.name);
736
+ r || (r = new Oe(), r.objectId = n.handle, r.name = n.name, r.ownerId = n.ownerHandle, r.origin.copy(n.basePoint), r.layoutId = n.layout, r.blockInsertUnits = n.insertionUnits, r.explodability = n.explodability, r.blockScaling = n.scalability, n.bmpPreview && (r.bmpPreview = n.bmpPreview), t.tables.blockTable.add(r)), !r.isModelSapce && n.entities && n.entities.length > 0 && this.processEntitiesInBlock(n.entities, r);
567
737
  });
568
738
  }
569
- processBlocks(e, n) {
739
+ processBlocks(e, t) {
570
740
  }
571
- async processEntitiesInBlock(e, n) {
572
- const s = new x(), o = e.length, t = [];
573
- for (let r = 0; r < o; r++) {
574
- const l = e[r], c = s.convert(l);
575
- c && t.push(c);
741
+ async processEntitiesInBlock(e, t) {
742
+ const o = new V(), n = e.length, r = [];
743
+ for (let i = 0; i < n; i++) {
744
+ const a = e[i], s = o.convert(a);
745
+ s && r.push(s);
576
746
  }
577
- n.appendEntity(t);
747
+ t.appendEntity(r);
578
748
  }
579
- async processEntities(e, n, s, o, t) {
580
- const r = new x();
581
- let l = [];
582
- e.tables.BLOCK_RECORD.entries.forEach((a) => {
583
- this.isModelSpace(a.name) && (l = a.entities);
749
+ async processEntities(e, t, o, n, r) {
750
+ const i = new V();
751
+ let a = [];
752
+ e.tables.BLOCK_RECORD.entries.forEach((l) => {
753
+ this.isModelSpace(l.name) && (a = l.entities);
584
754
  });
585
- const c = l.length, i = new Ee(
586
- c,
587
- 100 - o.value,
588
- s
755
+ const s = a.length, c = new Ne(
756
+ s,
757
+ 100 - n.value,
758
+ o
589
759
  );
590
- this.config.convertByEntityType && (l = this.groupAndFlattenByType(l));
591
- const d = n.tables.blockTable.modelSpace;
592
- await i.processChunk(async (a, h) => {
760
+ this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
761
+ const d = t.tables.blockTable.modelSpace;
762
+ await c.processChunk(async (l, f) => {
593
763
  const p = [];
594
- for (let f = a; f < h; f++) {
595
- const u = l[f], g = r.convert(u);
596
- g && p.push(g);
764
+ for (let u = l; u < f; u++) {
765
+ const g = a[u], y = i.convert(g);
766
+ y && p.push(y);
597
767
  }
598
- if (d.appendEntity(p), t) {
599
- let f = o.value + h / c * (100 - o.value);
600
- f > 100 && (f = 100), await t(f, "ENTITY", "IN-PROGRESS");
768
+ if (d.appendEntity(p), r) {
769
+ let u = n.value + f / s * (100 - n.value);
770
+ u > 100 && (u = 100), await r(u, "ENTITY", "IN-PROGRESS");
601
771
  }
602
772
  });
603
773
  }
604
- processHeader(e, n) {
605
- const s = e.header;
606
- 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 ?? Me, 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 ?? S;
607
- }
608
- processCommonTableEntryAttrs(e, n) {
609
- n.name = e.name, n.objectId = e.handle, e.ownerHandle != null && (n.ownerId = e.ownerHandle);
610
- }
611
- processObjects(e, n) {
612
- this.processLayouts(e, n), this.processImageDefs(e, n);
613
- }
614
- processLayouts(e, n) {
615
- const s = n.objects.layout;
616
- e.objects.LAYOUT.forEach((t) => {
617
- const r = new Ce();
618
- r.layoutName = t.layoutName, r.tabOrder = t.tabOrder;
619
- const l = n.tables.blockTable.newIterator();
620
- r.objectId = t.handle;
621
- for (const c of l)
622
- if (c.layoutId === r.objectId) {
623
- r.blockTableRecordId = c.objectId;
774
+ processHeader(e, t) {
775
+ const o = e.header;
776
+ o.CECOLOR && (o.CECOLOR.index >= 0 && o.CECOLOR.index <= 256 ? t.cecolor.colorIndex = o.CECOLOR.index : t.cecolor.setRGBValue(o.CECOLOR.rgb)), t.angBase = o.ANGBASE ?? 0, t.angDir = o.ANGDIR ?? 0, t.aunits = o.AUNITS ?? 0, t.celtype = o.CELTYPE ?? Re, t.celtscale = o.CELTSCALE ?? 1, t.ltscale = o.LTSCALE ?? 1, o.EXTMAX && (t.extmax = o.EXTMAX), o.EXTMIN && (t.extmin = o.EXTMIN), t.insunits = o.INSUNITS ?? 1, t.pdmode = o.PDMODE ?? 0, t.pdsize = o.PDSIZE ?? 0, t.textstyle = o.TEXTSTYLE ?? R;
777
+ }
778
+ processCommonTableEntryAttrs(e, t) {
779
+ t.name = e.name, t.objectId = e.handle, e.ownerHandle != null && (t.ownerId = e.ownerHandle);
780
+ }
781
+ processObjects(e, t) {
782
+ this.processLayouts(e, t), this.processImageDefs(e, t);
783
+ }
784
+ processLayouts(e, t) {
785
+ const o = t.objects.layout;
786
+ e.objects.LAYOUT.forEach((r) => {
787
+ const i = new Ve();
788
+ i.layoutName = r.layoutName, i.tabOrder = r.tabOrder;
789
+ const a = t.tables.blockTable.newIterator();
790
+ i.objectId = r.handle;
791
+ for (const s of a)
792
+ if (s.layoutId === i.objectId) {
793
+ i.blockTableRecordId = s.objectId;
624
794
  break;
625
795
  }
626
- 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);
796
+ i.blockTableRecordId || r.layoutName === "Model" && (i.blockTableRecordId = t.tables.blockTable.modelSpace.objectId), i.limits.min.copy(r.minLimit), i.limits.max.copy(r.maxLimit), i.extents.min.copy(r.minExtent), i.extents.max.copy(r.maxExtent), r.viewportId && i.viewportArray.push(r.viewportId), this.processCommonObjectAttrs(r, i), o.setAt(i.layoutName, i);
627
797
  });
628
798
  }
629
- processImageDefs(e, n) {
630
- const s = n.objects.imageDefinition;
631
- e.objects.IMAGEDEF.forEach((t) => {
632
- const r = new Le();
633
- r.sourceFileName = t.fileName, this.processCommonObjectAttrs(t, r), s.setAt(r.objectId, r);
799
+ processImageDefs(e, t) {
800
+ const o = t.objects.imageDefinition;
801
+ e.objects.IMAGEDEF.forEach((r) => {
802
+ const i = new Fe();
803
+ i.sourceFileName = r.fileName, this.processCommonObjectAttrs(r, i), o.setAt(i.objectId, i);
634
804
  });
635
805
  }
636
- processCommonObjectAttrs(e, n) {
637
- n.objectId = e.handle, e.ownerHandle != null && (n.ownerId = e.ownerHandle);
806
+ processCommonObjectAttrs(e, t) {
807
+ t.objectId = e.handle, e.ownerHandle != null && (t.ownerId = e.ownerHandle);
638
808
  }
639
809
  groupAndFlattenByType(e) {
640
- const n = {}, s = [];
641
- for (const o of e)
642
- n[o.type] || (n[o.type] = [], s.push(o.type)), n[o.type].push(o);
643
- return s.flatMap((o) => n[o]);
810
+ const t = {}, o = [];
811
+ for (const n of e)
812
+ t[n.type] || (t[n.type] = [], o.push(n.type)), t[n.type].push(n);
813
+ return o.flatMap((n) => t[n]);
644
814
  }
645
815
  isModelSpace(e) {
646
- return e && e.toUpperCase() == Se;
816
+ return e && e.toUpperCase() == Be;
647
817
  }
648
818
  }
649
819
  export {
650
- ve as AcDbLibreDwgConverter
820
+ je as AcDbLibreDwgConverter
651
821
  };