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/browser.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];
@@ -16863,10 +17058,10 @@ function polygonTrig(angle) {
16863
17058
  }
16864
17059
  const x = Math.fround(b / TRIG_STEP);
16865
17060
  const i = Math.min(127, Math.floor(x));
16866
- const f = x - i;
17061
+ const f2 = x - i;
16867
17062
  return [
16868
- POLYGON_NODES.cos[i] * (1 - f) + POLYGON_NODES.cos[i + 1] * f,
16869
- POLYGON_NODES.sin[i] * (1 - f) + POLYGON_NODES.sin[i + 1] * f
17063
+ POLYGON_NODES.cos[i] * (1 - f2) + POLYGON_NODES.cos[i + 1] * f2,
17064
+ POLYGON_NODES.sin[i] * (1 - f2) + POLYGON_NODES.sin[i + 1] * f2
16870
17065
  ];
16871
17066
  }
16872
17067
  var ATAN_KNOTS = Array.from({ length: 33 }, (_, j) => Math.atan(j / 32));
@@ -16892,21 +17087,21 @@ function unitPiece(from, to, small, radius = Infinity) {
16892
17087
  const p0 = trig(from);
16893
17088
  const p3 = trig(to);
16894
17089
  if (small && 6e-8 * radius / Math.abs(Math.sin(to - from)) > 0.5) {
16895
- const f = Math.fround;
16896
- const q0 = [f(p0[0]), f(p0[1])];
16897
- const q3 = [f(p3[0]), f(p3[1])];
16898
- const det32 = f(f(q0[0] * q3[1]) - f(q0[1] * q3[0]));
17090
+ const f2 = Math.fround;
17091
+ const q0 = [f2(p0[0]), f2(p0[1])];
17092
+ const q3 = [f2(p3[0]), f2(p3[1])];
17093
+ const det32 = f2(f2(q0[0] * q3[1]) - f2(q0[1] * q3[0]));
16899
17094
  if (det32 !== 0) {
16900
- const X = [f(f(q3[1] - q0[1]) / det32), f(f(q0[0] - q3[0]) / det32)];
16901
- const c = f(polygonTrig(Math.abs(to - from) / 2)[0]);
16902
- const kappa = f(f(f(4 / 3) * c) / f(1 + c));
17095
+ const X = [f2(f2(q3[1] - q0[1]) / det32), f2(f2(q0[0] - q3[0]) / det32)];
17096
+ const c = f2(polygonTrig(Math.abs(to - from) / 2)[0]);
17097
+ const kappa = f2(f2(f2(4 / 3) * c) / f2(1 + c));
16903
17098
  return {
16904
17099
  start: p0,
16905
17100
  ctrl: [
16906
- f(q0[0] + f(kappa * f(X[0] - q0[0]))),
16907
- f(q0[1] + f(kappa * f(X[1] - q0[1]))),
16908
- f(q3[0] + f(kappa * f(X[0] - q3[0]))),
16909
- f(q3[1] + f(kappa * f(X[1] - q3[1]))),
17101
+ f2(q0[0] + f2(kappa * f2(X[0] - q0[0]))),
17102
+ f2(q0[1] + f2(kappa * f2(X[1] - q0[1]))),
17103
+ f2(q3[0] + f2(kappa * f2(X[0] - q3[0]))),
17104
+ f2(q3[1] + f2(kappa * f2(X[1] - q3[1]))),
16910
17105
  p3[0],
16911
17106
  p3[1]
16912
17107
  ]
@@ -17038,8 +17233,8 @@ var GdiRasterPath = class {
17038
17233
  * `GetPath`, Wine `gdi32/tests/path.c`, `test_all_functions`).
17039
17234
  */
17040
17235
  continueAt(x, y) {
17041
- const f = this.current;
17042
- if (f && f.pts[f.pts.length - 2] === x && f.pts[f.pts.length - 1] === y) {
17236
+ const f2 = this.current;
17237
+ if (f2 && f2.pts[f2.pts.length - 2] === x && f2.pts[f2.pts.length - 1] === y) {
17043
17238
  return;
17044
17239
  }
17045
17240
  this.moveTo(x, y);
@@ -17075,17 +17270,17 @@ var GdiRasterPath = class {
17075
17270
  }
17076
17271
  /** Flattens one Bezier onto the open figure, recording its end tangents. */
17077
17272
  flattenInto(x0, y0, c1x, c1y, c2x, c2y, x3, y3) {
17078
- const f = this.current;
17079
- const first = f.pts.length / 2 - 1;
17080
- flattenBezier(x0, y0, c1x, c1y, c2x, c2y, x3, y3, f.pts);
17081
- const last = f.pts.length / 2 - 2;
17273
+ const f2 = this.current;
17274
+ const first = f2.pts.length / 2 - 1;
17275
+ flattenBezier(x0, y0, c1x, c1y, c2x, c2y, x3, y3, f2.pts);
17276
+ const last = f2.pts.length / 2 - 2;
17082
17277
  if (last <= first) {
17083
17278
  if (last === first) {
17084
- const n = f.pts.length;
17085
- f.tangents ?? (f.tangents = /* @__PURE__ */ new Map());
17086
- f.tangentRoles ?? (f.tangentRoles = /* @__PURE__ */ new Map());
17087
- f.tangents.set(first, [f.pts[n - 2] - f.pts[n - 4], f.pts[n - 1] - f.pts[n - 3]]);
17088
- f.tangentRoles.set(first, 3);
17279
+ const n = f2.pts.length;
17280
+ f2.tangents ?? (f2.tangents = /* @__PURE__ */ new Map());
17281
+ f2.tangentRoles ?? (f2.tangentRoles = /* @__PURE__ */ new Map());
17282
+ f2.tangents.set(first, [f2.pts[n - 2] - f2.pts[n - 4], f2.pts[n - 1] - f2.pts[n - 3]]);
17283
+ f2.tangentRoles.set(first, 3);
17089
17284
  }
17090
17285
  return;
17091
17286
  }
@@ -17097,19 +17292,19 @@ var GdiRasterPath = class {
17097
17292
  };
17098
17293
  const t0 = tangent(x0, y0, c1x, c1y, c2x, c2y, x3, y3);
17099
17294
  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);
17100
- f.curveSegs ?? (f.curveSegs = /* @__PURE__ */ new Set());
17295
+ f2.curveSegs ?? (f2.curveSegs = /* @__PURE__ */ new Set());
17101
17296
  for (let k = first; k <= last; k++) {
17102
- f.curveSegs.add(k);
17297
+ f2.curveSegs.add(k);
17103
17298
  }
17104
- f.tangents ?? (f.tangents = /* @__PURE__ */ new Map());
17105
- f.tangentRoles ?? (f.tangentRoles = /* @__PURE__ */ new Map());
17299
+ f2.tangents ?? (f2.tangents = /* @__PURE__ */ new Map());
17300
+ f2.tangentRoles ?? (f2.tangentRoles = /* @__PURE__ */ new Map());
17106
17301
  if (t0) {
17107
- f.tangents.set(first, t0);
17108
- f.tangentRoles.set(first, 1);
17302
+ f2.tangents.set(first, t0);
17303
+ f2.tangentRoles.set(first, 1);
17109
17304
  }
17110
17305
  if (t1) {
17111
- f.tangents.set(last, t1);
17112
- f.tangentRoles.set(last, 2);
17306
+ f2.tangents.set(last, t1);
17307
+ f2.tangentRoles.set(last, 2);
17113
17308
  }
17114
17309
  }
17115
17310
  /**
@@ -17140,8 +17335,8 @@ var GdiRasterPath = class {
17140
17335
  }
17141
17336
  /** Appends every figure of `other`. */
17142
17337
  append(other) {
17143
- for (const f of other.figures) {
17144
- 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 });
17338
+ for (const f2 of other.figures) {
17339
+ 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 });
17145
17340
  }
17146
17341
  for (let i = 0; i < other.getPath.types.length; i++) {
17147
17342
  this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
@@ -17149,16 +17344,16 @@ var GdiRasterPath = class {
17149
17344
  this.current = null;
17150
17345
  }
17151
17346
  lastPoint() {
17152
- const f = this.figures[this.figures.length - 1];
17153
- if (!f) {
17347
+ const f2 = this.figures[this.figures.length - 1];
17348
+ if (!f2) {
17154
17349
  return null;
17155
17350
  }
17156
- return f.closed ? [f.pts[0], f.pts[1]] : [f.pts[f.pts.length - 2], f.pts[f.pts.length - 1]];
17351
+ return f2.closed ? [f2.pts[0], f2.pts[1]] : [f2.pts[f2.pts.length - 2], f2.pts[f2.pts.length - 1]];
17157
17352
  }
17158
17353
  };
17159
17354
  function fillPathSpans(path, winding, out) {
17160
17355
  return fillPolygonSpans(
17161
- path.figures.map((f) => f.pts),
17356
+ path.figures.map((f2) => f2.pts),
17162
17357
  winding,
17163
17358
  out
17164
17359
  );
@@ -17228,15 +17423,15 @@ function strokeCosmetic(path, on, off, pattern, style = { pos: 0 }, resetPerFigu
17228
17423
  p -= pattern[i];
17229
17424
  }
17230
17425
  };
17231
- path.figures.forEach((f, fi) => {
17426
+ path.figures.forEach((f2, fi) => {
17232
17427
  if (fi > 0 && resetPerFigure) {
17233
17428
  style.pos = 0;
17234
17429
  }
17235
- const p = f.pts;
17430
+ const p = f2.pts;
17236
17431
  for (let i = 0; i + 3 < p.length; i += 2) {
17237
17432
  cosmeticLine(p[i], p[i + 1], p[i + 2], p[i + 3], plot);
17238
17433
  }
17239
- if (f.closed && p.length >= 4) {
17434
+ if (f2.closed && p.length >= 4) {
17240
17435
  const n = p.length;
17241
17436
  if (p[n - 2] !== p[0] || p[n - 1] !== p[1]) {
17242
17437
  cosmeticLine(p[n - 2], p[n - 1], p[0], p[1], plot);
@@ -17583,7 +17778,7 @@ function accumulateLine(acc, mark, stride, rows, width, x0, y0, x1, y1) {
17583
17778
  if (top >= bottom) {
17584
17779
  return;
17585
17780
  }
17586
- const add2 = (row2, cell, v) => {
17781
+ const add3 = (row2, cell, v) => {
17587
17782
  const i = row2 * stride + cell;
17588
17783
  acc[i] += v;
17589
17784
  if (!mark[i]) {
@@ -17609,27 +17804,27 @@ function accumulateLine(acc, mark, stride, rows, width, x0, y0, x1, y1) {
17609
17804
  const hiCeil = Math.ceil(hi);
17610
17805
  if (hiCeil <= loFloor + 1) {
17611
17806
  const xmf = 0.5 * (x + xnext) - loFloor;
17612
- add2(row2, loFloor, d - d * xmf);
17613
- add2(row2, loFloor + 1, d * xmf);
17807
+ add3(row2, loFloor, d - d * xmf);
17808
+ add3(row2, loFloor + 1, d * xmf);
17614
17809
  } else {
17615
17810
  const s = 1 / (hi - lo);
17616
17811
  const x0f = lo - loFloor;
17617
17812
  const a0 = 0.5 * s * (1 - x0f) * (1 - x0f);
17618
17813
  const x1f = hi - hiCeil + 1;
17619
17814
  const am = 0.5 * s * x1f * x1f;
17620
- add2(row2, loFloor, d * a0);
17815
+ add3(row2, loFloor, d * a0);
17621
17816
  if (hiCeil === loFloor + 2) {
17622
- add2(row2, loFloor + 1, d * (1 - a0 - am));
17817
+ add3(row2, loFloor + 1, d * (1 - a0 - am));
17623
17818
  } else {
17624
17819
  const a1 = s * (1.5 - x0f);
17625
- add2(row2, loFloor + 1, d * (a1 - a0));
17820
+ add3(row2, loFloor + 1, d * (a1 - a0));
17626
17821
  for (let xi = loFloor + 2; xi < hiCeil - 1; xi++) {
17627
- add2(row2, xi, d * s);
17822
+ add3(row2, xi, d * s);
17628
17823
  }
17629
17824
  const a2 = a1 + (hiCeil - loFloor - 3) * s;
17630
- add2(row2, hiCeil - 1, d * (1 - a2 - am));
17825
+ add3(row2, hiCeil - 1, d * (1 - a2 - am));
17631
17826
  }
17632
- add2(row2, hiCeil, d * am);
17827
+ add3(row2, hiCeil, d * am);
17633
17828
  }
17634
17829
  x = xnext;
17635
17830
  }
@@ -17937,11 +18132,11 @@ function gradientColor(stops, t, out) {
17937
18132
  const a = stops[lo];
17938
18133
  const b = stops[hi];
17939
18134
  const span = b.offset - a.offset;
17940
- const f = span > 0 ? (t - a.offset) / span : 1;
17941
- const alpha = a.color[3] + (b.color[3] - a.color[3]) * f;
17942
- out[0] = (a.color[0] + (b.color[0] - a.color[0]) * f) * alpha;
17943
- out[1] = (a.color[1] + (b.color[1] - a.color[1]) * f) * alpha;
17944
- out[2] = (a.color[2] + (b.color[2] - a.color[2]) * f) * alpha;
18135
+ const f2 = span > 0 ? (t - a.offset) / span : 1;
18136
+ const alpha = a.color[3] + (b.color[3] - a.color[3]) * f2;
18137
+ out[0] = (a.color[0] + (b.color[0] - a.color[0]) * f2) * alpha;
18138
+ out[1] = (a.color[1] + (b.color[1] - a.color[1]) * f2) * alpha;
18139
+ out[2] = (a.color[2] + (b.color[2] - a.color[2]) * f2) * alpha;
17945
18140
  out[3] = alpha * 255;
17946
18141
  return;
17947
18142
  }
@@ -18868,13 +19063,13 @@ function unpremultiplyTable() {
18868
19063
  if (unpremultiplied) {
18869
19064
  return unpremultiplied;
18870
19065
  }
18871
- const f = Math.fround;
18872
- const inv255 = f(1 / 255);
19066
+ const f2 = Math.fround;
19067
+ const inv255 = f2(1 / 255);
18873
19068
  const table2 = new Uint8Array(256 * 256);
18874
19069
  for (let a = 1; a < 256; a++) {
18875
- const recip = f(1 / f(a * inv255));
19070
+ const recip = f2(1 / f2(a * inv255));
18876
19071
  for (let p = 0; p < 256; p++) {
18877
- const x = f(f(f(p * inv255) * recip) * 255);
19072
+ const x = f2(f2(f2(p * inv255) * recip) * 255);
18878
19073
  const clamped = Math.min(Math.max(x, 0), 255);
18879
19074
  const lo = Math.floor(clamped);
18880
19075
  const frac = clamped - lo;
@@ -19225,11 +19420,11 @@ var SoftwareRasterContext = class {
19225
19420
  }
19226
19421
  }
19227
19422
  getTransform() {
19228
- const [a, b, c, d, e, f] = this.state.transform;
19229
- return { a, b, c, d, e, f };
19423
+ const [a, b, c, d, e, f2] = this.state.transform;
19424
+ return { a, b, c, d, e, f: f2 };
19230
19425
  }
19231
- setTransform(a, b, c, d, e, f) {
19232
- 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];
19426
+ setTransform(a, b, c, d, e, f2) {
19427
+ 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];
19233
19428
  if (m.every(Number.isFinite)) {
19234
19429
  this.state.transform = m;
19235
19430
  }
@@ -19237,9 +19432,9 @@ var SoftwareRasterContext = class {
19237
19432
  resetTransform() {
19238
19433
  this.state.transform = [...IDENTITY_MATRIX];
19239
19434
  }
19240
- transform(a, b, c, d, e, f) {
19241
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
19242
- this.state.transform = multiplyMatrix(this.state.transform, [a, b, c, d, e, f]);
19435
+ transform(a, b, c, d, e, f2) {
19436
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
19437
+ this.state.transform = multiplyMatrix(this.state.transform, [a, b, c, d, e, f2]);
19243
19438
  }
19244
19439
  }
19245
19440
  translate(x, y) {
@@ -20658,15 +20853,15 @@ var FanTriangle = class {
20658
20853
  let b = bL;
20659
20854
  const cutLeft = sub(start, xl);
20660
20855
  if (Math.abs(cutLeft) > ALPHA_EPSILON) {
20661
- const f = div(cutLeft, n);
20662
- a = add(mul(sub(aR, aL), f), aL);
20663
- b = add(mul(sub(bR, bL), f), bL);
20856
+ const f2 = div(cutLeft, n);
20857
+ a = add(mul(sub(aR, aL), f2), aL);
20858
+ b = add(mul(sub(bR, bL), f2), bL);
20664
20859
  }
20665
20860
  const cutRight = sub(xr, end);
20666
20861
  if (Math.abs(cutRight) > ALPHA_EPSILON) {
20667
- const f = div(cutRight, n);
20668
- aR = sub(aR, mul(sub(aR, aL), f));
20669
- bR = sub(bR, mul(sub(bR, bL), f));
20862
+ const f2 = div(cutRight, n);
20863
+ aR = sub(aR, mul(sub(aR, aL), f2));
20864
+ bR = sub(bR, mul(sub(bR, bL), f2));
20670
20865
  }
20671
20866
  const count = end - start;
20672
20867
  const da = div(sub(aR, a), count);
@@ -20685,9 +20880,9 @@ var FanTriangle = class {
20685
20880
  const centre = adjust(sub(sub(1, a), b));
20686
20881
  const sum = add(b, a);
20687
20882
  if (sum !== 0) {
20688
- const f = div(sub(1, centre), sum);
20689
- wa = mul(a, f);
20690
- wb = mul(b, f);
20883
+ const f2 = div(sub(1, centre), sum);
20884
+ wa = mul(a, f2);
20885
+ wb = mul(b, f2);
20691
20886
  }
20692
20887
  }
20693
20888
  for (let q = 0; q < 4; q++) {
@@ -20891,7 +21086,7 @@ var BilinearQuad = class {
20891
21086
  }
20892
21087
  /** The pixel spans `[start, end)` of scanline `y` inside `[x0, x1)` (`GetXSpans`). */
20893
21088
  spans(y, x0, x1) {
20894
- if (this.constant < 0 && this.flags.every((f) => f === 0)) return [];
21089
+ if (this.constant < 0 && this.flags.every((f2) => f2 === 0)) return [];
20895
21090
  const yf = y;
20896
21091
  if (ja(this.minY, yf)) return [];
20897
21092
  if (jae(yf, add(this.minY, this.height))) return [];
@@ -21206,8 +21401,8 @@ function piecewise(xs, ys, x) {
21206
21401
  for (let i = 1; i < n; i++) {
21207
21402
  if (x <= xs[i]) {
21208
21403
  const span = xs[i] - xs[i - 1];
21209
- const f = span > 0 ? (x - xs[i - 1]) / span : 1;
21210
- return ys[i - 1] + (ys[i] - ys[i - 1]) * f;
21404
+ const f2 = span > 0 ? (x - xs[i - 1]) / span : 1;
21405
+ return ys[i - 1] + (ys[i] - ys[i - 1]) * f2;
21211
21406
  }
21212
21407
  }
21213
21408
  return ys[n - 1];
@@ -21221,12 +21416,12 @@ function premultiplied(argb, gamma) {
21221
21416
  };
21222
21417
  return [ch(16), ch(8), ch(0), a];
21223
21418
  }
21224
- function mix(c0, c1, f) {
21419
+ function mix(c0, c1, f2) {
21225
21420
  return [
21226
- c0[0] + (c1[0] - c0[0]) * f,
21227
- c0[1] + (c1[1] - c0[1]) * f,
21228
- c0[2] + (c1[2] - c0[2]) * f,
21229
- c0[3] + (c1[3] - c0[3]) * f
21421
+ c0[0] + (c1[0] - c0[0]) * f2,
21422
+ c0[1] + (c1[1] - c0[1]) * f2,
21423
+ c0[2] + (c1[2] - c0[2]) * f2,
21424
+ c0[3] + (c1[3] - c0[3]) * f2
21230
21425
  ];
21231
21426
  }
21232
21427
  var f32Buffer = new Float32Array(1);
@@ -21257,9 +21452,9 @@ function blendFactor(positions, factors, t) {
21257
21452
  }
21258
21453
  return factors[n - 1];
21259
21454
  }
21260
- function mixBlend(c0, c1, f) {
21261
- const g = truncF32(1 - f);
21262
- const ch = (a, b) => truncF32(truncF32(a * g) + truncF32(b * f));
21455
+ function mixBlend(c0, c1, f2) {
21456
+ const g = truncF32(1 - f2);
21457
+ const ch = (a, b) => truncF32(truncF32(a * g) + truncF32(b * f2));
21263
21458
  return [ch(c0[0], c1[0]), ch(c0[1], c1[1]), ch(c0[2], c1[2]), ch(c0[3], c1[3])];
21264
21459
  }
21265
21460
  function rampColorAt(ramp, t) {
@@ -21273,8 +21468,8 @@ function rampColorAt(ramp, t) {
21273
21468
  for (let i = 1; i < n; i++) {
21274
21469
  if (t <= positions[i]) {
21275
21470
  const span = positions[i] - positions[i - 1];
21276
- const f = span > 0 ? (t - positions[i - 1]) / span : 1;
21277
- return mix(premultiplied(argb[i - 1], gamma), premultiplied(argb[i], gamma), f);
21471
+ const f2 = span > 0 ? (t - positions[i - 1]) / span : 1;
21472
+ return mix(premultiplied(argb[i - 1], gamma), premultiplied(argb[i], gamma), f2);
21278
21473
  }
21279
21474
  }
21280
21475
  return premultiplied(argb[n - 1], gamma);
@@ -21351,18 +21546,18 @@ function unpremultiply(p, a) {
21351
21546
  function writeRampColor(table2, u, out, o, truncate = false) {
21352
21547
  const n = table2.intervals;
21353
21548
  const k = Math.floor(u / FIX_ONE);
21354
- const f = Math.floor(u / 256) & 255;
21549
+ const f2 = Math.floor(u / 256) & 255;
21355
21550
  const j0 = k <= n ? k : 2 * n - k;
21356
21551
  const j1 = k + 1 <= n ? k + 1 : Math.max(0, 2 * n - k - 1);
21357
21552
  const kn = table2.knots;
21358
21553
  const i0 = Math.min(n, j0) * 4;
21359
21554
  const i1 = Math.min(n, j1) * 4;
21360
- const a = kn[i0 + 3] * (256 - f) + kn[i1 + 3] * f + 128 >> 8;
21555
+ const a = kn[i0 + 3] * (256 - f2) + kn[i1 + 3] * f2 + 128 >> 8;
21361
21556
  if (a === 0) {
21362
21557
  return;
21363
21558
  }
21364
21559
  for (let ch = 0; ch < 3; ch++) {
21365
- const p = kn[i0 + ch] * (256 - f) + kn[i1 + ch] * f + 128 >> 8;
21560
+ const p = kn[i0 + ch] * (256 - f2) + kn[i1 + ch] * f2 + 128 >> 8;
21366
21561
  out[o + ch] = a === 255 ? p : truncate ? unpremultiply(p, a) : Math.round(p * 255 / a);
21367
21562
  }
21368
21563
  out[o + 3] = a;
@@ -21370,14 +21565,14 @@ function writeRampColor(table2, u, out, o, truncate = false) {
21370
21565
  function writeRampPremultiplied(table2, u, out, o) {
21371
21566
  const n = table2.intervals;
21372
21567
  const k = Math.floor(u / FIX_ONE);
21373
- const f = Math.floor(u / 256) & 255;
21568
+ const f2 = Math.floor(u / 256) & 255;
21374
21569
  const j0 = k <= n ? k : 2 * n - k;
21375
21570
  const j1 = k + 1 <= n ? k + 1 : Math.max(0, 2 * n - k - 1);
21376
21571
  const kn = table2.knots;
21377
21572
  const i0 = Math.min(n, j0) * 4;
21378
21573
  const i1 = Math.min(n, j1) * 4;
21379
21574
  for (let ch = 0; ch < 4; ch++) {
21380
- out[o + ch] = kn[i0 + ch] * (256 - f) + kn[i1 + ch] * f + 128 >> 8;
21575
+ out[o + ch] = kn[i0 + ch] * (256 - f2) + kn[i1 + ch] * f2 + 128 >> 8;
21381
21576
  }
21382
21577
  }
21383
21578
  function mulF32(a, b) {
@@ -21536,8 +21731,8 @@ function piecewise2(xs, ys, x) {
21536
21731
  for (let i = 1; i < n; i++) {
21537
21732
  if (x <= xs[i]) {
21538
21733
  const span = xs[i] - xs[i - 1];
21539
- const f = span > 0 ? (x - xs[i - 1]) / span : 1;
21540
- return ys[i - 1] + (ys[i] - ys[i - 1]) * f;
21734
+ const f2 = span > 0 ? (x - xs[i - 1]) / span : 1;
21735
+ return ys[i - 1] + (ys[i] - ys[i - 1]) * f2;
21541
21736
  }
21542
21737
  }
21543
21738
  return ys[n - 1];
@@ -22009,7 +22204,7 @@ function parseSerializableObject(view, dataOff, dataSize) {
22009
22204
  return null;
22010
22205
  }
22011
22206
  const p = dataOff + 20;
22012
- const i32 = (k, lo, hi) => clamp(view.getInt32(p + 4 * k, true), lo, hi);
22207
+ const i322 = (k, lo, hi) => clamp(view.getInt32(p + 4 * k, true), lo, hi);
22013
22208
  const f326 = (k, lo, hi) => {
22014
22209
  const v = view.getFloat32(p + 4 * k, true);
22015
22210
  return Number.isFinite(v) ? clamp(v, lo, hi) : 0;
@@ -22019,9 +22214,9 @@ function parseSerializableObject(view, dataOff, dataSize) {
22019
22214
  case "blur":
22020
22215
  return need(8) ? { kind, radius: f326(0, 0, 255), expandEdge: view.getUint32(p + 4, true) !== 0 } : null;
22021
22216
  case "brightnessContrast":
22022
- return need(8) ? { kind, brightness: i32(0, -255, 255), contrast: i32(1, -100, 100) } : null;
22217
+ return need(8) ? { kind, brightness: i322(0, -255, 255), contrast: i322(1, -100, 100) } : null;
22023
22218
  case "colorBalance":
22024
- return need(12) ? { kind, cyanRed: i32(0, -100, 100), magentaGreen: i32(1, -100, 100), yellowBlue: i32(2, -100, 100) } : null;
22219
+ return need(12) ? { kind, cyanRed: i322(0, -100, 100), magentaGreen: i322(1, -100, 100), yellowBlue: i322(2, -100, 100) } : null;
22025
22220
  case "colorCurve": {
22026
22221
  if (!need(COLOR_CURVE_PARAMS_SIZE)) return null;
22027
22222
  const adjustment = view.getInt32(p, true), channel = view.getInt32(p + 4, true), intensity = view.getInt32(p + 8, true);
@@ -22049,9 +22244,9 @@ function parseSerializableObject(view, dataOff, dataSize) {
22049
22244
  return { kind, matrix };
22050
22245
  }
22051
22246
  case "hueSaturationLightness":
22052
- return need(12) ? { kind, hue: i32(0, -180, 180), saturation: i32(1, -100, 100), lightness: i32(2, -100, 100) } : null;
22247
+ return need(12) ? { kind, hue: i322(0, -180, 180), saturation: i322(1, -100, 100), lightness: i322(2, -100, 100) } : null;
22053
22248
  case "levels":
22054
- return need(12) ? { kind, highlight: i32(0, 0, 100), midtone: i32(1, -100, 100), shadow: i32(2, 0, 100) } : null;
22249
+ return need(12) ? { kind, highlight: i322(0, 0, 100), midtone: i322(1, -100, 100), shadow: i322(2, 0, 100) } : null;
22055
22250
  case "redEyeCorrection": {
22056
22251
  if (!need(4)) {
22057
22252
  return null;
@@ -22075,14 +22270,14 @@ function parseSerializableObject(view, dataOff, dataSize) {
22075
22270
  case "sharpen":
22076
22271
  return need(8) ? { kind, radius: f326(0, 0, 255), amount: f326(1, 0, 100) } : null;
22077
22272
  case "tint":
22078
- return need(8) ? { kind, hue: i32(0, -180, 180), amount: i32(1, -100, 100) } : null;
22273
+ return need(8) ? { kind, hue: i322(0, -180, 180), amount: i322(1, -100, 100) } : null;
22079
22274
  }
22080
22275
  }
22081
22276
  var roundHalfDown = (v) => Math.ceil(v - 0.5);
22082
- function buildLut(f, round = Math.round) {
22277
+ function buildLut(f2, round = Math.round) {
22083
22278
  const lut = new Uint8Array(256);
22084
22279
  for (let v = 0; v < 256; v++) {
22085
- lut[v] = clamp(round(f(v)), 0, 255);
22280
+ lut[v] = clamp(round(f2(v)), 0, 255);
22086
22281
  }
22087
22282
  return lut;
22088
22283
  }
@@ -22167,17 +22362,17 @@ var HUE_CIRCLE = 255;
22167
22362
  function gdipHue(r, g, b) {
22168
22363
  const max = Math.max(r, g, b);
22169
22364
  const d = max - Math.min(r, g, b);
22170
- const f = (x) => Math.floor(x * HUE_SEXTANT / d);
22365
+ const f2 = (x) => Math.floor(x * HUE_SEXTANT / d);
22171
22366
  if (max === r && g >= b) {
22172
- return f(g - b);
22367
+ return f2(g - b);
22173
22368
  }
22174
22369
  if (max === b && b !== r) {
22175
- return r >= g ? 170 + f(r - g) : 127 + f(b - g);
22370
+ return r >= g ? 170 + f2(r - g) : 127 + f2(b - g);
22176
22371
  }
22177
22372
  if (max === g) {
22178
- return b >= r ? 86 + f(b - r) : 43 + f(g - r);
22373
+ return b >= r ? 86 + f2(b - r) : 43 + f2(g - r);
22179
22374
  }
22180
- const t = f(b - g);
22375
+ const t = f2(b - g);
22181
22376
  const q = (256 - t - (t >= 40 ? 1 : 0)) % 256;
22182
22377
  return q - Math.floor((q + 42) / 86);
22183
22378
  }
@@ -23205,7 +23400,7 @@ function deriveClipDomain(...regions) {
23205
23400
  let minY = Infinity;
23206
23401
  let maxX = -Infinity;
23207
23402
  let maxY = -Infinity;
23208
- const add2 = (x2, y2) => {
23403
+ const add3 = (x2, y2) => {
23209
23404
  if (Math.abs(x2) < FINITE_LIMIT && Math.abs(y2) < FINITE_LIMIT) {
23210
23405
  minX = Math.min(minX, x2);
23211
23406
  minY = Math.min(minY, y2);
@@ -23217,7 +23412,7 @@ function deriveClipDomain(...regions) {
23217
23412
  for (const shape of region ?? []) {
23218
23413
  for (const poly of flattenClipCmds(shape.cmds)) {
23219
23414
  for (let i = 0; i < poly.length; i += 2) {
23220
- add2(poly[i], poly[i + 1]);
23415
+ add3(poly[i], poly[i + 1]);
23221
23416
  }
23222
23417
  }
23223
23418
  }
@@ -23835,6 +24030,7 @@ function parsePathGradient(view, b, end) {
23835
24030
  }
23836
24031
  let boundaryPts = [];
23837
24032
  let boundaryArgb = [];
24033
+ let source;
23838
24034
  const surroundAt = (k) => surround.length > 0 ? surround[Math.min(k, surround.length - 1)] : centerArgb;
23839
24035
  if (flags & BRUSH_DATA_PATH) {
23840
24036
  if (o + 4 <= end) {
@@ -23846,6 +24042,20 @@ function parsePathGradient(view, b, end) {
23846
24042
  const flat = flattenFirstFigure(path.points, path.types, surroundAt);
23847
24043
  boundaryPts = flat.points;
23848
24044
  boundaryArgb = flat.argb;
24045
+ let figure = path.points.length;
24046
+ for (let k = 0; k < path.points.length; k++) {
24047
+ if (k > 0 && (path.types[k] & 7) === 0) {
24048
+ figure = k;
24049
+ break;
24050
+ }
24051
+ if (path.types[k] & 128) {
24052
+ figure = k + 1;
24053
+ break;
24054
+ }
24055
+ }
24056
+ if (path.types.slice(0, figure).some((t) => (t & 7) === 3)) {
24057
+ source = { points: path.points.slice(0, figure), types: path.types.slice(0, figure) };
24058
+ }
23849
24059
  }
23850
24060
  o += pathSize;
23851
24061
  }
@@ -23938,6 +24148,7 @@ function parsePathGradient(view, b, end) {
23938
24148
  center,
23939
24149
  centerArgb,
23940
24150
  boundary: boundaryPts,
24151
+ source,
23941
24152
  boundaryArgb,
23942
24153
  blend,
23943
24154
  preset,
@@ -24242,12 +24453,12 @@ function recordNominalFigures(buildPath, device, cull) {
24242
24453
  if (!fig) {
24243
24454
  moveTo(c1x, c1y);
24244
24455
  }
24245
- const f = fig;
24246
- f.curved = true;
24247
- const n = f.pts.length;
24456
+ const f2 = fig;
24457
+ f2.curved = true;
24458
+ const n = f2.pts.length;
24248
24459
  flattenBezierGdiplus(
24249
- [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)],
24250
- f.pts);
24460
+ [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)],
24461
+ f2.pts);
24251
24462
  },
24252
24463
  ellipse(cx, cy, rx, ry, rotation, a0, a1, ccw) {
24253
24464
  let sweep = a1 - a0;
@@ -24292,11 +24503,11 @@ function recordNominalFigures(buildPath, device, cull) {
24292
24503
  }
24293
24504
  };
24294
24505
  buildPath(recorder);
24295
- return figures.filter((f) => f.pts.length >= 4);
24506
+ return figures.filter((f2) => f2.pts.length >= 4);
24296
24507
  }
24297
- function strokePoints(f) {
24298
- const p = f.pts;
24299
- if (!f.closed || p.length < 4) {
24508
+ function strokePoints(f2) {
24509
+ const p = f2.pts;
24510
+ if (!f2.closed || p.length < 4) {
24300
24511
  return p;
24301
24512
  }
24302
24513
  return [...p, p[0], p[1]];
@@ -24551,7 +24762,7 @@ function nominalOutline(pts) {
24551
24762
  return poly;
24552
24763
  }
24553
24764
  function nominalLineCoverage(figures, mode, box) {
24554
- if (!mode.antialias && mode.opaqueSolid && !figures.some((f) => f.curved)) {
24765
+ if (!mode.antialias && mode.opaqueSolid && !figures.some((f2) => f2.curved)) {
24555
24766
  const shift = mode.half ? 8 : 0;
24556
24767
  const out = new Uint8ClampedArray(box.w * box.h);
24557
24768
  const plot = (x, y) => {
@@ -24562,8 +24773,8 @@ function nominalLineCoverage(figures, mode, box) {
24562
24773
  }
24563
24774
  };
24564
24775
  const clip = mode.clip && !pathInside(figures, mode.clip, shift) ? mode.clip : void 0;
24565
- for (const f of figures) {
24566
- const p = strokePoints(f);
24776
+ for (const f2 of figures) {
24777
+ const p = strokePoints(f2);
24567
24778
  for (let i = 0; i + 3 < p.length; i += 2) {
24568
24779
  ddaSegment(p[i] - shift, p[i + 1] - shift, p[i + 2] - shift, p[i + 3] - shift, true, plot, clip);
24569
24780
  }
@@ -24571,8 +24782,8 @@ function nominalLineCoverage(figures, mode, box) {
24571
24782
  return out;
24572
24783
  }
24573
24784
  const polys = [];
24574
- for (const f of figures) {
24575
- for (const batch of enumeratorBatches(strokePoints(f))) {
24785
+ for (const f2 of figures) {
24786
+ for (const batch of enumeratorBatches(strokePoints(f2))) {
24576
24787
  const outline = nominalOutline(batch);
24577
24788
  if (outline.length >= 6) {
24578
24789
  polys.push(outline);
@@ -24586,10 +24797,10 @@ function pathInside(figures, clip, shift) {
24586
24797
  let y0 = Infinity;
24587
24798
  let x1 = -Infinity;
24588
24799
  let y1 = -Infinity;
24589
- for (const f of figures) {
24590
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
24591
- const x = (f.pts[i] - shift) / 16;
24592
- const y = (f.pts[i + 1] - shift) / 16;
24800
+ for (const f2 of figures) {
24801
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
24802
+ const x = (f2.pts[i] - shift) / 16;
24803
+ const y = (f2.pts[i + 1] - shift) / 16;
24593
24804
  x0 = Math.min(x0, x);
24594
24805
  x1 = Math.max(x1, x);
24595
24806
  y0 = Math.min(y0, y);
@@ -24639,24 +24850,24 @@ function recordDeviceFigures(buildPath, device) {
24639
24850
  if (!fig) {
24640
24851
  moveTo(c1x, c1y);
24641
24852
  }
24642
- const f = fig;
24643
- f.curved = true;
24644
- const n = f.pts.length;
24645
- const near = (qx, qy) => Math.abs(qx - f.pts[n - 2]) < 1e-3 && Math.abs(qy - f.pts[n - 1]) < 1e-3;
24853
+ const f2 = fig;
24854
+ f2.curved = true;
24855
+ const n = f2.pts.length;
24856
+ const near = (qx, qy) => Math.abs(qx - f2.pts[n - 2]) < 1e-3 && Math.abs(qy - f2.pts[n - 1]) < 1e-3;
24646
24857
  const degenerate = near(dx(c1x, c1y), dy(c1x, c1y)) && near(dx(c2x, c2y), dy(c2x, c2y)) && near(dx(x, y), dy(x, y));
24647
24858
  const fix = (v) => toPlusFix(v);
24648
- const p0x = fix(f.pts[n - 2]);
24649
- const p0y = fix(f.pts[n - 1]);
24650
- f.pts[n - 2] = p0x / 16;
24651
- f.pts[n - 1] = p0y / 16;
24859
+ const p0x = fix(f2.pts[n - 2]);
24860
+ const p0y = fix(f2.pts[n - 1]);
24861
+ f2.pts[n - 2] = p0x / 16;
24862
+ f2.pts[n - 1] = p0y / 16;
24652
24863
  if (degenerate) {
24653
- (f.splits ?? (f.splits = [])).push({ x: p0x / 16, y: p0y / 16 });
24864
+ (f2.splits ?? (f2.splits = [])).push({ x: p0x / 16, y: p0y / 16 });
24654
24865
  }
24655
24866
  const out = [];
24656
24867
  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))];
24657
24868
  flattenBezierGdiplus(ctrl, out);
24658
24869
  for (const v of out) {
24659
- f.pts.push(v / 16);
24870
+ f2.pts.push(v / 16);
24660
24871
  }
24661
24872
  };
24662
24873
  const closePath = () => {
@@ -24711,10 +24922,10 @@ function recordDeviceFigures(buildPath, device) {
24711
24922
  }
24712
24923
  };
24713
24924
  buildPath(recorder);
24714
- return figures.filter((f) => f.pts.length >= 4);
24925
+ return figures.filter((f2) => f2.pts.length >= 4);
24715
24926
  }
24716
24927
  function recordPlusFigures(buildPath, device, aliased = false) {
24717
- return recordDeviceFigures(buildPath, device).map((f) => (aliased && !f.curved ? aliasedRectFix(f.pts) : null) ?? f.pts.map(toPlusFix)).filter((f) => f.length >= 6);
24928
+ return recordDeviceFigures(buildPath, device).map((f2) => (aliased && !f2.curved ? aliasedRectFix(f2.pts) : null) ?? f2.pts.map(toPlusFix)).filter((f2) => f2.length >= 6);
24718
24929
  }
24719
24930
  function ceilDiv2(a, b) {
24720
24931
  let q = Math.floor(a / b);
@@ -24731,12 +24942,12 @@ function figuresBox(figures, size) {
24731
24942
  let y0 = Infinity;
24732
24943
  let x1 = -Infinity;
24733
24944
  let y1 = -Infinity;
24734
- for (const f of figures) {
24735
- for (let i = 0; i < f.length; i += 2) {
24736
- x0 = Math.min(x0, f[i]);
24737
- x1 = Math.max(x1, f[i]);
24738
- y0 = Math.min(y0, f[i + 1]);
24739
- y1 = Math.max(y1, f[i + 1]);
24945
+ for (const f2 of figures) {
24946
+ for (let i = 0; i < f2.length; i += 2) {
24947
+ x0 = Math.min(x0, f2[i]);
24948
+ x1 = Math.max(x1, f2[i]);
24949
+ y0 = Math.min(y0, f2[i + 1]);
24950
+ y1 = Math.max(y1, f2[i + 1]);
24740
24951
  }
24741
24952
  }
24742
24953
  if (!Number.isFinite(x0)) {
@@ -24758,14 +24969,14 @@ function rasterizePlusFill(figures, evenOdd, antialias, half, box) {
24758
24969
  const y0 = 16 * box.y + o - (antialias ? 8 : 0);
24759
24970
  const cols = box.w * sx;
24760
24971
  const edges = [];
24761
- for (const f of figures) {
24762
- const n = f.length / 2;
24972
+ for (const f2 of figures) {
24973
+ const n = f2.length / 2;
24763
24974
  for (let i = 0; i < n; i++) {
24764
24975
  const j = (i + 1) % n;
24765
- const ax = f[2 * i];
24766
- const ay = f[2 * i + 1];
24767
- const bx = f[2 * j];
24768
- const by = f[2 * j + 1];
24976
+ const ax = f2[2 * i];
24977
+ const ay = f2[2 * i + 1];
24978
+ const bx = f2[2 * j];
24979
+ const by = f2[2 * j + 1];
24769
24980
  if (ay === by) {
24770
24981
  continue;
24771
24982
  }
@@ -24830,7 +25041,7 @@ function clipPixelRects(shapes, box, half) {
24830
25041
  for (const shape of shapes) {
24831
25042
  let figs;
24832
25043
  try {
24833
- figs = recordDeviceFigures(shape.build, identity).map((f) => f.pts.map(nearestFix));
25044
+ figs = recordDeviceFigures(shape.build, identity).map((f2) => f2.pts.map(nearestFix));
24834
25045
  } catch {
24835
25046
  return null;
24836
25047
  }
@@ -24877,6 +25088,156 @@ function clipPixelRects(shapes, box, half) {
24877
25088
  return rects;
24878
25089
  }
24879
25090
 
25091
+ // src/emf-plus-widen-f32.ts
25092
+ var f = Math.fround;
25093
+ var add2 = (a, b) => down32(a + b);
25094
+ var sub2 = (a, b) => down32(a - b);
25095
+ var mul3 = (a, b) => down32(a * b);
25096
+ var div2 = (a, b) => down32(a / b);
25097
+ var EPSILON2 = 11920928955078125e-23;
25098
+ function gradientF32(a, b) {
25099
+ let gx = sub2(f(b.x), f(a.x));
25100
+ let gy = sub2(f(b.y), f(a.y));
25101
+ const sum = add2(mul3(gy, gy), mul3(gx, gx));
25102
+ let len = 0;
25103
+ if (sum > 0) {
25104
+ len = down32(Math.sqrt(sum));
25105
+ gx = div2(gx, len);
25106
+ gy = div2(gy, len);
25107
+ }
25108
+ return { gx, gy, len };
25109
+ }
25110
+ function normF32(dx, dy) {
25111
+ const len = Math.sqrt(dx * dx + dy * dy);
25112
+ return len < EPSILON2 ? 0 : down32(len);
25113
+ }
25114
+ var KAPPA2 = f(0.552284777);
25115
+ var SEMICIRCLE = [
25116
+ [1, 0],
25117
+ [1, KAPPA2],
25118
+ [KAPPA2, 1],
25119
+ [0, 1],
25120
+ [-KAPPA2, 1],
25121
+ [-1, KAPPA2],
25122
+ [-1, 0]
25123
+ ];
25124
+ function capTransform(p, g, a, b, start) {
25125
+ const gx = start ? -g.gx : g.gx;
25126
+ const gy = start ? -g.gy : g.gy;
25127
+ const sum = add2(a, b);
25128
+ const half = mul3(sub2(a, b), 0.5);
25129
+ const cx = add2(mul3(mul3(sum, g.gy), 0.5), p.x);
25130
+ const cy = sub2(p.y, mul3(mul3(sum, g.gx), 0.5));
25131
+ const hy = mul3(half, gy);
25132
+ const nhx = mul3(-half, gx);
25133
+ return (x, y) => ({ x: add2(sub2(mul3(x, hy), mul3(y, nhx)), cx), y: add2(add2(mul3(y, hy), mul3(x, nhx)), cy) });
25134
+ }
25135
+ function doubleRoundCapF32(p, g, a, b, start) {
25136
+ const at = capTransform(p, g, a, b, start);
25137
+ const out = [];
25138
+ for (const shift of [0.5, -0.5]) {
25139
+ for (const [ux, uy] of SEMICIRCLE) {
25140
+ out.push(at(add2(mul3(ux, 0.5), shift), mul3(uy, 0.5)));
25141
+ }
25142
+ }
25143
+ return out;
25144
+ }
25145
+ function offsetPointF32(p, g, o) {
25146
+ if (o < 0) {
25147
+ return { x: add2(p.x, mul3(-o, g.gy)), y: add2(p.y, mul3(-o, -g.gx)) };
25148
+ }
25149
+ return { x: sub2(p.x, mul3(o, g.gy)), y: sub2(p.y, mul3(o, -g.gx)) };
25150
+ }
25151
+ function dashF32(pts, closed, dash, offset) {
25152
+ const n = pts.length;
25153
+ if (n < 2 || dash.length === 0) {
25154
+ return [];
25155
+ }
25156
+ let total = 0;
25157
+ for (const d of dash) {
25158
+ total = add2(total, d);
25159
+ }
25160
+ if (!(total > 0)) {
25161
+ return [];
25162
+ }
25163
+ let rem = f(offset % total);
25164
+ if (rem < 0) {
25165
+ rem = add2(rem, total);
25166
+ }
25167
+ let idx = 0;
25168
+ for (let guard = 0; guard < 1e6; guard++) {
25169
+ const d = dash[idx % dash.length];
25170
+ if (d > rem) {
25171
+ rem = sub2(d, rem);
25172
+ break;
25173
+ }
25174
+ rem = sub2(rem, d);
25175
+ idx++;
25176
+ }
25177
+ let on = idx % 2 === 0;
25178
+ let nextIdx = idx + 1;
25179
+ const lengths = [0];
25180
+ for (let i = 1; i < n; i++) {
25181
+ lengths.push(gradientF32(pts[i - 1], pts[i]).len);
25182
+ }
25183
+ let cur;
25184
+ let k;
25185
+ let segRem;
25186
+ {
25187
+ cur = pts[n - 1];
25188
+ k = 0;
25189
+ segRem = normF32(sub2(pts[0].x, cur.x), sub2(pts[0].y, cur.y));
25190
+ }
25191
+ let dashRem = rem;
25192
+ const out = [];
25193
+ let run = null;
25194
+ const tiny = (a, b) => Math.abs(sub2(a.x, b.x)) < EPSILON2 && Math.abs(sub2(a.y, b.y)) < EPSILON2;
25195
+ for (let guard = 0; k < n && guard < 1e7; guard++) {
25196
+ const next = pts[k];
25197
+ if (dashRem > segRem) {
25198
+ dashRem = sub2(dashRem, segRem);
25199
+ if (on) {
25200
+ if (tiny(cur, next)) {
25201
+ if (run && run.length > 1) {
25202
+ out.push(run);
25203
+ }
25204
+ run = null;
25205
+ } else {
25206
+ run ?? (run = [cur]);
25207
+ run.push(next);
25208
+ }
25209
+ }
25210
+ cur = next;
25211
+ k++;
25212
+ if (k < n) {
25213
+ segRem = lengths[k];
25214
+ }
25215
+ } else {
25216
+ const t = div2(dashRem, segRem);
25217
+ const q = { x: add2(mul3(sub2(next.x, cur.x), t), cur.x), y: add2(mul3(sub2(next.y, cur.y), t), cur.y) };
25218
+ segRem = sub2(segRem, dashRem);
25219
+ if (on) {
25220
+ if (!tiny(cur, q)) {
25221
+ run ?? (run = [cur]);
25222
+ run.push(q);
25223
+ out.push(run);
25224
+ } else if (run && run.length > 1) {
25225
+ out.push(run);
25226
+ }
25227
+ run = null;
25228
+ }
25229
+ cur = q;
25230
+ dashRem = dash[nextIdx % dash.length];
25231
+ nextIdx++;
25232
+ on = !on;
25233
+ }
25234
+ }
25235
+ if (on && run && run.length > 1) {
25236
+ out.push(run);
25237
+ }
25238
+ return out;
25239
+ }
25240
+
24880
25241
  // src/emf-plus-widen.ts
24881
25242
  function arcPoints2(c, r, a0, sweep) {
24882
25243
  const out = [];
@@ -24984,8 +25345,8 @@ function joinPoints(p, f1, f2, o, pen, meetInside = false) {
24984
25345
  }
24985
25346
  return [a, b];
24986
25347
  }
24987
- function capPoints(p, f, o1, o2, cap, half, double = false) {
24988
- const at = (o, ext) => ({ x: p.x + f.nx * o + f.ux * ext, y: p.y + f.ny * o + f.uy * ext });
25348
+ function capPoints(p, f2, o1, o2, cap, half, double = false) {
25349
+ const at = (o, ext) => ({ x: p.x + f2.nx * o + f2.ux * ext, y: p.y + f2.ny * o + f2.uy * ext });
24989
25350
  const base = cap & 15;
24990
25351
  const kind = cap === 17 ? 1 : cap === 18 ? 2 : cap === 19 || cap === 20 ? 3 : cap >= 16 ? 0 : base;
24991
25352
  switch (kind) {
@@ -24994,7 +25355,7 @@ function capPoints(p, f, o1, o2, cap, half, double = false) {
24994
25355
  case 2: {
24995
25356
  if (double) {
24996
25357
  const r2 = Math.abs(o2 - o1) / 4;
24997
- const a02 = Math.atan2(f.ny, f.nx);
25358
+ const a02 = Math.atan2(f2.ny, f2.nx);
24998
25359
  const mid = (o1 + o2) / 2;
24999
25360
  const c2 = (o2 + mid) / 2;
25000
25361
  const c1 = (o1 + mid) / 2;
@@ -25003,7 +25364,7 @@ function capPoints(p, f, o1, o2, cap, half, double = false) {
25003
25364
  const c = (o1 + o2) / 2;
25004
25365
  const r = Math.abs(o2 - o1) / 2;
25005
25366
  const centre = Math.abs(c) > 1e-9 ? at(c, 0) : p;
25006
- const a0 = Math.atan2(f.ny, f.nx) + (o2 < c ? Math.PI : 0);
25367
+ const a0 = Math.atan2(f2.ny, f2.nx) + (o2 < c ? Math.PI : 0);
25007
25368
  const sweep = o2 > c ? -Math.PI : Math.PI;
25008
25369
  return [at(o2, 0), ...arcPoints2(centre, r, a0, sweep), at(o1, 0)];
25009
25370
  }
@@ -25030,8 +25391,8 @@ function sidePoints(pts, closed, o, pen) {
25030
25391
  if (inIdx >= 0 && outIdx >= 0) {
25031
25392
  out.push(...joinPoints(pts[i], frames[inIdx], frames[outIdx], o, pen, closed && !!pen.compound));
25032
25393
  } else {
25033
- const f = frames[outIdx >= 0 ? outIdx : inIdx];
25034
- out.push({ x: pts[i].x + f.nx * o, y: pts[i].y + f.ny * o });
25394
+ const f2 = frames[outIdx >= 0 ? outIdx : inIdx];
25395
+ out.push({ x: pts[i].x + f2.nx * o, y: pts[i].y + f2.ny * o });
25035
25396
  }
25036
25397
  }
25037
25398
  return out;
@@ -25104,13 +25465,50 @@ function dashFigure(pts, closed, pen, splits) {
25104
25465
  }
25105
25466
  return out.filter((d) => d.pts.length > 1);
25106
25467
  }
25468
+ function dashPiecesSingle(raw, pen) {
25469
+ const width = down32(pen.dashCapWidth ?? 2 * pen.half);
25470
+ const least = down32(Math.fround(1e-3) * width);
25471
+ const dash = pen.dash.map((v, i) => {
25472
+ const d = down32(v);
25473
+ if (i % 2 === 1) {
25474
+ return down32(d + width);
25475
+ }
25476
+ const shortened = down32(d - width);
25477
+ return least > shortened ? least : shortened;
25478
+ });
25479
+ const pts = [];
25480
+ for (let i = 0; i + 1 < raw.length; i += 2) {
25481
+ pts.push({ x: Math.fround(raw[i]), y: Math.fround(raw[i + 1]) });
25482
+ }
25483
+ if (pts.length > 1 && pts[0].x === pts[pts.length - 1].x && pts[0].y === pts[pts.length - 1].y) {
25484
+ pts.pop();
25485
+ }
25486
+ return dashF32(pts, true, dash, down32(down32(pen.dashOffset) - width)).map((d) => ({ pts: d, first: false, last: false }));
25487
+ }
25488
+ function singleCap(p, g, o1, o2, start) {
25489
+ const c = doubleRoundCapF32({ x: Math.fround(p.x), y: Math.fround(p.y) }, g, o2, o1, start);
25490
+ const out = [c[0]];
25491
+ for (const [i0, i1, i2, i3] of [
25492
+ [0, 1, 2, 3],
25493
+ [3, 4, 5, 6],
25494
+ [7, 8, 9, 10],
25495
+ [10, 11, 12, 13]
25496
+ ]) {
25497
+ const flat = [];
25498
+ flattenBezierGdiplus([i0, i1, i2, i3].flatMap((i) => [toPlusFix(c[i].x), toPlusFix(c[i].y)]), flat);
25499
+ for (let k = 0; k + 1 < flat.length; k += 2) {
25500
+ out.push({ x: flat[k] / 16, y: flat[k + 1] / 16 });
25501
+ }
25502
+ }
25503
+ return out.reverse();
25504
+ }
25107
25505
  var ARROW_ANCHOR = 20;
25108
25506
  function centeredAnchor(pp, atEnd, half, cap) {
25109
25507
  const p = atEnd ? pp[pp.length - 1] : pp[0];
25110
25508
  const q = atEnd ? pp[pp.length - 2] : pp[1];
25111
- const f = frame(q, p);
25112
- const at = (u, n) => ({ x: p.x + f.ux * u + f.nx * n, y: p.y + f.uy * u + f.ny * n });
25113
- if (cap === 18) return arcPoints2(p, 2 * half, Math.atan2(f.uy, f.ux), 2 * Math.PI);
25509
+ const f2 = frame(q, p);
25510
+ const at = (u, n) => ({ x: p.x + f2.ux * u + f2.nx * n, y: p.y + f2.uy * u + f2.ny * n });
25511
+ if (cap === 18) return arcPoints2(p, 2 * half, Math.atan2(f2.uy, f2.ux), 2 * Math.PI);
25114
25512
  if (cap === 19) return [at(-2 * half, 0), at(0, -2 * half), at(2 * half, 0), at(0, 2 * half)];
25115
25513
  const h = Math.SQRT2 * half;
25116
25514
  return [at(-h, -h), at(h, -h), at(h, h), at(-h, h)];
@@ -25225,7 +25623,8 @@ function widenFigures(figures, pen) {
25225
25623
  bands.push([lo, hi]);
25226
25624
  }
25227
25625
  const dashPen = pen.inset && closed ? { ...pen, dashOffset: pen.dashOffset * 2 } : pen;
25228
- const pieces = pen.dash ? dashFigure(pts, closed, dashPen, fig.splits) : [{ pts, first: true, last: true }];
25626
+ const single = !!pen.dash && !!pen.doubleRoundCap && pen.dashCap === 2 && closed;
25627
+ const pieces = single ? dashPiecesSingle(fig.pts, pen) : pen.dash ? dashFigure(pts, closed, dashPen, fig.splits) : [{ pts, first: true, last: true }];
25229
25628
  const pieceClosed = !pen.dash && closed;
25230
25629
  for (const piece of pieces) {
25231
25630
  const pp = cleanPoints(
@@ -25268,8 +25667,13 @@ function widenFigures(figures, pen) {
25268
25667
  const f0 = frame(pp[1], pp[0]);
25269
25668
  const endCap = endCapOverride ?? (piece.last && !(pen.dash && closed) ? pen.endCap : pen.dashCap);
25270
25669
  const startCap = startCapOverride ?? (piece.first && !(pen.dash && closed) ? pen.startCap : pen.dashCap);
25271
- const capEnd = capPoints(pp[pp.length - 1], fEnd, o1, o2, endCap, h, pen.doubleRoundCap);
25272
- const capStart = capPoints(pp[0], f0, -o2, -o1, startCap, h, pen.doubleRoundCap);
25670
+ const gEnd = single ? gradientF32(pp[pp.length - 2], pp[pp.length - 1]) : null;
25671
+ const gStart = single ? gradientF32(pp[0], pp[1]) : null;
25672
+ const capEnd = gEnd ? singleCap(pp[pp.length - 1], gEnd, o1, o2, false) : capPoints(pp[pp.length - 1], fEnd, o1, o2, endCap, h, pen.doubleRoundCap);
25673
+ const capStart = gStart ? singleCap(pp[0], gStart, o1, o2, true) : capPoints(pp[0], f0, -o2, -o1, startCap, h, pen.doubleRoundCap);
25674
+ if (gStart) {
25675
+ left[0] = offsetPointF32(pp[0], gStart, o2);
25676
+ }
25273
25677
  if (endCap === 0 && capEnd.length === 2 && left.length > 2 && right.length > 2) {
25274
25678
  const behind = (c2, q) => (c2.x - q.x) * fEnd.ux + (c2.y - q.y) * fEnd.uy < -1e-9;
25275
25679
  const lq = left[left.length - 2];
@@ -25346,15 +25750,15 @@ function parseCustomLineCap(view, off, size) {
25346
25750
  }
25347
25751
  const type = view.getInt32(off + 4, true);
25348
25752
  const d = off + 8;
25349
- const f = (k) => view.getFloat32(d + k, true);
25753
+ const f2 = (k) => view.getFloat32(d + k, true);
25350
25754
  const u = (k) => view.getUint32(d + k, true);
25351
25755
  if (type === 1) {
25352
25756
  if (d + 52 > end) {
25353
25757
  return null;
25354
25758
  }
25355
- const width = f(0);
25356
- const height = f(4);
25357
- const middleInset = f(8);
25759
+ const width = f2(0);
25760
+ const height = f2(4);
25761
+ const middleInset = f2(8);
25358
25762
  const filled = u(12) !== 0;
25359
25763
  const path = arrowCapPath(width, height, middleInset, filled);
25360
25764
  const length = capPathLength(path.points, path.types);
@@ -25366,8 +25770,8 @@ function parseCustomLineCap(view, off, size) {
25366
25770
  strokeStartCap: u(16),
25367
25771
  strokeEndCap: u(20),
25368
25772
  strokeJoin: u(24),
25369
- strokeMiterLimit: f(28),
25370
- widthScale: f(32),
25773
+ strokeMiterLimit: f2(28),
25774
+ widthScale: f2(32),
25371
25775
  fillPath: filled ? path : null,
25372
25776
  linePath: filled ? null : path,
25373
25777
  fillLength: filled ? length : 0,
@@ -25399,12 +25803,12 @@ function parseCustomLineCap(view, off, size) {
25399
25803
  kind: "plus-customlinecap",
25400
25804
  capType: 0,
25401
25805
  baseCap: u(4),
25402
- baseInset: f(8),
25806
+ baseInset: f2(8),
25403
25807
  strokeStartCap: u(12),
25404
25808
  strokeEndCap: u(16),
25405
25809
  strokeJoin: u(20),
25406
- strokeMiterLimit: f(24),
25407
- widthScale: f(28),
25810
+ strokeMiterLimit: f2(24),
25811
+ widthScale: f2(28),
25408
25812
  fillPath,
25409
25813
  linePath,
25410
25814
  fillLength: fillPath ? capPathLength(fillPath.points, fillPath.types) : 0,
@@ -25533,7 +25937,7 @@ function capFigures(path, closeAll) {
25533
25937
  }
25534
25938
  }
25535
25939
  }, [1, 0, 0, 1, 0, 0]);
25536
- return closeAll ? figures.map((f) => ({ ...f, closed: true })) : figures;
25940
+ return closeAll ? figures.map((f2) => ({ ...f2, closed: true })) : figures;
25537
25941
  }
25538
25942
  function customCapGeometry(figures, width, start, end, options2 = {}) {
25539
25943
  const out = [];
@@ -25580,10 +25984,10 @@ function customCapGeometry(figures, width, start, end, options2 = {}) {
25580
25984
  const origin = atEnd ? last : first;
25581
25985
  if (fill2) {
25582
25986
  const placed = placeCapPath(path, origin, dir, Math.max(scale, minFill));
25583
- for (const f of capFigures(placed, true)) {
25987
+ for (const f2 of capFigures(placed, true)) {
25584
25988
  const poly = [];
25585
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
25586
- poly.push({ x: f.pts[i], y: f.pts[i + 1] });
25989
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
25990
+ poly.push({ x: f2.pts[i], y: f2.pts[i + 1] });
25587
25991
  }
25588
25992
  polygons.push(poly);
25589
25993
  }
@@ -26182,9 +26586,9 @@ function writeTextureColorAt(cu, cv, width, height, rgba, wrap, out, o) {
26182
26586
  out[o + 3] = a;
26183
26587
  }
26184
26588
  function invertTextureMatrix(m, halfPixel2 = false) {
26185
- const [a, b, c, d, e, f] = [m[0], m[1], m[2], m[3], m[4], m[5]].map(Math.fround);
26589
+ const [a, b, c, d, e, f2] = [m[0], m[1], m[2], m[3], m[4], m[5]].map(Math.fround);
26186
26590
  const ex = halfPixel2 ? down32(down32(down32(down32(0.5 * a) + down32(0.5 * c)) + e) - 0.5) : e;
26187
- const fy = halfPixel2 ? down32(down32(down32(down32(0.5 * b) + down32(0.5 * d)) + f) - 0.5) : f;
26591
+ const fy = halfPixel2 ? down32(down32(down32(down32(0.5 * b) + down32(0.5 * d)) + f2) - 0.5) : f2;
26188
26592
  const det = down32(down32(a * d) - down32(b * c));
26189
26593
  if (!Number.isFinite(det) || det === 0) {
26190
26594
  return null;
@@ -26233,10 +26637,10 @@ function textureRowPositions(inv3, x0, y, us, vs, count = us.length) {
26233
26637
  if (count <= 0) {
26234
26638
  return;
26235
26639
  }
26236
- const [a, b, c, d, e, f] = inv3;
26640
+ const [a, b, c, d, e, f2] = inv3;
26237
26641
  const at = (x) => [
26238
26642
  down32(down32(down32(a * x) + down32(c * y)) + e),
26239
- down32(down32(down32(b * x) + down32(d * y)) + f)
26643
+ down32(down32(down32(b * x) + down32(d * y)) + f2)
26240
26644
  ];
26241
26645
  const [us0, vs0] = at(x0);
26242
26646
  const [us1, vs1] = at(x0 + count);
@@ -26303,16 +26707,16 @@ function addDown(a, b) {
26303
26707
  const r = down32(s);
26304
26708
  return Math.fround(s) === s && err < 0 ? prevF322(s) : r;
26305
26709
  }
26306
- var sub2 = (a, b) => addDown(a, -b);
26307
- var mul3 = (a, b) => down32(a * b);
26308
- function div2(a, b) {
26710
+ var sub3 = (a, b) => addDown(a, -b);
26711
+ var mul4 = (a, b) => down32(a * b);
26712
+ function div3(a, b) {
26309
26713
  let c = down32(a / b);
26310
26714
  if (b > 0 ? c * b > a : c * b < a) c = prevF322(c);
26311
26715
  return c;
26312
26716
  }
26313
26717
  var COMPLEXITY_TOLERANCE = 596046448e-12;
26314
26718
  function matrixComplexity(m) {
26315
- const [a, b, c, d, e, f] = m;
26719
+ const [a, b, c, d, e, f2] = m;
26316
26720
  const absA = Math.abs(a);
26317
26721
  const absD = Math.abs(d);
26318
26722
  const absB = Math.abs(b);
@@ -26326,11 +26730,11 @@ function matrixComplexity(m) {
26326
26730
  let flags = 15;
26327
26731
  if (tolerance > absB && tolerance > absC) {
26328
26732
  flags = 3;
26329
- if (COMPLEXITY_TOLERANCE > Math.abs(sub2(a, 1)) && COMPLEXITY_TOLERANCE > Math.abs(sub2(d, 1))) flags = 1;
26330
- } else if (tolerance > Math.abs(sub2(a, d)) && tolerance > Math.abs(addDown(c, b))) {
26331
- flags = COMPLEXITY_TOLERANCE > Math.abs(sub2(addDown(mul3(b, b), mul3(a, a)), 1)) ? 5 : 7;
26733
+ if (COMPLEXITY_TOLERANCE > Math.abs(sub3(a, 1)) && COMPLEXITY_TOLERANCE > Math.abs(sub3(d, 1))) flags = 1;
26734
+ } else if (tolerance > Math.abs(sub3(a, d)) && tolerance > Math.abs(addDown(c, b))) {
26735
+ flags = COMPLEXITY_TOLERANCE > Math.abs(sub3(addDown(mul4(b, b), mul4(a, a)), 1)) ? 5 : 7;
26332
26736
  }
26333
- if (e === 0 && f === 0) flags &= -2;
26737
+ if (e === 0 && f2 === 0) flags &= -2;
26334
26738
  return flags;
26335
26739
  }
26336
26740
  function inferPointsMatrix(points, src) {
@@ -26338,32 +26742,32 @@ function inferPointsMatrix(points, src) {
26338
26742
  const [x, y, w, h] = src;
26339
26743
  const nh = -h;
26340
26744
  const nw = -w;
26341
- const product = sub2(mul3(addDown(w, x), addDown(y, h)), mul3(y, x));
26342
- const det = addDown(product, sub2(mul3(nh, x), mul3(y, w)));
26745
+ const product = sub3(mul4(addDown(w, x), addDown(y, h)), mul4(y, x));
26746
+ const det = addDown(product, sub3(mul4(nh, x), mul4(y, w)));
26343
26747
  if (!(Math.abs(det) >= 11920929e-14)) return null;
26344
- const r = div2(1, det);
26345
- const a = mul3(addDown(mul3(h, x1), mul3(nh, x0)), r);
26346
- const b = mul3(addDown(mul3(h, y1), mul3(nh, y0)), r);
26347
- const c = mul3(addDown(mul3(w, x2), mul3(nw, x0)), r);
26348
- const d = mul3(addDown(mul3(w, y2), mul3(nw, y0)), r);
26349
- const nxh = mul3(-x, h);
26350
- const nyw = mul3(-y, w);
26351
- const p = sub2(mul3(addDown(x, w), addDown(y, h)), mul3(x, y));
26352
- const e = mul3(addDown(addDown(mul3(nxh, x1), mul3(p, x0)), mul3(nyw, x2)), r);
26353
- const f = mul3(addDown(addDown(mul3(nxh, y1), mul3(p, y0)), mul3(nyw, y2)), r);
26354
- return [a, b, c, d, e, f];
26748
+ const r = div3(1, det);
26749
+ const a = mul4(addDown(mul4(h, x1), mul4(nh, x0)), r);
26750
+ const b = mul4(addDown(mul4(h, y1), mul4(nh, y0)), r);
26751
+ const c = mul4(addDown(mul4(w, x2), mul4(nw, x0)), r);
26752
+ const d = mul4(addDown(mul4(w, y2), mul4(nw, y0)), r);
26753
+ const nxh = mul4(-x, h);
26754
+ const nyw = mul4(-y, w);
26755
+ const p = sub3(mul4(addDown(x, w), addDown(y, h)), mul4(x, y));
26756
+ const e = mul4(addDown(addDown(mul4(nxh, x1), mul4(p, x0)), mul4(nyw, x2)), r);
26757
+ const f2 = mul4(addDown(addDown(mul4(nxh, y1), mul4(p, y0)), mul4(nyw, y2)), r);
26758
+ return [a, b, c, d, e, f2];
26355
26759
  }
26356
26760
  function transformPoints(m, pts) {
26357
26761
  const complexity = matrixComplexity(m);
26358
- const [a, b, c, d, e, f] = m;
26762
+ const [a, b, c, d, e, f2] = m;
26359
26763
  const out = [];
26360
26764
  for (let i = 0; i < pts.length; i += 2) {
26361
26765
  const x = pts[i];
26362
26766
  const y = pts[i + 1];
26363
26767
  if (complexity === 0) out.push(x, y);
26364
- else if ((complexity & -2) === 0) out.push(addDown(e, x), addDown(f, y));
26365
- else if ((complexity & -4) === 0) out.push(addDown(mul3(a, x), e), addDown(mul3(d, y), f));
26366
- else out.push(addDown(addDown(mul3(x, a), mul3(y, c)), e), addDown(addDown(mul3(x, b), mul3(y, d)), f));
26768
+ else if ((complexity & -2) === 0) out.push(addDown(e, x), addDown(f2, y));
26769
+ else if ((complexity & -4) === 0) out.push(addDown(mul4(a, x), e), addDown(mul4(d, y), f2));
26770
+ else out.push(addDown(addDown(mul4(x, a), mul4(y, c)), e), addDown(addDown(mul4(x, b), mul4(y, d)), f2));
26367
26771
  }
26368
26772
  return out;
26369
26773
  }
@@ -26374,15 +26778,15 @@ function driverPoints(points, src) {
26374
26778
  return transformPoints(m, [x, y, addDown(x, w), y, x, addDown(y, h)]);
26375
26779
  }
26376
26780
  function multiplyDown(n, w) {
26377
- const [a, b, c, d, e, f] = n;
26781
+ const [a, b, c, d, e, f2] = n;
26378
26782
  const [wa, wb, wc, wd, we, wf] = w;
26379
26783
  return [
26380
- addDown(mul3(a, wa), mul3(b, wc)),
26381
- addDown(mul3(a, wb), mul3(b, wd)),
26382
- addDown(mul3(c, wa), mul3(d, wc)),
26383
- addDown(mul3(c, wb), mul3(d, wd)),
26384
- addDown(addDown(mul3(e, wa), mul3(f, wc)), we),
26385
- addDown(addDown(mul3(e, wb), mul3(f, wd)), wf)
26784
+ addDown(mul4(a, wa), mul4(b, wc)),
26785
+ addDown(mul4(a, wb), mul4(b, wd)),
26786
+ addDown(mul4(c, wa), mul4(d, wc)),
26787
+ addDown(mul4(c, wb), mul4(d, wd)),
26788
+ addDown(addDown(mul4(e, wa), mul4(f2, wc)), we),
26789
+ addDown(addDown(mul4(e, wb), mul4(f2, wd)), wf)
26386
26790
  ];
26387
26791
  }
26388
26792
  function drawImagePointsDeviceMatrix(points, src, world) {
@@ -26392,32 +26796,32 @@ function drawImagePointsDeviceMatrix(points, src, world) {
26392
26796
  return n ? multiplyDown(n, world) : null;
26393
26797
  }
26394
26798
  function invertDown(m) {
26395
- const [a, b, c, d, e, f] = m;
26396
- const det = sub2(mul3(a, d), mul3(b, c));
26799
+ const [a, b, c, d, e, f2] = m;
26800
+ const det = sub3(mul4(a, d), mul4(b, c));
26397
26801
  if (!Number.isFinite(det) || det === 0) return null;
26398
- const r = div2(1, det);
26802
+ const r = div3(1, det);
26399
26803
  return [
26400
- mul3(d, r),
26401
- mul3(-b, r),
26402
- mul3(-c, r),
26403
- mul3(a, r),
26404
- mul3(sub2(mul3(c, f), mul3(d, e)), r),
26405
- mul3(sub2(mul3(b, e), mul3(a, f)), r)
26804
+ mul4(d, r),
26805
+ mul4(-b, r),
26806
+ mul4(-c, r),
26807
+ mul4(a, r),
26808
+ mul4(sub3(mul4(c, f2), mul4(d, e)), r),
26809
+ mul4(sub3(mul4(b, e), mul4(a, f2)), r)
26406
26810
  ];
26407
26811
  }
26408
26812
  function spanPositions(inv3, x0, y, n, us, vs) {
26409
- const [a, b, c, d, e, f] = inv3;
26813
+ const [a, b, c, d, e, f2] = inv3;
26410
26814
  const complexity = matrixComplexity(inv3);
26411
26815
  const at = (x) => {
26412
26816
  if (complexity === 0) return [x, y];
26413
- if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f)];
26414
- if ((complexity & -4) === 0) return [addDown(mul3(x, a), e), addDown(mul3(y, d), f)];
26415
- return [addDown(addDown(mul3(a, x), mul3(c, y)), e), addDown(addDown(mul3(b, x), mul3(d, y)), f)];
26817
+ if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f2)];
26818
+ if ((complexity & -4) === 0) return [addDown(mul4(x, a), e), addDown(mul4(y, d), f2)];
26819
+ return [addDown(addDown(mul4(a, x), mul4(c, y)), e), addDown(addDown(mul4(b, x), mul4(d, y)), f2)];
26416
26820
  };
26417
26821
  const [u0, v0] = at(x0);
26418
26822
  const [u1, v1] = at(x0 + n);
26419
- const su = div2(sub2(u1, u0), n);
26420
- const sv = div2(sub2(v1, v0), n);
26823
+ const su = div3(sub3(u1, u0), n);
26824
+ const sv = div3(sub3(v1, v0), n);
26421
26825
  let u = u0;
26422
26826
  let v = v0;
26423
26827
  for (let i = 0; i < n; i++) {
@@ -26427,6 +26831,62 @@ function spanPositions(inv3, x0, y, n, us, vs) {
26427
26831
  v = addDown(v, sv);
26428
26832
  }
26429
26833
  }
26834
+ function bicubicSpanPositions(inv3, x0, y, n, us, vs) {
26835
+ const [a, b, c, d, e, f2] = inv3;
26836
+ const complexity = matrixComplexity(inv3);
26837
+ const at = (x) => {
26838
+ if (complexity === 0) return [x, y];
26839
+ if ((complexity & -2) === 0) return [addDown(x, e), addDown(y, f2)];
26840
+ if ((complexity & -4) === 0) return [addDown(mul4(x, a), e), addDown(mul4(y, d), f2)];
26841
+ return [addDown(addDown(mul4(a, x), mul4(c, y)), e), addDown(addDown(mul4(b, x), mul4(d, y)), f2)];
26842
+ };
26843
+ const [u0, v0] = at(x0);
26844
+ const [u1, v1] = at(x0 + n);
26845
+ const fix = (p) => {
26846
+ const r = Math.floor(addDown(mul4(p, 65536), 0.5));
26847
+ return r >= -2147483648 && r <= 2147483647 ? r : -2147483648;
26848
+ };
26849
+ const stepOf = (p0, p1) => fix2(div3(mul4(sub3(p1, p0), 65536), n));
26850
+ const fix2 = (q) => {
26851
+ const r = Math.floor(addDown(q, 0.5));
26852
+ return r >= -2147483648 && r <= 2147483647 ? r : -2147483648;
26853
+ };
26854
+ let u = fix(u0);
26855
+ let v = fix(v0);
26856
+ const su = stepOf(u0, u1);
26857
+ const sv = stepOf(v0, v1);
26858
+ for (let i = 0; i < n; i++) {
26859
+ us[i] = u;
26860
+ vs[i] = v;
26861
+ u = u + su | 0;
26862
+ v = v + sv | 0;
26863
+ }
26864
+ }
26865
+ function rectFormPoints(src, dest) {
26866
+ const [sx, sy, sw, sh] = src.map(Math.fround);
26867
+ const [dx, dy, dw, dh] = dest.map(Math.fround);
26868
+ const sxr = addDown(sx, sw);
26869
+ const syb = addDown(sy, sh);
26870
+ const dxr = addDown(dx, dw);
26871
+ const dyb = addDown(dy, dh);
26872
+ if (sx === sxr || sy === syb) return null;
26873
+ const m11 = div3(sub3(dxr, dx), sub3(sxr, sx));
26874
+ const m22 = div3(sub3(dyb, dy), sub3(syb, sy));
26875
+ const e = sub3(dxr, mul4(m11, sxr));
26876
+ const f2 = sub3(dyb, mul4(m22, syb));
26877
+ return transformPoints([m11, 0, 0, m22, e, f2], [sx, sy, sxr, sy, sx, syb]);
26878
+ }
26879
+ function deviceDestRect(device, src) {
26880
+ const [sx, sy, sw, sh] = src.map(Math.fround);
26881
+ const p = transformPoints(device, [sx, sy, addDown(sx, sw), addDown(sy, sh)]);
26882
+ return [p[0], p[1], sub3(p[2], p[0]), sub3(p[3], p[1])];
26883
+ }
26884
+ function rectFormDeviceMatrix(src, dest, world) {
26885
+ const pts = rectFormPoints(src, dest);
26886
+ if (!pts) return null;
26887
+ const n = inferPointsMatrix(pts, src);
26888
+ return n ? multiplyDown(n, world) : null;
26889
+ }
26430
26890
 
26431
26891
  // src/emf-plus-hq-cubic-weights.ts
26432
26892
  var HQ_CUBIC_HALF_TABLE = [
@@ -26528,6 +26988,270 @@ function hqCubicCdf(m) {
26528
26988
  return HQ_CUBIC_CDF[m + 256];
26529
26989
  }
26530
26990
 
26991
+ // src/gdiplus-span-stretch.ts
26992
+ var TWO_POW_M16 = 1 / 65536;
26993
+ function tentTable(n) {
26994
+ if (n <= -128) return 0;
26995
+ if (n >= 128) return 65536;
26996
+ return 32768 + (n < 0 ? -(512 * -n - 2 * n * n) : 512 * n - 2 * n * n);
26997
+ }
26998
+ function cubicTable(n) {
26999
+ if (n < -256) return 0;
27000
+ if (n > 255) return 65536;
27001
+ return 32768 + hqCubicCdf(n);
27002
+ }
27003
+ var i32 = (v) => v | 0;
27004
+ var mulShift16 = (a, b) => Math.floor(a * b / 65536);
27005
+ function validFixed16(v) {
27006
+ return v >= -32768 && v <= 32767;
27007
+ }
27008
+ function createStretch(request) {
27009
+ const [sx, sy, sw, sh] = request.src.map(Math.fround);
27010
+ const [dx, dy, dw, dh] = request.dest.map(Math.fround);
27011
+ if (![sx, sy, sw, sh, dx, dy, dw, dh].every(validFixed16)) return null;
27012
+ const kScale = request.kernel === "cubic" ? 2 : 1;
27013
+ const minStretch = request.kernel === "cubic" ? 131072 : 65536;
27014
+ const half = 0.5;
27015
+ const fix = (v2) => floorInt(add(mul(v2, 65536), half));
27016
+ const xStepS = fix(div(sw, dw));
27017
+ fix(div(dw, sw));
27018
+ const yStepS = fix(div(sh, dh));
27019
+ fix(div(dh, sh));
27020
+ if (xStepS === 0 || yStepS === 0) return null;
27021
+ const grid = (v2) => floorInt(add(mul(v2, 16), half));
27022
+ const left = grid(dx);
27023
+ const right = grid(add(mul(sw, div(dw, sw)), dx));
27024
+ const top = grid(dy);
27025
+ const bottom = grid(add(mul(sh, div(dh, sh)), dy));
27026
+ const lo = Math.min(left, right);
27027
+ const hi = Math.max(left, right);
27028
+ const topLo = Math.min(top, bottom);
27029
+ const botHi = Math.max(top, bottom);
27030
+ const firstColumn = lo + 15 >> 4;
27031
+ const loFix = i32(lo << 12);
27032
+ const hiFix = i32(hi << 12);
27033
+ const topFix = i32(topLo << 12);
27034
+ const botFix = i32(botHi << 12);
27035
+ const floatOf = (v2) => down32(v2);
27036
+ const sxF = floatOf(xStepS);
27037
+ let xBase;
27038
+ let xEdge;
27039
+ if (xStepS < 0) {
27040
+ xBase = floatOf(hiFix + 65535 >> 16);
27041
+ xEdge = add(dx, dw);
27042
+ } else {
27043
+ xBase = floatOf(loFix >> 16);
27044
+ xEdge = dx;
27045
+ }
27046
+ let v = sub(xEdge, xBase);
27047
+ v = mul(v, sxF);
27048
+ v = mul(v, TWO_POW_M16);
27049
+ v = add(v, sx);
27050
+ const xStart = fix(v);
27051
+ const stretchOf = (s, d) => {
27052
+ let r = fix(div(mul(kScale, s), d));
27053
+ if (r < 0) r = -r;
27054
+ return r < minStretch ? minStretch : r;
27055
+ };
27056
+ const xStretch = stretchOf(sw, dw);
27057
+ const xRecip = floorInt(add(mul(div(65536, floatOf(xStretch)), 65536), half));
27058
+ const syF = floatOf(yStepS);
27059
+ let yStart;
27060
+ if (yStepS < 0) {
27061
+ let w = floatOf(botFix + 65535 >> 16);
27062
+ w = sub(w, add(dh, dy));
27063
+ w = mul(w, syF);
27064
+ w = mul(w, TWO_POW_M16);
27065
+ yStart = fix(sub(sy, w));
27066
+ } else {
27067
+ let w = floatOf(topFix >> 16);
27068
+ w = sub(w, dy);
27069
+ w = mul(w, syF);
27070
+ w = mul(w, TWO_POW_M16);
27071
+ yStart = fix(add(w, sy));
27072
+ }
27073
+ const yStretch = stretchOf(sh, dh);
27074
+ const yRecip = floorInt(add(mul(div(65536, floatOf(yStretch)), 65536), half));
27075
+ const firstRow = topFix >> 16;
27076
+ const columns = (hiFix + 65535 >> 16) - (loFix >> 16) + 1;
27077
+ const kernelRows = 2 * (yStretch + 65535 >> 16) + 1;
27078
+ const range = (stretch, start) => {
27079
+ const r = start - 32768;
27080
+ return r >= -2147483648 && r <= 2147483647 && r - stretch >= -2147483648 && r + stretch <= 2147483647;
27081
+ };
27082
+ if (!range(xStretch, xStart) || !range(yStretch, yStart)) return null;
27083
+ return {
27084
+ request,
27085
+ firstColumn,
27086
+ columns,
27087
+ firstRow,
27088
+ xStart,
27089
+ xStep: xStepS,
27090
+ xStretch,
27091
+ xRecip,
27092
+ yStart,
27093
+ yStep: yStepS,
27094
+ yStretch,
27095
+ yRecip,
27096
+ kernelRows,
27097
+ table: request.kernel === "cubic" ? cubicTable : tentTable,
27098
+ shift: request.kernel === "cubic" ? 8 : 9,
27099
+ rows: /* @__PURE__ */ new Map()
27100
+ };
27101
+ }
27102
+ function wrapIndex2(index, size, mirror2) {
27103
+ if (!mirror2) {
27104
+ return (index % size + size) % size;
27105
+ }
27106
+ const q = (index % size + size) % size;
27107
+ return Math.floor(index / size) % 2 !== 0 ? size - q - 1 : q;
27108
+ }
27109
+ function clampBytes(argb) {
27110
+ return [argb >>> 16 & 255, argb >>> 8 & 255, argb & 255, argb >>> 24];
27111
+ }
27112
+ function stretchRow(state, rowPixels) {
27113
+ const { request, columns, xStart, xStep, xStretch, xRecip, table: table2, shift } = state;
27114
+ const { width, wrap = 4, clampArgb = 0 } = request;
27115
+ const cubic = request.kernel === "cubic";
27116
+ const out = new Uint8Array(columns * 4);
27117
+ const clamp2 = clampBytes(clampArgb);
27118
+ const mirrorX = wrap === 1 || wrap === 3;
27119
+ let pos = i32(xStart - 32768);
27120
+ const sum = [0, 0, 0, 0];
27121
+ for (let c = 0; c < columns; c++) {
27122
+ const edx = i32(xStretch + 65535 + pos);
27123
+ const last = edx >> 16;
27124
+ const first = i32(edx - 2 * xStretch) >> 16;
27125
+ sum[0] = sum[1] = sum[2] = sum[3] = 0;
27126
+ let prev = 0;
27127
+ const accumulate = (idx2, pixel, o2) => {
27128
+ const t = table2(i32(idx2) >> shift);
27129
+ const wgt = t - prev;
27130
+ prev = t;
27131
+ sum[0] += pixel[o2] * wgt;
27132
+ sum[1] += pixel[o2 + 1] * wgt;
27133
+ sum[2] += pixel[o2 + 2] * wgt;
27134
+ sum[3] += pixel[o2 + 3] * wgt;
27135
+ };
27136
+ const startOf = (col) => mulShift16(i32(i32(col << 16) - pos), xRecip);
27137
+ const inFirst = first < 0 ? 0 : first;
27138
+ const inLast = last < width - 1 ? last : width - 1;
27139
+ let idx = startOf(first);
27140
+ for (let t = first; t < Math.min(inFirst, last + 1); t++) {
27141
+ if (wrap === 4 || !rowPixels) accumulate(idx, clamp2, 0);
27142
+ else accumulate(idx, rowPixels, wrapIndex2(t, width, mirrorX) * 4);
27143
+ idx = i32(idx + xRecip);
27144
+ }
27145
+ if (inFirst <= inLast) {
27146
+ idx = startOf(inFirst);
27147
+ for (let t = inFirst; t <= inLast; t++) {
27148
+ if (rowPixels) accumulate(idx, rowPixels, t * 4);
27149
+ else accumulate(idx, clamp2, 0);
27150
+ idx = i32(idx + xRecip);
27151
+ }
27152
+ }
27153
+ const rightFirst = Math.max(inLast + 1, first);
27154
+ if (rightFirst <= last) {
27155
+ idx = startOf(rightFirst);
27156
+ for (let t = rightFirst; t <= last; t++) {
27157
+ if (wrap === 4 || !rowPixels) accumulate(idx, clamp2, 0);
27158
+ else accumulate(idx, rowPixels, wrapIndex2(t, width, mirrorX) * 4);
27159
+ idx = i32(idx + xRecip);
27160
+ }
27161
+ }
27162
+ const o = c * 4;
27163
+ const a = Math.max(0, Math.min(255, sum[3] + 32768 >> 16));
27164
+ out[o + 3] = a;
27165
+ for (let ch = 0; ch < 3; ch++) {
27166
+ const v = sum[ch] + 32768 >> 16;
27167
+ out[o + ch] = cubic ? Math.max(0, Math.min(a, v)) : Math.min(255, v);
27168
+ }
27169
+ pos = i32(pos + xStep);
27170
+ }
27171
+ return out;
27172
+ }
27173
+ function stretchedRow(state, row2) {
27174
+ const { request } = state;
27175
+ const { height, width, wrap = 4 } = request;
27176
+ let r = row2;
27177
+ if (r < 0 || r >= height) {
27178
+ if (wrap === 4) {
27179
+ return null;
27180
+ }
27181
+ r = wrapIndex2(r, height, wrap === 2 || wrap === 3);
27182
+ }
27183
+ let cached = state.rows.get(r);
27184
+ if (!cached) {
27185
+ 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));
27186
+ cached = stretchRow(state, pixels);
27187
+ state.rows.set(r, cached);
27188
+ }
27189
+ return cached;
27190
+ }
27191
+ function clampRow(state) {
27192
+ let cached = state.rows.get(Number.NaN);
27193
+ if (!cached) {
27194
+ cached = stretchRow(state, null);
27195
+ state.rows.set(Number.NaN, cached);
27196
+ }
27197
+ return cached;
27198
+ }
27199
+ function stretchRun(state, y, xLeft, xRight) {
27200
+ const { firstColumn, columns, firstRow, yStart, yStep, yStretch, yRecip, kernelRows, table: table2, shift } = state;
27201
+ const xs = Math.max(xLeft, firstColumn);
27202
+ const xe = Math.min(xRight, firstColumn + columns);
27203
+ if (xe < xs || xe - xs > columns) return null;
27204
+ const n = xe - xs;
27205
+ const row2 = Math.max(y, firstRow);
27206
+ const pos = i32(yStart - 32768 + i32((row2 - firstRow) * yStep));
27207
+ const lastSource = i32(pos + yStretch + 65535) >> 16;
27208
+ const firstSource = i32(pos - yStretch + 65535) >> 16;
27209
+ if (lastSource < firstSource) return null;
27210
+ let idx = mulShift16(i32(i32(firstSource << 16) - pos), yRecip);
27211
+ let prev = 0;
27212
+ const sources = [];
27213
+ const weights = [];
27214
+ for (let k = 0; k < kernelRows; k++) {
27215
+ const source = firstSource + k;
27216
+ if (source > lastSource) {
27217
+ weights.push(0);
27218
+ sources.push(null);
27219
+ continue;
27220
+ }
27221
+ const t = table2(i32(idx) >> shift);
27222
+ weights.push(t - prev);
27223
+ prev = t;
27224
+ idx = i32(idx + yRecip);
27225
+ 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));
27226
+ }
27227
+ const cubic = state.request.kernel === "cubic";
27228
+ const pixels = new Uint8Array(n * 4);
27229
+ for (let i = 0; i < n; i++) {
27230
+ const col = (xs - firstColumn + i) * 4;
27231
+ let r = 0;
27232
+ let g = 0;
27233
+ let b = 0;
27234
+ let a = 0;
27235
+ for (let k = 0; k < kernelRows; k++) {
27236
+ const src = sources[k];
27237
+ if (!src) continue;
27238
+ const wgt = weights[k];
27239
+ r += src[col] * wgt;
27240
+ g += src[col + 1] * wgt;
27241
+ b += src[col + 2] * wgt;
27242
+ a += src[col + 3] * wgt;
27243
+ }
27244
+ const o = i * 4;
27245
+ const alpha = Math.max(0, Math.min(255, a + 32768 >> 16));
27246
+ pixels[o + 3] = alpha;
27247
+ for (const [ch, v] of [[0, r], [1, g], [2, b]]) {
27248
+ const q = v + 32768 >> 16;
27249
+ pixels[o + ch] = cubic ? Math.max(0, Math.min(alpha, q)) : Math.min(255, q);
27250
+ }
27251
+ }
27252
+ return { x: xs, pixels };
27253
+ }
27254
+
26531
27255
  // src/emf-plus-image-resample.ts
26532
27256
  var INTERPOLATION_KERNELS = {
26533
27257
  0: "bilinear",
@@ -26629,11 +27353,11 @@ function nearSourceExtent(deviceLen, srcLen) {
26629
27353
  return d >= -1 && d <= 1;
26630
27354
  }
26631
27355
  function unitCopyOffset(t, other, spec) {
26632
- const f = t - Math.round(t);
26633
- if (f > -1 / 64 + 1e-9) {
26634
- return f <= 1 / 64 + 1e-9;
27356
+ const f2 = t - Math.round(t);
27357
+ if (f2 > -1 / 64 + 1e-9) {
27358
+ return f2 <= 1 / 64 + 1e-9;
26635
27359
  }
26636
- if (Math.abs(f + 1 / 64) > 1e-9 || !isPowerOfTwo(spec.srcW) || !isPowerOfTwo(spec.srcH)) {
27360
+ if (Math.abs(f2 + 1 / 64) > 1e-9 || !isPowerOfTwo(spec.srcW) || !isPowerOfTwo(spec.srcH)) {
26637
27361
  return false;
26638
27362
  }
26639
27363
  const g = (other - Math.round(other)) * 128;
@@ -26751,11 +27475,11 @@ function wrapTap(t, lo, hi, mirror2, edge) {
26751
27475
  return lo + (q < n ? q : 2 * n - 1 - q);
26752
27476
  }
26753
27477
  function mirroredOrigin(o) {
26754
- const f = o - Math.floor(o);
26755
- return f === 0 ? o : Math.floor(o) + 1 - f;
27478
+ const f2 = o - Math.floor(o);
27479
+ return f2 === 0 ? o : Math.floor(o) + 1 - f2;
26756
27480
  }
26757
27481
  function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26758
- const { plainRotated: plainRotatedPass = false, keepOrigin = false, premultSource = false, premultOut = false } = typeof options2 === "boolean" ? { plainRotated: options2 } : options2;
27482
+ const { plainRotated: plainRotatedPass = false, keepOrigin = false, premultSource = false, premultOut = false, rasterQuad, rasterHalf = false, chainPad = 0 } = typeof options2 === "boolean" ? { plainRotated: options2 } : options2;
26759
27483
  if (spec.rightHalo && spec.rightHalo.length === height * 4) {
26760
27484
  const grown = new Uint8ClampedArray((width + 1) * height * 4);
26761
27485
  for (let y = 0; y < height; y++) {
@@ -26838,7 +27562,7 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26838
27562
  if (!(w > 0 && h > 0) || w * h > MAX_RESAMPLE_PIXELS) {
26839
27563
  return null;
26840
27564
  }
26841
- const rasterCoverage = rasterCovered ? rasterizePlusFill(
27565
+ const rasterCoverage = rasterQuad ? rasterizePlusFill([rasterQuad], false, false, rasterHalf, { x: bx0, y: by0, w, h }) : rasterCovered ? rasterizePlusFill(
26842
27566
  [[
26843
27567
  [spec.srcX, spec.srcY],
26844
27568
  [spec.srcX + spec.srcW, spec.srcY],
@@ -26878,12 +27602,18 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26878
27602
  const bicubicDv = Math.round(inv3[1] * FIX16);
26879
27603
  const steppedInv = !plainRotatedPass && (kernel === "bilinear" || kernel === "bicubic" && !axisAligned) ? invertTextureMatrix(m) : null;
26880
27604
  let exactInv = null;
26881
- if (steppedInv && spec.pointsForm && spec.worldPoints && spec.worldMatrix && kernel === "bilinear" && axisAligned && !spec.halfPixelOffset && !spec.wrap) {
26882
- const device = drawImagePointsDeviceMatrix(spec.worldPoints, [spec.srcX, spec.srcY, spec.srcW, spec.srcH], spec.worldMatrix);
27605
+ if ((steppedInv || plainRotatedPass) && spec.pointsForm && spec.worldPoints && spec.worldMatrix && (kernel === "bilinear" || kernel === "bicubic") && !spec.halfPixelOffset && !spec.chainHalf && !spec.wrap) {
27606
+ const device = drawImagePointsDeviceMatrix(spec.worldPoints, spec.chainSrc ?? [spec.srcX, spec.srcY, spec.srcW, spec.srcH], spec.worldMatrix);
27607
+ exactInv = device && invertDown(device);
27608
+ } else if (plainRotatedPass && spec.chainHalf && spec.pointsForm && spec.worldPoints && spec.worldMatrix && spec.chainSrc && (kernel === "bilinear" || kernel === "bicubic")) {
27609
+ const w2 = spec.worldMatrix;
27610
+ 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)]);
26883
27611
  exactInv = device && invertDown(device);
26884
27612
  }
26885
27613
  const runU = new Float64Array(w);
26886
27614
  const runV = new Float64Array(w);
27615
+ const fixU = new Int32Array(w);
27616
+ const fixV = new Int32Array(w);
26887
27617
  let runBase = 0;
26888
27618
  const covers = (px, py) => {
26889
27619
  const cx = px + COVERAGE_NUDGE_X;
@@ -26922,10 +27652,19 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26922
27652
  while (end < w && (rasterCoverage ? rasterCoverage[j * w + end] !== 0 : covers(bx0 + end + o, py))) {
26923
27653
  end++;
26924
27654
  }
26925
- spanPositions(exactInv, bx0 + i, by0 + j, end - i, runU, runV);
27655
+ if (integerBicubic) {
27656
+ bicubicSpanPositions(exactInv, bx0 + i, by0 + j, end - i, fixU, fixV);
27657
+ } else {
27658
+ spanPositions(exactInv, bx0 + i, by0 + j, end - i, runU, runV);
27659
+ }
27660
+ }
27661
+ if (integerBicubic) {
27662
+ u = (fixU[i - runBase] + chainPad * FIX16) / FIX16;
27663
+ v = (fixV[i - runBase] + chainPad * FIX16) / FIX16;
27664
+ } else {
27665
+ u = runU[i - runBase] + chainPad;
27666
+ v = runV[i - runBase] + chainPad;
26926
27667
  }
26927
- u = runU[i - runBase];
26928
- v = runV[i - runBase];
26929
27668
  } else if (steppedInv) {
26930
27669
  if (start < 0) {
26931
27670
  start = i;
@@ -26948,7 +27687,10 @@ function resampleImage(rgba, width, height, spec, surface, options2 = {}) {
26948
27687
  }
26949
27688
  }
26950
27689
  if (integerBicubic) {
26951
- if (steppedInv) {
27690
+ if (exactInv) {
27691
+ u = Math.floor(u * 64) / 64;
27692
+ v = Math.floor(v * 64) / 64;
27693
+ } else if (steppedInv) {
26952
27694
  u = Math.floor(u * 64) / 64;
26953
27695
  v = Math.floor(v * 64) / 64;
26954
27696
  } else {
@@ -27126,6 +27868,10 @@ function resampleHqAxisAligned(rgba, width, height, spec, surface, m, premultOut
27126
27868
  if (w * h > MAX_RESAMPLE_PIXELS) {
27127
27869
  return null;
27128
27870
  }
27871
+ const stretched = resampleHqStretch(rgba, width, height, spec, cx0, cy0, w, h, premultOut);
27872
+ if (stretched) {
27873
+ return stretched;
27874
+ }
27129
27875
  const cubic = kernel === "hq-bicubic";
27130
27876
  const bin = cubic ? 0.5 : 1;
27131
27877
  let stepU = hqStep(scaleU);
@@ -27305,7 +28051,71 @@ function resampleHqAxisAligned(rgba, width, height, spec, surface, m, premultOut
27305
28051
  }
27306
28052
  return { x: cx0, y: cy0, w, h, rgba: out, premultiplied: premultOut };
27307
28053
  }
27308
- function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel, near) {
28054
+ function resampleHqStretch(rgba, width, height, spec, x0, y0, w, h, premultOut) {
28055
+ const world = spec.worldMatrix;
28056
+ if (spec.halfPixelOffset || !world || spec.wrap || spec.srcX !== 0 || spec.srcY !== 0 || spec.srcW !== width || spec.srcH !== height) {
28057
+ return void 0;
28058
+ }
28059
+ const src = [spec.srcX, spec.srcY, spec.srcW, spec.srcH];
28060
+ const inferred = spec.worldRect ? null : spec.worldPoints ? inferPointsMatrix(spec.worldPoints, src) : null;
28061
+ const device = spec.worldRect ? rectFormDeviceMatrix(src, spec.worldRect, world) : inferred ? multiplyDown(inferred, world) : null;
28062
+ if (!device || !(device[0] > 0 && device[3] > 0)) {
28063
+ return void 0;
28064
+ }
28065
+ const dest = deviceDestRect(device, src);
28066
+ const premultiplied2 = new Uint8Array(width * height * 4);
28067
+ for (let i = 0; i < width * height * 4; i += 4) {
28068
+ const a = rgba[i + 3];
28069
+ premultiplied2[i] = Math.round(rgba[i] * a / 255);
28070
+ premultiplied2[i + 1] = Math.round(rgba[i + 1] * a / 255);
28071
+ premultiplied2[i + 2] = Math.round(rgba[i + 2] * a / 255);
28072
+ premultiplied2[i + 3] = a;
28073
+ }
28074
+ const state = createStretch({
28075
+ kernel: spec.kernel === "hq-bicubic" ? "cubic" : "tent",
28076
+ pixels: premultiplied2,
28077
+ width,
28078
+ height,
28079
+ src,
28080
+ dest
28081
+ });
28082
+ if (!state) {
28083
+ return void 0;
28084
+ }
28085
+ const out = new Uint8ClampedArray(w * h * 4);
28086
+ for (let j = 0; j < h; j++) {
28087
+ const run = stretchRun(state, y0 + j, x0, x0 + w);
28088
+ if (!run) {
28089
+ continue;
28090
+ }
28091
+ for (let i = 0; i < run.pixels.length / 4; i++) {
28092
+ const o = run.pixels.subarray(i * 4, i * 4 + 4);
28093
+ const alpha = o[3];
28094
+ if (alpha === 0) {
28095
+ continue;
28096
+ }
28097
+ const d = (j * w + run.x - x0 + i) * 4;
28098
+ const k = premultOut ? 1 : 255 / alpha;
28099
+ out[d] = o[0] * k;
28100
+ out[d + 1] = o[1] * k;
28101
+ out[d + 2] = o[2] * k;
28102
+ out[d + 3] = alpha;
28103
+ }
28104
+ }
28105
+ return { x: x0, y: y0, w, h, rgba: out, premultiplied: premultOut };
28106
+ }
28107
+ function deviceEdgeLengths(points, world) {
28108
+ const p = transformPoints(world, points);
28109
+ const length = (dx, dy) => Math.ceil(sqrt(addDown(mul(dy, dy), mul(dx, dx))));
28110
+ return [
28111
+ length(addDown(p[2], -p[0]), addDown(p[3], -p[1])),
28112
+ length(addDown(p[4], -p[0]), addDown(p[5], -p[1]))
28113
+ ];
28114
+ }
28115
+ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel, nearHint) {
28116
+ const chain = !!(spec.pointsForm && spec.worldPoints && spec.worldMatrix && !spec.wrap);
28117
+ const edges = chain ? deviceEdgeLengths(spec.worldPoints, spec.worldMatrix) : null;
28118
+ const near = edges ? Math.abs(edges[0] - spec.srcW) <= 1.0000001 || Math.abs(edges[1] - spec.srcH) <= 1.0000001 : nearHint;
27309
28119
  const pad = spec.wrap ? 0 : 2;
27310
28120
  let img;
27311
28121
  let pw;
@@ -27317,6 +28127,8 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27317
28127
  let ex;
27318
28128
  let ey;
27319
28129
  const half = spec.halfPixelOffset;
28130
+ let interW = 0;
28131
+ let interH = 0;
27320
28132
  if (near) {
27321
28133
  pw = width + 2 * pad;
27322
28134
  ph = height + 2 * pad;
@@ -27336,8 +28148,10 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27336
28148
  ex = m[4] - (half ? 0.5 : 0);
27337
28149
  ey = m[5] - (half ? 0.5 : 0);
27338
28150
  } else {
27339
- const W = ceilExtent(Math.hypot(m[0], m[1]) * spec.srcW);
27340
- const H = ceilExtent(Math.hypot(m[2], m[3]) * spec.srcH);
28151
+ const W = edges ? edges[0] : ceilExtent(Math.hypot(m[0], m[1]) * spec.srcW);
28152
+ const H = edges ? edges[1] : ceilExtent(Math.hypot(m[2], m[3]) * spec.srcH);
28153
+ interW = W;
28154
+ interH = H;
27341
28155
  const kx = W / spec.srcW;
27342
28156
  const ky = H / spec.srcH;
27343
28157
  const pre = resampleImage(rgba, width, height, {
@@ -27383,6 +28197,12 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27383
28197
  ex = half ? ox - 0.5 + 0.5 * (a + c) : ox;
27384
28198
  ey = half ? oy - 0.5 + 0.5 * (b + d) : oy;
27385
28199
  }
28200
+ const corners = [
28201
+ [spec.srcX, spec.srcY],
28202
+ [spec.srcX + spec.srcW, spec.srcY],
28203
+ [spec.srcX + spec.srcW, spec.srcY + spec.srcH],
28204
+ [spec.srcX, spec.srcY + spec.srcH]
28205
+ ].flatMap(([u, v]) => [toPlusFix(m[0] * u + m[2] * v + m[4]), toPlusFix(m[1] * u + m[3] * v + m[5])]);
27386
28206
  const block = resampleImage(img, pw, ph, {
27387
28207
  srcX: 0,
27388
28208
  srcY: 0,
@@ -27392,17 +28212,18 @@ function resampleRotatedTwoStage(rgba, width, height, spec, surface, m, kernel,
27392
28212
  kernel: kernel === "hq-bicubic" ? "bicubic" : "bilinear",
27393
28213
  halfPixelOffset: false,
27394
28214
  wrap: spec.wrap,
27395
- clampArgb: spec.clampArgb
27396
- }, surface, { plainRotated: true, keepOrigin: true, premultSource: true });
28215
+ clampArgb: spec.clampArgb,
28216
+ ...chain ? {
28217
+ pointsForm: true,
28218
+ worldPoints: spec.worldPoints,
28219
+ worldMatrix: spec.worldMatrix,
28220
+ chainSrc: near ? [spec.srcX, spec.srcY, spec.srcW, spec.srcH] : [half ? -0.5 : 0, half ? -0.5 : 0, interW, interH],
28221
+ ...half ? { chainHalf: true } : {}
28222
+ } : {}
28223
+ }, surface, { plainRotated: true, keepOrigin: true, premultSource: true, ...chain ? { rasterQuad: corners, rasterHalf: half, chainPad: pad } : {} });
27397
28224
  if (!block) {
27398
28225
  return block;
27399
28226
  }
27400
- const corners = [
27401
- [spec.srcX, spec.srcY],
27402
- [spec.srcX + spec.srcW, spec.srcY],
27403
- [spec.srcX + spec.srcW, spec.srcY + spec.srcH],
27404
- [spec.srcX, spec.srcY + spec.srcH]
27405
- ].flatMap(([u, v]) => [toPlusFix(m[0] * u + m[2] * v + m[4]), toPlusFix(m[1] * u + m[3] * v + m[5])]);
27406
28227
  const coverage = rasterizePlusFill([corners], false, false, half, { x: block.x, y: block.y, w: block.w, h: block.h });
27407
28228
  for (let i = 0; i < block.w * block.h; i++) {
27408
28229
  if (!coverage[i]) {
@@ -28120,7 +28941,7 @@ function filterScanlines(input, width, height) {
28120
28941
  const stride = width * 4;
28121
28942
  const words = data.byteOffset % 4 === 0 ? new Uint32Array(data.buffer, data.byteOffset, width * height) : null;
28122
28943
  const out = new Uint8Array((stride + 1) * height);
28123
- const sub3 = new Uint8Array(stride);
28944
+ const sub4 = new Uint8Array(stride);
28124
28945
  const up = new Uint8Array(stride);
28125
28946
  const pae = new Uint8Array(stride);
28126
28947
  for (let y = 0; y < height; y++) {
@@ -28155,12 +28976,12 @@ function filterScanlines(input, width, height) {
28155
28976
  let upScore = 0;
28156
28977
  for (let i = 0; i < 4 && i < stride; i++) {
28157
28978
  const x = data[row2 + i];
28158
- sub3[i] = x;
28979
+ sub4[i] = x;
28159
28980
  subScore += x < 128 ? x : 256 - x;
28160
28981
  }
28161
28982
  for (let i = 4; i < stride; i++) {
28162
28983
  const v = data[row2 + i] - data[row2 + i - 4] & 255;
28163
- sub3[i] = v;
28984
+ sub4[i] = v;
28164
28985
  subScore += v < 128 ? v : 256 - v;
28165
28986
  }
28166
28987
  if (y > 0) {
@@ -28178,7 +28999,7 @@ function filterScanlines(input, width, height) {
28178
28999
  let bestScore = noneScore;
28179
29000
  if (subScore < bestScore) {
28180
29001
  bestScore = subScore;
28181
- best = sub3;
29002
+ best = sub4;
28182
29003
  code = 1;
28183
29004
  }
28184
29005
  if (upScore < bestScore) {
@@ -28434,7 +29255,7 @@ function svgTreeToJsx(node, options2 = {}) {
28434
29255
 
28435
29256
  // src/svg-context.ts
28436
29257
  var IDENTITY3 = [1, 0, 0, 1, 0, 0];
28437
- function mul4(m, n) {
29258
+ function mul5(m, n) {
28438
29259
  return [
28439
29260
  m[0] * n[0] + m[2] * n[1],
28440
29261
  m[1] * n[0] + m[3] * n[1],
@@ -28971,23 +29792,23 @@ var SvgContext = class {
28971
29792
  this.shadow?.restore();
28972
29793
  }
28973
29794
  getTransform() {
28974
- const [a, b, c, d, e, f] = this.state.transform;
28975
- return { a, b, c, d, e, f };
29795
+ const [a, b, c, d, e, f2] = this.state.transform;
29796
+ return { a, b, c, d, e, f: f2 };
28976
29797
  }
28977
- setTransform(a, b, c, d, e, f) {
28978
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
28979
- this.state.transform = [a, b, c, d, e, f];
29798
+ setTransform(a, b, c, d, e, f2) {
29799
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
29800
+ this.state.transform = [a, b, c, d, e, f2];
28980
29801
  }
28981
- this.shadow?.setTransform(a, b, c, d, e, f);
29802
+ this.shadow?.setTransform(a, b, c, d, e, f2);
28982
29803
  }
28983
29804
  resetTransform() {
28984
29805
  this.setTransform(1, 0, 0, 1, 0, 0);
28985
29806
  }
28986
- transform(a, b, c, d, e, f) {
28987
- if ([a, b, c, d, e, f].every(Number.isFinite)) {
28988
- this.state.transform = mul4(this.state.transform, [a, b, c, d, e, f]);
29807
+ transform(a, b, c, d, e, f2) {
29808
+ if ([a, b, c, d, e, f2].every(Number.isFinite)) {
29809
+ this.state.transform = mul5(this.state.transform, [a, b, c, d, e, f2]);
28989
29810
  }
28990
- this.shadow?.transform(a, b, c, d, e, f);
29811
+ this.shadow?.transform(a, b, c, d, e, f2);
28991
29812
  }
28992
29813
  translate(x, y) {
28993
29814
  this.transform(1, 0, 0, 1, x, y);
@@ -29167,7 +29988,7 @@ var SvgContext = class {
29167
29988
  return { tag: g.type === "linear" ? "linearGradient" : "radialGradient", attrs, children: stops };
29168
29989
  }
29169
29990
  patternNode(p, id, space) {
29170
- const m = mul4(space, p.matrix);
29991
+ const m = mul5(space, p.matrix);
29171
29992
  let spanU = p.width;
29172
29993
  let spanV = p.height;
29173
29994
  const im = inv(m);
@@ -29496,7 +30317,7 @@ var SvgContext = class {
29496
30317
  let m = run.matrix ? [...run.matrix] : null;
29497
30318
  if (run.scaleX && run.scaleX !== 1) {
29498
30319
  const s = [run.scaleX, 0, 0, 1, 0, 0];
29499
- m = m ? mul4(m, s) : s;
30320
+ m = m ? mul5(m, s) : s;
29500
30321
  attrs.x = run.xs.map((v) => fmt(v / run.scaleX)).join(" ");
29501
30322
  }
29502
30323
  if (m && !isIdentity(m)) {
@@ -29784,25 +30605,25 @@ function canReadBack(ctx) {
29784
30605
 
29785
30606
  // src/emf-plus-state-handlers.ts
29786
30607
  function rotateWorldTransform(m, degrees, append2) {
29787
- const f = down32;
29788
- const rad = f(Math.fround(degrees) * Math.fround(0.0174532924));
29789
- const s = f(Math.sin(rad));
29790
- const c = f(Math.cos(rad));
30608
+ const f2 = down32;
30609
+ const rad = f2(Math.fround(degrees) * Math.fround(0.0174532924));
30610
+ const s = f2(Math.sin(rad));
30611
+ const c = f2(Math.cos(rad));
29791
30612
  if (append2) {
29792
30613
  return [
29793
- f(f(m[0] * c) - f(m[1] * s)),
29794
- f(f(m[0] * s) + f(m[1] * c)),
29795
- f(f(m[2] * c) - f(m[3] * s)),
29796
- f(f(m[2] * s) + f(m[3] * c)),
29797
- f(f(m[4] * c) - f(m[5] * s)),
29798
- f(f(m[4] * s) + f(m[5] * c))
30614
+ f2(f2(m[0] * c) - f2(m[1] * s)),
30615
+ f2(f2(m[0] * s) + f2(m[1] * c)),
30616
+ f2(f2(m[2] * c) - f2(m[3] * s)),
30617
+ f2(f2(m[2] * s) + f2(m[3] * c)),
30618
+ f2(f2(m[4] * c) - f2(m[5] * s)),
30619
+ f2(f2(m[4] * s) + f2(m[5] * c))
29799
30620
  ];
29800
30621
  }
29801
30622
  return [
29802
- f(f(m[0] * c) + f(m[2] * s)),
29803
- f(f(m[3] * s) + f(m[1] * c)),
29804
- f(f(m[2] * c) - f(m[0] * s)),
29805
- f(f(m[3] * c) - f(m[1] * s)),
30623
+ f2(f2(m[0] * c) + f2(m[2] * s)),
30624
+ f2(f2(m[3] * s) + f2(m[1] * c)),
30625
+ f2(f2(m[2] * c) - f2(m[0] * s)),
30626
+ f2(f2(m[3] * c) - f2(m[1] * s)),
29806
30627
  m[4],
29807
30628
  m[5]
29808
30629
  ];
@@ -30385,10 +31206,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
30385
31206
  }
30386
31207
  case EMFPLUS_BEGINCONTAINER: {
30387
31208
  if (recDataSize >= 36) {
30388
- const f = (k) => view.getFloat32(dataOff + k, true);
31209
+ const f2 = (k) => view.getFloat32(dataOff + k, true);
30389
31210
  const t = containerRectTransform(
30390
- { x: f(0), y: f(4), w: f(8), h: f(12) },
30391
- { x: f(16), y: f(20), w: f(24), h: f(28) },
31211
+ { x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
31212
+ { x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
30392
31213
  recFlags & 255
30393
31214
  );
30394
31215
  beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
@@ -30544,7 +31365,7 @@ function registerNestedMetafileReplayer(fn) {
30544
31365
  nestedReplayer = fn;
30545
31366
  }
30546
31367
  function inclusiveNestedMapping(toDevice, srcX, srcY, srcW, srcH) {
30547
- const [a, b, c, d, e, f] = toDevice;
31368
+ const [a, b, c, d, e, f2] = toDevice;
30548
31369
  const lengthU = Math.hypot(a, b) * srcW;
30549
31370
  const lengthV = Math.hypot(c, d) * srcH;
30550
31371
  if (!(srcW > 1 && srcH > 1 && lengthU > 1 && lengthV > 1)) {
@@ -30556,7 +31377,7 @@ function inclusiveNestedMapping(toDevice, srcX, srcY, srcW, srcH) {
30556
31377
  const nb = b * ku;
30557
31378
  const nc = c * kv;
30558
31379
  const nd = d * kv;
30559
- return [na, nb, nc, nd, e + (a - na) * srcX + (c - nc) * srcY, f + (b - nb) * srcX + (d - nd) * srcY];
31380
+ return [na, nb, nc, nd, e + (a - na) * srcX + (c - nc) * srcY, f2 + (b - nb) * srcX + (d - nd) * srcY];
30560
31381
  }
30561
31382
  function drawNestedMetafile(rCtx, img, cached, source) {
30562
31383
  const depth = rCtx.nestingDepth ?? 0;
@@ -31339,7 +32160,7 @@ function encodeJpeg(data, width, height, options2 = {}) {
31339
32160
  }
31340
32161
  const quality = Number.isFinite(options2.quality) ? Math.min(1, Math.max(0, options2.quality)) : DEFAULT_JPEG_QUALITY;
31341
32162
  const [bgR, bgG, bgB] = options2.background ?? [255, 255, 255];
31342
- const sub3 = options2.chromaSubsampling ?? false;
32163
+ const sub4 = options2.chromaSubsampling ?? false;
31343
32164
  const lumaQuant = scaleQuant(LUMA_QUANT, quality);
31344
32165
  const chromaQuant = scaleQuant(CHROMA_QUANT, quality);
31345
32166
  const n = width * height;
@@ -31359,7 +32180,7 @@ function encodeJpeg(data, width, height, options2 = {}) {
31359
32180
  const acL = buildCodes(AC_LUMA);
31360
32181
  const dcC = buildCodes(DC_CHROMA);
31361
32182
  const acC = buildCodes(AC_CHROMA);
31362
- const factor = sub3 ? 2 : 1;
32183
+ const factor = sub4 ? 2 : 1;
31363
32184
  const mcu = 8 * factor;
31364
32185
  const block = new Float64Array(64);
31365
32186
  const tmp = new Float64Array(64);
@@ -35620,8 +36441,8 @@ function parseRasterFontFile(data) {
35620
36441
  }
35621
36442
  const sig = view.getUint16(0, true);
35622
36443
  if (sig === 512 || sig === 768) {
35623
- const f = parseFnt(view, 0, view.byteLength);
35624
- return f ? [f] : out;
36444
+ const f2 = parseFnt(view, 0, view.byteLength);
36445
+ return f2 ? [f2] : out;
35625
36446
  }
35626
36447
  if (sig !== 23117) {
35627
36448
  return out;
@@ -35646,9 +36467,9 @@ function parseRasterFontFile(data) {
35646
36467
  }
35647
36468
  const off = view.getUint16(p, true) * 2 ** shift;
35648
36469
  const len = view.getUint16(p + 2, true) * 2 ** shift;
35649
- const f = parseFnt(view, off, Math.min(view.byteLength, off + len));
35650
- if (f) {
35651
- out.push(f);
36470
+ const f2 = parseFnt(view, off, Math.min(view.byteLength, off + len));
36471
+ if (f2) {
36472
+ out.push(f2);
35652
36473
  }
35653
36474
  }
35654
36475
  }
@@ -36007,12 +36828,12 @@ function readGlyph(view, glyf, start, end) {
36007
36828
  p += insLen;
36008
36829
  const flags2 = new Uint8Array(nPts);
36009
36830
  for (let i = 0; i < nPts; ) {
36010
- const f = view.getUint8(p++);
36011
- flags2[i++] = f;
36012
- if (f & 8) {
36831
+ const f2 = view.getUint8(p++);
36832
+ flags2[i++] = f2;
36833
+ if (f2 & 8) {
36013
36834
  let rep = view.getUint8(p++);
36014
36835
  while (rep-- > 0 && i < nPts) {
36015
- flags2[i++] = f;
36836
+ flags2[i++] = f2;
36016
36837
  }
36017
36838
  }
36018
36839
  }
@@ -36020,11 +36841,11 @@ function readGlyph(view, glyf, start, end) {
36020
36841
  const ys = new Array(nPts);
36021
36842
  let v = 0;
36022
36843
  for (let i = 0; i < nPts; i++) {
36023
- const f = flags2[i];
36024
- if (f & 2) {
36844
+ const f2 = flags2[i];
36845
+ if (f2 & 2) {
36025
36846
  const d = view.getUint8(p++);
36026
- v += f & 16 ? d : -d;
36027
- } else if (!(f & 16)) {
36847
+ v += f2 & 16 ? d : -d;
36848
+ } else if (!(f2 & 16)) {
36028
36849
  v += view.getInt16(p);
36029
36850
  p += 2;
36030
36851
  }
@@ -36032,11 +36853,11 @@ function readGlyph(view, glyf, start, end) {
36032
36853
  }
36033
36854
  v = 0;
36034
36855
  for (let i = 0; i < nPts; i++) {
36035
- const f = flags2[i];
36036
- if (f & 4) {
36856
+ const f2 = flags2[i];
36857
+ if (f2 & 4) {
36037
36858
  const d = view.getUint8(p++);
36038
- v += f & 32 ? d : -d;
36039
- } else if (!(f & 32)) {
36859
+ v += f2 & 32 ? d : -d;
36860
+ } else if (!(f2 & 32)) {
36040
36861
  v += view.getInt16(p);
36041
36862
  p += 2;
36042
36863
  }
@@ -36576,9 +37397,9 @@ var HintedSize = class _HintedSize {
36576
37397
  let metricsFrom = null;
36577
37398
  let lastScan = scan;
36578
37399
  for (const comp of glyph.components) {
36579
- const sub3 = this.loadRecursive(comp.glyphIndex, depth + 1);
36580
- lastScan = { scanControl: sub3.scanControl, scanSet: sub3.scanSet, scanType: sub3.scanType };
36581
- const z = sub3.zone;
37400
+ const sub4 = this.loadRecursive(comp.glyphIndex, depth + 1);
37401
+ lastScan = { scanControl: sub4.scanControl, scanSet: sub4.scanSet, scanType: sub4.scanType };
37402
+ const z = sub4.zone;
36582
37403
  const m = z.n - 4;
36583
37404
  if (comp.flags & (WE_HAVE_A_SCALE | WE_HAVE_AN_X_AND_Y_SCALE | WE_HAVE_A_TWO_BY_TWO)) {
36584
37405
  for (let i = 0; i < z.n; i++) {
@@ -36839,17 +37660,17 @@ var HintedSize = class _HintedSize {
36839
37660
  * freedom vector was copied from the projection vector, or their rounded dot product is exactly 1.0): the move
36840
37661
  * is then the distance times the component over 1.0 on both axes.
36841
37662
  */
36842
- moveAmt(distance, f, alongX) {
37663
+ moveAmt(distance, f2, alongX) {
36843
37664
  if (this.gdiMath) {
36844
37665
  if (this.gs.fvIsPv || this.fDotP === 16384) {
36845
- return mulDiv(distance, f, 16384);
37666
+ return mulDiv(distance, f2, 16384);
36846
37667
  }
36847
- if (alongX && f === this.fDotP) {
37668
+ if (alongX && f2 === this.fDotP) {
36848
37669
  return distance;
36849
37670
  }
36850
- return alongX ? mulDivGdi(distance, f, this.fDotP) : mulDiv(distance, f, this.fDotP);
37671
+ return alongX ? mulDivGdi(distance, f2, this.fDotP) : mulDiv(distance, f2, this.fDotP);
36851
37672
  }
36852
- return mulDiv(distance, f, this.fDotP);
37673
+ return mulDiv(distance, f2, this.fDotP);
36853
37674
  }
36854
37675
  moveOrig(zone, p, distance) {
36855
37676
  const gs = this.gs;
@@ -37227,7 +38048,7 @@ var HintedSize = class _HintedSize {
37227
38048
  break;
37228
38049
  }
37229
38050
  case 44: {
37230
- const f = this.pop();
38051
+ const f2 = this.pop();
37231
38052
  let p = next;
37232
38053
  while (p < cur.length && cur[p] !== 45) {
37233
38054
  if (cur[p] === 44 || cur[p] === 137) {
@@ -37235,10 +38056,10 @@ var HintedSize = class _HintedSize {
37235
38056
  }
37236
38057
  p += _HintedSize.insLength(cur, p);
37237
38058
  }
37238
- if (f < 0 || f > 65535) {
38059
+ if (f2 < 0 || f2 > 65535) {
37239
38060
  throw new HintError("fdef");
37240
38061
  }
37241
- this.fdefs[f] = { code: cur, start: next, end: p };
38062
+ this.fdefs[f2] = { code: cur, start: next, end: p };
37242
38063
  next = p + 1;
37243
38064
  break;
37244
38065
  }
@@ -37269,8 +38090,8 @@ var HintedSize = class _HintedSize {
37269
38090
  continue;
37270
38091
  }
37271
38092
  case 43: {
37272
- const f = this.pop();
37273
- const def = this.fdefs[f];
38093
+ const f2 = this.pop();
38094
+ const def = this.fdefs[f2];
37274
38095
  if (!def) {
37275
38096
  throw new HintError("call");
37276
38097
  }
@@ -37283,9 +38104,9 @@ var HintedSize = class _HintedSize {
37283
38104
  continue;
37284
38105
  }
37285
38106
  case 42: {
37286
- const f = this.pop();
38107
+ const f2 = this.pop();
37287
38108
  const cnt = this.pop();
37288
- const def = this.fdefs[f];
38109
+ const def = this.fdefs[f2];
37289
38110
  if (!def) {
37290
38111
  throw new HintError("loopcall");
37291
38112
  }
@@ -37594,7 +38415,7 @@ var HintedSize = class _HintedSize {
37594
38415
  while (gs.loop > 0) {
37595
38416
  const p = this.pop();
37596
38417
  if (p >= 0 && p < this.zp2.n) {
37597
- const keep = !this.ctCompat() || this.inComposite || gs.fvx === 0 && this.shpixAlongY(p) || gs.fvx !== 0 && !this.inSizeTweak() && (!this.env.grayscale || this.plusShpixX(p, amt));
38418
+ 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));
37598
38419
  if (keep) {
37599
38420
  this.moveZp2(p, dx, dy, true);
37600
38421
  }
@@ -38342,12 +39163,12 @@ var HintedSize = class _HintedSize {
38342
39163
  if (pt === -1) {
38343
39164
  return 0;
38344
39165
  }
38345
- let f = links.flags[pt];
38346
- if (f & 4) {
39166
+ let f2 = links.flags[pt];
39167
+ if (f2 & 4) {
38347
39168
  return 0;
38348
39169
  }
38349
- links.flags[pt] = f |= 4;
38350
- if (!(f & 2)) {
39170
+ links.flags[pt] = f2 |= 4;
39171
+ if (!(f2 & 2)) {
38351
39172
  const lastEp = z.n - 5;
38352
39173
  const w0 = links.w0[pt];
38353
39174
  let shift = 0;
@@ -38586,8 +39407,8 @@ var HintedSize = class _HintedSize {
38586
39407
  return;
38587
39408
  }
38588
39409
  if (zp2 === this.pts && this.recorder(false)) {
38589
- const mul6 = (u, v) => Math.abs(Math.floor((u * v + 32) / 64));
38590
- 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]);
39410
+ const mul7 = (u, v) => Math.abs(Math.floor((u * v + 32) / 64));
39411
+ 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]);
38591
39412
  this.linkProportion(zp2, steeperA ? a0 : b0, p, steeperA ? a1 : b1);
38592
39413
  }
38593
39414
  const dbx = zp0.curX[b1] - zp0.curX[b0];
@@ -40253,6 +41074,97 @@ function dropoutMode(scanControl, scanType) {
40253
41074
  return 2;
40254
41075
  }
40255
41076
  }
41077
+ function compDiv2(n, d) {
41078
+ if (d === 0) return n < 0 ? -2147483648 : 2147483647;
41079
+ const h = Math.trunc(d / 2);
41080
+ return Math.trunc((n < 0 === d < 0 ? n + h : n - h) / d);
41081
+ }
41082
+ function nativeConicPieces(x0, y0, x1, y1, x2, y2, out) {
41083
+ for (; ; ) {
41084
+ const dx01 = x1 - x0;
41085
+ const dx12 = x2 - x1;
41086
+ const dy01 = y1 - y0;
41087
+ const dy12 = y2 - y1;
41088
+ if (dy01 > 0 && dy12 < 0 || dy01 < 0 && dy12 > 0) {
41089
+ const den = dy01 - dy12;
41090
+ const xa = x0 + compDiv2(dx01 * dy01, den);
41091
+ const xb = x1 + compDiv2(dx12 * dy01, den);
41092
+ const xs = xa + compDiv2((xb - xa) * dy01, den);
41093
+ const ys = y0 + compDiv2(dy01 * dy01, den);
41094
+ nativeConicPieces(x0, y0, xa, ys, xs, ys, out);
41095
+ x0 = xs;
41096
+ y0 = ys;
41097
+ x1 = xb;
41098
+ y1 = ys;
41099
+ continue;
41100
+ }
41101
+ if (dx01 > 0 && dx12 < 0 || dx01 < 0 && dx12 > 0) {
41102
+ const den = dx01 - dx12;
41103
+ const ya = y0 + compDiv2(dy01 * dx01, den);
41104
+ const yb = y1 + compDiv2(dy12 * dx01, den);
41105
+ const ys = ya + compDiv2((yb - ya) * dx01, den);
41106
+ const xs = x0 + compDiv2(dx01 * dx01, den);
41107
+ nativeConicPieces(x0, y0, xs, ya, xs, ys, out);
41108
+ x0 = xs;
41109
+ y0 = ys;
41110
+ x1 = xs;
41111
+ y1 = yb;
41112
+ continue;
41113
+ }
41114
+ if (Math.abs(x2 - x0) > 3200 || Math.abs(y2 - y0) > 3200) {
41115
+ const ax = x0 + x1 >> 1;
41116
+ const ay = y0 + y1 >> 1;
41117
+ const bx = x1 + x2 >> 1;
41118
+ const by = y1 + y2 >> 1;
41119
+ const mx = ax + bx >> 1;
41120
+ const my = ay + by >> 1;
41121
+ nativeConicPieces(x0, y0, ax, ay, mx, my, out);
41122
+ x0 = mx;
41123
+ y0 = my;
41124
+ x1 = bx;
41125
+ y1 = by;
41126
+ continue;
41127
+ }
41128
+ out.push([x1, y1, x2, y2]);
41129
+ return;
41130
+ }
41131
+ }
41132
+ 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];
41133
+ function bitLength2(v) {
41134
+ v = Math.abs(v);
41135
+ let n = 0;
41136
+ while (v > 0) {
41137
+ n++;
41138
+ v = Math.floor(v / 2);
41139
+ }
41140
+ return n;
41141
+ }
41142
+ function nativeArc(x0, y0, x1, y1, x2, y2) {
41143
+ const sx = x2 > x0 ? 1 : -1;
41144
+ const sy = y2 > y0 ? 1 : -1;
41145
+ let dx = sx * (x2 - x0);
41146
+ let dy = sy * (y2 - y0);
41147
+ let ax = sx * (x1 - x0);
41148
+ let ay = sy * (y1 - y0);
41149
+ const first = (p0, sg) => sg > 0 ? Math.floor((p0 + 32) / 64) * 64 + 32 - p0 : p0 - (Math.floor((p0 - 33) / 64) * 64 + 32);
41150
+ const fx0 = first(x0, sx);
41151
+ const fy0 = first(y0, sy);
41152
+ let fx = fx0;
41153
+ let fy = fy0;
41154
+ const shift = ARC_SHIFT[bitLength2(2 * (dy * ax - dx * ay)) + bitLength2(Math.max(dx, dy))] ?? 0;
41155
+ if (shift > 0) {
41156
+ const h = 2 ** (shift - 1);
41157
+ const q = 2 ** shift;
41158
+ const r = (v) => Math.floor((v + h) / q) * q;
41159
+ dx = r(dx);
41160
+ dy = r(dy);
41161
+ ax = r(ax);
41162
+ ay = r(ay);
41163
+ fx = r(fx);
41164
+ fy = r(fy);
41165
+ }
41166
+ return { sx, sy, x0, y0, dx, ax, fx, dy, ay, fy, fx0, fy0 };
41167
+ }
40256
41168
  var Raster = class {
40257
41169
  constructor(dropOutControl, fineArcs = false) {
40258
41170
  this.dropOutControl = dropOutControl;
@@ -40275,6 +41187,9 @@ var Raster = class {
40275
41187
  * curved edges with that rounding; FreeType's black rasterizer keeps the half and truncates at its own precision).
40276
41188
  */
40277
41189
  this.roundImpliedPoints = false;
41190
+ /** Walks arcs the way GDI's scan converter does (see {@link nativeConicPieces}, {@link nativeArc}); needs `roundImpliedPoints`. */
41191
+ this.nativeArcs = false;
41192
+ this.arcRecord = null;
40278
41193
  /**
40279
41194
  * Decides a pixel centre that lies exactly on an edge the way GDI's rotated glyphs do (native GetGlyphOutline bitmaps
40280
41195
  * of diagonal edges through pixel centres): the pixel is in when the contour runs downward there and out when it runs
@@ -40282,6 +41197,7 @@ var Raster = class {
40282
41197
  */
40283
41198
  this.directedTies = false;
40284
41199
  this.flipped = false;
41200
+ this.arcFlipped = false;
40285
41201
  this.precBits = 16;
40286
41202
  this.precStep = fineArcs ? 512 : 4096;
40287
41203
  this.precJitter = 480;
@@ -40586,7 +41502,9 @@ var Raster = class {
40586
41502
  }
40587
41503
  this.newProfileState(stateBez, o);
40588
41504
  }
40589
- if (stateBez === ASCENDING) {
41505
+ if (this.arcRecord) {
41506
+ this.nativeBezier(stateBez !== ASCENDING, this.minY, this.maxY);
41507
+ } else if (stateBez === ASCENDING) {
40590
41508
  this.bezierUp(this.minY, this.maxY);
40591
41509
  } else {
40592
41510
  this.bezierDown(this.minY, this.maxY);
@@ -40596,6 +41514,109 @@ var Raster = class {
40596
41514
  this.lastX = x3;
40597
41515
  this.lastY = y3;
40598
41516
  }
41517
+ /**
41518
+ * Adds the arc from (tsx, tsy) through (tcx, tcy) to (tex, tey), all in the outline's own axes and raw units, as GDI
41519
+ * walks it: cut into monotonic pieces (see {@link nativeConicPieces}), each walked on its rounded differences
41520
+ * (see {@link nativeArc}); a piece whose three points are on a line is a line.
41521
+ */
41522
+ nativeConic(flipped, tsx, tsy, tcx, tcy, tex, tey) {
41523
+ const pieces = [];
41524
+ nativeConicPieces(tsx, tsy, tcx, tcy, tex, tey, pieces);
41525
+ let px = tsx;
41526
+ let py = tsy;
41527
+ for (const [cx, cy, ex, ey] of pieces) {
41528
+ const sx = this.scaled(flipped ? ey : ex);
41529
+ const sy = this.scaled(flipped ? ex : ey);
41530
+ if ((cy - py) * (ex - cx) === (ey - cy) * (cx - px)) {
41531
+ this.lineTo(sx, sy);
41532
+ } else {
41533
+ this.arcRecord = nativeArc(px, py, cx, cy, ex, ey);
41534
+ this.arcFlipped = flipped;
41535
+ this.conicTo(this.scaled(flipped ? cy : cx), this.scaled(flipped ? cx : cy), sx, sy);
41536
+ this.arcRecord = null;
41537
+ }
41538
+ px = ex;
41539
+ py = ey;
41540
+ }
41541
+ }
41542
+ /**
41543
+ * Where the native walk of the current arc meets the scan line at `lineY` (a multiple of the precision in the
41544
+ * sweep's own axes), in the sweep's x.
41545
+ */
41546
+ nativeCrossing(lineY) {
41547
+ const a = this.arcRecord;
41548
+ const flipped = this.arcFlipped;
41549
+ const raw = lineY * 64 / this.prec + 32;
41550
+ const start = flipped ? a.x0 : a.y0;
41551
+ const sA = flipped ? a.sx : a.sy;
41552
+ const dA = flipped ? a.dx : a.dy;
41553
+ const aA = flipped ? a.ax : a.ay;
41554
+ const fA0 = flipped ? a.fx0 : a.fy0;
41555
+ const fA = flipped ? a.fx : a.fy;
41556
+ const dB = flipped ? a.dy : a.dx;
41557
+ const aB = flipped ? a.ay : a.ax;
41558
+ const sB = flipped ? a.sy : a.sx;
41559
+ const startB = flipped ? a.y0 : a.x0;
41560
+ const fB = flipped ? a.fy : a.fx;
41561
+ const fB0 = flipped ? a.fy0 : a.fx0;
41562
+ const line = sA * (raw - start);
41563
+ const index = Math.round((line - fA0) / 64);
41564
+ const dist = fA + 64 * index;
41565
+ let t = 1;
41566
+ if (dist < dA) {
41567
+ const b = 2 * aA;
41568
+ const c = dA - 2 * aA;
41569
+ t = 2 * dist / (b + Math.sqrt(b * b + 4 * c * dist));
41570
+ }
41571
+ const along = 2 * t * aB + t * t * (dB - 2 * aB);
41572
+ return Math.round((startB + sB * (along + fB0 - fB)) * this.prec / 64 - this.precHalf);
41573
+ }
41574
+ /** {@link bezierUp} for an arc walked natively: one pass over its scan lines, the crossings from {@link nativeCrossing}. */
41575
+ nativeBezier(down, miny, maxy) {
41576
+ const X = this.arcX;
41577
+ const Y = this.arcY;
41578
+ const sg = down ? -1 : 1;
41579
+ const mn = down ? -maxy : miny;
41580
+ const mx = down ? -miny : maxy;
41581
+ const y1 = sg * Y[2];
41582
+ const y2 = sg * Y[0];
41583
+ const xs = this.cProfile.xs;
41584
+ const fresh = this.fresh;
41585
+ this.arc -= 2;
41586
+ if (y2 < mn || y1 > mx) return;
41587
+ let e2 = this.floorP(y2);
41588
+ if (e2 > mx) e2 = mx;
41589
+ let e0 = mn;
41590
+ let e;
41591
+ if (y1 < mn) {
41592
+ e = mn;
41593
+ } else {
41594
+ e = this.ceilP(y1);
41595
+ e0 = e;
41596
+ if (this.frac(y1) === 0) {
41597
+ if (this.joint) {
41598
+ xs.pop();
41599
+ this.joint = false;
41600
+ }
41601
+ xs.push(X[2]);
41602
+ e += this.prec;
41603
+ }
41604
+ }
41605
+ if (this.fresh) {
41606
+ this.cProfile.start = this.trunc(e0);
41607
+ this.fresh = false;
41608
+ }
41609
+ for (; e <= e2; e += this.prec) {
41610
+ this.joint = false;
41611
+ if (y2 > e) {
41612
+ xs.push(this.nativeCrossing(sg * e));
41613
+ } else {
41614
+ this.joint = true;
41615
+ xs.push(X[0]);
41616
+ }
41617
+ }
41618
+ if (down && fresh && !this.fresh) this.cProfile.start = -this.cProfile.start;
41619
+ }
40599
41620
  decomposeContour(o, first, last, flipped) {
40600
41621
  const px = (i) => this.scaled(flipped ? o.ys[i] : o.xs[i]);
40601
41622
  const py = (i) => this.scaled(flipped ? o.xs[i] : o.ys[i]);
@@ -40608,12 +41629,30 @@ var Raster = class {
40608
41629
  const lastY = py(last);
40609
41630
  let limit = last;
40610
41631
  let point = first;
41632
+ const native = this.nativeArcs && this.roundImpliedPoints;
41633
+ let curTx = o.xs[first];
41634
+ let curTy = o.ys[first];
41635
+ let startTx = curTx;
41636
+ let startTy = curTy;
41637
+ const arc = (tcx, tcy, tex, tey, cx, cy, x, y) => {
41638
+ if (native) {
41639
+ this.nativeConic(flipped, curTx, curTy, tcx, tcy, tex, tey);
41640
+ curTx = tex;
41641
+ curTy = tey;
41642
+ } else {
41643
+ this.conicTo(cx, cy, x, y);
41644
+ }
41645
+ };
40611
41646
  if (!o.onCurve[first]) {
40612
41647
  if (o.onCurve[last]) {
40613
41648
  startX = lastX;
40614
41649
  startY = lastY;
41650
+ startTx = curTx = o.xs[last];
41651
+ startTy = curTy = o.ys[last];
40615
41652
  limit--;
40616
41653
  } else {
41654
+ startTx = curTx = Math.floor((o.xs[first] + o.xs[last] + 1) / 2);
41655
+ startTy = curTy = Math.floor((o.ys[first] + o.ys[last] + 1) / 2);
40617
41656
  if (this.roundImpliedPoints) {
40618
41657
  startX = mid(rx(first), rx(last));
40619
41658
  startY = mid(ry(first), ry(last));
@@ -40630,12 +41669,16 @@ var Raster = class {
40630
41669
  point++;
40631
41670
  if (o.onCurve[point]) {
40632
41671
  this.lineTo(px(point), py(point));
41672
+ curTx = o.xs[point];
41673
+ curTy = o.ys[point];
40633
41674
  continue;
40634
41675
  }
40635
41676
  let cx = px(point);
40636
41677
  let cy = py(point);
40637
41678
  let cxRaw = rx(point);
40638
41679
  let cyRaw = ry(point);
41680
+ let ctx = o.xs[point];
41681
+ let cty = o.ys[point];
40639
41682
  let closed = false;
40640
41683
  while (true) {
40641
41684
  if (point < limit) {
@@ -40643,11 +41686,11 @@ var Raster = class {
40643
41686
  const x = px(point);
40644
41687
  const y = py(point);
40645
41688
  if (o.onCurve[point]) {
40646
- this.conicTo(cx, cy, x, y);
41689
+ arc(ctx, cty, o.xs[point], o.ys[point], cx, cy, x, y);
40647
41690
  break;
40648
41691
  }
40649
41692
  if (this.roundImpliedPoints) {
40650
- this.conicTo(cx, cy, mid(cxRaw, rx(point)), mid(cyRaw, ry(point)));
41693
+ 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)));
40651
41694
  } else {
40652
41695
  this.conicTo(cx, cy, Math.trunc((cx + x) / 2), Math.trunc((cy + y) / 2));
40653
41696
  }
@@ -40655,9 +41698,11 @@ var Raster = class {
40655
41698
  cy = y;
40656
41699
  cxRaw = rx(point);
40657
41700
  cyRaw = ry(point);
41701
+ ctx = o.xs[point];
41702
+ cty = o.ys[point];
40658
41703
  continue;
40659
41704
  }
40660
- this.conicTo(cx, cy, startX, startY);
41705
+ arc(ctx, cty, startTx, startTy, cx, cy, startX, startY);
40661
41706
  closed = true;
40662
41707
  break;
40663
41708
  }
@@ -41031,6 +42076,69 @@ function flattenForStubs(o) {
41031
42076
  }
41032
42077
  return { xs, ys, onCurve: new Array(xs.length).fill(1), endPts };
41033
42078
  }
42079
+ var ScanLists = class {
42080
+ constructor(count, P) {
42081
+ this.P = P;
42082
+ this.pairs = Array.from({ length: count }, () => []);
42083
+ }
42084
+ add(line, x1, x2) {
42085
+ if (line < 0 || line >= this.pairs.length) return;
42086
+ this.pairs[line].push({ start: Math.ceil(x1 / this.P), stop: Math.floor(x2 / this.P) + 1, x1, x2 });
42087
+ }
42088
+ /** Entries of `line` whose start or stop is `value` (native `HorizCrossings` / `VertCrossings`; 0 outside the box). */
42089
+ count(line, value) {
42090
+ if (line < 0 || line >= this.pairs.length) return 0;
42091
+ let n = 0;
42092
+ for (const p of this.pairs[line]) n += (p.start === value ? 1 : 0) + (p.stop === value ? 1 : 0);
42093
+ return n;
42094
+ }
42095
+ };
42096
+ var NativeScanLists = class {
42097
+ constructor(width, height, P) {
42098
+ this.width = width;
42099
+ this.height = height;
42100
+ this.rows = new ScanLists(height, P);
42101
+ this.cols = new ScanLists(width, P);
42102
+ }
42103
+ };
42104
+ function nativeDropoutPass(lists, mode, data, width, height, smartPixel, raster) {
42105
+ const stubs = mode === 1 || mode === 5;
42106
+ const smart = mode === 4 || mode === 5;
42107
+ const P = raster.precision;
42108
+ const at = (col, row2) => (height - 1 - row2) * width + col;
42109
+ const step = P / 64;
42110
+ const pick = (x1, x2, start) => smart ? Math.floor((Math.floor(x1 / step) + Math.floor(x2 / step) + 63) / 128) : start - 1;
42111
+ for (let y = height - 1; y >= 0; y--) {
42112
+ for (const p of lists.rows.pairs[y]) {
42113
+ if (p.start !== p.stop) continue;
42114
+ const x = p.start;
42115
+ if (stubs) {
42116
+ if (lists.rows.count(y + 1, x) + lists.cols.count(x - 1, y + 1) + lists.cols.count(x, y + 1) < 2) continue;
42117
+ if (lists.rows.count(y - 1, x) + lists.cols.count(x - 1, y) + lists.cols.count(x, y) < 2) continue;
42118
+ }
42119
+ if (x > 0 && x - 1 < width && data[at(x - 1, y)]) continue;
42120
+ if (x < width && x >= 0 && data[at(x, y)]) continue;
42121
+ const c = Math.max(0, pick(p.x1, p.x2, x));
42122
+ if (c < width) data[at(c, y)] = 1;
42123
+ }
42124
+ }
42125
+ for (let c = 0; c < width; c++) {
42126
+ for (let k = lists.cols.pairs[c].length - 1; k >= 0; k--) {
42127
+ const p = lists.cols.pairs[c][k];
42128
+ if (p.start !== p.stop) continue;
42129
+ const r = p.start;
42130
+ if (r < 0 || r > height) continue;
42131
+ if (stubs) {
42132
+ if (lists.cols.count(c - 1, r) + lists.rows.count(r, c) + lists.rows.count(r - 1, c) < 2) continue;
42133
+ if (lists.cols.count(c + 1, r) + lists.rows.count(r, c + 1) + lists.rows.count(r - 1, c + 1) < 2) continue;
42134
+ }
42135
+ if (r > 0 && r - 1 < height && data[at(c, r - 1)]) continue;
42136
+ if (r < height && data[at(c, r)]) continue;
42137
+ const row2 = Math.max(0, pick(p.x1, p.x2, r));
42138
+ if (row2 < height) data[at(c, row2)] = 1;
42139
+ }
42140
+ }
42141
+ }
41034
42142
  var StubSquares = class {
41035
42143
  constructor(o) {
41036
42144
  this.contours = [];
@@ -41149,7 +42257,7 @@ function monoBox(o) {
41149
42257
  if (collapsedY) yMax += 1;
41150
42258
  return { xMin, xMax, yMin, yMax, collapsedX, collapsedY };
41151
42259
  }
41152
- function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossings26Dot6 = false, roundImpliedPoints = false, directedTies = false, fineArcs = false, closedTies = false, squareStubs = false) {
42260
+ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossings26Dot6 = false, roundImpliedPoints = false, directedTies = false, fineArcs = false, closedTies = false, squareStubs = false, nativeDropouts = false) {
41153
42261
  const box = fixedBox ?? monoBox(o);
41154
42262
  if (!box) {
41155
42263
  return null;
@@ -41171,6 +42279,7 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41171
42279
  const at = (col, row2) => (height - 1 - row2) * width + col;
41172
42280
  const r = new Raster(dropout, fineArcs);
41173
42281
  r.roundImpliedPoints = roundImpliedPoints;
42282
+ r.nativeArcs = nativeDropouts;
41174
42283
  r.directedTies = directedTies;
41175
42284
  const P = r.precision;
41176
42285
  const monoContour = !squareStubs && stubOvershoot && (dropout === 1 || dropout === 4 || dropout === 5) ? MonoStubContours.create(local) : null;
@@ -41185,9 +42294,11 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41185
42294
  }
41186
42295
  return raster.floorPub(Math.floor((x1 + x2 + Math.floor(P * 63 / 64)) / 2));
41187
42296
  };
42297
+ const native = nativeDropouts && dropout !== 2 ? new NativeScanLists(width, height, P) : null;
41188
42298
  if (r.convert(local, false, 0, (height - 1) * P)) {
41189
42299
  r.sweep(
41190
42300
  (y, x1, x2) => {
42301
+ native?.rows.add(y, x1, x2);
41191
42302
  let e1 = r.ceilPub(x1);
41192
42303
  let e2 = r.floorPub(x2);
41193
42304
  if (dropout !== 2 && x2 - x1 - P <= r.jitter && e1 !== x1 && e2 !== x2) {
@@ -41202,6 +42313,10 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41202
42313
  }
41203
42314
  },
41204
42315
  (y, x1, x2, left, right) => {
42316
+ if (native) {
42317
+ native.rows.add(y, x1, x2);
42318
+ return;
42319
+ }
41205
42320
  let e1 = r.ceilPub(x1);
41206
42321
  let e2 = r.floorPub(x2);
41207
42322
  let pxl = e1;
@@ -41249,9 +42364,12 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41249
42364
  if (dropout !== 2) {
41250
42365
  const h = new Raster(dropout, fineArcs);
41251
42366
  h.directedTies = directedTies;
42367
+ h.roundImpliedPoints = roundImpliedPoints && nativeDropouts;
42368
+ h.nativeArcs = nativeDropouts;
41252
42369
  if (h.convert(local, true, 0, (width - 1) * P)) {
41253
42370
  h.sweep(
41254
42371
  (col, x1, x2) => {
42372
+ native?.cols.add(col, x1, x2);
41255
42373
  if (x2 - x1 < P) {
41256
42374
  const e1 = h.ceilPub(x1);
41257
42375
  const e2 = h.floorPub(x2);
@@ -41264,6 +42382,10 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41264
42382
  }
41265
42383
  },
41266
42384
  (col, x1, x2, left, right) => {
42385
+ if (native) {
42386
+ native.cols.add(col, x1, x2);
42387
+ return;
42388
+ }
41267
42389
  let e1 = h.ceilPub(x1);
41268
42390
  const e2 = h.floorPub(x2);
41269
42391
  let pxl = e1;
@@ -41309,11 +42431,12 @@ function rasterizeMono(o, dropout, fixedBox, stubOvershoot = true, smartCrossing
41309
42431
  );
41310
42432
  }
41311
42433
  }
42434
+ if (native) nativeDropoutPass(native, dropout, data, width, height, smartPixel, r);
41312
42435
  if (closedTies) fillTieRows(local, curved, data, width, height, at);
41313
42436
  return { width, height, left: box.xMin, top: box.yMax, data };
41314
42437
  }
41315
42438
  var GRAY_OVERSAMPLE = 4;
41316
- function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true, fineArcs = false, closedTies = false, squareStubs = false, roundImpliedPoints = false) {
42439
+ function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true, fineArcs = false, closedTies = false, squareStubs = false, roundImpliedPoints = false, nativeDropouts = false) {
41317
42440
  const n = o.xs.length;
41318
42441
  if (n === 0) {
41319
42442
  return null;
@@ -41342,7 +42465,7 @@ function rasterizeSamples(o, kx, ky, padX = 0, dropout = 2, stubOvershoot = true
41342
42465
  onCurve: o.onCurve,
41343
42466
  endPts: o.endPts
41344
42467
  };
41345
- 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);
42468
+ 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);
41346
42469
  return hi ? { box, hi } : null;
41347
42470
  }
41348
42471
  function rasterizeGray(o, dropout = 2, roundImpliedPoints = false, fineArcs = false, squareStubs = false) {
@@ -41398,6 +42521,7 @@ var NONANTIALIASED_QUALITY = 3;
41398
42521
  var ANTIALIASED_QUALITY = 4;
41399
42522
  var CLEARTYPE_QUALITY = 5;
41400
42523
  var CLEARTYPE_NATURAL_QUALITY = 6;
42524
+ var UNHINTED_MONO_DROPOUT = 1;
41401
42525
  var NOTDEF = 0;
41402
42526
  var FONT_SUBSTITUTES = {
41403
42527
  "ms shell dlg": "microsoft sans serif",
@@ -41438,8 +42562,8 @@ var RASTER_SUBSTITUTES = {
41438
42562
  "tms rmn": "ms serif"
41439
42563
  };
41440
42564
  var ITALIC_SHEAR = 22272 / 65536;
41441
- function isItalicFace(f) {
41442
- return (f.fsSelection & 1) !== 0 || (f.macStyle & 2) !== 0;
42565
+ function isItalicFace(f2) {
42566
+ return (f2.fsSelection & 1) !== 0 || (f2.macStyle & 2) !== 0;
41443
42567
  }
41444
42568
  var CP1252_HIGH = [
41445
42569
  8364,
@@ -42013,13 +43137,13 @@ var RealizedFont = class {
42013
43137
  if (this.mode === "mono") {
42014
43138
  const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
42015
43139
  const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
42016
- bitmap = this.gdiPlus ? rasterizeMono(o, dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
43140
+ 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));
42017
43141
  } else if (this.mode === "cleartype") {
42018
- const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : 2;
43142
+ const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
42019
43143
  bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
42020
43144
  } else {
42021
43145
  const dropout = this.gdiPlus ? src.scanSet ? dropoutMode(src.scanControl, src.scanType) : 2 : msScanFlags(src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM, src.scanType);
42022
- 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);
43146
+ 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);
42023
43147
  }
42024
43148
  if (bitmap && this.syntheticBold) {
42025
43149
  bitmap = embolden(bitmap, this.mode === "mono" ? 1 : 16);
@@ -42047,27 +43171,32 @@ function roundedRotationMatrix(m, ppem) {
42047
43171
  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];
42048
43172
  }
42049
43173
  function rotationMatrix(m, ppem, integerPpem) {
42050
- const isRotation = Math.abs(m[0] - m[3]) < 1e-6 && Math.abs(m[1] + m[2]) < 1e-6;
43174
+ const xLength = Math.hypot(m[0], m[1]);
43175
+ const yLength = Math.hypot(m[2], m[3]);
43176
+ const stretch = yLength > 0 ? xLength / yLength : 0;
43177
+ const isRotation = stretch > 0.9 && stretch < 1.1 && Math.abs(m[0] * m[2] + m[1] * m[3]) < 1e-6 * xLength * yLength;
42051
43178
  if (!isRotation || ppem <= 0) {
42052
43179
  return null;
42053
43180
  }
42054
43181
  if (!integerPpem) {
42055
43182
  return { ppem: 0, matrix: [m[0], m[1], m[2], m[3]] };
42056
43183
  }
42057
- const major = Math.max(Math.abs(m[0]), Math.abs(m[1]));
42058
- const minor = Math.min(Math.abs(m[0]), Math.abs(m[1]));
42059
- const majorFixed = Math.round(major * ppem * 32);
42060
- const target = Math.floor((majorFixed + 16) / 32);
43184
+ const normalise = (vx, vy) => {
43185
+ const ax = Math.abs(vx);
43186
+ const ay = Math.abs(vy);
43187
+ const majorFixed = Math.round(Math.max(ax, ay) * ppem * 32);
43188
+ const q = Math.round(Math.round(Math.min(ax, ay) * ppem * 32) / majorFixed * 65536) / 65536;
43189
+ const sx = vx < 0 ? -1 : 1;
43190
+ const sy = vy < 0 ? -1 : 1;
43191
+ return ax >= ay ? { x: sx, y: sy * q, majorFixed } : { x: sx * q, y: sy, majorFixed };
43192
+ };
43193
+ const xv = normalise(m[0], -m[1]);
43194
+ const yv = normalise(-m[2], m[3]);
43195
+ const target = Math.floor((xv.majorFixed + 16) / 32);
42061
43196
  if (target < 1) {
42062
43197
  return null;
42063
43198
  }
42064
- const q = Math.round(Math.round(minor * ppem * 32) / majorFixed * 65536) / 65536;
42065
- const xMajor = Math.abs(m[0]) >= Math.abs(m[1]);
42066
- const sg = (v) => v < 0 ? -1 : 1;
42067
- return {
42068
- ppem: target,
42069
- 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]
42070
- };
43199
+ return { ppem: target, matrix: [xv.x, -xv.y, -yv.x, yv.y] };
42071
43200
  }
42072
43201
  function embolden(b, full) {
42073
43202
  const w = b.width + 1;
@@ -42135,7 +43264,7 @@ var GdiFontCollection = class _GdiFontCollection {
42135
43264
  const list = this.families.get(k);
42136
43265
  if (!list) {
42137
43266
  this.families.set(k, [face]);
42138
- } else if (!list.some((f) => f.family.toLowerCase().trim() === k)) {
43267
+ } else if (!list.some((f2) => f2.family.toLowerCase().trim() === k)) {
42139
43268
  list.push(face);
42140
43269
  }
42141
43270
  }
@@ -42153,9 +43282,9 @@ var GdiFontCollection = class _GdiFontCollection {
42153
43282
  return m;
42154
43283
  }
42155
43284
  }
42156
- const sub3 = FONT_SUBSTITUTES[k];
42157
- if (sub3 && this.families.get(sub3)) {
42158
- return this.families.get(sub3);
43285
+ const sub4 = FONT_SUBSTITUTES[k];
43286
+ if (sub4 && this.families.get(sub4)) {
43287
+ return this.families.get(sub4);
42159
43288
  }
42160
43289
  const family = pitchAndFamily & 240;
42161
43290
  const fixed = (pitchAndFamily & 3) === 1;
@@ -42173,7 +43302,7 @@ var GdiFontCollection = class _GdiFontCollection {
42173
43302
  }
42174
43303
  if (height === 0) {
42175
43304
  const sorted = faces.slice().sort((a, b) => a.pixHeight - b.pixHeight);
42176
- const face = sorted.find((f) => f.points >= 10) ?? sorted[0];
43305
+ const face = sorted.find((f2) => f2.points >= 10) ?? sorted[0];
42177
43306
  return { face, scale: 1, scaleX: 1 };
42178
43307
  }
42179
43308
  const pick = pickRasterFace(faces, height, width, weight);
@@ -42206,8 +43335,8 @@ var GdiFontCollection = class _GdiFontCollection {
42206
43335
  if (!pick || pick.scale !== 1 || pick.face.pixHeight > 16) {
42207
43336
  return 0;
42208
43337
  }
42209
- const f = pick.face;
42210
- return f.pixHeight <= ttCell + 1 ? f.pixHeight - f.internalLeading : 0;
43338
+ const f2 = pick.face;
43339
+ return f2.pixHeight <= ttCell + 1 ? f2.pixHeight - f2.internalLeading : 0;
42211
43340
  }
42212
43341
  /** Realises `spec`, or null when no supplied font can stand in for it. */
42213
43342
  realize(spec, fontFamilyMap) {
@@ -42231,11 +43360,11 @@ var GdiFontCollection = class _GdiFontCollection {
42231
43360
  const weight = spec.weight || 400;
42232
43361
  let best = faces[0];
42233
43362
  let bestScore = Infinity;
42234
- for (const f of faces) {
42235
- const dw = f.weightClass - weight;
42236
- const score2 = (isItalicFace(f) !== spec.italic ? 1e4 : 0) + (dw > 0 ? dw * 3 : -dw);
43363
+ for (const f2 of faces) {
43364
+ const dw = f2.weightClass - weight;
43365
+ const score2 = (isItalicFace(f2) !== spec.italic ? 1e4 : 0) + (dw > 0 ? dw * 3 : -dw);
42237
43366
  if (score2 < bestScore) {
42238
- best = f;
43367
+ best = f2;
42239
43368
  bestScore = score2;
42240
43369
  }
42241
43370
  }
@@ -42391,7 +43520,7 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42391
43520
  const KY = vertical ? CLEARTYPE_ROWS : 1;
42392
43521
  const WT = vertical ? CLEARTYPE_ROW_WEIGHTS : [1];
42393
43522
  const WSUM = WT.reduce((a, c) => a + c, 0);
42394
- const r = rasterizeSamples(o, CLEARTYPE_OVERSAMPLE, KY, 1, dropout, false, !truncate, !truncate, true, !truncate);
43523
+ const r = rasterizeSamples(o, CLEARTYPE_OVERSAMPLE, KY, 1, dropout, false, !truncate, !truncate, true, !truncate, !truncate);
42395
43524
  if (!r) {
42396
43525
  return null;
42397
43526
  }
@@ -42399,10 +43528,10 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42399
43528
  const width = box.xMax - box.xMin;
42400
43529
  const height = box.yMax - box.yMin;
42401
43530
  const n = width * 3;
42402
- const sub3 = new Float64Array(n);
43531
+ const sub4 = new Float64Array(n);
42403
43532
  const data = new Uint8Array(n * height);
42404
43533
  for (let y = 0; y < height; y++) {
42405
- sub3.fill(0);
43534
+ sub4.fill(0);
42406
43535
  for (let yy = 0; yy < KY; yy++) {
42407
43536
  const row2 = (y * KY + yy) * hi.width;
42408
43537
  for (let x = 0; x < hi.width; x++) {
@@ -42413,15 +43542,15 @@ function rasterizeClearType(o, truncate = false, spread, dropout = 2, vertical =
42413
43542
  }
42414
43543
  }
42415
43544
  if (on) {
42416
- sub3[Math.floor(x / S)] += WT[yy] ?? 1;
43545
+ sub4[Math.floor(x / S)] += WT[yy] ?? 1;
42417
43546
  }
42418
43547
  }
42419
43548
  }
42420
43549
  for (let j = 0; j < n; j++) {
42421
- const before = j > 0 ? sub3[j - 1] : 0;
42422
- const after = j + 1 < n ? sub3[j + 1] : 0;
42423
- let acc = before + sub3[j] + after;
42424
- if (spread && acc === 1 && sub3[j] === 0 && (j % 3 === 0 && before === 1 || (j + 1) % 3 === 0 && after === 1)) {
43550
+ const before = j > 0 ? sub4[j - 1] : 0;
43551
+ const after = j + 1 < n ? sub4[j + 1] : 0;
43552
+ let acc = before + sub4[j] + after;
43553
+ if (spread && acc === 1 && sub4[j] === 0 && (j % 3 === 0 && before === 1 || (j + 1) % 3 === 0 && after === 1)) {
42425
43554
  acc = 0;
42426
43555
  }
42427
43556
  data[y * n + j] = vertical ? Math.floor((acc + WSUM / 2) / WSUM) : (truncate ? Math.floor : Math.round)(255 * acc / (3 * S * WSUM));
@@ -42999,7 +44128,7 @@ function measurePathBox(build, pad, surface) {
42999
44128
  let tx = 0;
43000
44129
  let ty = 0;
43001
44130
  let unknown = false;
43002
- const add2 = (x, y, r = 0) => {
44131
+ const add3 = (x, y, r = 0) => {
43003
44132
  minX = Math.min(minX, x + tx - r);
43004
44133
  minY = Math.min(minY, y + ty - r);
43005
44134
  maxX = Math.max(maxX, x + tx + r);
@@ -43009,35 +44138,35 @@ function measurePathBox(build, pad, surface) {
43009
44138
  unknown = true;
43010
44139
  };
43011
44140
  const recorder = {
43012
- moveTo: (x, y) => add2(x, y),
43013
- lineTo: (x, y) => add2(x, y),
44141
+ moveTo: (x, y) => add3(x, y),
44142
+ lineTo: (x, y) => add3(x, y),
43014
44143
  rect: (x, y, w, h) => {
43015
- add2(x, y);
43016
- add2(x + w, y + h);
44144
+ add3(x, y);
44145
+ add3(x + w, y + h);
43017
44146
  },
43018
44147
  fillRect: (x, y, w, h) => {
43019
- add2(x, y);
43020
- add2(x + w, y + h);
44148
+ add3(x, y);
44149
+ add3(x + w, y + h);
43021
44150
  },
43022
44151
  strokeRect: (x, y, w, h) => {
43023
- add2(x, y);
43024
- add2(x + w, y + h);
44152
+ add3(x, y);
44153
+ add3(x + w, y + h);
43025
44154
  },
43026
44155
  bezierCurveTo: (ax, ay, bx, by, x, y) => {
43027
- add2(ax, ay);
43028
- add2(bx, by);
43029
- add2(x, y);
44156
+ add3(ax, ay);
44157
+ add3(bx, by);
44158
+ add3(x, y);
43030
44159
  },
43031
44160
  quadraticCurveTo: (ax, ay, x, y) => {
43032
- add2(ax, ay);
43033
- add2(x, y);
44161
+ add3(ax, ay);
44162
+ add3(x, y);
43034
44163
  },
43035
44164
  arcTo: (x12, y12, x2, y2) => {
43036
- add2(x12, y12);
43037
- add2(x2, y2);
44165
+ add3(x12, y12);
44166
+ add3(x2, y2);
43038
44167
  },
43039
- arc: (x, y, r) => add2(x, y, Math.abs(r)),
43040
- ellipse: (x, y, rx, ry) => add2(x, y, Math.max(Math.abs(rx), Math.abs(ry))),
44168
+ arc: (x, y, r) => add3(x, y, Math.abs(r)),
44169
+ ellipse: (x, y, rx, ry) => add3(x, y, Math.max(Math.abs(rx), Math.abs(ry))),
43041
44170
  translate: (x, y) => {
43042
44171
  tx += x;
43043
44172
  ty += y;
@@ -43739,11 +44868,11 @@ function penPolygon(width, height = width) {
43739
44868
  } else {
43740
44869
  const rx = Math.ceil(width / 2);
43741
44870
  const ry = Math.ceil(height / 2);
43742
- const f = flattenBezierPath(ellipseBeziers(-rx, -ry, rx, ry));
44871
+ const f2 = flattenBezierPath(ellipseBeziers(-rx, -ry, rx, ry));
43743
44872
  const half = [];
43744
- for (let i = 0; i + 1 < f.length; i += 2) {
43745
- half.push([f[i], f[i + 1]]);
43746
- if (i > 0 && f[i + 1] === 0) {
44873
+ for (let i = 0; i + 1 < f2.length; i += 2) {
44874
+ half.push([f2[i], f2[i + 1]]);
44875
+ if (i > 0 && f2[i + 1] === 0) {
43747
44876
  break;
43748
44877
  }
43749
44878
  }
@@ -43774,10 +44903,10 @@ function penPolygonMatrix(width, m) {
43774
44903
  const hx = [halfVectorComponent(m[0] * h), halfVectorComponent(m[1] * h)];
43775
44904
  const hy = [mirror2 * halfVectorComponent(m[2] * h), mirror2 * halfVectorComponent(m[3] * h)];
43776
44905
  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] });
43777
- const f = flattenBezierPath(box.slice(0, 14));
44906
+ const f2 = flattenBezierPath(box.slice(0, 14));
43778
44907
  const half = [];
43779
- for (let i = 0; i + 1 < f.length; i += 2) {
43780
- half.push([f[i], f[i + 1]]);
44908
+ for (let i = 0; i + 1 < f2.length; i += 2) {
44909
+ half.push([f2[i], f2[i + 1]]);
43781
44910
  }
43782
44911
  half.pop();
43783
44912
  const pen = [...half, ...half.map((p) => [0 - p[0] || 0, 0 - p[1] || 0])];
@@ -44517,20 +45646,20 @@ function boxFrame(box) {
44517
45646
  return { l: 0, t: 0, r: w, b: h };
44518
45647
  }
44519
45648
  function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatible = false) {
44520
- const f = boxFrame(box);
45649
+ const f2 = boxFrame(box);
44521
45650
  const mirrorX = isAxisBox(box) && box.exx < 0;
44522
45651
  const mirrorY = isAxisBox(box) && box.eyy < 0;
44523
45652
  const clockwise = recordedClockwise !== mirrorY;
44524
- const q = roundRectCorners(f.l, f.t, f.r, f.b, cw, ch, compatible, clockwise, mirrorX, isAxisBox(box) ? box.cornerRatio : void 0);
44525
- const map = frameMapper(box, f.l, f.t, f.r - f.l, f.b - f.t);
45653
+ const q = roundRectCorners(f2.l, f2.t, f2.r, f2.b, cw, ch, compatible, clockwise, mirrorX, isAxisBox(box) ? box.cornerRatio : void 0);
45654
+ const map = frameMapper(box, f2.l, f2.t, f2.r - f2.l, f2.b - f2.t);
44526
45655
  const pts = [];
44527
45656
  for (let i = 0; i < q.length; i += 2) {
44528
- pts.push(...map(q[i], clockwise ? f.t + f.b - q[i + 1] : q[i + 1]));
45657
+ pts.push(...map(q[i], clockwise ? f2.t + f2.b - q[i + 1] : q[i + 1]));
44529
45658
  }
44530
45659
  if (box.halfX) {
44531
45660
  if (box.halfXCompat || !clockwise) {
44532
- const cy = (f.t + f.b) / 2;
44533
- const ry = (f.b - f.t) / 2 || 1;
45661
+ const cy = (f2.t + f2.b) / 2;
45662
+ const ry = (f2.b - f2.t) / 2 || 1;
44534
45663
  for (let k = 0; k < 16; k++) {
44535
45664
  const v = (cy - pts[2 * k + 1]) / ry;
44536
45665
  pts[2 * k] += k >= 8 ? Math.round(1 + v) : Math.ceil(v - 0.5);
@@ -44543,8 +45672,8 @@ function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatib
44543
45672
  }
44544
45673
  }
44545
45674
  if (box.cornerExact && isAxisBox(box)) {
44546
- const w = f.r - f.l;
44547
- const h = f.b - f.t;
45675
+ const w = f2.r - f2.l;
45676
+ const h = f2.b - f2.t;
44548
45677
  if (w >= 0 && h >= 0) {
44549
45678
  const hx = w === 0 ? 0 : Math.round(box.cornerExact[0] * (mirrorX ? w - w % 2 : w + w % 2) / w / 2);
44550
45679
  const hy = h === 0 ? 0 : Math.round(box.cornerExact[1] * (clockwise ? h + h % 2 : h - h % 2) / h / 2);
@@ -44552,30 +45681,30 @@ function roundRectDeviceBeziers(box, cw, ch, recordedClockwise = false, compatib
44552
45681
  const vc = clockwise ? Math.ceil(KAPPA * hy) : Math.floor(KAPPA * hy);
44553
45682
  const set = (k, x, y) => {
44554
45683
  if (x !== null) pts[2 * k] = x;
44555
- pts[2 * k + 1] = clockwise ? f.t + f.b - y : y;
45684
+ pts[2 * k + 1] = clockwise ? f2.t + f2.b - y : y;
44556
45685
  };
44557
45686
  const a = box.halfX ? 1 : 0;
44558
- set(0, null, f.t + hy);
44559
- set(1, null, f.t + hy - vc);
44560
- set(2, f.r + a - hx + hc, f.t);
44561
- set(3, f.r + a - hx, f.t);
44562
- set(4, f.l + a + hx, f.t);
44563
- set(5, f.l + a + hx - hc, f.t);
44564
- set(6, null, f.t + hy - vc);
44565
- set(7, null, f.t + hy);
44566
- set(8, null, f.b - hy);
44567
- set(9, null, f.b - hy + vc);
44568
- set(10, f.l + hx - hc, f.b);
44569
- set(11, f.l + hx, f.b);
44570
- set(12, f.r - hx, f.b);
44571
- set(13, f.r - hx + hc, f.b);
44572
- set(14, null, f.b - hy + vc);
44573
- set(15, null, f.b - hy);
45687
+ set(0, null, f2.t + hy);
45688
+ set(1, null, f2.t + hy - vc);
45689
+ set(2, f2.r + a - hx + hc, f2.t);
45690
+ set(3, f2.r + a - hx, f2.t);
45691
+ set(4, f2.l + a + hx, f2.t);
45692
+ set(5, f2.l + a + hx - hc, f2.t);
45693
+ set(6, null, f2.t + hy - vc);
45694
+ set(7, null, f2.t + hy);
45695
+ set(8, null, f2.b - hy);
45696
+ set(9, null, f2.b - hy + vc);
45697
+ set(10, f2.l + hx - hc, f2.b);
45698
+ set(11, f2.l + hx, f2.b);
45699
+ set(12, f2.r - hx, f2.b);
45700
+ set(13, f2.r - hx + hc, f2.b);
45701
+ set(14, null, f2.b - hy + vc);
45702
+ set(15, null, f2.b - hy);
44574
45703
  }
44575
45704
  }
44576
45705
  if (mirrorX) {
44577
45706
  for (let i = 0; i < pts.length; i += 2) {
44578
- pts[i] = f.l + f.r - pts[i];
45707
+ pts[i] = f2.l + f2.r - pts[i];
44579
45708
  }
44580
45709
  }
44581
45710
  return pts;
@@ -44592,8 +45721,8 @@ function roundRectRasterPath(box, cw, ch, clockwise = false, rectangle = false,
44592
45721
  return path;
44593
45722
  }
44594
45723
  function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPath(), mirror2) {
44595
- const f = boxFrame(box);
44596
- const map = frameMapper(box, f.l, f.t, f.r - f.l, f.b - f.t);
45724
+ const f2 = boxFrame(box);
45725
+ const map = frameMapper(box, f2.l, f2.t, f2.r - f2.l, f2.b - f2.t);
44597
45726
  let sx = s[0];
44598
45727
  let sy = s[1];
44599
45728
  let ex = e[0];
@@ -44606,7 +45735,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44606
45735
  const qy = py - box.ay;
44607
45736
  const u = (qx * box.eyy - qy * box.eyx) / det;
44608
45737
  const v = (box.exx * qy - box.exy * qx) / det;
44609
- return [f.l + u * (f.r - f.l), f.t + v * (f.b - f.t)];
45738
+ return [f2.l + u * (f2.r - f2.l), f2.t + v * (f2.b - f2.t)];
44610
45739
  };
44611
45740
  [sx, sy] = toFrame(sx, sy);
44612
45741
  [ex, ey] = toFrame(ex, ey);
@@ -44616,8 +45745,8 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44616
45745
  } else if (mirror2) {
44617
45746
  cw = clockwise !== mirror2.y;
44618
45747
  if (mirror2.x) {
44619
- sx = f.l + f.r - sx;
44620
- ex = f.l + f.r - ex;
45748
+ sx = f2.l + f2.r - sx;
45749
+ ex = f2.l + f2.r - ex;
44621
45750
  }
44622
45751
  } else {
44623
45752
  if (box.exx < 0 !== box.eyy < 0) {
@@ -44625,7 +45754,7 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44625
45754
  }
44626
45755
  }
44627
45756
  const mirrorX = !!mirror2?.x && isAxisBox(box);
44628
- const bz = arcBeziers(f.l, f.t, f.r, f.b, sx, sy, ex, ey, cw, !!box.halfX, !!box.framed, mirrorX);
45757
+ const bz = arcBeziers(f2.l, f2.t, f2.r, f2.b, sx, sy, ex, ey, cw, !!box.halfX, !!box.framed, mirrorX);
44629
45758
  const pts = [];
44630
45759
  for (let i = 0; i < bz.length; i += 2) {
44631
45760
  pts.push(...map(bz[i], bz[i + 1]));
@@ -44637,9 +45766,9 @@ function arcRasterPath(box, s, e, clockwise, kind, from, path = new GdiRasterPat
44637
45766
  path.addBeziers(pts, true);
44638
45767
  }
44639
45768
  if (kind === "pie") {
44640
- const w = f.r - f.l;
44641
- const h = f.b - f.t;
44642
- const [cx, cy] = map(f.l + Math.ceil(w / 2) + (box.halfX && !mirrorX ? 1 : 0), f.t + Math.ceil(h / 2));
45769
+ const w = f2.r - f2.l;
45770
+ const h = f2.b - f2.t;
45771
+ const [cx, cy] = map(f2.l + Math.ceil(w / 2) + (box.halfX && !mirrorX ? 1 : 0), f2.t + Math.ceil(h / 2));
44643
45772
  path.lineTo(cx, cy);
44644
45773
  }
44645
45774
  if (kind === "pie" || kind === "chord") {
@@ -44749,11 +45878,11 @@ function brushPaint2(rCtx) {
44749
45878
  };
44750
45879
  }
44751
45880
  function withoutCurveTangents(path) {
44752
- if (!path.figures.some((f) => f.tangents)) {
45881
+ if (!path.figures.some((f2) => f2.tangents)) {
44753
45882
  return path;
44754
45883
  }
44755
45884
  const plain = new GdiRasterPath();
44756
- plain.figures = path.figures.map((f) => ({ pts: f.pts, closed: f.closed, roundWiden: f.roundWiden }));
45885
+ plain.figures = path.figures.map((f2) => ({ pts: f2.pts, closed: f2.closed, roundWiden: f2.roundWiden }));
44757
45886
  return plain;
44758
45887
  }
44759
45888
  function layoutRasterPath(rCtx, path, boxShape = false) {
@@ -44983,11 +46112,11 @@ function strokeStyledCosmetic(rCtx, path, pattern, style) {
44983
46112
  const paint = rop2Paint(state.rop2);
44984
46113
  const bk = state.bkMode === 2 && styleGapsUseBackground(flags);
44985
46114
  const segs2 = [];
44986
- path.figures.forEach((f, fi) => {
46115
+ path.figures.forEach((f2, fi) => {
44987
46116
  if (fi > 0) {
44988
46117
  style.pos = 0;
44989
46118
  }
44990
- const p = f.closed ? [...f.pts, f.pts[0], f.pts[1]] : f.pts;
46119
+ const p = f2.closed ? [...f2.pts, f2.pts[0], f2.pts[1]] : f2.pts;
44991
46120
  for (let i = 0; i + 3 < p.length; i += 2) {
44992
46121
  let n = 0;
44993
46122
  cosmeticLine(p[i], p[i + 1], p[i + 2], p[i + 3], () => {
@@ -45009,10 +46138,10 @@ function strokeStyledCosmetic(rCtx, path, pattern, style) {
45009
46138
  for (const pass of bk ? ["bk", "fg"] : ["fg"]) {
45010
46139
  ctx.strokeStyle = rop2TransformColor(pass === "bk" ? state.bkColor : state.penColor, paint.colorTransform);
45011
46140
  for (const [x0, y0, x1, y1, pos, n] of segs2) {
45012
- const f = Math.hypot(x1 - x0, y1 - y0) / 16 / n;
46141
+ const f2 = Math.hypot(x1 - x0, y1 - y0) / 16 / n;
45013
46142
  if (pass === "fg") {
45014
- ctx.setLineDash(pattern.map((v) => v * f));
45015
- ctx.lineDashOffset = pos % period * f;
46143
+ ctx.setLineDash(pattern.map((v) => v * f2));
46144
+ ctx.lineDashOffset = pos % period * f2;
45016
46145
  } else {
45017
46146
  ctx.setLineDash([]);
45018
46147
  }
@@ -45278,6 +46407,25 @@ function tileIndex(i, n, mirror2) {
45278
46407
  const m = (i % (2 * n) + 2 * n) % (2 * n);
45279
46408
  return m < n ? m : 2 * n - 1 - m;
45280
46409
  }
46410
+ function flattenUnderMatrix(source, toTile, full) {
46411
+ 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] }));
46412
+ const out = [];
46413
+ for (let k = 0; k < points.length; k++) {
46414
+ if ((source.types[k] & 7) === 3 && k > 0 && k + 2 < points.length) {
46415
+ const curve = points.slice(k - 1, k + 3).flatMap((p) => [gdiplusFix(p.x), gdiplusFix(p.y)]);
46416
+ out[out.length - 1] = { x: curve[0] / 16, y: curve[1] / 16 };
46417
+ const flat = [];
46418
+ flattenBezierGdiplus(curve, flat);
46419
+ for (let q = 0; q < flat.length; q += 2) out.push({ x: flat[q] / 16, y: flat[q + 1] / 16 });
46420
+ k += 2;
46421
+ } else {
46422
+ out.push(points[k]);
46423
+ }
46424
+ }
46425
+ const n = out.length;
46426
+ if (n > 1 && out[0].x === out[n - 1].x && out[0].y === out[n - 1].y) out.pop();
46427
+ return out;
46428
+ }
45281
46429
  function fractionalTileSampler(shape, wrap, full) {
45282
46430
  if (Math.abs(full[1]) > 1e-9 || Math.abs(full[2]) > 1e-9 || full[0] <= 0 || full[3] <= 0) return null;
45283
46431
  if (!shape.boundaryArgb.every((color) => color === shape.boundaryArgb[0])) return null;
@@ -45285,7 +46433,7 @@ function fractionalTileSampler(shape, wrap, full) {
45285
46433
  let y0 = Infinity;
45286
46434
  let x1 = -Infinity;
45287
46435
  let y1 = -Infinity;
45288
- for (const point of shape.boundary) {
46436
+ for (const point of shape.source ? shape.source.points : shape.boundary) {
45289
46437
  const x = full[0] * point.x + full[4];
45290
46438
  const y = full[3] * point.y + full[5];
45291
46439
  x0 = Math.min(x0, x);
@@ -45305,7 +46453,8 @@ function fractionalTileSampler(shape, wrap, full) {
45305
46453
  });
45306
46454
  const inner = pathGradientSampler({
45307
46455
  ...shape,
45308
- boundary: shape.boundary.map(toTile),
46456
+ boundary: shape.source ? flattenUnderMatrix(shape.source, toTile, full) : shape.boundary.map(toTile),
46457
+ source: void 0,
45309
46458
  center: toTile(shape.center),
45310
46459
  transform: null
45311
46460
  }, "clamp", IDENTITY4, false, true);
@@ -45320,9 +46469,9 @@ function fractionalTileSampler(shape, wrap, full) {
45320
46469
  texels = new Float64Array(width * height * 4);
45321
46470
  for (let i = 0; i < width * height; i++) {
45322
46471
  const a = rgba[i * 4 + 3];
45323
- texels[i * 4] = rgba[i * 4] * a / 255;
45324
- texels[i * 4 + 1] = rgba[i * 4 + 1] * a / 255;
45325
- texels[i * 4 + 2] = rgba[i * 4 + 2] * a / 255;
46472
+ texels[i * 4] = Math.floor(rgba[i * 4] * a / 255 + 0.5);
46473
+ texels[i * 4 + 1] = Math.floor(rgba[i * 4 + 1] * a / 255 + 0.5);
46474
+ texels[i * 4 + 2] = Math.floor(rgba[i * 4 + 2] * a / 255 + 0.5);
45326
46475
  texels[i * 4 + 3] = a;
45327
46476
  }
45328
46477
  return texels;
@@ -45349,10 +46498,10 @@ function fractionalTileSampler(shape, wrap, full) {
45349
46498
  out[o] = out[o + 1] = out[o + 2] = out[o + 3] = 0;
45350
46499
  continue;
45351
46500
  }
45352
- const scale = coverage >= 255 ? 1 : 255 / coverage;
45353
- out[o] = Math.min(255, Math.floor(sample2(0) * scale + 0.5));
45354
- out[o + 1] = Math.min(255, Math.floor(sample2(1) * scale + 0.5));
45355
- out[o + 2] = Math.min(255, Math.floor(sample2(2) * scale + 0.5));
46501
+ for (let k = 0; k < 3; k++) {
46502
+ const premultiplied2 = Math.floor(sample2(k) + 0.5);
46503
+ out[o + k] = Math.min(255, coverage >= 255 ? premultiplied2 : Math.floor(premultiplied2 * 255 / alpha + 0.5));
46504
+ }
45356
46505
  out[o + 3] = alpha;
45357
46506
  }
45358
46507
  }
@@ -45382,14 +46531,26 @@ function pathGradientSampler(shape, wrap, device, strictOutside = true, straight
45382
46531
  const mirrorY = wrap === "tile-flip-y" || wrap === "tile-flip-xy";
45383
46532
  const bias = wrap === "clamp" ? CLAMP_EDGE_BIAS : 0;
45384
46533
  const tile = wrap === "clamp" ? null : tileDeviceRect(box, full);
45385
- return (x0, y0, w, h, out) => {
46534
+ return (x0, y0, w, h, out, coverage) => {
45386
46535
  const inside = tile !== null && x0 >= tile[0] && x0 + w <= tile[2] && y0 >= tile[1] && y0 + h <= tile[3];
45387
- const windowLeft = tile && !inside ? tile[0] : x0;
45388
- const windowRight = tile && !inside ? tile[2] : x0 + w;
46536
+ let windowLeft = tile && !inside ? tile[0] : x0;
46537
+ let windowRight = tile && !inside ? tile[2] : x0 + w;
45389
46538
  const bitmap = straightBitmap || tile !== null && !inside;
46539
+ const spans = coverage !== void 0 && !(tile && !inside);
45390
46540
  for (let j = 0; j < h; j++) {
45391
46541
  const dy = y0 + j;
46542
+ let runEnd = -1;
45392
46543
  for (let i = 0; i < w; i++) {
46544
+ if (spans && coverage[j * w + i]) {
46545
+ if (i >= runEnd) {
46546
+ let start = i;
46547
+ while (start > 0 && coverage[j * w + start - 1]) start--;
46548
+ runEnd = i;
46549
+ while (runEnd < w && coverage[j * w + runEnd]) runEnd++;
46550
+ windowLeft = x0 + start;
46551
+ windowRight = x0 + runEnd;
46552
+ }
46553
+ }
45393
46554
  const dx = x0 + i + bias;
45394
46555
  let bx = inv3[0] * dx + inv3[2] * dy + inv3[4];
45395
46556
  let by = inv3[1] * dx + inv3[3] * dy + inv3[5];
@@ -46020,8 +47181,8 @@ function handleMoveToEx(rCtx, dataOff, recSize) {
46020
47181
  if (inPath) {
46021
47182
  const p = hasWorldRotation(rCtx) ? gmapPoint(rCtx, state.curX, state.curY) : { x: gmx(rCtx, state.curX), y: gmy(rCtx, state.curY) };
46022
47183
  gdiPathRecorder(rCtx).moveTo(p.x, p.y);
46023
- const f = fixPoint(rCtx, state.curX, state.curY);
46024
- rasterPathOf(rCtx).moveTo(f[0], f[1]);
47184
+ const f2 = fixPoint(rCtx, state.curX, state.curY);
47185
+ rasterPathOf(rCtx).moveTo(f2[0], f2[1]);
46025
47186
  }
46026
47187
  }
46027
47188
  return true;
@@ -46178,7 +47339,7 @@ function rectangleInterior(state, x, y, w, h, scale = 1) {
46178
47339
  c.rect(x0 + 1, y0 + 1, iw, ih);
46179
47340
  };
46180
47341
  }
46181
- var KAPPA2 = 0.5522847498307936;
47342
+ var KAPPA3 = 0.5522847498307936;
46182
47343
  function appendRoundRectPath(c, x0, y0, x1, y1, rx, ry, map) {
46183
47344
  const left = Math.min(x0, x1);
46184
47345
  const right = Math.max(x0, x1);
@@ -46226,8 +47387,8 @@ function appendRoundRectPath(c, x0, y0, x1, y1, rx, ry, map) {
46226
47387
  c.closePath();
46227
47388
  return;
46228
47389
  }
46229
- const kx = ex * KAPPA2;
46230
- const ky = ey * KAPPA2;
47390
+ const kx = ex * KAPPA3;
47391
+ const ky = ey * KAPPA3;
46231
47392
  move(left + ex, top);
46232
47393
  line(right - ex, top);
46233
47394
  curve(right - ex + kx, top, right, top + ey - ky, right, top + ey);
@@ -46763,14 +47924,14 @@ var WHITE_D = WHITE[0] + 15 * WHITE[1] + 3 * WHITE[2];
46763
47924
  var WHITE_U = 4 * WHITE[0] / WHITE_D;
46764
47925
  var WHITE_V = 9 * WHITE[1] / WHITE_D;
46765
47926
  function invert3(m) {
46766
- const [[a, b, c], [d, e, f], [g, h, i]] = m;
46767
- const A = e * i - f * h;
46768
- const B = f * g - d * i;
47927
+ const [[a, b, c], [d, e, f2], [g, h, i]] = m;
47928
+ const A = e * i - f2 * h;
47929
+ const B = f2 * g - d * i;
46769
47930
  const C = d * h - e * g;
46770
47931
  const det = a * A + b * B + c * C;
46771
47932
  return [
46772
- [A / det, (c * h - b * i) / det, (b * f - c * e) / det],
46773
- [B / det, (a * i - c * g) / det, (c * d - a * f) / det],
47933
+ [A / det, (c * h - b * i) / det, (b * f2 - c * e) / det],
47934
+ [B / det, (a * i - c * g) / det, (c * d - a * f2) / det],
46774
47935
  [C / det, (b * g - a * h) / det, (a * e - b * d) / det]
46775
47936
  ];
46776
47937
  }
@@ -46816,7 +47977,7 @@ function chromaTieTable(ca) {
46816
47977
  table2 = null;
46817
47978
  if (flips) {
46818
47979
  table2 = new Int8Array(32768 * 3);
46819
- for (const f of flips) table2[f >> 1] = f & 1 ? 1 : -1;
47980
+ for (const f2 of flips) table2[f2 >> 1] = f2 & 1 ? 1 : -1;
46820
47981
  }
46821
47982
  chromaTieTables.set(key, table2);
46822
47983
  }
@@ -50006,7 +51167,11 @@ function compositeGlyphs(ctx, placed, color, gray, clip, opaque = false) {
50006
51167
  const dx = p.x + x - x0;
50007
51168
  if (dx < 0 || dx >= w) continue;
50008
51169
  const i = dy * w + dx;
50009
- if (v > cov[i]) cov[i] = v;
51170
+ if (gray && cov[i]) {
51171
+ cov[i] = ((cov[i] - 1 | v - 1) & 15) + 1;
51172
+ } else if (v > cov[i]) {
51173
+ cov[i] = v;
51174
+ }
50010
51175
  }
50011
51176
  }
50012
51177
  }
@@ -50070,7 +51235,7 @@ function deviceLogFont(state, heightScale, widthScale) {
50070
51235
  };
50071
51236
  }
50072
51237
  function drawGdiTextCall(ctx, fonts, state, call) {
50073
- const [a, b, c, d, e, f] = call.matrix;
51238
+ const [a, b, c, d, e, f2] = call.matrix;
50074
51239
  const advanceScale = Math.hypot(a, b);
50075
51240
  const fontScale = Math.hypot(c, d);
50076
51241
  if (!(advanceScale > 0) || !(fontScale > 0) || call.codes.length === 0) {
@@ -50102,10 +51267,14 @@ function drawGdiTextCall(ctx, fonts, state, call) {
50102
51267
  glyphFrame = compose(table2.sin, table2.cos);
50103
51268
  frame2 = compose(Math.sin(t), Math.cos(t));
50104
51269
  }
51270
+ if (glyphFrame && call.playbackStretch && call.playbackStretch !== 1) {
51271
+ const k = call.playbackStretch;
51272
+ glyphFrame = [glyphFrame[0] * k, glyphFrame[1] * k, glyphFrame[2], glyphFrame[3]];
51273
+ }
50105
51274
  const updateCp = (state.textAlign & 1) !== 0;
50106
51275
  const lx = updateCp ? state.curX : call.x;
50107
51276
  const ly = updateCp ? state.curY : call.y;
50108
- const map = (x, y) => ({ x: a * x + c * y + e, y: b * x + d * y + f });
51277
+ const map = (x, y) => ({ x: a * x + c * y + e, y: b * x + d * y + f2 });
50109
51278
  const ref = map(lx, ly);
50110
51279
  let rect = null;
50111
51280
  if (call.rect && call.options & (ETO_OPAQUE | ETO_CLIPPED)) {
@@ -50249,15 +51418,15 @@ function gdiTextCoverage(font, run, options2 = {}) {
50249
51418
  const end = x + Math.round(total);
50250
51419
  const snapped = run.plusBars === "snapped" && font.exactDecorations ? fractionalBars(font.exactDecorations, run, run.x + startAlong, run.y + baseDown, total) : null;
50251
51420
  let barIndex = 0;
50252
- const add2 = (position, thickness) => {
51421
+ const add3 = (position, thickness) => {
50253
51422
  const top = Math.round(run.y + baseDown) - position;
50254
51423
  const snap = snapped?.[barIndex++];
50255
51424
  const l = snap ? Math.round(snap.left) : x;
50256
51425
  const r = snap ? Math.round(snap.right) : end;
50257
51426
  bars.push({ left: Math.min(l, r), right: Math.max(l, r), top, bottom: top + Math.max(1, thickness) });
50258
51427
  };
50259
- if (run.underline) add2(font.underlinePosition, font.underlineThickness);
50260
- if (run.strikeOut) add2(font.strikeoutPosition, font.strikeoutThickness);
51428
+ if (run.underline) add3(font.underlinePosition, font.underlineThickness);
51429
+ if (run.strikeOut) add3(font.strikeoutPosition, font.strikeoutThickness);
50261
51430
  }
50262
51431
  if (placed.length === 0 && bars.length === 0 && softBars.length === 0) {
50263
51432
  return null;
@@ -51484,9 +52653,9 @@ function handlePolyDraw(rCtx, offset, dataOff, recSize, pointSize) {
51484
52653
  if (kind === PT_MOVETO) {
51485
52654
  const [x, y] = readPt(i);
51486
52655
  const p = gmapPoint(rCtx, x, y);
51487
- const f = fixPoint(rCtx, x, y);
52656
+ const f2 = fixPoint(rCtx, x, y);
51488
52657
  canvas?.moveTo(p.x, p.y);
51489
- raster?.moveTo(f[0], f[1]);
52658
+ raster?.moveTo(f2[0], f2[1]);
51490
52659
  open = true;
51491
52660
  continue;
51492
52661
  }
@@ -51494,9 +52663,9 @@ function handlePolyDraw(rCtx, offset, dataOff, recSize, pointSize) {
51494
52663
  ensureOpen();
51495
52664
  const [x, y] = readPt(i);
51496
52665
  const p = gmapPoint(rCtx, x, y);
51497
- const f = fixPoint(rCtx, x, y);
52666
+ const f2 = fixPoint(rCtx, x, y);
51498
52667
  canvas?.lineTo(p.x, p.y);
51499
- raster?.lineTo(f[0], f[1]);
52668
+ raster?.lineTo(f2[0], f2[1]);
51500
52669
  } else if (kind === PT_BEZIERTO && i + 2 < count) {
51501
52670
  ensureOpen();
51502
52671
  const pts = [0, 1, 2].map((k) => readPt(i + k));
@@ -51569,8 +52738,8 @@ function paintBracketPath(rCtx, fill2, stroke) {
51569
52738
  if (close) {
51570
52739
  const closed = new GdiRasterPath();
51571
52740
  closed.append(raster);
51572
- for (const f of closed.figures) {
51573
- f.closed = true;
52741
+ for (const f2 of closed.figures) {
52742
+ f2.closed = true;
51574
52743
  }
51575
52744
  raster = closed;
51576
52745
  }
@@ -51588,11 +52757,11 @@ function discardPath(rCtx) {
51588
52757
  }
51589
52758
  function syncPathCmds(rCtx) {
51590
52759
  const cmds = [];
51591
- for (const f of rCtx.rasterPath?.figures ?? []) {
51592
- for (let i = 0; i + 1 < f.pts.length; i += 2) {
51593
- cmds.push({ op: i === 0 ? "moveTo" : "lineTo", x: f.pts[i] / 16, y: f.pts[i + 1] / 16 });
52760
+ for (const f2 of rCtx.rasterPath?.figures ?? []) {
52761
+ for (let i = 0; i + 1 < f2.pts.length; i += 2) {
52762
+ cmds.push({ op: i === 0 ? "moveTo" : "lineTo", x: f2.pts[i] / 16, y: f2.pts[i + 1] / 16 });
51594
52763
  }
51595
- if (f.closed) {
52764
+ if (f2.closed) {
51596
52765
  cmds.push({ op: "closePath" });
51597
52766
  }
51598
52767
  }
@@ -51602,10 +52771,10 @@ function flattenBracketPath(rCtx) {
51602
52771
  if (rCtx.inPath || !rCtx.rasterPath) {
51603
52772
  return;
51604
52773
  }
51605
- for (const f of rCtx.rasterPath.figures) {
51606
- delete f.tangents;
51607
- delete f.curveSegs;
51608
- delete f.roundWiden;
52774
+ for (const f2 of rCtx.rasterPath.figures) {
52775
+ delete f2.tangents;
52776
+ delete f2.curveSegs;
52777
+ delete f2.roundWiden;
51609
52778
  }
51610
52779
  syncPathCmds(rCtx);
51611
52780
  }
@@ -52590,12 +53759,12 @@ function nearestFix2(v) {
52590
53759
  function leafMask(build, m, evenOdd, box, half) {
52591
53760
  let figures;
52592
53761
  try {
52593
- figures = recordDeviceFigures(build, m).map((f) => f.pts.map(nearestFix2));
53762
+ figures = recordDeviceFigures(build, m).map((f2) => f2.pts.map(nearestFix2));
52594
53763
  } catch {
52595
53764
  return null;
52596
53765
  }
52597
53766
  const coverage = rasterizePlusFill(
52598
- figures.filter((f) => f.length >= 6),
53767
+ figures.filter((f2) => f2.length >= 6),
52599
53768
  evenOdd,
52600
53769
  false,
52601
53770
  half,
@@ -52706,7 +53875,7 @@ function insetStrokeCoverage(strokeGroups, figureFix, antialias, half, box, even
52706
53875
  }
52707
53876
  return mask;
52708
53877
  });
52709
- const shifted2 = half ? open.map((f) => f.map((v) => v - 8)) : open;
53878
+ const shifted2 = half ? open.map((f2) => f2.map((v) => v - 8)) : open;
52710
53879
  return rasterizePlusFill([...masks.flatMap((mask) => insetMaskOutline(mask, box.w, box.h, box.x, box.y)), ...shifted2], false, antialias, false, box);
52711
53880
  }
52712
53881
  function insetMaskOutline(mask, w, h, ox, oy) {
@@ -53252,7 +54421,7 @@ function strokeGdiplus(rCtx, pen, nib, sampler, buildPath, device, size, mode, c
53252
54421
  return false;
53253
54422
  }
53254
54423
  if (closedFigure) {
53255
- figures = figures.map((f) => ({ ...f, closed: true }));
54424
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53256
54425
  }
53257
54426
  const width = (pen.width || 1) * frame2.unit;
53258
54427
  const devicePen = framePen(pen, frame2.unit, nib);
@@ -53284,15 +54453,15 @@ function strokeGdiplus(rCtx, pen, nib, sampler, buildPath, device, size, mode, c
53284
54453
  return compositeBrushCoverage(rCtx, sampler, box, coverage, 1, true);
53285
54454
  }
53286
54455
  function widenedPen(figures, devicePen, toFix) {
53287
- const closedFigures = figures.filter((f) => f.closed);
54456
+ const closedFigures = figures.filter((f2) => f2.closed);
53288
54457
  if (!devicePen.inset || devicePen.compound || closedFigures.length === 0) {
53289
54458
  const fix = widenFigures(figures, devicePen).map(toFix);
53290
54459
  return { fix, groups: [fix], insetFigures: null, open: [] };
53291
54460
  }
53292
54461
  const widenPen = { ...devicePen, inset: false, half: devicePen.half * 2, dashOffset: devicePen.dashOffset * 2, dashCapWidth: devicePen.half * 2, doubleRoundCap: true };
53293
- const groups = closedFigures.map((f) => widenFigures([f], widenPen).map(toFix));
54462
+ const groups = closedFigures.map((f2) => widenFigures([f2], widenPen).map(toFix));
53294
54463
  const open = widenFigures(
53295
- figures.filter((f) => !f.closed),
54464
+ figures.filter((f2) => !f2.closed),
53296
54465
  { ...devicePen, inset: false }
53297
54466
  ).map(toFix).map((poly) => {
53298
54467
  const reversed2 = [];
@@ -53301,7 +54470,7 @@ function widenedPen(figures, devicePen, toFix) {
53301
54470
  }
53302
54471
  return reversed2;
53303
54472
  });
53304
- 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] }))));
54473
+ 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] }))));
53305
54474
  return { fix: [...groups.flat(), ...open], groups, insetFigures, open };
53306
54475
  }
53307
54476
  function strokeNominal(rCtx, pen, sampler, buildPath, device, size, antialias, closedFigure) {
@@ -53312,10 +54481,10 @@ function strokeNominal(rCtx, pen, sampler, buildPath, device, size, antialias, c
53312
54481
  return false;
53313
54482
  }
53314
54483
  if (closedFigure) {
53315
- figures = figures.map((f) => ({ ...f, closed: true }));
54484
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53316
54485
  }
53317
54486
  const box = figuresBox(
53318
- figures.map((f) => f.pts),
54487
+ figures.map((f2) => f2.pts),
53319
54488
  size
53320
54489
  );
53321
54490
  if (!box) {
@@ -53371,7 +54540,7 @@ function penOutlineWorld(rCtx, pen, nib, buildPath, closedFigure) {
53371
54540
  return null;
53372
54541
  }
53373
54542
  if (closedFigure) {
53374
- figures = figures.map((f) => ({ ...f, closed: true }));
54543
+ figures = figures.map((f2) => ({ ...f2, closed: true }));
53375
54544
  }
53376
54545
  const width = (pen.width || 1) * frame2.unit;
53377
54546
  const devicePen = framePen(pen, frame2.unit, nib);
@@ -53467,7 +54636,7 @@ function deviceQuad(wt, s, pts) {
53467
54636
  }
53468
54637
  return out;
53469
54638
  }
53470
- function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints) {
54639
+ function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints, worldRect) {
53471
54640
  const { view } = rCtx;
53472
54641
  const kernel = resampleKernelFor(rCtx.interpolationMode ?? 0);
53473
54642
  if (isMetafile || view.getUint32(dataOff + 4, true) !== UNIT_PIXEL2) {
@@ -53490,11 +54659,12 @@ function imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalSc
53490
54659
  halfPixelOffset: isHalfPixelOffset(rCtx.pixelOffsetMode ?? 0),
53491
54660
  ...points ? { pointsForm: true } : {},
53492
54661
  ...points && worldPoints ? { worldPoints, worldMatrix: plusWorldMatrix(rCtx) } : {},
54662
+ ...!points && worldRect ? { worldRect, worldMatrix: plusWorldMatrix(rCtx) } : {},
53493
54663
  ...nominalScale ? { nominalScale: nominalScale(srcW, srcH) } : {},
53494
54664
  ...imageAttributesWrap(rCtx, view.getUint32(dataOff, true))
53495
54665
  };
53496
54666
  }
53497
- function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect = null, points = false, nominalScale, worldPoints) {
54667
+ function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect = null, points = false, nominalScale, worldPoints, worldRect) {
53498
54668
  if (!imgObj.data) {
53499
54669
  return;
53500
54670
  }
@@ -53507,7 +54677,7 @@ function drawOrDeferImage(rCtx, imgObj, dataOff, dx, dy, dw, dh, toWorld, effect
53507
54677
  dh,
53508
54678
  transform: plusWorldMatrix(rCtx),
53509
54679
  isMetafile,
53510
- resample: imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints)
54680
+ resample: imageResampleSpec(rCtx, dataOff, isMetafile, toWorld, points, nominalScale, worldPoints, worldRect)
53511
54681
  };
53512
54682
  const { view } = rCtx;
53513
54683
  const source = {
@@ -53963,7 +55133,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
53963
55133
  down32(dh / sh),
53964
55134
  dx - sx * dw / sw,
53965
55135
  dy - sy * dh / sh
53966
- ], null, false, (sw, sh) => [Math.fround(dw / sw), Math.fround(dh / sh)]);
55136
+ ], null, false, (sw, sh) => [Math.fround(dw / sw), Math.fround(dh / sh)], void 0, [dx, dy, dw, dh]);
53967
55137
  }
53968
55138
  }
53969
55139
  return true;
@@ -55154,10 +56324,10 @@ function replayNestedEmf(bytes, ctx, canvasW, canvasH, toCanvas, options2) {
55154
56324
  if (!header) {
55155
56325
  return null;
55156
56326
  }
55157
- const [a, b, c, d, e, f] = toCanvas;
56327
+ const [a, b, c, d, e, f2] = toCanvas;
55158
56328
  if (b === 0 && c === 0 && a > 0 && d > 0) {
55159
56329
  const left = -e / a;
55160
- const top = -f / d;
56330
+ const top = -f2 / d;
55161
56331
  const bounds2 = { left, top, right: left + canvasW / a, bottom: top + canvasH / d };
55162
56332
  return replayEmfRecords(view, ctx, bounds2, canvasW, canvasH, 1, options2);
55163
56333
  }
@@ -55717,15 +56887,15 @@ function selectObject(p, slot) {
55717
56887
  selectBrush(p, obj);
55718
56888
  break;
55719
56889
  case "font": {
55720
- const f = obj.font;
55721
- s.fontHeight = f.height;
55722
- s.fontWeight = f.weight;
55723
- s.fontItalic = f.italic;
55724
- s.fontUnderline = f.underline;
55725
- s.fontStrikeOut = f.strikeOut;
55726
- s.fontFamily = f.family;
55727
- s.fontEscapementTenthDeg = f.escapementTenthDeg ?? 0;
55728
- s.fontDetails = f.details;
56890
+ const f2 = obj.font;
56891
+ s.fontHeight = f2.height;
56892
+ s.fontWeight = f2.weight;
56893
+ s.fontItalic = f2.italic;
56894
+ s.fontUnderline = f2.underline;
56895
+ s.fontStrikeOut = f2.strikeOut;
56896
+ s.fontFamily = f2.family;
56897
+ s.fontEscapementTenthDeg = f2.escapementTenthDeg ?? 0;
56898
+ s.fontDetails = f2.details;
55729
56899
  break;
55730
56900
  }
55731
56901
  }
@@ -57808,14 +58978,14 @@ function winAnsiByte(cp) {
57808
58978
  return WIN_ANSI_HIGH[cp] ?? -1;
57809
58979
  }
57810
58980
  function standardFamilyFor(familyList) {
57811
- const f = familyList.toLowerCase();
57812
- if (/courier|mono|consolas|lucida console|terminal|fixedsys|andale|menlo|monaco|typewriter/.test(f)) {
58981
+ const f2 = familyList.toLowerCase();
58982
+ if (/courier|mono|consolas|lucida console|terminal|fixedsys|andale|menlo|monaco|typewriter/.test(f2)) {
57813
58983
  return "Courier";
57814
58984
  }
57815
- if (/sans|arial|helvet|verdana|tahoma|calibri|segoe|trebuchet|impact/.test(f)) {
58985
+ if (/sans|arial|helvet|verdana|tahoma|calibri|segoe|trebuchet|impact/.test(f2)) {
57816
58986
  return "Helvetica";
57817
58987
  }
57818
- if (/times|serif|georgia|garamond|palatino|cambria|book antiqua|century|bookman|minion|constantia|baskerville|didot/.test(f)) {
58988
+ if (/times|serif|georgia|garamond|palatino|cambria|book antiqua|century|bookman|minion|constantia|baskerville|didot/.test(f2)) {
57819
58989
  return "Times";
57820
58990
  }
57821
58991
  return "Helvetica";
@@ -58126,12 +59296,12 @@ var PdfFontBook = class {
58126
59296
  const want = bold ? 700 : 400;
58127
59297
  let best = faces[0];
58128
59298
  let bestScore = Infinity;
58129
- for (const f of faces) {
58130
- const isItalic = (f.ttf.fsSelection & 1) !== 0 || (f.ttf.macStyle & 2) !== 0;
58131
- const score2 = Math.abs(f.ttf.weightClass - want) + (isItalic !== italic ? 1e3 : 0);
59299
+ for (const f2 of faces) {
59300
+ const isItalic = (f2.ttf.fsSelection & 1) !== 0 || (f2.ttf.macStyle & 2) !== 0;
59301
+ const score2 = Math.abs(f2.ttf.weightClass - want) + (isItalic !== italic ? 1e3 : 0);
58132
59302
  if (score2 < bestScore) {
58133
59303
  bestScore = score2;
58134
- best = f;
59304
+ best = f2;
58135
59305
  }
58136
59306
  }
58137
59307
  return best;
@@ -58169,8 +59339,8 @@ var PdfFontBook = class {
58169
59339
  }
58170
59340
  /** Writes the subset programs and CID font objects of every embedded font. Call once, after all text is placed. */
58171
59341
  finish() {
58172
- for (const f of this.embeddedFonts) {
58173
- f.finish(this.writer, this.compress);
59342
+ for (const f2 of this.embeddedFonts) {
59343
+ f2.finish(this.writer, this.compress);
58174
59344
  }
58175
59345
  }
58176
59346
  };
@@ -58256,7 +59426,7 @@ function parseSvgMarkup(markup) {
58256
59426
 
58257
59427
  // src/pdf-svg.ts
58258
59428
  var IDENTITY6 = [1, 0, 0, 1, 0, 0];
58259
- function mul5(m, n) {
59429
+ function mul6(m, n) {
58260
59430
  return [
58261
59431
  m[0] * n[0] + m[2] * n[1],
58262
59432
  m[1] * n[0] + m[3] * n[1],
@@ -58304,11 +59474,11 @@ function parseTransform(value) {
58304
59474
  const s = Math.sin(r);
58305
59475
  n = [c, s, -s, c, 0, 0];
58306
59476
  if (a.length === 3) {
58307
- n = mul5(mul5([1, 0, 0, 1, a[1], a[2]], n), [1, 0, 0, 1, -a[1], -a[2]]);
59477
+ n = mul6(mul6([1, 0, 0, 1, a[1], a[2]], n), [1, 0, 0, 1, -a[1], -a[2]]);
58308
59478
  }
58309
59479
  }
58310
59480
  if (n && n.every(Number.isFinite)) {
58311
- m = mul5(m, n);
59481
+ m = mul6(m, n);
58312
59482
  }
58313
59483
  }
58314
59484
  return m;
@@ -58825,7 +59995,7 @@ var PdfBuilder = class {
58825
59995
  }
58826
59996
  const bounds = pts.slice(1, -1).map((p) => num(p.offset));
58827
59997
  return this.writer.add(
58828
- `<< /FunctionType 3 /Domain [0 1] /Functions [${fns.map((f) => `${f} 0 R`).join(" ")}] /Bounds [${bounds.join(" ")}] /Encode [${fns.map(() => "0 1").join(" ")}] >>`
59998
+ `<< /FunctionType 3 /Domain [0 1] /Functions [${fns.map((f2) => `${f2} 0 R`).join(" ")}] /Bounds [${bounds.join(" ")}] /Encode [${fns.map(() => "0 1").join(" ")}] >>`
58829
59999
  );
58830
60000
  }
58831
60001
  /**
@@ -58906,8 +60076,8 @@ var PdfBuilder = class {
58906
60076
  smask = this.alphaMask(c, node, stops, gt, ctm);
58907
60077
  }
58908
60078
  const pattern = this.cached(
58909
- `gp:${node.attrs.id}:${mul5(ctm, gt).map(num).join(",")}`,
58910
- () => this.writer.add(`<< /Type /Pattern /PatternType 2 /Shading ${shading} 0 R /Matrix [${mul5(ctm, gt).map(num).join(" ")}] >>`)
60079
+ `gp:${node.attrs.id}:${mul6(ctm, gt).map(num).join(",")}`,
60080
+ () => this.writer.add(`<< /Type /Pattern /PatternType 2 /Shading ${shading} 0 R /Matrix [${mul6(ctm, gt).map(num).join(" ")}] >>`)
58911
60081
  );
58912
60082
  colorOp = `/Pattern ${stroke ? "CS" : "cs"} ${c.res.use("Pattern", pattern)} ${stroke ? "SCN" : "scn"}`;
58913
60083
  }
@@ -58976,7 +60146,7 @@ var PdfBuilder = class {
58976
60146
  if (tw <= 0 || th <= 0) {
58977
60147
  return null;
58978
60148
  }
58979
- const m = mul5(ctm, parseTransform(p.attrs.patternTransform));
60149
+ const m = mul6(ctm, parseTransform(p.attrs.patternTransform));
58980
60150
  return this.cached(`tp:${p.attrs.id}:${m.map(num).join(",")}`, () => {
58981
60151
  const tile = { ops: [], res: new Resources(), bounds: [0, 0, tw, th] };
58982
60152
  for (const child of p.children ?? []) {
@@ -59036,7 +60206,7 @@ var PdfBuilder = class {
59036
60206
  if (node.attrs.transform !== void 0) {
59037
60207
  const t = parseTransform(node.attrs.transform);
59038
60208
  c.ops.push(matrixOp(t));
59039
- m = mul5(ctm, t);
60209
+ m = mul6(ctm, t);
59040
60210
  }
59041
60211
  this.clipOps(c, node.attrs["clip-path"], scope);
59042
60212
  for (const child of node.children ?? []) {
@@ -59067,7 +60237,7 @@ var PdfBuilder = class {
59067
60237
  const style = parseStyleAttr(a.style);
59068
60238
  const blend = BLEND_NAMES[style["mix-blend-mode"]] ?? null;
59069
60239
  const t = a.transform !== void 0 ? parseTransform(a.transform) : null;
59070
- const m = t ? mul5(ctm, t) : ctm;
60240
+ const m = t ? mul6(ctm, t) : ctm;
59071
60241
  if (!isFinite(m[0] + m[3]) || m[0] * m[3] - m[1] * m[2] === 0) {
59072
60242
  return;
59073
60243
  }
@@ -59180,7 +60350,7 @@ var PdfBuilder = class {
59180
60350
  const families = String(a["font-family"] ?? "sans-serif");
59181
60351
  const font = this.fontBook.resolve(families, bold, italic);
59182
60352
  const t = a.transform !== void 0 ? parseTransform(a.transform) : null;
59183
- const m = t ? mul5(ctm, t) : ctm;
60353
+ const m = t ? mul6(ctm, t) : ctm;
59184
60354
  c.ops.push("q");
59185
60355
  if (t) {
59186
60356
  c.ops.push(matrixOp(t));
@@ -59276,7 +60446,7 @@ async function svgTreeToPdf(tree, options2 = {}) {
59276
60446
  offY = (pageH - heightPx * scale) / 2;
59277
60447
  }
59278
60448
  const toPage = [scale, 0, 0, -scale, offX, pageH - offY];
59279
- const base = mul5(toPage, toPx);
60449
+ const base = mul6(toPage, toPx);
59280
60450
  const content = { ops: [], res: new Resources(), bounds: [0, 0, pageW, pageH] };
59281
60451
  const scope = { defs: /* @__PURE__ */ new Map() };
59282
60452
  indexIds(tree, scope.defs);
@@ -59418,12 +60588,12 @@ function addImage(scan, mime) {
59418
60588
  scan.mimeTypes.add(mime);
59419
60589
  }
59420
60590
  function mergeNested(scan, inner) {
59421
- for (const f of inner.fonts.values()) {
59422
- if (f.gdi) {
59423
- addFont(scan, f.name, "gdi");
60591
+ for (const f2 of inner.fonts.values()) {
60592
+ if (f2.gdi) {
60593
+ addFont(scan, f2.name, "gdi");
59424
60594
  }
59425
- if (f.emfPlus) {
59426
- addFont(scan, f.name, "emfPlus");
60595
+ if (f2.emfPlus) {
60596
+ addFont(scan, f2.name, "emfPlus");
59427
60597
  }
59428
60598
  }
59429
60599
  scan.hasText || (scan.hasText = inner.hasText);
@@ -59727,10 +60897,10 @@ function inspectWmf(view, opts) {
59727
60897
  width = inner.width;
59728
60898
  height = inner.height;
59729
60899
  description = inner.description;
59730
- for (const f of inner.fonts) {
59731
- addFont(scan, f.name, f.gdi ? "gdi" : "emfPlus");
59732
- if (f.gdi && f.emfPlus) {
59733
- addFont(scan, f.name, "emfPlus");
60900
+ for (const f2 of inner.fonts) {
60901
+ addFont(scan, f2.name, f2.gdi ? "gdi" : "emfPlus");
60902
+ if (f2.gdi && f2.emfPlus) {
60903
+ addFont(scan, f2.name, "emfPlus");
59734
60904
  }
59735
60905
  }
59736
60906
  scan.hasText || (scan.hasText = inner.hasText);