@mlightcad/data-model 1.7.27 → 1.7.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +224 -224
  3. package/dist/data-model.cjs +4 -3
  4. package/dist/data-model.js +5870 -3428
  5. package/dist/dxf-parser-worker.js +1002 -740
  6. package/lib/converter/AcDbDxfConverter.d.ts.map +1 -1
  7. package/lib/converter/AcDbDxfConverter.js +28 -0
  8. package/lib/converter/AcDbDxfConverter.js.map +1 -1
  9. package/lib/converter/AcDbEntitiyConverter.d.ts +12 -0
  10. package/lib/converter/AcDbEntitiyConverter.d.ts.map +1 -1
  11. package/lib/converter/AcDbEntitiyConverter.js +552 -3
  12. package/lib/converter/AcDbEntitiyConverter.js.map +1 -1
  13. package/lib/converter/AcDbObjectConverter.d.ts +10 -3
  14. package/lib/converter/AcDbObjectConverter.d.ts.map +1 -1
  15. package/lib/converter/AcDbObjectConverter.js +154 -1
  16. package/lib/converter/AcDbObjectConverter.js.map +1 -1
  17. package/lib/converter/AcDbRegenerator.d.ts.map +1 -1
  18. package/lib/converter/AcDbRegenerator.js +22 -4
  19. package/lib/converter/AcDbRegenerator.js.map +1 -1
  20. package/lib/database/AcDbDatabase.d.ts +4 -0
  21. package/lib/database/AcDbDatabase.d.ts.map +1 -1
  22. package/lib/database/AcDbDatabase.js +67 -15
  23. package/lib/database/AcDbDatabase.js.map +1 -1
  24. package/lib/entity/AcDbLeader.d.ts +32 -3
  25. package/lib/entity/AcDbLeader.d.ts.map +1 -1
  26. package/lib/entity/AcDbLeader.js +140 -10
  27. package/lib/entity/AcDbLeader.js.map +1 -1
  28. package/lib/entity/AcDbMLeader.d.ts +899 -0
  29. package/lib/entity/AcDbMLeader.d.ts.map +1 -0
  30. package/lib/entity/AcDbMLeader.js +2122 -0
  31. package/lib/entity/AcDbMLeader.js.map +1 -0
  32. package/lib/entity/AcDbMLine.d.ts +122 -0
  33. package/lib/entity/AcDbMLine.d.ts.map +1 -0
  34. package/lib/entity/AcDbMLine.js +548 -0
  35. package/lib/entity/AcDbMLine.js.map +1 -0
  36. package/lib/entity/dimension/AcDbDiametricDimension.d.ts +0 -33
  37. package/lib/entity/dimension/AcDbDiametricDimension.d.ts.map +1 -1
  38. package/lib/entity/dimension/AcDbDiametricDimension.js +0 -80
  39. package/lib/entity/dimension/AcDbDiametricDimension.js.map +1 -1
  40. package/lib/entity/dimension/AcDbDimension.d.ts +1 -9
  41. package/lib/entity/dimension/AcDbDimension.d.ts.map +1 -1
  42. package/lib/entity/dimension/AcDbDimension.js +0 -10
  43. package/lib/entity/dimension/AcDbDimension.js.map +1 -1
  44. package/lib/entity/dimension/AcDbRadialDimension.d.ts +0 -6
  45. package/lib/entity/dimension/AcDbRadialDimension.d.ts.map +1 -1
  46. package/lib/entity/dimension/AcDbRadialDimension.js +0 -8
  47. package/lib/entity/dimension/AcDbRadialDimension.js.map +1 -1
  48. package/lib/entity/index.d.ts +2 -0
  49. package/lib/entity/index.d.ts.map +1 -1
  50. package/lib/entity/index.js +2 -0
  51. package/lib/entity/index.js.map +1 -1
  52. package/lib/object/AcDbMLeaderStyle.d.ts +404 -0
  53. package/lib/object/AcDbMLeaderStyle.d.ts.map +1 -0
  54. package/lib/object/AcDbMLeaderStyle.js +1004 -0
  55. package/lib/object/AcDbMLeaderStyle.js.map +1 -0
  56. package/lib/object/AcDbMlineStyle.d.ts +57 -0
  57. package/lib/object/AcDbMlineStyle.d.ts.map +1 -0
  58. package/lib/object/AcDbMlineStyle.js +164 -0
  59. package/lib/object/AcDbMlineStyle.js.map +1 -0
  60. package/lib/object/index.d.ts +2 -0
  61. package/lib/object/index.d.ts.map +1 -1
  62. package/lib/object/index.js +2 -0
  63. package/lib/object/index.js.map +1 -1
  64. package/package.json +5 -5
