@mlightcad/mtext-renderer 0.10.11 → 0.10.13

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.
package/dist/index.js CHANGED
@@ -10297,7 +10297,7 @@ class rl {
10297
10297
  }
10298
10298
  }
10299
10299
  }
10300
- class te {
10300
+ class re {
10301
10301
  /**
10302
10302
  * Creates a new Point instance.
10303
10303
  * @param x - The x-coordinate (defaults to 0)
@@ -10335,7 +10335,7 @@ class te {
10335
10335
  * @returns A new Point instance with the same x and y values
10336
10336
  */
10337
10337
  clone() {
10338
- return new te(this.x, this.y);
10338
+ return new re(this.x, this.y);
10339
10339
  }
10340
10340
  /**
10341
10341
  * Adds another point's coordinates to this point.
@@ -10440,18 +10440,18 @@ class Bt {
10440
10440
  }
10441
10441
  const a = 4 * Math.atan(Math.abs(this.bulge));
10442
10442
  this.radius = n / (2 * Math.sin(a / 2));
10443
- const i = this.start.clone().add(r.clone().divide(2)), s = new te(-r.y, r.x);
10443
+ const i = this.start.clone().add(r.clone().divide(2)), s = new re(-r.y, r.x);
10444
10444
  s.normalize(), s.multiply(Math.abs(this.radius * Math.cos(a / 2))), this.center = i.clone(), this.isClockwise ? this.center.subtract(s) : this.center.add(s), this.startAngle = Math.atan2(this.start.y - this.center.y, this.start.x - this.center.x), this.endAngle = Math.atan2(this.end.y - this.center.y, this.end.x - this.center.x), this.isClockwise ? this.endAngle >= this.startAngle && (this.endAngle -= 2 * Math.PI) : this.endAngle <= this.startAngle && (this.endAngle += 2 * Math.PI);
10445
10445
  } else if (e.center && e.radius !== void 0 && e.startOctant !== void 0 && e.octantCount !== void 0 && e.isClockwise !== void 0) {
10446
10446
  this.center = e.center.clone(), this.radius = e.radius, this.isClockwise = e.isClockwise, this.startAngle = e.startOctant * Ta;
10447
10447
  const r = (e.octantCount === 0 ? 8 : e.octantCount) * Ta;
10448
10448
  this.endAngle = this.startAngle + (this.isClockwise ? -r : r), this.start = this.center.clone().add(
10449
- new te(
10449
+ new re(
10450
10450
  this.radius * Math.cos(this.startAngle),
10451
10451
  this.radius * Math.sin(this.startAngle)
10452
10452
  )
10453
10453
  ), this.end = this.center.clone().add(
10454
- new te(this.radius * Math.cos(this.endAngle), this.radius * Math.sin(this.endAngle))
10454
+ new re(this.radius * Math.cos(this.endAngle), this.radius * Math.sin(this.endAngle))
10455
10455
  );
10456
10456
  } else
10457
10457
  throw new Error("Invalid arc parameters");
@@ -10468,12 +10468,12 @@ class Bt {
10468
10468
  for (let i = 1; i < a; i++) {
10469
10469
  const s = i / a, o = this.isClockwise ? this.startAngle - s * n : this.startAngle + s * n;
10470
10470
  r.push(
10471
- this.center.clone().add(new te(this.radius * Math.cos(o), this.radius * Math.sin(o)))
10471
+ this.center.clone().add(new re(this.radius * Math.cos(o), this.radius * Math.sin(o)))
10472
10472
  );
10473
10473
  }
10474
10474
  return r.push(
10475
10475
  this.end ? this.end.clone() : this.center.clone().add(
10476
- new te(
10476
+ new re(
10477
10477
  this.radius * Math.cos(this.endAngle),
10478
10478
  this.radius * Math.sin(this.endAngle)
10479
10479
  )
@@ -10520,7 +10520,7 @@ class Tt {
10520
10520
  */
10521
10521
  normalizeToOrigin(e = !1) {
10522
10522
  const r = this.bbox;
10523
- return this.offset(new te(-r.minX, -r.minY), e);
10523
+ return this.offset(new re(-r.minX, -r.minY), e);
10524
10524
  }
10525
10525
  /**
10526
10526
  * Converts the shape to an SVG string
@@ -10639,7 +10639,7 @@ class al {
10639
10639
  */
10640
10640
  parseShape(e) {
10641
10641
  const r = {
10642
- currentPoint: new te(),
10642
+ currentPoint: new re(),
10643
10643
  polylines: [],
10644
10644
  currentPolyline: [],
10645
10645
  sp: [],
@@ -10725,7 +10725,7 @@ class al {
10725
10725
  * @returns Returns the vector for the given direction code
10726
10726
  */
10727
10727
  getVectorForDirection(e) {
10728
- const r = new te();
10728
+ const r = new re();
10729
10729
  switch (e) {
10730
10730
  case 0:
10731
10731
  r.x = 1;
@@ -10796,13 +10796,13 @@ class al {
10796
10796
  }
10797
10797
  handleXYDisplacement(e, r, n) {
10798
10798
  let a = r;
10799
- const i = new te();
10799
+ const i = new re();
10800
10800
  return i.x = ge.byteToSByte(e[++a]), i.y = ge.byteToSByte(e[++a]), n.currentPoint.add(i.multiply(n.scale)), n.isPenDown && n.currentPolyline.push(n.currentPoint.clone()), a;
10801
10801
  }
10802
10802
  handleMultipleXYDisplacements(e, r, n) {
10803
10803
  let a = r;
10804
10804
  for (; ; ) {
10805
- const i = new te();
10805
+ const i = new re();
10806
10806
  if (i.x = ge.byteToSByte(e[++a]), i.y = ge.byteToSByte(e[++a]), i.x === 0 && i.y === 0)
10807
10807
  break;
10808
10808
  n.currentPoint.add(i.multiply(n.scale)), n.isPenDown && n.currentPolyline.push(n.currentPoint.clone());
@@ -10814,7 +10814,7 @@ class al {
10814
10814
  let i = r;
10815
10815
  const s = e[++i] * n.scale, o = ge.byteToSByte(e[++i]), c = (o & 112) >> 4;
10816
10816
  let u = o & 7;
10817
- const h = o < 0, p = Math.PI / 4 * c, l = n.currentPoint.clone().subtract(new te(Math.cos(p) * s, Math.sin(p) * s)), g = Bt.fromOctant(l, s, c, u, h);
10817
+ const h = o < 0, p = Math.PI / 4 * c, l = n.currentPoint.clone().subtract(new re(Math.cos(p) * s, Math.sin(p) * s)), g = Bt.fromOctant(l, s, c, u, h);
10818
10818
  if (n.isPenDown) {
10819
10819
  const x = g.tessellate();
10820
10820
  n.currentPolyline.pop(), n.currentPolyline.push(...x.slice());
@@ -10831,29 +10831,29 @@ class al {
10831
10831
  h < 0 && (v = -v, x = -x, b = -1);
10832
10832
  let m = g * p, F = m + x;
10833
10833
  m += g * i / 256 * b, F += g * s / 256 * b;
10834
- const w = n.currentPoint.clone().subtract(new te(u * Math.cos(m), u * Math.sin(m)));
10835
- if (n.currentPoint = w.clone().add(new te(u * Math.cos(F), u * Math.sin(F))), n.isPenDown) {
10834
+ const w = n.currentPoint.clone().subtract(new re(u * Math.cos(m), u * Math.sin(m)));
10835
+ if (n.currentPoint = w.clone().add(new re(u * Math.cos(F), u * Math.sin(F))), n.isPenDown) {
10836
10836
  let k = m;
10837
10837
  const C = [];
10838
10838
  if (C.push(
10839
- w.clone().add(new te(u * Math.cos(k), u * Math.sin(k)))
10839
+ w.clone().add(new re(u * Math.cos(k), u * Math.sin(k)))
10840
10840
  ), v > 0)
10841
10841
  for (; k + v < F; )
10842
10842
  k += v, C.push(
10843
- w.clone().add(new te(u * Math.cos(k), u * Math.sin(k)))
10843
+ w.clone().add(new re(u * Math.cos(k), u * Math.sin(k)))
10844
10844
  );
10845
10845
  else
10846
10846
  for (; k + v > F; )
10847
10847
  k += v, C.push(
10848
- w.clone().add(new te(u * Math.cos(k), u * Math.sin(k)))
10848
+ w.clone().add(new re(u * Math.cos(k), u * Math.sin(k)))
10849
10849
  );
10850
- C.push(w.clone().add(new te(u * Math.cos(F), u * Math.sin(F)))), n.currentPolyline.push(...C);
10850
+ C.push(w.clone().add(new re(u * Math.cos(F), u * Math.sin(F)))), n.currentPolyline.push(...C);
10851
10851
  }
10852
10852
  return a;
10853
10853
  }
10854
10854
  handleBulgeArc(e, r, n) {
10855
10855
  let a = r;
10856
- const i = new te();
10856
+ const i = new re();
10857
10857
  i.x = ge.byteToSByte(e[++a]), i.y = ge.byteToSByte(e[++a]);
10858
10858
  const s = ge.byteToSByte(e[++a]);
10859
10859
  return n.currentPoint = this.handleArcSegment(
@@ -10868,7 +10868,7 @@ class al {
10868
10868
  handleMultipleBulgeArcs(e, r, n) {
10869
10869
  let a = r;
10870
10870
  for (; ; ) {
10871
- const i = new te();
10871
+ const i = new re();
10872
10872
  if (i.x = ge.byteToSByte(e[++a]), i.y = ge.byteToSByte(e[++a]), i.x === 0 && i.y === 0)
10873
10873
  break;
10874
10874
  const s = ge.byteToSByte(e[++a]);
@@ -11434,9 +11434,9 @@ yn.write = function(t, e, r, n, a, i) {
11434
11434
  if (d >= S)
11435
11435
  return 1;
11436
11436
  if (d >>>= 0, S >>>= 0, T >>>= 0, L >>>= 0, this === f) return 0;
11437
- for (var A = L - T, V = S - d, Y = Math.min(A, V), J = this.slice(T, L), de = f.slice(d, S), ee = 0; ee < Y; ++ee)
11438
- if (J[ee] !== de[ee]) {
11439
- A = J[ee], V = de[ee];
11437
+ for (var A = L - T, V = S - d, Y = Math.min(A, V), J = this.slice(T, L), de = f.slice(d, S), te = 0; te < Y; ++te)
11438
+ if (J[te] !== de[te]) {
11439
+ A = J[te], V = de[te];
11440
11440
  break;
11441
11441
  }
11442
11442
  return A < V ? -1 : V < A ? 1 : 0;
@@ -11475,12 +11475,12 @@ yn.write = function(t, e, r, n, a, i) {
11475
11475
  de !== -1 && (J -= J - de), de = -1;
11476
11476
  } else
11477
11477
  for (d + V > A && (d = A - V), J = d; J >= 0; J--) {
11478
- for (var ee = !0, Ht = 0; Ht < V; Ht++)
11478
+ for (var te = !0, Ht = 0; Ht < V; Ht++)
11479
11479
  if (Y(y, J + Ht) !== Y(f, Ht)) {
11480
- ee = !1;
11480
+ te = !1;
11481
11481
  break;
11482
11482
  }
11483
- if (ee) return J;
11483
+ if (te) return J;
11484
11484
  }
11485
11485
  return -1;
11486
11486
  }
@@ -11567,19 +11567,19 @@ yn.write = function(t, e, r, n, a, i) {
11567
11567
  for (var S = [], T = f; T < d; ) {
11568
11568
  var L = y[T], A = null, V = L > 239 ? 4 : L > 223 ? 3 : L > 191 ? 2 : 1;
11569
11569
  if (T + V <= d) {
11570
- var Y, J, de, ee;
11570
+ var Y, J, de, te;
11571
11571
  switch (V) {
11572
11572
  case 1:
11573
11573
  L < 128 && (A = L);
11574
11574
  break;
11575
11575
  case 2:
11576
- Y = y[T + 1], (Y & 192) === 128 && (ee = (L & 31) << 6 | Y & 63, ee > 127 && (A = ee));
11576
+ Y = y[T + 1], (Y & 192) === 128 && (te = (L & 31) << 6 | Y & 63, te > 127 && (A = te));
11577
11577
  break;
11578
11578
  case 3:
11579
- Y = y[T + 1], J = y[T + 2], (Y & 192) === 128 && (J & 192) === 128 && (ee = (L & 15) << 12 | (Y & 63) << 6 | J & 63, ee > 2047 && (ee < 55296 || ee > 57343) && (A = ee));
11579
+ Y = y[T + 1], J = y[T + 2], (Y & 192) === 128 && (J & 192) === 128 && (te = (L & 15) << 12 | (Y & 63) << 6 | J & 63, te > 2047 && (te < 55296 || te > 57343) && (A = te));
11580
11580
  break;
11581
11581
  case 4:
11582
- Y = y[T + 1], J = y[T + 2], de = y[T + 3], (Y & 192) === 128 && (J & 192) === 128 && (de & 192) === 128 && (ee = (L & 15) << 18 | (Y & 63) << 12 | (J & 63) << 6 | de & 63, ee > 65535 && ee < 1114112 && (A = ee));
11582
+ Y = y[T + 1], J = y[T + 2], de = y[T + 3], (Y & 192) === 128 && (J & 192) === 128 && (de & 192) === 128 && (te = (L & 15) << 18 | (Y & 63) << 12 | (J & 63) << 6 | de & 63, te > 65535 && te < 1114112 && (A = te));
11583
11583
  }
11584
11584
  }
11585
11585
  A === null ? (A = 65533, V = 1) : A > 65535 && (A -= 65536, S.push(A >>> 10 & 1023 | 55296), A = 56320 | A & 1023), S.push(A), T += V;
@@ -22180,7 +22180,7 @@ class Wl extends Ka {
22180
22180
  a += r, this.addUnsupportedChar(s);
22181
22181
  continue;
22182
22182
  }
22183
- n.push(o.offset(new te(a, 0))), a += o.width;
22183
+ n.push(o.offset(new re(a, 0))), a += o.width;
22184
22184
  }
22185
22185
  return n;
22186
22186
  }
@@ -22631,6 +22631,7 @@ function er(t) {
22631
22631
  const e = t.color, r = e.aci;
22632
22632
  return r === 0 ? $t(t.byBlockColor) : r === 256 ? $t(t.byLayerColor) : r != null ? Za(r) : e.rgbValue !== null ? $t(e.rgbValue) : $t(t.byLayerColor);
22633
22633
  }
22634
+ const ql = 1.666666, Zt = 0.3;
22634
22635
  var Z;
22635
22636
  (function(t) {
22636
22637
  t[t.NONE = 0] = "NONE", t[t.WORD = 1] = "WORD", t[t.STACK = 2] = "STACK", t[t.SPACE = 3] = "SPACE", t[t.NBSP = 4] = "NBSP", t[t.TABULATOR = 5] = "TABULATOR", t[t.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", t[t.NEW_COLUMN = 7] = "NEW_COLUMN", t[t.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", t[t.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED";
@@ -22639,27 +22640,27 @@ var Ze;
22639
22640
  (function(t) {
22640
22641
  t[t.BOTTOM = 0] = "BOTTOM", t[t.MIDDLE = 1] = "MIDDLE", t[t.TOP = 2] = "TOP";
22641
22642
  })(Ze || (Ze = {}));
22642
- var re;
22643
+ var ee;
22643
22644
  (function(t) {
22644
22645
  t[t.DEFAULT = 0] = "DEFAULT", t[t.LEFT = 1] = "LEFT", t[t.RIGHT = 2] = "RIGHT", t[t.CENTER = 3] = "CENTER", t[t.JUSTIFIED = 4] = "JUSTIFIED", t[t.DISTRIBUTED = 5] = "DISTRIBUTED";
22645
- })(re || (re = {}));
22646
+ })(ee || (ee = {}));
22646
22647
  var Xe;
22647
22648
  (function(t) {
22648
22649
  t[t.NONE = 0] = "NONE", t[t.UNDERLINE = 1] = "UNDERLINE", t[t.OVERLINE = 2] = "OVERLINE", t[t.STRIKE_THROUGH = 4] = "STRIKE_THROUGH";
22649
22650
  })(Xe || (Xe = {}));
22650
- const ql = {
22651
+ const Xl = {
22651
22652
  c: "Ø",
22652
22653
  d: "°",
22653
22654
  p: "±",
22654
22655
  "%": "%"
22655
- }, Xl = {
22656
- l: re.LEFT,
22657
- r: re.RIGHT,
22658
- c: re.CENTER,
22659
- j: re.JUSTIFIED,
22660
- d: re.DISTRIBUTED
22661
- };
22662
- function Yl(t) {
22656
+ }, Yl = {
22657
+ l: ee.LEFT,
22658
+ r: ee.RIGHT,
22659
+ c: ee.CENTER,
22660
+ j: ee.JUSTIFIED,
22661
+ d: ee.DISTRIBUTED
22662
+ };
22663
+ function jl(t) {
22663
22664
  const [e, r, n] = t;
22664
22665
  return e << 16 | r << 8 | n;
22665
22666
  }
@@ -22673,10 +22674,10 @@ function Ha(t) {
22673
22674
  function Ki(t) {
22674
22675
  return Math.max(0, Math.min(16777215, Math.round(t)));
22675
22676
  }
22676
- function jl(t) {
22677
+ function $l(t) {
22677
22678
  return t === null ? null : `#${Ki(t).toString(16).padStart(6, "0")}`;
22678
22679
  }
22679
- function $l(t) {
22680
+ function Zl(t) {
22680
22681
  if (!t)
22681
22682
  return null;
22682
22683
  const e = t.trim().toLowerCase();
@@ -22694,13 +22695,13 @@ function $l(t) {
22694
22695
  }
22695
22696
  return null;
22696
22697
  }
22697
- function Zl(t) {
22698
+ function Kl(t) {
22698
22699
  if (!t)
22699
22700
  return null;
22700
22701
  const e = t.trim().toLowerCase();
22701
22702
  if (e === "transparent")
22702
22703
  return null;
22703
- const r = $l(e);
22704
+ const r = Zl(e);
22704
22705
  if (r)
22705
22706
  return Ki(Number.parseInt(r.slice(1), 16));
22706
22707
  const n = e.match(/^rgba?\((.*)\)$/);
@@ -22717,7 +22718,7 @@ function Zl(t) {
22717
22718
  const h = Number.parseFloat(u);
22718
22719
  return Ha(h);
22719
22720
  }, s = i(a[0]), o = i(a[1]), c = i(a[2]);
22720
- return Yl([s, o, c]);
22721
+ return jl([s, o, c]);
22721
22722
  }
22722
22723
  function uf(t) {
22723
22724
  return t.replace(/\r\n|\r|\n/g, "\\P");
@@ -22725,14 +22726,14 @@ function uf(t) {
22725
22726
  function hf(t) {
22726
22727
  return t.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
22727
22728
  }
22728
- function Kl(t, e = !1) {
22729
+ function Ql(t, e = !1) {
22729
22730
  const r = /* @__PURE__ */ new Set(), n = /\\[fF](.*?)[;|]/g;
22730
22731
  return [...t.matchAll(n)].forEach((a) => {
22731
22732
  let i = a[1].toLowerCase();
22732
22733
  e && (i = i.replace(/\.(ttf|otf|woff|shx)$/, "")), r.add(i);
22733
22734
  }), r;
22734
22735
  }
22735
- class Ql {
22736
+ class Jl {
22736
22737
  /**
22737
22738
  * Creates a new ContextStack with an initial context.
22738
22739
  * @param initial The initial MTextContext to use as the base of the stack.
@@ -22785,7 +22786,7 @@ class Ql {
22785
22786
  this.stack[this.stack.length - 1] = e;
22786
22787
  }
22787
22788
  }
22788
- class Jl {
22789
+ class ef {
22789
22790
  /**
22790
22791
  * Creates a new MTextParser instance
22791
22792
  * @param content - The MText content to parse
@@ -22795,7 +22796,7 @@ class Jl {
22795
22796
  constructor(e, r, n = {}) {
22796
22797
  this.continueStroke = !1, this.inStackContext = !1, this.scanner = new Pr(e);
22797
22798
  const a = r ?? new Dt();
22798
- this.ctxStack = new Ql(a), this.yieldPropertyCommands = n.yieldPropertyCommands ?? !1, this.resetParagraphParameters = n.resetParagraphParameters ?? !1, this.mifDecoder = n.mifDecoder ?? this.decodeMultiByteChar.bind(this), this.mifCodeLength = n.mifCodeLength ?? "auto";
22799
+ this.ctxStack = new Jl(a), this.yieldPropertyCommands = n.yieldPropertyCommands ?? !1, this.resetParagraphParameters = n.resetParagraphParameters ?? !1, this.mifDecoder = n.mifDecoder ?? this.decodeMultiByteChar.bind(this), this.mifCodeLength = n.mifCodeLength ?? "auto";
22799
22800
  }
22800
22801
  /**
22801
22802
  * Decode multi-byte character from hex code
@@ -23179,7 +23180,7 @@ class Jl {
23179
23180
  break;
23180
23181
  case "q": {
23181
23182
  const h = r.get();
23182
- for (s = Xl[h] || re.DEFAULT; r.peek() === ","; )
23183
+ for (s = Yl[h] || ee.DEFAULT; r.peek() === ","; )
23183
23184
  r.consume(1);
23184
23185
  break;
23185
23186
  }
@@ -23224,11 +23225,11 @@ class Jl {
23224
23225
  indent: 0,
23225
23226
  left: 0,
23226
23227
  right: 0,
23227
- align: re.DEFAULT,
23228
+ align: ee.DEFAULT,
23228
23229
  tabs: []
23229
23230
  };
23230
23231
  const c = {};
23231
- return o.indent !== 0 && (c.indent = 0), o.left !== 0 && (c.left = 0), o.right !== 0 && (c.right = 0), o.align !== re.DEFAULT && (c.align = re.DEFAULT), JSON.stringify(o.tabs) !== JSON.stringify([]) && (c.tabs = []), c;
23232
+ return o.indent !== 0 && (c.indent = 0), o.left !== 0 && (c.left = 0), o.right !== 0 && (c.right = 0), o.align !== ee.DEFAULT && (c.align = ee.DEFAULT), JSON.stringify(o.tabs) !== JSON.stringify([]) && (c.tabs = []), c;
23232
23233
  }
23233
23234
  const i = () => {
23234
23235
  let s = "";
@@ -23314,7 +23315,7 @@ class Jl {
23314
23315
  continue;
23315
23316
  }
23316
23317
  if (c === "%" && this.scanner.peek(1) === "%") {
23317
- const h = this.scanner.peek(2).toLowerCase(), p = ql[h];
23318
+ const h = this.scanner.peek(2).toLowerCase(), p = Xl[h];
23318
23319
  if (p) {
23319
23320
  this.scanner.consume(3), s += p;
23320
23321
  continue;
@@ -23583,14 +23584,14 @@ class vt {
23583
23584
  * Returns null if the color is ACI-based and has no RGB value.
23584
23585
  */
23585
23586
  toCssColor() {
23586
- return this._rgbValue !== null ? jl(this._rgbValue) : null;
23587
+ return this._rgbValue !== null ? $l(this._rgbValue) : null;
23587
23588
  }
23588
23589
  /**
23589
23590
  * Create an MTextColor from a CSS color string.
23590
23591
  * Supports #rgb, #rrggbb, rgb(...), rgba(...). Returns null if invalid or transparent.
23591
23592
  */
23592
23593
  static fromCssColor(e) {
23593
- const r = Zl(e);
23594
+ const r = Kl(e);
23594
23595
  if (r === null)
23595
23596
  return null;
23596
23597
  const n = new vt();
@@ -23611,7 +23612,7 @@ class Dt {
23611
23612
  indent: 0,
23612
23613
  left: 0,
23613
23614
  right: 0,
23614
- align: re.DEFAULT,
23615
+ align: ee.DEFAULT,
23615
23616
  tabs: []
23616
23617
  };
23617
23618
  }
@@ -23799,7 +23800,7 @@ const tr = "", ct = () => ({
23799
23800
  layer: "0",
23800
23801
  color: new vt()
23801
23802
  });
23802
- function ef(t) {
23803
+ function tf(t) {
23803
23804
  if (!(!t || [
23804
23805
  t.min.x,
23805
23806
  t.min.y,
@@ -23813,7 +23814,7 @@ function ef(t) {
23813
23814
  function nn(t, e, r) {
23814
23815
  const n = [];
23815
23816
  if (t.filter((l) => l.char !== tr).forEach((l) => {
23816
- const g = ef(
23817
+ const g = tf(
23817
23818
  new M.Box3().copy(l.box).applyMatrix4(e)
23818
23819
  );
23819
23820
  g && n.push({
@@ -23846,7 +23847,7 @@ function nn(t, e, r) {
23846
23847
  ...u
23847
23848
  ];
23848
23849
  }
23849
- const tf = /* @__PURE__ */ new M.Vector3(), rf = 1.666666, Zt = 0.3;
23850
+ const rf = /* @__PURE__ */ new M.Vector3();
23850
23851
  class wn extends Dt {
23851
23852
  /**
23852
23853
  * Creates a new RenderContext instance with optional initial values.
@@ -23992,7 +23993,7 @@ class nf {
23992
23993
  * The height of current line of texts
23993
23994
  */
23994
23995
  get currentLineHeight() {
23995
- const e = this.defaultLineSpaceFactor * this.currentFontSize * rf, r = this.currentMaxFontSize > 0 ? this.currentMaxFontSize : this.currentFontSize;
23996
+ const e = this.defaultLineSpaceFactor * this.currentFontSize * ql, r = this.currentMaxFontSize > 0 ? this.currentMaxFontSize : this.currentFontSize;
23996
23997
  return e + r;
23997
23998
  }
23998
23999
  /**
@@ -24126,7 +24127,7 @@ class nf {
24126
24127
  * - underline/overline/strike-through flags
24127
24128
  */
24128
24129
  applyPropertyChanges(e) {
24129
- this.applyFontFaceChange(e.fontFace), this.applyColorCommandChanges(e), this.applyWidthFactorChange(e.widthFactor), this.applyCapHeightChange(e.capHeight), this.applyCharTrackingChange(e.charTrackingFactor), this.applyParagraphChange(e.paragraph), typeof e.underline == "boolean" && (this._currentContext.underline = e.underline), typeof e.overline == "boolean" && (this._currentContext.overline = e.overline), typeof e.strikeThrough == "boolean" && (this._currentContext.strikeThrough = e.strikeThrough), e.oblique !== void 0 && (this._currentContext.oblique = e.oblique);
24130
+ this.applyFontFaceChange(e.fontFace), this.applyColorCommandChanges(e), this.applyWidthFactorChange(e.widthFactor), this.applyCapHeightChange(e.capHeight), this.applyCharTrackingChange(e.charTrackingFactor), this.applyParagraphMarginsOnly(e.paragraph), typeof e.underline == "boolean" && (this._currentContext.underline = e.underline), typeof e.overline == "boolean" && (this._currentContext.overline = e.overline), typeof e.strikeThrough == "boolean" && (this._currentContext.strikeThrough = e.strikeThrough), e.oblique !== void 0 && (this._currentContext.oblique = e.oblique);
24130
24131
  }
24131
24132
  /**
24132
24133
  * Apply a font face change to the current render context, including
@@ -24188,12 +24189,23 @@ class nf {
24188
24189
  isRelative: !1
24189
24190
  });
24190
24191
  }
24192
+ /**
24193
+ * Applies indent and margins from a paragraph snapshot only.
24194
+ *
24195
+ * Used when exiting `{}` formatting groups: the parser restores full context
24196
+ * including `paragraph.align`, but paragraph alignment is not scoped to `{}`
24197
+ * (see class comment on `_currentHorizontalAlignment`). Restoring align here
24198
+ * would undo an active `\\p...` alignment before the line is finalized.
24199
+ */
24200
+ applyParagraphMarginsOnly(e) {
24201
+ e && (typeof e.indent == "number" && (this._currentIndent = e.indent * this.defaultFontSize, this._hOffset += this._currentIndent), typeof e.left == "number" && (this._currentLeftMargin = e.left * this.defaultFontSize), typeof e.right == "number" && (this._currentRightMargin = e.right * this.defaultFontSize));
24202
+ }
24191
24203
  /**
24192
24204
  * Apply paragraph-level changes such as alignment and margins.
24193
24205
  * @param paragraph Paragraph change data.
24194
24206
  */
24195
24207
  applyParagraphChange(e) {
24196
- e && (e.align && (this._currentHorizontalAlignment = e.align), typeof e.indent == "number" && (this._currentIndent = e.indent * this.defaultFontSize, this._hOffset += this._currentIndent), typeof e.left == "number" && (this._currentLeftMargin = e.left * this.defaultFontSize), typeof e.right == "number" && (this._currentRightMargin = e.right * this.defaultFontSize));
24208
+ e && ("align" in e && (this._currentHorizontalAlignment = e.align), typeof e.indent == "number" && (this._currentIndent = e.indent * this.defaultFontSize, this._hOffset += this._currentIndent), typeof e.left == "number" && (this._currentLeftMargin = e.left * this.defaultFontSize), typeof e.right == "number" && (this._currentRightMargin = e.right * this.defaultFontSize));
24197
24209
  }
24198
24210
  /**
24199
24211
  * Reset paragraph properties to their default values from options.
@@ -24339,7 +24351,7 @@ class nf {
24339
24351
  let s = 0;
24340
24352
  for (let o = 0; o < e.length; o++) {
24341
24353
  const c = this.getCharShape(e[o]);
24342
- c ? this.currentHorizontalAlignment == re.DISTRIBUTED ? s += c.width * this.currentWidthFactor : s += c.width * this.currentWordSpace * this.currentWidthFactor : s += this._currentContext.blankWidth;
24354
+ c ? this.currentHorizontalAlignment == ee.DISTRIBUTED ? s += c.width * this.currentWidthFactor : s += c.width * this.currentWordSpace * this.currentWidthFactor : s += this._currentContext.blankWidth;
24343
24355
  }
24344
24356
  this.hOffset + s > (this.maxLineWidth || 1 / 0) && (this._vOffset <= 0 && this._currentLineObjects.length <= 0 || (this.recordVisualLineBreak(a, i), this.advanceToNextLine(!1)));
24345
24357
  for (let o = 0; o < e.length; o++)
@@ -24552,7 +24564,7 @@ class nf {
24552
24564
  const u = this.fontManager.getFontType(this.currentFont);
24553
24565
  this._currentContext.bold && u === "mesh" && o.scale(1.06, 1.06, 1), this.hOffset > (this.maxLineWidth || 1 / 0) && (this.recordVisualLineBreak(a, i), this.advanceToNextLine(!1));
24554
24566
  const h = this.hOffset, p = this.flowDirection == Ye.BOTTOM_TO_TOP ? this.vOffset : this.vOffset - this.currentLayoutFontSize, l = s.width * this.currentWidthFactor, g = this.currentLayoutFontSize;
24555
- if (o.translate(h, p, 0), this.currentHorizontalAlignment == re.DISTRIBUTED ? this._hOffset += s.width * this.currentWidthFactor : this._hOffset += s.width * this.currentWordSpace * this.currentWidthFactor, r.push(o), this._lineHasRenderableChar = !0, this._options.collectCharBoxes !== !1) {
24567
+ if (o.translate(h, p, 0), this.currentHorizontalAlignment == ee.DISTRIBUTED ? this._hOffset += s.width * this.currentWidthFactor : this._hOffset += s.width * this.currentWordSpace * this.currentWidthFactor, r.push(o), this._lineHasRenderableChar = !0, this._options.collectCharBoxes !== !1) {
24556
24568
  o.userData.char = e, o.boundingBox || o.computeBoundingBox();
24557
24569
  const b = new M.Box3().copy(o.boundingBox);
24558
24570
  o instanceof M.ShapeGeometry ? (this._lastCharBoxTarget = "mesh", a.push({
@@ -24705,7 +24717,7 @@ class nf {
24705
24717
  if (e.forEach((s, o) => {
24706
24718
  s.geometry.boundingBox || s.geometry.computeBoundingBox(), o === 0 ? r = s.geometry.boundingBox : r.union(s.geometry.boundingBox);
24707
24719
  }), !r) return;
24708
- const n = r, a = n.getSize(tf), i = (s, o) => {
24720
+ const n = r, a = n.getSize(rf), i = (s, o) => {
24709
24721
  var u, h;
24710
24722
  const c = (h = (u = s.userData) == null ? void 0 : u.layout) == null ? void 0 : h.chars;
24711
24723
  if (c && c.length > 0) {
@@ -24717,28 +24729,29 @@ class nf {
24717
24729
  }
24718
24730
  };
24719
24731
  switch (this.currentHorizontalAlignment) {
24720
- case re.LEFT: {
24732
+ case ee.LEFT:
24733
+ case ee.JUSTIFIED: {
24721
24734
  const s = this._currentLeftMargin - n.min.x, o = /* @__PURE__ */ new Set();
24722
24735
  e.forEach((c) => {
24723
24736
  c.geometry.translate(s, 0, 0), o.has(c.owner) || (i(c.owner, s), o.add(c.owner));
24724
24737
  });
24725
24738
  break;
24726
24739
  }
24727
- case re.CENTER: {
24740
+ case ee.CENTER: {
24728
24741
  const s = this._currentLeftMargin + (this.maxLineWidth - a.x) / 2 - n.min.x, o = /* @__PURE__ */ new Set();
24729
24742
  e.forEach((c) => {
24730
24743
  c.geometry.translate(s, 0, 0), o.has(c.owner) || (i(c.owner, s), o.add(c.owner));
24731
24744
  });
24732
24745
  break;
24733
24746
  }
24734
- case re.RIGHT: {
24747
+ case ee.RIGHT: {
24735
24748
  const s = this._currentLeftMargin + this.maxLineWidth - a.x - n.min.x, o = /* @__PURE__ */ new Set();
24736
24749
  e.forEach((c) => {
24737
24750
  c.geometry.translate(s, 0, 0), o.has(c.owner) || (i(c.owner, s), o.add(c.owner));
24738
24751
  });
24739
24752
  break;
24740
24753
  }
24741
- case re.DISTRIBUTED: {
24754
+ case ee.DISTRIBUTED: {
24742
24755
  const s = e.length > 1 ? (this.maxLineWidth - a.x) / (e.length - 1) : 0, o = /* @__PURE__ */ new Set();
24743
24756
  e.forEach((c, u) => {
24744
24757
  const h = s * u + (this._currentLeftMargin - n.min.x);
@@ -24822,7 +24835,7 @@ class cr extends M.Object3D {
24822
24835
  * ```
24823
24836
  */
24824
24837
  static getFonts(e, r = !1) {
24825
- return Kl(e, r);
24838
+ return Ql(e, r);
24826
24839
  }
24827
24840
  /**
24828
24841
  * Creates a new instance of MText.
@@ -25019,23 +25032,23 @@ class cr extends M.Object3D {
25019
25032
  this.styleManager.unsupportedTextStyles[m] || (this.styleManager.unsupportedTextStyles[m] = 0), this.styleManager.unsupportedTextStyles[m]++;
25020
25033
  }
25021
25034
  const n = e.width || 0, a = Number.isFinite(n) && n > 0;
25022
- let i = re.LEFT;
25035
+ let i = ee.LEFT;
25023
25036
  a && e.attachmentPoint && ([
25024
25037
  X.TopLeft,
25025
25038
  X.MiddleLeft,
25026
25039
  X.BottomLeft,
25027
25040
  X.BaselineLeft
25028
- ].includes(e.attachmentPoint) ? i = re.LEFT : [
25041
+ ].includes(e.attachmentPoint) ? i = ee.LEFT : [
25029
25042
  X.TopCenter,
25030
25043
  X.MiddleCenter,
25031
25044
  X.BottomCenter,
25032
25045
  X.BaselineCenter
25033
- ].includes(e.attachmentPoint) ? i = re.CENTER : [
25046
+ ].includes(e.attachmentPoint) ? i = ee.CENTER : [
25034
25047
  X.TopRight,
25035
25048
  X.MiddleRight,
25036
25049
  X.BottomRight,
25037
25050
  X.BaselineRight
25038
- ].includes(e.attachmentPoint) && (i = re.RIGHT));
25051
+ ].includes(e.attachmentPoint) && (i = ee.RIGHT));
25039
25052
  let s = Ze.BOTTOM;
25040
25053
  e.attachmentPoint && ([
25041
25054
  X.TopLeft,
@@ -25071,7 +25084,7 @@ class cr extends M.Object3D {
25071
25084
  this.styleManager,
25072
25085
  this.fontManager,
25073
25086
  p
25074
- ), v = new Jl(e.text, l, {
25087
+ ), v = new ef(e.text, l, {
25075
25088
  resetParagraphParameters: !0,
25076
25089
  yieldPropertyCommands: !0
25077
25090
  }).parse();
@@ -25740,18 +25753,20 @@ export {
25740
25753
  An as EventManager,
25741
25754
  $e as FontFactory,
25742
25755
  Ie as FontManager,
25756
+ ql as LINE_SPACING_SCALE_FACTOR,
25743
25757
  cr as MText,
25744
25758
  X as MTextAttachmentPoint,
25745
25759
  vt as MTextColor,
25746
25760
  Dt as MTextContext,
25747
25761
  Ye as MTextFlowDirection,
25748
25762
  Ze as MTextLineAlignment,
25749
- re as MTextParagraphAlignment,
25750
- Jl as MTextParser,
25763
+ ee as MTextParagraphAlignment,
25764
+ ef as MTextParser,
25751
25765
  Xe as MTextStroke,
25752
25766
  Nr as MTextToken,
25753
25767
  sf as MainThreadRenderer,
25754
25768
  tr as STACK_DIVIDER_CHAR,
25769
+ Zt as STACK_VERTICAL_SHIFT_FACTOR,
25755
25770
  il as ShxParserFont,
25756
25771
  Pr as TextScanner,
25757
25772
  Z as TokenType,
@@ -25760,9 +25775,9 @@ export {
25760
25775
  ct as createDefaultColorSettings,
25761
25776
  uf as escapeDxfLineEndings,
25762
25777
  Za as getColorByIndex,
25763
- Kl as getFonts,
25778
+ Ql as getFonts,
25764
25779
  hf as hasInlineFormattingCodes,
25765
25780
  cf as int2rgb,
25766
25781
  er as resolveMTextColor,
25767
- Yl as rgb2int
25782
+ jl as rgb2int
25768
25783
  };