@pixerate/editor 0.115.0 → 0.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -0
  2. package/dist/animation-editor/index.cjs +54 -54
  3. package/dist/animation-editor/index.d.cts +2 -2
  4. package/dist/animation-editor/index.d.ts +2 -2
  5. package/dist/animation-editor/index.js +2 -2
  6. package/dist/{chunk-I7FQBWMQ.cjs → chunk-2J3LS7JZ.cjs} +333 -333
  7. package/dist/{chunk-I7FQBWMQ.cjs.map → chunk-2J3LS7JZ.cjs.map} +1 -1
  8. package/dist/{chunk-TFOPHZ3U.cjs → chunk-7ISPWEJA.cjs} +302 -5
  9. package/dist/chunk-7ISPWEJA.cjs.map +1 -0
  10. package/dist/{chunk-VXR7XWMF.js → chunk-7LNZAWSJ.js} +437 -41
  11. package/dist/chunk-7LNZAWSJ.js.map +1 -0
  12. package/dist/{chunk-DFQEX3AM.cjs → chunk-BYAWOAST.cjs} +223 -30
  13. package/dist/chunk-BYAWOAST.cjs.map +1 -0
  14. package/dist/chunk-COAMRKVI.cjs +159 -0
  15. package/dist/chunk-COAMRKVI.cjs.map +1 -0
  16. package/dist/{chunk-ST7E3NEE.cjs → chunk-EBSYZRSW.cjs} +230 -732
  17. package/dist/chunk-EBSYZRSW.cjs.map +1 -0
  18. package/dist/chunk-EJVDBITD.cjs +501 -0
  19. package/dist/chunk-EJVDBITD.cjs.map +1 -0
  20. package/dist/{chunk-LPLCWZTM.cjs → chunk-FODKPD44.cjs} +555 -159
  21. package/dist/chunk-FODKPD44.cjs.map +1 -0
  22. package/dist/{chunk-XK5LZKBD.js → chunk-HKDTM6VC.js} +298 -1
  23. package/dist/chunk-HKDTM6VC.js.map +1 -0
  24. package/dist/chunk-IPFRWILU.js +1908 -0
  25. package/dist/chunk-IPFRWILU.js.map +1 -0
  26. package/dist/chunk-IVSNUXW7.js +3339 -0
  27. package/dist/chunk-IVSNUXW7.js.map +1 -0
  28. package/dist/{chunk-LKCYANMW.js → chunk-JHXMNOMF.js} +198 -5
  29. package/dist/chunk-JHXMNOMF.js.map +1 -0
  30. package/dist/{chunk-FV5AXTSF.cjs → chunk-JSSBHMMU.cjs} +36 -188
  31. package/dist/chunk-JSSBHMMU.cjs.map +1 -0
  32. package/dist/chunk-L2T6EJ5S.cjs +3339 -0
  33. package/dist/chunk-L2T6EJ5S.cjs.map +1 -0
  34. package/dist/chunk-LF4WOZXZ.js +159 -0
  35. package/dist/chunk-LF4WOZXZ.js.map +1 -0
  36. package/dist/{chunk-26PGXHY7.cjs → chunk-M7O4BJRH.cjs} +36 -36
  37. package/dist/{chunk-26PGXHY7.cjs.map → chunk-M7O4BJRH.cjs.map} +1 -1
  38. package/dist/chunk-N3467VD6.js +501 -0
  39. package/dist/chunk-N3467VD6.js.map +1 -0
  40. package/dist/{chunk-XICA4PVO.js → chunk-R2JE6SA7.js} +17 -17
  41. package/dist/chunk-SMJGE7HM.cjs +1908 -0
  42. package/dist/chunk-SMJGE7HM.cjs.map +1 -0
  43. package/dist/{chunk-MMVHBKMM.js → chunk-T2P5TIZ6.js} +2 -2
  44. package/dist/{chunk-C6C5PDKU.js → chunk-VD2UDVF7.js} +102 -604
  45. package/dist/chunk-VD2UDVF7.js.map +1 -0
  46. package/dist/{chunk-FGW5OWJ4.js → chunk-VJUML33I.js} +4 -156
  47. package/dist/chunk-VJUML33I.js.map +1 -0
  48. package/dist/export/index.cjs +4 -2
  49. package/dist/export/index.cjs.map +1 -1
  50. package/dist/export/index.js +5 -3
  51. package/dist/{export-BJE8T0YA.d.cts → export-DMOuzgZZ.d.cts} +9 -4
  52. package/dist/{export-Con3UKkm.d.ts → export-Dul1SbPv.d.ts} +9 -4
  53. package/dist/export-Dv0-ZVrV.d.cts +501 -0
  54. package/dist/export-Dv0-ZVrV.d.ts +501 -0
  55. package/dist/{retouch-Bxkuc0KH.d.cts → flow-4-OC-UkQ.d.cts} +582 -2
  56. package/dist/{retouch-Do6tBs2H.d.ts → flow-Cb7lkPm8.d.ts} +582 -2
  57. package/dist/image-editor/index.cjs +1345 -1095
  58. package/dist/image-editor/index.cjs.map +1 -1
  59. package/dist/image-editor/index.d.cts +8 -8
  60. package/dist/image-editor/index.d.ts +8 -8
  61. package/dist/image-editor/index.js +300 -50
  62. package/dist/image-editor/index.js.map +1 -1
  63. package/dist/index.cjs +4 -2
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.js +5 -3
  66. package/dist/index.js.map +1 -1
  67. package/dist/kernel-wasm-WYCGNZR4.js +10 -0
  68. package/dist/kernel-wasm-WYCGNZR4.js.map +1 -0
  69. package/dist/kernel-wasm-YPVAEMVN.cjs +10 -0
  70. package/dist/kernel-wasm-YPVAEMVN.cjs.map +1 -0
  71. package/dist/paint/index.cjs +170 -4
  72. package/dist/paint/index.cjs.map +1 -1
  73. package/dist/paint/index.d.cts +225 -3
  74. package/dist/paint/index.d.ts +225 -3
  75. package/dist/paint/index.js +171 -5
  76. package/dist/paint-editor/index.cjs +4735 -890
  77. package/dist/paint-editor/index.cjs.map +1 -1
  78. package/dist/paint-editor/index.d.cts +1526 -278
  79. package/dist/paint-editor/index.d.ts +1526 -278
  80. package/dist/paint-editor/index.js +4561 -716
  81. package/dist/paint-editor/index.js.map +1 -1
  82. package/dist/raster/index.cjs +7 -4
  83. package/dist/raster/index.cjs.map +1 -1
  84. package/dist/raster/index.d.cts +2 -2
  85. package/dist/raster/index.d.ts +2 -2
  86. package/dist/raster/index.js +36 -33
  87. package/dist/{render-CrmHOgpo.d.ts → render-B05K68_h.d.ts} +9 -1
  88. package/dist/{render-B1K_OoLy.d.cts → render-DnAbIKcs.d.cts} +9 -1
  89. package/dist/{svg-BnRj0q8i.d.cts → svg-CVdFc80-.d.cts} +2 -2
  90. package/dist/{svg-CmmBFfGT.d.ts → svg-DlEuhwoX.d.ts} +2 -2
  91. package/dist/{types-1SUQKDAw.d.ts → types-CDLGhAZp.d.ts} +40 -2
  92. package/dist/{types-yINF17Ta.d.cts → types-Tfly4Aya.d.cts} +40 -2
  93. package/dist/vector/index.cjs +6536 -4525
  94. package/dist/vector/index.cjs.map +1 -1
  95. package/dist/vector/index.d.cts +426 -32
  96. package/dist/vector/index.d.ts +426 -32
  97. package/dist/vector/index.js +11397 -9386
  98. package/dist/vector/index.js.map +1 -1
  99. package/dist/video-editor/index.cjs +502 -2165
  100. package/dist/video-editor/index.cjs.map +1 -1
  101. package/dist/video-editor/index.d.cts +3 -501
  102. package/dist/video-editor/index.d.ts +3 -501
  103. package/dist/video-editor/index.js +151 -1814
  104. package/dist/video-editor/index.js.map +1 -1
  105. package/package.json +1 -1
  106. package/skills/pixerate-image-editor/references/photoshop-files.md +7 -3
  107. package/skills/pixerate-vector/SKILL.md +3 -0
  108. package/dist/chunk-C6C5PDKU.js.map +0 -1
  109. package/dist/chunk-DFQEX3AM.cjs.map +0 -1
  110. package/dist/chunk-FGW5OWJ4.js.map +0 -1
  111. package/dist/chunk-FV5AXTSF.cjs.map +0 -1
  112. package/dist/chunk-GX332W2C.js +0 -181
  113. package/dist/chunk-GX332W2C.js.map +0 -1
  114. package/dist/chunk-LKCYANMW.js.map +0 -1
  115. package/dist/chunk-LPLCWZTM.cjs.map +0 -1
  116. package/dist/chunk-MUUXNRU4.cjs +0 -181
  117. package/dist/chunk-MUUXNRU4.cjs.map +0 -1
  118. package/dist/chunk-ST7E3NEE.cjs.map +0 -1
  119. package/dist/chunk-TCKIXI46.cjs +0 -1136
  120. package/dist/chunk-TCKIXI46.cjs.map +0 -1
  121. package/dist/chunk-TFOPHZ3U.cjs.map +0 -1
  122. package/dist/chunk-UBIXVXPR.js +0 -1136
  123. package/dist/chunk-UBIXVXPR.js.map +0 -1
  124. package/dist/chunk-VXR7XWMF.js.map +0 -1
  125. package/dist/chunk-XK5LZKBD.js.map +0 -1
  126. /package/dist/{chunk-XICA4PVO.js.map → chunk-R2JE6SA7.js.map} +0 -0
  127. /package/dist/{chunk-MMVHBKMM.js.map → chunk-T2P5TIZ6.js.map} +0 -0
