emf-converter 4.24.0 → 4.25.1

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
@@ -13,7 +13,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
13
13
  throw Error('Dynamic require of "' + x + '" is not supported');
14
14
  });
15
15
  var __commonJS = (cb, mod3) => function __require2() {
16
- return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
16
+ try {
17
+ return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
18
+ } catch (e) {
19
+ throw mod3 = 0, e;
20
+ }
17
21
  };
18
22
  var __copyProps = (to, from, except, desc) => {
19
23
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2720,10 +2724,10 @@ var require_lib2 = __commonJS({
2720
2724
  };
2721
2725
  exports.decompressFrame = decompressFrame2;
2722
2726
  var decompressFrames = function decompressFrames2(parsedGif, buildImagePatches) {
2723
- return parsedGif.frames.filter(function(f) {
2724
- return f.image;
2725
- }).map(function(f) {
2726
- return decompressFrame2(f, parsedGif.gct, buildImagePatches);
2727
+ return parsedGif.frames.filter(function(f2) {
2728
+ return f2.image;
2729
+ }).map(function(f2) {
2730
+ return decompressFrame2(f2, parsedGif.gct, buildImagePatches);
2727
2731
  });
2728
2732
  };
2729
2733
  exports.decompressFrames = decompressFrames;
@@ -2952,7 +2956,7 @@ var require_trees = __commonJS({
2952
2956
  var n, m;
2953
2957
  var bits;
2954
2958
  var xbits;
2955
- var f;
2959
+ var f2;
2956
2960
  var overflow = 0;
2957
2961
  for (bits = 0; bits <= MAX_BITS; bits++) {
2958
2962
  s.bl_count[bits] = 0;
@@ -2974,10 +2978,10 @@ var require_trees = __commonJS({
2974
2978
  if (n >= base) {
2975
2979
  xbits = extra[n - base];
2976
2980
  }
2977
- f = tree[n * 2];
2978
- s.opt_len += f * (bits + xbits);
2981
+ f2 = tree[n * 2];
2982
+ s.opt_len += f2 * (bits + xbits);
2979
2983
  if (has_stree) {
2980
- s.static_len += f * (stree[n * 2 + 1] + xbits);
2984
+ s.static_len += f2 * (stree[n * 2 + 1] + xbits);
2981
2985
  }
2982
2986
  }
2983
2987
  if (overflow === 0) {
@@ -3591,8 +3595,8 @@ var require_deflate = __commonJS({
3591
3595
  strm.msg = msg[errorCode];
3592
3596
  return errorCode;
3593
3597
  }
3594
- function rank(f) {
3595
- return (f << 1) - (f > 4 ? 9 : 0);
3598
+ function rank(f2) {
3599
+ return (f2 << 1) - (f2 > 4 ? 9 : 0);
3596
3600
  }
3597
3601
  function zero(buf) {
3598
3602
  var len = buf.length;
@@ -6981,22 +6985,22 @@ var require_UTIF = __commonJS({
6981
6985
  this.B = -1;
6982
6986
  }
6983
6987
  function W(a, d) {
6984
- for (var f = 0, e = [], b, B, k = 16; 0 < k && !a[k - 1]; ) k--;
6988
+ for (var f2 = 0, e = [], b, B, k = 16; 0 < k && !a[k - 1]; ) k--;
6985
6989
  e.push({ children: [], index: 0 });
6986
6990
  var l = e[0], r;
6987
6991
  for (b = 0; b < k; b++) {
6988
6992
  for (B = 0; B < a[b]; B++) {
6989
6993
  l = e.pop();
6990
- for (l.children[l.index] = d[f]; 0 < l.index; ) l = e.pop();
6994
+ for (l.children[l.index] = d[f2]; 0 < l.index; ) l = e.pop();
6991
6995
  l.index++;
6992
6996
  for (e.push(l); e.length <= b; ) e.push(r = { children: [], index: 0 }), l.children[l.index] = r.children, l = r;
6993
- f++;
6997
+ f2++;
6994
6998
  }
6995
6999
  b + 1 < k && (e.push(r = { children: [], index: 0 }), l.children[l.index] = r.children, l = r);
6996
7000
  }
6997
7001
  return e[0].children;
6998
7002
  }
6999
- function X(a, d, f, e, b, B, k, l, r) {
7003
+ function X(a, d, f2, e, b, B, k, l, r) {
7000
7004
  function n() {
7001
7005
  if (0 < x) return x--, z >> x & 1;
7002
7006
  z = a[d++];
@@ -7006,7 +7010,7 @@ var require_UTIF = __commonJS({
7006
7010
  if (220 === c2 && g2) {
7007
7011
  d += 2;
7008
7012
  var b2 = a[d++] << 8 | a[d++];
7009
- if (0 < b2 && b2 !== f.g) throw new P("Found DNL marker (0xFFDC) while parsing scan data", b2);
7013
+ if (0 < b2 && b2 !== f2.g) throw new P("Found DNL marker (0xFFDC) while parsing scan data", b2);
7010
7014
  }
7011
7015
  throw new D("unexpected marker " + (z << 8 | c2).toString(16));
7012
7016
  }
@@ -7054,51 +7058,51 @@ var require_UTIF = __commonJS({
7054
7058
  function m(a2, b2) {
7055
7059
  if (0 < A) A--;
7056
7060
  else for (var d2 = B; d2 <= k; ) {
7057
- var e2 = q(a2.o), f2 = e2 & 15;
7061
+ var e2 = q(a2.o), f3 = e2 & 15;
7058
7062
  e2 >>= 4;
7059
- if (0 === f2) {
7063
+ if (0 === f3) {
7060
7064
  if (15 > e2) {
7061
7065
  A = h(e2) + (1 << e2) - 1;
7062
7066
  break;
7063
7067
  }
7064
7068
  d2 += 16;
7065
- } else d2 += e2, a2.a[b2 + J[d2]] = c(f2) * (1 << r), d2++;
7069
+ } else d2 += e2, a2.a[b2 + J[d2]] = c(f3) * (1 << r), d2++;
7066
7070
  }
7067
7071
  }
7068
7072
  function t(a2, d2) {
7069
- for (var b2 = B, e2 = 0, f2; b2 <= k; ) {
7070
- f2 = d2 + J[b2];
7071
- var l2 = 0 > a2.a[f2] ? -1 : 1;
7073
+ for (var b2 = B, e2 = 0, f3; b2 <= k; ) {
7074
+ f3 = d2 + J[b2];
7075
+ var l2 = 0 > a2.a[f3] ? -1 : 1;
7072
7076
  switch (E) {
7073
7077
  case 0:
7074
7078
  e2 = q(a2.o);
7075
- f2 = e2 & 15;
7079
+ f3 = e2 & 15;
7076
7080
  e2 >>= 4;
7077
- if (0 === f2) 15 > e2 ? (A = h(e2) + (1 << e2), E = 4) : (e2 = 16, E = 1);
7081
+ if (0 === f3) 15 > e2 ? (A = h(e2) + (1 << e2), E = 4) : (e2 = 16, E = 1);
7078
7082
  else {
7079
- if (1 !== f2) throw new D("invalid ACn encoding");
7080
- Q = c(f2);
7083
+ if (1 !== f3) throw new D("invalid ACn encoding");
7084
+ Q = c(f3);
7081
7085
  E = e2 ? 2 : 3;
7082
7086
  }
7083
7087
  continue;
7084
7088
  case 1:
7085
7089
  case 2:
7086
- a2.a[f2] ? a2.a[f2] += l2 * (n() << r) : (e2--, 0 === e2 && (E = 2 === E ? 3 : 0));
7090
+ a2.a[f3] ? a2.a[f3] += l2 * (n() << r) : (e2--, 0 === e2 && (E = 2 === E ? 3 : 0));
7087
7091
  break;
7088
7092
  case 3:
7089
- a2.a[f2] ? a2.a[f2] += l2 * (n() << r) : (a2.a[f2] = Q << r, E = 0);
7093
+ a2.a[f3] ? a2.a[f3] += l2 * (n() << r) : (a2.a[f3] = Q << r, E = 0);
7090
7094
  break;
7091
7095
  case 4:
7092
- a2.a[f2] && (a2.a[f2] += l2 * (n() << r));
7096
+ a2.a[f3] && (a2.a[f3] += l2 * (n() << r));
7093
7097
  }
7094
7098
  b2++;
7095
7099
  }
7096
7100
  4 === E && (A--, 0 === A && (E = 0));
7097
7101
  }
7098
- var g2 = 9 < arguments.length && void 0 !== arguments[9] ? arguments[9] : false, u = f.P, v = d, z = 0, x = 0, A = 0, E = 0, Q, K = e.length, F, L, M, I;
7099
- var R = f.S ? 0 === B ? 0 === l ? w : p : 0 === l ? m : t : C;
7102
+ var g2 = 9 < arguments.length && void 0 !== arguments[9] ? arguments[9] : false, u = f2.P, v = d, z = 0, x = 0, A = 0, E = 0, Q, K = e.length, F, L, M, I;
7103
+ var R = f2.S ? 0 === B ? 0 === l ? w : p : 0 === l ? m : t : C;
7100
7104
  var G = 0;
7101
- var O = 1 === K ? e[0].c * e[0].l : u * f.O;
7105
+ var O = 1 === K ? e[0].c * e[0].l : u * f2.O;
7102
7106
  for (var S, T; G < O; ) {
7103
7107
  var U = b ? Math.min(O - G, b) : O;
7104
7108
  for (F = 0; F < K; F++) e[F].m = 0;
@@ -7121,7 +7125,7 @@ var require_UTIF = __commonJS({
7121
7125
  return d - v;
7122
7126
  }
7123
7127
  function Y(a, d) {
7124
- for (var f = d.c, e = d.l, b = new Int16Array(64), B = 0; B < e; B++) for (var k = 0; k < f; k++) {
7128
+ for (var f2 = d.c, e = d.l, b = new Int16Array(64), B = 0; B < e; B++) for (var k = 0; k < f2; k++) {
7125
7129
  var l = 64 * ((d.c + 1) * B + k), r = b, n = d.G, q = d.a;
7126
7130
  if (!n) throw new D("missing required Quantization Table.");
7127
7131
  for (var h = 0; 64 > h; h += 8) {
@@ -7185,16 +7189,16 @@ var require_UTIF = __commonJS({
7185
7189
  return d.a;
7186
7190
  }
7187
7191
  function N2(a, d) {
7188
- var f = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : d, e = a.length - 1;
7189
- f = f < d ? f : d;
7192
+ var f2 = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : d, e = a.length - 1;
7193
+ f2 = f2 < d ? f2 : d;
7190
7194
  if (d >= e) return null;
7191
7195
  var b = a[d] << 8 | a[d + 1];
7192
7196
  if (65472 <= b && 65534 >= b) return { f: null, F: b, offset: d };
7193
- for (var B = a[f] << 8 | a[f + 1]; !(65472 <= B && 65534 >= B); ) {
7194
- if (++f >= e) return null;
7195
- B = a[f] << 8 | a[f + 1];
7197
+ for (var B = a[f2] << 8 | a[f2 + 1]; !(65472 <= B && 65534 >= B); ) {
7198
+ if (++f2 >= e) return null;
7199
+ B = a[f2] << 8 | a[f2 + 1];
7196
7200
  }
7197
- return { f: b.toString(16), F: B, offset: f };
7201
+ return { f: b.toString(16), F: B, offset: f2 };
7198
7202
  }
7199
7203
  var J = new Uint8Array([
7200
7204
  0,
@@ -7268,7 +7272,7 @@ var require_UTIF = __commonJS({
7268
7272
  k += 2;
7269
7273
  return d2;
7270
7274
  }
7271
- function f() {
7275
+ function f2() {
7272
7276
  var b2 = d();
7273
7277
  b2 = k + b2 - 2;
7274
7278
  var c2 = N2(a, b2, k);
@@ -7280,10 +7284,10 @@ var require_UTIF = __commonJS({
7280
7284
  function e(a2) {
7281
7285
  for (var b2 = Math.ceil(a2.v / 8 / a2.s), c2 = Math.ceil(a2.g / 8 / a2.u), d2 = 0; d2 < a2.b.length; d2++) {
7282
7286
  v = a2.b[d2];
7283
- var e2 = Math.ceil(Math.ceil(a2.v / 8) * v.h / a2.s), f2 = Math.ceil(Math.ceil(a2.g / 8) * v.j / a2.u);
7287
+ var e2 = Math.ceil(Math.ceil(a2.v / 8) * v.h / a2.s), f3 = Math.ceil(Math.ceil(a2.g / 8) * v.j / a2.u);
7284
7288
  v.a = new Int16Array(64 * c2 * v.j * (b2 * v.h + 1));
7285
7289
  v.c = e2;
7286
- v.l = f2;
7290
+ v.l = f3;
7287
7291
  }
7288
7292
  a2.P = b2;
7289
7293
  a2.O = c2;
@@ -7311,7 +7315,7 @@ var require_UTIF = __commonJS({
7311
7315
  case 65518:
7312
7316
  case 65519:
7313
7317
  case 65534:
7314
- var c = f();
7318
+ var c = f2();
7315
7319
  65518 === h && 65 === c[0] && 100 === c[1] && 111 === c[2] && 98 === c[3] && 101 === c[4] && (l = { version: c[5] << 8 | c[6], Y: c[7] << 8 | c[8], Z: c[9] << 8 | c[10], W: c[11] });
7316
7320
  break;
7317
7321
  case 65499:
@@ -7417,10 +7421,10 @@ var require_UTIF = __commonJS({
7417
7421
  }
7418
7422
  this.i = this.b.length;
7419
7423
  }, L: function(a, d) {
7420
- var f = this.width / a, e = this.height / d, b, g2, k = this.b.length, l = a * d * k, r = new Uint8ClampedArray(l), n = new Uint32Array(a);
7424
+ var f2 = this.width / a, e = this.height / d, b, g2, k = this.b.length, l = a * d * k, r = new Uint8ClampedArray(l), n = new Uint32Array(a);
7421
7425
  for (g2 = 0; g2 < k; g2++) {
7422
7426
  var q = this.b[g2];
7423
- var h = q.U * f;
7427
+ var h = q.U * f2;
7424
7428
  var c = q.V * e;
7425
7429
  var C = g2;
7426
7430
  var w = q.R;
@@ -7428,32 +7432,32 @@ var require_UTIF = __commonJS({
7428
7432
  for (b = 0; b < a; b++) q = 0 | b * h, n[b] = (q & 4294967288) << 3 | q & 7;
7429
7433
  for (h = 0; h < d; h++) for (q = 0 | h * c, q = p * (q & 4294967288) | (q & 7) << 3, b = 0; b < a; b++) r[C] = w[q + n[b]], C += k;
7430
7434
  }
7431
- if (e = this.M) for (g2 = 0; g2 < l; ) for (f = q = 0; q < k; q++, g2++, f += 2) r[g2] = (r[g2] * e[f] >> 8) + e[f + 1];
7435
+ if (e = this.M) for (g2 = 0; g2 < l; ) for (f2 = q = 0; q < k; q++, g2++, f2 += 2) r[g2] = (r[g2] * e[f2] >> 8) + e[f2 + 1];
7432
7436
  return r;
7433
7437
  }, w: function() {
7434
7438
  return this.A ? !!this.A.W : 3 === this.i ? 0 === this.B ? false : true : 1 === this.B ? true : false;
7435
7439
  }, I: function(a) {
7436
- for (var d, f, e, b = 0, g2 = a.length; b < g2; b += 3) d = a[b], f = a[b + 1], e = a[b + 2], a[b] = d - 179.456 + 1.402 * e, a[b + 1] = d + 135.459 - 0.344 * f - 0.714 * e, a[b + 2] = d - 226.816 + 1.772 * f;
7440
+ for (var d, f2, e, b = 0, g2 = a.length; b < g2; b += 3) d = a[b], f2 = a[b + 1], e = a[b + 2], a[b] = d - 179.456 + 1.402 * e, a[b + 1] = d + 135.459 - 0.344 * f2 - 0.714 * e, a[b + 2] = d - 226.816 + 1.772 * f2;
7437
7441
  return a;
7438
7442
  }, K: function(a) {
7439
- for (var d, f, e, b, g2 = 0, k = 0, l = a.length; k < l; k += 4) d = a[k], f = a[k + 1], e = a[k + 2], b = a[k + 3], a[g2++] = -122.67195406894 + f * (-660635669420364e-19 * f + 437130475926232e-18 * e - 54080610064599e-18 * d + 48449797120281e-17 * b - 0.154362151871126) + e * (-957964378445773e-18 * e + 817076911346625e-18 * d - 0.00477271405408747 * b + 1.53380253221734) + d * (961250184130688e-18 * d - 0.00266257332283933 * b + 0.48357088451265) + b * (-336197177618394e-18 * b + 0.484791561490776), a[g2++] = 107.268039397724 + f * (219927104525741e-19 * f - 640992018297945e-18 * e + 659397001245577e-18 * d + 426105652938837e-18 * b - 0.176491792462875) + e * (-778269941513683e-18 * e + 0.00130872261408275 * d + 770482631801132e-18 * b - 0.151051492775562) + d * (0.00126935368114843 * d - 0.00265090189010898 * b + 0.25802910206845) + b * (-318913117588328e-18 * b - 0.213742400323665), a[g2++] = -20.810012546947 + f * (-570115196973677e-18 * f - 263409051004589e-19 * e + 0.0020741088115012 * d - 0.00288260236853442 * b + 0.814272968359295) + e * (-153496057440975e-19 * e - 132689043961446e-18 * d + 560833691242812e-18 * b - 0.195152027534049) + d * (0.00174418132927582 * d - 0.00255243321439347 * b + 0.116935020465145) + b * (-343531996510555e-18 * b + 0.24165260232407);
7443
+ for (var d, f2, e, b, g2 = 0, k = 0, l = a.length; k < l; k += 4) d = a[k], f2 = a[k + 1], e = a[k + 2], b = a[k + 3], a[g2++] = -122.67195406894 + f2 * (-660635669420364e-19 * f2 + 437130475926232e-18 * e - 54080610064599e-18 * d + 48449797120281e-17 * b - 0.154362151871126) + e * (-957964378445773e-18 * e + 817076911346625e-18 * d - 0.00477271405408747 * b + 1.53380253221734) + d * (961250184130688e-18 * d - 0.00266257332283933 * b + 0.48357088451265) + b * (-336197177618394e-18 * b + 0.484791561490776), a[g2++] = 107.268039397724 + f2 * (219927104525741e-19 * f2 - 640992018297945e-18 * e + 659397001245577e-18 * d + 426105652938837e-18 * b - 0.176491792462875) + e * (-778269941513683e-18 * e + 0.00130872261408275 * d + 770482631801132e-18 * b - 0.151051492775562) + d * (0.00126935368114843 * d - 0.00265090189010898 * b + 0.25802910206845) + b * (-318913117588328e-18 * b - 0.213742400323665), a[g2++] = -20.810012546947 + f2 * (-570115196973677e-18 * f2 - 263409051004589e-19 * e + 0.0020741088115012 * d - 0.00288260236853442 * b + 0.814272968359295) + e * (-153496057440975e-19 * e - 132689043961446e-18 * d + 560833691242812e-18 * b - 0.195152027534049) + d * (0.00174418132927582 * d - 0.00255243321439347 * b + 0.116935020465145) + b * (-343531996510555e-18 * b + 0.24165260232407);
7440
7444
  return a.subarray(
7441
7445
  0,
7442
7446
  g2
7443
7447
  );
7444
7448
  }, J: function(a) {
7445
- for (var d, f, e, b = 0, g2 = a.length; b < g2; b += 4) d = a[b], f = a[b + 1], e = a[b + 2], a[b] = 434.456 - d - 1.402 * e, a[b + 1] = 119.541 - d + 0.344 * f + 0.714 * e, a[b + 2] = 481.816 - d - 1.772 * f;
7449
+ for (var d, f2, e, b = 0, g2 = a.length; b < g2; b += 4) d = a[b], f2 = a[b + 1], e = a[b + 2], a[b] = 434.456 - d - 1.402 * e, a[b + 1] = 119.541 - d + 0.344 * f2 + 0.714 * e, a[b + 2] = 481.816 - d - 1.772 * f2;
7446
7450
  return a;
7447
7451
  }, H: function(a) {
7448
- for (var d, f, e, b, g2 = 0, k = 1 / 255, l = 0, r = a.length; l < r; l += 4) d = a[l] * k, f = a[l + 1] * k, e = a[l + 2] * k, b = a[l + 3] * k, a[g2++] = 255 + d * (-4.387332384609988 * d + 54.48615194189176 * f + 18.82290502165302 * e + 212.25662451639585 * b - 285.2331026137004) + f * (1.7149763477362134 * f - 5.6096736904047315 * e - 17.873870861415444 * b - 5.497006427196366) + e * (-2.5217340131683033 * e - 21.248923337353073 * b + 17.5119270841813) - b * (21.86122147463605 * b + 189.48180835922747), a[g2++] = 255 + d * (8.841041422036149 * d + 60.118027045597366 * f + 6.871425592049007 * e + 31.159100130055922 * b - 79.2970844816548) + f * (-15.310361306967817 * f + 17.575251261109482 * e + 131.35250912493976 * b - 190.9453302588951) + e * (4.444339102852739 * e + 9.8632861493405 * b - 24.86741582555878) - b * (20.737325471181034 * b + 187.80453709719578), a[g2++] = 255 + d * (0.8842522430003296 * d + 8.078677503112928 * f + 30.89978309703729 * e - 0.23883238689178934 * b - 14.183576799673286) + f * (10.49593273432072 * f + 63.02378494754052 * e + 50.606957656360734 * b - 112.23884253719248) + e * (0.03296041114873217 * e + 115.60384449646641 * b - 193.58209356861505) - b * (22.33816807309886 * b + 180.12613974708367);
7452
+ for (var d, f2, e, b, g2 = 0, k = 1 / 255, l = 0, r = a.length; l < r; l += 4) d = a[l] * k, f2 = a[l + 1] * k, e = a[l + 2] * k, b = a[l + 3] * k, a[g2++] = 255 + d * (-4.387332384609988 * d + 54.48615194189176 * f2 + 18.82290502165302 * e + 212.25662451639585 * b - 285.2331026137004) + f2 * (1.7149763477362134 * f2 - 5.6096736904047315 * e - 17.873870861415444 * b - 5.497006427196366) + e * (-2.5217340131683033 * e - 21.248923337353073 * b + 17.5119270841813) - b * (21.86122147463605 * b + 189.48180835922747), a[g2++] = 255 + d * (8.841041422036149 * d + 60.118027045597366 * f2 + 6.871425592049007 * e + 31.159100130055922 * b - 79.2970844816548) + f2 * (-15.310361306967817 * f2 + 17.575251261109482 * e + 131.35250912493976 * b - 190.9453302588951) + e * (4.444339102852739 * e + 9.8632861493405 * b - 24.86741582555878) - b * (20.737325471181034 * b + 187.80453709719578), a[g2++] = 255 + d * (0.8842522430003296 * d + 8.078677503112928 * f2 + 30.89978309703729 * e - 0.23883238689178934 * b - 14.183576799673286) + f2 * (10.49593273432072 * f2 + 63.02378494754052 * e + 50.606957656360734 * b - 112.23884253719248) + e * (0.03296041114873217 * e + 115.60384449646641 * b - 193.58209356861505) - b * (22.33816807309886 * b + 180.12613974708367);
7449
7453
  return a.subarray(0, g2);
7450
- }, getData: function(a, d, f) {
7454
+ }, getData: function(a, d, f2) {
7451
7455
  if (4 < this.i) throw new D("Unsupported color mode");
7452
7456
  a = this.L(a, d);
7453
- if (1 === this.i && f) {
7454
- f = a.length;
7455
- d = new Uint8ClampedArray(3 * f);
7456
- for (var e = 0, b = 0; b < f; b++) {
7457
+ if (1 === this.i && f2) {
7458
+ f2 = a.length;
7459
+ d = new Uint8ClampedArray(3 * f2);
7460
+ for (var e = 0, b = 0; b < f2; b++) {
7457
7461
  var g2 = a[b];
7458
7462
  d[e++] = g2;
7459
7463
  d[e++] = g2;
@@ -7463,8 +7467,8 @@ var require_UTIF = __commonJS({
7463
7467
  }
7464
7468
  if (3 === this.i && this.w()) return this.I(a);
7465
7469
  if (4 === this.i) {
7466
- if (this.w()) return f ? this.K(a) : this.J(a);
7467
- if (f) return this.H(a);
7470
+ if (this.w()) return f2 ? this.K(a) : this.J(a);
7471
+ if (f2) return this.H(a);
7468
7472
  }
7469
7473
  return a;
7470
7474
  } };
@@ -9650,10 +9654,10 @@ function escapementSinCos(tenthsOfDegree) {
9650
9654
  const tenths = (tenthsOfDegree % 3600 + 3600) % 3600;
9651
9655
  const x = tenths * ESCAPEMENT_TABLE_STEPS / 3600;
9652
9656
  const k = Math.floor(x);
9653
- const f = x - k;
9657
+ const f2 = x - k;
9654
9658
  const a = k * 2 * Math.PI / ESCAPEMENT_TABLE_STEPS;
9655
9659
  const b = (k + 1) * 2 * Math.PI / ESCAPEMENT_TABLE_STEPS;
9656
- return f === 0 ? { sin: Math.sin(a), cos: Math.cos(a) } : { sin: (1 - f) * Math.sin(a) + f * Math.sin(b), cos: (1 - f) * Math.cos(a) + f * Math.cos(b) };
9660
+ return f2 === 0 ? { sin: Math.sin(a), cos: Math.cos(a) } : { sin: (1 - f2) * Math.sin(a) + f2 * Math.sin(b), cos: (1 - f2) * Math.cos(a) + f2 * Math.cos(b) };
9657
9661
  }
9658
9662
  var ESCAPEMENT_TABLE_STEPS = 128;
9659
9663
  function escapementToCanvasRadians(tenthsOfDegree) {
@@ -10439,6 +10443,197 @@ function nodeTable() {
10439
10443
  }
10440
10444
  return table = values;
10441
10445
  }
10446
+ var NODE_DELTA_8BIT = [
10447
+ 192,
10448
+ 1,
10449
+ 91,
10450
+ 2,
10451
+ 53,
10452
+ 1,
10453
+ 1440,
10454
+ 2,
10455
+ 144,
10456
+ 1,
10457
+ 960,
10458
+ 1,
10459
+ 5706,
10460
+ -2,
10461
+ 1776,
10462
+ 2,
10463
+ 768,
10464
+ 1,
10465
+ 1348,
10466
+ -1,
10467
+ 48,
10468
+ -1,
10469
+ 5,
10470
+ -1,
10471
+ 237,
10472
+ 1,
10473
+ 3930,
10474
+ 1,
10475
+ 819,
10476
+ -1,
10477
+ 2586,
10478
+ -1,
10479
+ 3,
10480
+ 1,
10481
+ 768,
10482
+ 2,
10483
+ 48,
10484
+ -1,
10485
+ 192,
10486
+ -1,
10487
+ 6838,
10488
+ -1,
10489
+ 765,
10490
+ -1,
10491
+ 3,
10492
+ 1,
10493
+ 1850,
10494
+ 1,
10495
+ 1872,
10496
+ -1,
10497
+ 1773,
10498
+ -1,
10499
+ 3,
10500
+ 1,
10501
+ 720,
10502
+ 3,
10503
+ 51,
10504
+ -1,
10505
+ 3744,
10506
+ -1,
10507
+ 337,
10508
+ -1,
10509
+ 719,
10510
+ -1,
10511
+ 48,
10512
+ -1,
10513
+ 48,
10514
+ -1,
10515
+ 2973,
10516
+ -1,
10517
+ 4035,
10518
+ 1,
10519
+ 336,
10520
+ -1,
10521
+ 3792,
10522
+ 1,
10523
+ 337,
10524
+ -1,
10525
+ 7971,
10526
+ 1,
10527
+ 48,
10528
+ -1,
10529
+ 569,
10530
+ 1,
10531
+ 3,
10532
+ -1,
10533
+ 48,
10534
+ -1,
10535
+ 199,
10536
+ 1,
10537
+ 10649,
10538
+ -1,
10539
+ 9822,
10540
+ 1,
10541
+ 3,
10542
+ -1,
10543
+ 2463,
10544
+ 1,
10545
+ 816,
10546
+ -1,
10547
+ 15121,
10548
+ -5,
10549
+ 12128,
10550
+ 1,
10551
+ 48,
10552
+ -1,
10553
+ 64,
10554
+ -1,
10555
+ 196,
10556
+ -1,
10557
+ 3499,
10558
+ -1,
10559
+ 768,
10560
+ 1,
10561
+ 7825,
10562
+ -1,
10563
+ 45,
10564
+ 1,
10565
+ 3,
10566
+ -1,
10567
+ 24062,
10568
+ 1,
10569
+ 12192,
10570
+ -1,
10571
+ 3,
10572
+ -1,
10573
+ 93,
10574
+ -1,
10575
+ 342,
10576
+ 1,
10577
+ 3,
10578
+ -1,
10579
+ 768,
10580
+ 1,
10581
+ 1467,
10582
+ 1,
10583
+ 5614,
10584
+ -1,
10585
+ 922,
10586
+ -3,
10587
+ 48,
10588
+ 1,
10589
+ 4618,
10590
+ -1,
10591
+ 45,
10592
+ -1,
10593
+ 393,
10594
+ -1,
10595
+ 516,
10596
+ 1,
10597
+ 138,
10598
+ 1,
10599
+ 114,
10600
+ 1,
10601
+ 225,
10602
+ 2,
10603
+ 429,
10604
+ 2,
10605
+ 5608,
10606
+ 1,
10607
+ 5069,
10608
+ -1,
10609
+ 48,
10610
+ 1,
10611
+ 381,
10612
+ -1,
10613
+ 3,
10614
+ 1,
10615
+ 45,
10616
+ -1,
10617
+ 852,
10618
+ -1,
10619
+ 48,
10620
+ -1,
10621
+ 3,
10622
+ -1,
10623
+ 231,
10624
+ -1
10625
+ ];
10626
+ var table8 = null;
10627
+ function nodeTable8() {
10628
+ if (table8) return table8;
10629
+ const nodes = nodeTable();
10630
+ table8 = nodes.map((v) => Math.min(65535, Math.max(0, v + 1)));
10631
+ for (let i = 0, at = 0; i < NODE_DELTA_8BIT.length; i += 2) {
10632
+ at += NODE_DELTA_8BIT[i];
10633
+ table8[at] += NODE_DELTA_8BIT[i + 1];
10634
+ }
10635
+ return table8;
10636
+ }
10442
10637
  var fraction = new Int32Array(4);
10443
10638
  var order = new Int32Array(4);
10444
10639
  var positionsIn = new Int32Array(4);
@@ -10477,7 +10672,7 @@ function interpolate(nodes, sums) {
10477
10672
  }
10478
10673
  var clamp8 = (v) => v < 0 ? 0 : v > 255 ? 255 : v;
10479
10674
  function cmykPlanesToRgba(planes, width, height, ycck) {
10480
- const nodes = nodeTable();
10675
+ const nodes = nodeTable8();
10481
10676
  const out = new Uint8Array(width * height * 4);
10482
10677
  const fix = (x) => Math.floor(x * 65536 + 0.5);
10483
10678
  const half = 1 << 15;
@@ -10507,9 +10702,9 @@ function cmykPlanesToRgba(planes, width, height, ycck) {
10507
10702
  positionsIn[2] = cmykInputPositions[y];
10508
10703
  positionsIn[3] = cmykInputPositions[255 - planes[3][p]];
10509
10704
  interpolate(nodes, sums);
10510
- out[p * 4] = clamp8(sums[0] + 4096 >> 20);
10511
- out[p * 4 + 1] = clamp8(sums[1] + 4096 >> 20);
10512
- out[p * 4 + 2] = clamp8(sums[2] + 4096 >> 20);
10705
+ out[p * 4] = sums[0] >> 20;
10706
+ out[p * 4 + 1] = sums[1] >> 20;
10707
+ out[p * 4 + 2] = sums[2] >> 20;
10513
10708
  out[p * 4 + 3] = 255;
10514
10709
  }
10515
10710
  return out;
@@ -15564,8 +15759,8 @@ function decodeVp8(data) {
15564
15759
  }
15565
15760
  var mulHi = (v, coeff) => v * coeff >> 8;
15566
15761
  var clip6 = (v) => (v & -16384) === 0 ? v >> 6 : v < 0 ? 0 : 255;
15567
- function vp8ToRgba(f, alpha) {
15568
- const { width: w, height: h } = f;
15762
+ function vp8ToRgba(f2, alpha) {
15763
+ const { width: w, height: h } = f2;
15569
15764
  const out = new Uint8ClampedArray(w * h * 4);
15570
15765
  const uvW = w + 1 >> 1;
15571
15766
  const cu = new Uint8Array(w), cv = new Uint8Array(w);
@@ -15573,9 +15768,9 @@ function vp8ToRgba(f, alpha) {
15573
15768
  const near = y >> 1;
15574
15769
  let far = y & 1 ? near + 1 : near - 1;
15575
15770
  if (far < 0 || far >= h + 1 >> 1) far = near;
15576
- const nU = near * f.uvStride, fU = far * f.uvStride;
15771
+ const nU = near * f2.uvStride, fU = far * f2.uvStride;
15577
15772
  for (let c = 0; c < 2; c++) {
15578
- const plane = c === 0 ? f.u : f.v, dst = c === 0 ? cu : cv;
15773
+ const plane = c === 0 ? f2.u : f2.v, dst = c === 0 ? cu : cv;
15579
15774
  dst[0] = 3 * plane[nU] + plane[fU] + 2 >> 2;
15580
15775
  for (let k = 1; k <= w - 1 >> 1; k++) {
15581
15776
  const tl = plane[nU + k - 1], t = plane[nU + k], l = plane[fU + k - 1], u = plane[fU + k];
@@ -15587,7 +15782,7 @@ function vp8ToRgba(f, alpha) {
15587
15782
  if (!(w & 1)) dst[w - 1] = 3 * plane[nU + uvW - 1] + plane[fU + uvW - 1] + 2 >> 2;
15588
15783
  }
15589
15784
  for (let x = 0; x < w; x++) {
15590
- const Y = mulHi(f.y[y * f.yStride + x], 19077), U = cu[x], V = cv[x];
15785
+ const Y = mulHi(f2.y[y * f2.yStride + x], 19077), U = cu[x], V = cv[x];
15591
15786
  const o = (y * w + x) * 4;
15592
15787
  out[o] = clip6(Y + mulHi(V, 26149) - 14234);
15593
15788
  out[o + 1] = clip6(Y - mulHi(U, 6419) - mulHi(V, 13320) + 8708);
@@ -15796,10 +15991,10 @@ function buildHuffman3(lengths, n) {
15796
15991
  function readSymbol(br, h) {
15797
15992
  if (h.single >= 0) return h.single;
15798
15993
  const bits = br.peek();
15799
- const f = h.fast[bits & (1 << FAST_BITS) - 1];
15800
- if (f !== 0) {
15801
- br.skip(f >>> 16);
15802
- return f & 65535;
15994
+ const f2 = h.fast[bits & (1 << FAST_BITS) - 1];
15995
+ if (f2 !== 0) {
15996
+ br.skip(f2 >>> 16);
15997
+ return f2 & 65535;
15803
15998
  }
15804
15999
  let code = 0, first = 0, index = 0;
15805
16000
  for (let len = 1; len <= MAX_CODE_LENGTH; len++) {
@@ -16230,9 +16425,9 @@ function decodeImageCodecFallback(bytes) {
16230
16425
  const width = v.getUint16(6, true), height = v.getUint16(8, true);
16231
16426
  if (!validSize(width, height)) return null;
16232
16427
  const gif = (0, import_gifuct_js.parseGIF)(bytes.slice().buffer);
16233
- const f = gif.frames.find((f2) => "image" in f2);
16234
- if (!f || !validSize(f.image.descriptor.width, f.image.descriptor.height)) return null;
16235
- const frame2 = (0, import_gifuct_js.decompressFrame)(f, gif.gct, true);
16428
+ const f2 = gif.frames.find((f3) => "image" in f3);
16429
+ if (!f2 || !validSize(f2.image.descriptor.width, f2.image.descriptor.height)) return null;
16430
+ const frame2 = (0, import_gifuct_js.decompressFrame)(f2, gif.gct, true);
16236
16431
  const data = new Uint8ClampedArray(width * height * 4);
16237
16432
  const transparent = frame2.transparentIndex !== void 0;
16238
16433
  const background = transparent ? frame2.colorTable[frame2.transparentIndex] : gif.gct?.[gif.lsd.backgroundColorIndex];
@@ -16864,10 +17059,10 @@ function polygonTrig(angle) {
16864
17059
  }
16865
17060
  const x = Math.fround(b / TRIG_STEP);
16866
17061
  const i = Math.min(127, Math.floor(x));
16867
- const f = x - i;
17062
+ const f2 = x - i;
16868
17063
  return [
16869
- POLYGON_NODES.cos[i] * (1 - f) + POLYGON_NODES.cos[i + 1] * f,
16870
- POLYGON_NODES.sin[i] * (1 - f) + POLYGON_NODES.sin[i + 1] * f
17064
+ POLYGON_NODES.cos[i] * (1 - f2) + POLYGON_NODES.cos[i + 1] * f2,
17065
+ POLYGON_NODES.sin[i] * (1 - f2) + POLYGON_NODES.sin[i + 1] * f2
16871
17066
  ];
16872
17067
  }
16873
17068
  var ATAN_KNOTS = Array.from({ length: 33 }, (_, j) => Math.atan(j / 32));
@@ -16893,21 +17088,21 @@ function unitPiece(from, to, small, radius = Infinity) {
16893
17088
  const p0 = trig(from);
16894
17089
  const p3 = trig(to);
16895
17090
  if (small && 6e-8 * radius / Math.abs(Math.sin(to - from)) > 0.5) {
16896
- const f = Math.fround;
16897
- const q0 = [f(p0[0]), f(p0[1])];
16898
- const q3 = [f(p3[0]), f(p3[1])];
16899
- const det32 = f(f(q0[0] * q3[1]) - f(q0[1] * q3[0]));
17091
+ const f2 = Math.fround;
17092
+ const q0 = [f2(p0[0]), f2(p0[1])];
17093
+ const q3 = [f2(p3[0]), f2(p3[1])];
17094
+ const det32 = f2(f2(q0[0] * q3[1]) - f2(q0[1] * q3[0]));
16900
17095
  if (det32 !== 0) {
16901
- const X = [f(f(q3[1] - q0[1]) / det32), f(f(q0[0] - q3[0]) / det32)];
16902
- const c = f(polygonTrig(Math.abs(to - from) / 2)[0]);
16903
- const kappa = f(f(f(4 / 3) * c) / f(1 + c));
17096
+ const X = [f2(f2(q3[1] - q0[1]) / det32), f2(f2(q0[0] - q3[0]) / det32)];
17097
+ const c = f2(polygonTrig(Math.abs(to - from) / 2)[0]);
17098
+ const kappa = f2(f2(f2(4 / 3) * c) / f2(1 + c));
16904
17099
  return {
16905
17100
  start: p0,
16906
17101
  ctrl: [
16907
- f(q0[0] + f(kappa * f(X[0] - q0[0]))),
16908
- f(q0[1] + f(kappa * f(X[1] - q0[1]))),
16909
- f(q3[0] + f(kappa * f(X[0] - q3[0]))),
16910
- f(q3[1] + f(kappa * f(X[1] - q3[1]))),
17102
+ f2(q0[0] + f2(kappa * f2(X[0] - q0[0]))),
17103
+ f2(q0[1] + f2(kappa * f2(X[1] - q0[1]))),
17104
+ f2(q3[0] + f2(kappa * f2(X[0] - q3[0]))),
17105
+ f2(q3[1] + f2(kappa * f2(X[1] - q3[1]))),
16911
17106
  p3[0],
16912
17107
  p3[1]
16913
17108
  ]
@@ -17039,8 +17234,8 @@ var GdiRasterPath = class {
17039
17234
  * `GetPath`, Wine `gdi32/tests/path.c`, `test_all_functions`).
17040
17235
  */
17041
17236
  continueAt(x, y) {
17042
- const f = this.current;
17043
- if (f && f.pts[f.pts.length - 2] === x && f.pts[f.pts.length - 1] === y) {
17237
+ const f2 = this.current;
17238
+ if (f2 && f2.pts[f2.pts.length - 2] === x && f2.pts[f2.pts.length - 1] === y) {
17044
17239
  return;
17045
17240
  }
17046
17241
  this.moveTo(x, y);
@@ -17076,17 +17271,17 @@ var GdiRasterPath = class {
17076
17271
  }
17077
17272
  /** Flattens one Bezier onto the open figure, recording its end tangents. */
17078
17273
  flattenInto(x0, y0, c1x, c1y, c2x, c2y, x3, y3) {
17079
- const f = this.current;
17080
- const first = f.pts.length / 2 - 1;
17081
- flattenBezier(x0, y0, c1x, c1y, c2x, c2y, x3, y3, f.pts);
17082
- const last = f.pts.length / 2 - 2;
17274
+ const f2 = this.current;
17275
+ const first = f2.pts.length / 2 - 1;
17276
+ flattenBezier(x0, y0, c1x, c1y, c2x, c2y, x3, y3, f2.pts);
17277
+ const last = f2.pts.length / 2 - 2;
17083
17278
  if (last <= first) {
17084
17279
  if (last === first) {
17085
- const n = f.pts.length;
17086
- f.tangents ?? (f.tangents = /* @__PURE__ */ new Map());
17087
- f.tangentRoles ?? (f.tangentRoles = /* @__PURE__ */ new Map());
17088
- f.tangents.set(first, [f.pts[n - 2] - f.pts[n - 4], f.pts[n - 1] - f.pts[n - 3]]);
17089
- f.tangentRoles.set(first, 3);
17280
+ const n = f2.pts.length;
17281
+ f2.tangents ?? (f2.tangents = /* @__PURE__ */ new Map());
17282
+ f2.tangentRoles ?? (f2.tangentRoles = /* @__PURE__ */ new Map());
17283
+ f2.tangents.set(first, [f2.pts[n - 2] - f2.pts[n - 4], f2.pts[n - 1] - f2.pts[n - 3]]);
17284
+ f2.tangentRoles.set(first, 3);
17090
17285
  }
17091
17286
  return;
17092
17287
  }
@@ -17098,19 +17293,19 @@ var GdiRasterPath = class {
17098
17293
  };
17099
17294
  const t0 = tangent(x0, y0, c1x, c1y, c2x, c2y, x3, y3);
17100
17295
  const t1 = tangent(c2x, c2y, x3, y3, x3, y3, x3, y3) ?? tangent(c1x, c1y, x3, y3, x3, y3, x3, y3) ?? tangent(x0, y0, x3, y3, x3, y3, x3, y3);
17101
- f.curveSegs ?? (f.curveSegs = /* @__PURE__ */ new Set());
17296
+ f2.curveSegs ?? (f2.curveSegs = /* @__PURE__ */ new Set());
17102
17297
  for (let k = first; k <= last; k++) {
17103
- f.curveSegs.add(k);
17298
+ f2.curveSegs.add(k);
17104
17299
  }
17105
- f.tangents ?? (f.tangents = /* @__PURE__ */ new Map());
17106
- f.tangentRoles ?? (f.tangentRoles = /* @__PURE__ */ new Map());
17300
+ f2.tangents ?? (f2.tangents = /* @__PURE__ */ new Map());
17301
+ f2.tangentRoles ?? (f2.tangentRoles = /* @__PURE__ */ new Map());
17107
17302
  if (t0) {
17108
- f.tangents.set(first, t0);
17109
- f.tangentRoles.set(first, 1);
17303
+ f2.tangents.set(first, t0);
17304
+ f2.tangentRoles.set(first, 1);
17110
17305
  }
17111
17306
  if (t1) {
17112
- f.tangents.set(last, t1);
17113
- f.tangentRoles.set(last, 2);
17307
+ f2.tangents.set(last, t1);
17308
+ f2.tangentRoles.set(last, 2);
17114
17309
  }
17115
17310
  }
17116
17311
  /**
@@ -17141,8 +17336,8 @@ var GdiRasterPath = class {
17141
17336
  }
17142
17337
  /** Appends every figure of `other`. */
17143
17338
  append(other) {
17144
- for (const f of other.figures) {
17145
- this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), tangentRoles: f.tangentRoles && new Map(f.tangentRoles), curveSegs: f.curveSegs && new Set(f.curveSegs), roundWiden: f.roundWiden });
17339
+ for (const f2 of other.figures) {
17340
+ this.figures.push({ pts: f2.pts.slice(), closed: f2.closed, tangents: f2.tangents && new Map(f2.tangents), tangentRoles: f2.tangentRoles && new Map(f2.tangentRoles), curveSegs: f2.curveSegs && new Set(f2.curveSegs), roundWiden: f2.roundWiden });
17146
17341
  }
17147
17342
  for (let i = 0; i < other.getPath.types.length; i++) {
17148
17343
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -17150,16 +17345,16 @@ var GdiRasterPath = class {
17150
17345
  this.current = null;
17151
17346
  }
17152
17347
  lastPoint() {
17153
- const f = this.figures[this.figures.length - 1];
17154
- if (!f) {
17348
+ const f2 = this.figures[this.figures.length - 1];
17349
+ if (!f2) {
17155
17350
  return null;
17156
17351
  }
17157
- return f.closed ? [f.pts[0], f.pts[1]] : [f.pts[f.pts.length - 2], f.pts[f.pts.length - 1]];
17352
+ return f2.closed ? [f2.pts[0], f2.pts[1]] : [f2.pts[f2.pts.length - 2], f2.pts[f2.pts.length - 1]];
17158
17353
  }
17159
17354
  };
17160
17355
  function fillPathSpans(path, winding, out) {
17161
17356
  return fillPolygonSpans(
17162
- path.figures.map((f) => f.pts),
17357
+ path.figures.map((f2) => f2.pts),
17163
17358
  winding,
17164
17359
  out
17165
17360
  );
@@ -17229,15 +17424,15 @@ function strokeCosmetic(path, on, off, pattern, style = { pos: 0 }, resetPerFigu
17229
17424
  p -= pattern[i];
17230
17425
  }
17231
17426
  };
17232
- path.figures.forEach((f, fi) => {
17427
+ path.figures.forEach((f2, fi) => {
17233
17428
  if (fi > 0 && resetPerFigure) {
17234
17429
  style.pos = 0;
17235
17430
  }
17236
- const p = f.pts;
17431
+ const p = f2.pts;
17237
17432
  for (let i = 0; i + 3 < p.length; i += 2) {
17238
17433
  cosmeticLine(p[i], p[i + 1], p[i + 2], p[i + 3], plot);
17239
17434
  }
17240
- if (f.closed && p.length >= 4) {
17435
+ if (f2.closed && p.length >= 4) {
17241
17436
  const n = p.length;
17242
17437
  if (p[n - 2] !== p[0] || p[n - 1] !== p[1]) {
17243
17438
  cosmeticLine(p[n - 2], p[n - 1], p[0], p[1], plot);
@@ -17584,7 +17779,7 @@ function accumulateLine(acc, mark, stride, rows, width, x0, y0, x1, y1) {
17584
17779
  if (top >= bottom) {
17585
17780
  return;
17586
17781
  }
17587
- const add2 = (row2, cell, v) => {
17782
+ const add3 = (row2, cell, v) => {
17588
17783
  const i = row2 * stride + cell;
17589
17784
  acc[i] += v;
17590
17785
  if (!mark[i]) {
@@ -17610,27 +17805,27 @@ function accumulateLine(acc, mark, stride, rows, width, x0, y0, x1, y1) {
17610
17805
  const hiCeil = Math.ceil(hi);
17611
17806
  if (hiCeil <= loFloor + 1) {
17612
17807
  const xmf = 0.5 * (x + xnext) - loFloor;
17613
- add2(row2, loFloor, d - d * xmf);
17614
- add2(row2, loFloor + 1, d * xmf);
17808
+ add3(row2, loFloor, d - d * xmf);
17809
+ add3(row2, loFloor + 1, d * xmf);
17615
17810
  } else {
17616
17811
  const s = 1 / (hi - lo);
17617
17812
  const x0f = lo - loFloor;
17618
17813
  const a0 = 0.5 * s * (1 - x0f) * (1 - x0f);
17619
17814
  const x1f = hi - hiCeil + 1;
17620
17815
  const am = 0.5 * s * x1f * x1f;
17621
- add2(row2, loFloor, d * a0);
17816
+ add3(row2, loFloor, d * a0);
17622
17817
  if (hiCeil === loFloor + 2) {
17623
- add2(row2, loFloor + 1, d * (1 - a0 - am));
17818
+ add3(row2, loFloor + 1, d * (1 - a0 - am));
17624
17819
  } else {
17625
17820
  const a1 = s * (1.5 - x0f);
17626
- add2(row2, loFloor + 1, d * (a1 - a0));
17821
+ add3(row2, loFloor + 1, d * (a1 - a0));
17627
17822
  for (let xi = loFloor + 2; xi < hiCeil - 1; xi++) {
17628
- add2(row2, xi, d * s);
17823
+ add3(row2, xi, d * s);
17629
17824
  }
17630
17825
  const a2 = a1 + (hiCeil - loFloor - 3) * s;
17631
- add2(row2, hiCeil - 1, d * (1 - a2 - am));
17826
+ add3(row2, hiCeil - 1, d * (1 - a2 - am));
17632
17827
  }
17633
- add2(row2, hiCeil, d * am);
17828
+ add3(row2, hiCeil, d * am);
17634
17829
  }
17635
17830
  x = xnext;
17636
17831
  }
@@ -17938,11 +18133,11 @@ function gradientColor(stops, t, out) {
17938
18133
  const a = stops[lo];
17939
18134
  const b = stops[hi];
17940
18135
  const span = b.offset - a.offset;
17941
- const f = span > 0 ? (t - a.offset) / span : 1;
17942
- const alpha = a.color[3] + (b.color[3] - a.color[3]) * f;
17943
- out[0] = (a.color[0] + (b.color[0] - a.color[0]) * f) * alpha;
17944
- out[1] = (a.color[1] + (b.color[1] - a.color[1]) * f) * alpha;
17945
- out[2] = (a.color[2] + (b.color[2] - a.color[2]) * f) * alpha;
18136
+ const f2 = span > 0 ? (t - a.offset) / span : 1;
18137
+ const alpha = a.color[3] + (b.color[3] - a.color[3]) * f2;
18138
+ out[0] = (a.color[0] + (b.color[0] - a.color[0]) * f2) * alpha;
18139
+ out[1] = (a.color[1] + (b.color[1] - a.color[1]) * f2) * alpha;
18140
+ out[2] = (a.color[2] + (b.color[2] - a.color[2]) * f2) * alpha;
17946
18141
  out[3] = alpha * 255;
17947
18142
  return;
17948
18143
  }
@@ -18869,13 +19064,13 @@ function unpremultiplyTable() {
18869
19064
  if (unpremultiplied) {
18870
19065
  return unpremultiplied;
18871
19066
  }
18872
- const f = Math.fround;
18873
- const inv255 = f(1 / 255);
19067
+ const f2 = Math.fround;
19068
+ const inv255 = f2(1 / 255);
18874
19069
  const table2 = new Uint8Array(256 * 256);
18875
19070
  for (let a = 1; a < 256; a++) {
18876
- const recip = f(1 / f(a * inv255));
19071
+ const recip = f2(1 / f2(a * inv255));
18877
19072
  for (let p = 0; p < 256; p++) {
18878
- const x = f(f(f(p * inv255) * recip) * 255);
19073
+ const x = f2(f2(f2(p * inv255) * recip) * 255);
18879
19074
  const clamped = Math.min(Math.max(x, 0), 255);
18880
19075
  const lo = Math.floor(clamped);
18881
19076
  const frac = clamped - lo;
@@ -19226,11 +19421,11 @@ var SoftwareRasterContext = class {
19226
19421
  }
19227
19422
  }
19228
19423
  getTransform() {
19229
- const [a, b, c, d, e, f] = this.state.transform;
19230
- return { a, b, c, d, e, f };
19424
+ const [a, b, c, d, e, f2] = this.state.transform;
19425
+ return { a, b, c, d, e, f: f2 };
19231
19426
  }
19232
- setTransform(a, b, c, d, e, f) {
19233
- const m = typeof a === "object" ? [a.a ?? 1, a.b ?? 0, a.c ?? 0, a.d ?? 1, a.e ?? 0, a.f ?? 0] : [a, b, c, d, e, f];
19427
+ setTransform(a, b, c, d, e, f2) {
19428
+ const m = typeof a === "object" ? [a.a ?? 1, a.b ?? 0, a.c ?? 0, a.d ?? 1, a.e ?? 0, a.f ?? 0] : [a, b, c, d, e, f2];
19234
19429
  if (m.every(Number.isFinite)) {
19235
19430
  this.state.transform = m;
19236
19431
  }
@@ -19238,9 +19433,9 @@ var SoftwareRasterContext = class {
19238
19433
  resetTransform() {
19239
19434
  this.state.transform = [...IDENTITY_MATRIX];
19240
19435
  }
19241
- transform(a, b, c, d, e, f) {
19242
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
19243
- this.state.transform = multiplyMatrix(this.state.transform, [a, b, c, d, e, f]);
19436
+ transform(a, b, c, d, e, f2) {
19437
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
19438
+ this.state.transform = multiplyMatrix(this.state.transform, [a, b, c, d, e, f2]);
19244
19439
  }
19245
19440
  }
19246
19441
  translate(x, y) {
@@ -20659,15 +20854,15 @@ var FanTriangle = class {
20659
20854
  let b = bL;
20660
20855
  const cutLeft = sub(start, xl);
20661
20856
  if (Math.abs(cutLeft) > ALPHA_EPSILON) {
20662
- const f = div(cutLeft, n);
20663
- a = add(mul(sub(aR, aL), f), aL);
20664
- b = add(mul(sub(bR, bL), f), bL);
20857
+ const f2 = div(cutLeft, n);
20858
+ a = add(mul(sub(aR, aL), f2), aL);
20859
+ b = add(mul(sub(bR, bL), f2), bL);
20665
20860
  }
20666
20861
  const cutRight = sub(xr, end);
20667
20862
  if (Math.abs(cutRight) > ALPHA_EPSILON) {
20668
- const f = div(cutRight, n);
20669
- aR = sub(aR, mul(sub(aR, aL), f));
20670
- bR = sub(bR, mul(sub(bR, bL), f));
20863
+ const f2 = div(cutRight, n);
20864
+ aR = sub(aR, mul(sub(aR, aL), f2));
20865
+ bR = sub(bR, mul(sub(bR, bL), f2));
20671
20866
  }
20672
20867
  const count = end - start;
20673
20868
  const da = div(sub(aR, a), count);
@@ -20686,9 +20881,9 @@ var FanTriangle = class {
20686
20881
  const centre = adjust(sub(sub(1, a), b));
20687
20882
  const sum = add(b, a);
20688
20883
  if (sum !== 0) {
20689
- const f = div(sub(1, centre), sum);
20690
- wa = mul(a, f);
20691
- wb = mul(b, f);
20884
+ const f2 = div(sub(1, centre), sum);
20885
+ wa = mul(a, f2);
20886
+ wb = mul(b, f2);
20692
20887
  }
20693
20888
  }
20694
20889
  for (let q = 0; q < 4; q++) {
@@ -20892,7 +21087,7 @@ var BilinearQuad = class {
20892
21087
  }
20893
21088
  /** The pixel spans `[start, end)` of scanline `y` inside `[x0, x1)` (`GetXSpans`). */
20894
21089
  spans(y, x0, x1) {
20895
- if (this.constant < 0 && this.flags.every((f) => f === 0)) return [];
21090
+ if (this.constant < 0 && this.flags.every((f2) => f2 === 0)) return [];
20896
21091
  const yf = y;
20897
21092
  if (ja(this.minY, yf)) return [];
20898
21093
  if (jae(yf, add(this.minY, this.height))) return [];
@@ -21207,8 +21402,8 @@ function piecewise(xs, ys, x) {
21207
21402
  for (let i = 1; i < n; i++) {
21208
21403
  if (x <= xs[i]) {
21209
21404
  const span = xs[i] - xs[i - 1];
21210
- const f = span > 0 ? (x - xs[i - 1]) / span : 1;
21211
- return ys[i - 1] + (ys[i] - ys[i - 1]) * f;
21405
+ const f2 = span > 0 ? (x - xs[i - 1]) / span : 1;
21406
+ return ys[i - 1] + (ys[i] - ys[i - 1]) * f2;
21212
21407
  }
21213
21408
  }
21214
21409
  return ys[n - 1];
@@ -21222,12 +21417,12 @@ function premultiplied(argb, gamma) {
21222
21417
  };
21223
21418
  return [ch(16), ch(8), ch(0), a];
21224
21419
  }
21225
- function mix(c0, c1, f) {
21420
+ function mix(c0, c1, f2) {
21226
21421
  return [
21227
- c0[0] + (c1[0] - c0[0]) * f,
21228
- c0[1] + (c1[1] - c0[1]) * f,
21229
- c0[2] + (c1[2] - c0[2]) * f,
21230
- c0[3] + (c1[3] - c0[3]) * f
21422
+ c0[0] + (c1[0] - c0[0]) * f2,
21423
+ c0[1] + (c1[1] - c0[1]) * f2,
21424
+ c0[2] + (c1[2] - c0[2]) * f2,
21425
+ c0[3] + (c1[3] - c0[3]) * f2
21231
21426
  ];
21232
21427
  }
21233
21428
  var f32Buffer = new Float32Array(1);
@@ -21258,9 +21453,9 @@ function blendFactor(positions, factors, t) {
21258
21453
  }
21259
21454
  return factors[n - 1];
21260
21455
  }
21261
- function mixBlend(c0, c1, f) {
21262
- const g = truncF32(1 - f);
21263
- const ch = (a, b) => truncF32(truncF32(a * g) + truncF32(b * f));
21456
+ function mixBlend(c0, c1, f2) {
21457
+ const g = truncF32(1 - f2);
21458
+ const ch = (a, b) => truncF32(truncF32(a * g) + truncF32(b * f2));
21264
21459
  return [ch(c0[0], c1[0]), ch(c0[1], c1[1]), ch(c0[2], c1[2]), ch(c0[3], c1[3])];
21265
21460
  }
21266
21461
  function rampColorAt(ramp, t) {
@@ -21274,8 +21469,8 @@ function rampColorAt(ramp, t) {
21274
21469
  for (let i = 1; i < n; i++) {
21275
21470
  if (t <= positions[i]) {
21276
21471
  const span = positions[i] - positions[i - 1];
21277
- const f = span > 0 ? (t - positions[i - 1]) / span : 1;
21278
- return mix(premultiplied(argb[i - 1], gamma), premultiplied(argb[i], gamma), f);
21472
+ const f2 = span > 0 ? (t - positions[i - 1]) / span : 1;
21473
+ return mix(premultiplied(argb[i - 1], gamma), premultiplied(argb[i], gamma), f2);
21279
21474
  }
21280
21475
  }
21281
21476
  return premultiplied(argb[n - 1], gamma);
@@ -21352,18 +21547,18 @@ function unpremultiply(p, a) {
21352
21547
  function writeRampColor(table2, u, out, o, truncate = false) {
21353
21548
  const n = table2.intervals;
21354
21549
  const k = Math.floor(u / FIX_ONE);
21355
- const f = Math.floor(u / 256) & 255;
21550
+ const f2 = Math.floor(u / 256) & 255;
21356
21551
  const j0 = k <= n ? k : 2 * n - k;
21357
21552
  const j1 = k + 1 <= n ? k + 1 : Math.max(0, 2 * n - k - 1);
21358
21553
  const kn = table2.knots;
21359
21554
  const i0 = Math.min(n, j0) * 4;
21360
21555
  const i1 = Math.min(n, j1) * 4;
21361
- const a = kn[i0 + 3] * (256 - f) + kn[i1 + 3] * f + 128 >> 8;
21556
+ const a = kn[i0 + 3] * (256 - f2) + kn[i1 + 3] * f2 + 128 >> 8;
21362
21557
  if (a === 0) {
21363
21558
  return;
21364
21559
  }
21365
21560
  for (let ch = 0; ch < 3; ch++) {
21366
- const p = kn[i0 + ch] * (256 - f) + kn[i1 + ch] * f + 128 >> 8;
21561
+ const p = kn[i0 + ch] * (256 - f2) + kn[i1 + ch] * f2 + 128 >> 8;
21367
21562
  out[o + ch] = a === 255 ? p : truncate ? unpremultiply(p, a) : Math.round(p * 255 / a);
21368
21563
  }
21369
21564
  out[o + 3] = a;
@@ -21371,14 +21566,14 @@ function writeRampColor(table2, u, out, o, truncate = false) {
21371
21566
  function writeRampPremultiplied(table2, u, out, o) {
21372
21567
  const n = table2.intervals;
21373
21568
  const k = Math.floor(u / FIX_ONE);
21374
- const f = Math.floor(u / 256) & 255;
21569
+ const f2 = Math.floor(u / 256) & 255;
21375
21570
  const j0 = k <= n ? k : 2 * n - k;
21376
21571
  const j1 = k + 1 <= n ? k + 1 : Math.max(0, 2 * n - k - 1);
21377
21572
  const kn = table2.knots;
21378
21573
  const i0 = Math.min(n, j0) * 4;
21379
21574
  const i1 = Math.min(n, j1) * 4;
21380
21575
  for (let ch = 0; ch < 4; ch++) {
21381
- out[o + ch] = kn[i0 + ch] * (256 - f) + kn[i1 + ch] * f + 128 >> 8;
21576
+ out[o + ch] = kn[i0 + ch] * (256 - f2) + kn[i1 + ch] * f2 + 128 >> 8;
21382
21577
  }
21383
21578
  }
21384
21579
  function mulF32(a, b) {
@@ -21537,8 +21732,8 @@ function piecewise2(xs, ys, x) {
21537
21732
  for (let i = 1; i < n; i++) {
21538
21733
  if (x <= xs[i]) {
21539
21734
  const span = xs[i] - xs[i - 1];
21540
- const f = span > 0 ? (x - xs[i - 1]) / span : 1;
21541
- return ys[i - 1] + (ys[i] - ys[i - 1]) * f;
21735
+ const f2 = span > 0 ? (x - xs[i - 1]) / span : 1;
21736
+ return ys[i - 1] + (ys[i] - ys[i - 1]) * f2;
21542
21737
  }
21543
21738
  }
21544
21739
  return ys[n - 1];
@@ -22010,7 +22205,7 @@ function parseSerializableObject(view, dataOff, dataSize) {
22010
22205
  return null;
22011
22206
  }
22012
22207
  const p = dataOff + 20;
22013
- const i32 = (k, lo, hi) => clamp(view.getInt32(p + 4 * k, true), lo, hi);
22208
+ const i322 = (k, lo, hi) => clamp(view.getInt32(p + 4 * k, true), lo, hi);
22014
22209
  const f326 = (k, lo, hi) => {
22015
22210
  const v = view.getFloat32(p + 4 * k, true);
22016
22211
  return Number.isFinite(v) ? clamp(v, lo, hi) : 0;
@@ -22020,9 +22215,9 @@ function parseSerializableObject(view, dataOff, dataSize) {
22020
22215
  case "blur":
22021
22216
  return need(8) ? { kind, radius: f326(0, 0, 255), expandEdge: view.getUint32(p + 4, true) !== 0 } : null;
22022
22217
  case "brightnessContrast":
22023
- return need(8) ? { kind, brightness: i32(0, -255, 255), contrast: i32(1, -100, 100) } : null;
22218
+ return need(8) ? { kind, brightness: i322(0, -255, 255), contrast: i322(1, -100, 100) } : null;
22024
22219
  case "colorBalance":
22025
- return need(12) ? { kind, cyanRed: i32(0, -100, 100), magentaGreen: i32(1, -100, 100), yellowBlue: i32(2, -100, 100) } : null;
22220
+ return need(12) ? { kind, cyanRed: i322(0, -100, 100), magentaGreen: i322(1, -100, 100), yellowBlue: i322(2, -100, 100) } : null;
22026
22221
  case "colorCurve": {
22027
22222
  if (!need(COLOR_CURVE_PARAMS_SIZE)) return null;
22028
22223
  const adjustment = view.getInt32(p, true), channel = view.getInt32(p + 4, true), intensity = view.getInt32(p + 8, true);
@@ -22050,9 +22245,9 @@ function parseSerializableObject(view, dataOff, dataSize) {
22050
22245
  return { kind, matrix };
22051
22246
  }
22052
22247
  case "hueSaturationLightness":
22053
- return need(12) ? { kind, hue: i32(0, -180, 180), saturation: i32(1, -100, 100), lightness: i32(2, -100, 100) } : null;
22248
+ return need(12) ? { kind, hue: i322(0, -180, 180), saturation: i322(1, -100, 100), lightness: i322(2, -100, 100) } : null;
22054
22249
  case "levels":
22055
- return need(12) ? { kind, highlight: i32(0, 0, 100), midtone: i32(1, -100, 100), shadow: i32(2, 0, 100) } : null;
22250
+ return need(12) ? { kind, highlight: i322(0, 0, 100), midtone: i322(1, -100, 100), shadow: i322(2, 0, 100) } : null;
22056
22251
  case "redEyeCorrection": {
22057
22252
  if (!need(4)) {
22058
22253
  return null;
@@ -22076,14 +22271,14 @@ function parseSerializableObject(view, dataOff, dataSize) {
22076
22271
  case "sharpen":
22077
22272
  return need(8) ? { kind, radius: f326(0, 0, 255), amount: f326(1, 0, 100) } : null;
22078
22273
  case "tint":
22079
- return need(8) ? { kind, hue: i32(0, -180, 180), amount: i32(1, -100, 100) } : null;
22274
+ return need(8) ? { kind, hue: i322(0, -180, 180), amount: i322(1, -100, 100) } : null;
22080
22275
  }
22081
22276
  }
22082
22277
  var roundHalfDown = (v) => Math.ceil(v - 0.5);
22083
- function buildLut(f, round = Math.round) {
22278
+ function buildLut(f2, round = Math.round) {
22084
22279
  const lut = new Uint8Array(256);
22085
22280
  for (let v = 0; v < 256; v++) {
22086
- lut[v] = clamp(round(f(v)), 0, 255);
22281
+ lut[v] = clamp(round(f2(v)), 0, 255);
22087
22282
  }
22088
22283
  return lut;
22089
22284
  }
@@ -22168,17 +22363,17 @@ var HUE_CIRCLE = 255;
22168
22363
  function gdipHue(r, g, b) {
22169
22364
  const max = Math.max(r, g, b);
22170
22365
  const d = max - Math.min(r, g, b);
22171
- const f = (x) => Math.floor(x * HUE_SEXTANT / d);
22366
+ const f2 = (x) => Math.floor(x * HUE_SEXTANT / d);
22172
22367
  if (max === r && g >= b) {
22173
- return f(g - b);
22368
+ return f2(g - b);
22174
22369
  }
22175
22370
  if (max === b && b !== r) {
22176
- return r >= g ? 170 + f(r - g) : 127 + f(b - g);
22371
+ return r >= g ? 170 + f2(r - g) : 127 + f2(b - g);
22177
22372
  }
22178
22373
  if (max === g) {
22179
- return b >= r ? 86 + f(b - r) : 43 + f(g - r);
22374
+ return b >= r ? 86 + f2(b - r) : 43 + f2(g - r);
22180
22375
  }
22181
- const t = f(b - g);
22376
+ const t = f2(b - g);
22182
22377
  const q = (256 - t - (t >= 40 ? 1 : 0)) % 256;
22183
22378
  return q - Math.floor((q + 42) / 86);
22184
22379
  }
@@ -23206,7 +23401,7 @@ function deriveClipDomain(...regions) {
23206
23401
  let minY = Infinity;
23207
23402
  let maxX = -Infinity;
23208
23403
  let maxY = -Infinity;
23209
- const add2 = (x2, y2) => {
23404
+ const add3 = (x2, y2) => {
23210
23405
  if (Math.abs(x2) < FINITE_LIMIT && Math.abs(y2) < FINITE_LIMIT) {
23211
23406
  minX = Math.min(minX, x2);
23212
23407
  minY = Math.min(minY, y2);
@@ -23218,7 +23413,7 @@ function deriveClipDomain(...regions) {
23218
23413
  for (const shape of region ?? []) {
23219
23414
  for (const poly of flattenClipCmds(shape.cmds)) {
23220
23415
  for (let i = 0; i < poly.length; i += 2) {
23221
- add2(poly[i], poly[i + 1]);
23416
+ add3(poly[i], poly[i + 1]);
23222
23417
  }
23223
23418
  }
23224
23419
  }
@@ -23836,6 +24031,7 @@ function parsePathGradient(view, b, end) {
23836
24031
  }
23837
24032
  let boundaryPts = [];
23838
24033
  let boundaryArgb = [];
24034
+ let source;
23839
24035
  const surroundAt = (k) => surround.length > 0 ? surround[Math.min(k, surround.length - 1)] : centerArgb;
23840
24036
  if (flags & BRUSH_DATA_PATH) {
23841
24037
  if (o + 4 <= end) {
@@ -23847,6 +24043,20 @@ function parsePathGradient(view, b, end) {
23847
24043
  const flat = flattenFirstFigure(path.points, path.types, surroundAt);
23848
24044
  boundaryPts = flat.points;
23849
24045
  boundaryArgb = flat.argb;
24046
+ let figure = path.points.length;
24047
+ for (let k = 0; k < path.points.length; k++) {
24048
+ if (k > 0 && (path.types[k] & 7) === 0) {
24049
+ figure = k;
24050
+ break;
24051
+ }
24052
+ if (path.types[k] & 128) {
24053
+ figure = k + 1;
24054
+ break;
24055
+ }
24056
+ }
24057
+ if (path.types.slice(0, figure).some((t) => (t & 7) === 3)) {
24058
+ source = { points: path.points.slice(0, figure), types: path.types.slice(0, figure) };
24059
+ }
23850
24060
  }
23851
24061
  o += pathSize;
23852
24062
  }
@@ -23939,6 +24149,7 @@ function parsePathGradient(view, b, end) {
23939
24149
  center,
23940
24150
  centerArgb,
23941
24151
  boundary: boundaryPts,
24152
+ source,
23942
24153
  boundaryArgb,
23943
24154
  blend,
23944
24155
  preset,
@@ -24243,12 +24454,12 @@ function recordNominalFigures(buildPath, device, cull) {
24243
24454
  if (!fig) {
24244
24455
  moveTo(c1x, c1y);
24245
24456
  }
24246
- const f = fig;
24247
- f.curved = true;
24248
- const n = f.pts.length;
24457
+ const f2 = fig;
24458
+ f2.curved = true;
24459
+ const n = f2.pts.length;
24249
24460
  flattenBezierGdiplus(
24250
- [f.pts[n - 2], f.pts[n - 1], fx(c1x, c1y), fy(c1x, c1y), fx(c2x, c2y), fy(c2x, c2y), fx(x, y), fy(x, y)],
24251
- f.pts);
24461
+ [f2.pts[n - 2], f2.pts[n - 1], fx(c1x, c1y), fy(c1x, c1y), fx(c2x, c2y), fy(c2x, c2y), fx(x, y), fy(x, y)],
24462
+ f2.pts);
24252
24463
  },
24253
24464
  ellipse(cx, cy, rx, ry, rotation, a0, a1, ccw) {
24254
24465
  let sweep = a1 - a0;
@@ -24293,11 +24504,11 @@ function recordNominalFigures(buildPath, device, cull) {
24293
24504
  }
24294
24505
  };
24295
24506
  buildPath(recorder);
24296
- return figures.filter((f) => f.pts.length >= 4);
24507
+ return figures.filter((f2) => f2.pts.length >= 4);
24297
24508
  }
24298
- function strokePoints(f) {
24299
- const p = f.pts;
24300
- if (!f.closed || p.length < 4) {
24509
+ function strokePoints(f2) {
24510
+ const p = f2.pts;
24511
+ if (!f2.closed || p.length < 4) {
24301
24512
  return p;
24302
24513
  }
24303
24514
  return [...p, p[0], p[1]];
@@ -24552,7 +24763,7 @@ function nominalOutline(pts) {
24552
24763
  return poly;
24553
24764
  }
24554
24765
  function nominalLineCoverage(figures, mode, box) {
24555
- if (!mode.antialias && mode.opaqueSolid && !figures.some((f) => f.curved)) {
24766
+ if (!mode.antialias && mode.opaqueSolid && !figures.some((f2) => f2.curved)) {
24556
24767
  const shift = mode.half ? 8 : 0;
24557
24768
  const out = new Uint8ClampedArray(box.w * box.h);
24558
24769
  const plot = (x, y) => {
@@ -24563,8 +24774,8 @@ function nominalLineCoverage(figures, mode, box) {
24563
24774
  }
24564
24775
  };
24565
24776
  const clip = mode.clip && !pathInside(figures, mode.clip, shift) ? mode.clip : void 0;
24566
- for (const f of figures) {
24567
- const p = strokePoints(f);
24777
+ for (const f2 of figures) {
24778
+ const p = strokePoints(f2);
24568
24779
  for (let i = 0; i + 3 < p.length; i += 2) {
24569
24780
  ddaSegment(p[i] - shift, p[i + 1] - shift, p[i + 2] - shift, p[i + 3] - shift, true, plot, clip);
24570
24781
  }
@@ -24572,8 +24783,8 @@ function nominalLineCoverage(figures, mode, box) {
24572
24783
  return out;
24573
24784
  }
24574
24785
  const polys = [];
24575
- for (const f of figures) {
24576
- for (const batch of enumeratorBatches(strokePoints(f))) {
24786
+ for (const f2 of figures) {
24787
+ for (const batch of enumeratorBatches(strokePoints(f2))) {
24577
24788
  const outline = nominalOutline(batch);
24578
24789
  if (outline.length >= 6) {
24579
24790
  polys.push(outline);
@@ -24587,10 +24798,10 @@ function pathInside(figures, clip, shift) {
24587
24798
  let y0 = Infinity;
24588
24799
  let x1 = -Infinity;
24589
24800
  let y1 = -Infinity;
24590
- for (const f of figures) {
24591
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
24592
- const x = (f.pts[i] - shift) / 16;
24593
- const y = (f.pts[i + 1] - shift) / 16;
24801
+ for (const f2 of figures) {
24802
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
24803
+ const x = (f2.pts[i] - shift) / 16;
24804
+ const y = (f2.pts[i + 1] - shift) / 16;
24594
24805
  x0 = Math.min(x0, x);
24595
24806
  x1 = Math.max(x1, x);
24596
24807
  y0 = Math.min(y0, y);
@@ -24640,24 +24851,24 @@ function recordDeviceFigures(buildPath, device) {
24640
24851
  if (!fig) {
24641
24852
  moveTo(c1x, c1y);
24642
24853
  }
24643
- const f = fig;
24644
- f.curved = true;
24645
- const n = f.pts.length;
24646
- const near = (qx, qy) => Math.abs(qx - f.pts[n - 2]) < 1e-3 && Math.abs(qy - f.pts[n - 1]) < 1e-3;
24854
+ const f2 = fig;
24855
+ f2.curved = true;
24856
+ const n = f2.pts.length;
24857
+ const near = (qx, qy) => Math.abs(qx - f2.pts[n - 2]) < 1e-3 && Math.abs(qy - f2.pts[n - 1]) < 1e-3;
24647
24858
  const degenerate = near(dx(c1x, c1y), dy(c1x, c1y)) && near(dx(c2x, c2y), dy(c2x, c2y)) && near(dx(x, y), dy(x, y));
24648
24859
  const fix = (v) => toPlusFix(v);
24649
- const p0x = fix(f.pts[n - 2]);
24650
- const p0y = fix(f.pts[n - 1]);
24651
- f.pts[n - 2] = p0x / 16;
24652
- f.pts[n - 1] = p0y / 16;
24860
+ const p0x = fix(f2.pts[n - 2]);
24861
+ const p0y = fix(f2.pts[n - 1]);
24862
+ f2.pts[n - 2] = p0x / 16;
24863
+ f2.pts[n - 1] = p0y / 16;
24653
24864
  if (degenerate) {
24654
- (f.splits ?? (f.splits = [])).push({ x: p0x / 16, y: p0y / 16 });
24865
+ (f2.splits ?? (f2.splits = [])).push({ x: p0x / 16, y: p0y / 16 });
24655
24866
  }
24656
24867
  const out = [];
24657
24868
  const ctrl = [p0x, p0y, fix(dx(c1x, c1y)), fix(dy(c1x, c1y)), fix(dx(c2x, c2y)), fix(dy(c2x, c2y)), fix(dx(x, y)), fix(dy(x, y))];
24658
24869
  flattenBezierGdiplus(ctrl, out);
24659
24870
  for (const v of out) {
24660
- f.pts.push(v / 16);
24871
+ f2.pts.push(v / 16);
24661
24872
  }
24662
24873
  };
24663
24874
  const closePath = () => {
@@ -24712,10 +24923,10 @@ function recordDeviceFigures(buildPath, device) {
24712
24923
  }
24713
24924
  };
24714
24925
  buildPath(recorder);
24715
- return figures.filter((f) => f.pts.length >= 4);
24926
+ return figures.filter((f2) => f2.pts.length >= 4);
24716
24927
  }
24717
24928
  function recordPlusFigures(buildPath, device, aliased = false) {
24718
- return recordDeviceFigures(buildPath, device).map((f) => (aliased && !f.curved ? aliasedRectFix(f.pts) : null) ?? f.pts.map(toPlusFix)).filter((f) => f.length >= 6);
24929
+ return recordDeviceFigures(buildPath, device).map((f2) => (aliased && !f2.curved ? aliasedRectFix(f2.pts) : null) ?? f2.pts.map(toPlusFix)).filter((f2) => f2.length >= 6);
24719
24930
  }
24720
24931
  function ceilDiv2(a, b) {
24721
24932
  let q = Math.floor(a / b);
@@ -24732,12 +24943,12 @@ function figuresBox(figures, size) {
24732
24943
  let y0 = Infinity;
24733
24944
  let x1 = -Infinity;
24734
24945
  let y1 = -Infinity;
24735
- for (const f of figures) {
24736
- for (let i = 0; i < f.length; i += 2) {
24737
- x0 = Math.min(x0, f[i]);
24738
- x1 = Math.max(x1, f[i]);
24739
- y0 = Math.min(y0, f[i + 1]);
24740
- y1 = Math.max(y1, f[i + 1]);
24946
+ for (const f2 of figures) {
24947
+ for (let i = 0; i < f2.length; i += 2) {
24948
+ x0 = Math.min(x0, f2[i]);
24949
+ x1 = Math.max(x1, f2[i]);
24950
+ y0 = Math.min(y0, f2[i + 1]);
24951
+ y1 = Math.max(y1, f2[i + 1]);
24741
24952
  }
24742
24953
  }
24743
24954
  if (!Number.isFinite(x0)) {
@@ -24759,14 +24970,14 @@ function rasterizePlusFill(figures, evenOdd, antialias, half, box) {
24759
24970
  const y0 = 16 * box.y + o - (antialias ? 8 : 0);
24760
24971
  const cols = box.w * sx;
24761
24972
  const edges = [];
24762
- for (const f of figures) {
24763
- const n = f.length / 2;
24973
+ for (const f2 of figures) {
24974
+ const n = f2.length / 2;
24764
24975
  for (let i = 0; i < n; i++) {
24765
24976
  const j = (i + 1) % n;
24766
- const ax = f[2 * i];
24767
- const ay = f[2 * i + 1];
24768
- const bx = f[2 * j];
24769
- const by = f[2 * j + 1];
24977
+ const ax = f2[2 * i];
24978
+ const ay = f2[2 * i + 1];
24979
+ const bx = f2[2 * j];
24980
+ const by = f2[2 * j + 1];
24770
24981
  if (ay === by) {
24771
24982
  continue;
24772
24983
  }
@@ -24831,7 +25042,7 @@ function clipPixelRects(shapes, box, half) {
24831
25042
  for (const shape of shapes) {
24832
25043
  let figs;
24833
25044
  try {
24834
- figs = recordDeviceFigures(shape.build, identity).map((f) => f.pts.map(nearestFix));
25045
+ figs = recordDeviceFigures(shape.build, identity).map((f2) => f2.pts.map(nearestFix));
24835
25046
  } catch {
24836
25047
  return null;
24837
25048
  }
@@ -24878,6 +25089,156 @@ function clipPixelRects(shapes, box, half) {
24878
25089
  return rects;
24879
25090
  }
24880
25091
 
25092
+ // src/emf-plus-widen-f32.ts
25093
+ var f = Math.fround;
25094
+ var add2 = (a, b) => down32(a + b);
25095
+ var sub2 = (a, b) => down32(a - b);
25096
+ var mul3 = (a, b) => down32(a * b);
25097
+ var div2 = (a, b) => down32(a / b);
25098
+ var EPSILON2 = 11920928955078125e-23;
25099
+ function gradientF32(a, b) {
25100
+ let gx = sub2(f(b.x), f(a.x));
25101
+ let gy = sub2(f(b.y), f(a.y));
25102
+ const sum = add2(mul3(gy, gy), mul3(gx, gx));
25103
+ let len = 0;
25104
+ if (sum > 0) {
25105
+ len = down32(Math.sqrt(sum));
25106
+ gx = div2(gx, len);
25107
+ gy = div2(gy, len);
25108
+ }
25109
+ return { gx, gy, len };
25110
+ }
25111
+ function normF32(dx, dy) {
25112
+ const len = Math.sqrt(dx * dx + dy * dy);
25113
+ return len < EPSILON2 ? 0 : down32(len);
25114
+ }
25115
+ var KAPPA2 = f(0.552284777);
25116
+ var SEMICIRCLE = [
25117
+ [1, 0],
25118
+ [1, KAPPA2],
25119
+ [KAPPA2, 1],
25120
+ [0, 1],
25121
+ [-KAPPA2, 1],
25122
+ [-1, KAPPA2],
25123
+ [-1, 0]
25124
+ ];
25125
+ function capTransform(p, g, a, b, start) {
25126
+ const gx = start ? -g.gx : g.gx;
25127
+ const gy = start ? -g.gy : g.gy;
25128
+ const sum = add2(a, b);
25129
+ const half = mul3(sub2(a, b), 0.5);
25130
+ const cx = add2(mul3(mul3(sum, g.gy), 0.5), p.x);
25131
+ const cy = sub2(p.y, mul3(mul3(sum, g.gx), 0.5));
25132
+ const hy = mul3(half, gy);
25133
+ const nhx = mul3(-half, gx);
25134
+ return (x, y) => ({ x: add2(sub2(mul3(x, hy), mul3(y, nhx)), cx), y: add2(add2(mul3(y, hy), mul3(x, nhx)), cy) });
25135
+ }
25136
+ function doubleRoundCapF32(p, g, a, b, start) {
25137
+ const at = capTransform(p, g, a, b, start);
25138
+ const out = [];
25139
+ for (const shift of [0.5, -0.5]) {
25140
+ for (const [ux, uy] of SEMICIRCLE) {
25141
+ out.push(at(add2(mul3(ux, 0.5), shift), mul3(uy, 0.5)));
25142
+ }
25143
+ }
25144
+ return out;
25145
+ }
25146
+ function offsetPointF32(p, g, o) {
25147
+ if (o < 0) {
25148
+ return { x: add2(p.x, mul3(-o, g.gy)), y: add2(p.y, mul3(-o, -g.gx)) };
25149
+ }
25150
+ return { x: sub2(p.x, mul3(o, g.gy)), y: sub2(p.y, mul3(o, -g.gx)) };
25151
+ }
25152
+ function dashF32(pts, closed, dash, offset) {
25153
+ const n = pts.length;
25154
+ if (n < 2 || dash.length === 0) {
25155
+ return [];
25156
+ }
25157
+ let total = 0;
25158
+ for (const d of dash) {
25159
+ total = add2(total, d);
25160
+ }
25161
+ if (!(total > 0)) {
25162
+ return [];
25163
+ }
25164
+ let rem = f(offset % total);
25165
+ if (rem < 0) {
25166
+ rem = add2(rem, total);
25167
+ }
25168
+ let idx = 0;
25169
+ for (let guard = 0; guard < 1e6; guard++) {
25170
+ const d = dash[idx % dash.length];
25171
+ if (d > rem) {
25172
+ rem = sub2(d, rem);
25173
+ break;
25174
+ }
25175
+ rem = sub2(rem, d);
25176
+ idx++;
25177
+ }
25178
+ let on = idx % 2 === 0;
25179
+ let nextIdx = idx + 1;
25180
+ const lengths = [0];
25181
+ for (let i = 1; i < n; i++) {
25182
+ lengths.push(gradientF32(pts[i - 1], pts[i]).len);
25183
+ }
25184
+ let cur;
25185
+ let k;
25186
+ let segRem;
25187
+ {
25188
+ cur = pts[n - 1];
25189
+ k = 0;
25190
+ segRem = normF32(sub2(pts[0].x, cur.x), sub2(pts[0].y, cur.y));
25191
+ }
25192
+ let dashRem = rem;
25193
+ const out = [];
25194
+ let run = null;
25195
+ const tiny = (a, b) => Math.abs(sub2(a.x, b.x)) < EPSILON2 && Math.abs(sub2(a.y, b.y)) < EPSILON2;
25196
+ for (let guard = 0; k < n && guard < 1e7; guard++) {
25197
+ const next = pts[k];
25198
+ if (dashRem > segRem) {
25199
+ dashRem = sub2(dashRem, segRem);
25200
+ if (on) {
25201
+ if (tiny(cur, next)) {
25202
+ if (run && run.length > 1) {
25203
+ out.push(run);
25204
+ }
25205
+ run = null;
25206
+ } else {
25207
+ run ?? (run = [cur]);
25208
+ run.push(next);
25209
+ }
25210
+ }
25211
+ cur = next;
25212
+ k++;
25213
+ if (k < n) {
25214
+ segRem = lengths[k];
25215
+ }
25216
+ } else {
25217
+ const t = div2(dashRem, segRem);
25218
+ const q = { x: add2(mul3(sub2(next.x, cur.x), t), cur.x), y: add2(mul3(sub2(next.y, cur.y), t), cur.y) };
25219
+ segRem = sub2(segRem, dashRem);
25220
+ if (on) {
25221
+ if (!tiny(cur, q)) {
25222
+ run ?? (run = [cur]);
25223
+ run.push(q);
25224
+ out.push(run);
25225
+ } else if (run && run.length > 1) {
25226
+ out.push(run);
25227
+ }
25228
+ run = null;
25229
+ }
25230
+ cur = q;
25231
+ dashRem = dash[nextIdx % dash.length];
25232
+ nextIdx++;
25233
+ on = !on;
25234
+ }
25235
+ }
25236
+ if (on && run && run.length > 1) {
25237
+ out.push(run);
25238
+ }
25239
+ return out;
25240
+ }
25241
+
24881
25242
  // src/emf-plus-widen.ts
24882
25243
  function arcPoints2(c, r, a0, sweep) {
24883
25244
  const out = [];
@@ -24985,8 +25346,8 @@ function joinPoints(p, f1, f2, o, pen, meetInside = false) {
24985
25346
  }
24986
25347
  return [a, b];
24987
25348
  }
24988
- function capPoints(p, f, o1, o2, cap, half, double = false) {
24989
- const at = (o, ext) => ({ x: p.x + f.nx * o + f.ux * ext, y: p.y + f.ny * o + f.uy * ext });
25349
+ function capPoints(p, f2, o1, o2, cap, half, double = false) {
25350
+ const at = (o, ext) => ({ x: p.x + f2.nx * o + f2.ux * ext, y: p.y + f2.ny * o + f2.uy * ext });
24990
25351
  const base = cap & 15;
24991
25352
  const kind = cap === 17 ? 1 : cap === 18 ? 2 : cap === 19 || cap === 20 ? 3 : cap >= 16 ? 0 : base;
24992
25353
  switch (kind) {
@@ -24995,7 +25356,7 @@ function capPoints(p, f, o1, o2, cap, half, double = false) {
24995
25356
  case 2: {
24996
25357
  if (double) {
24997
25358
  const r2 = Math.abs(o2 - o1) / 4;
24998
- const a02 = Math.atan2(f.ny, f.nx);
25359
+ const a02 = Math.atan2(f2.ny, f2.nx);
24999
25360
  const mid = (o1 + o2) / 2;
25000
25361
  const c2 = (o2 + mid) / 2;
25001
25362
  const c1 = (o1 + mid) / 2;
@@ -25004,7 +25365,7 @@ function capPoints(p, f, o1, o2, cap, half, double = false) {
25004
25365
  const c = (o1 + o2) / 2;
25005
25366
  const r = Math.abs(o2 - o1) / 2;
25006
25367
  const centre = Math.abs(c) > 1e-9 ? at(c, 0) : p;
25007
- const a0 = Math.atan2(f.ny, f.nx) + (o2 < c ? Math.PI : 0);
25368
+ const a0 = Math.atan2(f2.ny, f2.nx) + (o2 < c ? Math.PI : 0);
25008
25369
  const sweep = o2 > c ? -Math.PI : Math.PI;
25009
25370
  return [at(o2, 0), ...arcPoints2(centre, r, a0, sweep), at(o1, 0)];
25010
25371
  }
@@ -25031,8 +25392,8 @@ function sidePoints(pts, closed, o, pen) {
25031
25392
  if (inIdx >= 0 && outIdx >= 0) {
25032
25393
  out.push(...joinPoints(pts[i], frames[inIdx], frames[outIdx], o, pen, closed && !!pen.compound));
25033
25394
  } else {
25034
- const f = frames[outIdx >= 0 ? outIdx : inIdx];
25035
- out.push({ x: pts[i].x + f.nx * o, y: pts[i].y + f.ny * o });
25395
+ const f2 = frames[outIdx >= 0 ? outIdx : inIdx];
25396
+ out.push({ x: pts[i].x + f2.nx * o, y: pts[i].y + f2.ny * o });
25036
25397
  }
25037
25398
  }
25038
25399
  return out;
@@ -25105,13 +25466,50 @@ function dashFigure(pts, closed, pen, splits) {
25105
25466
  }
25106
25467
  return out.filter((d) => d.pts.length > 1);
25107
25468
  }
25469
+ function dashPiecesSingle(raw, pen) {
25470
+ const width = down32(pen.dashCapWidth ?? 2 * pen.half);
25471
+ const least = down32(Math.fround(1e-3) * width);
25472
+ const dash = pen.dash.map((v, i) => {
25473
+ const d = down32(v);
25474
+ if (i % 2 === 1) {
25475
+ return down32(d + width);
25476
+ }
25477
+ const shortened = down32(d - width);
25478
+ return least > shortened ? least : shortened;
25479
+ });
25480
+ const pts = [];
25481
+ for (let i = 0; i + 1 < raw.length; i += 2) {
25482
+ pts.push({ x: Math.fround(raw[i]), y: Math.fround(raw[i + 1]) });
25483
+ }
25484
+ if (pts.length > 1 && pts[0].x === pts[pts.length - 1].x && pts[0].y === pts[pts.length - 1].y) {
25485
+ pts.pop();
25486
+ }
25487
+ return dashF32(pts, true, dash, down32(down32(pen.dashOffset) - width)).map((d) => ({ pts: d, first: false, last: false }));
25488
+ }
25489
+ function singleCap(p, g, o1, o2, start) {
25490
+ const c = doubleRoundCapF32({ x: Math.fround(p.x), y: Math.fround(p.y) }, g, o2, o1, start);
25491
+ const out = [c[0]];
25492
+ for (const [i0, i1, i2, i3] of [
25493
+ [0, 1, 2, 3],
25494
+ [3, 4, 5, 6],
25495
+ [7, 8, 9, 10],
25496
+ [10, 11, 12, 13]
25497
+ ]) {
25498
+ const flat = [];
25499
+ flattenBezierGdiplus([i0, i1, i2, i3].flatMap((i) => [toPlusFix(c[i].x), toPlusFix(c[i].y)]), flat);
25500
+ for (let k = 0; k + 1 < flat.length; k += 2) {
25501
+ out.push({ x: flat[k] / 16, y: flat[k + 1] / 16 });
25502
+ }
25503
+ }
25504
+ return out.reverse();
25505
+ }
25108
25506
  var ARROW_ANCHOR = 20;
25109
25507
  function centeredAnchor(pp, atEnd, half, cap) {
25110
25508
  const p = atEnd ? pp[pp.length - 1] : pp[0];
25111
25509
  const q = atEnd ? pp[pp.length - 2] : pp[1];
25112
- const f = frame(q, p);
25113
- const at = (u, n) => ({ x: p.x + f.ux * u + f.nx * n, y: p.y + f.uy * u + f.ny * n });
25114
- if (cap === 18) return arcPoints2(p, 2 * half, Math.atan2(f.uy, f.ux), 2 * Math.PI);
25510
+ const f2 = frame(q, p);
25511
+ const at = (u, n) => ({ x: p.x + f2.ux * u + f2.nx * n, y: p.y + f2.uy * u + f2.ny * n });
25512
+ if (cap === 18) return arcPoints2(p, 2 * half, Math.atan2(f2.uy, f2.ux), 2 * Math.PI);
25115
25513
  if (cap === 19) return [at(-2 * half, 0), at(0, -2 * half), at(2 * half, 0), at(0, 2 * half)];
25116
25514
  const h = Math.SQRT2 * half;
25117
25515
  return [at(-h, -h), at(h, -h), at(h, h), at(-h, h)];
@@ -25226,7 +25624,8 @@ function widenFigures(figures, pen) {
25226
25624
  bands.push([lo, hi]);
25227
25625
  }
25228
25626
  const dashPen = pen.inset && closed ? { ...pen, dashOffset: pen.dashOffset * 2 } : pen;
25229
- const pieces = pen.dash ? dashFigure(pts, closed, dashPen, fig.splits) : [{ pts, first: true, last: true }];
25627
+ const single = !!pen.dash && !!pen.doubleRoundCap && pen.dashCap === 2 && closed;
25628
+ const pieces = single ? dashPiecesSingle(fig.pts, pen) : pen.dash ? dashFigure(pts, closed, dashPen, fig.splits) : [{ pts, first: true, last: true }];
25230
25629
  const pieceClosed = !pen.dash && closed;
25231
25630
  for (const piece of pieces) {
25232
25631
  const pp = cleanPoints(
@@ -25269,8 +25668,13 @@ function widenFigures(figures, pen) {
25269
25668
  const f0 = frame(pp[1], pp[0]);
25270
25669
  const endCap = endCapOverride ?? (piece.last && !(pen.dash && closed) ? pen.endCap : pen.dashCap);
25271
25670
  const startCap = startCapOverride ?? (piece.first && !(pen.dash && closed) ? pen.startCap : pen.dashCap);
25272
- const capEnd = capPoints(pp[pp.length - 1], fEnd, o1, o2, endCap, h, pen.doubleRoundCap);
25273
- const capStart = capPoints(pp[0], f0, -o2, -o1, startCap, h, pen.doubleRoundCap);
25671
+ const gEnd = single ? gradientF32(pp[pp.length - 2], pp[pp.length - 1]) : null;
25672
+ const gStart = single ? gradientF32(pp[0], pp[1]) : null;
25673
+ const capEnd = gEnd ? singleCap(pp[pp.length - 1], gEnd, o1, o2, false) : capPoints(pp[pp.length - 1], fEnd, o1, o2, endCap, h, pen.doubleRoundCap);
25674
+ const capStart = gStart ? singleCap(pp[0], gStart, o1, o2, true) : capPoints(pp[0], f0, -o2, -o1, startCap, h, pen.doubleRoundCap);
25675
+ if (gStart) {
25676
+ left[0] = offsetPointF32(pp[0], gStart, o2);
25677
+ }
25274
25678
  if (endCap === 0 && capEnd.length === 2 && left.length > 2 && right.length > 2) {
25275
25679
  const behind = (c2, q) => (c2.x - q.x) * fEnd.ux + (c2.y - q.y) * fEnd.uy < -1e-9;
25276
25680
  const lq = left[left.length - 2];
@@ -25347,15 +25751,15 @@ function parseCustomLineCap(view, off, size) {
25347
25751
  }
25348
25752
  const type = view.getInt32(off + 4, true);
25349
25753
  const d = off + 8;
25350
- const f = (k) => view.getFloat32(d + k, true);
25754
+ const f2 = (k) => view.getFloat32(d + k, true);
25351
25755
  const u = (k) => view.getUint32(d + k, true);
25352
25756
  if (type === 1) {
25353
25757
  if (d + 52 > end) {
25354
25758
  return null;
25355
25759
  }
25356
- const width = f(0);
25357
- const height = f(4);
25358
- const middleInset = f(8);
25760
+ const width = f2(0);
25761
+ const height = f2(4);
25762
+ const middleInset = f2(8);
25359
25763
  const filled = u(12) !== 0;
25360
25764
  const path = arrowCapPath(width, height, middleInset, filled);
25361
25765
  const length = capPathLength(path.points, path.types);
@@ -25367,8 +25771,8 @@ function parseCustomLineCap(view, off, size) {
25367
25771
  strokeStartCap: u(16),
25368
25772
  strokeEndCap: u(20),
25369
25773
  strokeJoin: u(24),
25370
- strokeMiterLimit: f(28),
25371
- widthScale: f(32),
25774
+ strokeMiterLimit: f2(28),
25775
+ widthScale: f2(32),
25372
25776
  fillPath: filled ? path : null,
25373
25777
  linePath: filled ? null : path,
25374
25778
  fillLength: filled ? length : 0,
@@ -25400,12 +25804,12 @@ function parseCustomLineCap(view, off, size) {
25400
25804
  kind: "plus-customlinecap",
25401
25805
  capType: 0,
25402
25806
  baseCap: u(4),
25403
- baseInset: f(8),
25807
+ baseInset: f2(8),
25404
25808
  strokeStartCap: u(12),
25405
25809
  strokeEndCap: u(16),
25406
25810
  strokeJoin: u(20),
25407
- strokeMiterLimit: f(24),
25408
- widthScale: f(28),
25811
+ strokeMiterLimit: f2(24),
25812
+ widthScale: f2(28),
25409
25813
  fillPath,
25410
25814
  linePath,
25411
25815
  fillLength: fillPath ? capPathLength(fillPath.points, fillPath.types) : 0,
@@ -25534,7 +25938,7 @@ function capFigures(path, closeAll) {
25534
25938
  }
25535
25939
  }
25536
25940
  }, [1, 0, 0, 1, 0, 0]);
25537
- return closeAll ? figures.map((f) => ({ ...f, closed: true })) : figures;
25941
+ return closeAll ? figures.map((f2) => ({ ...f2, closed: true })) : figures;
25538
25942
  }
25539
25943
  function customCapGeometry(figures, width, start, end, options2 = {}) {
25540
25944
  const out = [];
@@ -25581,10 +25985,10 @@ function customCapGeometry(figures, width, start, end, options2 = {}) {
25581
25985
  const origin = atEnd ? last : first;
25582
25986
  if (fill2) {
25583
25987
  const placed = placeCapPath(path, origin, dir, Math.max(scale, minFill));
25584
- for (const f of capFigures(placed, true)) {
25988
+ for (const f2 of capFigures(placed, true)) {
25585
25989
  const poly = [];
25586
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
25587
- poly.push({ x: f.pts[i], y: f.pts[i + 1] });
25990
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
25991
+ poly.push({ x: f2.pts[i], y: f2.pts[i + 1] });
25588
25992
  }
25589
25993
  polygons.push(poly);
25590
25994
  }
@@ -26183,9 +26587,9 @@ function writeTextureColorAt(cu, cv, width, height, rgba, wrap, out, o) {
26183
26587
  out[o + 3] = a;
26184
26588
  }
26185
26589
  function invertTextureMatrix(m, halfPixel2 = false) {
26186
- const [a, b, c, d, e, f] = [m[0], m[1], m[2], m[3], m[4], m[5]].map(Math.fround);
26590
+ const [a, b, c, d, e, f2] = [m[0], m[1], m[2], m[3], m[4], m[5]].map(Math.fround);
26187
26591
  const ex = halfPixel2 ? down32(down32(down32(down32(0.5 * a) + down32(0.5 * c)) + e) - 0.5) : e;
26188
- const fy = halfPixel2 ? down32(down32(down32(down32(0.5 * b) + down32(0.5 * d)) + f) - 0.5) : f;
26592
+ const fy = halfPixel2 ? down32(down32(down32(down32(0.5 * b) + down32(0.5 * d)) + f2) - 0.5) : f2;
26189
26593
  const det = down32(down32(a * d) - down32(b * c));
26190
26594
  if (!Number.isFinite(det) || det === 0) {
26191
26595
  return null;
@@ -26234,10 +26638,10 @@ function textureRowPositions(inv3, x0, y, us, vs, count = us.length) {
26234
26638
  if (count <= 0) {
26235
26639
  return;
26236
26640
  }
26237
- const [a, b, c, d, e, f] = inv3;
26641
+ const [a, b, c, d, e, f2] = inv3;
26238
26642
  const at = (x) => [
26239
26643
  down32(down32(down32(a * x) + down32(c * y)) + e),
26240
- down32(down32(down32(b * x) + down32(d * y)) + f)
26644
+ down32(down32(down32(b * x) + down32(d * y)) + f2)
26241
26645
  ];
26242
26646
  const [us0, vs0] = at(x0);
26243
26647
  const [us1, vs1] = at(x0 + count);
@@ -26304,16 +26708,16 @@ function addDown(a, b) {
26304
26708
  const r = down32(s);
26305
26709
  return Math.fround(s) === s && err < 0 ? prevF322(s) : r;
26306
26710
  }
26307
- var sub2 = (a, b) => addDown(a, -b);
26308
- var mul3 = (a, b) => down32(a * b);
26309
- function div2(a, b) {
26711
+ var sub3 = (a, b) => addDown(a, -b);
26712
+ var mul4 = (a, b) => down32(a * b);
26713
+ function div3(a, b) {
26310
26714
  let c = down32(a / b);
26311
26715
  if (b > 0 ? c * b > a : c * b < a) c = prevF322(c);
26312
26716
  return c;
26313
26717
  }
26314
26718
  var COMPLEXITY_TOLERANCE = 596046448e-12;
26315
26719
  function matrixComplexity(m) {
26316
- const [a, b, c, d, e, f] = m;
26720
+ const [a, b, c, d, e, f2] = m;
26317
26721
  const absA = Math.abs(a);
26318
26722
  const absD = Math.abs(d);
26319
26723
  const absB = Math.abs(b);
@@ -26327,11 +26731,11 @@ function matrixComplexity(m) {
26327
26731
  let flags = 15;
26328
26732
  if (tolerance > absB && tolerance > absC) {
26329
26733
  flags = 3;
26330
- if (COMPLEXITY_TOLERANCE > Math.abs(sub2(a, 1)) && COMPLEXITY_TOLERANCE > Math.abs(sub2(d, 1))) flags = 1;
26331
- } else if (tolerance > Math.abs(sub2(a, d)) && tolerance > Math.abs(addDown(c, b))) {
26332
- flags = COMPLEXITY_TOLERANCE > Math.abs(sub2(addDown(mul3(b, b), mul3(a, a)), 1)) ? 5 : 7;
26734
+ if (COMPLEXITY_TOLERANCE > Math.abs(sub3(a, 1)) && COMPLEXITY_TOLERANCE > Math.abs(sub3(d, 1))) flags = 1;
26735
+ } else if (tolerance > Math.abs(sub3(a, d)) && tolerance > Math.abs(addDown(c, b))) {
26736
+ flags = COMPLEXITY_TOLERANCE > Math.abs(sub3(addDown(mul4(b, b), mul4(a, a)), 1)) ? 5 : 7;
26333
26737
  }
26334
- if (e === 0 && f === 0) flags &= -2;
26738
+ if (e === 0 && f2 === 0) flags &= -2;
26335
26739
  return flags;
26336
26740
  }
26337
26741
  function inferPointsMatrix(points, src) {
@@ -26339,32 +26743,32 @@ function inferPointsMatrix(points, src) {
26339
26743
  const [x, y, w, h] = src;
26340
26744
  const nh = -h;
26341
26745
  const nw = -w;
26342
- const product = sub2(mul3(addDown(w, x), addDown(y, h)), mul3(y, x));
26343
- const det = addDown(product, sub2(mul3(nh, x), mul3(y, w)));
26746
+ const product = sub3(mul4(addDown(w, x), addDown(y, h)), mul4(y, x));
26747
+ const det = addDown(product, sub3(mul4(nh, x), mul4(y, w)));
26344
26748
  if (!(Math.abs(det) >= 11920929e-14)) return null;
26345
- const r = div2(1, det);
26346
- const a = mul3(addDown(mul3(h, x1), mul3(nh, x0)), r);
26347
- const b = mul3(addDown(mul3(h, y1), mul3(nh, y0)), r);
26348
- const c = mul3(addDown(mul3(w, x2), mul3(nw, x0)), r);
26349
- const d = mul3(addDown(mul3(w, y2), mul3(nw, y0)), r);
26350
- const nxh = mul3(-x, h);
26351
- const nyw = mul3(-y, w);
26352
- const p = sub2(mul3(addDown(x, w), addDown(y, h)), mul3(x, y));
26353
- const e = mul3(addDown(addDown(mul3(nxh, x1), mul3(p, x0)), mul3(nyw, x2)), r);
26354
- const f = mul3(addDown(addDown(mul3(nxh, y1), mul3(p, y0)), mul3(nyw, y2)), r);
26355
- return [a, b, c, d, e, f];
26749
+ const r = div3(1, det);
26750
+ const a = mul4(addDown(mul4(h, x1), mul4(nh, x0)), r);
26751
+ const b = mul4(addDown(mul4(h, y1), mul4(nh, y0)), r);
26752
+ const c = mul4(addDown(mul4(w, x2), mul4(nw, x0)), r);
26753
+ const d = mul4(addDown(mul4(w, y2), mul4(nw, y0)), r);
26754
+ const nxh = mul4(-x, h);
26755
+ const nyw = mul4(-y, w);
26756
+ const p = sub3(mul4(addDown(x, w), addDown(y, h)), mul4(x, y));
26757
+ const e = mul4(addDown(addDown(mul4(nxh, x1), mul4(p, x0)), mul4(nyw, x2)), r);
26758
+ const f2 = mul4(addDown(addDown(mul4(nxh, y1), mul4(p, y0)), mul4(nyw, y2)), r);
26759
+ return [a, b, c, d, e, f2];
26356
26760
  }
26357
26761
  function transformPoints(m, pts) {
26358
26762
  const complexity = matrixComplexity(m);
26359
- const [a, b, c, d, e, f] = m;
26763
+ const [a, b, c, d, e, f2] = m;
26360
26764
  const out = [];
26361
26765
  for (let i = 0; i < pts.length; i += 2) {
26362
26766
  const x = pts[i];
26363
26767
  const y = pts[i + 1];
26364
26768
  if (complexity === 0) out.push(x, y);
26365
- else if ((complexity & -2) === 0) out.push(addDown(e, x), addDown(f, y));
26366
- else if ((complexity & -4) === 0) out.push(addDown(mul3(a, x), e), addDown(mul3(d, y), f));
26367
- else out.push(addDown(addDown(mul3(x, a), mul3(y, c)), e), addDown(addDown(mul3(x, b), mul3(y, d)), f));
26769
+ else if ((complexity & -2) === 0) out.push(addDown(e, x), addDown(f2, y));
26770
+ else if ((complexity & -4) === 0) out.push(addDown(mul4(a, x), e), addDown(mul4(d, y), f2));
26771
+ else out.push(addDown(addDown(mul4(x, a), mul4(y, c)), e), addDown(addDown(mul4(x, b), mul4(y, d)), f2));
26368
26772
  }
26369
26773
  return out;
26370
26774
  }
@@ -26375,15 +26779,15 @@ function driverPoints(points, src) {
26375
26779
  return transformPoints(m, [x, y, addDown(x, w), y, x, addDown(y, h)]);
26376
26780
  }
26377
26781
  function multiplyDown(n, w) {
26378
- const [a, b, c, d, e, f] = n;
26782
+ const [a, b, c, d, e, f2] = n;
26379
26783
  const [wa, wb, wc, wd, we, wf] = w;
26380
26784
  return [
26381
- addDown(mul3(a, wa), mul3(b, wc)),
26382
- addDown(mul3(a, wb), mul3(b, wd)),
26383
- addDown(mul3(c, wa), mul3(d, wc)),
26384
- addDown(mul3(c, wb), mul3(d, wd)),
26385
- addDown(addDown(mul3(e, wa), mul3(f, wc)), we),
26386
- addDown(addDown(mul3(e, wb), mul3(f, wd)), wf)
26785
+ addDown(mul4(a, wa), mul4(b, wc)),
26786
+ addDown(mul4(a, wb), mul4(b, wd)),
26787
+ addDown(mul4(c, wa), mul4(d, wc)),
26788
+ addDown(mul4(c, wb), mul4(d, wd)),
26789
+ addDown(addDown(mul4(e, wa), mul4(f2, wc)), we),
26790
+ addDown(addDown(mul4(e, wb), mul4(f2, wd)), wf)
26387
26791
  ];
26388
26792
  }
26389
26793
  function drawImagePointsDeviceMatrix(points, src, world) {
@@ -26393,32 +26797,32 @@ function drawImagePointsDeviceMatrix(points, src, world) {
26393
26797
  return n ? multiplyDown(n, world) : null;
26394
26798
  }
26395
26799
  function invertDown(m) {
26396
- const [a, b, c, d, e, f] = m;
26397
- const det = sub2(mul3(a, d), mul3(b, c));
26800
+ const [a, b, c, d, e, f2] = m;
26801
+ const det = sub3(mul4(a, d), mul4(b, c));
26398
26802
  if (!Number.isFinite(det) || det === 0) return null;
26399
- const r = div2(1, det);
26803
+ const r = div3(1, det);
26400
26804
  return [
26401
- mul3(d, r),
26402
- mul3(-b, r),
26403
- mul3(-c, r),
26404
- mul3(a, r),
26405
- mul3(sub2(mul3(c, f), mul3(d, e)), r),
26406
- mul3(sub2(mul3(b, e), mul3(a, f)), r)
26805
+ mul4(d, r),
26806
+ mul4(-b, r),
26807
+ mul4(-c, r),
26808
+ mul4(a, r),
26809
+ mul4(sub3(mul4(c, f2), mul4(d, e)), r),
26810
+ mul4(sub3(mul4(b, e), mul4(a, f2)), r)
26407
26811
  ];
26408
26812
  }
26409
26813
  function spanPositions(inv3, x0, y, n, us, vs) {
26410
- const [a, b, c, d, e, f] = inv3;
26814
+ const [a, b, c, d, e, f2] = inv3;
26411
26815
  const complexity = matrixComplexity(inv3);
26412
26816
  const at = (x) => {
26413
26817
  if (complexity === 0) return [x, y];
26414
- if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f)];
26415
- if ((complexity & -4) === 0) return [addDown(mul3(x, a), e), addDown(mul3(y, d), f)];
26416
- return [addDown(addDown(mul3(a, x), mul3(c, y)), e), addDown(addDown(mul3(b, x), mul3(d, y)), f)];
26818
+ if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f2)];
26819
+ if ((complexity & -4) === 0) return [addDown(mul4(x, a), e), addDown(mul4(y, d), f2)];
26820
+ return [addDown(addDown(mul4(a, x), mul4(c, y)), e), addDown(addDown(mul4(b, x), mul4(d, y)), f2)];
26417
26821
  };
26418
26822
  const [u0, v0] = at(x0);
26419
26823
  const [u1, v1] = at(x0 + n);
26420
- const su = div2(sub2(u1, u0), n);
26421
- const sv = div2(sub2(v1, v0), n);
26824
+ const su = div3(sub3(u1, u0), n);
26825
+ const sv = div3(sub3(v1, v0), n);
26422
26826
  let u = u0;
26423
26827
  let v = v0;
26424
26828
  for (let i = 0; i < n; i++) {
@@ -26428,6 +26832,62 @@ function spanPositions(inv3, x0, y, n, us, vs) {
26428
26832
  v = addDown(v, sv);
26429
26833
  }
26430
26834
  }
26835
+ function bicubicSpanPositions(inv3, x0, y, n, us, vs) {
26836
+ const [a, b, c, d, e, f2] = inv3;
26837
+ const complexity = matrixComplexity(inv3);
26838
+ const at = (x) => {
26839
+ if (complexity === 0) return [x, y];
26840
+ if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f2)];
26841
+ if ((complexity & -4) === 0) return [addDown(mul4(x, a), e), addDown(mul4(y, d), f2)];
26842
+ return [addDown(addDown(mul4(a, x), mul4(c, y)), e), addDown(addDown(mul4(b, x), mul4(d, y)), f2)];
26843
+ };
26844
+ const [u0, v0] = at(x0);
26845
+ const [u1, v1] = at(x0 + n);
26846
+ const fix = (p) => {
26847
+ const r = Math.floor(addDown(mul4(p, 65536), 0.5));
26848
+ return r >= -2147483648 && r <= 2147483647 ? r : -2147483648;
26849
+ };
26850
+ const stepOf = (p0, p1) => fix2(div3(mul4(sub3(p1, p0), 65536), n));
26851
+ const fix2 = (q) => {
26852
+ const r = Math.floor(addDown(q, 0.5));
26853
+ return r >= -2147483648 && r <= 2147483647 ? r : -2147483648;
26854
+ };
26855
+ let u = fix(u0);
26856
+ let v = fix(v0);
26857
+ const su = stepOf(u0, u1);
26858
+ const sv = stepOf(v0, v1);
26859
+ for (let i = 0; i < n; i++) {
26860
+ us[i] = u;
26861
+ vs[i] = v;
26862
+ u = u + su | 0;
26863
+ v = v + sv | 0;
26864
+ }
26865
+ }
26866
+ function rectFormPoints(src, dest) {
26867
+ const [sx, sy, sw, sh] = src.map(Math.fround);
26868
+ const [dx, dy, dw, dh] = dest.map(Math.fround);
26869
+ const sxr = addDown(sx, sw);
26870
+ const syb = addDown(sy, sh);
26871
+ const dxr = addDown(dx, dw);
26872
+ const dyb = addDown(dy, dh);
26873
+ if (sx === sxr || sy === syb) return null;
26874
+ const m11 = div3(sub3(dxr, dx), sub3(sxr, sx));
26875
+ const m22 = div3(sub3(dyb, dy), sub3(syb, sy));
26876
+ const e = sub3(dxr, mul4(m11, sxr));
26877
+ const f2 = sub3(dyb, mul4(m22, syb));
26878
+ return transformPoints([m11, 0, 0, m22, e, f2], [sx, sy, sxr, sy, sx, syb]);
26879
+ }
26880
+ function deviceDestRect(device, src) {
26881
+ const [sx, sy, sw, sh] = src.map(Math.fround);
26882
+ const p = transformPoints(device, [sx, sy, addDown(sx, sw), addDown(sy, sh)]);
26883
+ return [p[0], p[1], sub3(p[2], p[0]), sub3(p[3], p[1])];
26884
+ }
26885
+ function rectFormDeviceMatrix(src, dest, world) {
26886
+ const pts = rectFormPoints(src, dest);
26887
+ if (!pts) return null;
26888
+ const n = inferPointsMatrix(pts, src);
26889
+ return n ? multiplyDown(n, world) : null;
26890
+ }
26431
26891
 
26432
26892
  // src/emf-plus-hq-cubic-weights.ts
26433
26893
  var HQ_CUBIC_HALF_TABLE = [
@@ -26529,6 +26989,270 @@ function hqCubicCdf(m) {
26529
26989
  return HQ_CUBIC_CDF[m + 256];
26530
26990
  }
26531
26991
 
26992
+ // src/gdiplus-span-stretch.ts
26993
+ var TWO_POW_M16 = 1 / 65536;
26994
+ function tentTable(n) {
26995
+ if (n <= -128) return 0;
26996
+ if (n >= 128) return 65536;
26997
+ return 32768 + (n < 0 ? -(512 * -n - 2 * n * n) : 512 * n - 2 * n * n);
26998
+ }
26999
+ function cubicTable(n) {
27000
+ if (n < -256) return 0;
27001
+ if (n > 255) return 65536;
27002
+ return 32768 + hqCubicCdf(n);
27003
+ }
27004
+ var i32 = (v) => v | 0;
27005
+ var mulShift16 = (a, b) => Math.floor(a * b / 65536);
27006
+ function validFixed16(v) {
27007
+ return v >= -32768 && v <= 32767;
27008
+ }
27009
+ function createStretch(request) {
27010
+ const [sx, sy, sw, sh] = request.src.map(Math.fround);
27011
+ const [dx, dy, dw, dh] = request.dest.map(Math.fround);
27012
+ if (![sx, sy, sw, sh, dx, dy, dw, dh].every(validFixed16)) return null;
27013
+ const kScale = request.kernel === "cubic" ? 2 : 1;
27014
+ const minStretch = request.kernel === "cubic" ? 131072 : 65536;
27015
+ const half = 0.5;
27016
+ const fix = (v2) => floorInt(add(mul(v2, 65536), half));
27017
+ const xStepS = fix(div(sw, dw));
27018
+ fix(div(dw, sw));
27019
+ const yStepS = fix(div(sh, dh));
27020
+ fix(div(dh, sh));
27021
+ if (xStepS === 0 || yStepS === 0) return null;
27022
+ const grid = (v2) => floorInt(add(mul(v2, 16), half));
27023
+ const left = grid(dx);
27024
+ const right = grid(add(mul(sw, div(dw, sw)), dx));
27025
+ const top = grid(dy);
27026
+ const bottom = grid(add(mul(sh, div(dh, sh)), dy));
27027
+ const lo = Math.min(left, right);
27028
+ const hi = Math.max(left, right);
27029
+ const topLo = Math.min(top, bottom);
27030
+ const botHi = Math.max(top, bottom);
27031
+ const firstColumn = lo + 15 >> 4;
27032
+ const loFix = i32(lo << 12);
27033
+ const hiFix = i32(hi << 12);
27034
+ const topFix = i32(topLo << 12);
27035
+ const botFix = i32(botHi << 12);
27036
+ const floatOf = (v2) => down32(v2);
27037
+ const sxF = floatOf(xStepS);
27038
+ let xBase;
27039
+ let xEdge;
27040
+ if (xStepS < 0) {
27041
+ xBase = floatOf(hiFix + 65535 >> 16);
27042
+ xEdge = add(dx, dw);
27043
+ } else {
27044
+ xBase = floatOf(loFix >> 16);
27045
+ xEdge = dx;
27046
+ }
27047
+ let v = sub(xEdge, xBase);
27048
+ v = mul(v, sxF);
27049
+ v = mul(v, TWO_POW_M16);
27050
+ v = add(v, sx);
27051
+ const xStart = fix(v);
27052
+ const stretchOf = (s, d) => {
27053
+ let r = fix(div(mul(kScale, s), d));
27054
+ if (r < 0) r = -r;
27055
+ return r < minStretch ? minStretch : r;
27056
+ };
27057
+ const xStretch = stretchOf(sw, dw);
27058
+ const xRecip = floorInt(add(mul(div(65536, floatOf(xStretch)), 65536), half));
27059
+ const syF = floatOf(yStepS);
27060
+ let yStart;
27061
+ if (yStepS < 0) {
27062
+ let w = floatOf(botFix + 65535 >> 16);
27063
+ w = sub(w, add(dh, dy));
27064
+ w = mul(w, syF);
27065
+ w = mul(w, TWO_POW_M16);
27066
+ yStart = fix(sub(sy, w));
27067
+ } else {
27068
+ let w = floatOf(topFix >> 16);
27069
+ w = sub(w, dy);
27070
+ w = mul(w, syF);
27071
+ w = mul(w, TWO_POW_M16);
27072
+ yStart = fix(add(w, sy));
27073
+ }
27074
+ const yStretch = stretchOf(sh, dh);
27075
+ const yRecip = floorInt(add(mul(div(65536, floatOf(yStretch)), 65536), half));
27076
+ const firstRow = topFix >> 16;
27077
+ const columns = (hiFix + 65535 >> 16) - (loFix >> 16) + 1;
27078
+ const kernelRows = 2 * (yStretch + 65535 >> 16) + 1;
27079
+ const range = (stretch, start) => {
27080
+ const r = start - 32768;
27081
+ return r >= -2147483648 && r <= 2147483647 && r - stretch >= -2147483648 && r + stretch <= 2147483647;
27082
+ };
27083
+ if (!range(xStretch, xStart) || !range(yStretch, yStart)) return null;
27084
+ return {
27085
+ request,
27086
+ firstColumn,
27087
+ columns,
27088
+ firstRow,
27089
+ xStart,
27090
+ xStep: xStepS,
27091
+ xStretch,
27092
+ xRecip,
27093
+ yStart,
27094
+ yStep: yStepS,
27095
+ yStretch,
27096
+ yRecip,
27097
+ kernelRows,
27098
+ table: request.kernel === "cubic" ? cubicTable : tentTable,
27099
+ shift: request.kernel === "cubic" ? 8 : 9,
27100
+ rows: /* @__PURE__ */ new Map()
27101
+ };
27102
+ }
27103
+ function wrapIndex2(index, size, mirror2) {
27104
+ if (!mirror2) {
27105
+ return (index % size + size) % size;
27106
+ }
27107
+ const q = (index % size + size) % size;
27108
+ return Math.floor(index / size) % 2 !== 0 ? size - q - 1 : q;
27109
+ }
27110
+ function clampBytes(argb) {
27111
+ return [argb >>> 16 & 255, argb >>> 8 & 255, argb & 255, argb >>> 24];
27112
+ }
27113
+ function stretchRow(state, rowPixels) {
27114
+ const { request, columns, xStart, xStep, xStretch, xRecip, table: table2, shift } = state;
27115
+ const { width, wrap = 4, clampArgb = 0 } = request;
27116
+ const cubic = request.kernel === "cubic";
27117
+ const out = new Uint8Array(columns * 4);
27118
+ const clamp2 = clampBytes(clampArgb);
27119
+ const mirrorX = wrap === 1 || wrap === 3;
27120
+ let pos = i32(xStart - 32768);
27121
+ const sum = [0, 0, 0, 0];
27122
+ for (let c = 0; c < columns; c++) {
27123
+ const edx = i32(xStretch + 65535 + pos);
27124
+ const last = edx >> 16;
27125
+ const first = i32(edx - 2 * xStretch) >> 16;
27126
+ sum[0] = sum[1] = sum[2] = sum[3] = 0;
27127
+ let prev = 0;
27128
+ const accumulate = (idx2, pixel, o2) => {
27129
+ const t = table2(i32(idx2) >> shift);
27130
+ const wgt = t - prev;
27131
+ prev = t;
27132
+ sum[0] += pixel[o2] * wgt;
27133
+ sum[1] += pixel[o2 + 1] * wgt;
27134
+ sum[2] += pixel[o2 + 2] * wgt;
27135
+ sum[3] += pixel[o2 + 3] * wgt;
27136
+ };
27137
+ const startOf = (col) => mulShift16(i32(i32(col << 16) - pos), xRecip);
27138
+ const inFirst = first < 0 ? 0 : first;
27139
+ const inLast = last < width - 1 ? last : width - 1;
27140
+ let idx = startOf(first);
27141
+ for (let t = first; t < Math.min(inFirst, last + 1); t++) {
27142
+ if (wrap === 4 || !rowPixels) accumulate(idx, clamp2, 0);
27143
+ else accumulate(idx, rowPixels, wrapIndex2(t, width, mirrorX) * 4);
27144
+ idx = i32(idx + xRecip);
27145
+ }
27146
+ if (inFirst <= inLast) {
27147
+ idx = startOf(inFirst);
27148
+ for (let t = inFirst; t <= inLast; t++) {
27149
+ if (rowPixels) accumulate(idx, rowPixels, t * 4);
27150
+ else accumulate(idx, clamp2, 0);
27151
+ idx = i32(idx + xRecip);
27152
+ }
27153
+ }
27154
+ const rightFirst = Math.max(inLast + 1, first);
27155
+ if (rightFirst <= last) {
27156
+ idx = startOf(rightFirst);
27157
+ for (let t = rightFirst; t <= last; t++) {
27158
+ if (wrap === 4 || !rowPixels) accumulate(idx, clamp2, 0);
27159
+ else accumulate(idx, rowPixels, wrapIndex2(t, width, mirrorX) * 4);
27160
+ idx = i32(idx + xRecip);
27161
+ }
27162
+ }
27163
+ const o = c * 4;
27164
+ const a = Math.max(0, Math.min(255, sum[3] + 32768 >> 16));
27165
+ out[o + 3] = a;
27166
+ for (let ch = 0; ch < 3; ch++) {
27167
+ const v = sum[ch] + 32768 >> 16;
27168
+ out[o + ch] = cubic ? Math.max(0, Math.min(a, v)) : Math.min(255, v);
27169
+ }
27170
+ pos = i32(pos + xStep);
27171
+ }
27172
+ return out;
27173
+ }
27174
+ function stretchedRow(state, row2) {
27175
+ const { request } = state;
27176
+ const { height, width, wrap = 4 } = request;
27177
+ let r = row2;
27178
+ if (r < 0 || r >= height) {
27179
+ if (wrap === 4) {
27180
+ return null;
27181
+ }
27182
+ r = wrapIndex2(r, height, wrap === 2 || wrap === 3);
27183
+ }
27184
+ let cached = state.rows.get(r);
27185
+ if (!cached) {
27186
+ const pixels = request.pixels instanceof Uint8Array || request.pixels instanceof Uint8ClampedArray ? request.pixels.subarray(r * width * 4, (r + 1) * width * 4) : Uint8Array.from(Array.prototype.slice.call(request.pixels, r * width * 4, (r + 1) * width * 4));
27187
+ cached = stretchRow(state, pixels);
27188
+ state.rows.set(r, cached);
27189
+ }
27190
+ return cached;
27191
+ }
27192
+ function clampRow(state) {
27193
+ let cached = state.rows.get(Number.NaN);
27194
+ if (!cached) {
27195
+ cached = stretchRow(state, null);
27196
+ state.rows.set(Number.NaN, cached);
27197
+ }
27198
+ return cached;
27199
+ }
27200
+ function stretchRun(state, y, xLeft, xRight) {
27201
+ const { firstColumn, columns, firstRow, yStart, yStep, yStretch, yRecip, kernelRows, table: table2, shift } = state;
27202
+ const xs = Math.max(xLeft, firstColumn);
27203
+ const xe = Math.min(xRight, firstColumn + columns);
27204
+ if (xe < xs || xe - xs > columns) return null;
27205
+ const n = xe - xs;
27206
+ const row2 = Math.max(y, firstRow);
27207
+ const pos = i32(yStart - 32768 + i32((row2 - firstRow) * yStep));
27208
+ const lastSource = i32(pos + yStretch + 65535) >> 16;
27209
+ const firstSource = i32(pos - yStretch + 65535) >> 16;
27210
+ if (lastSource < firstSource) return null;
27211
+ let idx = mulShift16(i32(i32(firstSource << 16) - pos), yRecip);
27212
+ let prev = 0;
27213
+ const sources = [];
27214
+ const weights = [];
27215
+ for (let k = 0; k < kernelRows; k++) {
27216
+ const source = firstSource + k;
27217
+ if (source > lastSource) {
27218
+ weights.push(0);
27219
+ sources.push(null);
27220
+ continue;
27221
+ }
27222
+ const t = table2(i32(idx) >> shift);
27223
+ weights.push(t - prev);
27224
+ prev = t;
27225
+ idx = i32(idx + yRecip);
27226
+ sources.push(source >= 0 && source < state.request.height ? stretchedRow(state, source) : state.request.wrap === 4 || state.request.wrap === void 0 ? clampRow(state) : stretchedRow(state, source));
27227
+ }
27228
+ const cubic = state.request.kernel === "cubic";
27229
+ const pixels = new Uint8Array(n * 4);
27230
+ for (let i = 0; i < n; i++) {
27231
+ const col = (xs - firstColumn + i) * 4;
27232
+ let r = 0;
27233
+ let g = 0;
27234
+ let b = 0;
27235
+ let a = 0;
27236
+ for (let k = 0; k < kernelRows; k++) {
27237
+ const src = sources[k];
27238
+ if (!src) continue;
27239
+ const wgt = weights[k];
27240
+ r += src[col] * wgt;
27241
+ g += src[col + 1] * wgt;
27242
+ b += src[col + 2] * wgt;
27243
+ a += src[col + 3] * wgt;
27244
+ }
27245
+ const o = i * 4;
27246
+ const alpha = Math.max(0, Math.min(255, a + 32768 >> 16));
27247
+ pixels[o + 3] = alpha;
27248
+ for (const [ch, v] of [[0, r], [1, g], [2, b]]) {
27249
+ const q = v + 32768 >> 16;
27250
+ pixels[o + ch] = cubic ? Math.max(0, Math.min(alpha, q)) : Math.min(255, q);
27251
+ }
27252
+ }
27253
+ return { x: xs, pixels };
27254
+ }
27255
+
26532
27256
  // src/emf-plus-image-resample.ts
26533
27257
  var INTERPOLATION_KERNELS = {
26534
27258
  0: "bilinear",
@@ -26630,11 +27354,11 @@ function nearSourceExtent(deviceLen, srcLen) {
26630
27354
  return d >= -1 && d <= 1;
26631
27355
  }
26632
27356
  function unitCopyOffset(t, other, spec) {
26633
- const f = t - Math.round(t);
26634
- if (f > -1 / 64 + 1e-9) {
26635
- return f <= 1 / 64 + 1e-9;
27357
+ const f2 = t - Math.round(t);
27358
+ if (f2 > -1 / 64 + 1e-9) {
27359
+ return f2 <= 1 / 64 + 1e-9;
26636
27360
  }
26637
- if (Math.abs(f + 1 / 64) > 1e-9 || !isPowerOfTwo(spec.srcW) || !isPowerOfTwo(spec.srcH)) {
27361
+ if (Math.abs(f2 + 1 / 64) > 1e-9 || !isPowerOfTwo(spec.srcW) || !isPowerOfTwo(spec.srcH)) {
26638
27362
  return false;
26639
27363
  }
26640
27364
  const g = (other - Math.round(other)) * 128;
@@ -26752,11 +27476,11 @@ function wrapTap(t, lo, hi, mirror2, edge) {
26752
27476
  return lo + (q < n ? q : 2 * n - 1 - q);
26753
27477
  }
26754
27478
  function mirroredOrigin(o) {
26755
- const f = o - Math.floor(o);
26756
- return f === 0 ? o : Math.floor(o) + 1 - f;
27479
+ const f2 = o - Math.floor(o);
27480
+ return f2 === 0 ? o : Math.floor(o) + 1 - f2;
26757
27481
  }
26758
27482
  function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26759
- const { plainRotated: plainRotatedPass = false, keepOrigin = false, premultSource = false, premultOut = false } = typeof options2 === "boolean" ? { plainRotated: options2 } : options2;
27483
+ const { plainRotated: plainRotatedPass = false, keepOrigin = false, premultSource = false, premultOut = false, rasterQuad, rasterHalf = false, chainPad = 0 } = typeof options2 === "boolean" ? { plainRotated: options2 } : options2;
26760
27484
  if (spec.rightHalo && spec.rightHalo.length === height * 4) {
26761
27485
  const grown = new Uint8ClampedArray((width + 1) * height * 4);
26762
27486
  for (let y = 0; y < height; y++) {
@@ -26839,7 +27563,7 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26839
27563
  if (!(w > 0 && h > 0) || w * h > MAX_RESAMPLE_PIXELS) {
26840
27564
  return null;
26841
27565
  }
26842
- const rasterCoverage = rasterCovered ? rasterizePlusFill(
27566
+ const rasterCoverage = rasterQuad ? rasterizePlusFill([rasterQuad], false, false, rasterHalf, { x: bx0, y: by0, w, h }) : rasterCovered ? rasterizePlusFill(
26843
27567
  [[
26844
27568
  [spec.srcX, spec.srcY],
26845
27569
  [spec.srcX + spec.srcW, spec.srcY],
@@ -26879,12 +27603,18 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26879
27603
  const bicubicDv = Math.round(inv3[1] * FIX16);
26880
27604
  const steppedInv = !plainRotatedPass && (kernel === "bilinear" || kernel === "bicubic" && !axisAligned) ? invertTextureMatrix(m) : null;
26881
27605
  let exactInv = null;
26882
- if (steppedInv && spec.pointsForm && spec.worldPoints && spec.worldMatrix && kernel === "bilinear" && axisAligned && !spec.halfPixelOffset && !spec.wrap) {
26883
- const device = drawImagePointsDeviceMatrix(spec.worldPoints, [spec.srcX, spec.srcY, spec.srcW, spec.srcH], spec.worldMatrix);
27606
+ if ((steppedInv || plainRotatedPass) && spec.pointsForm && spec.worldPoints && spec.worldMatrix && (kernel === "bilinear" || kernel === "bicubic") && !spec.halfPixelOffset && !spec.chainHalf && !spec.wrap) {
27607
+ const device = drawImagePointsDeviceMatrix(spec.worldPoints, spec.chainSrc ?? [spec.srcX, spec.srcY, spec.srcW, spec.srcH], spec.worldMatrix);
27608
+ exactInv = device && invertDown(device);
27609
+ } else if (plainRotatedPass && spec.chainHalf && spec.pointsForm && spec.worldPoints && spec.worldMatrix && spec.chainSrc && (kernel === "bilinear" || kernel === "bicubic")) {
27610
+ const w2 = spec.worldMatrix;
27611
+ const device = drawImagePointsDeviceMatrix(spec.worldPoints, spec.chainSrc, [w2[0], w2[1], w2[2], w2[3], down32(w2[4] - 0.5), down32(w2[5] - 0.5)]);
26884
27612
  exactInv = device && invertDown(device);
26885
27613
  }
26886
27614
  const runU = new Float64Array(w);
26887
27615
  const runV = new Float64Array(w);
27616
+ const fixU = new Int32Array(w);
27617
+ const fixV = new Int32Array(w);
26888
27618
  let runBase = 0;
26889
27619
  const covers = (px, py) => {
26890
27620
  const cx = px + COVERAGE_NUDGE_X;
@@ -26923,10 +27653,19 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26923
27653
  while (end < w && (rasterCoverage ? rasterCoverage[j * w + end] !== 0 : covers(bx0 + end + o, py))) {
26924
27654
  end++;
26925
27655
  }
26926
- spanPositions(exactInv, bx0 + i, by0 + j, end - i, runU, runV);
27656
+ if (integerBicubic) {
27657
+ bicubicSpanPositions(exactInv, bx0 + i, by0 + j, end - i, fixU, fixV);
27658
+ } else {
27659
+ spanPositions(exactInv, bx0 + i, by0 + j, end - i, runU, runV);
27660
+ }
27661
+ }
27662
+ if (integerBicubic) {
27663
+ u = (fixU[i - runBase] + chainPad * FIX16) / FIX16;
27664
+ v = (fixV[i - runBase] + chainPad * FIX16) / FIX16;
27665
+ } else {
27666
+ u = runU[i - runBase] + chainPad;
27667
+ v = runV[i - runBase] + chainPad;
26927
27668
  }
26928
- u = runU[i - runBase];
26929
- v = runV[i - runBase];
26930
27669
  } else if (steppedInv) {
26931
27670
  if (start < 0) {
26932
27671
  start = i;
@@ -26949,7 +27688,10 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26949
27688
  }
26950
27689
  }
26951
27690
  if (integerBicubic) {
26952
- if (steppedInv) {
27691
+ if (exactInv) {
27692
+ u = Math.floor(u * 64) / 64;
27693
+ v = Math.floor(v * 64) / 64;
27694
+ } else if (steppedInv) {
26953
27695
  u = Math.floor(u * 64) / 64;
26954
27696
  v = Math.floor(v * 64) / 64;
26955
27697
  } else {
@@ -27127,6 +27869,10 @@ function resampleHqAxisAligned(rgba, width, height, spec, surface, m, premultOut
27127
27869
  if (w * h > MAX_RESAMPLE_PIXELS) {
27128
27870
  return null;
27129
27871
  }
27872
+ const stretched = resampleHqStretch(rgba, width, height, spec, cx0, cy0, w, h, premultOut);
27873
+ if (stretched) {
27874
+ return stretched;
27875
+ }
27130
27876
  const cubic = kernel === "hq-bicubic";
27131
27877
  const bin = cubic ? 0.5 : 1;
27132
27878
  let stepU = hqStep(scaleU);
@@ -27306,7 +28052,71 @@ function resampleHqAxisAligned(rgba, width, height, spec, surface, m, premultOut
27306
28052
  }
27307
28053
  return { x: cx0, y: cy0, w, h, rgba: out, premultiplied: premultOut };
27308
28054
  }
27309
- function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel, near) {
28055
+ function resampleHqStretch(rgba, width, height, spec, x0, y0, w, h, premultOut) {
28056
+ const world = spec.worldMatrix;
28057
+ if (spec.halfPixelOffset || !world || spec.wrap || spec.srcX !== 0 || spec.srcY !== 0 || spec.srcW !== width || spec.srcH !== height) {
28058
+ return void 0;
28059
+ }
28060
+ const src = [spec.srcX, spec.srcY, spec.srcW, spec.srcH];
28061
+ const inferred = spec.worldRect ? null : spec.worldPoints ? inferPointsMatrix(spec.worldPoints, src) : null;
28062
+ const device = spec.worldRect ? rectFormDeviceMatrix(src, spec.worldRect, world) : inferred ? multiplyDown(inferred, world) : null;
28063
+ if (!device || !(device[0] > 0 && device[3] > 0)) {
28064
+ return void 0;
28065
+ }
28066
+ const dest = deviceDestRect(device, src);
28067
+ const premultiplied2 = new Uint8Array(width * height * 4);
28068
+ for (let i = 0; i < width * height * 4; i += 4) {
28069
+ const a = rgba[i + 3];
28070
+ premultiplied2[i] = Math.round(rgba[i] * a / 255);
28071
+ premultiplied2[i + 1] = Math.round(rgba[i + 1] * a / 255);
28072
+ premultiplied2[i + 2] = Math.round(rgba[i + 2] * a / 255);
28073
+ premultiplied2[i + 3] = a;
28074
+ }
28075
+ const state = createStretch({
28076
+ kernel: spec.kernel === "hq-bicubic" ? "cubic" : "tent",
28077
+ pixels: premultiplied2,
28078
+ width,
28079
+ height,
28080
+ src,
28081
+ dest
28082
+ });
28083
+ if (!state) {
28084
+ return void 0;
28085
+ }
28086
+ const out = new Uint8ClampedArray(w * h * 4);
28087
+ for (let j = 0; j < h; j++) {
28088
+ const run = stretchRun(state, y0 + j, x0, x0 + w);
28089
+ if (!run) {
28090
+ continue;
28091
+ }
28092
+ for (let i = 0; i < run.pixels.length / 4; i++) {
28093
+ const o = run.pixels.subarray(i * 4, i * 4 + 4);
28094
+ const alpha = o[3];
28095
+ if (alpha === 0) {
28096
+ continue;
28097
+ }
28098
+ const d = (j * w + run.x - x0 + i) * 4;
28099
+ const k = premultOut ? 1 : 255 / alpha;
28100
+ out[d] = o[0] * k;
28101
+ out[d + 1] = o[1] * k;
28102
+ out[d + 2] = o[2] * k;
28103
+ out[d + 3] = alpha;
28104
+ }
28105
+ }
28106
+ return { x: x0, y: y0, w, h, rgba: out, premultiplied: premultOut };
28107
+ }
28108
+ function deviceEdgeLengths(points, world) {
28109
+ const p = transformPoints(world, points);
28110
+ const length = (dx, dy) => Math.ceil(sqrt(addDown(mul(dy, dy), mul(dx, dx))));
28111
+ return [
28112
+ length(addDown(p[2], -p[0]), addDown(p[3], -p[1])),
28113
+ length(addDown(p[4], -p[0]), addDown(p[5], -p[1]))
28114
+ ];
28115
+ }
28116
+ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel, nearHint) {
28117
+ const chain = !!(spec.pointsForm && spec.worldPoints && spec.worldMatrix && !spec.wrap);
28118
+ const edges = chain ? deviceEdgeLengths(spec.worldPoints, spec.worldMatrix) : null;
28119
+ const near = edges ? Math.abs(edges[0] - spec.srcW) <= 1.0000001 || Math.abs(edges[1] - spec.srcH) <= 1.0000001 : nearHint;
27310
28120
  const pad = spec.wrap ? 0 : 2;
27311
28121
  let img;
27312
28122
  let pw;
@@ -27318,6 +28128,8 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27318
28128
  let ex;
27319
28129
  let ey;
27320
28130
  const half = spec.halfPixelOffset;
28131
+ let interW = 0;
28132
+ let interH = 0;
27321
28133
  if (near) {
27322
28134
  pw = width + 2 * pad;
27323
28135
  ph = height + 2 * pad;
@@ -27337,8 +28149,10 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27337
28149
  ex = m[4] - (half ? 0.5 : 0);
27338
28150
  ey = m[5] - (half ? 0.5 : 0);
27339
28151
  } else {
27340
- const W = ceilExtent(Math.hypot(m[0], m[1]) * spec.srcW);
27341
- const H = ceilExtent(Math.hypot(m[2], m[3]) * spec.srcH);
28152
+ const W = edges ? edges[0] : ceilExtent(Math.hypot(m[0], m[1]) * spec.srcW);
28153
+ const H = edges ? edges[1] : ceilExtent(Math.hypot(m[2], m[3]) * spec.srcH);
28154
+ interW = W;
28155
+ interH = H;
27342
28156
  const kx = W / spec.srcW;
27343
28157
  const ky = H / spec.srcH;
27344
28158
  const pre = resampleImage(rgba, width, height, {
@@ -27384,6 +28198,12 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27384
28198
  ex = half ? ox - 0.5 + 0.5 * (a + c) : ox;
27385
28199
  ey = half ? oy - 0.5 + 0.5 * (b + d) : oy;
27386
28200
  }
28201
+ const corners = [
28202
+ [spec.srcX, spec.srcY],
28203
+ [spec.srcX + spec.srcW, spec.srcY],
28204
+ [spec.srcX + spec.srcW, spec.srcY + spec.srcH],
28205
+ [spec.srcX, spec.srcY + spec.srcH]
28206
+ ].flatMap(([u, v]) => [toPlusFix(m[0] * u + m[2] * v + m[4]), toPlusFix(m[1] * u + m[3] * v + m[5])]);
27387
28207
  const block = resampleImage(img, pw, ph, {
27388
28208
  srcX: 0,
27389
28209
  srcY: 0,
@@ -27393,17 +28213,18 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27393
28213
  kernel: kernel === "hq-bicubic" ? "bicubic" : "bilinear",
27394
28214
  halfPixelOffset: false,
27395
28215
  wrap: spec.wrap,
27396
- clampArgb: spec.clampArgb
27397
- }, surface, { plainRotated: true, keepOrigin: true, premultSource: true });
28216
+ clampArgb: spec.clampArgb,
28217
+ ...chain ? {
28218
+ pointsForm: true,
28219
+ worldPoints: spec.worldPoints,
28220
+ worldMatrix: spec.worldMatrix,
28221
+ chainSrc: near ? [spec.srcX, spec.srcY, spec.srcW, spec.srcH] : [half ? -0.5 : 0, half ? -0.5 : 0, interW, interH],
28222
+ ...half ? { chainHalf: true } : {}
28223
+ } : {}
28224
+ }, surface, { plainRotated: true, keepOrigin: true, premultSource: true, ...chain ? { rasterQuad: corners, rasterHalf: half, chainPad: pad } : {} });
27398
28225
  if (!block) {
27399
28226
  return block;
27400
28227
  }
27401
- const corners = [
27402
- [spec.srcX, spec.srcY],
27403
- [spec.srcX + spec.srcW, spec.srcY],
27404
- [spec.srcX + spec.srcW, spec.srcY + spec.srcH],
27405
- [spec.srcX, spec.srcY + spec.srcH]
27406
- ].flatMap(([u, v]) => [toPlusFix(m[0] * u + m[2] * v + m[4]), toPlusFix(m[1] * u + m[3] * v + m[5])]);
27407
28228
  const coverage = rasterizePlusFill([corners], false, false, half, { x: block.x, y: block.y, w: block.w, h: block.h });
27408
28229
  for (let i = 0; i < block.w * block.h; i++) {
27409
28230
  if (!coverage[i]) {
@@ -28121,7 +28942,7 @@ function filterScanlines(input, width, height) {
28121
28942
  const stride = width * 4;
28122
28943
  const words = data.byteOffset % 4 === 0 ? new Uint32Array(data.buffer, data.byteOffset, width * height) : null;
28123
28944
  const out = new Uint8Array((stride + 1) * height);
28124
- const sub3 = new Uint8Array(stride);
28945
+ const sub4 = new Uint8Array(stride);
28125
28946
  const up = new Uint8Array(stride);
28126
28947
  const pae = new Uint8Array(stride);
28127
28948
  for (let y = 0; y < height; y++) {
@@ -28156,12 +28977,12 @@ function filterScanlines(input, width, height) {
28156
28977
  let upScore = 0;
28157
28978
  for (let i = 0; i < 4 && i < stride; i++) {
28158
28979
  const x = data[row2 + i];
28159
- sub3[i] = x;
28980
+ sub4[i] = x;
28160
28981
  subScore += x < 128 ? x : 256 - x;
28161
28982
  }
28162
28983
  for (let i = 4; i < stride; i++) {
28163
28984
  const v = data[row2 + i] - data[row2 + i - 4] & 255;
28164
- sub3[i] = v;
28985
+ sub4[i] = v;
28165
28986
  subScore += v < 128 ? v : 256 - v;
28166
28987
  }
28167
28988
  if (y > 0) {
@@ -28179,7 +29000,7 @@ function filterScanlines(input, width, height) {
28179
29000
  let bestScore = noneScore;
28180
29001
  if (subScore < bestScore) {
28181
29002
  bestScore = subScore;
28182
- best = sub3;
29003
+ best = sub4;
28183
29004
  code = 1;
28184
29005
  }
28185
29006
  if (upScore < bestScore) {
@@ -28435,7 +29256,7 @@ function svgTreeToJsx(node, options2 = {}) {
28435
29256
 
28436
29257
  // src/svg-context.ts
28437
29258
  var IDENTITY3 = [1, 0, 0, 1, 0, 0];
28438
- function mul4(m, n) {
29259
+ function mul5(m, n) {
28439
29260
  return [
28440
29261
  m[0] * n[0] + m[2] * n[1],
28441
29262
  m[1] * n[0] + m[3] * n[1],
@@ -28972,23 +29793,23 @@ var SvgContext = class {
28972
29793
  this.shadow?.restore();
28973
29794
  }
28974
29795
  getTransform() {
28975
- const [a, b, c, d, e, f] = this.state.transform;
28976
- return { a, b, c, d, e, f };
29796
+ const [a, b, c, d, e, f2] = this.state.transform;
29797
+ return { a, b, c, d, e, f: f2 };
28977
29798
  }
28978
- setTransform(a, b, c, d, e, f) {
28979
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
28980
- this.state.transform = [a, b, c, d, e, f];
29799
+ setTransform(a, b, c, d, e, f2) {
29800
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
29801
+ this.state.transform = [a, b, c, d, e, f2];
28981
29802
  }
28982
- this.shadow?.setTransform(a, b, c, d, e, f);
29803
+ this.shadow?.setTransform(a, b, c, d, e, f2);
28983
29804
  }
28984
29805
  resetTransform() {
28985
29806
  this.setTransform(1, 0, 0, 1, 0, 0);
28986
29807
  }
28987
- transform(a, b, c, d, e, f) {
28988
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
28989
- this.state.transform = mul4(this.state.transform, [a, b, c, d, e, f]);
29808
+ transform(a, b, c, d, e, f2) {
29809
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
29810
+ this.state.transform = mul5(this.state.transform, [a, b, c, d, e, f2]);
28990
29811
  }
28991
- this.shadow?.transform(a, b, c, d, e, f);
29812
+ this.shadow?.transform(a, b, c, d, e, f2);
28992
29813
  }
28993
29814
  translate(x, y) {
28994
29815
  this.transform(1, 0, 0, 1, x, y);
@@ -29168,7 +29989,7 @@ var SvgContext = class {
29168
29989
  return { tag: g.type === "linear" ? "linearGradient" : "radialGradient", attrs, children: stops };
29169
29990
  }
29170
29991
  patternNode(p, id, space) {
29171
- const m = mul4(space, p.matrix);
29992
+ const m = mul5(space, p.matrix);
29172
29993
  let spanU = p.width;
29173
29994
  let spanV = p.height;
29174
29995
  const im = inv(m);
@@ -29497,7 +30318,7 @@ var SvgContext = class {
29497
30318
  let m = run.matrix ? [...run.matrix] : null;
29498
30319
  if (run.scaleX && run.scaleX !== 1) {
29499
30320
  const s = [run.scaleX, 0, 0, 1, 0, 0];
29500
- m = m ? mul4(m, s) : s;
30321
+ m = m ? mul5(m, s) : s;
29501
30322
  attrs.x = run.xs.map((v) => fmt(v / run.scaleX)).join(" ");
29502
30323
  }
29503
30324
  if (m && !isIdentity(m)) {
@@ -29785,25 +30606,25 @@ function canReadBack(ctx) {
29785
30606
 
29786
30607
  // src/emf-plus-state-handlers.ts
29787
30608
  function rotateWorldTransform(m, degrees, append2) {
29788
- const f = down32;
29789
- const rad = f(Math.fround(degrees) * Math.fround(0.0174532924));
29790
- const s = f(Math.sin(rad));
29791
- const c = f(Math.cos(rad));
30609
+ const f2 = down32;
30610
+ const rad = f2(Math.fround(degrees) * Math.fround(0.0174532924));
30611
+ const s = f2(Math.sin(rad));
30612
+ const c = f2(Math.cos(rad));
29792
30613
  if (append2) {
29793
30614
  return [
29794
- f(f(m[0] * c) - f(m[1] * s)),
29795
- f(f(m[0] * s) + f(m[1] * c)),
29796
- f(f(m[2] * c) - f(m[3] * s)),
29797
- f(f(m[2] * s) + f(m[3] * c)),
29798
- f(f(m[4] * c) - f(m[5] * s)),
29799
- f(f(m[4] * s) + f(m[5] * c))
30615
+ f2(f2(m[0] * c) - f2(m[1] * s)),
30616
+ f2(f2(m[0] * s) + f2(m[1] * c)),
30617
+ f2(f2(m[2] * c) - f2(m[3] * s)),
30618
+ f2(f2(m[2] * s) + f2(m[3] * c)),
30619
+ f2(f2(m[4] * c) - f2(m[5] * s)),
30620
+ f2(f2(m[4] * s) + f2(m[5] * c))
29800
30621
  ];
29801
30622
  }
29802
30623
  return [
29803
- f(f(m[0] * c) + f(m[2] * s)),
29804
- f(f(m[3] * s) + f(m[1] * c)),
29805
- f(f(m[2] * c) - f(m[0] * s)),
29806
- f(f(m[3] * c) - f(m[1] * s)),
30624
+ f2(f2(m[0] * c) + f2(m[2] * s)),
30625
+ f2(f2(m[3] * s) + f2(m[1] * c)),
30626
+ f2(f2(m[2] * c) - f2(m[0] * s)),
30627
+ f2(f2(m[3] * c) - f2(m[1] * s)),
29807
30628
  m[4],
29808
30629
  m[5]
29809
30630
  ];
@@ -30386,10 +31207,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
30386
31207
  }
30387
31208
  case EMFPLUS_BEGINCONTAINER: {
30388
31209
  if (recDataSize >= 36) {
30389
- const f = (k) => view.getFloat32(dataOff + k, true);
31210
+ const f2 = (k) => view.getFloat32(dataOff + k, true);
30390
31211
  const t = containerRectTransform(
30391
- { x: f(0), y: f(4), w: f(8), h: f(12) },
30392
- { x: f(16), y: f(20), w: f(24), h: f(28) },
31212
+ { x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
31213
+ { x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
30393
31214
  recFlags & 255
30394
31215
  );
30395
31216
  beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
@@ -30545,7 +31366,7 @@ function registerNestedMetafileReplayer(fn) {
30545
31366
  nestedReplayer = fn;
30546
31367
  }
30547
31368
  function inclusiveNestedMapping(toDevice, srcX, srcY, srcW, srcH) {
30548
- const [a, b, c, d, e, f] = toDevice;
31369
+ const [a, b, c, d, e, f2] = toDevice;
30549
31370
  const lengthU = Math.hypot(a, b) * srcW;
30550
31371
  const lengthV = Math.hypot(c, d) * srcH;
30551
31372
  if (!(srcW > 1 && srcH > 1 && lengthU > 1 && lengthV > 1)) {
@@ -30557,7 +31378,7 @@ function inclusiveNestedMapping(toDevice, srcX, srcY, srcW, srcH) {
30557
31378
  const nb = b * ku;
30558
31379
  const nc = c * kv;
30559
31380
  const nd = d * kv;
30560
- return [na, nb, nc, nd, e + (a - na) * srcX + (c - nc) * srcY, f + (b - nb) * srcX + (d - nd) * srcY];
31381
+ return [na, nb, nc, nd, e + (a - na) * srcX + (c - nc) * srcY, f2 + (b - nb) * srcX + (d - nd) * srcY];
30561
31382
  }
30562
31383
  function drawNestedMetafile(rCtx, img, cached, source) {
30563
31384
  const depth = rCtx.nestingDepth ?? 0;
@@ -31340,7 +32161,7 @@ function encodeJpeg(data, width, height, options2 = {}) {
31340
32161
  }
31341
32162
  const quality = Number.isFinite(options2.quality) ? Math.min(1, Math.max(0, options2.quality)) : DEFAULT_JPEG_QUALITY;
31342
32163
  const [bgR, bgG, bgB] = options2.background ?? [255, 255, 255];
31343
- const sub3 = options2.chromaSubsampling ?? false;
32164
+ const sub4 = options2.chromaSubsampling ?? false;
31344
32165
  const lumaQuant = scaleQuant(LUMA_QUANT, quality);
31345
32166
  const chromaQuant = scaleQuant(CHROMA_QUANT, quality);
31346
32167
  const n = width * height;
@@ -31360,7 +32181,7 @@ function encodeJpeg(data, width, height, options2 = {}) {
31360
32181
  const acL = buildCodes(AC_LUMA);
31361
32182
  const dcC = buildCodes(DC_CHROMA);
31362
32183
  const acC = buildCodes(AC_CHROMA);
31363
- const factor = sub3 ? 2 : 1;
32184
+ const factor = sub4 ? 2 : 1;
31364
32185
  const mcu = 8 * factor;
31365
32186
  const block = new Float64Array(64);
31366
32187
  const tmp = new Float64Array(64);
@@ -35621,8 +36442,8 @@ function parseRasterFontFile(data) {
35621
36442
  }
35622
36443
  const sig = view.getUint16(0, true);
35623
36444
  if (sig === 512 || sig === 768) {
35624
- const f = parseFnt(view, 0, view.byteLength);
35625
- return f ? [f] : out;
36445
+ const f2 = parseFnt(view, 0, view.byteLength);
36446
+ return f2 ? [f2] : out;
35626
36447
  }
35627
36448
  if (sig !== 23117) {
35628
36449
  return out;
@@ -35647,9 +36468,9 @@ function parseRasterFontFile(data) {
35647
36468
  }
35648
36469
  const off = view.getUint16(p, true) * 2 ** shift;
35649
36470
  const len = view.getUint16(p + 2, true) * 2 ** shift;
35650
- const f = parseFnt(view, off, Math.min(view.byteLength, off + len));
35651
- if (f) {
35652
- out.push(f);
36471
+ const f2 = parseFnt(view, off, Math.min(view.byteLength, off + len));
36472
+ if (f2) {
36473
+ out.push(f2);
35653
36474
  }
35654
36475
  }
35655
36476
  }
@@ -36008,12 +36829,12 @@ function readGlyph(view, glyf, start, end) {
36008
36829
  p += insLen;
36009
36830
  const flags2 = new Uint8Array(nPts);
36010
36831
  for (let i = 0; i < nPts; ) {
36011
- const f = view.getUint8(p++);
36012
- flags2[i++] = f;
36013
- if (f & 8) {
36832
+ const f2 = view.getUint8(p++);
36833
+ flags2[i++] = f2;
36834
+ if (f2 & 8) {
36014
36835
  let rep = view.getUint8(p++);
36015
36836
  while (rep-- > 0 && i < nPts) {
36016
- flags2[i++] = f;
36837
+ flags2[i++] = f2;
36017
36838
  }
36018
36839
  }
36019
36840
  }
@@ -36021,11 +36842,11 @@ function readGlyph(view, glyf, start, end) {
36021
36842
  const ys = new Array(nPts);
36022
36843
  let v = 0;
36023
36844
  for (let i = 0; i < nPts; i++) {
36024
- const f = flags2[i];
36025
- if (f & 2) {
36845
+ const f2 = flags2[i];
36846
+ if (f2 & 2) {
36026
36847
  const d = view.getUint8(p++);
36027
- v += f & 16 ? d : -d;
36028
- } else if (!(f & 16)) {
36848
+ v += f2 & 16 ? d : -d;
36849
+ } else if (!(f2 & 16)) {
36029
36850
  v += view.getInt16(p);
36030
36851
  p += 2;
36031
36852
  }
@@ -36033,11 +36854,11 @@ function readGlyph(view, glyf, start, end) {
36033
36854
  }
36034
36855
  v = 0;
36035
36856
  for (let i = 0; i < nPts; i++) {
36036
- const f = flags2[i];
36037
- if (f & 4) {
36857
+ const f2 = flags2[i];
36858
+ if (f2 & 4) {
36038
36859
  const d = view.getUint8(p++);
36039
- v += f & 32 ? d : -d;
36040
- } else if (!(f & 32)) {
36860
+ v += f2 & 32 ? d : -d;
36861
+ } else if (!(f2 & 32)) {
36041
36862
  v += view.getInt16(p);
36042
36863
  p += 2;
36043
36864
  }
@@ -36577,9 +37398,9 @@ var HintedSize = class _HintedSize {
36577
37398
  let metricsFrom = null;
36578
37399
  let lastScan = scan;
36579
37400
  for (const comp of glyph.components) {
36580
- const sub3 = this.loadRecursive(comp.glyphIndex, depth + 1);
36581
- lastScan = { scanControl: sub3.scanControl, scanSet: sub3.scanSet, scanType: sub3.scanType };
36582
- const z = sub3.zone;
37401
+ const sub4 = this.loadRecursive(comp.glyphIndex, depth + 1);
37402
+ lastScan = { scanControl: sub4.scanControl, scanSet: sub4.scanSet, scanType: sub4.scanType };
37403
+ const z = sub4.zone;
36583
37404
  const m = z.n - 4;
36584
37405
  if (comp.flags & (WE_HAVE_A_SCALE | WE_HAVE_AN_X_AND_Y_SCALE | WE_HAVE_A_TWO_BY_TWO)) {
36585
37406
  for (let i = 0; i < z.n; i++) {
@@ -36840,17 +37661,17 @@ var HintedSize = class _HintedSize {
36840
37661
  * freedom vector was copied from the projection vector, or their rounded dot product is exactly 1.0): the move
36841
37662
  * is then the distance times the component over 1.0 on both axes.
36842
37663
  */
36843
- moveAmt(distance, f, alongX) {
37664
+ moveAmt(distance, f2, alongX) {
36844
37665
  if (this.gdiMath) {
36845
37666
  if (this.gs.fvIsPv || this.fDotP === 16384) {
36846
- return mulDiv(distance, f, 16384);
37667
+ return mulDiv(distance, f2, 16384);
36847
37668
  }
36848
- if (alongX && f === this.fDotP) {
37669
+ if (alongX && f2 === this.fDotP) {
36849
37670
  return distance;
36850
37671
  }
36851
- return alongX ? mulDivGdi(distance, f, this.fDotP) : mulDiv(distance, f, this.fDotP);
37672
+ return alongX ? mulDivGdi(distance, f2, this.fDotP) : mulDiv(distance, f2, this.fDotP);
36852
37673
  }
36853
- return mulDiv(distance, f, this.fDotP);
37674
+ return mulDiv(distance, f2, this.fDotP);
36854
37675
  }
36855
37676
  moveOrig(zone, p, distance) {
36856
37677
  const gs = this.gs;
@@ -37228,7 +38049,7 @@ var HintedSize = class _HintedSize {
37228
38049
  break;
37229
38050
  }
37230
38051
  case 44: {
37231
- const f = this.pop();
38052
+ const f2 = this.pop();
37232
38053
  let p = next;
37233
38054
  while (p < cur.length && cur[p] !== 45) {
37234
38055
  if (cur[p] === 44 || cur[p] === 137) {
@@ -37236,10 +38057,10 @@ var HintedSize = class _HintedSize {
37236
38057
  }
37237
38058
  p += _HintedSize.insLength(cur, p);
37238
38059
  }
37239
- if (f < 0 || f > 65535) {
38060
+ if (f2 < 0 || f2 > 65535) {
37240
38061
  throw new HintError("fdef");
37241
38062
  }
37242
- this.fdefs[f] = { code: cur, start: next, end: p };
38063
+ this.fdefs[f2] = { code: cur, start: next, end: p };
37243
38064
  next = p + 1;
37244
38065
  break;
37245
38066
  }
@@ -37270,8 +38091,8 @@ var HintedSize = class _HintedSize {
37270
38091
  continue;
37271
38092
  }
37272
38093
  case 43: {
37273
- const f = this.pop();
37274
- const def = this.fdefs[f];
38094
+ const f2 = this.pop();
38095
+ const def = this.fdefs[f2];
37275
38096
  if (!def) {
37276
38097
  throw new HintError("call");
37277
38098
  }
@@ -37284,9 +38105,9 @@ var HintedSize = class _HintedSize {
37284
38105
  continue;
37285
38106
  }
37286
38107
  case 42: {
37287
- const f = this.pop();
38108
+ const f2 = this.pop();
37288
38109
  const cnt = this.pop();
37289
- const def = this.fdefs[f];
38110
+ const def = this.fdefs[f2];
37290
38111
  if (!def) {
37291
38112
  throw new HintError("loopcall");
37292
38113
  }
@@ -37595,7 +38416,7 @@ var HintedSize = class _HintedSize {
37595
38416
  while (gs.loop > 0) {
37596
38417
  const p = this.pop();
37597
38418
  if (p >= 0 && p < this.zp2.n) {
37598
- const keep = !this.ctCompat() || this.inComposite || gs.fvx === 0 && this.shpixAlongY(p) || gs.fvx !== 0 && !this.inSizeTweak() && (!this.env.grayscale || this.plusShpixX(p, amt));
38419
+ const keep = !this.ctCompat() || this.inComposite || gs.fvx === 0 && (this.shpixAlongY(p) || this.iupy && this.linkMode() && !this.inSizeTweak()) || gs.fvx !== 0 && !this.inSizeTweak() && (!this.env.grayscale || this.plusShpixX(p, amt));
37599
38420
  if (keep) {
37600
38421
  this.moveZp2(p, dx, dy, true);
37601
38422
  }
@@ -38343,12 +39164,12 @@ var HintedSize = class _HintedSize {
38343
39164
  if (pt === -1) {
38344
39165
  return 0;
38345
39166
  }
38346
- let f = links.flags[pt];
38347
- if (f & 4) {
39167
+ let f2 = links.flags[pt];
39168
+ if (f2 & 4) {
38348
39169
  return 0;
38349
39170
  }
38350
- links.flags[pt] = f |= 4;
38351
- if (!(f & 2)) {
39171
+ links.flags[pt] = f2 |= 4;
39172
+ if (!(f2 & 2)) {
38352
39173
  const lastEp = z.n - 5;
38353
39174
  const w0 = links.w0[pt];
38354
39175
  let shift = 0;
@@ -38587,8 +39408,8 @@ var HintedSize = class _HintedSize {
38587
39408
  return;
38588
39409
  }
38589
39410
  if (zp2 === this.pts && this.recorder(false)) {
38590
- const mul6 = (u, v) => Math.abs(Math.floor((u * v + 32) / 64));
38591
- const steeperA = mul6(zp1.curY[a1] - zp1.curY[a0], zp0.curX[b1] - zp0.curX[b0]) > mul6(zp1.curX[a1] - zp1.curX[a0], zp0.curY[b1] - zp0.curY[b0]);
39411
+ const mul7 = (u, v) => Math.abs(Math.floor((u * v + 32) / 64));
39412
+ const steeperA = mul7(zp1.curY[a1] - zp1.curY[a0], zp0.curX[b1] - zp0.curX[b0]) > mul7(zp1.curX[a1] - zp1.curX[a0], zp0.curY[b1] - zp0.curY[b0]);
38592
39413
  this.linkProportion(zp2, steeperA ? a0 : b0, p, steeperA ? a1 : b1);
38593
39414
  }
38594
39415
  const dbx = zp0.curX[b1] - zp0.curX[b0];
@@ -40254,6 +41075,97 @@ function dropoutMode(scanControl, scanType) {
40254
41075
  return 2;
40255
41076
  }
40256
41077
  }
41078
+ function compDiv2(n, d) {
41079
+ if (d === 0) return n < 0 ? -2147483648 : 2147483647;
41080
+ const h = Math.trunc(d / 2);
41081
+ return Math.trunc((n < 0 === d < 0 ? n + h : n - h) / d);
41082
+ }
41083
+ function nativeConicPieces(x0, y0, x1, y1, x2, y2, out) {
41084
+ for (; ; ) {
41085
+ const dx01 = x1 - x0;
41086
+ const dx12 = x2 - x1;
41087
+ const dy01 = y1 - y0;
41088
+ const dy12 = y2 - y1;
41089
+ if (dy01 > 0 && dy12 < 0 || dy01 < 0 && dy12 > 0) {
41090
+ const den = dy01 - dy12;
41091
+ const xa = x0 + compDiv2(dx01 * dy01, den);
41092
+ const xb = x1 + compDiv2(dx12 * dy01, den);
41093
+ const xs = xa + compDiv2((xb - xa) * dy01, den);
41094
+ const ys = y0 + compDiv2(dy01 * dy01, den);
41095
+ nativeConicPieces(x0, y0, xa, ys, xs, ys, out);
41096
+ x0 = xs;
41097
+ y0 = ys;
41098
+ x1 = xb;
41099
+ y1 = ys;
41100
+ continue;
41101
+ }
41102
+ if (dx01 > 0 && dx12 < 0 || dx01 < 0 && dx12 > 0) {
41103
+ const den = dx01 - dx12;
41104
+ const ya = y0 + compDiv2(dy01 * dx01, den);
41105
+ const yb = y1 + compDiv2(dy12 * dx01, den);
41106
+ const ys = ya + compDiv2((yb - ya) * dx01, den);
41107
+ const xs = x0 + compDiv2(dx01 * dx01, den);
41108
+ nativeConicPieces(x0, y0, xs, ya, xs, ys, out);
41109
+ x0 = xs;
41110
+ y0 = ys;
41111
+ x1 = xs;
41112
+ y1 = yb;
41113
+ continue;
41114
+ }
41115
+ if (Math.abs(x2 - x0) > 3200 || Math.abs(y2 - y0) > 3200) {
41116
+ const ax = x0 + x1 >> 1;
41117
+ const ay = y0 + y1 >> 1;
41118
+ const bx = x1 + x2 >> 1;
41119
+ const by = y1 + y2 >> 1;
41120
+ const mx = ax + bx >> 1;
41121
+ const my = ay + by >> 1;
41122
+ nativeConicPieces(x0, y0, ax, ay, mx, my, out);
41123
+ x0 = mx;
41124
+ y0 = my;
41125
+ x1 = bx;
41126
+ y1 = by;
41127
+ continue;
41128
+ }
41129
+ out.push([x1, y1, x2, y2]);
41130
+ return;
41131
+ }
41132
+ }
41133
+ var ARC_SHIFT = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3];
41134
+ function bitLength2(v) {
41135
+ v = Math.abs(v);
41136
+ let n = 0;
41137
+ while (v > 0) {
41138
+ n++;
41139
+ v = Math.floor(v / 2);
41140
+ }
41141
+ return n;
41142
+ }
41143
+ function nativeArc(x0, y0, x1, y1, x2, y2) {
41144
+ const sx = x2 > x0 ? 1 : -1;
41145
+ const sy = y2 > y0 ? 1 : -1;
41146
+ let dx = sx * (x2 - x0);
41147
+ let dy = sy * (y2 - y0);
41148
+ let ax = sx * (x1 - x0);
41149
+ let ay = sy * (y1 - y0);
41150
+ const first = (p0, sg) => sg > 0 ? Math.floor((p0 + 32) / 64) * 64 + 32 - p0 : p0 - (Math.floor((p0 - 33) / 64) * 64 + 32);
41151
+ const fx0 = first(x0, sx);
41152
+ const fy0 = first(y0, sy);
41153
+ let fx = fx0;
41154
+ let fy = fy0;
41155
+ const shift = ARC_SHIFT[bitLength2(2 * (dy * ax - dx * ay)) + bitLength2(Math.max(dx, dy))] ?? 0;
41156
+ if (shift > 0) {
41157
+ const h = 2 ** (shift - 1);
41158
+ const q = 2 ** shift;
41159
+ const r = (v) => Math.floor((v + h) / q) * q;
41160
+ dx = r(dx);
41161
+ dy = r(dy);
41162
+ ax = r(ax);
41163
+ ay = r(ay);
41164
+ fx = r(fx);
41165
+ fy = r(fy);
41166
+ }
41167
+ return { sx, sy, x0, y0, dx, ax, fx, dy, ay, fy, fx0, fy0 };
41168
+ }
40257
41169
  var Raster = class {
40258
41170
  constructor(dropOutControl, fineArcs = false) {
40259
41171
  this.dropOutControl = dropOutControl;
@@ -40276,6 +41188,9 @@ var Raster = class {
40276
41188
  * curved edges with that rounding; FreeType's black rasterizer keeps the half and truncates at its own precision).
40277
41189
  */
40278
41190
  this.roundImpliedPoints = false;
41191
+ /** Walks arcs the way GDI's scan converter does (see {@link nativeConicPieces}, {@link nativeArc}); needs `roundImpliedPoints`. */
41192
+ this.nativeArcs = false;
41193
+ this.arcRecord = null;
40279
41194
  /**
40280
41195
  * Decides a pixel centre that lies exactly on an edge the way GDI's rotated glyphs do (native GetGlyphOutline bitmaps
40281
41196
  * of diagonal edges through pixel centres): the pixel is in when the contour runs downward there and out when it runs
@@ -40283,6 +41198,7 @@ var Raster = class {
40283
41198
  */
40284
41199
  this.directedTies = false;
40285
41200
  this.flipped = false;
41201
+ this.arcFlipped = false;
40286
41202
  this.precBits = 16;
40287
41203
  this.precStep = fineArcs ? 512 : 4096;
40288
41204
  this.precJitter = 480;
@@ -40587,7 +41503,9 @@ var Raster = class {
40587
41503
  }
40588
41504
  this.newProfileState(stateBez, o);
40589
41505
  }
40590
- if (stateBez === ASCENDING) {
41506
+ if (this.arcRecord) {
41507
+ this.nativeBezier(stateBez !== ASCENDING, this.minY, this.maxY);
41508
+ } else if (stateBez === ASCENDING) {
40591
41509
  this.bezierUp(this.minY, this.maxY);
40592
41510
  } else {
40593
41511
  this.bezierDown(this.minY, this.maxY);
@@ -40597,6 +41515,109 @@ var Raster = class {
40597
41515
  this.lastX = x3;
40598
41516
  this.lastY = y3;
40599
41517
  }
41518
+ /**
41519
+ * Adds the arc from (tsx, tsy) through (tcx, tcy) to (tex, tey), all in the outline's own axes and raw units, as GDI
41520
+ * walks it: cut into monotonic pieces (see {@link nativeConicPieces}), each walked on its rounded differences
41521
+ * (see {@link nativeArc}); a piece whose three points are on a line is a line.
41522
+ */
41523
+ nativeConic(flipped, tsx, tsy, tcx, tcy, tex, tey) {
41524
+ const pieces = [];
41525
+ nativeConicPieces(tsx, tsy, tcx, tcy, tex, tey, pieces);
41526
+ let px = tsx;
41527
+ let py = tsy;
41528
+ for (const [cx, cy, ex, ey] of pieces) {
41529
+ const sx = this.scaled(flipped ? ey : ex);
41530
+ const sy = this.scaled(flipped ? ex : ey);
41531
+ if ((cy - py) * (ex - cx) === (ey - cy) * (cx - px)) {
41532
+ this.lineTo(sx, sy);
41533
+ } else {
41534
+ this.arcRecord = nativeArc(px, py, cx, cy, ex, ey);
41535
+ this.arcFlipped = flipped;
41536
+ this.conicTo(this.scaled(flipped ? cy : cx), this.scaled(flipped ? cx : cy), sx, sy);
41537
+ this.arcRecord = null;
41538
+ }
41539
+ px = ex;
41540
+ py = ey;
41541
+ }
41542
+ }
41543
+ /**
41544
+ * Where the native walk of the current arc meets the scan line at `lineY` (a multiple of the precision in the
41545
+ * sweep's own axes), in the sweep's x.
41546
+ */
41547
+ nativeCrossing(lineY) {
41548
+ const a = this.arcRecord;
41549
+ const flipped = this.arcFlipped;
41550
+ const raw = lineY * 64 / this.prec + 32;
41551
+ const start = flipped ? a.x0 : a.y0;
41552
+ const sA = flipped ? a.sx : a.sy;
41553
+ const dA = flipped ? a.dx : a.dy;
41554
+ const aA = flipped ? a.ax : a.ay;
41555
+ const fA0 = flipped ? a.fx0 : a.fy0;
41556
+ const fA = flipped ? a.fx : a.fy;
41557
+ const dB = flipped ? a.dy : a.dx;
41558
+ const aB = flipped ? a.ay : a.ax;
41559
+ const sB = flipped ? a.sy : a.sx;
41560
+ const startB = flipped ? a.y0 : a.x0;
41561
+ const fB = flipped ? a.fy : a.fx;
41562
+ const fB0 = flipped ? a.fy0 : a.fx0;
41563
+ const line = sA * (raw - start);
41564
+ const index = Math.round((line - fA0) / 64);
41565
+ const dist = fA + 64 * index;
41566
+ let t = 1;
41567
+ if (dist < dA) {
41568
+ const b = 2 * aA;
41569
+ const c = dA - 2 * aA;
41570
+ t = 2 * dist / (b + Math.sqrt(b * b + 4 * c * dist));
41571
+ }
41572
+ const along = 2 * t * aB + t * t * (dB - 2 * aB);
41573
+ return Math.round((startB + sB * (along + fB0 - fB)) * this.prec / 64 - this.precHalf);
41574
+ }
41575
+ /** {@link bezierUp} for an arc walked natively: one pass over its scan lines, the crossings from {@link nativeCrossing}. */
41576
+ nativeBezier(down, miny, maxy) {
41577
+ const X = this.arcX;
41578
+ const Y = this.arcY;
41579
+ const sg = down ? -1 : 1;
41580
+ const mn = down ? -maxy : miny;
41581
+ const mx = down ? -miny : maxy;
41582
+ const y1 = sg * Y[2];
41583
+ const y2 = sg * Y[0];
41584
+ const xs = this.cProfile.xs;
41585
+ const fresh = this.fresh;
41586
+ this.arc -= 2;
41587
+ if (y2 < mn || y1 > mx) return;
41588
+ let e2 = this.floorP(y2);
41589
+ if (e2 > mx) e2 = mx;
41590
+ let e0 = mn;
41591
+ let e;
41592
+ if (y1 < mn) {
41593
+ e = mn;
41594
+ } else {
41595
+ e = this.ceilP(y1);
41596
+ e0 = e;
41597
+ if (this.frac(y1) === 0) {
41598
+ if (this.joint) {
41599
+ xs.pop();
41600
+ this.joint = false;
41601
+ }
41602
+ xs.push(X[2]);
41603
+ e += this.prec;
41604
+ }
41605
+ }
41606
+ if (this.fresh) {
41607
+ this.cProfile.start = this.trunc(e0);
41608
+ this.fresh = false;
41609
+ }
41610
+ for (; e <= e2; e += this.prec) {
41611
+ this.joint = false;
41612
+ if (y2 > e) {
41613
+ xs.push(this.nativeCrossing(sg * e));
41614
+ } else {
41615
+ this.joint = true;
41616
+ xs.push(X[0]);
41617
+ }
41618
+ }
41619
+ if (down && fresh && !this.fresh) this.cProfile.start = -this.cProfile.start;
41620
+ }
40600
41621
  decomposeContour(o, first, last, flipped) {
40601
41622
  const px = (i) => this.scaled(flipped ? o.ys[i] : o.xs[i]);
40602
41623
  const py = (i) => this.scaled(flipped ? o.xs[i] : o.ys[i]);
@@ -40609,12 +41630,30 @@ var Raster = class {
40609
41630
  const lastY = py(last);
40610
41631
  let limit = last;
40611
41632
  let point = first;
41633
+ const native = this.nativeArcs && this.roundImpliedPoints;
41634
+ let curTx = o.xs[first];
41635
+ let curTy = o.ys[first];
41636
+ let startTx = curTx;
41637
+ let startTy = curTy;
41638
+ const arc = (tcx, tcy, tex, tey, cx, cy, x, y) => {
41639
+ if (native) {
41640
+ this.nativeConic(flipped, curTx, curTy, tcx, tcy, tex, tey);
41641
+ curTx = tex;
41642
+ curTy = tey;
41643
+ } else {
41644
+ this.conicTo(cx, cy, x, y);
41645
+ }
41646
+ };
40612
41647
  if (!o.onCurve[first]) {
40613
41648
  if (o.onCurve[last]) {
40614
41649
  startX = lastX;
40615
41650
  startY = lastY;
41651
+ startTx = curTx = o.xs[last];
41652
+ startTy = curTy = o.ys[last];
40616
41653
  limit--;
40617
41654
  } else {
41655
+ startTx = curTx = Math.floor((o.xs[first] + o.xs[last] + 1) / 2);
41656
+ startTy = curTy = Math.floor((o.ys[first] + o.ys[last] + 1) / 2);
40618
41657
  if (this.roundImpliedPoints) {
40619
41658
  startX = mid(rx(first), rx(last));
40620
41659
  startY = mid(ry(first), ry(last));
@@ -40631,12 +41670,16 @@ var Raster = class {
40631
41670
  point++;
40632
41671
  if (o.onCurve[point]) {
40633
41672
  this.lineTo(px(point), py(point));
41673
+ curTx = o.xs[point];
41674
+ curTy = o.ys[point];
40634
41675
  continue;
40635
41676
  }
40636
41677
  let cx = px(point);
40637
41678
  let cy = py(point);
40638
41679
  let cxRaw = rx(point);
40639
41680
  let cyRaw = ry(point);
41681
+ let ctx = o.xs[point];
41682
+ let cty = o.ys[point];
40640
41683
  let closed = false;
40641
41684
  while (true) {
40642
41685
  if (point < limit) {
@@ -40644,11 +41687,11 @@ var Raster = class {
40644
41687
  const x = px(point);
40645
41688
  const y = py(point);
40646
41689
  if (o.onCurve[point]) {
40647
- this.conicTo(cx, cy, x, y);
41690
+ arc(ctx, cty, o.xs[point], o.ys[point], cx, cy, x, y);
40648
41691
  break;
40649
41692
  }
40650
41693
  if (this.roundImpliedPoints) {
40651
- this.conicTo(cx, cy, mid(cxRaw, rx(point)), mid(cyRaw, ry(point)));
41694
+ arc(ctx, cty, Math.floor((ctx + o.xs[point] + 1) / 2), Math.floor((cty + o.ys[point] + 1) / 2), cx, cy, mid(cxRaw, rx(point)), mid(cyRaw, ry(point)));
40652
41695
  } else {
40653
41696
  this.conicTo(cx, cy, Math.trunc((cx + x) / 2), Math.trunc((cy + y) / 2));
40654
41697
  }
@@ -40656,9 +41699,11 @@ var Raster = class {
40656
41699
  cy = y;
40657
41700
  cxRaw = rx(point);
40658
41701
  cyRaw = ry(point);
41702
+ ctx = o.xs[point];
41703
+ cty = o.ys[point];
40659
41704
  continue;
40660
41705
  }
40661
- this.conicTo(cx, cy, startX, startY);
41706
+ arc(ctx, cty, startTx, startTy, cx, cy, startX, startY);
40662
41707
  closed = true;
40663
41708
  break;
40664
41709
  }
@@ -41032,6 +42077,69 @@ function flattenForStubs(o) {
41032
42077
  }
41033
42078
  return { xs, ys, onCurve: new Array(xs.length).fill(1), endPts };
41034
42079
  }
42080
+ var ScanLists = class {
42081
+ constructor(count, P) {
42082
+ this.P = P;
42083
+ this.pairs = Array.from({ length: count }, () => []);
42084
+ }
42085
+ add(line, x1, x2) {
42086
+ if (line < 0 || line >= this.pairs.length) return;
42087
+ this.pairs[line].push({ start: Math.ceil(x1 / this.P), stop: Math.floor(x2 / this.P) + 1, x1, x2 });
42088
+ }
42089
+ /** Entries of `line` whose start or stop is `value` (native `HorizCrossings` / `VertCrossings`; 0 outside the box). */
42090
+ count(line, value) {
42091
+ if (line < 0 || line >= this.pairs.length) return 0;
42092
+ let n = 0;
42093
+ for (const p of this.pairs[line]) n += (p.start === value ? 1 : 0) + (p.stop === value ? 1 : 0);
42094
+ return n;
42095
+ }
42096
+ };
42097
+ var NativeScanLists = class {
42098
+ constructor(width, height, P) {
42099
+ this.width = width;
42100
+ this.height = height;
42101
+ this.rows = new ScanLists(height, P);
42102
+ this.cols = new ScanLists(width, P);
42103
+ }
42104
+ };
42105
+ function nativeDropoutPass(lists, mode, data, width, height, smartPixel, raster) {
42106
+ const stubs = mode === 1 || mode === 5;
42107
+ const smart = mode === 4 || mode === 5;
42108
+ const P = raster.precision;
42109
+ const at = (col, row2) => (height - 1 - row2) * width + col;
42110
+ const step = P / 64;
42111
+ const pick = (x1, x2, start) => smart ? Math.floor((Math.floor(x1 / step) + Math.floor(x2 / step) + 63) / 128) : start - 1;
42112
+ for (let y = height - 1; y >= 0; y--) {
42113
+ for (const p of lists.rows.pairs[y]) {
42114
+ if (p.start !== p.stop) continue;
42115
+ const x = p.start;
42116
+ if (stubs) {
42117
+ if (lists.rows.count(y + 1, x) + lists.cols.count(x - 1, y + 1) + lists.cols.count(x, y + 1) < 2) continue;
42118
+ if (lists.rows.count(y - 1, x) + lists.cols.count(x - 1, y) + lists.cols.count(x, y) < 2) continue;
42119
+ }
42120
+ if (x > 0 && x - 1 < width && data[at(x - 1, y)]) continue;
42121
+ if (x < width && x >= 0 && data[at(x, y)]) continue;
42122
+ const c = Math.max(0, pick(p.x1, p.x2, x));
42123
+ if (c < width) data[at(c, y)] = 1;
42124
+ }
42125
+ }
42126
+ for (let c = 0; c < width; c++) {
42127
+ for (let k = lists.cols.pairs[c].length - 1; k >= 0; k--) {
42128
+ const p = lists.cols.pairs[c][k];
42129
+ if (p.start !== p.stop) continue;
42130
+ const r = p.start;
42131
+ if (r < 0 || r > height) continue;
42132
+ if (stubs) {
42133
+ if (lists.cols.count(c - 1, r) + lists.rows.count(r, c) + lists.rows.count(r - 1, c) < 2) continue;
42134
+ if (lists.cols.count(c + 1, r) + lists.rows.count(r, c + 1) + lists.rows.count(r - 1, c + 1) < 2) continue;
42135
+ }
42136
+ if (r > 0 && r - 1 < height && data[at(c, r - 1)]) continue;
42137
+ if (r < height && data[at(c, r)]) continue;
42138
+ const row2 = Math.max(0, pick(p.x1, p.x2, r));
42139
+ if (row2 < height) data[at(c, row2)] = 1;
42140
+ }
42141
+ }
42142
+ }
41035
42143
  var StubSquares = class {
41036
42144
  constructor(o) {
41037
42145
  this.contours = [];
@@ -41150,7 +42258,7 @@ function monoBox(o) {
41150
42258
  if (collapsedY) yMax += 1;
41151
42259
  return { xMin, xMax, yMin, yMax, collapsedX, collapsedY };
41152
42260
  }
41153
- function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossings26Dot6 = false, roundImpliedPoints = false, directedTies = false, fineArcs = false, closedTies = false, squareStubs = false) {
42261
+ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossings26Dot6 = false, roundImpliedPoints = false, directedTies = false, fineArcs = false, closedTies = false, squareStubs = false, nativeDropouts = false) {
41154
42262
  const box = fixedBox ?? monoBox(o);
41155
42263
  if (!box) {
41156
42264
  return null;
@@ -41172,6 +42280,7 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41172
42280
  const at = (col, row2) => (height - 1 - row2) * width + col;
41173
42281
  const r = new Raster(dropout, fineArcs);
41174
42282
  r.roundImpliedPoints = roundImpliedPoints;
42283
+ r.nativeArcs = nativeDropouts;
41175
42284
  r.directedTies = directedTies;
41176
42285
  const P = r.precision;
41177
42286
  const monoContour = !squareStubs && stubOvershoot && (dropout === 1 || dropout === 4 || dropout === 5) ? MonoStubContours.create(local) : null;
@@ -41186,9 +42295,11 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41186
42295
  }
41187
42296
  return raster.floorPub(Math.floor((x1 + x2 + Math.floor(P * 63 / 64)) / 2));
41188
42297
  };
42298
+ const native = nativeDropouts && dropout !== 2 ? new NativeScanLists(width, height, P) : null;
41189
42299
  if (r.convert(local, false, 0, (height - 1) * P)) {
41190
42300
  r.sweep(
41191
42301
  (y, x1, x2) => {
42302
+ native?.rows.add(y, x1, x2);
41192
42303
  let e1 = r.ceilPub(x1);
41193
42304
  let e2 = r.floorPub(x2);
41194
42305
  if (dropout !== 2 && x2 - x1 - P <= r.jitter && e1 !== x1 && e2 !== x2) {
@@ -41203,6 +42314,10 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41203
42314
  }
41204
42315
  },
41205
42316
  (y, x1, x2, left, right) => {
42317
+ if (native) {
42318
+ native.rows.add(y, x1, x2);
42319
+ return;
42320
+ }
41206
42321
  let e1 = r.ceilPub(x1);
41207
42322
  let e2 = r.floorPub(x2);
41208
42323
  let pxl = e1;
@@ -41250,9 +42365,12 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41250
42365
  if (dropout !== 2) {
41251
42366
  const h = new Raster(dropout, fineArcs);
41252
42367
  h.directedTies = directedTies;
42368
+ h.roundImpliedPoints = roundImpliedPoints && nativeDropouts;
42369
+ h.nativeArcs = nativeDropouts;
41253
42370
  if (h.convert(local, true, 0, (width - 1) * P)) {
41254
42371
  h.sweep(
41255
42372
  (col, x1, x2) => {
42373
+ native?.cols.add(col, x1, x2);
41256
42374
  if (x2 - x1 < P) {
41257
42375
  const e1 = h.ceilPub(x1);
41258
42376
  const e2 = h.floorPub(x2);
@@ -41265,6 +42383,10 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41265
42383
  }
41266
42384
  },
41267
42385
  (col, x1, x2, left, right) => {
42386
+ if (native) {
42387
+ native.cols.add(col, x1, x2);
42388
+ return;
42389
+ }
41268
42390
  let e1 = h.ceilPub(x1);
41269
42391
  const e2 = h.floorPub(x2);
41270
42392
  let pxl = e1;
@@ -41310,11 +42432,12 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41310
42432
  );
41311
42433
  }
41312
42434
  }
42435
+ if (native) nativeDropoutPass(native, dropout, data, width, height, smartPixel, r);
41313
42436
  if (closedTies) fillTieRows(local, curved, data, width, height, at);
41314
42437
  return { width, height, left: box.xMin, top: box.yMax, data };
41315
42438
  }
41316
42439
  var GRAY_OVERSAMPLE = 4;
41317
- function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true, fineArcs = false, closedTies = false, squareStubs = false, roundImpliedPoints = false) {
42440
+ function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true, fineArcs = false, closedTies = false, squareStubs = false, roundImpliedPoints = false, nativeDropouts = false) {
41318
42441
  const n = o.xs.length;
41319
42442
  if (n === 0) {
41320
42443
  return null;
@@ -41343,7 +42466,7 @@ function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true
41343
42466
  onCurve: o.onCurve,
41344
42467
  endPts: o.endPts
41345
42468
  };
41346
- const hi = rasterizeMono(big, dropout, { xMin: box.xMin * kx, xMax: box.xMax * kx, yMin: box.yMin * ky, yMax: box.yMax * ky }, stubOvershoot, false, roundImpliedPoints, false, fineArcs, closedTies, squareStubs);
42469
+ const hi = rasterizeMono(big, dropout, { xMin: box.xMin * kx, xMax: box.xMax * kx, yMin: box.yMin * ky, yMax: box.yMax * ky }, stubOvershoot, false, roundImpliedPoints, false, fineArcs, closedTies, squareStubs, nativeDropouts);
41347
42470
  return hi ? { box, hi } : null;
41348
42471
  }
41349
42472
  function rasterizeGray(o, dropout = 2, roundImpliedPoints = false, fineArcs = false, squareStubs = false) {
@@ -41399,6 +42522,7 @@ var NONANTIALIASED_QUALITY = 3;
41399
42522
  var ANTIALIASED_QUALITY = 4;
41400
42523
  var CLEARTYPE_QUALITY = 5;
41401
42524
  var CLEARTYPE_NATURAL_QUALITY = 6;
42525
+ var UNHINTED_MONO_DROPOUT = 1;
41402
42526
  var NOTDEF = 0;
41403
42527
  var FONT_SUBSTITUTES = {
41404
42528
  "ms shell dlg": "microsoft sans serif",
@@ -41439,8 +42563,8 @@ var RASTER_SUBSTITUTES = {
41439
42563
  "tms rmn": "ms serif"
41440
42564
  };
41441
42565
  var ITALIC_SHEAR = 22272 / 65536;
41442
- function isItalicFace(f) {
41443
- return (f.fsSelection & 1) !== 0 || (f.macStyle & 2) !== 0;
42566
+ function isItalicFace(f2) {
42567
+ return (f2.fsSelection & 1) !== 0 || (f2.macStyle & 2) !== 0;
41444
42568
  }
41445
42569
  var CP1252_HIGH = [
41446
42570
  8364,
@@ -42014,13 +43138,13 @@ var RealizedFont = class {
42014
43138
  if (this.mode === "mono") {
42015
43139
  const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
42016
43140
  const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
42017
- bitmap = this.gdiPlus ? rasterizeMono(o, dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
43141
+ bitmap = this.gdiPlus ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
42018
43142
  } else if (this.mode === "cleartype") {
42019
- const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : 2;
43143
+ const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
42020
43144
  bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
42021
43145
  } else {
42022
43146
  const dropout = this.gdiPlus ? src.scanSet ? dropoutMode(src.scanControl, src.scanType) : 2 : msScanFlags(src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM, src.scanType);
42023
- bitmap = this.gdiPlus && !this.gridFit && !m && !this.syntheticBold && !this.syntheticItalic && this.ttf.weightClass < 600 && this.ttf.family.toLowerCase() === "courier new" ? rasterizeCourierGray(o, dropout) : this.gdiPlus ? rasterizeGray(o, dropout, false, false, true) : msGrayBitmap(o, dropout);
43147
+ bitmap = this.gdiPlus && !this.gridFit && !m && !this.syntheticBold && !this.syntheticItalic && this.ttf.weightClass < 600 && this.ttf.family.toLowerCase() === "courier new" ? rasterizeCourierGray(o, dropout) : this.gdiPlus && !this.installed ? rasterizeGray(o, dropout, false, false, true) : msGrayBitmap(o, dropout);
42024
43148
  }
42025
43149
  if (bitmap && this.syntheticBold) {
42026
43150
  bitmap = embolden(bitmap, this.mode === "mono" ? 1 : 16);
@@ -42048,27 +43172,32 @@ function roundedRotationMatrix(m, ppem) {
42048
43172
  return [Math.round(m[0] * p) / p, Math.round(m[1] * p) / p, Math.round(m[2] * p) / p, Math.round(m[3] * p) / p];
42049
43173
  }
42050
43174
  function rotationMatrix(m, ppem, integerPpem) {
42051
- const isRotation = Math.abs(m[0] - m[3]) < 1e-6 && Math.abs(m[1] + m[2]) < 1e-6;
43175
+ const xLength = Math.hypot(m[0], m[1]);
43176
+ const yLength = Math.hypot(m[2], m[3]);
43177
+ const stretch = yLength > 0 ? xLength / yLength : 0;
43178
+ const isRotation = stretch > 0.9 && stretch < 1.1 && Math.abs(m[0] * m[2] + m[1] * m[3]) < 1e-6 * xLength * yLength;
42052
43179
  if (!isRotation || ppem <= 0) {
42053
43180
  return null;
42054
43181
  }
42055
43182
  if (!integerPpem) {
42056
43183
  return { ppem: 0, matrix: [m[0], m[1], m[2], m[3]] };
42057
43184
  }
42058
- const major = Math.max(Math.abs(m[0]), Math.abs(m[1]));
42059
- const minor = Math.min(Math.abs(m[0]), Math.abs(m[1]));
42060
- const majorFixed = Math.round(major * ppem * 32);
42061
- const target = Math.floor((majorFixed + 16) / 32);
43185
+ const normalise = (vx, vy) => {
43186
+ const ax = Math.abs(vx);
43187
+ const ay = Math.abs(vy);
43188
+ const majorFixed = Math.round(Math.max(ax, ay) * ppem * 32);
43189
+ const q = Math.round(Math.round(Math.min(ax, ay) * ppem * 32) / majorFixed * 65536) / 65536;
43190
+ const sx = vx < 0 ? -1 : 1;
43191
+ const sy = vy < 0 ? -1 : 1;
43192
+ return ax >= ay ? { x: sx, y: sy * q, majorFixed } : { x: sx * q, y: sy, majorFixed };
43193
+ };
43194
+ const xv = normalise(m[0], -m[1]);
43195
+ const yv = normalise(-m[2], m[3]);
43196
+ const target = Math.floor((xv.majorFixed + 16) / 32);
42062
43197
  if (target < 1) {
42063
43198
  return null;
42064
43199
  }
42065
- const q = Math.round(Math.round(minor * ppem * 32) / majorFixed * 65536) / 65536;
42066
- const xMajor = Math.abs(m[0]) >= Math.abs(m[1]);
42067
- const sg = (v) => v < 0 ? -1 : 1;
42068
- return {
42069
- ppem: target,
42070
- matrix: xMajor ? [sg(m[0]), sg(m[1]) * q, sg(m[2]) * q, sg(m[3])] : [sg(m[0]) * q, sg(m[1]), sg(m[2]), sg(m[3]) * q]
42071
- };
43200
+ return { ppem: target, matrix: [xv.x, -xv.y, -yv.x, yv.y] };
42072
43201
  }
42073
43202
  function embolden(b, full) {
42074
43203
  const w = b.width + 1;
@@ -42136,7 +43265,7 @@ var GdiFontCollection = class _GdiFontCollection {
42136
43265
  const list = this.families.get(k);
42137
43266
  if (!list) {
42138
43267
  this.families.set(k, [face]);
42139
- } else if (!list.some((f) => f.family.toLowerCase().trim() === k)) {
43268
+ } else if (!list.some((f2) => f2.family.toLowerCase().trim() === k)) {
42140
43269
  list.push(face);
42141
43270
  }
42142
43271
  }
@@ -42154,9 +43283,9 @@ var GdiFontCollection = class _GdiFontCollection {
42154
43283
  return m;
42155
43284
  }
42156
43285
  }
42157
- const sub3 = FONT_SUBSTITUTES[k];
42158
- if (sub3 && this.families.get(sub3)) {
42159
- return this.families.get(sub3);
43286
+ const sub4 = FONT_SUBSTITUTES[k];
43287
+ if (sub4 && this.families.get(sub4)) {
43288
+ return this.families.get(sub4);
42160
43289
  }
42161
43290
  const family = pitchAndFamily & 240;
42162
43291
  const fixed = (pitchAndFamily & 3) === 1;
@@ -42174,7 +43303,7 @@ var GdiFontCollection = class _GdiFontCollection {
42174
43303
  }
42175
43304
  if (height === 0) {
42176
43305
  const sorted = faces.slice().sort((a, b) => a.pixHeight - b.pixHeight);
42177
- const face = sorted.find((f) => f.points >= 10) ?? sorted[0];
43306
+ const face = sorted.find((f2) => f2.points >= 10) ?? sorted[0];
42178
43307
  return { face, scale: 1, scaleX: 1 };
42179
43308
  }
42180
43309
  const pick = pickRasterFace(faces, height, width, weight);
@@ -42207,8 +43336,8 @@ var GdiFontCollection = class _GdiFontCollection {
42207
43336
  if (!pick || pick.scale !== 1 || pick.face.pixHeight > 16) {
42208
43337
  return 0;
42209
43338
  }
42210
- const f = pick.face;
42211
- return f.pixHeight <= ttCell + 1 ? f.pixHeight - f.internalLeading : 0;
43339
+ const f2 = pick.face;
43340
+ return f2.pixHeight <= ttCell + 1 ? f2.pixHeight - f2.internalLeading : 0;
42212
43341
  }
42213
43342
  /** Realises `spec`, or null when no supplied font can stand in for it. */
42214
43343
  realize(spec, fontFamilyMap) {
@@ -42232,11 +43361,11 @@ var GdiFontCollection = class _GdiFontCollection {
42232
43361
  const weight = spec.weight || 400;
42233
43362
  let best = faces[0];
42234
43363
  let bestScore = Infinity;
42235
- for (const f of faces) {
42236
- const dw = f.weightClass - weight;
42237
- const score2 = (isItalicFace(f) !== spec.italic ? 1e4 : 0) + (dw > 0 ? dw * 3 : -dw);
43364
+ for (const f2 of faces) {
43365
+ const dw = f2.weightClass - weight;
43366
+ const score2 = (isItalicFace(f2) !== spec.italic ? 1e4 : 0) + (dw > 0 ? dw * 3 : -dw);
42238
43367
  if (score2 < bestScore) {
42239
- best = f;
43368
+ best = f2;
42240
43369
  bestScore = score2;
42241
43370
  }
42242
43371
  }
@@ -42392,7 +43521,7 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42392
43521
  const KY = vertical ? CLEARTYPE_ROWS : 1;
42393
43522
  const WT = vertical ? CLEARTYPE_ROW_WEIGHTS : [1];
42394
43523
  const WSUM = WT.reduce((a, c) => a + c, 0);
42395
- const r = rasterizeSamples(o, CLEARTYPE_OVERSAMPLE, KY, 1, dropout, false, !truncate, !truncate, true, !truncate);
43524
+ const r = rasterizeSamples(o, CLEARTYPE_OVERSAMPLE, KY, 1, dropout, false, !truncate, !truncate, true, !truncate, !truncate);
42396
43525
  if (!r) {
42397
43526
  return null;
42398
43527
  }
@@ -42400,10 +43529,10 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42400
43529
  const width = box.xMax - box.xMin;
42401
43530
  const height = box.yMax - box.yMin;
42402
43531
  const n = width * 3;
42403
- const sub3 = new Float64Array(n);
43532
+ const sub4 = new Float64Array(n);
42404
43533
  const data = new Uint8Array(n * height);
42405
43534
  for (let y = 0; y < height; y++) {
42406
- sub3.fill(0);
43535
+ sub4.fill(0);
42407
43536
  for (let yy = 0; yy < KY; yy++) {
42408
43537
  const row2 = (y * KY + yy) * hi.width;
42409
43538
  for (let x = 0; x < hi.width; x++) {
@@ -42414,15 +43543,15 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42414
43543
  }
42415
43544
  }
42416
43545
  if (on) {
42417
- sub3[Math.floor(x / S)] += WT[yy] ?? 1;
43546
+ sub4[Math.floor(x / S)] += WT[yy] ?? 1;
42418
43547
  }
42419
43548
  }
42420
43549
  }
42421
43550
  for (let j = 0; j < n; j++) {
42422
- const before = j > 0 ? sub3[j - 1] : 0;
42423
- const after = j + 1 < n ? sub3[j + 1] : 0;
42424
- let acc = before + sub3[j] + after;
42425
- if (spread && acc === 1 && sub3[j] === 0 && (j % 3 === 0 && before === 1 || (j + 1) % 3 === 0 && after === 1)) {
43551
+ const before = j > 0 ? sub4[j - 1] : 0;
43552
+ const after = j + 1 < n ? sub4[j + 1] : 0;
43553
+ let acc = before + sub4[j] + after;
43554
+ if (spread && acc === 1 && sub4[j] === 0 && (j % 3 === 0 && before === 1 || (j + 1) % 3 === 0 && after === 1)) {
42426
43555
  acc = 0;
42427
43556
  }
42428
43557
  data[y * n + j] = vertical ? Math.floor((acc + WSUM / 2) / WSUM) : (truncate ? Math.floor : Math.round)(255 * acc / (3 * S * WSUM));
@@ -43000,7 +44129,7 @@ function measurePathBox(build, pad, surface) {
43000
44129
  let tx = 0;
43001
44130
  let ty = 0;
43002
44131
  let unknown = false;
43003
- const add2 = (x, y, r = 0) => {
44132
+ const add3 = (x, y, r = 0) => {
43004
44133
  minX = Math.min(minX, x + tx - r);
43005
44134
  minY = Math.min(minY, y + ty - r);
43006
44135
  maxX = Math.max(maxX, x + tx + r);
@@ -43010,35 +44139,35 @@ function measurePathBox(build, pad, surface) {
43010
44139
  unknown = true;
43011
44140
  };
43012
44141
  const recorder = {
43013
- moveTo: (x, y) => add2(x, y),
43014
- lineTo: (x, y) => add2(x, y),
44142
+ moveTo: (x, y) => add3(x, y),
44143
+ lineTo: (x, y) => add3(x, y),
43015
44144
  rect: (x, y, w, h) => {
43016
- add2(x, y);
43017
- add2(x + w, y + h);
44145
+ add3(x, y);
44146
+ add3(x + w, y + h);
43018
44147
  },
43019
44148
  fillRect: (x, y, w, h) => {
43020
- add2(x, y);
43021
- add2(x + w, y + h);
44149
+ add3(x, y);
44150
+ add3(x + w, y + h);
43022
44151
  },
43023
44152
  strokeRect: (x, y, w, h) => {
43024
- add2(x, y);
43025
- add2(x + w, y + h);
44153
+ add3(x, y);
44154
+ add3(x + w, y + h);
43026
44155
  },
43027
44156
  bezierCurveTo: (ax, ay, bx, by, x, y) => {
43028
- add2(ax, ay);
43029
- add2(bx, by);
43030
- add2(x, y);
44157
+ add3(ax, ay);
44158
+ add3(bx, by);
44159
+ add3(x, y);
43031
44160
  },
43032
44161
  quadraticCurveTo: (ax, ay, x, y) => {
43033
- add2(ax, ay);
43034
- add2(x, y);
44162
+ add3(ax, ay);
44163
+ add3(x, y);
43035
44164
  },
43036
44165
  arcTo: (x12, y12, x2, y2) => {
43037
- add2(x12, y12);
43038
- add2(x2, y2);
44166
+ add3(x12, y12);
44167
+ add3(x2, y2);
43039
44168
  },
43040
- arc: (x, y, r) => add2(x, y, Math.abs(r)),
43041
- ellipse: (x, y, rx, ry) => add2(x, y, Math.max(Math.abs(rx), Math.abs(ry))),
44169
+ arc: (x, y, r) => add3(x, y, Math.abs(r)),
44170
+ ellipse: (x, y, rx, ry) => add3(x, y, Math.max(Math.abs(rx), Math.abs(ry))),
43042
44171
  translate: (x, y) => {
43043
44172
  tx += x;
43044
44173
  ty += y;
@@ -43740,11 +44869,11 @@ function penPolygon(width, height = width) {
43740
44869
  } else {
43741
44870
  const rx = Math.ceil(width / 2);
43742
44871
  const ry = Math.ceil(height / 2);
43743
- const f = flattenBezierPath(ellipseBeziers(-rx, -ry, rx, ry));
44872
+ const f2 = flattenBezierPath(ellipseBeziers(-rx, -ry, rx, ry));
43744
44873
  const half = [];
43745
- for (let i = 0; i + 1 < f.length; i += 2) {
43746
- half.push([f[i], f[i + 1]]);
43747
- if (i > 0 && f[i + 1] === 0) {
44874
+ for (let i = 0; i + 1 < f2.length; i += 2) {
44875
+ half.push([f2[i], f2[i + 1]]);
44876
+ if (i > 0 && f2[i + 1] === 0) {
43748
44877
  break;
43749
44878
  }
43750
44879
  }
@@ -43775,10 +44904,10 @@ function penPolygonMatrix(width, m) {
43775
44904
  const hx = [halfVectorComponent(m[0] * h), halfVectorComponent(m[1] * h)];
43776
44905
  const hy = [mirror2 * halfVectorComponent(m[2] * h), mirror2 * halfVectorComponent(m[3] * h)];
43777
44906
  const box = ellipseBeziersBox({ ax: -hx[0] - hy[0], ay: -hx[1] - hy[1], exx: 2 * hx[0], exy: 2 * hx[1], eyx: 2 * hy[0], eyy: 2 * hy[1] });
43778
- const f = flattenBezierPath(box.slice(0, 14));
44907
+ const f2 = flattenBezierPath(box.slice(0, 14));
43779
44908
  const half = [];
43780
- for (let i = 0; i + 1 < f.length; i += 2) {
43781
- half.push([f[i], f[i + 1]]);
44909
+ for (let i = 0; i + 1 < f2.length; i += 2) {
44910
+ half.push([f2[i], f2[i + 1]]);
43782
44911
  }
43783
44912
  half.pop();
43784
44913
  const pen = [...half, ...half.map((p) => [0 - p[0] || 0, 0 - p[1] || 0])];
@@ -44518,20 +45647,20 @@ function boxFrame(box) {
44518
45647
  return { l: 0, t: 0, r: w, b: h };
44519
45648
  }
44520
45649
  function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatible = false) {
44521
- const f = boxFrame(box);
45650
+ const f2 = boxFrame(box);
44522
45651
  const mirrorX = isAxisBox(box) && box.exx < 0;
44523
45652
  const mirrorY = isAxisBox(box) && box.eyy < 0;
44524
45653
  const clockwise = recordedClockwise !== mirrorY;
44525
- const q = roundRectCorners(f.l, f.t, f.r, f.b, cw, ch, compatible, clockwise, mirrorX, isAxisBox(box) ? box.cornerRatio : void 0);
44526
- const map = frameMapper(box, f.l, f.t, f.r - f.l, f.b - f.t);
45654
+ const q = roundRectCorners(f2.l, f2.t, f2.r, f2.b, cw, ch, compatible, clockwise, mirrorX, isAxisBox(box) ? box.cornerRatio : void 0);
45655
+ const map = frameMapper(box, f2.l, f2.t, f2.r - f2.l, f2.b - f2.t);
44527
45656
  const pts = [];
44528
45657
  for (let i = 0; i < q.length; i += 2) {
44529
- pts.push(...map(q[i], clockwise ? f.t + f.b - q[i + 1] : q[i + 1]));
45658
+ pts.push(...map(q[i], clockwise ? f2.t + f2.b - q[i + 1] : q[i + 1]));
44530
45659
  }
44531
45660
  if (box.halfX) {
44532
45661
  if (box.halfXCompat || !clockwise) {
44533
- const cy = (f.t + f.b) / 2;
44534
- const ry = (f.b - f.t) / 2 || 1;
45662
+ const cy = (f2.t + f2.b) / 2;
45663
+ const ry = (f2.b - f2.t) / 2 || 1;
44535
45664
  for (let k = 0; k < 16; k++) {
44536
45665
  const v = (cy - pts[2 * k + 1]) / ry;
44537
45666
  pts[2 * k] += k >= 8 ? Math.round(1 + v) : Math.ceil(v - 0.5);
@@ -44544,8 +45673,8 @@ function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatib
44544
45673
  }
44545
45674
  }
44546
45675
  if (box.cornerExact && isAxisBox(box)) {
44547
- const w = f.r - f.l;
44548
- const h = f.b - f.t;
45676
+ const w = f2.r - f2.l;
45677
+ const h = f2.b - f2.t;
44549
45678
  if (w >= 0 && h >= 0) {
44550
45679
  const hx = w === 0 ? 0 : Math.round(box.cornerExact[0] * (mirrorX ? w - w % 2 : w + w % 2) / w / 2);
44551
45680
  const hy = h === 0 ? 0 : Math.round(box.cornerExact[1] * (clockwise ? h + h % 2 : h - h % 2) / h / 2);
@@ -44553,30 +45682,30 @@ function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatib
44553
45682
  const vc = clockwise ? Math.ceil(KAPPA * hy) : Math.floor(KAPPA * hy);
44554
45683
  const set = (k, x, y) => {
44555
45684
  if (x !== null) pts[2 * k] = x;
44556
- pts[2 * k + 1] = clockwise ? f.t + f.b - y : y;
45685
+ pts[2 * k + 1] = clockwise ? f2.t + f2.b - y : y;
44557
45686
  };
44558
45687
  const a = box.halfX ? 1 : 0;
44559
- set(0, null, f.t + hy);
44560
- set(1, null, f.t + hy - vc);
44561
- set(2, f.r + a - hx + hc, f.t);
44562
- set(3, f.r + a - hx, f.t);
44563
- set(4, f.l + a + hx, f.t);
44564
- set(5, f.l + a + hx - hc, f.t);
44565
- set(6, null, f.t + hy - vc);
44566
- set(7, null, f.t + hy);
44567
- set(8, null, f.b - hy);
44568
- set(9, null, f.b - hy + vc);
44569
- set(10, f.l + hx - hc, f.b);
44570
- set(11, f.l + hx, f.b);
44571
- set(12, f.r - hx, f.b);
44572
- set(13, f.r - hx + hc, f.b);
44573
- set(14, null, f.b - hy + vc);
44574
- set(15, null, f.b - hy);
45688
+ set(0, null, f2.t + hy);
45689
+ set(1, null, f2.t + hy - vc);
45690
+ set(2, f2.r + a - hx + hc, f2.t);
45691
+ set(3, f2.r + a - hx, f2.t);
45692
+ set(4, f2.l + a + hx, f2.t);
45693
+ set(5, f2.l + a + hx - hc, f2.t);
45694
+ set(6, null, f2.t + hy - vc);
45695
+ set(7, null, f2.t + hy);
45696
+ set(8, null, f2.b - hy);
45697
+ set(9, null, f2.b - hy + vc);
45698
+ set(10, f2.l + hx - hc, f2.b);
45699
+ set(11, f2.l + hx, f2.b);
45700
+ set(12, f2.r - hx, f2.b);
45701
+ set(13, f2.r - hx + hc, f2.b);
45702
+ set(14, null, f2.b - hy + vc);
45703
+ set(15, null, f2.b - hy);
44575
45704
  }
44576
45705
  }
44577
45706
  if (mirrorX) {
44578
45707
  for (let i = 0; i < pts.length; i += 2) {
44579
- pts[i] = f.l + f.r - pts[i];
45708
+ pts[i] = f2.l + f2.r - pts[i];
44580
45709
  }
44581
45710
  }
44582
45711
  return pts;
@@ -44593,8 +45722,8 @@ function roundRectRasterPath(box, cw, ch, clockwise = false, rectangle = false,
44593
45722
  return path;
44594
45723
  }
44595
45724
  function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPath(), mirror2) {
44596
- const f = boxFrame(box);
44597
- const map = frameMapper(box, f.l, f.t, f.r - f.l, f.b - f.t);
45725
+ const f2 = boxFrame(box);
45726
+ const map = frameMapper(box, f2.l, f2.t, f2.r - f2.l, f2.b - f2.t);
44598
45727
  let sx = s[0];
44599
45728
  let sy = s[1];
44600
45729
  let ex = e[0];
@@ -44607,7 +45736,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44607
45736
  const qy = py - box.ay;
44608
45737
  const u = (qx * box.eyy - qy * box.eyx) / det;
44609
45738
  const v = (box.exx * qy - box.exy * qx) / det;
44610
- return [f.l + u * (f.r - f.l), f.t + v * (f.b - f.t)];
45739
+ return [f2.l + u * (f2.r - f2.l), f2.t + v * (f2.b - f2.t)];
44611
45740
  };
44612
45741
  [sx, sy] = toFrame(sx, sy);
44613
45742
  [ex, ey] = toFrame(ex, ey);
@@ -44617,8 +45746,8 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44617
45746
  } else if (mirror2) {
44618
45747
  cw = clockwise !== mirror2.y;
44619
45748
  if (mirror2.x) {
44620
- sx = f.l + f.r - sx;
44621
- ex = f.l + f.r - ex;
45749
+ sx = f2.l + f2.r - sx;
45750
+ ex = f2.l + f2.r - ex;
44622
45751
  }
44623
45752
  } else {
44624
45753
  if (box.exx < 0 !== box.eyy < 0) {
@@ -44626,7 +45755,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44626
45755
  }
44627
45756
  }
44628
45757
  const mirrorX = !!mirror2?.x && isAxisBox(box);
44629
- const bz = arcBeziers(f.l, f.t, f.r, f.b, sx, sy, ex, ey, cw, !!box.halfX, !!box.framed, mirrorX);
45758
+ const bz = arcBeziers(f2.l, f2.t, f2.r, f2.b, sx, sy, ex, ey, cw, !!box.halfX, !!box.framed, mirrorX);
44630
45759
  const pts = [];
44631
45760
  for (let i = 0; i < bz.length; i += 2) {
44632
45761
  pts.push(...map(bz[i], bz[i + 1]));
@@ -44638,9 +45767,9 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44638
45767
  path.addBeziers(pts, true);
44639
45768
  }
44640
45769
  if (kind === "pie") {
44641
- const w = f.r - f.l;
44642
- const h = f.b - f.t;
44643
- const [cx, cy] = map(f.l + Math.ceil(w / 2) + (box.halfX && !mirrorX ? 1 : 0), f.t + Math.ceil(h / 2));
45770
+ const w = f2.r - f2.l;
45771
+ const h = f2.b - f2.t;
45772
+ const [cx, cy] = map(f2.l + Math.ceil(w / 2) + (box.halfX && !mirrorX ? 1 : 0), f2.t + Math.ceil(h / 2));
44644
45773
  path.lineTo(cx, cy);
44645
45774
  }
44646
45775
  if (kind === "pie" || kind === "chord") {
@@ -44750,11 +45879,11 @@ function brushPaint2(rCtx) {
44750
45879
  };
44751
45880
  }
44752
45881
  function withoutCurveTangents(path) {
44753
- if (!path.figures.some((f) => f.tangents)) {
45882
+ if (!path.figures.some((f2) => f2.tangents)) {
44754
45883
  return path;
44755
45884
  }
44756
45885
  const plain = new GdiRasterPath();
44757
- plain.figures = path.figures.map((f) => ({ pts: f.pts, closed: f.closed, roundWiden: f.roundWiden }));
45886
+ plain.figures = path.figures.map((f2) => ({ pts: f2.pts, closed: f2.closed, roundWiden: f2.roundWiden }));
44758
45887
  return plain;
44759
45888
  }
44760
45889
  function layoutRasterPath(rCtx, path, boxShape = false) {
@@ -44984,11 +46113,11 @@ function strokeStyledCosmetic(rCtx, path, pattern, style) {
44984
46113
  const paint = rop2Paint(state.rop2);
44985
46114
  const bk = state.bkMode === 2 && styleGapsUseBackground(flags);
44986
46115
  const segs2 = [];
44987
- path.figures.forEach((f, fi) => {
46116
+ path.figures.forEach((f2, fi) => {
44988
46117
  if (fi > 0) {
44989
46118
  style.pos = 0;
44990
46119
  }
44991
- const p = f.closed ? [...f.pts, f.pts[0], f.pts[1]] : f.pts;
46120
+ const p = f2.closed ? [...f2.pts, f2.pts[0], f2.pts[1]] : f2.pts;
44992
46121
  for (let i = 0; i + 3 < p.length; i += 2) {
44993
46122
  let n = 0;
44994
46123
  cosmeticLine(p[i], p[i + 1], p[i + 2], p[i + 3], () => {
@@ -45010,10 +46139,10 @@ function strokeStyledCosmetic(rCtx, path, pattern, style) {
45010
46139
  for (const pass of bk ? ["bk", "fg"] : ["fg"]) {
45011
46140
  ctx.strokeStyle = rop2TransformColor(pass === "bk" ? state.bkColor : state.penColor, paint.colorTransform);
45012
46141
  for (const [x0, y0, x1, y1, pos, n] of segs2) {
45013
- const f = Math.hypot(x1 - x0, y1 - y0) / 16 / n;
46142
+ const f2 = Math.hypot(x1 - x0, y1 - y0) / 16 / n;
45014
46143
  if (pass === "fg") {
45015
- ctx.setLineDash(pattern.map((v) => v * f));
45016
- ctx.lineDashOffset = pos % period * f;
46144
+ ctx.setLineDash(pattern.map((v) => v * f2));
46145
+ ctx.lineDashOffset = pos % period * f2;
45017
46146
  } else {
45018
46147
  ctx.setLineDash([]);
45019
46148
  }
@@ -45279,6 +46408,25 @@ function tileIndex(i, n, mirror2) {
45279
46408
  const m = (i % (2 * n) + 2 * n) % (2 * n);
45280
46409
  return m < n ? m : 2 * n - 1 - m;
45281
46410
  }
46411
+ function flattenUnderMatrix(source, toTile, full) {
46412
+ const points = source.points.map((p) => toTile({ x: full[0] * p.x + full[2] * p.y + full[4], y: full[1] * p.x + full[3] * p.y + full[5] }));
46413
+ const out = [];
46414
+ for (let k = 0; k < points.length; k++) {
46415
+ if ((source.types[k] & 7) === 3 && k > 0 && k + 2 < points.length) {
46416
+ const curve = points.slice(k - 1, k + 3).flatMap((p) => [gdiplusFix(p.x), gdiplusFix(p.y)]);
46417
+ out[out.length - 1] = { x: curve[0] / 16, y: curve[1] / 16 };
46418
+ const flat = [];
46419
+ flattenBezierGdiplus(curve, flat);
46420
+ for (let q = 0; q < flat.length; q += 2) out.push({ x: flat[q] / 16, y: flat[q + 1] / 16 });
46421
+ k += 2;
46422
+ } else {
46423
+ out.push(points[k]);
46424
+ }
46425
+ }
46426
+ const n = out.length;
46427
+ if (n > 1 && out[0].x === out[n - 1].x && out[0].y === out[n - 1].y) out.pop();
46428
+ return out;
46429
+ }
45282
46430
  function fractionalTileSampler(shape, wrap, full) {
45283
46431
  if (Math.abs(full[1]) > 1e-9 || Math.abs(full[2]) > 1e-9 || full[0] <= 0 || full[3] <= 0) return null;
45284
46432
  if (!shape.boundaryArgb.every((color) => color === shape.boundaryArgb[0])) return null;
@@ -45286,7 +46434,7 @@ function fractionalTileSampler(shape, wrap, full) {
45286
46434
  let y0 = Infinity;
45287
46435
  let x1 = -Infinity;
45288
46436
  let y1 = -Infinity;
45289
- for (const point of shape.boundary) {
46437
+ for (const point of shape.source ? shape.source.points : shape.boundary) {
45290
46438
  const x = full[0] * point.x + full[4];
45291
46439
  const y = full[3] * point.y + full[5];
45292
46440
  x0 = Math.min(x0, x);
@@ -45306,7 +46454,8 @@ function fractionalTileSampler(shape, wrap, full) {
45306
46454
  });
45307
46455
  const inner = pathGradientSampler({
45308
46456
  ...shape,
45309
- boundary: shape.boundary.map(toTile),
46457
+ boundary: shape.source ? flattenUnderMatrix(shape.source, toTile, full) : shape.boundary.map(toTile),
46458
+ source: void 0,
45310
46459
  center: toTile(shape.center),
45311
46460
  transform: null
45312
46461
  }, "clamp", IDENTITY4, false, true);
@@ -45321,9 +46470,9 @@ function fractionalTileSampler(shape, wrap, full) {
45321
46470
  texels = new Float64Array(width * height * 4);
45322
46471
  for (let i = 0; i < width * height; i++) {
45323
46472
  const a = rgba[i * 4 + 3];
45324
- texels[i * 4] = rgba[i * 4] * a / 255;
45325
- texels[i * 4 + 1] = rgba[i * 4 + 1] * a / 255;
45326
- texels[i * 4 + 2] = rgba[i * 4 + 2] * a / 255;
46473
+ texels[i * 4] = Math.floor(rgba[i * 4] * a / 255 + 0.5);
46474
+ texels[i * 4 + 1] = Math.floor(rgba[i * 4 + 1] * a / 255 + 0.5);
46475
+ texels[i * 4 + 2] = Math.floor(rgba[i * 4 + 2] * a / 255 + 0.5);
45327
46476
  texels[i * 4 + 3] = a;
45328
46477
  }
45329
46478
  return texels;
@@ -45350,10 +46499,10 @@ function fractionalTileSampler(shape, wrap, full) {
45350
46499
  out[o] = out[o + 1] = out[o + 2] = out[o + 3] = 0;
45351
46500
  continue;
45352
46501
  }
45353
- const scale = coverage >= 255 ? 1 : 255 / coverage;
45354
- out[o] = Math.min(255, Math.floor(sample2(0) * scale + 0.5));
45355
- out[o + 1] = Math.min(255, Math.floor(sample2(1) * scale + 0.5));
45356
- out[o + 2] = Math.min(255, Math.floor(sample2(2) * scale + 0.5));
46502
+ for (let k = 0; k < 3; k++) {
46503
+ const premultiplied2 = Math.floor(sample2(k) + 0.5);
46504
+ out[o + k] = Math.min(255, coverage >= 255 ? premultiplied2 : Math.floor(premultiplied2 * 255 / alpha + 0.5));
46505
+ }
45357
46506
  out[o + 3] = alpha;
45358
46507
  }
45359
46508
  }
@@ -45383,14 +46532,26 @@ function pathGradientSampler(shape, wrap, device, strictOutside = true, straight
45383
46532
  const mirrorY = wrap === "tile-flip-y" || wrap === "tile-flip-xy";
45384
46533
  const bias = wrap === "clamp" ? CLAMP_EDGE_BIAS : 0;
45385
46534
  const tile = wrap === "clamp" ? null : tileDeviceRect(box, full);
45386
- return (x0, y0, w, h, out) => {
46535
+ return (x0, y0, w, h, out, coverage) => {
45387
46536
  const inside = tile !== null && x0 >= tile[0] && x0 + w <= tile[2] && y0 >= tile[1] && y0 + h <= tile[3];
45388
- const windowLeft = tile && !inside ? tile[0] : x0;
45389
- const windowRight = tile && !inside ? tile[2] : x0 + w;
46537
+ let windowLeft = tile && !inside ? tile[0] : x0;
46538
+ let windowRight = tile && !inside ? tile[2] : x0 + w;
45390
46539
  const bitmap = straightBitmap || tile !== null && !inside;
46540
+ const spans = coverage !== void 0 && !(tile && !inside);
45391
46541
  for (let j = 0; j < h; j++) {
45392
46542
  const dy = y0 + j;
46543
+ let runEnd = -1;
45393
46544
  for (let i = 0; i < w; i++) {
46545
+ if (spans && coverage[j * w + i]) {
46546
+ if (i >= runEnd) {
46547
+ let start = i;
46548
+ while (start > 0 && coverage[j * w + start - 1]) start--;
46549
+ runEnd = i;
46550
+ while (runEnd < w && coverage[j * w + runEnd]) runEnd++;
46551
+ windowLeft = x0 + start;
46552
+ windowRight = x0 + runEnd;
46553
+ }
46554
+ }
45394
46555
  const dx = x0 + i + bias;
45395
46556
  let bx = inv3[0] * dx + inv3[2] * dy + inv3[4];
45396
46557
  let by = inv3[1] * dx + inv3[3] * dy + inv3[5];
@@ -46021,8 +47182,8 @@ function handleMoveToEx(rCtx, dataOff, recSize) {
46021
47182
  if (inPath) {
46022
47183
  const p = hasWorldRotation(rCtx) ? gmapPoint(rCtx, state.curX, state.curY) : { x: gmx(rCtx, state.curX), y: gmy(rCtx, state.curY) };
46023
47184
  gdiPathRecorder(rCtx).moveTo(p.x, p.y);
46024
- const f = fixPoint(rCtx, state.curX, state.curY);
46025
- rasterPathOf(rCtx).moveTo(f[0], f[1]);
47185
+ const f2 = fixPoint(rCtx, state.curX, state.curY);
47186
+ rasterPathOf(rCtx).moveTo(f2[0], f2[1]);
46026
47187
  }
46027
47188
  }
46028
47189
  return true;
@@ -46179,7 +47340,7 @@ function rectangleInterior(state, x, y, w, h, scale = 1) {
46179
47340
  c.rect(x0 + 1, y0 + 1, iw, ih);
46180
47341
  };
46181
47342
  }
46182
- var KAPPA2 = 0.5522847498307936;
47343
+ var KAPPA3 = 0.5522847498307936;
46183
47344
  function appendRoundRectPath(c, x0, y0, x1, y1, rx, ry, map) {
46184
47345
  const left = Math.min(x0, x1);
46185
47346
  const right = Math.max(x0, x1);
@@ -46227,8 +47388,8 @@ function appendRoundRectPath(c, x0, y0, x1, y1, rx, ry, map) {
46227
47388
  c.closePath();
46228
47389
  return;
46229
47390
  }
46230
- const kx = ex * KAPPA2;
46231
- const ky = ey * KAPPA2;
47391
+ const kx = ex * KAPPA3;
47392
+ const ky = ey * KAPPA3;
46232
47393
  move(left + ex, top);
46233
47394
  line(right - ex, top);
46234
47395
  curve(right - ex + kx, top, right, top + ey - ky, right, top + ey);
@@ -46764,14 +47925,14 @@ var WHITE_D = WHITE[0] + 15 * WHITE[1] + 3 * WHITE[2];
46764
47925
  var WHITE_U = 4 * WHITE[0] / WHITE_D;
46765
47926
  var WHITE_V = 9 * WHITE[1] / WHITE_D;
46766
47927
  function invert3(m) {
46767
- const [[a, b, c], [d, e, f], [g, h, i]] = m;
46768
- const A = e * i - f * h;
46769
- const B = f * g - d * i;
47928
+ const [[a, b, c], [d, e, f2], [g, h, i]] = m;
47929
+ const A = e * i - f2 * h;
47930
+ const B = f2 * g - d * i;
46770
47931
  const C = d * h - e * g;
46771
47932
  const det = a * A + b * B + c * C;
46772
47933
  return [
46773
- [A / det, (c * h - b * i) / det, (b * f - c * e) / det],
46774
- [B / det, (a * i - c * g) / det, (c * d - a * f) / det],
47934
+ [A / det, (c * h - b * i) / det, (b * f2 - c * e) / det],
47935
+ [B / det, (a * i - c * g) / det, (c * d - a * f2) / det],
46775
47936
  [C / det, (b * g - a * h) / det, (a * e - b * d) / det]
46776
47937
  ];
46777
47938
  }
@@ -46817,7 +47978,7 @@ function chromaTieTable(ca) {
46817
47978
  table2 = null;
46818
47979
  if (flips) {
46819
47980
  table2 = new Int8Array(32768 * 3);
46820
- for (const f of flips) table2[f >> 1] = f & 1 ? 1 : -1;
47981
+ for (const f2 of flips) table2[f2 >> 1] = f2 & 1 ? 1 : -1;
46821
47982
  }
46822
47983
  chromaTieTables.set(key, table2);
46823
47984
  }
@@ -50007,7 +51168,11 @@ function compositeGlyphs(ctx, placed, color, gray, clip, opaque = false) {
50007
51168
  const dx = p.x + x - x0;
50008
51169
  if (dx < 0 || dx >= w) continue;
50009
51170
  const i = dy * w + dx;
50010
- if (v > cov[i]) cov[i] = v;
51171
+ if (gray && cov[i]) {
51172
+ cov[i] = ((cov[i] - 1 | v - 1) & 15) + 1;
51173
+ } else if (v > cov[i]) {
51174
+ cov[i] = v;
51175
+ }
50011
51176
  }
50012
51177
  }
50013
51178
  }
@@ -50071,7 +51236,7 @@ function deviceLogFont(state, heightScale, widthScale) {
50071
51236
  };
50072
51237
  }
50073
51238
  function drawGdiTextCall(ctx, fonts, state, call) {
50074
- const [a, b, c, d, e, f] = call.matrix;
51239
+ const [a, b, c, d, e, f2] = call.matrix;
50075
51240
  const advanceScale = Math.hypot(a, b);
50076
51241
  const fontScale = Math.hypot(c, d);
50077
51242
  if (!(advanceScale > 0) || !(fontScale > 0) || call.codes.length === 0) {
@@ -50103,10 +51268,14 @@ function drawGdiTextCall(ctx, fonts, state, call) {
50103
51268
  glyphFrame = compose(table2.sin, table2.cos);
50104
51269
  frame2 = compose(Math.sin(t), Math.cos(t));
50105
51270
  }
51271
+ if (glyphFrame && call.playbackStretch && call.playbackStretch !== 1) {
51272
+ const k = call.playbackStretch;
51273
+ glyphFrame = [glyphFrame[0] * k, glyphFrame[1] * k, glyphFrame[2], glyphFrame[3]];
51274
+ }
50106
51275
  const updateCp = (state.textAlign & 1) !== 0;
50107
51276
  const lx = updateCp ? state.curX : call.x;
50108
51277
  const ly = updateCp ? state.curY : call.y;
50109
- const map = (x, y) => ({ x: a * x + c * y + e, y: b * x + d * y + f });
51278
+ const map = (x, y) => ({ x: a * x + c * y + e, y: b * x + d * y + f2 });
50110
51279
  const ref = map(lx, ly);
50111
51280
  let rect = null;
50112
51281
  if (call.rect && call.options & (ETO_OPAQUE | ETO_CLIPPED)) {
@@ -50250,15 +51419,15 @@ function gdiTextCoverage(font, run, options2 = {}) {
50250
51419
  const end = x + Math.round(total);
50251
51420
  const snapped = run.plusBars === "snapped" && font.exactDecorations ? fractionalBars(font.exactDecorations, run, run.x + startAlong, run.y + baseDown, total) : null;
50252
51421
  let barIndex = 0;
50253
- const add2 = (position, thickness) => {
51422
+ const add3 = (position, thickness) => {
50254
51423
  const top = Math.round(run.y + baseDown) - position;
50255
51424
  const snap = snapped?.[barIndex++];
50256
51425
  const l = snap ? Math.round(snap.left) : x;
50257
51426
  const r = snap ? Math.round(snap.right) : end;
50258
51427
  bars.push({ left: Math.min(l, r), right: Math.max(l, r), top, bottom: top + Math.max(1, thickness) });
50259
51428
  };
50260
- if (run.underline) add2(font.underlinePosition, font.underlineThickness);
50261
- if (run.strikeOut) add2(font.strikeoutPosition, font.strikeoutThickness);
51429
+ if (run.underline) add3(font.underlinePosition, font.underlineThickness);
51430
+ if (run.strikeOut) add3(font.strikeoutPosition, font.strikeoutThickness);
50262
51431
  }
50263
51432
  if (placed.length === 0 && bars.length === 0 && softBars.length === 0) {
50264
51433
  return null;
@@ -51485,9 +52654,9 @@ function handlePolyDraw(rCtx, offset, dataOff, recSize, pointSize) {
51485
52654
  if (kind === PT_MOVETO) {
51486
52655
  const [x, y] = readPt(i);
51487
52656
  const p = gmapPoint(rCtx, x, y);
51488
- const f = fixPoint(rCtx, x, y);
52657
+ const f2 = fixPoint(rCtx, x, y);
51489
52658
  canvas?.moveTo(p.x, p.y);
51490
- raster?.moveTo(f[0], f[1]);
52659
+ raster?.moveTo(f2[0], f2[1]);
51491
52660
  open = true;
51492
52661
  continue;
51493
52662
  }
@@ -51495,9 +52664,9 @@ function handlePolyDraw(rCtx, offset, dataOff, recSize, pointSize) {
51495
52664
  ensureOpen();
51496
52665
  const [x, y] = readPt(i);
51497
52666
  const p = gmapPoint(rCtx, x, y);
51498
- const f = fixPoint(rCtx, x, y);
52667
+ const f2 = fixPoint(rCtx, x, y);
51499
52668
  canvas?.lineTo(p.x, p.y);
51500
- raster?.lineTo(f[0], f[1]);
52669
+ raster?.lineTo(f2[0], f2[1]);
51501
52670
  } else if (kind === PT_BEZIERTO && i + 2 < count) {
51502
52671
  ensureOpen();
51503
52672
  const pts = [0, 1, 2].map((k) => readPt(i + k));
@@ -51570,8 +52739,8 @@ function paintBracketPath(rCtx, fill2, stroke) {
51570
52739
  if (close) {
51571
52740
  const closed = new GdiRasterPath();
51572
52741
  closed.append(raster);
51573
- for (const f of closed.figures) {
51574
- f.closed = true;
52742
+ for (const f2 of closed.figures) {
52743
+ f2.closed = true;
51575
52744
  }
51576
52745
  raster = closed;
51577
52746
  }
@@ -51589,11 +52758,11 @@ function discardPath(rCtx) {
51589
52758
  }
51590
52759
  function syncPathCmds(rCtx) {
51591
52760
  const cmds = [];
51592
- for (const f of rCtx.rasterPath?.figures ?? []) {
51593
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
51594
- cmds.push({ op: i === 0 ? "moveTo" : "lineTo", x: f.pts[i] / 16, y: f.pts[i + 1] / 16 });
52761
+ for (const f2 of rCtx.rasterPath?.figures ?? []) {
52762
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
52763
+ cmds.push({ op: i === 0 ? "moveTo" : "lineTo", x: f2.pts[i] / 16, y: f2.pts[i + 1] / 16 });
51595
52764
  }
51596
- if (f.closed) {
52765
+ if (f2.closed) {
51597
52766
  cmds.push({ op: "closePath" });
51598
52767
  }
51599
52768
  }
@@ -51603,10 +52772,10 @@ function flattenBracketPath(rCtx) {
51603
52772
  if (rCtx.inPath || !rCtx.rasterPath) {
51604
52773
  return;
51605
52774
  }
51606
- for (const f of rCtx.rasterPath.figures) {
51607
- delete f.tangents;
51608
- delete f.curveSegs;
51609
- delete f.roundWiden;
52775
+ for (const f2 of rCtx.rasterPath.figures) {
52776
+ delete f2.tangents;
52777
+ delete f2.curveSegs;
52778
+ delete f2.roundWiden;
51610
52779
  }
51611
52780
  syncPathCmds(rCtx);
51612
52781
  }
@@ -52591,12 +53760,12 @@ function nearestFix2(v) {
52591
53760
  function leafMask(build, m, evenOdd, box, half) {
52592
53761
  let figures;
52593
53762
  try {
52594
- figures = recordDeviceFigures(build, m).map((f) => f.pts.map(nearestFix2));
53763
+ figures = recordDeviceFigures(build, m).map((f2) => f2.pts.map(nearestFix2));
52595
53764
  } catch {
52596
53765
  return null;
52597
53766
  }
52598
53767
  const coverage = rasterizePlusFill(
52599
- figures.filter((f) => f.length >= 6),
53768
+ figures.filter((f2) => f2.length >= 6),
52600
53769
  evenOdd,
52601
53770
  false,
52602
53771
  half,
@@ -52707,7 +53876,7 @@ function insetStrokeCoverage(strokeGroups, figureFix, antialias, half, box, even
52707
53876
  }
52708
53877
  return mask;
52709
53878
  });
52710
- const shifted2 = half ? open.map((f) => f.map((v) => v - 8)) : open;
53879
+ const shifted2 = half ? open.map((f2) => f2.map((v) => v - 8)) : open;
52711
53880
  return rasterizePlusFill([...masks.flatMap((mask) => insetMaskOutline(mask, box.w, box.h, box.x, box.y)), ...shifted2], false, antialias, false, box);
52712
53881
  }
52713
53882
  function insetMaskOutline(mask, w, h, ox, oy) {
@@ -53253,7 +54422,7 @@ function strokeGdiplus(rCtx, pen, nib, sampler, buildPath, device, size, mode, c
53253
54422
  return false;
53254
54423
  }
53255
54424
  if (closedFigure) {
53256
- figures = figures.map((f) => ({ ...f, closed: true }));
54425
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53257
54426
  }
53258
54427
  const width = (pen.width || 1) * frame2.unit;
53259
54428
  const devicePen = framePen(pen, frame2.unit, nib);
@@ -53285,15 +54454,15 @@ function strokeGdiplus(rCtx, pen, nib, sampler, buildPath, device, size, mode, c
53285
54454
  return compositeBrushCoverage(rCtx, sampler, box, coverage, 1, true);
53286
54455
  }
53287
54456
  function widenedPen(figures, devicePen, toFix) {
53288
- const closedFigures = figures.filter((f) => f.closed);
54457
+ const closedFigures = figures.filter((f2) => f2.closed);
53289
54458
  if (!devicePen.inset || devicePen.compound || closedFigures.length === 0) {
53290
54459
  const fix = widenFigures(figures, devicePen).map(toFix);
53291
54460
  return { fix, groups: [fix], insetFigures: null, open: [] };
53292
54461
  }
53293
54462
  const widenPen = { ...devicePen, inset: false, half: devicePen.half * 2, dashOffset: devicePen.dashOffset * 2, dashCapWidth: devicePen.half * 2, doubleRoundCap: true };
53294
- const groups = closedFigures.map((f) => widenFigures([f], widenPen).map(toFix));
54463
+ const groups = closedFigures.map((f2) => widenFigures([f2], widenPen).map(toFix));
53295
54464
  const open = widenFigures(
53296
- figures.filter((f) => !f.closed),
54465
+ figures.filter((f2) => !f2.closed),
53297
54466
  { ...devicePen, inset: false }
53298
54467
  ).map(toFix).map((poly) => {
53299
54468
  const reversed2 = [];
@@ -53302,7 +54471,7 @@ function widenedPen(figures, devicePen, toFix) {
53302
54471
  }
53303
54472
  return reversed2;
53304
54473
  });
53305
- const insetFigures = figures.map((f) => toFix(Array.from({ length: f.pts.length >> 1 }, (_, i) => ({ x: f.pts[2 * i], y: f.pts[2 * i + 1] }))));
54474
+ const insetFigures = figures.map((f2) => toFix(Array.from({ length: f2.pts.length >> 1 }, (_, i) => ({ x: f2.pts[2 * i], y: f2.pts[2 * i + 1] }))));
53306
54475
  return { fix: [...groups.flat(), ...open], groups, insetFigures, open };
53307
54476
  }
53308
54477
  function strokeNominal(rCtx, pen, sampler, buildPath, device, size, antialias, closedFigure) {
@@ -53313,10 +54482,10 @@ function strokeNominal(rCtx, pen, sampler, buildPath, device, size, antialias, c
53313
54482
  return false;
53314
54483
  }
53315
54484
  if (closedFigure) {
53316
- figures = figures.map((f) => ({ ...f, closed: true }));
54485
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53317
54486
  }
53318
54487
  const box = figuresBox(
53319
- figures.map((f) => f.pts),
54488
+ figures.map((f2) => f2.pts),
53320
54489
  size
53321
54490
  );
53322
54491
  if (!box) {
@@ -53372,7 +54541,7 @@ function penOutlineWorld(rCtx, pen, nib, buildPath, closedFigure) {
53372
54541
  return null;
53373
54542
  }
53374
54543
  if (closedFigure) {
53375
- figures = figures.map((f) => ({ ...f, closed: true }));
54544
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53376
54545
  }
53377
54546
  const width = (pen.width || 1) * frame2.unit;
53378
54547
  const devicePen = framePen(pen, frame2.unit, nib);
@@ -53468,7 +54637,7 @@ function deviceQuad(wt, s, pts) {
53468
54637
  }
53469
54638
  return out;
53470
54639
  }
53471
- function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints) {
54640
+ function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints, worldRect) {
53472
54641
  const { view } = rCtx;
53473
54642
  const kernel = resampleKernelFor(rCtx.interpolationMode ?? 0);
53474
54643
  if (isMetafile || view.getUint32(dataOff + 4, true) !== UNIT_PIXEL2) {
@@ -53491,11 +54660,12 @@ function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalSc
53491
54660
  halfPixelOffset: isHalfPixelOffset(rCtx.pixelOffsetMode ?? 0),
53492
54661
  ...points ? { pointsForm: true } : {},
53493
54662
  ...points && worldPoints ? { worldPoints, worldMatrix: plusWorldMatrix(rCtx) } : {},
54663
+ ...!points && worldRect ? { worldRect, worldMatrix: plusWorldMatrix(rCtx) } : {},
53494
54664
  ...nominalScale ? { nominalScale: nominalScale(srcW, srcH) } : {},
53495
54665
  ...imageAttributesWrap(rCtx, view.getUint32(dataOff, true))
53496
54666
  };
53497
54667
  }
53498
- function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect = null, points = false, nominalScale, worldPoints) {
54668
+ function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect = null, points = false, nominalScale, worldPoints, worldRect) {
53499
54669
  if (!imgObj.data) {
53500
54670
  return;
53501
54671
  }
@@ -53508,7 +54678,7 @@ function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect
53508
54678
  dh,
53509
54679
  transform: plusWorldMatrix(rCtx),
53510
54680
  isMetafile,
53511
- resample: imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints)
54681
+ resample: imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints, worldRect)
53512
54682
  };
53513
54683
  const { view } = rCtx;
53514
54684
  const source = {
@@ -53964,7 +55134,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
53964
55134
  down32(dh / sh),
53965
55135
  dx - sx * dw / sw,
53966
55136
  dy - sy * dh / sh
53967
- ], null, false, (sw, sh) => [Math.fround(dw / sw), Math.fround(dh / sh)]);
55137
+ ], null, false, (sw, sh) => [Math.fround(dw / sw), Math.fround(dh / sh)], void 0, [dx, dy, dw, dh]);
53968
55138
  }
53969
55139
  }
53970
55140
  return true;
@@ -55155,10 +56325,10 @@ function replayNestedEmf(bytes, ctx, canvasW, canvasH, toCanvas, options2) {
55155
56325
  if (!header) {
55156
56326
  return null;
55157
56327
  }
55158
- const [a, b, c, d, e, f] = toCanvas;
56328
+ const [a, b, c, d, e, f2] = toCanvas;
55159
56329
  if (b === 0 && c === 0 && a > 0 && d > 0) {
55160
56330
  const left = -e / a;
55161
- const top = -f / d;
56331
+ const top = -f2 / d;
55162
56332
  const bounds2 = { left, top, right: left + canvasW / a, bottom: top + canvasH / d };
55163
56333
  return replayEmfRecords(view, ctx, bounds2, canvasW, canvasH, 1, options2);
55164
56334
  }
@@ -55718,15 +56888,15 @@ function selectObject(p, slot) {
55718
56888
  selectBrush(p, obj);
55719
56889
  break;
55720
56890
  case "font": {
55721
- const f = obj.font;
55722
- s.fontHeight = f.height;
55723
- s.fontWeight = f.weight;
55724
- s.fontItalic = f.italic;
55725
- s.fontUnderline = f.underline;
55726
- s.fontStrikeOut = f.strikeOut;
55727
- s.fontFamily = f.family;
55728
- s.fontEscapementTenthDeg = f.escapementTenthDeg ?? 0;
55729
- s.fontDetails = f.details;
56891
+ const f2 = obj.font;
56892
+ s.fontHeight = f2.height;
56893
+ s.fontWeight = f2.weight;
56894
+ s.fontItalic = f2.italic;
56895
+ s.fontUnderline = f2.underline;
56896
+ s.fontStrikeOut = f2.strikeOut;
56897
+ s.fontFamily = f2.family;
56898
+ s.fontEscapementTenthDeg = f2.escapementTenthDeg ?? 0;
56899
+ s.fontDetails = f2.details;
55730
56900
  break;
55731
56901
  }
55732
56902
  }
@@ -57809,14 +58979,14 @@ function winAnsiByte(cp) {
57809
58979
  return WIN_ANSI_HIGH[cp] ?? -1;
57810
58980
  }
57811
58981
  function standardFamilyFor(familyList) {
57812
- const f = familyList.toLowerCase();
57813
- if (/courier|mono|consolas|lucida console|terminal|fixedsys|andale|menlo|monaco|typewriter/.test(f)) {
58982
+ const f2 = familyList.toLowerCase();
58983
+ if (/courier|mono|consolas|lucida console|terminal|fixedsys|andale|menlo|monaco|typewriter/.test(f2)) {
57814
58984
  return "Courier";
57815
58985
  }
57816
- if (/sans|arial|helvet|verdana|tahoma|calibri|segoe|trebuchet|impact/.test(f)) {
58986
+ if (/sans|arial|helvet|verdana|tahoma|calibri|segoe|trebuchet|impact/.test(f2)) {
57817
58987
  return "Helvetica";
57818
58988
  }
57819
- if (/times|serif|georgia|garamond|palatino|cambria|book antiqua|century|bookman|minion|constantia|baskerville|didot/.test(f)) {
58989
+ if (/times|serif|georgia|garamond|palatino|cambria|book antiqua|century|bookman|minion|constantia|baskerville|didot/.test(f2)) {
57820
58990
  return "Times";
57821
58991
  }
57822
58992
  return "Helvetica";
@@ -58127,12 +59297,12 @@ var PdfFontBook = class {
58127
59297
  const want = bold ? 700 : 400;
58128
59298
  let best = faces[0];
58129
59299
  let bestScore = Infinity;
58130
- for (const f of faces) {
58131
- const isItalic = (f.ttf.fsSelection & 1) !== 0 || (f.ttf.macStyle & 2) !== 0;
58132
- const score2 = Math.abs(f.ttf.weightClass - want) + (isItalic !== italic ? 1e3 : 0);
59300
+ for (const f2 of faces) {
59301
+ const isItalic = (f2.ttf.fsSelection & 1) !== 0 || (f2.ttf.macStyle & 2) !== 0;
59302
+ const score2 = Math.abs(f2.ttf.weightClass - want) + (isItalic !== italic ? 1e3 : 0);
58133
59303
  if (score2 < bestScore) {
58134
59304
  bestScore = score2;
58135
- best = f;
59305
+ best = f2;
58136
59306
  }
58137
59307
  }
58138
59308
  return best;
@@ -58170,8 +59340,8 @@ var PdfFontBook = class {
58170
59340
  }
58171
59341
  /** Writes the subset programs and CID font objects of every embedded font. Call once, after all text is placed. */
58172
59342
  finish() {
58173
- for (const f of this.embeddedFonts) {
58174
- f.finish(this.writer, this.compress);
59343
+ for (const f2 of this.embeddedFonts) {
59344
+ f2.finish(this.writer, this.compress);
58175
59345
  }
58176
59346
  }
58177
59347
  };
@@ -58257,7 +59427,7 @@ function parseSvgMarkup(markup) {
58257
59427
 
58258
59428
  // src/pdf-svg.ts
58259
59429
  var IDENTITY6 = [1, 0, 0, 1, 0, 0];
58260
- function mul5(m, n) {
59430
+ function mul6(m, n) {
58261
59431
  return [
58262
59432
  m[0] * n[0] + m[2] * n[1],
58263
59433
  m[1] * n[0] + m[3] * n[1],
@@ -58305,11 +59475,11 @@ function parseTransform(value) {
58305
59475
  const s = Math.sin(r);
58306
59476
  n = [c, s, -s, c, 0, 0];
58307
59477
  if (a.length === 3) {
58308
- n = mul5(mul5([1, 0, 0, 1, a[1], a[2]], n), [1, 0, 0, 1, -a[1], -a[2]]);
59478
+ n = mul6(mul6([1, 0, 0, 1, a[1], a[2]], n), [1, 0, 0, 1, -a[1], -a[2]]);
58309
59479
  }
58310
59480
  }
58311
59481
  if (n && n.every(Number.isFinite)) {
58312
- m = mul5(m, n);
59482
+ m = mul6(m, n);
58313
59483
  }
58314
59484
  }
58315
59485
  return m;
@@ -58826,7 +59996,7 @@ var PdfBuilder = class {
58826
59996
  }
58827
59997
  const bounds = pts.slice(1, -1).map((p) => num(p.offset));
58828
59998
  return this.writer.add(
58829
- `<< /FunctionType 3 /Domain [0 1] /Functions [${fns.map((f) => `${f} 0 R`).join(" ")}] /Bounds [${bounds.join(" ")}] /Encode [${fns.map(() => "0 1").join(" ")}] >>`
59999
+ `<< /FunctionType 3 /Domain [0 1] /Functions [${fns.map((f2) => `${f2} 0 R`).join(" ")}] /Bounds [${bounds.join(" ")}] /Encode [${fns.map(() => "0 1").join(" ")}] >>`
58830
60000
  );
58831
60001
  }
58832
60002
  /**
@@ -58907,8 +60077,8 @@ var PdfBuilder = class {
58907
60077
  smask = this.alphaMask(c, node, stops, gt, ctm);
58908
60078
  }
58909
60079
  const pattern = this.cached(
58910
- `gp:${node.attrs.id}:${mul5(ctm, gt).map(num).join(",")}`,
58911
- () => this.writer.add(`<< /Type /Pattern /PatternType 2 /Shading ${shading} 0 R /Matrix [${mul5(ctm, gt).map(num).join(" ")}] >>`)
60080
+ `gp:${node.attrs.id}:${mul6(ctm, gt).map(num).join(",")}`,
60081
+ () => this.writer.add(`<< /Type /Pattern /PatternType 2 /Shading ${shading} 0 R /Matrix [${mul6(ctm, gt).map(num).join(" ")}] >>`)
58912
60082
  );
58913
60083
  colorOp = `/Pattern ${stroke ? "CS" : "cs"} ${c.res.use("Pattern", pattern)} ${stroke ? "SCN" : "scn"}`;
58914
60084
  }
@@ -58977,7 +60147,7 @@ var PdfBuilder = class {
58977
60147
  if (tw <= 0 || th <= 0) {
58978
60148
  return null;
58979
60149
  }
58980
- const m = mul5(ctm, parseTransform(p.attrs.patternTransform));
60150
+ const m = mul6(ctm, parseTransform(p.attrs.patternTransform));
58981
60151
  return this.cached(`tp:${p.attrs.id}:${m.map(num).join(",")}`, () => {
58982
60152
  const tile = { ops: [], res: new Resources(), bounds: [0, 0, tw, th] };
58983
60153
  for (const child of p.children ?? []) {
@@ -59037,7 +60207,7 @@ var PdfBuilder = class {
59037
60207
  if (node.attrs.transform !== void 0) {
59038
60208
  const t = parseTransform(node.attrs.transform);
59039
60209
  c.ops.push(matrixOp(t));
59040
- m = mul5(ctm, t);
60210
+ m = mul6(ctm, t);
59041
60211
  }
59042
60212
  this.clipOps(c, node.attrs["clip-path"], scope);
59043
60213
  for (const child of node.children ?? []) {
@@ -59068,7 +60238,7 @@ var PdfBuilder = class {
59068
60238
  const style = parseStyleAttr(a.style);
59069
60239
  const blend = BLEND_NAMES[style["mix-blend-mode"]] ?? null;
59070
60240
  const t = a.transform !== void 0 ? parseTransform(a.transform) : null;
59071
- const m = t ? mul5(ctm, t) : ctm;
60241
+ const m = t ? mul6(ctm, t) : ctm;
59072
60242
  if (!isFinite(m[0] + m[3]) || m[0] * m[3] - m[1] * m[2] === 0) {
59073
60243
  return;
59074
60244
  }
@@ -59181,7 +60351,7 @@ var PdfBuilder = class {
59181
60351
  const families = String(a["font-family"] ?? "sans-serif");
59182
60352
  const font = this.fontBook.resolve(families, bold, italic);
59183
60353
  const t = a.transform !== void 0 ? parseTransform(a.transform) : null;
59184
- const m = t ? mul5(ctm, t) : ctm;
60354
+ const m = t ? mul6(ctm, t) : ctm;
59185
60355
  c.ops.push("q");
59186
60356
  if (t) {
59187
60357
  c.ops.push(matrixOp(t));
@@ -59277,7 +60447,7 @@ async function svgTreeToPdf(tree, options2 = {}) {
59277
60447
  offY = (pageH - heightPx * scale) / 2;
59278
60448
  }
59279
60449
  const toPage = [scale, 0, 0, -scale, offX, pageH - offY];
59280
- const base = mul5(toPage, toPx);
60450
+ const base = mul6(toPage, toPx);
59281
60451
  const content = { ops: [], res: new Resources(), bounds: [0, 0, pageW, pageH] };
59282
60452
  const scope = { defs: /* @__PURE__ */ new Map() };
59283
60453
  indexIds(tree, scope.defs);
@@ -59373,9 +60543,9 @@ async function loadSystemFonts(options2 = {}) {
59373
60543
  await walk2(d, 0);
59374
60544
  }
59375
60545
  const out = [];
59376
- for (const f of files) {
60546
+ for (const f2 of files) {
59377
60547
  try {
59378
- out.push(new Uint8Array(await fs.readFile(f)));
60548
+ out.push(new Uint8Array(await fs.readFile(f2)));
59379
60549
  } catch {
59380
60550
  }
59381
60551
  }
@@ -59501,12 +60671,12 @@ function addImage(scan, mime) {
59501
60671
  scan.mimeTypes.add(mime);
59502
60672
  }
59503
60673
  function mergeNested(scan, inner) {
59504
- for (const f of inner.fonts.values()) {
59505
- if (f.gdi) {
59506
- addFont(scan, f.name, "gdi");
60674
+ for (const f2 of inner.fonts.values()) {
60675
+ if (f2.gdi) {
60676
+ addFont(scan, f2.name, "gdi");
59507
60677
  }
59508
- if (f.emfPlus) {
59509
- addFont(scan, f.name, "emfPlus");
60678
+ if (f2.emfPlus) {
60679
+ addFont(scan, f2.name, "emfPlus");
59510
60680
  }
59511
60681
  }
59512
60682
  scan.hasText || (scan.hasText = inner.hasText);
@@ -59810,10 +60980,10 @@ function inspectWmf(view, opts) {
59810
60980
  width = inner.width;
59811
60981
  height = inner.height;
59812
60982
  description = inner.description;
59813
- for (const f of inner.fonts) {
59814
- addFont(scan, f.name, f.gdi ? "gdi" : "emfPlus");
59815
- if (f.gdi && f.emfPlus) {
59816
- addFont(scan, f.name, "emfPlus");
60983
+ for (const f2 of inner.fonts) {
60984
+ addFont(scan, f2.name, f2.gdi ? "gdi" : "emfPlus");
60985
+ if (f2.gdi && f2.emfPlus) {
60986
+ addFont(scan, f2.name, "emfPlus");
59817
60987
  }
59818
60988
  }
59819
60989
  scan.hasText || (scan.hasText = inner.hasText);