@@ -0,0 +1,2122 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __read = (this && this.__read) || function (o, n) {
17
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
18
+ if (!m) return o;
19
+ var i = m.call(o), r, ar = [], e;
20
+ try {
21
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22
+ }
23
+ catch (error) { e = { error: error }; }
24
+ finally {
25
+ try {
26
+ if (r && !r.done && (m = i["return"])) m.call(i);
27
+ }
28
+ finally { if (e) throw e.error; }
29
+ }
30
+ return ar;
31
+ };
32
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34
+ if (ar || !(i in from)) {
35
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
36
+ ar[i] = from[i];
37
+ }
38
+ }
39
+ return to.concat(ar || Array.prototype.slice.call(from));
40
+ };
41
+ import { AcGeArea2d, AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePolyline2d, AcGeVector3d } from '@mlightcad/geometry-engine';
42
+ import { AcGiMTextAttachmentPoint, AcGiMTextFlowDirection } from '@mlightcad/graphic-interface';
43
+ import { AcDbRenderingCache, DEFAULT_TEXT_STYLE } from '../misc';
44
+ import { AcDbEntity } from './AcDbEntity';
45
+ /**
46
+ * Defines the type of leader line used by a multileader.
47
+ */
48
+ export var AcDbMLeaderLineType;
49
+ (function (AcDbMLeaderLineType) {
50
+ /** The leader line is not displayed. */
51
+ AcDbMLeaderLineType[AcDbMLeaderLineType["InvisibleLeader"] = 0] = "InvisibleLeader";
52
+ /** The leader line is drawn using straight segments. */
53
+ AcDbMLeaderLineType[AcDbMLeaderLineType["StraightLeader"] = 1] = "StraightLeader";
54
+ /** The leader line is drawn as a spline. */
55
+ AcDbMLeaderLineType[AcDbMLeaderLineType["SplineLeader"] = 2] = "SplineLeader";
56
+ })(AcDbMLeaderLineType || (AcDbMLeaderLineType = {}));
57
+ /**
58
+ * Defines the annotation content type used by a multileader.
59
+ */
60
+ export var AcDbMLeaderContentType;
61
+ (function (AcDbMLeaderContentType) {
62
+ /** No annotation content. */
63
+ AcDbMLeaderContentType[AcDbMLeaderContentType["NoneContent"] = 0] = "NoneContent";
64
+ /** Block annotation content. */
65
+ AcDbMLeaderContentType[AcDbMLeaderContentType["BlockContent"] = 1] = "BlockContent";
66
+ /** MText annotation content. */
67
+ AcDbMLeaderContentType[AcDbMLeaderContentType["MTextContent"] = 2] = "MTextContent";
68
+ /** Tolerance annotation content. */
69
+ AcDbMLeaderContentType[AcDbMLeaderContentType["ToleranceContent"] = 3] = "ToleranceContent";
70
+ })(AcDbMLeaderContentType || (AcDbMLeaderContentType = {}));
71
+ /**
72
+ * Defines the attachment direction of multileader text.
73
+ */
74
+ export var AcDbMLeaderTextAttachmentDirection;
75
+ (function (AcDbMLeaderTextAttachmentDirection) {
76
+ /** Text is attached horizontally. */
77
+ AcDbMLeaderTextAttachmentDirection[AcDbMLeaderTextAttachmentDirection["Horizontal"] = 0] = "Horizontal";
78
+ /** Text is attached vertically. */
79
+ AcDbMLeaderTextAttachmentDirection[AcDbMLeaderTextAttachmentDirection["Vertical"] = 1] = "Vertical";
80
+ })(AcDbMLeaderTextAttachmentDirection || (AcDbMLeaderTextAttachmentDirection = {}));
81
+ /**
82
+ * Defines the general direction of a leader branch.
83
+ */
84
+ export var AcDbMLeaderDirectionType;
85
+ (function (AcDbMLeaderDirectionType) {
86
+ /** Direction is not known or not applicable. */
87
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Unknown"] = 0] = "Unknown";
88
+ /** Leader points to the left of the content. */
89
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Left"] = 1] = "Left";
90
+ /** Leader points to the right of the content. */
91
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Right"] = 2] = "Right";
92
+ /** Leader points above the content. */
93
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Top"] = 3] = "Top";
94
+ /** Leader points below the content. */
95
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Bottom"] = 4] = "Bottom";
96
+ })(AcDbMLeaderDirectionType || (AcDbMLeaderDirectionType = {}));
97
+ /**
98
+ * Represents a multileader entity.
99
+ *
100
+ * A multileader contains one or more leader branches, each of which can contain
101
+ * one or more leader lines, plus optional MText or block content.
102
+ */
103
+ var AcDbMLeader = /** @class */ (function (_super) {
104
+ __extends(AcDbMLeader, _super);
105
+ /**
106
+ * Creates an empty multileader entity with default style-related state.
107
+ */
108
+ function AcDbMLeader() {
109
+ var _this = _super.call(this) || this;
110
+ _this._leaders = [];
111
+ _this._leaderLineType = AcDbMLeaderLineType.StraightLeader;
112
+ _this._contentType = AcDbMLeaderContentType.NoneContent;
113
+ _this._doglegEnabled = false;
114
+ _this._doglegLength = 0;
115
+ _this._doglegVector = new AcGeVector3d(1, 0, 0);
116
+ _this._normal = new AcGeVector3d(0, 0, 1);
117
+ _this._mleaderStyleId = '';
118
+ _this._textHeight = 2.5;
119
+ _this._textWidth = 0;
120
+ _this._textRotation = 0;
121
+ _this._textDirection = new AcGeVector3d(1, 0, 0);
122
+ _this._textStyleName = '';
123
+ _this._textAttachmentPoint = AcGiMTextAttachmentPoint.MiddleLeft;
124
+ _this._textDrawingDirection = AcGiMTextFlowDirection.LEFT_TO_RIGHT;
125
+ _this._textLineSpacingFactor = 1;
126
+ _this._textAttachmentDirection =
127
+ AcDbMLeaderTextAttachmentDirection.Horizontal;
128
+ _this._arrowheadOverrides = [];
129
+ _this._blockAttributes = [];
130
+ return _this;
131
+ }
132
+ Object.defineProperty(AcDbMLeader.prototype, "dxfTypeName", {
133
+ /**
134
+ * Gets the DXF type name used when exporting this entity.
135
+ */
136
+ get: function () {
137
+ return 'MULTILEADER';
138
+ },
139
+ enumerable: false,
140
+ configurable: true
141
+ });
142
+ Object.defineProperty(AcDbMLeader.prototype, "leaders", {
143
+ /**
144
+ * Gets a deep-cloned collection of all leader branches.
145
+ */
146
+ get: function () {
147
+ var _this = this;
148
+ return this._leaders.map(function (leader) { return _this.cloneLeader(leader); });
149
+ },
150
+ enumerable: false,
151
+ configurable: true
152
+ });
153
+ Object.defineProperty(AcDbMLeader.prototype, "numberOfLeaders", {
154
+ /**
155
+ * Gets the current number of leader branches.
156
+ */
157
+ get: function () {
158
+ return this._leaders.length;
159
+ },
160
+ enumerable: false,
161
+ configurable: true
162
+ });
163
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineType", {
164
+ /**
165
+ * Gets the leader line type.
166
+ */
167
+ get: function () {
168
+ return this._leaderLineType;
169
+ },
170
+ set: function (value) {
171
+ this._leaderLineType = value;
172
+ },
173
+ enumerable: false,
174
+ configurable: true
175
+ });
176
+ Object.defineProperty(AcDbMLeader.prototype, "contentType", {
177
+ /**
178
+ * Gets the content type.
179
+ */
180
+ get: function () {
181
+ return this._contentType;
182
+ },
183
+ set: function (value) {
184
+ this._contentType = value;
185
+ },
186
+ enumerable: false,
187
+ configurable: true
188
+ });
189
+ Object.defineProperty(AcDbMLeader.prototype, "doglegEnabled", {
190
+ /**
191
+ * Gets the dogleg enabled.
192
+ */
193
+ get: function () {
194
+ return this._doglegEnabled;
195
+ },
196
+ set: function (value) {
197
+ this._doglegEnabled = value;
198
+ },
199
+ enumerable: false,
200
+ configurable: true
201
+ });
202
+ Object.defineProperty(AcDbMLeader.prototype, "doglegLength", {
203
+ /**
204
+ * Gets the dogleg length.
205
+ */
206
+ get: function () {
207
+ return this._doglegLength;
208
+ },
209
+ set: function (value) {
210
+ this._doglegLength = value;
211
+ },
212
+ enumerable: false,
213
+ configurable: true
214
+ });
215
+ Object.defineProperty(AcDbMLeader.prototype, "doglegVector", {
216
+ /**
217
+ * Gets the dogleg vector.
218
+ */
219
+ get: function () {
220
+ return this._doglegVector;
221
+ },
222
+ set: function (value) {
223
+ this._doglegVector.copy(value);
224
+ },
225
+ enumerable: false,
226
+ configurable: true
227
+ });
228
+ Object.defineProperty(AcDbMLeader.prototype, "landingPoint", {
229
+ /**
230
+ * Gets the landing point.
231
+ */
232
+ get: function () {
233
+ return this._landingPoint;
234
+ },
235
+ set: function (value) {
236
+ this._landingPoint = value ? this.createPoint(value) : undefined;
237
+ },
238
+ enumerable: false,
239
+ configurable: true
240
+ });
241
+ Object.defineProperty(AcDbMLeader.prototype, "normal", {
242
+ /**
243
+ * Gets the normal.
244
+ */
245
+ get: function () {
246
+ return this._normal;
247
+ },
248
+ set: function (value) {
249
+ this._normal.copy(value);
250
+ },
251
+ enumerable: false,
252
+ configurable: true
253
+ });
254
+ Object.defineProperty(AcDbMLeader.prototype, "mleaderStyleId", {
255
+ /**
256
+ * Gets the mleader style id.
257
+ */
258
+ get: function () {
259
+ return this._mleaderStyleId;
260
+ },
261
+ set: function (value) {
262
+ this._mleaderStyleId = value;
263
+ },
264
+ enumerable: false,
265
+ configurable: true
266
+ });
267
+ Object.defineProperty(AcDbMLeader.prototype, "version", {
268
+ /**
269
+ * Gets or sets the serialized MLeader version code.
270
+ *
271
+ * This value mirrors DXF/internal version metadata and is used to keep
272
+ * compatibility with files saved from different AutoCAD generations.
273
+ */
274
+ get: function () {
275
+ return this._version;
276
+ },
277
+ set: function (value) {
278
+ this._version = value;
279
+ },
280
+ enumerable: false,
281
+ configurable: true
282
+ });
283
+ Object.defineProperty(AcDbMLeader.prototype, "leaderStyleId", {
284
+ /**
285
+ * Gets or sets the MLeader style handle override stored on the entity.
286
+ *
287
+ * When provided, this value is typically used as a fallback in addition to
288
+ * `mleaderStyleId` during style resolution.
289
+ */
290
+ get: function () {
291
+ return this._leaderStyleId;
292
+ },
293
+ set: function (value) {
294
+ this._leaderStyleId = value;
295
+ },
296
+ enumerable: false,
297
+ configurable: true
298
+ });
299
+ Object.defineProperty(AcDbMLeader.prototype, "propertyOverrideFlag", {
300
+ /**
301
+ * Gets or sets the property-override bit flag.
302
+ *
303
+ * The flag indicates which visual/behavioral properties are overridden at the
304
+ * entity level instead of inherited from the referenced MLeader style.
305
+ */
306
+ get: function () {
307
+ return this._propertyOverrideFlag;
308
+ },
309
+ set: function (value) {
310
+ this._propertyOverrideFlag = value;
311
+ },
312
+ enumerable: false,
313
+ configurable: true
314
+ });
315
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineColor", {
316
+ /**
317
+ * Gets or sets the explicit leader line color override.
318
+ */
319
+ get: function () {
320
+ return this._leaderLineColor;
321
+ },
322
+ set: function (value) {
323
+ this._leaderLineColor = value;
324
+ },
325
+ enumerable: false,
326
+ configurable: true
327
+ });
328
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineTypeId", {
329
+ /**
330
+ * Gets or sets the leader line type handle override.
331
+ */
332
+ get: function () {
333
+ return this._leaderLineTypeId;
334
+ },
335
+ set: function (value) {
336
+ this._leaderLineTypeId = value;
337
+ },
338
+ enumerable: false,
339
+ configurable: true
340
+ });
341
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineWeight", {
342
+ /**
343
+ * Gets or sets the lineweight override for leader segments.
344
+ */
345
+ get: function () {
346
+ return this._leaderLineWeight;
347
+ },
348
+ set: function (value) {
349
+ this._leaderLineWeight = value;
350
+ },
351
+ enumerable: false,
352
+ configurable: true
353
+ });
354
+ Object.defineProperty(AcDbMLeader.prototype, "landingEnabled", {
355
+ /**
356
+ * Gets or sets whether leader landings are enabled.
357
+ */
358
+ get: function () {
359
+ return this._landingEnabled;
360
+ },
361
+ set: function (value) {
362
+ this._landingEnabled = value;
363
+ },
364
+ enumerable: false,
365
+ configurable: true
366
+ });
367
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadId", {
368
+ /**
369
+ * Gets or sets the arrowhead block handle/name override.
370
+ */
371
+ get: function () {
372
+ return this._arrowheadId;
373
+ },
374
+ set: function (value) {
375
+ this._arrowheadId = value;
376
+ },
377
+ enumerable: false,
378
+ configurable: true
379
+ });
380
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadSize", {
381
+ /**
382
+ * Gets or sets the arrowhead size override in drawing units.
383
+ */
384
+ get: function () {
385
+ return this._arrowheadSize;
386
+ },
387
+ set: function (value) {
388
+ this._arrowheadSize = value;
389
+ },
390
+ enumerable: false,
391
+ configurable: true
392
+ });
393
+ Object.defineProperty(AcDbMLeader.prototype, "textStyleId", {
394
+ /**
395
+ * Gets or sets the text style handle override for MText content.
396
+ */
397
+ get: function () {
398
+ return this._textStyleId;
399
+ },
400
+ set: function (value) {
401
+ this._textStyleId = value;
402
+ },
403
+ enumerable: false,
404
+ configurable: true
405
+ });
406
+ Object.defineProperty(AcDbMLeader.prototype, "textLeftAttachmentType", {
407
+ /**
408
+ * Gets or sets left-side text attachment behavior code.
409
+ */
410
+ get: function () {
411
+ return this._textLeftAttachmentType;
412
+ },
413
+ set: function (value) {
414
+ this._textLeftAttachmentType = value;
415
+ },
416
+ enumerable: false,
417
+ configurable: true
418
+ });
419
+ Object.defineProperty(AcDbMLeader.prototype, "textRightAttachmentType", {
420
+ /**
421
+ * Gets or sets right-side text attachment behavior code.
422
+ */
423
+ get: function () {
424
+ return this._textRightAttachmentType;
425
+ },
426
+ set: function (value) {
427
+ this._textRightAttachmentType = value;
428
+ },
429
+ enumerable: false,
430
+ configurable: true
431
+ });
432
+ Object.defineProperty(AcDbMLeader.prototype, "textAngleType", {
433
+ /**
434
+ * Gets or sets the text angle type code controlling rotation strategy.
435
+ */
436
+ get: function () {
437
+ return this._textAngleType;
438
+ },
439
+ set: function (value) {
440
+ this._textAngleType = value;
441
+ },
442
+ enumerable: false,
443
+ configurable: true
444
+ });
445
+ Object.defineProperty(AcDbMLeader.prototype, "textAlignmentType", {
446
+ /**
447
+ * Gets or sets the text alignment type code.
448
+ */
449
+ get: function () {
450
+ return this._textAlignmentType;
451
+ },
452
+ set: function (value) {
453
+ this._textAlignmentType = value;
454
+ },
455
+ enumerable: false,
456
+ configurable: true
457
+ });
458
+ Object.defineProperty(AcDbMLeader.prototype, "textColor", {
459
+ /**
460
+ * Gets or sets the MText color override.
461
+ */
462
+ get: function () {
463
+ return this._textColor;
464
+ },
465
+ set: function (value) {
466
+ this._textColor = value;
467
+ },
468
+ enumerable: false,
469
+ configurable: true
470
+ });
471
+ Object.defineProperty(AcDbMLeader.prototype, "textFrameEnabled", {
472
+ /**
473
+ * Gets or sets whether a text frame (border) is enabled.
474
+ */
475
+ get: function () {
476
+ return this._textFrameEnabled;
477
+ },
478
+ set: function (value) {
479
+ this._textFrameEnabled = value;
480
+ },
481
+ enumerable: false,
482
+ configurable: true
483
+ });
484
+ Object.defineProperty(AcDbMLeader.prototype, "landingGap", {
485
+ /**
486
+ * Gets or sets the gap distance between landing and annotation content.
487
+ */
488
+ get: function () {
489
+ return this._landingGap;
490
+ },
491
+ set: function (value) {
492
+ this._landingGap = value;
493
+ },
494
+ enumerable: false,
495
+ configurable: true
496
+ });
497
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachment", {
498
+ /**
499
+ * Gets or sets the legacy text attachment value used in some DXF variants.
500
+ */
501
+ get: function () {
502
+ return this._textAttachment;
503
+ },
504
+ set: function (value) {
505
+ this._textAttachment = value;
506
+ },
507
+ enumerable: false,
508
+ configurable: true
509
+ });
510
+ Object.defineProperty(AcDbMLeader.prototype, "textFlowDirection", {
511
+ /**
512
+ * Gets or sets the text flow direction override code.
513
+ */
514
+ get: function () {
515
+ return this._textFlowDirection;
516
+ },
517
+ set: function (value) {
518
+ this._textFlowDirection = value;
519
+ },
520
+ enumerable: false,
521
+ configurable: true
522
+ });
523
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentId", {
524
+ /**
525
+ * Gets or sets the referenced block content id/handle for block-based content.
526
+ */
527
+ get: function () {
528
+ return this._blockContentId;
529
+ },
530
+ set: function (value) {
531
+ this._blockContentId = value;
532
+ },
533
+ enumerable: false,
534
+ configurable: true
535
+ });
536
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentColor", {
537
+ /**
538
+ * Gets or sets the block content color override.
539
+ */
540
+ get: function () {
541
+ return this._blockContentColor;
542
+ },
543
+ set: function (value) {
544
+ this._blockContentColor = value;
545
+ },
546
+ enumerable: false,
547
+ configurable: true
548
+ });
549
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentScale", {
550
+ /**
551
+ * Gets or sets the block content scale vector override.
552
+ */
553
+ get: function () {
554
+ return this._blockContentScale;
555
+ },
556
+ set: function (value) {
557
+ this._blockContentScale = value;
558
+ },
559
+ enumerable: false,
560
+ configurable: true
561
+ });
562
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentRotation", {
563
+ /**
564
+ * Gets or sets the block content rotation override in radians.
565
+ */
566
+ get: function () {
567
+ return this._blockContentRotation;
568
+ },
569
+ set: function (value) {
570
+ this._blockContentRotation = value;
571
+ },
572
+ enumerable: false,
573
+ configurable: true
574
+ });
575
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentConnectionType", {
576
+ /**
577
+ * Gets or sets the block content connection type code.
578
+ */
579
+ get: function () {
580
+ return this._blockContentConnectionType;
581
+ },
582
+ set: function (value) {
583
+ this._blockContentConnectionType = value;
584
+ },
585
+ enumerable: false,
586
+ configurable: true
587
+ });
588
+ Object.defineProperty(AcDbMLeader.prototype, "annotativeScaleEnabled", {
589
+ /**
590
+ * Gets or sets whether annotative scaling is enabled for this entity.
591
+ */
592
+ get: function () {
593
+ return this._annotativeScaleEnabled;
594
+ },
595
+ set: function (value) {
596
+ this._annotativeScaleEnabled = value;
597
+ },
598
+ enumerable: false,
599
+ configurable: true
600
+ });
601
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadOverrides", {
602
+ /**
603
+ * Gets or sets per-index arrowhead overrides.
604
+ *
605
+ * Each entry maps a branch/line index to a specific arrowhead handle.
606
+ */
607
+ get: function () {
608
+ return this._arrowheadOverrides;
609
+ },
610
+ set: function (value) {
611
+ this._arrowheadOverrides = value;
612
+ },
613
+ enumerable: false,
614
+ configurable: true
615
+ });
616
+ Object.defineProperty(AcDbMLeader.prototype, "blockAttributes", {
617
+ /**
618
+ * Gets or sets block attribute override values used by block content.
619
+ */
620
+ get: function () {
621
+ return this._blockAttributes;
622
+ },
623
+ set: function (value) {
624
+ this._blockAttributes = value;
625
+ },
626
+ enumerable: false,
627
+ configurable: true
628
+ });
629
+ Object.defineProperty(AcDbMLeader.prototype, "textDirectionNegative", {
630
+ /**
631
+ * Gets or sets whether text direction is treated as negative.
632
+ */
633
+ get: function () {
634
+ return this._textDirectionNegative;
635
+ },
636
+ set: function (value) {
637
+ this._textDirectionNegative = value;
638
+ },
639
+ enumerable: false,
640
+ configurable: true
641
+ });
642
+ Object.defineProperty(AcDbMLeader.prototype, "textAlignInIPE", {
643
+ /**
644
+ * Gets or sets the in-place editor text alignment code.
645
+ */
646
+ get: function () {
647
+ return this._textAlignInIPE;
648
+ },
649
+ set: function (value) {
650
+ this._textAlignInIPE = value;
651
+ },
652
+ enumerable: false,
653
+ configurable: true
654
+ });
655
+ Object.defineProperty(AcDbMLeader.prototype, "bottomTextAttachmentDirection", {
656
+ /**
657
+ * Gets or sets bottom attachment direction code for vertical text behavior.
658
+ */
659
+ get: function () {
660
+ return this._bottomTextAttachmentDirection;
661
+ },
662
+ set: function (value) {
663
+ this._bottomTextAttachmentDirection = value;
664
+ },
665
+ enumerable: false,
666
+ configurable: true
667
+ });
668
+ Object.defineProperty(AcDbMLeader.prototype, "topTextAttachmentDirection", {
669
+ /**
670
+ * Gets or sets top attachment direction code for vertical text behavior.
671
+ */
672
+ get: function () {
673
+ return this._topTextAttachmentDirection;
674
+ },
675
+ set: function (value) {
676
+ this._topTextAttachmentDirection = value;
677
+ },
678
+ enumerable: false,
679
+ configurable: true
680
+ });
681
+ Object.defineProperty(AcDbMLeader.prototype, "contentScale", {
682
+ /**
683
+ * Gets or sets the overall content scale override.
684
+ */
685
+ get: function () {
686
+ return this._contentScale;
687
+ },
688
+ set: function (value) {
689
+ this._contentScale = value;
690
+ },
691
+ enumerable: false,
692
+ configurable: true
693
+ });
694
+ Object.defineProperty(AcDbMLeader.prototype, "contentBasePosition", {
695
+ /**
696
+ * Gets or sets the base insertion position of annotation content.
697
+ */
698
+ get: function () {
699
+ return this._contentBasePosition;
700
+ },
701
+ set: function (value) {
702
+ this._contentBasePosition = value;
703
+ },
704
+ enumerable: false,
705
+ configurable: true
706
+ });
707
+ Object.defineProperty(AcDbMLeader.prototype, "textAnchor", {
708
+ /**
709
+ * Gets or sets the explicit text anchor position.
710
+ */
711
+ get: function () {
712
+ return this._textAnchor;
713
+ },
714
+ set: function (value) {
715
+ this._textAnchor = value;
716
+ },
717
+ enumerable: false,
718
+ configurable: true
719
+ });
720
+ Object.defineProperty(AcDbMLeader.prototype, "textLineSpacingStyle", {
721
+ /**
722
+ * Gets or sets the text line spacing style code for column/text layout.
723
+ */
724
+ get: function () {
725
+ return this._textLineSpacingStyle;
726
+ },
727
+ set: function (value) {
728
+ this._textLineSpacingStyle = value;
729
+ },
730
+ enumerable: false,
731
+ configurable: true
732
+ });
733
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundColor", {
734
+ /**
735
+ * Gets or sets text background color override.
736
+ */
737
+ get: function () {
738
+ return this._textBackgroundColor;
739
+ },
740
+ set: function (value) {
741
+ this._textBackgroundColor = value;
742
+ },
743
+ enumerable: false,
744
+ configurable: true
745
+ });
746
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundScaleFactor", {
747
+ /**
748
+ * Gets or sets background-mask scale factor around text.
749
+ */
750
+ get: function () {
751
+ return this._textBackgroundScaleFactor;
752
+ },
753
+ set: function (value) {
754
+ this._textBackgroundScaleFactor = value;
755
+ },
756
+ enumerable: false,
757
+ configurable: true
758
+ });
759
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundTransparency", {
760
+ /**
761
+ * Gets or sets text background transparency value.
762
+ */
763
+ get: function () {
764
+ return this._textBackgroundTransparency;
765
+ },
766
+ set: function (value) {
767
+ this._textBackgroundTransparency = value;
768
+ },
769
+ enumerable: false,
770
+ configurable: true
771
+ });
772
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundColorOn", {
773
+ /**
774
+ * Gets or sets whether explicit background color masking is enabled.
775
+ */
776
+ get: function () {
777
+ return this._textBackgroundColorOn;
778
+ },
779
+ set: function (value) {
780
+ this._textBackgroundColorOn = value;
781
+ },
782
+ enumerable: false,
783
+ configurable: true
784
+ });
785
+ Object.defineProperty(AcDbMLeader.prototype, "textFillOn", {
786
+ /**
787
+ * Gets or sets whether text fill/mask is enabled.
788
+ */
789
+ get: function () {
790
+ return this._textFillOn;
791
+ },
792
+ set: function (value) {
793
+ this._textFillOn = value;
794
+ },
795
+ enumerable: false,
796
+ configurable: true
797
+ });
798
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnType", {
799
+ /**
800
+ * Gets or sets the text column layout type code.
801
+ */
802
+ get: function () {
803
+ return this._textColumnType;
804
+ },
805
+ set: function (value) {
806
+ this._textColumnType = value;
807
+ },
808
+ enumerable: false,
809
+ configurable: true
810
+ });
811
+ Object.defineProperty(AcDbMLeader.prototype, "textUseAutoHeight", {
812
+ /**
813
+ * Gets or sets whether text column height is auto-managed.
814
+ */
815
+ get: function () {
816
+ return this._textUseAutoHeight;
817
+ },
818
+ set: function (value) {
819
+ this._textUseAutoHeight = value;
820
+ },
821
+ enumerable: false,
822
+ configurable: true
823
+ });
824
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnWidth", {
825
+ /**
826
+ * Gets or sets the fixed width for text columns.
827
+ */
828
+ get: function () {
829
+ return this._textColumnWidth;
830
+ },
831
+ set: function (value) {
832
+ this._textColumnWidth = value;
833
+ },
834
+ enumerable: false,
835
+ configurable: true
836
+ });
837
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnGutterWidth", {
838
+ /**
839
+ * Gets or sets the gutter width between text columns.
840
+ */
841
+ get: function () {
842
+ return this._textColumnGutterWidth;
843
+ },
844
+ set: function (value) {
845
+ this._textColumnGutterWidth = value;
846
+ },
847
+ enumerable: false,
848
+ configurable: true
849
+ });
850
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnFlowReversed", {
851
+ /**
852
+ * Gets or sets whether text columns flow in reverse order.
853
+ */
854
+ get: function () {
855
+ return this._textColumnFlowReversed;
856
+ },
857
+ set: function (value) {
858
+ this._textColumnFlowReversed = value;
859
+ },
860
+ enumerable: false,
861
+ configurable: true
862
+ });
863
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnHeight", {
864
+ /**
865
+ * Gets or sets the explicit text column height.
866
+ */
867
+ get: function () {
868
+ return this._textColumnHeight;
869
+ },
870
+ set: function (value) {
871
+ this._textColumnHeight = value;
872
+ },
873
+ enumerable: false,
874
+ configurable: true
875
+ });
876
+ Object.defineProperty(AcDbMLeader.prototype, "textUseWordBreak", {
877
+ /**
878
+ * Gets or sets whether word breaking is enabled in column layout.
879
+ */
880
+ get: function () {
881
+ return this._textUseWordBreak;
882
+ },
883
+ set: function (value) {
884
+ this._textUseWordBreak = value;
885
+ },
886
+ enumerable: false,
887
+ configurable: true
888
+ });
889
+ Object.defineProperty(AcDbMLeader.prototype, "hasMText", {
890
+ /**
891
+ * Gets or sets whether MText content exists in the serialized payload.
892
+ */
893
+ get: function () {
894
+ return this._hasMText;
895
+ },
896
+ set: function (value) {
897
+ this._hasMText = value;
898
+ },
899
+ enumerable: false,
900
+ configurable: true
901
+ });
902
+ Object.defineProperty(AcDbMLeader.prototype, "hasBlock", {
903
+ /**
904
+ * Gets or sets whether block content exists in the serialized payload.
905
+ */
906
+ get: function () {
907
+ return this._hasBlock;
908
+ },
909
+ set: function (value) {
910
+ this._hasBlock = value;
911
+ },
912
+ enumerable: false,
913
+ configurable: true
914
+ });
915
+ Object.defineProperty(AcDbMLeader.prototype, "planeOrigin", {
916
+ /**
917
+ * Gets or sets the origin of the MLeader plane definition.
918
+ */
919
+ get: function () {
920
+ return this._planeOrigin;
921
+ },
922
+ set: function (value) {
923
+ this._planeOrigin = value;
924
+ },
925
+ enumerable: false,
926
+ configurable: true
927
+ });
928
+ Object.defineProperty(AcDbMLeader.prototype, "planeXAxisDirection", {
929
+ /**
930
+ * Gets or sets the X-axis direction vector of the MLeader plane.
931
+ */
932
+ get: function () {
933
+ return this._planeXAxisDirection;
934
+ },
935
+ set: function (value) {
936
+ this._planeXAxisDirection = value;
937
+ },
938
+ enumerable: false,
939
+ configurable: true
940
+ });
941
+ Object.defineProperty(AcDbMLeader.prototype, "planeYAxisDirection", {
942
+ /**
943
+ * Gets or sets the Y-axis direction vector of the MLeader plane.
944
+ */
945
+ get: function () {
946
+ return this._planeYAxisDirection;
947
+ },
948
+ set: function (value) {
949
+ this._planeYAxisDirection = value;
950
+ },
951
+ enumerable: false,
952
+ configurable: true
953
+ });
954
+ Object.defineProperty(AcDbMLeader.prototype, "planeNormalReversed", {
955
+ /**
956
+ * Gets or sets whether the MLeader plane normal is reversed.
957
+ */
958
+ get: function () {
959
+ return this._planeNormalReversed;
960
+ },
961
+ set: function (value) {
962
+ this._planeNormalReversed = value;
963
+ },
964
+ enumerable: false,
965
+ configurable: true
966
+ });
967
+ Object.defineProperty(AcDbMLeader.prototype, "leaderSections", {
968
+ /**
969
+ * Gets the alias of `leaders`.
970
+ */
971
+ get: function () {
972
+ return this.leaders;
973
+ },
974
+ enumerable: false,
975
+ configurable: true
976
+ });
977
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentData", {
978
+ /**
979
+ * Gets the alias of `blockContent`.
980
+ */
981
+ get: function () {
982
+ return this.blockContent;
983
+ },
984
+ enumerable: false,
985
+ configurable: true
986
+ });
987
+ Object.defineProperty(AcDbMLeader.prototype, "mtextContent", {
988
+ /**
989
+ * Gets the MText content payload if present.
990
+ */
991
+ get: function () {
992
+ return this._mtextContent
993
+ ? {
994
+ text: this._mtextContent.text,
995
+ anchorPoint: this._mtextContent.anchorPoint.clone()
996
+ }
997
+ : undefined;
998
+ },
999
+ set: function (value) {
1000
+ if (!value) {
1001
+ this._mtextContent = undefined;
1002
+ if (this._contentType === AcDbMLeaderContentType.MTextContent) {
1003
+ this._contentType = AcDbMLeaderContentType.NoneContent;
1004
+ }
1005
+ return;
1006
+ }
1007
+ this._mtextContent = {
1008
+ text: value.text,
1009
+ anchorPoint: this.createPoint(value.anchorPoint)
1010
+ };
1011
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1012
+ },
1013
+ enumerable: false,
1014
+ configurable: true
1015
+ });
1016
+ Object.defineProperty(AcDbMLeader.prototype, "contents", {
1017
+ /**
1018
+ * Gets the displayed MText string content.
1019
+ */
1020
+ get: function () {
1021
+ var _a, _b;
1022
+ return (_b = (_a = this._mtextContent) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
1023
+ },
1024
+ set: function (value) {
1025
+ if (!this._mtextContent) {
1026
+ this._mtextContent = {
1027
+ text: value,
1028
+ anchorPoint: new AcGePoint3d()
1029
+ };
1030
+ }
1031
+ else {
1032
+ this._mtextContent.text = value;
1033
+ }
1034
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1035
+ },
1036
+ enumerable: false,
1037
+ configurable: true
1038
+ });
1039
+ Object.defineProperty(AcDbMLeader.prototype, "textLocation", {
1040
+ /**
1041
+ * Gets the MText anchor point.
1042
+ */
1043
+ get: function () {
1044
+ var _a;
1045
+ return (_a = this._mtextContent) === null || _a === void 0 ? void 0 : _a.anchorPoint;
1046
+ },
1047
+ set: function (value) {
1048
+ if (!value) {
1049
+ this._mtextContent = undefined;
1050
+ return;
1051
+ }
1052
+ if (!this._mtextContent) {
1053
+ this._mtextContent = {
1054
+ text: '',
1055
+ anchorPoint: this.createPoint(value)
1056
+ };
1057
+ }
1058
+ else {
1059
+ this._mtextContent.anchorPoint.copy(value);
1060
+ }
1061
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1062
+ },
1063
+ enumerable: false,
1064
+ configurable: true
1065
+ });
1066
+ Object.defineProperty(AcDbMLeader.prototype, "textHeight", {
1067
+ /**
1068
+ * Gets the text height.
1069
+ */
1070
+ get: function () {
1071
+ return this._textHeight;
1072
+ },
1073
+ set: function (value) {
1074
+ this._textHeight = value;
1075
+ },
1076
+ enumerable: false,
1077
+ configurable: true
1078
+ });
1079
+ Object.defineProperty(AcDbMLeader.prototype, "textWidth", {
1080
+ /**
1081
+ * Gets the text width.
1082
+ */
1083
+ get: function () {
1084
+ return this._textWidth;
1085
+ },
1086
+ set: function (value) {
1087
+ this._textWidth = value;
1088
+ },
1089
+ enumerable: false,
1090
+ configurable: true
1091
+ });
1092
+ Object.defineProperty(AcDbMLeader.prototype, "textRotation", {
1093
+ /**
1094
+ * Gets the text rotation.
1095
+ */
1096
+ get: function () {
1097
+ return this._textRotation;
1098
+ },
1099
+ set: function (value) {
1100
+ this._textRotation = value;
1101
+ },
1102
+ enumerable: false,
1103
+ configurable: true
1104
+ });
1105
+ Object.defineProperty(AcDbMLeader.prototype, "textDirection", {
1106
+ /**
1107
+ * Gets the text direction.
1108
+ */
1109
+ get: function () {
1110
+ return this._textDirection;
1111
+ },
1112
+ set: function (value) {
1113
+ this._textDirection.copy(value);
1114
+ },
1115
+ enumerable: false,
1116
+ configurable: true
1117
+ });
1118
+ Object.defineProperty(AcDbMLeader.prototype, "textStyleName", {
1119
+ /**
1120
+ * Gets the text style name.
1121
+ */
1122
+ get: function () {
1123
+ return this._textStyleName;
1124
+ },
1125
+ set: function (value) {
1126
+ this._textStyleName = value;
1127
+ },
1128
+ enumerable: false,
1129
+ configurable: true
1130
+ });
1131
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachmentPoint", {
1132
+ /**
1133
+ * Gets the text attachment point.
1134
+ */
1135
+ get: function () {
1136
+ return this._textAttachmentPoint;
1137
+ },
1138
+ set: function (value) {
1139
+ this._textAttachmentPoint = value;
1140
+ },
1141
+ enumerable: false,
1142
+ configurable: true
1143
+ });
1144
+ Object.defineProperty(AcDbMLeader.prototype, "textDrawingDirection", {
1145
+ /**
1146
+ * Gets the text drawing direction.
1147
+ */
1148
+ get: function () {
1149
+ return this._textDrawingDirection;
1150
+ },
1151
+ set: function (value) {
1152
+ this._textDrawingDirection = value;
1153
+ },
1154
+ enumerable: false,
1155
+ configurable: true
1156
+ });
1157
+ Object.defineProperty(AcDbMLeader.prototype, "textLineSpacingFactor", {
1158
+ /**
1159
+ * Gets the text line spacing factor.
1160
+ */
1161
+ get: function () {
1162
+ return this._textLineSpacingFactor;
1163
+ },
1164
+ set: function (value) {
1165
+ this._textLineSpacingFactor = value;
1166
+ },
1167
+ enumerable: false,
1168
+ configurable: true
1169
+ });
1170
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachmentDirection", {
1171
+ /**
1172
+ * Gets the text attachment direction.
1173
+ */
1174
+ get: function () {
1175
+ return this._textAttachmentDirection;
1176
+ },
1177
+ set: function (value) {
1178
+ this._textAttachmentDirection = value;
1179
+ },
1180
+ enumerable: false,
1181
+ configurable: true
1182
+ });
1183
+ Object.defineProperty(AcDbMLeader.prototype, "blockContent", {
1184
+ /**
1185
+ * Gets the block content.
1186
+ */
1187
+ get: function () {
1188
+ var _a, _b;
1189
+ return this._blockContent
1190
+ ? {
1191
+ blockContentId: this._blockContent.blockContentId,
1192
+ blockHandle: this._blockContent.blockHandle,
1193
+ normal: (_a = this._blockContent.normal) === null || _a === void 0 ? void 0 : _a.clone(),
1194
+ position: (_b = this._blockContent.position) === null || _b === void 0 ? void 0 : _b.clone(),
1195
+ scale: this._blockContent.scale.clone(),
1196
+ rotation: this._blockContent.rotation,
1197
+ color: this._blockContent.color,
1198
+ transformationMatrix: __spreadArray([], __read(this._blockContent.transformationMatrix), false)
1199
+ }
1200
+ : undefined;
1201
+ },
1202
+ set: function (value) {
1203
+ var _a, _b, _c;
1204
+ if (!value) {
1205
+ this._blockContent = undefined;
1206
+ if (this._contentType === AcDbMLeaderContentType.BlockContent) {
1207
+ this._contentType = AcDbMLeaderContentType.NoneContent;
1208
+ }
1209
+ return;
1210
+ }
1211
+ this._blockContent = {
1212
+ blockContentId: (_a = value.blockContentId) !== null && _a !== void 0 ? _a : value.blockHandle,
1213
+ blockHandle: value.blockHandle,
1214
+ normal: value.normal ? new AcGeVector3d(value.normal) : undefined,
1215
+ position: value.position ? this.createPoint(value.position) : undefined,
1216
+ scale: new AcGeVector3d((_b = value.scale) !== null && _b !== void 0 ? _b : { x: 1, y: 1, z: 1 }),
1217
+ rotation: (_c = value.rotation) !== null && _c !== void 0 ? _c : 0,
1218
+ color: value.color,
1219
+ transformationMatrix: value.transformationMatrix
1220
+ ? __spreadArray([], __read(value.transformationMatrix), false) : []
1221
+ };
1222
+ this.blockContentId = this._blockContent.blockContentId;
1223
+ this._contentType = AcDbMLeaderContentType.BlockContent;
1224
+ },
1225
+ enumerable: false,
1226
+ configurable: true
1227
+ });
1228
+ /**
1229
+ * Adds a leader branch and returns its index.
1230
+ */
1231
+ AcDbMLeader.prototype.addLeader = function (leader) {
1232
+ var _this = this;
1233
+ var _a, _b, _c;
1234
+ if (leader === void 0) { leader = {}; }
1235
+ var dbLeader = {
1236
+ lastLeaderLinePoint: leader.lastLeaderLinePoint
1237
+ ? this.createPoint(leader.lastLeaderLinePoint)
1238
+ : undefined,
1239
+ lastLeaderLinePointSet: leader.lastLeaderLinePointSet,
1240
+ landingPoint: leader.landingPoint
1241
+ ? this.createPoint(leader.landingPoint)
1242
+ : undefined,
1243
+ doglegVector: leader.doglegVector
1244
+ ? new AcGeVector3d(leader.doglegVector)
1245
+ : undefined,
1246
+ doglegVectorSet: leader.doglegVectorSet,
1247
+ doglegLength: leader.doglegLength,
1248
+ breaks: (_b = (_a = leader.breaks) === null || _a === void 0 ? void 0 : _a.map(function (item) { return ({
1249
+ index: item.index,
1250
+ start: _this.createPoint(item.start),
1251
+ end: _this.createPoint(item.end)
1252
+ }); })) !== null && _b !== void 0 ? _b : [],
1253
+ leaderBranchIndex: leader.leaderBranchIndex,
1254
+ directionType: leader.directionType,
1255
+ leaderLines: []
1256
+ };
1257
+ (_c = leader.leaderLines) === null || _c === void 0 ? void 0 : _c.forEach(function (line) {
1258
+ dbLeader.leaderLines.push(_this.createLeaderLine(line));
1259
+ });
1260
+ this._leaders.push(dbLeader);
1261
+ return this._leaders.length - 1;
1262
+ };
1263
+ /**
1264
+ * Removes a leader branch.
1265
+ */
1266
+ AcDbMLeader.prototype.removeLeader = function (leaderIndex) {
1267
+ this.checkLeaderIndex(leaderIndex);
1268
+ this._leaders.splice(leaderIndex, 1);
1269
+ return this;
1270
+ };
1271
+ /**
1272
+ * Adds a leader line to a leader branch and returns the line index.
1273
+ */
1274
+ AcDbMLeader.prototype.addLeaderLine = function (leaderIndex, vertices) {
1275
+ if (vertices === void 0) { vertices = []; }
1276
+ this.checkLeaderIndex(leaderIndex);
1277
+ this._leaders[leaderIndex].leaderLines.push(this.createLeaderLine({ vertices: vertices }));
1278
+ return this._leaders[leaderIndex].leaderLines.length - 1;
1279
+ };
1280
+ /**
1281
+ * Appends a vertex to one leader line.
1282
+ */
1283
+ AcDbMLeader.prototype.appendVertex = function (leaderIndex, leaderLineIndex, point) {
1284
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices.push(this.createPoint(point));
1285
+ return this;
1286
+ };
1287
+ /**
1288
+ * Replaces the vertices of one leader line.
1289
+ */
1290
+ AcDbMLeader.prototype.setLeaderLineVertices = function (leaderIndex, leaderLineIndex, vertices) {
1291
+ var _this = this;
1292
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices =
1293
+ vertices.map(function (point) { return _this.createPoint(point); });
1294
+ return this;
1295
+ };
1296
+ /**
1297
+ * Gets cloned vertices from the specified leader line.
1298
+ *
1299
+ * @param leaderIndex Index of the leader branch.
1300
+ * @param leaderLineIndex Index of the leader line in the branch.
1301
+ * @returns A cloned vertex list so callers cannot mutate internal state.
1302
+ */
1303
+ AcDbMLeader.prototype.getLeaderLineVertices = function (leaderIndex, leaderLineIndex) {
1304
+ return this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices.map(function (point) { return point.clone(); });
1305
+ };
1306
+ /**
1307
+ * Adds a break segment to a specific leader line.
1308
+ *
1309
+ * @param leaderIndex Index of the leader branch.
1310
+ * @param leaderLineIndex Index of the leader line.
1311
+ * @param start Break start point.
1312
+ * @param end Break end point.
1313
+ * @returns The current entity instance for chaining.
1314
+ */
1315
+ AcDbMLeader.prototype.addBreak = function (leaderIndex, leaderLineIndex, start, end) {
1316
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).breaks.push({
1317
+ start: this.createPoint(start),
1318
+ end: this.createPoint(end)
1319
+ });
1320
+ return this;
1321
+ };
1322
+ /**
1323
+ * Sets the landing point for one leader branch.
1324
+ *
1325
+ * @param leaderIndex Index of the leader branch.
1326
+ * @param point New landing point, or `undefined` to clear it.
1327
+ * @returns The current entity instance for chaining.
1328
+ */
1329
+ AcDbMLeader.prototype.setLandingPoint = function (leaderIndex, point) {
1330
+ this.checkLeaderIndex(leaderIndex);
1331
+ this._leaders[leaderIndex].landingPoint = point
1332
+ ? this.createPoint(point)
1333
+ : undefined;
1334
+ return this;
1335
+ };
1336
+ /**
1337
+ * Sets the dogleg direction for one leader branch.
1338
+ *
1339
+ * @param leaderIndex Index of the leader branch.
1340
+ * @param vector New dogleg direction vector.
1341
+ * @returns The current entity instance for chaining.
1342
+ */
1343
+ AcDbMLeader.prototype.setDoglegDirection = function (leaderIndex, vector) {
1344
+ this.checkLeaderIndex(leaderIndex);
1345
+ this._leaders[leaderIndex].doglegVector = new AcGeVector3d(vector);
1346
+ return this;
1347
+ };
1348
+ /**
1349
+ * Sets the dogleg length for one leader branch.
1350
+ *
1351
+ * @param leaderIndex Index of the leader branch.
1352
+ * @param length New dogleg length, or `undefined` to clear the override.
1353
+ * @returns The current entity instance for chaining.
1354
+ */
1355
+ AcDbMLeader.prototype.setDoglegLength = function (leaderIndex, length) {
1356
+ this.checkLeaderIndex(leaderIndex);
1357
+ this._leaders[leaderIndex].doglegLength = length;
1358
+ return this;
1359
+ };
1360
+ Object.defineProperty(AcDbMLeader.prototype, "geometricExtents", {
1361
+ /**
1362
+ * Gets the axis-aligned extents computed from all geometry points.
1363
+ */
1364
+ get: function () {
1365
+ var points = this.collectGeometryPoints();
1366
+ return points.length > 0
1367
+ ? new AcGeBox3d().setFromPoints(points)
1368
+ : new AcGeBox3d();
1369
+ },
1370
+ enumerable: false,
1371
+ configurable: true
1372
+ });
1373
+ /**
1374
+ * Gets grip points used for interactive editing.
1375
+ *
1376
+ * @returns Cloned grip points derived from renderable geometry.
1377
+ */
1378
+ AcDbMLeader.prototype.subGetGripPoints = function () {
1379
+ return this.collectGeometryPoints().map(function (point) { return point.clone(); });
1380
+ };
1381
+ /**
1382
+ * Applies a transformation matrix to this entity.
1383
+ *
1384
+ * @param matrix Transformation matrix applied to all geometry and vectors.
1385
+ * @returns The current entity instance for chaining.
1386
+ */
1387
+ AcDbMLeader.prototype.transformBy = function (matrix) {
1388
+ var _this = this;
1389
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1390
+ this._leaders.forEach(function (leader) {
1391
+ var _a, _b;
1392
+ (_a = leader.lastLeaderLinePoint) === null || _a === void 0 ? void 0 : _a.applyMatrix4(matrix);
1393
+ (_b = leader.landingPoint) === null || _b === void 0 ? void 0 : _b.applyMatrix4(matrix);
1394
+ if (leader.doglegVector) {
1395
+ _this.transformVector(leader.doglegVector, matrix);
1396
+ }
1397
+ leader.breaks.forEach(function (item) {
1398
+ item.start.applyMatrix4(matrix);
1399
+ item.end.applyMatrix4(matrix);
1400
+ });
1401
+ leader.leaderLines.forEach(function (line) {
1402
+ line.vertices.forEach(function (point) { return point.applyMatrix4(matrix); });
1403
+ line.breaks.forEach(function (item) {
1404
+ item.start.applyMatrix4(matrix);
1405
+ item.end.applyMatrix4(matrix);
1406
+ });
1407
+ });
1408
+ });
1409
+ (_a = this._landingPoint) === null || _a === void 0 ? void 0 : _a.applyMatrix4(matrix);
1410
+ (_b = this.contentBasePosition) === null || _b === void 0 ? void 0 : _b.applyMatrix4(matrix);
1411
+ this.transformVector(this._doglegVector, matrix);
1412
+ this.transformVector(this._normal, matrix);
1413
+ (_c = this.textAnchor) === null || _c === void 0 ? void 0 : _c.applyMatrix4(matrix);
1414
+ (_d = this._mtextContent) === null || _d === void 0 ? void 0 : _d.anchorPoint.applyMatrix4(matrix);
1415
+ this.transformVector(this._textDirection, matrix);
1416
+ (_f = (_e = this._blockContent) === null || _e === void 0 ? void 0 : _e.position) === null || _f === void 0 ? void 0 : _f.applyMatrix4(matrix);
1417
+ if ((_g = this._blockContent) === null || _g === void 0 ? void 0 : _g.normal) {
1418
+ this.transformVector(this._blockContent.normal, matrix);
1419
+ }
1420
+ if (this.blockContentScale) {
1421
+ this.transformVector(this.blockContentScale, matrix);
1422
+ }
1423
+ (_h = this.planeOrigin) === null || _h === void 0 ? void 0 : _h.applyMatrix4(matrix);
1424
+ if (this.planeXAxisDirection) {
1425
+ this.transformVector(this.planeXAxisDirection, matrix);
1426
+ }
1427
+ if (this.planeYAxisDirection) {
1428
+ this.transformVector(this.planeYAxisDirection, matrix);
1429
+ }
1430
+ return this;
1431
+ };
1432
+ Object.defineProperty(AcDbMLeader.prototype, "properties", {
1433
+ get: function () {
1434
+ var _this = this;
1435
+ return {
1436
+ type: this.type,
1437
+ groups: [
1438
+ this.getGeneralProperties(),
1439
+ {
1440
+ groupName: 'leader',
1441
+ properties: [
1442
+ {
1443
+ name: 'contentType',
1444
+ type: 'enum',
1445
+ editable: true,
1446
+ options: [
1447
+ {
1448
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.NoneContent],
1449
+ value: AcDbMLeaderContentType.NoneContent
1450
+ },
1451
+ {
1452
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.BlockContent],
1453
+ value: AcDbMLeaderContentType.BlockContent
1454
+ },
1455
+ {
1456
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.MTextContent],
1457
+ value: AcDbMLeaderContentType.MTextContent
1458
+ },
1459
+ {
1460
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.ToleranceContent],
1461
+ value: AcDbMLeaderContentType.ToleranceContent
1462
+ }
1463
+ ],
1464
+ accessor: {
1465
+ get: function () { return _this.contentType; },
1466
+ set: function (value) {
1467
+ _this.contentType = value;
1468
+ }
1469
+ }
1470
+ },
1471
+ {
1472
+ name: 'leaderLineType',
1473
+ type: 'enum',
1474
+ editable: true,
1475
+ options: [
1476
+ {
1477
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.InvisibleLeader],
1478
+ value: AcDbMLeaderLineType.InvisibleLeader
1479
+ },
1480
+ {
1481
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.StraightLeader],
1482
+ value: AcDbMLeaderLineType.StraightLeader
1483
+ },
1484
+ {
1485
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.SplineLeader],
1486
+ value: AcDbMLeaderLineType.SplineLeader
1487
+ }
1488
+ ],
1489
+ accessor: {
1490
+ get: function () { return _this.leaderLineType; },
1491
+ set: function (value) {
1492
+ _this.leaderLineType = value;
1493
+ }
1494
+ }
1495
+ },
1496
+ {
1497
+ name: 'doglegEnabled',
1498
+ type: 'boolean',
1499
+ editable: true,
1500
+ accessor: {
1501
+ get: function () { return _this.doglegEnabled; },
1502
+ set: function (value) {
1503
+ _this.doglegEnabled = value;
1504
+ }
1505
+ }
1506
+ },
1507
+ {
1508
+ name: 'doglegLength',
1509
+ type: 'float',
1510
+ editable: true,
1511
+ accessor: {
1512
+ get: function () { return _this.doglegLength; },
1513
+ set: function (value) {
1514
+ _this.doglegLength = value;
1515
+ }
1516
+ }
1517
+ },
1518
+ {
1519
+ name: 'leaderCount',
1520
+ type: 'int',
1521
+ editable: false,
1522
+ accessor: {
1523
+ get: function () { return _this.numberOfLeaders; }
1524
+ }
1525
+ }
1526
+ ]
1527
+ },
1528
+ {
1529
+ groupName: 'text',
1530
+ properties: [
1531
+ {
1532
+ name: 'contents',
1533
+ type: 'string',
1534
+ editable: true,
1535
+ accessor: {
1536
+ get: function () { return _this.contents; },
1537
+ set: function (value) {
1538
+ _this.contents = value;
1539
+ }
1540
+ }
1541
+ },
1542
+ {
1543
+ name: 'textHeight',
1544
+ type: 'float',
1545
+ editable: true,
1546
+ accessor: {
1547
+ get: function () { return _this.textHeight; },
1548
+ set: function (value) {
1549
+ _this.textHeight = value;
1550
+ }
1551
+ }
1552
+ },
1553
+ {
1554
+ name: 'textWidth',
1555
+ type: 'float',
1556
+ editable: true,
1557
+ accessor: {
1558
+ get: function () { return _this.textWidth; },
1559
+ set: function (value) {
1560
+ _this.textWidth = value;
1561
+ }
1562
+ }
1563
+ },
1564
+ {
1565
+ name: 'textStyleName',
1566
+ type: 'string',
1567
+ editable: true,
1568
+ accessor: {
1569
+ get: function () { return _this.textStyleName; },
1570
+ set: function (value) {
1571
+ _this.textStyleName = value;
1572
+ }
1573
+ }
1574
+ }
1575
+ ]
1576
+ }
1577
+ ]
1578
+ };
1579
+ },
1580
+ enumerable: false,
1581
+ configurable: true
1582
+ });
1583
+ /**
1584
+ * Builds renderable primitives for this multileader entity.
1585
+ *
1586
+ * @param renderer Graphics renderer used to create draw entities.
1587
+ * @returns A single entity, an entity group, or undefined when nothing is drawable.
1588
+ */
1589
+ AcDbMLeader.prototype.subWorldDraw = function (renderer) {
1590
+ var _this = this;
1591
+ var entities = [];
1592
+ if (this.leaderLineType !== AcDbMLeaderLineType.InvisibleLeader) {
1593
+ this._leaders.forEach(function (leader) {
1594
+ leader.leaderLines.forEach(function (line) {
1595
+ var points = _this.getLeaderLineDrawPoints(leader, line);
1596
+ if (points.length > 0) {
1597
+ var leaderEntity = _this.drawLeaderLine(renderer, points);
1598
+ if (leaderEntity)
1599
+ entities.push(leaderEntity);
1600
+ }
1601
+ });
1602
+ var doglegPoints = _this.getDoglegPoints(leader);
1603
+ if (doglegPoints) {
1604
+ entities.push(renderer.lines(doglegPoints));
1605
+ }
1606
+ });
1607
+ }
1608
+ var mtextContent = this.getRenderableMTextContent();
1609
+ if (this.contentType === AcDbMLeaderContentType.MTextContent &&
1610
+ mtextContent) {
1611
+ var textHeight = this.getResolvedTextHeight();
1612
+ var mtextData = {
1613
+ text: mtextContent.text,
1614
+ height: textHeight,
1615
+ width: this.getMTextRenderWidth(mtextContent.text, textHeight),
1616
+ position: mtextContent.anchorPoint,
1617
+ rotation: this.textRotation,
1618
+ directionVector: this.textDirection,
1619
+ attachmentPoint: this.textAttachmentPoint,
1620
+ drawingDirection: this.textDrawingDirection,
1621
+ lineSpaceFactor: this.textLineSpacingFactor
1622
+ };
1623
+ // MLeader draws multiple primitives as a group. Delayed MText rendering is
1624
+ // only scheduled for top-level entities, so render nested MText eagerly.
1625
+ entities.push(renderer.mtext(mtextData, this.getTextStyle(), false));
1626
+ }
1627
+ if (entities.length === 0)
1628
+ return undefined;
1629
+ return entities.length === 1 ? entities[0] : renderer.group(entities);
1630
+ };
1631
+ /**
1632
+ * Writes this multileader entity to DXF group codes.
1633
+ *
1634
+ * @param filer DXF filer that receives serialized values.
1635
+ * @returns The current entity instance for chaining.
1636
+ */
1637
+ AcDbMLeader.prototype.dxfOutFields = function (filer) {
1638
+ var _a;
1639
+ _super.prototype.dxfOutFields.call(this, filer);
1640
+ filer.writeSubclassMarker('AcDbMLeader');
1641
+ filer.writeInt16(170, this.leaderLineType);
1642
+ filer.writeBoolean(290, this.doglegEnabled);
1643
+ filer.writeDouble(41, this.doglegLength);
1644
+ filer.writeInt16(172, this.contentType);
1645
+ filer.writeVector3d(210, this.normal);
1646
+ filer.writeHandle(340, this.mleaderStyleId);
1647
+ if (this._landingPoint)
1648
+ filer.writePoint3d(10, this._landingPoint);
1649
+ filer.writeVector3d(11, this.doglegVector);
1650
+ if (this._mtextContent) {
1651
+ filer.writeString(1, this._mtextContent.text);
1652
+ filer.writePoint3d(12, this._mtextContent.anchorPoint);
1653
+ filer.writeDouble(40, this.textHeight);
1654
+ filer.writeDouble(42, this.textWidth);
1655
+ filer.writeAngle(50, this.textRotation);
1656
+ filer.writeString(7, this.textStyleName);
1657
+ }
1658
+ if (this._blockContent) {
1659
+ filer.writeHandle(341, (_a = this._blockContent.blockContentId) !== null && _a !== void 0 ? _a : '');
1660
+ if (this._blockContent.position) {
1661
+ filer.writePoint3d(15, this._blockContent.position);
1662
+ }
1663
+ filer.writeVector3d(16, this._blockContent.scale);
1664
+ filer.writeAngle(52, this._blockContent.rotation);
1665
+ }
1666
+ this._leaders.forEach(function (leader) {
1667
+ if (leader.landingPoint)
1668
+ filer.writePoint3d(110, leader.landingPoint);
1669
+ if (leader.doglegVector)
1670
+ filer.writeVector3d(111, leader.doglegVector);
1671
+ filer.writeDouble(140, leader.doglegLength);
1672
+ filer.writeInt16(171, leader.leaderLines.length);
1673
+ leader.leaderLines.forEach(function (line) {
1674
+ filer.writeInt16(90, line.vertices.length);
1675
+ line.vertices.forEach(function (point) { return filer.writePoint3d(10, point); });
1676
+ });
1677
+ });
1678
+ return this;
1679
+ };
1680
+ /**
1681
+ * Creates a concrete point from point-like input.
1682
+ *
1683
+ * @param point Source point-like value.
1684
+ * @returns A newly created point instance.
1685
+ */
1686
+ AcDbMLeader.prototype.createPoint = function (point) {
1687
+ return new AcGePoint3d().copy(point);
1688
+ };
1689
+ /**
1690
+ * Normalizes one leader-line payload into internal storage format.
1691
+ *
1692
+ * @param line Source leader-line payload.
1693
+ * @returns A normalized leader line.
1694
+ */
1695
+ AcDbMLeader.prototype.createLeaderLine = function (line) {
1696
+ var _this = this;
1697
+ var _a, _b, _c, _d;
1698
+ return {
1699
+ vertices: (_b = (_a = line.vertices) === null || _a === void 0 ? void 0 : _a.map(function (point) { return _this.createPoint(point); })) !== null && _b !== void 0 ? _b : [],
1700
+ breakPointIndexes: line.breakPointIndexes
1701
+ ? __spreadArray([], __read(line.breakPointIndexes), false) : [],
1702
+ leaderLineIndex: line.leaderLineIndex,
1703
+ breaks: (_d = (_c = line.breaks) === null || _c === void 0 ? void 0 : _c.map(function (item) { return ({
1704
+ index: item.index,
1705
+ start: _this.createPoint(item.start),
1706
+ end: _this.createPoint(item.end)
1707
+ }); })) !== null && _d !== void 0 ? _d : []
1708
+ };
1709
+ };
1710
+ /**
1711
+ * Creates a deep clone of a leader branch.
1712
+ *
1713
+ * @param leader Leader branch to clone.
1714
+ * @returns A deep-cloned leader branch.
1715
+ */
1716
+ AcDbMLeader.prototype.cloneLeader = function (leader) {
1717
+ var _a, _b, _c;
1718
+ return {
1719
+ lastLeaderLinePoint: (_a = leader.lastLeaderLinePoint) === null || _a === void 0 ? void 0 : _a.clone(),
1720
+ lastLeaderLinePointSet: leader.lastLeaderLinePointSet,
1721
+ landingPoint: (_b = leader.landingPoint) === null || _b === void 0 ? void 0 : _b.clone(),
1722
+ doglegVector: (_c = leader.doglegVector) === null || _c === void 0 ? void 0 : _c.clone(),
1723
+ doglegVectorSet: leader.doglegVectorSet,
1724
+ doglegLength: leader.doglegLength,
1725
+ breaks: leader.breaks.map(function (item) { return ({
1726
+ index: item.index,
1727
+ start: item.start.clone(),
1728
+ end: item.end.clone()
1729
+ }); }),
1730
+ leaderBranchIndex: leader.leaderBranchIndex,
1731
+ directionType: leader.directionType,
1732
+ leaderLines: leader.leaderLines.map(function (line) { return ({
1733
+ vertices: line.vertices.map(function (point) { return point.clone(); }),
1734
+ breakPointIndexes: __spreadArray([], __read(line.breakPointIndexes), false),
1735
+ leaderLineIndex: line.leaderLineIndex,
1736
+ breaks: line.breaks.map(function (item) { return ({
1737
+ index: item.index,
1738
+ start: item.start.clone(),
1739
+ end: item.end.clone()
1740
+ }); })
1741
+ }); })
1742
+ };
1743
+ };
1744
+ /**
1745
+ * Validates that a leader index is in range.
1746
+ *
1747
+ * @param leaderIndex Leader branch index to validate.
1748
+ */
1749
+ AcDbMLeader.prototype.checkLeaderIndex = function (leaderIndex) {
1750
+ if (leaderIndex < 0 || leaderIndex >= this._leaders.length) {
1751
+ throw new Error('The leader index is out of range!');
1752
+ }
1753
+ };
1754
+ /**
1755
+ * Gets a mutable leader line by branch and line index.
1756
+ *
1757
+ * @param leaderIndex Leader branch index.
1758
+ * @param leaderLineIndex Leader-line index in the branch.
1759
+ * @returns The mutable leader line reference.
1760
+ */
1761
+ AcDbMLeader.prototype.getMutableLeaderLine = function (leaderIndex, leaderLineIndex) {
1762
+ this.checkLeaderIndex(leaderIndex);
1763
+ var line = this._leaders[leaderIndex].leaderLines[leaderLineIndex];
1764
+ if (!line) {
1765
+ throw new Error('The leader line index is out of range!');
1766
+ }
1767
+ return line;
1768
+ };
1769
+ /**
1770
+ * Collects all geometry points contributing to draw/extents calculations.
1771
+ *
1772
+ * @returns Geometry point collection.
1773
+ */
1774
+ AcDbMLeader.prototype.collectGeometryPoints = function () {
1775
+ var _this = this;
1776
+ var _a;
1777
+ var points = [];
1778
+ this._leaders.forEach(function (leader) {
1779
+ if (leader.lastLeaderLinePoint)
1780
+ points.push(leader.lastLeaderLinePoint);
1781
+ if (leader.landingPoint)
1782
+ points.push(leader.landingPoint);
1783
+ leader.breaks.forEach(function (item) { return points.push(item.start, item.end); });
1784
+ leader.leaderLines.forEach(function (line) {
1785
+ points.push.apply(points, __spreadArray([], __read(line.vertices), false));
1786
+ line.breaks.forEach(function (item) { return points.push(item.start, item.end); });
1787
+ });
1788
+ var doglegPoints = _this.getDoglegPoints(leader);
1789
+ if (doglegPoints)
1790
+ points.push.apply(points, __spreadArray([], __read(doglegPoints), false));
1791
+ leader.leaderLines.forEach(function (line) {
1792
+ var arrowPoints = _this.getArrowheadPoints(_this.getLeaderLineDrawPoints(leader, line));
1793
+ if (arrowPoints)
1794
+ points.push.apply(points, __spreadArray([], __read(arrowPoints), false));
1795
+ });
1796
+ });
1797
+ if (this._landingPoint)
1798
+ points.push(this._landingPoint);
1799
+ if (this.contentBasePosition)
1800
+ points.push(this.contentBasePosition);
1801
+ if (this.textAnchor)
1802
+ points.push(this.textAnchor);
1803
+ if (this._mtextContent)
1804
+ points.push(this._mtextContent.anchorPoint);
1805
+ if ((_a = this._blockContent) === null || _a === void 0 ? void 0 : _a.position)
1806
+ points.push(this._blockContent.position);
1807
+ if (this.planeOrigin)
1808
+ points.push(this.planeOrigin);
1809
+ return points;
1810
+ };
1811
+ /**
1812
+ * Resolves the final draw points for a leader line.
1813
+ *
1814
+ * @param leader Owning leader branch.
1815
+ * @param line Leader line to resolve.
1816
+ * @returns The resolved draw-point sequence.
1817
+ */
1818
+ AcDbMLeader.prototype.getLeaderLineDrawPoints = function (leader, line) {
1819
+ var _a, _b, _c;
1820
+ if (line.vertices.length >= 2)
1821
+ return line.vertices;
1822
+ if (line.vertices.length === 0)
1823
+ return [];
1824
+ var end = (_c = (_b = (_a = leader.lastLeaderLinePoint) !== null && _a !== void 0 ? _a : leader.landingPoint) !== null && _b !== void 0 ? _b : this._landingPoint) !== null && _c !== void 0 ? _c : this.contentBasePosition;
1825
+ if (!end || line.vertices[0].equals(end))
1826
+ return line.vertices;
1827
+ return [line.vertices[0], end];
1828
+ };
1829
+ /**
1830
+ * Computes the dogleg segment points for a leader branch.
1831
+ *
1832
+ * @param leader Leader branch to evaluate.
1833
+ * @returns Dogleg segment points, or `undefined` if not applicable.
1834
+ */
1835
+ AcDbMLeader.prototype.getDoglegPoints = function (leader) {
1836
+ var _a, _b, _c, _d, _e;
1837
+ if (!this.doglegEnabled)
1838
+ return undefined;
1839
+ var start = (_c = (_b = (_a = leader.lastLeaderLinePoint) !== null && _a !== void 0 ? _a : leader.landingPoint) !== null && _b !== void 0 ? _b : this._landingPoint) !== null && _c !== void 0 ? _c : this.getLastLeaderLineVertex(leader);
1840
+ var vector = (_d = leader.doglegVector) !== null && _d !== void 0 ? _d : this._doglegVector;
1841
+ var length = (_e = leader.doglegLength) !== null && _e !== void 0 ? _e : this._doglegLength;
1842
+ if (!start || length === 0 || vector.lengthSq() === 0)
1843
+ return undefined;
1844
+ var end = start
1845
+ .clone()
1846
+ .add(vector.clone().normalize().multiplyScalar(length));
1847
+ return [start, end];
1848
+ };
1849
+ /**
1850
+ * Gets the last available vertex from all lines in one leader branch.
1851
+ *
1852
+ * @param leader Leader branch to inspect.
1853
+ * @returns The last vertex, or `undefined` when no vertices exist.
1854
+ */
1855
+ AcDbMLeader.prototype.getLastLeaderLineVertex = function (leader) {
1856
+ for (var i = leader.leaderLines.length - 1; i >= 0; i--) {
1857
+ var line = leader.leaderLines[i];
1858
+ if (line.vertices.length > 0) {
1859
+ return line.vertices[line.vertices.length - 1];
1860
+ }
1861
+ }
1862
+ return undefined;
1863
+ };
1864
+ /**
1865
+ * Builds arrowhead polyline points from leader-line points.
1866
+ *
1867
+ * @param points Leader-line points where the first point is treated as tip.
1868
+ * @returns Arrowhead points, or `undefined` when no arrowhead is drawable.
1869
+ */
1870
+ AcDbMLeader.prototype.getArrowheadPoints = function (points) {
1871
+ if (!this.isArrowheadVisible() || points.length < 2)
1872
+ return undefined;
1873
+ var frame = this.getArrowheadFrame(points);
1874
+ if (!frame)
1875
+ return undefined;
1876
+ var size = this.getResolvedArrowheadSize();
1877
+ var tip = frame.tip, unit = frame.unit;
1878
+ var baseCenter = tip.clone().add(unit.clone().multiplyScalar(size));
1879
+ var halfWidth = size / 6;
1880
+ var perpendicular = new AcGeVector3d(-unit.y, unit.x, 0);
1881
+ var left = baseCenter
1882
+ .clone()
1883
+ .add(perpendicular.clone().multiplyScalar(halfWidth));
1884
+ var right = baseCenter
1885
+ .clone()
1886
+ .add(perpendicular.clone().multiplyScalar(-halfWidth));
1887
+ return [tip, left, right, tip];
1888
+ };
1889
+ /**
1890
+ * Checks whether an arrowhead should be rendered.
1891
+ *
1892
+ * @returns `true` if arrowhead configuration is visible.
1893
+ */
1894
+ AcDbMLeader.prototype.isArrowheadVisible = function () {
1895
+ var arrowId = this.getResolvedArrowheadId();
1896
+ if ((arrowId === null || arrowId === void 0 ? void 0 : arrowId.toUpperCase()) === '_NONE')
1897
+ return false;
1898
+ return this.getResolvedArrowheadSize() > 0;
1899
+ };
1900
+ /**
1901
+ * Draws one leader line and applies arrow style from MLEADER/MLEADERSTYLE.
1902
+ */
1903
+ AcDbMLeader.prototype.drawLeaderLine = function (renderer, points) {
1904
+ var entities = [renderer.lines(points)];
1905
+ var arrow = this.drawArrowhead(renderer, points);
1906
+ if (arrow)
1907
+ entities.push(arrow);
1908
+ return entities.length === 1 ? entities[0] : renderer.group(entities);
1909
+ };
1910
+ /**
1911
+ * Draws one arrowhead primitive from leader-line points.
1912
+ */
1913
+ AcDbMLeader.prototype.drawArrowhead = function (renderer, points) {
1914
+ if (!this.isArrowheadVisible())
1915
+ return undefined;
1916
+ var blockArrow = this.drawArrowheadBlock(renderer, points);
1917
+ if (blockArrow)
1918
+ return blockArrow;
1919
+ var arrowPoints = this.getArrowheadPoints(points);
1920
+ if (!arrowPoints)
1921
+ return undefined;
1922
+ var area = new AcGeArea2d();
1923
+ area.add(new AcGePolyline2d(arrowPoints, true));
1924
+ var traits = renderer.subEntityTraits;
1925
+ var originalFillType = traits.fillType;
1926
+ traits.fillType = {
1927
+ solidFill: true,
1928
+ patternAngle: 0,
1929
+ definitionLines: []
1930
+ };
1931
+ var entity = renderer.area(area);
1932
+ traits.fillType = originalFillType;
1933
+ return entity;
1934
+ };
1935
+ /**
1936
+ * Draws arrowhead by rendering entities from referenced arrow block record.
1937
+ */
1938
+ AcDbMLeader.prototype.drawArrowheadBlock = function (renderer, points) {
1939
+ var _a;
1940
+ var blockTableRecord = this.getResolvedArrowheadBlockTableRecord();
1941
+ if (!blockTableRecord)
1942
+ return undefined;
1943
+ var frame = this.getArrowheadFrame(points);
1944
+ if (!frame)
1945
+ return undefined;
1946
+ var tip = frame.tip, unit = frame.unit;
1947
+ var size = this.getResolvedArrowheadSize();
1948
+ var angle = Math.atan2(unit.y, unit.x);
1949
+ var basePoint = (_a = blockTableRecord.origin) !== null && _a !== void 0 ? _a : AcGePoint3d.ORIGIN;
1950
+ var mBase = new AcGeMatrix3d().makeTranslation(-basePoint.x, -basePoint.y, -basePoint.z);
1951
+ var mScale = new AcGeMatrix3d().makeScale(size, size, size);
1952
+ var mRot = new AcGeMatrix3d().makeRotationZ(angle);
1953
+ var mInsert = new AcGeMatrix3d().makeTranslation(tip.x, tip.y, tip.z);
1954
+ var transform = new AcGeMatrix3d()
1955
+ .multiplyMatrices(mInsert, mRot)
1956
+ .multiply(mScale)
1957
+ .multiply(mBase);
1958
+ return AcDbRenderingCache.instance.draw(renderer, blockTableRecord, this.rgbColor, [], true, transform, new AcGeVector3d(this.normal));
1959
+ };
1960
+ /**
1961
+ * Resolves tip point and direction for arrowhead placement.
1962
+ */
1963
+ AcDbMLeader.prototype.getArrowheadFrame = function (points) {
1964
+ if (points.length < 2)
1965
+ return undefined;
1966
+ var tip = points[0];
1967
+ var next = points.find(function (point) { return !point.equals(tip); });
1968
+ if (!next)
1969
+ return undefined;
1970
+ var direction = new AcGeVector3d().subVectors(next, tip);
1971
+ if (direction.lengthSq() === 0)
1972
+ return undefined;
1973
+ return {
1974
+ tip: tip,
1975
+ unit: direction.normalize()
1976
+ };
1977
+ };
1978
+ /**
1979
+ * Resolves the effective arrowhead id.
1980
+ *
1981
+ * @returns Arrowhead id used for rendering.
1982
+ */
1983
+ AcDbMLeader.prototype.getResolvedArrowheadId = function () {
1984
+ var _a, _b;
1985
+ var styleArrowId = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.arrowSymbolId;
1986
+ return (_b = this.arrowheadId) !== null && _b !== void 0 ? _b : styleArrowId;
1987
+ };
1988
+ /**
1989
+ * Resolves arrowhead block record by Arrowhead ID handle.
1990
+ */
1991
+ AcDbMLeader.prototype.getResolvedArrowheadBlockTableRecord = function () {
1992
+ var arrowId = this.getResolvedArrowheadId();
1993
+ if (!arrowId)
1994
+ return undefined;
1995
+ return this.database.tables.blockTable.getIdAt(arrowId);
1996
+ };
1997
+ /**
1998
+ * Resolves the effective arrowhead size.
1999
+ *
2000
+ * @returns Arrowhead size used for rendering.
2001
+ */
2002
+ AcDbMLeader.prototype.getResolvedArrowheadSize = function () {
2003
+ var _a, _b, _c, _d;
2004
+ var style = this.getMLeaderStyle();
2005
+ var styleArrowSize = (_a = style === null || style === void 0 ? void 0 : style.arrowSize) !== null && _a !== void 0 ? _a : style === null || style === void 0 ? void 0 : style.scale;
2006
+ return ((_d = (_c = (_b = this.arrowheadSize) !== null && _b !== void 0 ? _b : this.contentScale) !== null && _c !== void 0 ? _c : styleArrowSize) !== null && _d !== void 0 ? _d : this.getResolvedTextHeight());
2007
+ };
2008
+ /**
2009
+ * Resolves effective text height by style and override-flag rules.
2010
+ */
2011
+ AcDbMLeader.prototype.getResolvedTextHeight = function () {
2012
+ var _a;
2013
+ var styleTextHeight = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textHeight;
2014
+ if (this.textHeight > 0)
2015
+ return this.textHeight;
2016
+ if (styleTextHeight != null && styleTextHeight > 0)
2017
+ return styleTextHeight;
2018
+ return 2.5;
2019
+ };
2020
+ /**
2021
+ * Resolves renderable MText content using entity content first, with style fallback.
2022
+ */
2023
+ AcDbMLeader.prototype.getRenderableMTextContent = function () {
2024
+ var _a, _b, _c;
2025
+ if (this._mtextContent) {
2026
+ return {
2027
+ text: this._mtextContent.text,
2028
+ anchorPoint: this._mtextContent.anchorPoint
2029
+ };
2030
+ }
2031
+ var defaultText = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.defaultMTextContents;
2032
+ var anchorPoint = (_c = (_b = this.textAnchor) !== null && _b !== void 0 ? _b : this.contentBasePosition) !== null && _c !== void 0 ? _c : this._landingPoint;
2033
+ if (!defaultText || !anchorPoint)
2034
+ return undefined;
2035
+ return {
2036
+ text: defaultText,
2037
+ anchorPoint: anchorPoint
2038
+ };
2039
+ };
2040
+ /**
2041
+ * Computes render width for current MText content.
2042
+ *
2043
+ * @returns Explicit width or an estimated width based on plain text length.
2044
+ */
2045
+ AcDbMLeader.prototype.getMTextRenderWidth = function (text, textHeight) {
2046
+ if (this._textWidth > 0)
2047
+ return this._textWidth;
2048
+ if (!text)
2049
+ return this._textWidth;
2050
+ var plainText = text
2051
+ .replace(/\\[PpNn]/g, '\n')
2052
+ .replace(/\\[A-Za-z][^;]*;/g, '')
2053
+ .replace(/[{}]/g, '');
2054
+ var longestLineLength = Math.max.apply(Math, __spreadArray(__spreadArray([], __read(plainText.split(/\r\n|\r|\n/g).map(function (line) { return line.length; })), false), [1], false));
2055
+ return Math.max(textHeight, longestLineLength * textHeight);
2056
+ };
2057
+ /**
2058
+ * Transforms a direction vector with an affine matrix.
2059
+ *
2060
+ * @param vector Vector to mutate.
2061
+ * @param matrix Transformation matrix.
2062
+ */
2063
+ AcDbMLeader.prototype.transformVector = function (vector, matrix) {
2064
+ var origin = new AcGePoint3d();
2065
+ var endpoint = new AcGePoint3d(vector.x, vector.y, vector.z);
2066
+ origin.applyMatrix4(matrix);
2067
+ endpoint.applyMatrix4(matrix);
2068
+ vector.set(endpoint.x - origin.x, endpoint.y - origin.y, endpoint.z - origin.z);
2069
+ };
2070
+ /**
2071
+ * Resolves the referenced MLeader style object.
2072
+ */
2073
+ AcDbMLeader.prototype.getMLeaderStyle = function () {
2074
+ var dictionary = this.database.objects.mleaderStyle;
2075
+ var styleId = this.mleaderStyleId || this.leaderStyleId;
2076
+ if (styleId) {
2077
+ var style = dictionary.getIdAt(styleId);
2078
+ if (style)
2079
+ return style;
2080
+ }
2081
+ return dictionary.newIterator().toArray()[0];
2082
+ };
2083
+ /**
2084
+ * Resolves text style name considering entity values, ids and style fallback.
2085
+ */
2086
+ AcDbMLeader.prototype.getResolvedTextStyleName = function () {
2087
+ var _a, _b;
2088
+ var textStyleTable = this.database.tables.textStyleTable;
2089
+ var styleIdFromStyle = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textStyleId;
2090
+ var styleNameFromStyleId = styleIdFromStyle
2091
+ ? (_b = textStyleTable.getIdAt(styleIdFromStyle)) === null || _b === void 0 ? void 0 : _b.name
2092
+ : undefined;
2093
+ if (this.textStyleName)
2094
+ return this.textStyleName;
2095
+ var directStyle = this.textStyleId
2096
+ ? textStyleTable.getIdAt(this.textStyleId)
2097
+ : undefined;
2098
+ if (directStyle === null || directStyle === void 0 ? void 0 : directStyle.name)
2099
+ return directStyle.name;
2100
+ return styleNameFromStyleId;
2101
+ };
2102
+ /**
2103
+ * Resolves the text style used by renderer-side MText drawing.
2104
+ *
2105
+ * @returns A valid text style object.
2106
+ */
2107
+ AcDbMLeader.prototype.getTextStyle = function () {
2108
+ var _a, _b;
2109
+ var textStyleTable = this.database.tables.textStyleTable;
2110
+ var textStyleName = this.getResolvedTextStyleName();
2111
+ var style = (_b = (_a = (textStyleName ? textStyleTable.getAt(textStyleName) : undefined)) !== null && _a !== void 0 ? _a : textStyleTable.getAt(this.database.textstyle)) !== null && _b !== void 0 ? _b : textStyleTable.getAt(DEFAULT_TEXT_STYLE);
2112
+ if (!style) {
2113
+ throw new Error('No valid text style found in text style table.');
2114
+ }
2115
+ return style.textStyle;
2116
+ };
2117
+ /** The entity type name. */
2118
+ AcDbMLeader.typeName = 'MLeader';
2119
+ return AcDbMLeader;
2120
+ }(AcDbEntity));
2121
+ export { AcDbMLeader };
2122
+ //# sourceMappingURL=AcDbMLeader.js.map