@@ -159,8 +159,8 @@ var fmtMatrix = (m) => `matrix(${m.map((n) => fmt(n, 6)).join(" ")})`;
159
159
  function isVectorGradient(paint) {
160
160
  return !!paint && typeof paint === "object" && VECTOR_GRADIENT_TYPES.includes(paint.type) && Array.isArray(paint.stops);
161
161
  }
162
- function parseVectorColor(color) {
163
- const hex = normalizeTokenColor(color);
162
+ function parseVectorColor(color2) {
163
+ const hex = normalizeTokenColor(color2);
164
164
  if (hex === null) return null;
165
165
  const c = hexToRgba(hex);
166
166
  return [c.r, c.g, c.b, c.a];
@@ -262,15 +262,15 @@ function sampleVectorGradient(g, t) {
262
262
  return s ? { color: s.color, opacity: s.opacity ?? 1 } : { color: "#000000", opacity: 0 };
263
263
  }
264
264
  var stopOf = (offset, c) => {
265
- const color = rgbaToHex(c[0], c[1], c[2]);
265
+ const color2 = rgbaToHex(c[0], c[1], c[2]);
266
266
  const opacity = Math.round(c[3] * 1e4) / 1e4;
267
- return opacity < 1 ? { offset, color, opacity } : { offset, color };
267
+ return opacity < 1 ? { offset, color: color2, opacity } : { offset, color: color2 };
268
268
  };
269
269
  var maxDiff = (a, b) => Math.max(Math.abs(a[0] - b[0]), Math.abs(a[1] - b[1]), Math.abs(a[2] - b[2]), Math.abs(a[3] - b[3]));
270
270
  var lerpRgba = (a, b, u) => [0, 1, 2, 3].map((c) => a[c] + (b[c] - a[c]) * u);
271
271
  function expandVectorGradientStops(g, options = {}) {
272
272
  const stops = sortedVectorGradientStops(g);
273
- const plain2 = () => stops.map(({ offset, color, opacity }) => opacity !== void 0 && opacity !== 1 ? { offset, color, opacity } : { offset, color });
273
+ const plain2 = () => stops.map(({ offset, color: color2, opacity }) => opacity !== void 0 && opacity !== 1 ? { offset, color: color2, opacity } : { offset, color: color2 });
274
274
  if (!vectorGradientNeedsExpansion(g)) return plain2();
275
275
  const ramp = vectorGradientRamp(g);
276
276
  if (!ramp || stops.length < 2) return plain2();
@@ -342,9 +342,9 @@ function placeStop(stops, stop) {
342
342
  }
343
343
  function insertVectorGradientStop(g, offset) {
344
344
  const at2 = clamp(offset, 0, 1);
345
- const { color, opacity } = sampleVectorGradient(g, at2);
345
+ const { color: color2, opacity } = sampleVectorGradient(g, at2);
346
346
  const stops = sortedVectorGradientStops(g);
347
- const index = placeStop(stops, opacity < 1 ? { offset: at2, color, opacity } : { offset: at2, color });
347
+ const index = placeStop(stops, opacity < 1 ? { offset: at2, color: color2, opacity } : { offset: at2, color: color2 });
348
348
  return { stops, index };
349
349
  }
350
350
  function moveVectorGradientStop(stops, index, offset) {
@@ -527,9 +527,11 @@ function mapVectorGradient(g, f) {
527
527
  return { ...g, start: f(p.start), end: f(p.end), width: f(p.width), ...p.focal ? { focal: f(p.focal) } : {} };
528
528
  }
529
529
  function mapVectorPaint(paint, f) {
530
+ if (isVectorShadedPaint(paint)) return mapVectorShadedPaint(paint, f);
530
531
  return isVectorGradient(paint) ? mapVectorGradient(paint, f) : paint;
531
532
  }
532
533
  function transformVectorPaint(paint, m) {
534
+ if (isVectorShadedPaint(paint)) return transformVectorShadedPaint(paint, m);
533
535
  return isVectorGradient(paint) ? transformVectorGradient(paint, m) : paint;
534
536
  }
535
537
  var isCentredVectorGradient = (type) => type === "radial" || type === "conic" || type === "diamond";
@@ -936,6 +938,365 @@ function applyVectorGradientPatch(g, patch) {
936
938
  return clean2;
937
939
  }
938
940
 
941
+ // src/vector/shading.ts
942
+ function isVectorMeshGradient(paint) {
943
+ return !!paint && typeof paint === "object" && paint.type === "mesh" && Array.isArray(paint.points);
944
+ }
945
+ function isVectorFreeformGradient(paint) {
946
+ return !!paint && typeof paint === "object" && paint.type === "freeform" && Array.isArray(paint.points);
947
+ }
948
+ function isVectorShadedPaint(paint) {
949
+ return isVectorMeshGradient(paint) || isVectorFreeformGradient(paint);
950
+ }
951
+ var lerp = (a, b, t) => a + (b - a) * t;
952
+ var rgbaOf = (color2, opacity = 1) => {
953
+ const c = parseVectorColor(color2) ?? [0, 0, 0, 1];
954
+ return [c[0], c[1], c[2], c[3] * opacity];
955
+ };
956
+ var hex2 = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255).toString(16).padStart(2, "0");
957
+ function vectorRgbaToCss([r, g, b, a]) {
958
+ if (a >= 0.9995) return `#${hex2(r)}${hex2(g)}${hex2(b)}`;
959
+ const c = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255);
960
+ return `rgba(${c(r)},${c(g)},${c(b)},${Math.round(Math.max(0, a) * 1e3) / 1e3})`;
961
+ }
962
+ var VECTOR_MESH_MAX = 32;
963
+ function createVectorMeshGradient(bounds, rows, columns, colors = {}) {
964
+ const r = Math.min(VECTOR_MESH_MAX, Math.max(1, Math.round(rows)));
965
+ const c = Math.min(VECTOR_MESH_MAX, Math.max(1, Math.round(columns)));
966
+ const points = [];
967
+ const out = [];
968
+ const corners = colors.corners?.map((k) => rgbaOf(k));
969
+ for (let i = 0; i <= r; i++) {
970
+ for (let j = 0; j <= c; j++) {
971
+ points.push({ x: bounds.x + bounds.width * j / c, y: bounds.y + bounds.height * i / r });
972
+ const k = i * (c + 1) + j;
973
+ if (colors.colors?.[k]) out.push(colors.colors[k]);
974
+ else if (corners) {
975
+ const u = j / c;
976
+ const v2 = i / r;
977
+ const top = corners[0].map((x, n) => lerp(x, corners[1][n], u));
978
+ const bottom = corners[3].map((x, n) => lerp(x, corners[2][n], u));
979
+ out.push(vectorRgbaToCss(top.map((x, n) => lerp(x, bottom[n], v2))));
980
+ } else out.push("#ffffff");
981
+ }
982
+ }
983
+ return { type: "mesh", rows: r, columns: c, points, colors: out };
984
+ }
985
+ function catmull(p0, p1, p2, p3) {
986
+ return [p1, { x: p1.x + (p2.x - p0.x) / 6, y: p1.y + (p2.y - p0.y) / 6 }, { x: p2.x - (p3.x - p1.x) / 6, y: p2.y - (p3.y - p1.y) / 6 }, p2];
987
+ }
988
+ function cubicAt(c, t) {
989
+ const s = 1 - t;
990
+ const a = s * s * s;
991
+ const b = 3 * s * s * t;
992
+ const d = 3 * s * t * t;
993
+ const e = t * t * t;
994
+ return { x: a * c[0].x + b * c[1].x + d * c[2].x + e * c[3].x, y: a * c[0].y + b * c[1].y + d * c[2].y + e * c[3].y };
995
+ }
996
+ function meshOk(m) {
997
+ const n = (m.rows + 1) * (m.columns + 1);
998
+ return m.rows >= 1 && m.columns >= 1 && m.points.length === n && m.colors.length === n;
999
+ }
1000
+ function meshLattice(m) {
1001
+ const cols = m.columns + 1;
1002
+ const at2 = (r, c) => m.points[r * cols + c];
1003
+ const ext = (a, b) => ({ x: 2 * a.x - b.x, y: 2 * a.y - b.y });
1004
+ const P = (r, c) => {
1005
+ if (r < 0) return ext(P(0, c), P(1, c));
1006
+ if (r > m.rows) return ext(P(m.rows, c), P(m.rows - 1, c));
1007
+ if (c < 0) return ext(at2(r, 0), at2(r, 1));
1008
+ if (c > m.columns) return ext(at2(r, m.columns), at2(r, m.columns - 1));
1009
+ return at2(r, c);
1010
+ };
1011
+ return P;
1012
+ }
1013
+ function vectorMeshPointAt(m, i, j, u, v2) {
1014
+ const P = meshLattice(m);
1015
+ const top = catmull(P(i, j - 1), P(i, j), P(i, j + 1), P(i, j + 2));
1016
+ const bottom = catmull(P(i + 1, j - 1), P(i + 1, j), P(i + 1, j + 1), P(i + 1, j + 2));
1017
+ const left2 = catmull(P(i - 1, j), P(i, j), P(i + 1, j), P(i + 2, j));
1018
+ const right = catmull(P(i - 1, j + 1), P(i, j + 1), P(i + 1, j + 1), P(i + 2, j + 1));
1019
+ const t = cubicAt(top, u);
1020
+ const b = cubicAt(bottom, u);
1021
+ const l = cubicAt(left2, v2);
1022
+ const r = cubicAt(right, v2);
1023
+ const [p00, p01, p11, p10] = [P(i, j), P(i, j + 1), P(i + 1, j + 1), P(i + 1, j)];
1024
+ const bl = (k) => (1 - u) * (1 - v2) * p00[k] + u * (1 - v2) * p01[k] + u * v2 * p11[k] + (1 - u) * v2 * p10[k];
1025
+ return { x: (1 - v2) * t.x + v2 * b.x + (1 - u) * l.x + u * r.x - bl("x"), y: (1 - v2) * t.y + v2 * b.y + (1 - u) * l.y + u * r.y - bl("y") };
1026
+ }
1027
+ function vectorMeshColorAt(m, i, j, u, v2) {
1028
+ const cols = m.columns + 1;
1029
+ const C = (r, c2) => rgbaOf(m.colors[r * cols + c2], m.opacities?.[r * cols + c2] ?? 1);
1030
+ const a = C(i, j);
1031
+ const b = C(i, j + 1);
1032
+ const c = C(i + 1, j + 1);
1033
+ const d = C(i + 1, j);
1034
+ return [0, 1, 2, 3].map((k) => (1 - u) * (1 - v2) * a[k] + u * (1 - v2) * b[k] + u * v2 * c[k] + (1 - u) * v2 * d[k]);
1035
+ }
1036
+ function vectorMeshLines(m) {
1037
+ const P = meshLattice(m);
1038
+ const rows = [];
1039
+ for (let i = 0; i <= m.rows; i++) rows.push(Array.from({ length: m.columns }, (_, j) => catmull(P(i, j - 1), P(i, j), P(i, j + 1), P(i, j + 2))));
1040
+ const columns = [];
1041
+ for (let j = 0; j <= m.columns; j++) columns.push(Array.from({ length: m.rows }, (_, i) => catmull(P(i - 1, j), P(i, j), P(i + 1, j), P(i + 2, j))));
1042
+ return { rows, columns };
1043
+ }
1044
+ var LINE_STEPS = 16;
1045
+ var lerpSource = (a, b, t) => ({ x: lerp(a.x, b.x, t), y: lerp(a.y, b.y, t), c: a.c.map((v2, k) => lerp(v2, b.c[k], t)), radius: lerp(a.radius, b.radius, t) });
1046
+ function vectorFreeformSpreadScale(bounds) {
1047
+ return Math.max(Math.abs(bounds.width), Math.abs(bounds.height)) / 2;
1048
+ }
1049
+ function vectorFreeformLineSegments(f, line) {
1050
+ const ix = f.lines?.[line];
1051
+ if (!ix) return [];
1052
+ const pts = ix.map((i) => f.points[i]);
1053
+ if (pts.some((p) => !p)) return [];
1054
+ const n = pts.length;
1055
+ const out = [];
1056
+ for (let i = 0; i + 1 < n; i++) out.push(catmull(pts[Math.max(0, i - 1)], pts[i], pts[i + 1], pts[Math.min(n - 1, i + 2)]));
1057
+ return out;
1058
+ }
1059
+ function vectorFreeformField(f, scale3) {
1060
+ const src = (p) => ({ x: p.x, y: p.y, c: rgbaOf(p.color, p.opacity ?? 1), radius: Math.min(1, Math.max(0, p.spread ?? 0)) * scale3 });
1061
+ const points = f.points.map(src);
1062
+ const pieces = [];
1063
+ (f.lines ?? []).forEach((ix, l) => {
1064
+ const v2 = [];
1065
+ vectorFreeformLineSegments(f, l).forEach((c, s) => {
1066
+ const a = points[ix[s]];
1067
+ const b = points[ix[s + 1]];
1068
+ for (let k = s === 0 ? 0 : 1; k <= LINE_STEPS; k++) {
1069
+ const t = k / LINE_STEPS;
1070
+ const at2 = cubicAt(c, t);
1071
+ v2.push({ ...lerpSource(a, b, t), x: at2.x, y: at2.y });
1072
+ }
1073
+ });
1074
+ let len2 = 0;
1075
+ for (let k = 1; k < v2.length; k++) len2 += Math.hypot(v2[k].x - v2[k - 1].x, v2[k].y - v2[k - 1].y);
1076
+ const n = Math.max(1, v2.length - 1);
1077
+ for (let k = 1; k < v2.length; k++) {
1078
+ const d = Math.hypot(v2[k].x - v2[k - 1].x, v2[k].y - v2[k - 1].y);
1079
+ pieces.push({ a: v2[k - 1], b: v2[k], share: len2 > 0 ? d / len2 : 1 / n });
1080
+ }
1081
+ });
1082
+ return { points, pieces, eps: 1e-9 * (Math.abs(scale3) + 1) };
1083
+ }
1084
+ function sampleVectorFreeform(field, p) {
1085
+ const disc = { w: 0, c: [0, 0, 0, 0] };
1086
+ const far = { w: 0, c: [0, 0, 0, 0] };
1087
+ const add5 = (d, s, share) => {
1088
+ let acc2;
1089
+ let w;
1090
+ if (d < s.radius || d <= field.eps) {
1091
+ acc2 = disc;
1092
+ w = (s.radius - d + field.eps) * share;
1093
+ } else {
1094
+ const e = d - s.radius;
1095
+ acc2 = far;
1096
+ w = share / (e * e);
1097
+ }
1098
+ acc2.w += w;
1099
+ for (let k = 0; k < 4; k++) acc2.c[k] += w * s.c[k];
1100
+ };
1101
+ for (const s of field.points) add5(Math.hypot(s.x - p.x, s.y - p.y), s, 1);
1102
+ for (const piece of field.pieces) {
1103
+ const vx = piece.b.x - piece.a.x;
1104
+ const vy = piece.b.y - piece.a.y;
1105
+ const l2 = vx * vx + vy * vy;
1106
+ const t = l2 > 0 ? Math.min(1, Math.max(0, ((p.x - piece.a.x) * vx + (p.y - piece.a.y) * vy) / l2)) : 0;
1107
+ const s = lerpSource(piece.a, piece.b, t);
1108
+ add5(Math.hypot(s.x - p.x, s.y - p.y), s, piece.share);
1109
+ }
1110
+ const acc = disc.w > 0 ? disc : far;
1111
+ if (!(acc.w > 0 && Number.isFinite(acc.w))) return [0, 0, 0, 0];
1112
+ return acc.c.map((v2) => v2 / acc.w);
1113
+ }
1114
+ function autoVectorFreeformGradient(b, colors, inside = () => true) {
1115
+ const w = Math.max(b.width, 1e-9);
1116
+ const h = Math.max(b.height, 1e-9);
1117
+ const long = Math.min(4, Math.max(2, Math.round(2 * Math.max(w, h) / Math.min(w, h))));
1118
+ const [cols, rows] = w >= h ? [long, 2] : [2, long];
1119
+ const cell = (i, n2) => (i + 0.5) / n2;
1120
+ const targets = [];
1121
+ for (let j = 0; j < rows; j++) for (let k = 0; k < cols; k++) targets.push({ x: b.x + cell(j % 2 === 0 ? k : cols - 1 - k, cols) * w, y: b.y + cell(j, rows) * h });
1122
+ const GRID = 24;
1123
+ const candidates = [];
1124
+ for (let k = 0; k < GRID * GRID; k++) {
1125
+ const p = { x: b.x + cell(k % GRID, GRID) * w, y: b.y + cell(Math.floor(k / GRID), GRID) * h };
1126
+ if (inside(p)) candidates.push(p);
1127
+ }
1128
+ const apart = Math.min(w, h) * 0.15;
1129
+ const placed = [];
1130
+ for (const t of targets) {
1131
+ let at2 = t;
1132
+ if (!inside(t)) {
1133
+ let best = null;
1134
+ let bestD = Infinity;
1135
+ for (const c of candidates) {
1136
+ if (!placed.every((q) => Math.hypot(q.x - c.x, q.y - c.y) >= apart)) continue;
1137
+ const d = Math.hypot(c.x - t.x, c.y - t.y);
1138
+ if (d < bestD) {
1139
+ best = c;
1140
+ bestD = d;
1141
+ }
1142
+ }
1143
+ at2 = best ?? t;
1144
+ }
1145
+ placed.push(at2);
1146
+ }
1147
+ const palette = colors.length ? colors : ["#ffffff", "#000000"];
1148
+ const n = placed.length;
1149
+ const colorAt = (k) => {
1150
+ if (palette.length === 1) return palette[0];
1151
+ const t = k / Math.max(1, n - 1) * (palette.length - 1);
1152
+ const i = Math.min(palette.length - 2, Math.floor(t));
1153
+ const a = rgbaOf(palette[i]);
1154
+ const c = rgbaOf(palette[i + 1]);
1155
+ return vectorRgbaToCss(a.map((v2, q) => lerp(v2, c[q], t - i)));
1156
+ };
1157
+ return { type: "freeform", points: placed.map((p, k) => ({ x: p.x, y: p.y, color: colorAt(k) })) };
1158
+ }
1159
+ var fmt2 = (n, digits) => {
1160
+ const k = 10 ** digits;
1161
+ const v2 = Math.round(n * k) / k;
1162
+ return Object.is(v2, -0) ? "0" : String(v2);
1163
+ };
1164
+ var quadD = (pts, precision) => `M${pts.map((p) => `${fmt2(p.x, precision)} ${fmt2(p.y, precision)}`).join("L")}Z`;
1165
+ function vectorShadedSvgDefs(paint, id, options = {}) {
1166
+ const precision = options.precision ?? 3;
1167
+ const bounds = options.bounds ?? null;
1168
+ const area = options.area ?? (bounds ? { x: bounds.x - 1, y: bounds.y - 1, width: bounds.width + 2, height: bounds.height + 2 } : { x: 0, y: 0, width: 1, height: 1 });
1169
+ const tiles = [];
1170
+ const gradients = [];
1171
+ if (isVectorMeshGradient(paint)) {
1172
+ if (meshOk(paint)) {
1173
+ const k = Math.max(1, Math.min(32, Math.round(options.meshCells ?? 8)));
1174
+ for (let i = 0; i < paint.rows; i++) {
1175
+ for (let j = 0; j < paint.columns; j++) {
1176
+ const grid = [];
1177
+ for (let a = 0; a <= k; a++) {
1178
+ const row = [];
1179
+ for (let b = 0; b <= k; b++) row.push(vectorMeshPointAt(paint, i, j, b / k, a / k));
1180
+ grid.push(row);
1181
+ }
1182
+ for (let a = 0; a < k; a++) {
1183
+ for (let b = 0; b < k; b++) {
1184
+ const c = vectorMeshColorAt(paint, i, j, (b + 0.5) / k, (a + 0.5) / k);
1185
+ if (c[3] <= 5e-4) continue;
1186
+ const q = [grid[a][b], grid[a][b + 1], grid[a + 1][b + 1], grid[a + 1][b]];
1187
+ const cx = (q[0].x + q[1].x + q[2].x + q[3].x) / 4;
1188
+ const cy = (q[0].y + q[1].y + q[2].y + q[3].y) / 4;
1189
+ const grow = (p) => ({ x: cx + (p.x - cx) * 1.12, y: cy + (p.y - cy) * 1.12 });
1190
+ tiles.push({ d: quadD(q.map(grow), precision), fill: vectorRgbaToCss(c) });
1191
+ }
1192
+ }
1193
+ }
1194
+ }
1195
+ }
1196
+ } else if (bounds && paint.points.length) {
1197
+ const field = vectorFreeformField(paint, vectorFreeformSpreadScale(bounds));
1198
+ const n = Math.max(2, Math.min(256, Math.round(options.freeformCells ?? 96)));
1199
+ const side = Math.max(area.width, area.height, 1e-9);
1200
+ const rows = Math.max(2, Math.ceil(n * area.height / side));
1201
+ const samples = Math.max(2, Math.min(96, Math.ceil(n * area.width / side) + 1));
1202
+ const ch = area.height / rows;
1203
+ for (let r = 0; r < rows; r++) {
1204
+ const y = area.y + r * ch;
1205
+ const stops = [];
1206
+ for (let k = 0; k < samples; k++) {
1207
+ const t = k / (samples - 1);
1208
+ const c = sampleVectorFreeform(field, { x: area.x + t * area.width, y: y + ch / 2 });
1209
+ const opaque = vectorRgbaToCss([c[0], c[1], c[2], 1]);
1210
+ stops.push({ offset: `${fmt2(t * 100, 3)}%`, stopColor: opaque, ...c[3] < 0.9995 ? { stopOpacity: Math.round(Math.max(0, c[3]) * 1e3) / 1e3 } : {} });
1211
+ }
1212
+ const gid = `${id}-r${r}`;
1213
+ gradients.push({ id: gid, type: "linear", attrs: { gradientUnits: "userSpaceOnUse", x1: fmt2(area.x, precision), y1: "0", x2: fmt2(area.x + area.width, precision), y2: "0" }, stops });
1214
+ const h = r < rows - 1 ? ch * 1.25 : ch;
1215
+ tiles.push({ d: quadD([{ x: area.x, y }, { x: area.x + area.width, y }, { x: area.x + area.width, y: y + h }, { x: area.x, y: y + h }], precision), fill: `url(#${gid})` });
1216
+ }
1217
+ }
1218
+ return [{ id, type: "pattern", attrs: patternAttrs(area), gradients, tiles }];
1219
+ }
1220
+ var apply2 = (m, p) => ({ x: m[0] * p.x + m[2] * p.y + m[4], y: m[1] * p.x + m[3] * p.y + m[5] });
1221
+ function mapVectorShadedPaint(paint, f) {
1222
+ if (isVectorMeshGradient(paint)) return { ...paint, points: paint.points.map((p) => f(p)) };
1223
+ return { ...paint, points: paint.points.map((p) => ({ ...p, ...f(p) })) };
1224
+ }
1225
+ function transformVectorShadedPaint(paint, m) {
1226
+ return mapVectorShadedPaint(paint, (p) => apply2(m, p));
1227
+ }
1228
+ var finite = (v2) => typeof v2 === "number" && Number.isFinite(v2);
1229
+ var color = (v2) => typeof v2 === "string" && parseVectorColor(v2) ? v2 : null;
1230
+ function sanitizeVectorShadedPaint(input) {
1231
+ if (!input || typeof input !== "object") return null;
1232
+ const r = input;
1233
+ if (r.type === "mesh") {
1234
+ const rows = r.rows;
1235
+ const columns = r.columns;
1236
+ if (!finite(rows) || !finite(columns) || rows < 1 || columns < 1 || rows > VECTOR_MESH_MAX || columns > VECTOR_MESH_MAX || !Number.isInteger(rows) || !Number.isInteger(columns)) return null;
1237
+ const n = (rows + 1) * (columns + 1);
1238
+ if (!Array.isArray(r.points) || !Array.isArray(r.colors) || r.points.length !== n || r.colors.length !== n) return null;
1239
+ const points = [];
1240
+ for (const p of r.points) {
1241
+ const q = p;
1242
+ if (!q || !finite(q.x) || !finite(q.y)) return null;
1243
+ points.push({ x: q.x, y: q.y });
1244
+ }
1245
+ const colors = [];
1246
+ for (const c of r.colors) {
1247
+ const k = color(c);
1248
+ if (!k) return null;
1249
+ colors.push(k);
1250
+ }
1251
+ const out = { type: "mesh", rows, columns, points, colors };
1252
+ if (Array.isArray(r.opacities) && r.opacities.length === n && r.opacities.every(finite)) out.opacities = r.opacities.map((o) => Math.min(1, Math.max(0, o)));
1253
+ return out;
1254
+ }
1255
+ if (r.type === "freeform") {
1256
+ if (!Array.isArray(r.points) || !r.points.length) return null;
1257
+ const points = [];
1258
+ for (const p of r.points) {
1259
+ const q = p;
1260
+ const c = q ? color(q.color) : null;
1261
+ if (!q || !finite(q.x) || !finite(q.y) || !c) return null;
1262
+ points.push({
1263
+ x: q.x,
1264
+ y: q.y,
1265
+ color: c,
1266
+ ...finite(q.opacity) && q.opacity < 1 ? { opacity: Math.max(0, q.opacity) } : {},
1267
+ ...finite(q.spread) && q.spread > 0 ? { spread: Math.min(1, q.spread) } : {}
1268
+ });
1269
+ }
1270
+ const out = { type: "freeform", points };
1271
+ if (Array.isArray(r.lines)) {
1272
+ const lines = r.lines.filter((l) => Array.isArray(l) && l.length >= 2 && l.every((i) => Number.isInteger(i) && i >= 0 && i < points.length) && l.every((i, k) => k === 0 || i !== l[k - 1]));
1273
+ if (lines.length) out.lines = lines.map((l) => [...l]);
1274
+ }
1275
+ return out;
1276
+ }
1277
+ return null;
1278
+ }
1279
+ function removeVectorFreeformPoint(f, index) {
1280
+ if (index < 0 || index >= f.points.length || f.points.length <= 1) return null;
1281
+ const points = f.points.filter((_, k) => k !== index);
1282
+ const lines = (f.lines ?? []).map(
1283
+ (l) => l.filter((i) => i !== index).map((i) => i > index ? i - 1 : i).filter((i, k, arr) => k === 0 || i !== arr[k - 1])
1284
+ ).filter((l) => l.length >= 2);
1285
+ return { type: "freeform", points, ...lines.length ? { lines } : {} };
1286
+ }
1287
+ function nearestVectorShadingPoint(paint, p, radius) {
1288
+ let best = -1;
1289
+ let bestD = radius;
1290
+ paint.points.forEach((q, k) => {
1291
+ const d = Math.hypot(q.x - p.x, q.y - p.y);
1292
+ if (d <= bestD) {
1293
+ best = k;
1294
+ bestD = d;
1295
+ }
1296
+ });
1297
+ return best;
1298
+ }
1299
+
939
1300
  // src/geom/affine.ts
940
1301
  var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
941
1302
  function multiplyMatrices(a, b) {
@@ -1472,7 +1833,7 @@ var SAMPLES_PER_SUBPATH = 128;
1472
1833
  var MAX_DASHES = 5e3;
1473
1834
  var sub3 = (a, b) => [a[0] - b[0], a[1] - b[1]];
1474
1835
  var along = (p, v2, k) => [p[0] + v2[0] * k, p[1] + v2[1] * k];
1475
- var lerp = (a, b, u) => [a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u];
1836
+ var lerp2 = (a, b, u) => [a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u];
1476
1837
  var dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]);
1477
1838
  var unitOf = (v2) => {
1478
1839
  const l = Math.hypot(v2[0], v2[1]);
@@ -1507,7 +1868,7 @@ function flatten(segments, closed, tol) {
1507
1868
  for (let i = 1; i < pts.length; i++) {
1508
1869
  const n = Math.max(1, Math.ceil(dist(pts[i - 1], pts[i]) / step));
1509
1870
  for (let k = 1; k <= n; k++) {
1510
- fine.push(k === n ? pts[i] : lerp(pts[i - 1], pts[i], k / n));
1871
+ fine.push(k === n ? pts[i] : lerp2(pts[i - 1], pts[i], k / n));
1511
1872
  fineCorner.push(k === n ? corner[i] : false);
1512
1873
  }
1513
1874
  }
@@ -1544,7 +1905,7 @@ function at(poly, t) {
1544
1905
  const a = poly.s[i - 1];
1545
1906
  const b = poly.s[i];
1546
1907
  const u = b > a ? Math.min(Math.max((t - a) / (b - a), 0), 1) : 0;
1547
- return [lerp(poly.pts[i - 1], poly.pts[i], u), i];
1908
+ return [lerp2(poly.pts[i - 1], poly.pts[i], u), i];
1548
1909
  }
1549
1910
  function arcPoints(c, a0, sweep, r0, r1, tol) {
1550
1911
  const r = Math.max(r0, r1);
@@ -1742,7 +2103,7 @@ function nearestStrokePosition(path, p, only) {
1742
2103
  if (!best || near3.distance < best.distance) {
1743
2104
  const s = acc + segmentLength(seg, 0, near3.t);
1744
2105
  const tan = segmentTangent(seg, near3.t);
1745
- const pt2 = seg.length === 2 ? lerp(seg[0], seg[1], near3.t) : evalSeg(seg, near3.t);
2106
+ const pt2 = seg.length === 2 ? lerp2(seg[0], seg[1], near3.t) : evalSeg(seg, near3.t);
1746
2107
  const n = leftNormal([tan[0], tan[1]]);
1747
2108
  const side = (p[0] - pt2[0]) * n[0] + (p[1] - pt2[1]) * n[1] >= 0 ? "left" : "right";
1748
2109
  best = { contour: ci, t: Math.min(Math.max(s / total, 0), 1), distance: near3.distance, side, point: pt2, tangent: [tan[0], tan[1]], length: total };
@@ -1754,7 +2115,7 @@ function nearestStrokePosition(path, p, only) {
1754
2115
  }
1755
2116
  function evalSeg(seg, t) {
1756
2117
  let pts = seg.map((q) => [q[0], q[1]]);
1757
- while (pts.length > 1) pts = pts.slice(1).map((q, i) => lerp(pts[i], q, t));
2118
+ while (pts.length > 1) pts = pts.slice(1).map((q, i) => lerp2(pts[i], q, t));
1758
2119
  return pts[0];
1759
2120
  }
1760
2121
  function strokePositionPoint(path, index, t) {
@@ -2174,7 +2535,7 @@ function normalizeVectorPaintStacks(node, prefer = "shorthand") {
2174
2535
  function sanitizePaint(value) {
2175
2536
  if (value === null || value === void 0) return null;
2176
2537
  if (typeof value === "string") return value;
2177
- return sanitizeVectorGradient(value);
2538
+ return sanitizeVectorShadedPaint(value) ?? sanitizeVectorGradient(value);
2178
2539
  }
2179
2540
  function sanitizeLayerBase(raw) {
2180
2541
  const out = { paint: sanitizePaint(raw.paint) };
@@ -2292,22 +2653,22 @@ function withVectorTargetPaint(node, target, layer, paint) {
2292
2653
  var MAX_PIECES = 1 << 20;
2293
2654
  var MAX_DEPTH = 6;
2294
2655
  var PROBES = [0.25, 0.5, 0.75];
2295
- var lerp2 = (a, b, t) => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });
2656
+ var lerp3 = (a, b, t) => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });
2296
2657
  var dist2 = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
2297
2658
  var same = (a, b) => Math.abs(a.x - b.x) < 1e-9 && Math.abs(a.y - b.y) < 1e-9;
2298
2659
  function evalCubic(s, t) {
2299
- const ab = lerp2(s[0], s[1], t);
2300
- const bc = lerp2(s[1], s[2], t);
2301
- const cd = lerp2(s[2], s[3], t);
2302
- return lerp2(lerp2(ab, bc, t), lerp2(bc, cd, t), t);
2660
+ const ab = lerp3(s[0], s[1], t);
2661
+ const bc = lerp3(s[1], s[2], t);
2662
+ const cd = lerp3(s[2], s[3], t);
2663
+ return lerp3(lerp3(ab, bc, t), lerp3(bc, cd, t), t);
2303
2664
  }
2304
2665
  function halves(s) {
2305
- const ab = lerp2(s[0], s[1], 0.5);
2306
- const bc = lerp2(s[1], s[2], 0.5);
2307
- const cd = lerp2(s[2], s[3], 0.5);
2308
- const abc = lerp2(ab, bc, 0.5);
2309
- const bcd = lerp2(bc, cd, 0.5);
2310
- const m = lerp2(abc, bcd, 0.5);
2666
+ const ab = lerp3(s[0], s[1], 0.5);
2667
+ const bc = lerp3(s[1], s[2], 0.5);
2668
+ const cd = lerp3(s[2], s[3], 0.5);
2669
+ const abc = lerp3(ab, bc, 0.5);
2670
+ const bcd = lerp3(bc, cd, 0.5);
2671
+ const m = lerp3(abc, bcd, 0.5);
2311
2672
  return [
2312
2673
  [s[0], ab, abc, m],
2313
2674
  [m, bcd, cd, s[3]]
@@ -2369,8 +2730,8 @@ function mapSegment(seg, f, tol, depth, fit) {
2369
2730
  if (same(seg[1], seg[0]) && same(seg[2], seg[3])) {
2370
2731
  const a = f(seg[0]);
2371
2732
  const b = f(seg[3]);
2372
- if (PROBES.every((t) => offLine(f(lerp2(seg[0], seg[3], t)), a, b) <= tol)) return [[a, a, b, b]];
2373
- const line = [seg[0], lerp2(seg[0], seg[3], 1 / 3), lerp2(seg[0], seg[3], 2 / 3), seg[3]];
2733
+ if (PROBES.every((t) => offLine(f(lerp3(seg[0], seg[3], t)), a, b) <= tol)) return [[a, a, b, b]];
2734
+ const line = [seg[0], lerp3(seg[0], seg[3], 1 / 3), lerp3(seg[0], seg[3], 2 / 3), seg[3]];
2374
2735
  const out2 = [];
2375
2736
  splitMapped(line, f, tol, depth, out2);
2376
2737
  return fit ? refit(line, out2, f, tol) : out2;
@@ -2487,11 +2848,11 @@ function vectorFrameChildMatrix(resizing, box, from, to) {
2487
2848
  const sy = box.height > 1e-9 ? (y1 - y0) / box.height : 1;
2488
2849
  return [sx, 0, 0, sy, x0 - sx * box.x, y0 - sy * box.y];
2489
2850
  }
2490
- var finite = (v2) => typeof v2 === "number" && Number.isFinite(v2);
2851
+ var finite2 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
2491
2852
  function sanitizeVectorFrame(value) {
2492
2853
  if (!value || typeof value !== "object") return null;
2493
2854
  const r = value;
2494
- if (!finite(r.x) || !finite(r.y) || !finite(r.width) || !finite(r.height) || r.width < 0 || r.height < 0) return null;
2855
+ if (!finite2(r.x) || !finite2(r.y) || !finite2(r.width) || !finite2(r.height) || r.width < 0 || r.height < 0) return null;
2495
2856
  const out = { x: r.x, y: r.y, width: r.width, height: r.height };
2496
2857
  if (typeof r.fill === "string" || r.fill && typeof r.fill === "object") out.fill = r.fill;
2497
2858
  if (r.clip === false) out.clip = false;
@@ -4621,14 +4982,14 @@ function bezierToSubpathsLite(path) {
4621
4982
  }
4622
4983
  return out.filter((sp) => sp.anchors.length);
4623
4984
  }
4624
- var fmt2 = (n) => Math.round(n * 1e3) / 1e3;
4985
+ var fmt3 = (n) => Math.round(n * 1e3) / 1e3;
4625
4986
  function vectorTextSpanSvg(sp, fill) {
4626
- const list = (v2) => v2.map(fmt2).join(" ");
4987
+ const list = (v2) => v2.map(fmt3).join(" ");
4627
4988
  const deco = [sp.style.underline ? "underline" : "", sp.style.strikethrough ? "line-through" : ""].filter(Boolean).join(" ");
4628
4989
  return {
4629
4990
  text: sp.text,
4630
4991
  x: list(sp.x),
4631
- y: sp.y.every((v2) => v2 === sp.y[0]) ? String(fmt2(sp.y[0])) : list(sp.y),
4992
+ y: sp.y.every((v2) => v2 === sp.y[0]) ? String(fmt3(sp.y[0])) : list(sp.y),
4632
4993
  ...sp.rotate ? { rotate: list(sp.rotate) } : {},
4633
4994
  fontFamily: cssFontFamily(sp.family),
4634
4995
  fontSize: sp.style.fontSize,
@@ -6417,13 +6778,13 @@ function vectorConnectorTargetAt(nodes, p, radius, exclude) {
6417
6778
  var SHARP = 1.25;
6418
6779
  var TOLERANCE = 0.2;
6419
6780
  var OVERLAP = 0.5;
6420
- var fmt3 = (n, digits = 3) => {
6781
+ var fmt4 = (n, digits = 3) => {
6421
6782
  const k = 10 ** digits;
6422
6783
  const v2 = Math.round(n * k) / k;
6423
6784
  return Object.is(v2, -0) ? "0" : String(v2);
6424
6785
  };
6425
- var toSvgStops2 = (stops) => stops.map((s) => ({ offset: `${fmt3(s.offset * 100)}%`, stopColor: s.color, ...s.opacity !== void 0 && s.opacity !== 1 ? { stopOpacity: Math.round(s.opacity * 1e4) / 1e4 } : {} }));
6426
- var polygonD2 = (pts, precision) => `M${pts.map((p) => `${fmt3(p.x, precision)} ${fmt3(p.y, precision)}`).join("L")}Z`;
6786
+ var toSvgStops2 = (stops) => stops.map((s) => ({ offset: `${fmt4(s.offset * 100)}%`, stopColor: s.color, ...s.opacity !== void 0 && s.opacity !== 1 ? { stopOpacity: Math.round(s.opacity * 1e4) / 1e4 } : {} }));
6787
+ var polygonD2 = (pts, precision) => `M${pts.map((p) => `${fmt4(p.x, precision)} ${fmt4(p.y, precision)}`).join("L")}Z`;
6427
6788
  var add4 = (a, b) => ({ x: a.x + b.x, y: a.y + b.y });
6428
6789
  var sub4 = (a, b) => ({ x: a.x - b.x, y: a.y - b.y });
6429
6790
  var scale2 = (a, k) => ({ x: a.x * k, y: a.y * k });
@@ -6542,7 +6903,7 @@ function vectorStrokeGradientDefs(g, id, node, options = {}) {
6542
6903
  gradients.push({
6543
6904
  id: gid,
6544
6905
  type: "linear",
6545
- attrs: { gradientUnits: "userSpaceOnUse", x1: fmt3(a.x, 4), y1: fmt3(a.y, 4), x2: fmt3(b.x, 4), y2: fmt3(b.y, 4) },
6906
+ attrs: { gradientUnits: "userSpaceOnUse", x1: fmt4(a.x, 4), y1: fmt4(a.y, 4), x2: fmt4(b.x, 4), y2: fmt4(b.y, 4) },
6546
6907
  stops: toSvgStops2(spanVectorGradientStops(g, t0, t1, expanded))
6547
6908
  });
6548
6909
  } else {
@@ -6556,7 +6917,7 @@ function vectorStrokeGradientDefs(g, id, node, options = {}) {
6556
6917
  gradients.push({
6557
6918
  id: gid,
6558
6919
  type: "linear",
6559
- attrs: { gradientUnits: "userSpaceOnUse", x1: fmt3(p0.x, 4), y1: fmt3(p0.y, 4), x2: fmt3(p1.x, 4), y2: fmt3(p1.y, 4) },
6920
+ attrs: { gradientUnits: "userSpaceOnUse", x1: fmt4(p0.x, 4), y1: fmt4(p0.y, 4), x2: fmt4(p1.x, 4), y2: fmt4(p1.y, 4) },
6560
6921
  stops: toSvgStops2(expanded)
6561
6922
  });
6562
6923
  }
@@ -6615,6 +6976,20 @@ var paintCache = /* @__PURE__ */ new WeakMap();
6615
6976
  function vectorPaintToSvg(paint, gradientId, options = {}) {
6616
6977
  if (!hasPaint(paint)) return { value: "none", defs: [] };
6617
6978
  if (typeof paint === "string") return { value: paint, defs: [] };
6979
+ if (isVectorShadedPaint(paint)) {
6980
+ const node2 = options.node;
6981
+ const bounds2 = node2 ? vectorPathLocalBounds(node2) : null;
6982
+ const reach2 = node2 && options.role === "stroke" ? vectorStrokeReach(node2) + 1 : 1;
6983
+ const area2 = bounds2 ? { x: bounds2.x - reach2, y: bounds2.y - reach2, width: bounds2.width + 2 * reach2, height: bounds2.height + 2 * reach2 } : null;
6984
+ const key2 = `${gradientId}|${options.role ?? "fill"}|${options.precision ?? 3}|${area2 ? [area2.x, area2.y, area2.width, area2.height].join(",") : ""}`;
6985
+ let byKey2 = paintCache.get(paint);
6986
+ const hit = byKey2?.get(key2);
6987
+ if (hit) return { value: `url(#${gradientId})`, defs: hit };
6988
+ const defs2 = vectorShadedSvgDefs(paint, gradientId, { bounds: bounds2, area: area2, precision: options.precision ?? 3 });
6989
+ if (!byKey2) paintCache.set(paint, byKey2 = /* @__PURE__ */ new Map());
6990
+ byKey2.set(key2, defs2);
6991
+ return { value: `url(#${gradientId})`, defs: defs2 };
6992
+ }
6618
6993
  if (!isVectorGradient(paint)) return { value: "none", defs: [] };
6619
6994
  const role = options.role ?? "fill";
6620
6995
  const precision = options.precision ?? 3;
@@ -6754,6 +7129,7 @@ function vectorDocumentToSvg(doc, options = {}) {
6754
7129
  if (node.type === "group" && node.blend) out2 += ` data-vector-blend="${escapeAttr2(JSON.stringify(node.blend))}"`;
6755
7130
  if (node.booleanOperation) out2 += ` data-vector-boolean-operation="${node.booleanOperation}"`;
6756
7131
  if (node.resizing) out2 += ` data-vector-resizing="${escapeAttr2(JSON.stringify(node.resizing))}"`;
7132
+ if (node.type === "path" && isVectorShadedPaint(node.fill)) out2 += ` data-vector-shading="${escapeAttr2(JSON.stringify(node.fill))}"`;
6757
7133
  if (node.type === "path" && node.connector) out2 += ` data-vector-connector="${escapeAttr2(JSON.stringify(node.connector))}"`;
6758
7134
  const blend = vectorBlendModeCss(node.blendMode);
6759
7135
  if (blend) out2 += ` style="mix-blend-mode:${blend}"`;
@@ -7917,7 +8293,7 @@ function parseVectorSvg(svg, options = {}) {
7917
8293
  type: "path",
7918
8294
  ...meta,
7919
8295
  subpaths,
7920
- fill: child.name === "line" ? null : paint(s.fill),
8296
+ fill: child.name === "line" ? null : sanitizeVectorShadedPaint(parseJson(child.attrs["data-vector-shading"])) ?? paint(s.fill),
7921
8297
  stroke: paint(s.stroke),
7922
8298
  ...strokeStyle(s)
7923
8299
  },
@@ -8366,15 +8742,15 @@ function bakeIntoGeometry(node, m) {
8366
8742
  const mirrored = flips && path.strokeWidthProfile?.length;
8367
8743
  const layer = (l) => ({
8368
8744
  ...l,
8369
- ...isVectorGradient(l.paint) ? { paint: transformVectorPaint(l.paint, m) } : {},
8745
+ ...isVectorGradient(l.paint) || isVectorShadedPaint(l.paint) ? { paint: transformVectorPaint(l.paint, m) } : {},
8370
8746
  ...flips && l.strokeWidthProfile?.length ? { strokeWidthProfile: mirrorWidthProfile(l.strokeWidthProfile) } : {}
8371
8747
  });
8372
8748
  return {
8373
8749
  ...path,
8374
8750
  ...mirrored ? { strokeWidthProfile: mirrorWidthProfile(path.strokeWidthProfile) } : {},
8375
8751
  // Gradients in the node's own space move with its geometry.
8376
- ...isVectorGradient(path.fill) ? { fill: transformVectorPaint(path.fill, m) } : {},
8377
- ...isVectorGradient(path.stroke) ? { stroke: transformVectorPaint(path.stroke, m) } : {},
8752
+ ...isVectorGradient(path.fill) || isVectorShadedPaint(path.fill) ? { fill: transformVectorPaint(path.fill, m) } : {},
8753
+ ...isVectorGradient(path.stroke) || isVectorShadedPaint(path.stroke) ? { stroke: transformVectorPaint(path.stroke, m) } : {},
8378
8754
  ...Array.isArray(path.fills) ? { fills: path.fills.map(layer) } : {},
8379
8755
  ...Array.isArray(path.strokes) ? { strokes: path.strokes.map(layer) } : {},
8380
8756
  ...path.type === "path" ? {
@@ -8975,6 +9351,26 @@ function pathsCenter(paths) {
8975
9351
  }
8976
9352
 
8977
9353
  export {
9354
+ isVectorMeshGradient,
9355
+ isVectorFreeformGradient,
9356
+ isVectorShadedPaint,
9357
+ vectorRgbaToCss,
9358
+ VECTOR_MESH_MAX,
9359
+ createVectorMeshGradient,
9360
+ vectorMeshPointAt,
9361
+ vectorMeshColorAt,
9362
+ vectorMeshLines,
9363
+ vectorFreeformSpreadScale,
9364
+ vectorFreeformLineSegments,
9365
+ vectorFreeformField,
9366
+ sampleVectorFreeform,
9367
+ autoVectorFreeformGradient,
9368
+ vectorShadedSvgDefs,
9369
+ mapVectorShadedPaint,
9370
+ transformVectorShadedPaint,
9371
+ sanitizeVectorShadedPaint,
9372
+ removeVectorFreeformPoint,
9373
+ nearestVectorShadingPoint,
8978
9374
  VECTOR_CORNER_KINDS,
8979
9375
  VECTOR_GRADIENT_TYPES,
8980
9376
  VECTOR_GRADIENT_SPREADS,
@@ -9398,4 +9794,4 @@ export {
9398
9794
  lineSubpath,
9399
9795
  roundSubpaths
9400
9796
  };
9401
- //# sourceMappingURL=chunk-VXR7XWMF.js.map
9797
+ //# sourceMappingURL=chunk-7LNZAWSJ.js.map