@pixerate/editor 0.112.0 → 0.114.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 (129) hide show
  1. package/THIRD_PARTY_NOTICES.md +11 -0
  2. package/dist/animation-editor/index.cjs +60 -54
  3. package/dist/animation-editor/index.cjs.map +1 -1
  4. package/dist/animation-editor/index.d.cts +3 -3
  5. package/dist/animation-editor/index.d.ts +3 -3
  6. package/dist/animation-editor/index.js +14 -8
  7. package/dist/animation-editor/index.js.map +1 -1
  8. package/dist/builtin-CY97ppKM.d.cts +354 -0
  9. package/dist/builtin-CY97ppKM.d.ts +354 -0
  10. package/dist/canvas/index.cjs +3 -3
  11. package/dist/canvas/index.cjs.map +1 -1
  12. package/dist/canvas/index.js +9 -9
  13. package/dist/chunk-26PGXHY7.cjs +753 -0
  14. package/dist/chunk-26PGXHY7.cjs.map +1 -0
  15. package/dist/chunk-2OJACTPR.cjs +929 -0
  16. package/dist/chunk-2OJACTPR.cjs.map +1 -0
  17. package/dist/chunk-3UFGNHSP.js +929 -0
  18. package/dist/chunk-3UFGNHSP.js.map +1 -0
  19. package/dist/{chunk-YGIMK4NX.cjs → chunk-5OVJHMZQ.cjs} +757 -825
  20. package/dist/chunk-5OVJHMZQ.cjs.map +1 -0
  21. package/dist/chunk-643B2HKC.cjs +534 -0
  22. package/dist/chunk-643B2HKC.cjs.map +1 -0
  23. package/dist/chunk-6FCKOS2B.js +534 -0
  24. package/dist/chunk-6FCKOS2B.js.map +1 -0
  25. package/dist/chunk-BRLYOPLT.js +2574 -0
  26. package/dist/chunk-BRLYOPLT.js.map +1 -0
  27. package/dist/{chunk-LQEEDHOP.js → chunk-C6C5PDKU.js} +759 -761
  28. package/dist/chunk-C6C5PDKU.js.map +1 -0
  29. package/dist/chunk-DFQEX3AM.cjs +781 -0
  30. package/dist/chunk-DFQEX3AM.cjs.map +1 -0
  31. package/dist/{chunk-CZOXTEMN.js → chunk-EUVSQ25B.js} +336 -404
  32. package/dist/chunk-EUVSQ25B.js.map +1 -0
  33. package/dist/chunk-G5NMLUVF.cjs +2574 -0
  34. package/dist/chunk-G5NMLUVF.cjs.map +1 -0
  35. package/dist/chunk-LKCYANMW.js +781 -0
  36. package/dist/chunk-LKCYANMW.js.map +1 -0
  37. package/dist/{chunk-W3GXSUSQ.cjs → chunk-LPLCWZTM.cjs} +5087 -1283
  38. package/dist/chunk-LPLCWZTM.cjs.map +1 -0
  39. package/dist/chunk-MMVHBKMM.js +753 -0
  40. package/dist/chunk-MMVHBKMM.js.map +1 -0
  41. package/dist/{chunk-POGBUYWE.cjs → chunk-ST7E3NEE.cjs} +857 -859
  42. package/dist/chunk-ST7E3NEE.cjs.map +1 -0
  43. package/dist/{chunk-7VOHOPLW.cjs → chunk-TCKIXI46.cjs} +59 -59
  44. package/dist/{chunk-7VOHOPLW.cjs.map → chunk-TCKIXI46.cjs.map} +1 -1
  45. package/dist/{chunk-XIOMMGPD.cjs → chunk-TFOPHZ3U.cjs} +1 -1
  46. package/dist/chunk-TFOPHZ3U.cjs.map +1 -0
  47. package/dist/{chunk-Z4BC6M74.js → chunk-UBIXVXPR.js} +2 -2
  48. package/dist/{chunk-BLWCAQCW.js → chunk-VXR7XWMF.js} +4574 -770
  49. package/dist/chunk-VXR7XWMF.js.map +1 -0
  50. package/dist/{chunk-HNS7UHCM.js → chunk-XK5LZKBD.js} +1 -1
  51. package/dist/chunk-XK5LZKBD.js.map +1 -0
  52. package/dist/cms/index.cjs +146 -0
  53. package/dist/cms/index.cjs.map +1 -0
  54. package/dist/cms/index.d.cts +51 -0
  55. package/dist/cms/index.d.ts +51 -0
  56. package/dist/cms/index.js +146 -0
  57. package/dist/{export-DNu_Jr8p.d.ts → export-_1dUKwpF.d.ts} +326 -195
  58. package/dist/{export-DBba-buV.d.cts → export-b6NjCZ5-.d.cts} +326 -195
  59. package/dist/image-editor/index.cjs +2377 -1291
  60. package/dist/image-editor/index.cjs.map +1 -1
  61. package/dist/image-editor/index.d.cts +149 -97
  62. package/dist/image-editor/index.d.ts +149 -97
  63. package/dist/image-editor/index.js +1343 -257
  64. package/dist/image-editor/index.js.map +1 -1
  65. package/dist/opentype-BZEOSOX3.d.ts +188 -0
  66. package/dist/opentype-Dpe75vL5.d.cts +188 -0
  67. package/dist/paint/index.cjs +63 -4
  68. package/dist/paint/index.cjs.map +1 -1
  69. package/dist/paint/index.d.cts +30 -3
  70. package/dist/paint/index.d.ts +30 -3
  71. package/dist/paint/index.js +62 -3
  72. package/dist/paint-editor/index.cjs +146 -145
  73. package/dist/paint-editor/index.cjs.map +1 -1
  74. package/dist/paint-editor/index.d.cts +9 -8
  75. package/dist/paint-editor/index.d.ts +9 -8
  76. package/dist/paint-editor/index.js +6 -5
  77. package/dist/paint-editor/index.js.map +1 -1
  78. package/dist/raster/index.cjs +53 -3
  79. package/dist/raster/index.cjs.map +1 -1
  80. package/dist/raster/index.d.cts +62 -91
  81. package/dist/raster/index.d.ts +62 -91
  82. package/dist/raster/index.js +59 -9
  83. package/dist/{render-BEriFuqK.d.cts → render-B1K_OoLy.d.cts} +87 -2
  84. package/dist/{render-tjzKaik-.d.ts → render-CrmHOgpo.d.ts} +87 -2
  85. package/dist/{blending-aOE6Y3UE.d.cts → retouch-Bxkuc0KH.d.cts} +219 -2
  86. package/dist/{blending-DXl06NSx.d.ts → retouch-Do6tBs2H.d.ts} +219 -2
  87. package/dist/{surface-C8RRg_Bh.d.ts → surface-Cn30xIV6.d.cts} +6 -1
  88. package/dist/{surface-C8RRg_Bh.d.cts → surface-Cn30xIV6.d.ts} +6 -1
  89. package/dist/{svg-D_cfkhlB.d.cts → svg-BnRj0q8i.d.cts} +16 -4
  90. package/dist/{svg-wIaKLrU0.d.ts → svg-CmmBFfGT.d.ts} +16 -4
  91. package/dist/{types-DtL_qLFz.d.ts → types-1SUQKDAw.d.ts} +273 -4
  92. package/dist/{types-DyQq-WPY.d.cts → types-yINF17Ta.d.cts} +273 -4
  93. package/dist/vector/index.cjs +12170 -7343
  94. package/dist/vector/index.cjs.map +1 -1
  95. package/dist/vector/index.d.cts +1579 -16
  96. package/dist/vector/index.d.ts +1579 -16
  97. package/dist/vector/index.js +6303 -1476
  98. package/dist/vector/index.js.map +1 -1
  99. package/dist/warp-B39VsOtd.d.cts +348 -0
  100. package/dist/warp-DMN30aY6.d.ts +348 -0
  101. package/dist/zlib-dxQdgHyN.d.cts +95 -0
  102. package/dist/zlib-dxQdgHyN.d.ts +95 -0
  103. package/package.json +6 -1
  104. package/skills/pixerate-image-editor/SKILL.md +34 -34
  105. package/skills/pixerate-image-editor/references/color-management.md +37 -0
  106. package/skills/pixerate-image-editor/references/photoshop-files.md +39 -0
  107. package/skills/pixerate-image-editor/references/retouching.md +36 -0
  108. package/skills/pixerate-vector/SKILL.md +154 -5
  109. package/dist/chunk-BLWCAQCW.js.map +0 -1
  110. package/dist/chunk-CZOXTEMN.js.map +0 -1
  111. package/dist/chunk-FTBZPI77.cjs +0 -1
  112. package/dist/chunk-FTBZPI77.cjs.map +0 -1
  113. package/dist/chunk-HNS7UHCM.js.map +0 -1
  114. package/dist/chunk-JLYX4V57.cjs +0 -2001
  115. package/dist/chunk-JLYX4V57.cjs.map +0 -1
  116. package/dist/chunk-KB2YBCVS.js +0 -2001
  117. package/dist/chunk-KB2YBCVS.js.map +0 -1
  118. package/dist/chunk-LQEEDHOP.js.map +0 -1
  119. package/dist/chunk-POGBUYWE.cjs.map +0 -1
  120. package/dist/chunk-VKK5VS2T.js +0 -1
  121. package/dist/chunk-W3GXSUSQ.cjs.map +0 -1
  122. package/dist/chunk-XIOMMGPD.cjs.map +0 -1
  123. package/dist/chunk-YGIMK4NX.cjs.map +0 -1
  124. package/dist/homography-CZ-tFjay.d.cts +0 -50
  125. package/dist/homography-Ctfjoc1b.d.ts +0 -50
  126. package/dist/warp-CWHZzE3x.d.ts +0 -118
  127. package/dist/warp-D5jz_tN7.d.cts +0 -118
  128. /package/dist/{chunk-Z4BC6M74.js.map → chunk-UBIXVXPR.js.map} +0 -0
  129. /package/dist/{chunk-VKK5VS2T.js.map → cms/index.js.map} +0 -0
@@ -41,7 +41,10 @@
41
41
 
42
42
 
43
43
 
44
- var _chunkPOGBUYWEcjs = require('./chunk-POGBUYWE.cjs');
44
+
45
+
46
+
47
+ var _chunkST7E3NEEcjs = require('./chunk-ST7E3NEE.cjs');
45
48
 
46
49
 
47
50
 
@@ -68,7 +71,18 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
68
71
 
69
72
 
70
73
 
71
- var _chunkXIOMMGPDcjs = require('./chunk-XIOMMGPD.cjs');
74
+ var _chunkTFOPHZ3Ucjs = require('./chunk-TFOPHZ3U.cjs');
75
+
76
+
77
+
78
+
79
+ var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
80
+
81
+
82
+
83
+
84
+
85
+
72
86
 
73
87
 
74
88
 
@@ -93,7 +107,12 @@ var _chunkXIOMMGPDcjs = require('./chunk-XIOMMGPD.cjs');
93
107
 
94
108
 
95
109
 
96
- var _chunkW3GXSUSQcjs = require('./chunk-W3GXSUSQ.cjs');
110
+
111
+
112
+
113
+
114
+
115
+ var _chunkLPLCWZTMcjs = require('./chunk-LPLCWZTM.cjs');
97
116
 
98
117
 
99
118
 
@@ -1112,7 +1131,7 @@ function smoothCoverage(m, w, h, r) {
1112
1131
  return src;
1113
1132
  }
1114
1133
  function featherCoverage(m, w, h, radius) {
1115
- const out = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1134
+ const out = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1116
1135
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1117
1136
  return out;
1118
1137
  }
@@ -1260,7 +1279,7 @@ function layerMaskCoverage(mask) {
1260
1279
  let v = new Float32Array(sel.data.length);
1261
1280
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1262
1281
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1263
- if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1282
+ if (feather > 0) v = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1264
1283
  const density = _nullishCoalesce(mask.density, () => ( 1));
1265
1284
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1266
1285
  return v;
@@ -1481,7 +1500,7 @@ function normalizeAdjustmentLayer(raw) {
1481
1500
  kind: r.kind,
1482
1501
  enabled: r.enabled !== false,
1483
1502
  opacity: clampTo(r.opacity, 0, 1, 1),
1484
- blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend),
1503
+ blend: _chunkTFOPHZ3Ucjs.normalizeBlendMode.call(void 0, r.blend),
1485
1504
  params: normParams(r.kind, r.params)
1486
1505
  };
1487
1506
  if (typeof r.name === "string" && r.name) layer.name = r.name;
@@ -1503,7 +1522,7 @@ function normalizeAdjustmentLayers(raw) {
1503
1522
  return out;
1504
1523
  }
1505
1524
  function curveLutFromLevels(points) {
1506
- return _chunkPOGBUYWEcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1525
+ return _chunkST7E3NEEcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1507
1526
  }
1508
1527
  var toUnitLevels = (c) => ({
1509
1528
  inBlack: c.inBlack / 255,
@@ -1742,7 +1761,7 @@ function lutOp(luts) {
1742
1761
  var isIdentityCurve = (pts) => pts.length === 2 && pts[0].input === 0 && pts[0].output === 0 && pts[1].input === 255 && pts[1].output === 255;
1743
1762
  var isIdentityLevels = (c) => c.inBlack === 0 && c.inWhite === 255 && c.gamma === 1 && c.outBlack === 0 && c.outWhite === 255;
1744
1763
  var LEVELS_QUANTUM = 255;
1745
- function toneLuts(layer) {
1764
+ function toneLuts(layer, quantum = LEVELS_QUANTUM) {
1746
1765
  const n = ADJUSTMENT_LUT_SIZE;
1747
1766
  if (layer.kind === "curves") {
1748
1767
  const m = curveLutFromLevels(layer.params.master);
@@ -1757,13 +1776,14 @@ function toneLuts(layer) {
1757
1776
  return [layer.params.red, layer.params.green, layer.params.blue].map((rec) => {
1758
1777
  const c = toUnitLevels(rec);
1759
1778
  const out = new Float32Array(n);
1760
- for (let k = 0; k < n; k++) out[k] = levelsValue(m, levelsValue(c, k / (n - 1), LEVELS_QUANTUM), LEVELS_QUANTUM);
1779
+ const q2 = _nullishCoalesce(quantum, () => ( void 0));
1780
+ for (let k = 0; k < n; k++) out[k] = levelsValue(m, levelsValue(c, k / (n - 1), q2), q2);
1761
1781
  return out;
1762
1782
  });
1763
1783
  }
1764
1784
  return null;
1765
1785
  }
1766
- function compileAdjustmentLayer(layer) {
1786
+ function compileAdjustmentLayer(layer, options = {}) {
1767
1787
  switch (layer.kind) {
1768
1788
  case "curves": {
1769
1789
  const p = layer.params;
@@ -1773,7 +1793,7 @@ function compileAdjustmentLayer(layer) {
1773
1793
  case "levels": {
1774
1794
  const p = layer.params;
1775
1795
  if ([p.master, p.red, p.green, p.blue].every(isIdentityLevels)) return null;
1776
- return lutOp(toneLuts(layer));
1796
+ return lutOp(toneLuts(layer, options.deep ? null : LEVELS_QUANTUM));
1777
1797
  }
1778
1798
  case "hueSaturation": {
1779
1799
  const p = layer.params;
@@ -1826,7 +1846,7 @@ function compileAdjustmentLayer(layer) {
1826
1846
  return (c) => {
1827
1847
  const g = blackWhiteGray(c, weights);
1828
1848
  if (tint) {
1829
- const t = _chunkXIOMMGPDcjs.setLum.call(void 0, tint, g);
1849
+ const t = _chunkTFOPHZ3Ucjs.setLum.call(void 0, tint, g);
1830
1850
  c[0] = clamp01(t[0]);
1831
1851
  c[1] = clamp01(t[1]);
1832
1852
  c[2] = clamp01(t[2]);
@@ -1845,7 +1865,7 @@ function compileAdjustmentLayer(layer) {
1845
1865
  let f = [0, 1, 2].map((r) => linearToSrgb(Math.max(0, m[r][0] * l[0] + m[r][1] * l[1] + m[r][2] * l[2])));
1846
1866
  if (preserve) {
1847
1867
  const target = 0.3 * c[0] + 0.59 * c[1] + 0.11 * c[2];
1848
- f = _chunkXIOMMGPDcjs.setLum.call(void 0, f, target);
1868
+ f = _chunkTFOPHZ3Ucjs.setLum.call(void 0, f, target);
1849
1869
  }
1850
1870
  c[0] = clamp01(f[0]);
1851
1871
  c[1] = clamp01(f[1]);
@@ -1878,15 +1898,15 @@ function compileAdjustmentLayer(layer) {
1878
1898
  }
1879
1899
  var COMPILE_CACHE_LIMIT = 64;
1880
1900
  var compileCache = /* @__PURE__ */ new Map();
1881
- function compiledFor(layer) {
1882
- const key = `${layer.kind}:${JSON.stringify(layer.params)}`;
1901
+ function compiledFor(layer, deep = false) {
1902
+ const key = `${deep ? "deep:" : ""}${layer.kind}:${JSON.stringify(layer.params)}`;
1883
1903
  if (compileCache.has(key)) {
1884
1904
  const op2 = compileCache.get(key);
1885
1905
  compileCache.delete(key);
1886
1906
  compileCache.set(key, op2);
1887
1907
  return op2;
1888
1908
  }
1889
- const op = compileAdjustmentLayer(layer);
1909
+ const op = compileAdjustmentLayer(layer, { deep });
1890
1910
  compileCache.set(key, op);
1891
1911
  if (compileCache.size > COMPILE_CACHE_LIMIT) compileCache.delete(compileCache.keys().next().value);
1892
1912
  return op;
@@ -1912,10 +1932,10 @@ function applyLayer(c, layer, op, coverage = 1) {
1912
1932
  const cb0 = c[0], cb1 = c[1], cb2 = c[2];
1913
1933
  op(c);
1914
1934
  if (blend === "pigment") {
1915
- _chunkXIOMMGPDcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
1935
+ _chunkTFOPHZ3Ucjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
1916
1936
  return;
1917
1937
  }
1918
- const b = blend === "normal" ? c : _chunkXIOMMGPDcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
1938
+ const b = blend === "normal" ? c : _chunkTFOPHZ3Ucjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
1919
1939
  c[0] = (1 - alpha) * cb0 + alpha * b[0];
1920
1940
  c[1] = (1 - alpha) * cb1 + alpha * b[1];
1921
1941
  c[2] = (1 - alpha) * cb2 + alpha * b[2];
@@ -1947,8 +1967,31 @@ function applyAdjustmentLayers(imageData, layers, masks) {
1947
1967
  data[i + 2] = Math.round(clamp01(c[2]) * 255);
1948
1968
  }
1949
1969
  }
1970
+ function applyAdjustmentLayersFloat(data, layers, masks) {
1971
+ const active = activeAdjustmentLayers(layers);
1972
+ if (!active.length) return;
1973
+ const ops = active.map((l) => compiledFor(l, true));
1974
+ const planes = active.map((l) => _optionalChain([masks, 'optionalAccess', _7 => _7.get, 'call', _8 => _8(l.id)]));
1975
+ const c = [0, 0, 0];
1976
+ for (let i = 0; i < data.length; i += 4) {
1977
+ if (!(data[i + 3] > 0)) continue;
1978
+ c[0] = data[i];
1979
+ c[1] = data[i + 1];
1980
+ c[2] = data[i + 2];
1981
+ for (let k = 0; k < active.length; k++) {
1982
+ const plane = planes[k];
1983
+ if (plane) {
1984
+ const cov = plane[i >> 2];
1985
+ if (cov > 0) applyLayer(c, active[k], ops[k], cov >= 1 ? 1 : cov);
1986
+ } else applyLayer(c, active[k], ops[k]);
1987
+ }
1988
+ data[i] = c[0];
1989
+ data[i + 1] = c[1];
1990
+ data[i + 2] = c[2];
1991
+ }
1992
+ }
1950
1993
  function adjustmentLayersKey(layers) {
1951
- if (!_optionalChain([layers, 'optionalAccess', _7 => _7.length])) return "";
1994
+ if (!_optionalChain([layers, 'optionalAccess', _9 => _9.length])) return "";
1952
1995
  return JSON.stringify(
1953
1996
  layers.map((l) => {
1954
1997
  const key = [l.kind, l.enabled !== false, _nullishCoalesce(l.opacity, () => ( 1)), _nullishCoalesce(l.blend, () => ( "normal")), l.params];
@@ -2222,22 +2265,24 @@ function removeAlpha(imageData) {
2222
2265
  }
2223
2266
  }
2224
2267
 
2268
+ // src/text/types.ts
2269
+ var TEXT_ALIGNS = ["left", "center", "right", "justify"];
2270
+
2225
2271
  // src/image-editor/layers/model.ts
2226
2272
  var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
2227
2273
  var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
2228
- var TEXT_ALIGNS = ["left", "center", "right", "justify"];
2229
2274
  var idCounter = 0;
2230
2275
  function newLayerId(prefix = "layer") {
2231
2276
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2232
2277
  }
2233
2278
  function pixelLayers(layers) {
2234
- return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2279
+ return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2235
2280
  }
2236
2281
  function developFilter(layer) {
2237
- return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
2282
+ return _optionalChain([layer, 'access', _10 => _10.filters, 'optionalAccess', _11 => _11.find, 'call', _12 => _12((f) => f.kind === "develop")]);
2238
2283
  }
2239
2284
  function blurFilter(layer) {
2240
- return _optionalChain([layer, 'access', _11 => _11.filters, 'optionalAccess', _12 => _12.find, 'call', _13 => _13((f) => f.kind === "blur")]);
2285
+ return _optionalChain([layer, 'access', _13 => _13.filters, 'optionalAccess', _14 => _14.find, 'call', _15 => _15((f) => f.kind === "blur")]);
2241
2286
  }
2242
2287
  function isActiveFilter(f) {
2243
2288
  if (!f.enabled) return false;
@@ -2262,10 +2307,10 @@ function isRenderedLayer(layer) {
2262
2307
  return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2263
2308
  }
2264
2309
  function shapeLayers(layers) {
2265
- return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2310
+ return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2266
2311
  }
2267
2312
  function smartObjectLayers(layers) {
2268
- return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2313
+ return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2269
2314
  }
2270
2315
 
2271
2316
  // src/image-editor/layers/compositor.ts
@@ -2331,7 +2376,7 @@ function runLayerFilters(data, width, height, filters) {
2331
2376
  var filterSpecCache = /* @__PURE__ */ new WeakMap();
2332
2377
  function pixelFilterSpec(layer) {
2333
2378
  const list2 = layer.filters;
2334
- if (!_optionalChain([list2, 'optionalAccess', _14 => _14.length])) return null;
2379
+ if (!_optionalChain([list2, 'optionalAccess', _16 => _16.length])) return null;
2335
2380
  if (filterSpecCache.has(list2)) return filterSpecCache.get(list2);
2336
2381
  const filters = list2.filter(isActiveFilter);
2337
2382
  let spec = null;
@@ -2352,7 +2397,7 @@ var PHOTO_PROFILE = {
2352
2397
  const views = layers.map(adjustmentNodeAsLayer);
2353
2398
  applyAdjustmentLayers({ data: acc }, views, masks);
2354
2399
  },
2355
- contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _15 => _15.rasterizeAnnotation, 'optionalCall', _16 => _16(l.annotation, r)]), () => ( null)) : null,
2400
+ contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.rasterizeAnnotation, 'optionalCall', _18 => _18(l.annotation, r)]), () => ( null)) : null,
2356
2401
  /** Annotation layers draw with their annotation's blend mode unless the layer sets one. */
2357
2402
  contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
2358
2403
  layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
@@ -2364,18 +2409,24 @@ var PHOTO_PROFILE = {
2364
2409
  isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
2365
2410
  maskSourcePlane: (source, W, H, sources) => {
2366
2411
  const opts = source;
2367
- const depth = _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.depthMap, 'optionalCall', _18 => _18(opts)]), () => ( null));
2412
+ const depth = _nullishCoalesce(_optionalChain([sources, 'access', _19 => _19.depthMap, 'optionalCall', _20 => _20(opts)]), () => ( null));
2368
2413
  if (!depth || depth.width !== W || depth.height !== H) return null;
2369
2414
  const v = new Float32Array(W * H);
2370
2415
  for (let i = 0; i < v.length; i++) v[i] = depthMaskAlpha(depth.data[i * 4], opts) / 255;
2371
2416
  return v;
2372
2417
  }
2373
2418
  };
2374
- var LayerCompositor = class extends _chunkPOGBUYWEcjs.RasterCompositor {
2419
+ var LayerCompositor = class extends _chunkST7E3NEEcjs.RasterCompositor {
2375
2420
  constructor(options = {}) {
2376
2421
  super(PHOTO_PROFILE, options);
2377
2422
  }
2378
2423
  };
2424
+ function compositeDeep(layers, rect, sources, depth) {
2425
+ const deep = new (0, _chunkST7E3NEEcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
2426
+ applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks)
2427
+ }, depth);
2428
+ return deep.composite(layers, rect, sources);
2429
+ }
2379
2430
 
2380
2431
  // src/image-editor/layers/vector-raster.ts
2381
2432
  var FLATNESS = 0.01;
@@ -2917,47 +2968,47 @@ var fail = (message) => {
2917
2968
  throw new LayerOperationError(message);
2918
2969
  };
2919
2970
  function requireLayer(layers, id) {
2920
- const loc = _chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id);
2971
+ const loc = _chunkST7E3NEEcjs.findLayer.call(void 0, layers, id);
2921
2972
  if (!loc) {
2922
- const ids = _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2973
+ const ids = _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2923
2974
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
2924
2975
  }
2925
2976
  return loc;
2926
2977
  }
2927
2978
  function requireUnlocked(layer, what, action) {
2928
- if (_chunkPOGBUYWEcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2929
- if (what !== "all" && _chunkPOGBUYWEcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2979
+ if (_chunkST7E3NEEcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2980
+ if (what !== "all" && _chunkST7E3NEEcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2930
2981
  }
2931
2982
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
2932
2983
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
2933
2984
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
2934
2985
  if (placement.aboveId || placement.belowId) {
2935
2986
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
2936
- return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2987
+ return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _21 => _21.parent, 'optionalAccess', _22 => _22.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2937
2988
  }
2938
2989
  if (placement.parentId) {
2939
2990
  const ref = requireLayer(layers, placement.parentId);
2940
2991
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
2941
- return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2992
+ return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2942
2993
  }
2943
- return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2994
+ return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2944
2995
  }
2945
2996
  function removeLayer(layers, id) {
2946
2997
  const loc = requireLayer(layers, id);
2947
2998
  requireUnlocked(loc.layer, "all", "delete it");
2948
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
2999
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
2949
3000
  }
2950
3001
  function moveLayer(layers, id, placement) {
2951
3002
  const loc = requireLayer(layers, id);
2952
3003
  requireUnlocked(loc.layer, "all", "move it");
2953
3004
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
2954
3005
  if (target === id) fail("A layer cannot be placed relative to itself.");
2955
- if (target && loc.layer.type === "group" && _chunkPOGBUYWEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
3006
+ if (target && loc.layer.type === "group" && _chunkST7E3NEEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
2956
3007
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
2957
3008
  }
2958
3009
  if (target) requireLayer(layers, target);
2959
3010
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
2960
- const without = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
3011
+ const without = _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
2961
3012
  return placeLayer(without, loc.layer, placement);
2962
3013
  }
2963
3014
  function withNewIds(layer) {
@@ -2965,7 +3016,7 @@ function withNewIds(layer) {
2965
3016
  if (next.type === "group") next.children = next.children.map(withNewIds);
2966
3017
  if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
2967
3018
  if (next.type === "shape" || next.type === "type") delete next.annotation;
2968
- if (next.type === "smart" && _optionalChain([next, 'access', _21 => _21.psd, 'optionalAccess', _22 => _22.placed])) {
3019
+ if (next.type === "smart" && _optionalChain([next, 'access', _23 => _23.psd, 'optionalAccess', _24 => _24.placed])) {
2969
3020
  next.psd = { ...next.psd };
2970
3021
  delete next.psd.placed;
2971
3022
  }
@@ -2976,7 +3027,7 @@ function duplicateLayer(layers, id, name) {
2976
3027
  const copy = withNewIds(loc.layer);
2977
3028
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
2978
3029
  delete copy.locks;
2979
- return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.id]), () => ( null)), loc.index + 1), id: copy.id };
3030
+ return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _25 => _25.parent, 'optionalAccess', _26 => _26.id]), () => ( null)), loc.index + 1), id: copy.id };
2980
3031
  }
2981
3032
  function setLayerProperties(layers, id, props) {
2982
3033
  const loc = requireLayer(layers, id);
@@ -3003,7 +3054,7 @@ function setLayerProperties(layers, id, props) {
3003
3054
  if (props.blend !== void 0) {
3004
3055
  if (props.blend === "pass-through") {
3005
3056
  if (layer.type !== "group") fail("pass-through is only for groups.");
3006
- } else if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
3057
+ } else if (!_chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
3007
3058
  next.blend = props.blend;
3008
3059
  }
3009
3060
  if (props.clipped !== void 0) {
@@ -3023,13 +3074,13 @@ function setLayerProperties(layers, id, props) {
3023
3074
  if (props.collapsed) g.collapsed = true;
3024
3075
  else delete g.collapsed;
3025
3076
  }
3026
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3077
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3027
3078
  }
3028
3079
  function groupLayers(layers, ids, name = "Group") {
3029
3080
  if (!ids.length) fail("Give at least one layer id to group.");
3030
3081
  const locs = ids.map((id) => requireLayer(layers, id));
3031
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _25 => _25[0], 'access', _26 => _26.parent, 'optionalAccess', _27 => _27.id]), () => ( null));
3032
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _28 => _28.parent, 'optionalAccess', _29 => _29.id]), () => ( null))) !== parent)) fail("Layers to group must share one parent; move them next to each other first.");
3082
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _27 => _27[0], 'access', _28 => _28.parent, 'optionalAccess', _29 => _29.id]), () => ( null));
3083
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _30 => _30.parent, 'optionalAccess', _31 => _31.id]), () => ( null))) !== parent)) fail("Layers to group must share one parent; move them next to each other first.");
3033
3084
  for (const l of locs) requireUnlocked(l.layer, "all", "group it");
3034
3085
  const ordered = [...new Set(locs)].sort((a, b) => a.index - b.index);
3035
3086
  const top = ordered[ordered.length - 1].index;
@@ -3046,23 +3097,23 @@ function groupLayers(layers, ids, name = "Group") {
3046
3097
  return c;
3047
3098
  })
3048
3099
  };
3049
- if (_optionalChain([group, 'access', _30 => _30.children, 'access', _31 => _31[0], 'optionalAccess', _32 => _32.clipped])) {
3100
+ if (_optionalChain([group, 'access', _32 => _32.children, 'access', _33 => _33[0], 'optionalAccess', _34 => _34.clipped])) {
3050
3101
  const c = { ...group.children[0] };
3051
3102
  delete c.clipped;
3052
3103
  group.children[0] = c;
3053
3104
  }
3054
3105
  let out = layers;
3055
- for (const l of ordered) out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3056
- return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3106
+ for (const l of ordered) out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3107
+ return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3057
3108
  }
3058
3109
  function ungroupLayer(layers, id) {
3059
3110
  const loc = requireLayer(layers, id);
3060
3111
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
3061
3112
  requireUnlocked(loc.layer, "all", "ungroup it");
3062
3113
  const group = loc.layer;
3063
- let out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
3114
+ let out = _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
3064
3115
  group.children.forEach((c, i) => {
3065
- out = _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.id]), () => ( null)), loc.index + i);
3116
+ out = _chunkST7E3NEEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _35 => _35.parent, 'optionalAccess', _36 => _36.id]), () => ( null)), loc.index + i);
3066
3117
  });
3067
3118
  return { layers: out, ids: group.children.map((c) => c.id) };
3068
3119
  }
@@ -3075,14 +3126,14 @@ function offsetLayer(layers, id, offset) {
3075
3126
  const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
3076
3127
  const mask = layer.mask;
3077
3128
  if (mask && mask.linked === false && !mask.source) {
3078
- next.mask = { ...mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3129
+ next.mask = { ...mask, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3079
3130
  }
3080
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3131
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3081
3132
  }
3082
3133
  function setLayerMask(layers, id, mask) {
3083
3134
  const loc = requireLayer(layers, id);
3084
3135
  requireUnlocked(loc.layer, "all", "change its mask");
3085
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, (l) => {
3136
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, (l) => {
3086
3137
  const next = { ...l };
3087
3138
  if (mask) next.mask = mask;
3088
3139
  else delete next.mask;
@@ -3120,8 +3171,8 @@ function requirePixelLayer(layers, id) {
3120
3171
  }
3121
3172
  function addLayerFilter(layers, id, filter) {
3122
3173
  const layer = requirePixelLayer(layers, id);
3123
- if (_optionalChain([layer, 'access', _35 => _35.filters, 'optionalAccess', _36 => _36.some, 'call', _37 => _37((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3124
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3174
+ if (_optionalChain([layer, 'access', _37 => _37.filters, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3175
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3125
3176
  }
3126
3177
  function updateLayerFilter(layers, id, filterId, changes) {
3127
3178
  const layer = requirePixelLayer(layers, id);
@@ -3132,7 +3183,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
3132
3183
  const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
3133
3184
  const filters = [...layer.filters];
3134
3185
  filters[i] = merged2;
3135
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3186
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3136
3187
  }
3137
3188
  function removeLayerFilter(layers, id, filterId) {
3138
3189
  const layer = requirePixelLayer(layers, id);
@@ -3141,7 +3192,7 @@ function removeLayerFilter(layers, id, filterId) {
3141
3192
  const next = { ...layer };
3142
3193
  if (filters.length) next.filters = filters;
3143
3194
  else delete next.filters;
3144
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3195
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3145
3196
  }
3146
3197
  function requireEffectLayer(layers, id, action) {
3147
3198
  const layer = requireLayer(layers, id).layer;
@@ -3156,7 +3207,7 @@ function guard(fn) {
3156
3207
  try {
3157
3208
  return fn();
3158
3209
  } catch (e) {
3159
- if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail(e.message);
3210
+ if (e instanceof _chunkST7E3NEEcjs.LayerEffectError) fail(e.message);
3160
3211
  throw e;
3161
3212
  }
3162
3213
  }
@@ -3164,27 +3215,27 @@ function setLayerEffects(layers, id, effects) {
3164
3215
  const layer = requireEffectLayer(layers, id, "change its effects");
3165
3216
  const next = { ...layer };
3166
3217
  if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
3167
- guard(() => _chunkPOGBUYWEcjs.validateLayerEffects.call(void 0, effects));
3218
+ guard(() => _chunkST7E3NEEcjs.validateLayerEffects.call(void 0, effects));
3168
3219
  next.effects = effects;
3169
3220
  } else delete next.effects;
3170
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3221
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3171
3222
  }
3172
3223
  function addLayerEffect(layers, id, kind, params = {}, index) {
3173
- if (!_chunkPOGBUYWEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkPOGBUYWEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3224
+ if (!_chunkST7E3NEEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkST7E3NEEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3174
3225
  const layer = requireEffectLayer(layers, id, "add effects");
3175
3226
  const current = layerEffectsOf(layer);
3176
3227
  const ids = new Set(current.items.map((e) => e.id));
3177
- let effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
3178
- while (ids.has(effectId)) effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
3228
+ let effectId = _chunkST7E3NEEcjs.newEffectId.call(void 0, );
3229
+ while (ids.has(effectId)) effectId = _chunkST7E3NEEcjs.newEffectId.call(void 0, );
3179
3230
  const { id: _ignored, kind: _kind, ...rest } = params;
3180
- const effect = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3231
+ const effect = guard(() => _chunkST7E3NEEcjs.mergeLayerEffect.call(void 0, _chunkST7E3NEEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3181
3232
  const items = [...current.items];
3182
3233
  const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
3183
3234
  items.splice(at, 0, effect);
3184
3235
  return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
3185
3236
  }
3186
3237
  function requireEffect(layer, effectId) {
3187
- const items = _nullishCoalesce(_optionalChain([layer, 'access', _38 => _38.effects, 'optionalAccess', _39 => _39.items]), () => ( []));
3238
+ const items = _nullishCoalesce(_optionalChain([layer, 'access', _40 => _40.effects, 'optionalAccess', _41 => _41.items]), () => ( []));
3188
3239
  const i = items.findIndex((e) => e.id === effectId);
3189
3240
  if (i === -1) fail(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
3190
3241
  return i;
@@ -3194,7 +3245,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
3194
3245
  const i = requireEffect(layer, effectId);
3195
3246
  const current = layer.effects;
3196
3247
  const items = [...current.items];
3197
- items[i] = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, items[i], changes));
3248
+ items[i] = guard(() => _chunkST7E3NEEcjs.mergeLayerEffect.call(void 0, items[i], changes));
3198
3249
  return setLayerEffects(layers, id, { ...current, items });
3199
3250
  }
3200
3251
  function removeLayerEffect(layers, id, effectId) {
@@ -3217,7 +3268,7 @@ function setLayerEffectsEnabled(layers, id, enabled, scale) {
3217
3268
  function parseBlend(value, allowPassThrough = false) {
3218
3269
  if (value === void 0) return void 0;
3219
3270
  if (value === "pass-through" && allowPassThrough) return value;
3220
- if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3271
+ if (!_chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3221
3272
  return value;
3222
3273
  }
3223
3274
  function unionRect(a, b) {
@@ -3229,7 +3280,7 @@ function unionRect(a, b) {
3229
3280
  }
3230
3281
 
3231
3282
  // src/image-editor/layers/shape.ts
3232
- var SHAPE_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
3283
+ var SHAPE_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
3233
3284
  var DEFAULT_MITER_LIMIT = 100;
3234
3285
  var fail2 = (message) => {
3235
3286
  throw new LayerOperationError(message);
@@ -3269,7 +3320,7 @@ function mapAnchor(a, f) {
3269
3320
  return out;
3270
3321
  }
3271
3322
  function mapSubpaths(subpaths, f) {
3272
- return _chunkW3GXSUSQcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
3323
+ return _chunkLPLCWZTMcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
3273
3324
  }
3274
3325
  function liveShapeSubpaths(live) {
3275
3326
  let out;
@@ -3277,19 +3328,19 @@ function liveShapeSubpaths(live) {
3277
3328
  case "rect": {
3278
3329
  const x = Math.min(live.x, live.x + live.width);
3279
3330
  const y = Math.min(live.y, live.y + live.height);
3280
- const sp = _chunkW3GXSUSQcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
3331
+ const sp = _chunkLPLCWZTMcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
3281
3332
  const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
3282
- out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkW3GXSUSQcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
3333
+ out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkLPLCWZTMcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
3283
3334
  break;
3284
3335
  }
3285
3336
  case "ellipse":
3286
- out = [_chunkW3GXSUSQcjs.ellipseSubpath.call(void 0, normBox(live))];
3337
+ out = [_chunkLPLCWZTMcjs.ellipseSubpath.call(void 0, normBox(live))];
3287
3338
  break;
3288
3339
  case "polygon":
3289
- out = [_chunkW3GXSUSQcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
3340
+ out = [_chunkLPLCWZTMcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
3290
3341
  break;
3291
3342
  case "star":
3292
- out = [_chunkW3GXSUSQcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
3343
+ out = [_chunkLPLCWZTMcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
3293
3344
  break;
3294
3345
  case "line": {
3295
3346
  const a = { x: live.x1, y: live.y1 };
@@ -3312,7 +3363,7 @@ function liveShapeSubpaths(live) {
3312
3363
  }
3313
3364
  }
3314
3365
  const m = live.transform;
3315
- return m && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p)) : out;
3366
+ return m && !_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, p)) : out;
3316
3367
  }
3317
3368
  function normBox(b) {
3318
3369
  return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
@@ -3324,7 +3375,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
3324
3375
  function componentPath(c) {
3325
3376
  let p = pathCache.get(c.subpaths);
3326
3377
  if (!p) {
3327
- p = _chunkW3GXSUSQcjs.subpathsToBezier.call(void 0, c.subpaths);
3378
+ p = _chunkLPLCWZTMcjs.subpathsToBezier.call(void 0, c.subpaths);
3328
3379
  pathCache.set(c.subpaths, p);
3329
3380
  }
3330
3381
  return p;
@@ -3372,7 +3423,7 @@ function closedOutline(path) {
3372
3423
  function strokeArea(path, stroke, double) {
3373
3424
  const w = stroke.width * (double ? 2 : 1);
3374
3425
  if (!(w > 0) || !path.length) return [];
3375
- const dashes = _optionalChain([stroke, 'access', _40 => _40.dashes, 'optionalAccess', _41 => _41.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
3426
+ const dashes = _optionalChain([stroke, 'access', _42 => _42.dashes, 'optionalAccess', _43 => _43.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
3376
3427
  const options = {
3377
3428
  width: w,
3378
3429
  cap: _nullishCoalesce(stroke.cap, () => ( "butt")),
@@ -3445,11 +3496,11 @@ function fillCoverage(geo, rect, rule, inverted = false) {
3445
3496
  function paintContext(env) {
3446
3497
  const tiles = /* @__PURE__ */ new Map();
3447
3498
  return {
3448
- light: _chunkPOGBUYWEcjs.DEFAULT_GLOBAL_LIGHT,
3499
+ light: _chunkST7E3NEEcjs.DEFAULT_GLOBAL_LIGHT,
3449
3500
  pattern: (id) => {
3450
3501
  if (tiles.has(id)) return tiles.get(id);
3451
- const p = _nullishCoalesce(_optionalChain([env, 'access', _42 => _42.pattern, 'optionalCall', _43 => _43(id)]), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
3452
- const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkPOGBUYWEcjs.PatternTile)(p) : null;
3502
+ const p = _nullishCoalesce(_optionalChain([env, 'access', _44 => _44.pattern, 'optionalCall', _45 => _45(id)]), () => ( _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)));
3503
+ const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkST7E3NEEcjs.PatternTile)(p) : null;
3453
3504
  tiles.set(id, t);
3454
3505
  return t;
3455
3506
  }
@@ -3480,10 +3531,10 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3480
3531
  if (!fCov && !sCov) return null;
3481
3532
  const canvas = { x: 0, y: 0, width: env.width, height: env.height };
3482
3533
  const anchor = { x: geo.frame.x, y: geo.frame.y };
3483
- const fc = fCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3484
- const fo = _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.fill, 'optionalAccess', _45 => _45.opacity]), () => ( 1));
3485
- const sc = sCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3486
- const so = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.stroke, 'optionalAccess', _47 => _47.paint, 'access', _48 => _48.opacity]), () => ( 1));
3534
+ const fc = fCov ? _chunkST7E3NEEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3535
+ const fo = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.fill, 'optionalAccess', _47 => _47.opacity]), () => ( 1));
3536
+ const sc = sCov ? _chunkST7E3NEEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3537
+ const so = _nullishCoalesce(_optionalChain([layer, 'access', _48 => _48.stroke, 'optionalAccess', _49 => _49.paint, 'access', _50 => _50.opacity]), () => ( 1));
3487
3538
  const out = new Uint8ClampedArray(n * 4);
3488
3539
  let any = false;
3489
3540
  for (let i = 0; i < n; i++) {
@@ -3521,20 +3572,20 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3521
3572
  }
3522
3573
  function renderShape(layer, env, options = {}) {
3523
3574
  const geo = shapeGeometry(layer);
3524
- if (!geo.bounds) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
3575
+ if (!geo.bounds) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
3525
3576
  let region = intersect(geo.bounds, shapeRenderClip(env));
3526
3577
  if (region && options.clip) region = intersect(region, options.clip);
3527
- if (!region) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
3578
+ if (!region) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
3528
3579
  const ctx = paintContext(env);
3529
3580
  const tiles = /* @__PURE__ */ new Map();
3530
- for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
3531
- const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
3581
+ for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, region)) {
3582
+ const rect = { x: tx * _chunkTFOPHZ3Ucjs.TILE, y: ty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE };
3532
3583
  const px2 = renderShapeRect(layer, rect, env, ctx);
3533
3584
  if (!px2) continue;
3534
- const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px2, 4, 0);
3535
- if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
3585
+ const tile = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, px2, 4, 0);
3586
+ if (tile) tiles.set(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty), tile);
3536
3587
  }
3537
- return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
3588
+ return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(4, tiles, 0);
3538
3589
  }
3539
3590
  function rerenderShape(layer, env) {
3540
3591
  return { ...layer, surface: renderShape(layer, env) };
@@ -3565,7 +3616,7 @@ function normalizeShapePaint(v, path = "paint") {
3565
3616
  const g = o.gradient;
3566
3617
  if (!g || typeof g !== "object") return fail2(`${path}.gradient is required: { stops: [{ position, color }], style, angle, \u2026 }.`);
3567
3618
  const gradient = {
3568
- stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([parseCssColor, 'call', _49 => _49(s.color), 'optionalAccess', _50 => _50.hex]), () => ( s.color)) })) : [],
3619
+ stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([parseCssColor, 'call', _51 => _51(s.color), 'optionalAccess', _52 => _52.hex]), () => ( s.color)) })) : [],
3569
3620
  ...g.opacityStops ? { opacityStops: g.opacityStops } : {},
3570
3621
  style: _nullishCoalesce(g.style, () => ( "linear")),
3571
3622
  angle: _nullishCoalesce(g.angle, () => ( 90)),
@@ -3575,9 +3626,9 @@ function normalizeShapePaint(v, path = "paint") {
3575
3626
  offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
3576
3627
  };
3577
3628
  try {
3578
- _chunkPOGBUYWEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3629
+ _chunkST7E3NEEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3579
3630
  } catch (e) {
3580
- if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail2(e.message);
3631
+ if (e instanceof _chunkST7E3NEEcjs.LayerEffectError) fail2(e.message);
3581
3632
  throw e;
3582
3633
  }
3583
3634
  if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
@@ -3591,7 +3642,7 @@ function normalizeShapePaint(v, path = "paint") {
3591
3642
  if (o.link !== void 0) p.link = Boolean(o.link);
3592
3643
  if (o.phase !== void 0) {
3593
3644
  const ph = o.phase;
3594
- p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _51 => _51.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _52 => _52.y]), `${path}.phase.y`) };
3645
+ p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _53 => _53.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _54 => _54.y]), `${path}.phase.y`) };
3595
3646
  }
3596
3647
  return withOpacity(p);
3597
3648
  }
@@ -3604,7 +3655,7 @@ function normalizeShapeStroke(v, path = "stroke", base) {
3604
3655
  const paint = o.paint === void 0 && base ? base.paint : o.paint === void 0 && o.color !== void 0 ? normalizeShapePaint(o.color, `${path}.color`) : normalizeShapePaint(o.paint, `${path}.paint`);
3605
3656
  const out = { width, paint };
3606
3657
  const pick = (k, allowed) => {
3607
- const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _53 => _53[k]]) : o[k];
3658
+ const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _55 => _55[k]]) : o[k];
3608
3659
  if (value === void 0) return;
3609
3660
  if (!allowed.includes(value)) fail2(`${path}.${k} must be one of ${allowed.join(", ")}, got ${JSON.stringify(value)}.`);
3610
3661
  if (value !== (k === "align" ? "center" : k === "cap" ? "butt" : "miter")) out[k] = value;
@@ -3612,9 +3663,9 @@ function normalizeShapeStroke(v, path = "stroke", base) {
3612
3663
  pick("align", ["inside", "center", "outside"]);
3613
3664
  pick("cap", ["butt", "round", "square"]);
3614
3665
  pick("join", ["miter", "round", "bevel"]);
3615
- const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _54 => _54.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
3666
+ const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _56 => _56.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
3616
3667
  if (miter !== void 0 && miter !== DEFAULT_MITER_LIMIT) out.miterLimit = miter;
3617
- const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _55 => _55.dashes]) : o.dashes;
3668
+ const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _57 => _57.dashes]) : o.dashes;
3618
3669
  if (dashes !== void 0 && dashes !== null) {
3619
3670
  if (!Array.isArray(dashes) || dashes.length > 32 || !dashes.every((d) => isNum(d) && d >= 0 && d <= 1e4)) fail2(`${path}.dashes must be at most 32 lengths 0..10000 (multiples of the width).`);
3620
3671
  if (dashes.length) {
@@ -3622,7 +3673,7 @@ function normalizeShapeStroke(v, path = "stroke", base) {
3622
3673
  out.dashes = [...dashes];
3623
3674
  }
3624
3675
  }
3625
- const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _56 => _56.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
3676
+ const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _58 => _58.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
3626
3677
  if (offset) out.dashOffset = offset;
3627
3678
  return out;
3628
3679
  }
@@ -3647,7 +3698,7 @@ function matrixArg(v, path) {
3647
3698
  if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
3648
3699
  const m = v;
3649
3700
  if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
3650
- return _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3701
+ return _chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3651
3702
  }
3652
3703
  function normalizeLiveShape(v, path = "shape") {
3653
3704
  if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
@@ -3708,7 +3759,7 @@ function normalizeSubpaths(v, path = "subpaths") {
3708
3759
  if (typeof v === "string") {
3709
3760
  let subs;
3710
3761
  try {
3711
- subs = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, v);
3762
+ subs = _chunkLPLCWZTMcjs.bezierToSubpaths.call(void 0, v);
3712
3763
  } catch (e5) {
3713
3764
  return fail2(`${path}: could not read the SVG path data.`);
3714
3765
  }
@@ -3758,7 +3809,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
3758
3809
  components: init.components,
3759
3810
  fill: init.fill === void 0 ? null : init.fill,
3760
3811
  stroke: _nullishCoalesce(init.stroke, () => ( null)),
3761
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
3812
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
3762
3813
  offset: { x: 0, y: 0 }
3763
3814
  };
3764
3815
  if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
@@ -3766,7 +3817,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
3766
3817
  return rerenderShape(layer, env);
3767
3818
  }
3768
3819
  function defaultShapeName(c) {
3769
- switch (_optionalChain([c, 'optionalAccess', _57 => _57.live, 'optionalAccess', _58 => _58.kind])) {
3820
+ switch (_optionalChain([c, 'optionalAccess', _59 => _59.live, 'optionalAccess', _60 => _60.kind])) {
3770
3821
  case "rect":
3771
3822
  return "Rectangle";
3772
3823
  case "ellipse":
@@ -3789,20 +3840,20 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
3789
3840
  if (!("annotation" in patch)) delete next.annotation;
3790
3841
  if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
3791
3842
  const rendered = rerenderShape(next, env);
3792
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3843
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3793
3844
  }
3794
3845
  function transformShapeComponents(components, f, affine) {
3795
3846
  return components.map((c) => {
3796
3847
  if (affine && c.live) {
3797
- const live = { ...c.live, transform: _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX)), affine) };
3798
- if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
3848
+ const live = { ...c.live, transform: _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkLPLCWZTMcjs.IDENTITY_MATRIX)), affine) };
3849
+ if (_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
3799
3850
  return { op: c.op, subpaths: liveShapeSubpaths(live), live };
3800
3851
  }
3801
3852
  return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
3802
3853
  });
3803
3854
  }
3804
3855
  function offsetShape(layer, dx, dy, env) {
3805
- const m = _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy);
3856
+ const m = _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy);
3806
3857
  const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
3807
3858
  delete next.annotation;
3808
3859
  return rerenderShape(next, env);
@@ -3810,7 +3861,7 @@ function offsetShape(layer, dx, dy, env) {
3810
3861
  function mergeShapeComponents(components, fillRule = "nonzero") {
3811
3862
  if (components.length < 2) return [...components];
3812
3863
  const path = shapeOutline(components, fillRule);
3813
- const subpaths = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, path);
3864
+ const subpaths = _chunkLPLCWZTMcjs.bezierToSubpaths.call(void 0, path);
3814
3865
  if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
3815
3866
  return [{ op: "combine", subpaths }];
3816
3867
  }
@@ -3820,14 +3871,14 @@ function shapeAsPixelLayer(layer) {
3820
3871
  }
3821
3872
  function annotationPaint(color, opacity) {
3822
3873
  const c = parseCssColor(color);
3823
- if (!c || !_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3874
+ if (!c || !_chunkST7E3NEEcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3824
3875
  const a = c.alpha * opacity;
3825
3876
  return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
3826
3877
  }
3827
3878
  function shapeFromAnnotation(a) {
3828
3879
  const opacity = _nullishCoalesce(a.opacity, () => ( 1));
3829
3880
  const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
3830
- const rotation = a.rotation ? _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
3881
+ const rotation = a.rotation ? _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
3831
3882
  const t = rotation ? { transform: rotation } : {};
3832
3883
  const live = (l) => liveComponent(l);
3833
3884
  switch (a.type) {
@@ -3870,7 +3921,7 @@ function shapeFromAnnotation(a) {
3870
3921
  case "pen": {
3871
3922
  const paint = annotationPaint(a.strokeColor, opacity);
3872
3923
  if (!paint) return null;
3873
- const pts = rotation ? a.points.map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
3924
+ const pts = rotation ? a.points.map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
3874
3925
  const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
3875
3926
  return {
3876
3927
  components: [{ op: "combine", subpaths }],
@@ -3884,7 +3935,7 @@ function shapeFromAnnotation(a) {
3884
3935
  }
3885
3936
  function annotationBlend(a, layerBlend) {
3886
3937
  if (layerBlend !== "normal") return layerBlend;
3887
- return a.blend && _chunkXIOMMGPDcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3938
+ return a.blend && _chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3888
3939
  }
3889
3940
  function annotationOfShape(layer) {
3890
3941
  const a = layer.annotation;
@@ -3901,303 +3952,9 @@ function annotationOfShape(layer) {
3901
3952
  var fail3 = (message) => {
3902
3953
  throw new LayerOperationError(message);
3903
3954
  };
3904
- var DEFAULT_TEXT_STYLE = { fontFamily: "sans-serif", fontWeight: 400, fontSize: 24, color: "#000000" };
3905
- var DEFAULT_AUTO_LEADING = 1.2;
3906
- var sameStyle = (a, b) => JSON.stringify(a) === JSON.stringify(b);
3907
- function compact(runs) {
3908
- const out = [];
3909
- for (const r of runs) {
3910
- if (r.length <= 0) continue;
3911
- const last = out[out.length - 1];
3912
- if (last && sameStyle(last.style, r.style)) out[out.length - 1] = { ...last, length: last.length + r.length };
3913
- else out.push({ ...r });
3914
- }
3915
- return out;
3916
- }
3917
- function fitRuns(runs, length, fallback) {
3918
- const out = [];
3919
- let left = length;
3920
- for (const r of runs) {
3921
- if (left <= 0) break;
3922
- const n = Math.min(Math.max(0, Math.floor(r.length)), left);
3923
- if (n > 0) out.push({ ...r, length: n });
3924
- left -= n;
3925
- }
3926
- if (left > 0) {
3927
- if (out.length) out[out.length - 1] = { ...out[out.length - 1], length: out[out.length - 1].length + left };
3928
- else out.push({ length: left, style: _nullishCoalesce(_optionalChain([runs, 'access', _59 => _59[runs.length - 1], 'optionalAccess', _60 => _60.style]), () => ( fallback)) });
3929
- }
3930
- return compact(out);
3931
- }
3932
- function styleAt(runs, index, fallback) {
3933
- let at = 0;
3934
- for (const r of runs) {
3935
- if (index < at + r.length) return r.style;
3936
- at += r.length;
3937
- }
3938
- return _nullishCoalesce(_optionalChain([runs, 'access', _61 => _61[runs.length - 1], 'optionalAccess', _62 => _62.style]), () => ( fallback));
3939
- }
3940
- function restyleRange(runs, start, end, patch) {
3941
- const out = [];
3942
- let at = 0;
3943
- for (const r of runs) {
3944
- const a = at;
3945
- const b = at + r.length;
3946
- at = b;
3947
- const lo = Math.max(a, start);
3948
- const hi = Math.min(b, end);
3949
- if (hi <= lo) {
3950
- out.push({ ...r });
3951
- continue;
3952
- }
3953
- if (lo > a) out.push({ length: lo - a, style: r.style });
3954
- out.push({ length: hi - lo, style: patch(r.style) });
3955
- if (b > hi) out.push({ length: b - hi, style: r.style });
3956
- }
3957
- return compact(out);
3958
- }
3959
- function spliceRuns(runs, start, end, inserted, style) {
3960
- const out = [];
3961
- let at = 0;
3962
- let placed = false;
3963
- for (const r of runs) {
3964
- const a = at;
3965
- const b = at + r.length;
3966
- at = b;
3967
- if (b <= start) {
3968
- out.push({ ...r });
3969
- continue;
3970
- }
3971
- if (a < start) out.push({ length: start - a, style: r.style });
3972
- if (!placed) {
3973
- out.push({ length: inserted, style });
3974
- placed = true;
3975
- }
3976
- if (b > end) out.push({ length: b - Math.max(end, a), style: r.style });
3977
- }
3978
- if (!placed) out.push({ length: inserted, style });
3979
- return compact(out);
3980
- }
3981
- function paragraphRanges(text3) {
3982
- const out = [];
3983
- let start = 0;
3984
- for (let i = 0; i < text3.length; i++) {
3985
- if (text3[i] === "\n") {
3986
- out.push({ start, end: i + 1, content: i });
3987
- start = i + 1;
3988
- }
3989
- }
3990
- out.push({ start, end: text3.length, content: text3.length });
3991
- return out;
3992
- }
3993
- function fitParagraphRuns(runs, text3) {
3994
- const fallback = _nullishCoalesce(_optionalChain([runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( {}));
3995
- const out = compact(paragraphRanges(text3).map((p) => ({ length: p.end - p.start, style: styleAt(runs, p.start, fallback) })));
3996
- return out.length ? out : [{ length: 0, style: fallback }];
3997
- }
3998
- function fontOf(style) {
3999
- const f = { family: style.fontFamily, weight: style.fontWeight, italic: Boolean(style.italic), size: style.fontSize };
4000
- if (style.postScriptName) f.postScriptName = style.postScriptName;
4001
- return f;
4002
- }
4003
- var isBreakAfter = (c) => c === " " || c === " " || c === "-" || c === "\u2010" || c === "\u200B";
4004
- var isSpace = (c) => c === " " || c === " ";
4005
- var isWide = (code) => code >= 11904 && code <= 40959 || code >= 44032 && code <= 55215 || code >= 63744 && code <= 64255 || code >= 65280 && code <= 65519;
4006
- var layoutCache = /* @__PURE__ */ new WeakMap();
4007
- function layoutText(layer, shaper) {
4008
- let byShaper = layoutCache.get(layer);
4009
- const hit = _optionalChain([byShaper, 'optionalAccess', _65 => _65.get, 'call', _66 => _66(shaper.id)]);
4010
- if (hit) return hit;
4011
- const out = computeLayout(layer, shaper);
4012
- if (!byShaper) {
4013
- byShaper = /* @__PURE__ */ new Map();
4014
- layoutCache.set(layer, byShaper);
4015
- }
4016
- byShaper.set(shaper.id, out);
4017
- return out;
4018
- }
4019
- function computeLayout(layer, shaper) {
4020
- const { text: text3, frame } = layer;
4021
- const runs = fitRuns(layer.runs, text3.length, DEFAULT_TEXT_STYLE);
4022
- const missing = /* @__PURE__ */ new Set();
4023
- const resolved = /* @__PURE__ */ new Map();
4024
- const familyOf = (font) => {
4025
- const key = `${font.family}|${font.weight}|${font.italic}|${_nullishCoalesce(font.postScriptName, () => ( ""))}`;
4026
- let fam = resolved.get(key);
4027
- if (fam === void 0) {
4028
- const r = shaper.resolve(font);
4029
- fam = r.family;
4030
- if (!r.available) missing.add(font.family);
4031
- resolved.set(key, fam);
4032
- }
4033
- return fam;
4034
- };
4035
- const resolvedFont = (style) => ({ ...fontOf(style), family: familyOf(fontOf(style)) });
4036
- const box2 = frame.kind === "box" ? frame : null;
4037
- const lines = [];
4038
- let y = 0;
4039
- let first = true;
4040
- const paragraphs = paragraphRanges(text3);
4041
- paragraphs.forEach((para, pi) => {
4042
- const pstyle = styleAt(layer.paragraphs, para.start, {});
4043
- const autoLeading = _nullishCoalesce(pstyle.autoLeading, () => ( DEFAULT_AUTO_LEADING));
4044
- if (pi > 0) y += _nullishCoalesce(pstyle.spaceBefore, () => ( 0));
4045
- const chars = [];
4046
- let i = para.start;
4047
- while (i < para.content) {
4048
- const style = styleAt(runs, i, DEFAULT_TEXT_STYLE);
4049
- let j = i + 1;
4050
- while (j < para.content && styleAt(runs, j, DEFAULT_TEXT_STYLE) === style) j++;
4051
- const seg = text3.slice(i, j);
4052
- const carets = shaper.measure(seg, resolvedFont(style));
4053
- const track = (_nullishCoalesce(style.tracking, () => ( 0))) / 1e3 * style.fontSize;
4054
- for (let k = 0; k < seg.length; k++) chars.push({ index: i + k, ch: seg[k], advance: (_nullishCoalesce(carets[k + 1], () => ( 0))) - (_nullishCoalesce(carets[k], () => ( 0))) + track, style });
4055
- i = j;
4056
- }
4057
- const startIndent = _nullishCoalesce(pstyle.startIndent, () => ( 0));
4058
- const endIndent = _nullishCoalesce(pstyle.endIndent, () => ( 0));
4059
- const firstIndent = _nullishCoalesce(pstyle.firstLineIndent, () => ( 0));
4060
- const breaks = [];
4061
- if (!box2 || !chars.length) breaks.push([0, chars.length]);
4062
- else {
4063
- let s = 0;
4064
- while (s < chars.length) {
4065
- const avail = box2.width - startIndent - endIndent - (breaks.length === 0 ? firstIndent : 0);
4066
- let w = 0;
4067
- let e = s;
4068
- let lastBreak = -1;
4069
- while (e < chars.length) {
4070
- const c = chars[e];
4071
- if (!isSpace(c.ch) && w + c.advance > avail && e > s) break;
4072
- w += c.advance;
4073
- if (isBreakAfter(c.ch) || isWide(c.ch.charCodeAt(0)) || e + 1 < chars.length && isWide(chars[e + 1].ch.charCodeAt(0))) lastBreak = e + 1;
4074
- e++;
4075
- }
4076
- if (e < chars.length && lastBreak > s) e = lastBreak;
4077
- while (e < chars.length && isSpace(chars[e].ch)) e++;
4078
- breaks.push([s, e]);
4079
- s = e;
4080
- }
4081
- }
4082
- const align = _nullishCoalesce(pstyle.align, () => ( "left"));
4083
- breaks.forEach(([s, e], li) => {
4084
- const lineChars = chars.slice(s, e);
4085
- let visibleEnd = lineChars.length;
4086
- while (visibleEnd > 0 && isSpace(lineChars[visibleEnd - 1].ch)) visibleEnd--;
4087
- const styles = lineChars.length ? [...new Set(lineChars.map((c) => c.style))] : [styleAt(runs, Math.min(para.start, Math.max(0, text3.length - 1)), DEFAULT_TEXT_STYLE)];
4088
- let ascent = 0;
4089
- let descent = 0;
4090
- let leading = 0;
4091
- for (const st of styles) {
4092
- const m = shaper.metrics(resolvedFont(st));
4093
- ascent = Math.max(ascent, m.ascent);
4094
- descent = Math.max(descent, m.descent);
4095
- leading = Math.max(leading, _nullishCoalesce(st.leading, () => ( autoLeading * st.fontSize)));
4096
- }
4097
- if (first) {
4098
- y = frame.kind === "box" || frame.kind === "point" && frame.origin === "top" ? ascent : 0;
4099
- first = false;
4100
- } else y += leading;
4101
- const indent = startIndent + (li === 0 ? firstIndent : 0);
4102
- let width = 0;
4103
- for (let k2 = 0; k2 < visibleEnd; k2++) width += lineChars[k2].advance;
4104
- const lastLine = li === breaks.length - 1;
4105
- let extraPerSpace = 0;
4106
- if (box2 && align === "justify" && !lastLine) {
4107
- const spaces = lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
4108
- const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
4109
- if (spaces > 0 && avail > width) extraPerSpace = (avail - width) / spaces;
4110
- }
4111
- let x0;
4112
- const fullWidth = width + extraPerSpace * lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
4113
- if (box2) {
4114
- const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
4115
- x0 = indent + (align === "center" ? (avail - fullWidth) / 2 : align === "right" ? avail - fullWidth : 0);
4116
- } else x0 = indent + (align === "center" ? -fullWidth / 2 : align === "right" ? -fullWidth : 0);
4117
- const laid = [];
4118
- let x = x0;
4119
- for (const c of lineChars) {
4120
- const adv = c.advance + (isSpace(c.ch) ? extraPerSpace : 0);
4121
- laid.push({ index: c.index, x, advance: adv });
4122
- x += adv;
4123
- }
4124
- const fragments = [];
4125
- let k = 0;
4126
- while (k < lineChars.length) {
4127
- const st = lineChars[k].style;
4128
- let m = k + 1;
4129
- while (m < lineChars.length && lineChars[m].style === st) m++;
4130
- const font = resolvedFont(st);
4131
- const fx = laid[k].x;
4132
- const carets = [0];
4133
- for (let q2 = k; q2 < m; q2++) carets.push(laid[q2].x + laid[q2].advance - fx);
4134
- fragments.push({
4135
- start: lineChars[k].index,
4136
- end: lineChars[m - 1].index + 1,
4137
- style: st,
4138
- font,
4139
- family: font.family,
4140
- x: fx,
4141
- y: y - (_nullishCoalesce(st.baselineShift, () => ( 0))),
4142
- carets,
4143
- spaced: Boolean(st.tracking) || extraPerSpace > 0
4144
- });
4145
- k = m;
4146
- }
4147
- const lineStart = lineChars.length ? lineChars[0].index : para.start;
4148
- lines.push({ start: lineStart, end: lineChars.length ? lineChars[lineChars.length - 1].index + 1 : para.start, baseline: y, ascent, descent, x: x0, width, chars: laid, fragments });
4149
- });
4150
- y += _nullishCoalesce(pstyle.spaceAfter, () => ( 0));
4151
- });
4152
- let bounds;
4153
- if (box2) bounds = { x: 0, y: 0, width: box2.width, height: box2.height };
4154
- else {
4155
- let x0 = Infinity;
4156
- let x1 = -Infinity;
4157
- for (const l of lines) {
4158
- x0 = Math.min(x0, l.x);
4159
- x1 = Math.max(x1, l.x + l.width);
4160
- }
4161
- if (!Number.isFinite(x0)) x0 = x1 = 0;
4162
- const top = lines.length ? lines[0].baseline - lines[0].ascent : 0;
4163
- const last = lines[lines.length - 1];
4164
- const bottom = last ? last.baseline + last.descent : 0;
4165
- bounds = { x: x0, y: top, width: Math.max(0, x1 - x0), height: Math.max(0, bottom - top) };
4166
- }
4167
- return { lines, bounds, missingFonts: [...missing] };
4168
- }
4169
- function textIndexAt(layout, p) {
4170
- if (!layout.lines.length) return 0;
4171
- let line = layout.lines[layout.lines.length - 1];
4172
- for (const l of layout.lines) {
4173
- if (p.y <= l.baseline + l.descent) {
4174
- line = l;
4175
- break;
4176
- }
4177
- }
4178
- if (!line.chars.length) return line.start;
4179
- for (const c of line.chars) if (p.x < c.x + c.advance / 2) return c.index;
4180
- const lastChar = line.chars[line.chars.length - 1];
4181
- return lastChar.index + 1;
4182
- }
4183
- function caretAt(layout, index) {
4184
- const lines = layout.lines;
4185
- if (!lines.length) return { x: 0, top: 0, bottom: 0, line: 0 };
4186
- for (let li = 0; li < lines.length; li++) {
4187
- const l2 = lines[li];
4188
- const next = lines[li + 1];
4189
- if (next && index >= next.start && (next.chars.length || index > l2.end || next.start > l2.end)) continue;
4190
- const c = l2.chars.find((ch) => ch.index === index);
4191
- const prev = l2.chars.find((ch) => ch.index === index - 1);
4192
- const x = c ? c.x : prev ? prev.x + prev.advance : l2.x;
4193
- return { x, top: l2.baseline - l2.ascent, bottom: l2.baseline + l2.descent, line: li };
4194
- }
4195
- const l = lines[lines.length - 1];
4196
- return { x: l.x + l.width, top: l.baseline - l.ascent, bottom: l.baseline + l.descent, line: lines.length - 1 };
4197
- }
4198
- var TEXT_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
3955
+ var TEXT_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
4199
3956
  function textMatrix(layer) {
4200
- return _nullishCoalesce(layer.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX));
3957
+ return _nullishCoalesce(layer.transform, () => ( _chunkLPLCWZTMcjs.IDENTITY_MATRIX));
4201
3958
  }
4202
3959
  function rectCorners(r) {
4203
3960
  return [
@@ -4208,7 +3965,7 @@ function rectCorners(r) {
4208
3965
  ];
4209
3966
  }
4210
3967
  function docRect(r, m) {
4211
- const pts = rectCorners(r).map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p));
3968
+ const pts = rectCorners(r).map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, p));
4212
3969
  const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
4213
3970
  const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
4214
3971
  const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
@@ -4239,56 +3996,31 @@ function inkBounds(layout) {
4239
3996
  }
4240
3997
  return b;
4241
3998
  }
4242
- function decorations(f, l) {
4243
- const out = [];
4244
- const t = Math.max(1, f.style.fontSize / 15);
4245
- const w = f.carets[f.carets.length - 1];
4246
- if (f.style.underline) out.push({ x: f.x, y: f.y + Math.max(t, l.descent * 0.35), width: w, height: t });
4247
- if (f.style.strikethrough) out.push({ x: f.x, y: f.y - l.ascent * 0.3 - t / 2, width: w, height: t });
4248
- return out;
4249
- }
4250
- var rectPath = (r) => [
4251
- { type: "M", x: r.x, y: r.y },
4252
- { type: "L", x: r.x + r.width, y: r.y },
4253
- { type: "L", x: r.x + r.width, y: r.y + r.height },
4254
- { type: "L", x: r.x, y: r.y + r.height },
4255
- { type: "Z" }
4256
- ];
4257
- function fragmentOutline(shaper, text3, f) {
4258
- const s = text3.slice(f.start, f.end);
4259
- if (!f.spaced) return shaper.outline(s, f.font, f.x, f.y);
4260
- const out = [];
4261
- for (let k = 0; k < s.length; k++) {
4262
- if (isSpace(s[k])) continue;
4263
- out.push(...shaper.outline(s[k], f.font, f.x + f.carets[k], f.y));
4264
- }
4265
- return out;
4266
- }
4267
3999
  function textOutlines(layer, shaper) {
4268
4000
  if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
4269
- const layout = layoutText(layer, shaper);
4001
+ const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4270
4002
  const m = textMatrix(layer);
4271
4003
  const out = [];
4272
4004
  for (const l of layout.lines) {
4273
4005
  for (const f of l.fragments) {
4274
- let path = fragmentOutline(shaper, layer.text, f);
4275
- for (const r of decorations(f, l)) path = [...path, ...rectPath(r)];
4276
- out.push({ fragment: f, path: _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
4006
+ let path = _chunkLPLCWZTMcjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
4007
+ for (const r of _chunkLPLCWZTMcjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunkLPLCWZTMcjs.textRectPath.call(void 0, r)];
4008
+ out.push({ fragment: f, path: _chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
4277
4009
  }
4278
4010
  }
4279
4011
  return out;
4280
4012
  }
4281
4013
  var rgbOf = (hex) => {
4282
4014
  const c = parseCssColor(hex);
4283
- const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _67 => _67.hex]), () => ( "#000000"))).slice(1);
4015
+ const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _61 => _61.hex]), () => ( "#000000"))).slice(1);
4284
4016
  return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
4285
4017
  };
4286
4018
  function renderOutlines(layer, shaper, region) {
4287
4019
  const parts = textOutlines(layer, shaper).map(({ fragment, path }) => ({ style: fragment.style, flat: flattenPath(path) }));
4288
4020
  const tiles = /* @__PURE__ */ new Map();
4289
- for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
4290
- const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
4291
- const n = _chunkXIOMMGPDcjs.TILE * _chunkXIOMMGPDcjs.TILE;
4021
+ for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, region)) {
4022
+ const rect = { x: tx * _chunkTFOPHZ3Ucjs.TILE, y: ty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE };
4023
+ const n = _chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE;
4292
4024
  const acc = new Float32Array(n * 4);
4293
4025
  let any = false;
4294
4026
  for (const p of parts) {
@@ -4319,17 +4051,17 @@ function renderOutlines(layer, shaper, region) {
4319
4051
  px2[i + 2] = Math.round(acc[i + 2]);
4320
4052
  px2[i + 3] = a;
4321
4053
  }
4322
- const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px2, 4, 0);
4323
- if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
4054
+ const tile = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, px2, 4, 0);
4055
+ if (tile) tiles.set(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty), tile);
4324
4056
  }
4325
- return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
4057
+ return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(4, tiles, 0);
4326
4058
  }
4327
4059
  function renderOnCanvas(layer, shaper, region, env) {
4328
4060
  if (!env.createCanvas) return null;
4329
4061
  const canvas = env.createCanvas(region.width, region.height);
4330
4062
  const ctx = canvas.getContext("2d");
4331
4063
  if (!ctx || typeof ctx.getImageData !== "function") return null;
4332
- const layout = layoutText(layer, shaper);
4064
+ const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4333
4065
  const m = textMatrix(layer);
4334
4066
  ctx.setTransform(1, 0, 0, 1, 0, 0);
4335
4067
  ctx.clearRect(0, 0, region.width, region.height);
@@ -4341,23 +4073,23 @@ function renderOnCanvas(layer, shaper, region, env) {
4341
4073
  ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
4342
4074
  const s = layer.text.slice(f.start, f.end);
4343
4075
  if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
4344
- else for (let k = 0; k < s.length; k++) if (!isSpace(s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
4345
- for (const d of decorations(f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
4076
+ else for (let k = 0; k < s.length; k++) if (!_chunkLPLCWZTMcjs.isTextSpace.call(void 0, s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
4077
+ for (const d of _chunkLPLCWZTMcjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
4346
4078
  }
4347
4079
  }
4348
4080
  ctx.globalAlpha = 1;
4349
4081
  ctx.setTransform(1, 0, 0, 1, 0, 0);
4350
4082
  const data = ctx.getImageData(0, 0, region.width, region.height).data;
4351
- return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: region.width, height: region.height, data: new Uint8ClampedArray(data) }, 4, region.x, region.y);
4083
+ return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width: region.width, height: region.height, data: new Uint8ClampedArray(data) }, 4, region.x, region.y);
4352
4084
  }
4353
4085
  function renderText(layer, env) {
4354
4086
  const shaper = env.shaper;
4355
4087
  if (!shaper || !shaper.outline && !shaper.draw) return null;
4356
- const layout = layoutText(layer, shaper);
4088
+ const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4357
4089
  const ink = inkBounds(layout);
4358
4090
  const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
4359
4091
  const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
4360
- if (!region) return { surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), missingFonts: layout.missingFonts };
4092
+ if (!region) return { surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4), missingFonts: layout.missingFonts };
4361
4093
  if (shaper.outline) return { surface: renderOutlines(layer, shaper, region), missingFonts: layout.missingFonts };
4362
4094
  const surface = renderOnCanvas(layer, shaper, region, env);
4363
4095
  return surface ? { surface, missingFonts: layout.missingFonts } : null;
@@ -4448,7 +4180,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
4448
4180
  continue;
4449
4181
  }
4450
4182
  const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
4451
- if (k === "autoLeading" && value === DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
4183
+ if (k === "autoLeading" && value === _chunkLPLCWZTMcjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
4452
4184
  else o[k] = value;
4453
4185
  } else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
4454
4186
  }
@@ -4485,14 +4217,14 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
4485
4217
  opacity: 1,
4486
4218
  blend: "normal",
4487
4219
  text: text3,
4488
- runs: fitRuns(init.runs, text3.length, DEFAULT_TEXT_STYLE),
4489
- paragraphs: fitParagraphRuns(_nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
4220
+ runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, init.runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
4221
+ paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
4490
4222
  frame: init.frame,
4491
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4223
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
4492
4224
  offset: { x: 0, y: 0 }
4493
4225
  };
4494
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _68 => _68.runs, 'access', _69 => _69[0], 'optionalAccess', _70 => _70.style]), () => ( DEFAULT_TEXT_STYLE)) }];
4495
- if (init.transform && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4226
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _62 => _62.runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)) }];
4227
+ if (init.transform && !_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4496
4228
  if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
4497
4229
  return rerenderText(layer, env);
4498
4230
  }
@@ -4502,24 +4234,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
4502
4234
  const patch = change(current);
4503
4235
  const next = { ...current, ...patch };
4504
4236
  if (!("annotation" in patch)) delete next.annotation;
4505
- if ("text" in patch || "runs" in patch) next.runs = fitRuns(next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _71 => _71.runs, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.style]), () => ( DEFAULT_TEXT_STYLE)));
4506
- if (!next.runs.length) next.runs = [{ length: 0, style: styleAt(current.runs, 0, DEFAULT_TEXT_STYLE) }];
4507
- if ("text" in patch || "paragraphs" in patch) next.paragraphs = fitParagraphRuns(next.paragraphs, next.text);
4237
+ if ("text" in patch || "runs" in patch) next.runs = _chunkLPLCWZTMcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _65 => _65.runs, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)));
4238
+ if (!next.runs.length) next.runs = [{ length: 0, style: _chunkLPLCWZTMcjs.styleAt.call(void 0, current.runs, 0, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE) }];
4239
+ if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
4508
4240
  const rendered = rerenderText(next, env);
4509
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4241
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4510
4242
  }
4511
4243
  function replaceTextRange(layer, start, end, insert) {
4512
4244
  const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
4513
- const style = styleAt(layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, DEFAULT_TEXT_STYLE);
4514
- const runs = spliceRuns(layer.runs, start, end, insert.length, style);
4515
- const pstyle = styleAt(layer.paragraphs, start, {});
4516
- const paragraphs = spliceRuns(layer.paragraphs, start, end, insert.length, pstyle);
4517
- return { text: text3, runs, paragraphs: fitParagraphRuns(paragraphs, text3) };
4245
+ const style = _chunkLPLCWZTMcjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE);
4246
+ const runs = _chunkLPLCWZTMcjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
4247
+ const pstyle = _chunkLPLCWZTMcjs.styleAt.call(void 0, layer.paragraphs, start, {});
4248
+ const paragraphs = _chunkLPLCWZTMcjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
4249
+ return { text: text3, runs, paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
4518
4250
  }
4519
4251
  function transformTypeLayer(layer, m) {
4520
- const t = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
4252
+ const t = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
4521
4253
  const next = { ...layer };
4522
- if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
4254
+ if (_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
4523
4255
  else next.transform = t;
4524
4256
  delete next.annotation;
4525
4257
  return next;
@@ -4527,7 +4259,7 @@ function transformTypeLayer(layer, m) {
4527
4259
  function typeFrame(layer, shaper) {
4528
4260
  if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
4529
4261
  if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
4530
- const b = layoutText(layer, shaper).bounds;
4262
+ const b = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper).bounds;
4531
4263
  return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
4532
4264
  }
4533
4265
  function typeAsPixelLayer(layer) {
@@ -4535,7 +4267,7 @@ function typeAsPixelLayer(layer) {
4535
4267
  return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
4536
4268
  }
4537
4269
  function toTextSpace(layer, p) {
4538
- return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
4270
+ return _chunkLPLCWZTMcjs.applyMatrix.call(void 0, _chunkLPLCWZTMcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
4539
4271
  }
4540
4272
  function typeFromAnnotation(a) {
4541
4273
  if (a.type !== "text") return null;
@@ -4549,7 +4281,7 @@ function typeFromAnnotation(a) {
4549
4281
  if (op !== 1) style.opacity = op;
4550
4282
  const text3 = t.text.replace(/\r?\n|\r/g, " ");
4551
4283
  const translate = [1, 0, 0, 1, t.x, t.y];
4552
- const transform = t.rotation ? _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, translate, _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
4284
+ const transform = t.rotation ? _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, translate, _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
4553
4285
  return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
4554
4286
  }
4555
4287
  function annotationOfType(layer) {
@@ -4598,7 +4330,7 @@ function rasterMaskFromLegacy(mask, width, height) {
4598
4330
  const sel = decodeLayerMask(mask);
4599
4331
  if (!sel) return null;
4600
4332
  const sized = sel.width === width && sel.height === height ? sel : resizeSelection(sel, width, height);
4601
- const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
4333
+ const surface = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
4602
4334
  legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
4603
4335
  const out = { surface, defaultValue: 0 };
4604
4336
  if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
@@ -4617,7 +4349,7 @@ function hasResampledLegacyMask(layers, width, height) {
4617
4349
  function legacyMaskOf(mask, width, height) {
4618
4350
  let memo = legacyMaskMemo.get(mask.surface);
4619
4351
  if (!memo) {
4620
- const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
4352
+ const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
4621
4353
  memo = { width, height, rle: encodeSelectionRle(new Uint8Array(data.buffer, data.byteOffset, data.length)) };
4622
4354
  legacyMaskMemo.set(mask.surface, memo);
4623
4355
  }
@@ -4719,7 +4451,7 @@ function backgroundLayer(filters = [], mask) {
4719
4451
  visible: true,
4720
4452
  opacity: 1,
4721
4453
  blend: "normal",
4722
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4454
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
4723
4455
  offset: { x: 0, y: 0 },
4724
4456
  source: "document",
4725
4457
  filters
@@ -4729,7 +4461,7 @@ function backgroundLayer(filters = [], mask) {
4729
4461
  }
4730
4462
  function depthRasterMask(source) {
4731
4463
  const out = {
4732
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255),
4464
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 1, 255),
4733
4465
  defaultValue: 255,
4734
4466
  source: { ...source, depthRange: [...source.depthRange] }
4735
4467
  };
@@ -4789,7 +4521,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4789
4521
  const { layers } = stack;
4790
4522
  const target = developTarget(layers, activeLayerId);
4791
4523
  const develop = target ? developFilter(target) : void 0;
4792
- const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _74 => _74(target), 'optionalAccess', _75 => _75.radius]) : void 0))), () => ( 0));
4524
+ const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _68 => _68(target), 'optionalAccess', _69 => _69.radius]) : void 0))), () => ( 0));
4793
4525
  const adjustments = {
4794
4526
  ...DEFAULT_ADJUSTMENTS_VALUES,
4795
4527
  ...develop ? {
@@ -4818,7 +4550,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4818
4550
  };
4819
4551
  walk(layers);
4820
4552
  if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
4821
- const depthSource = _optionalChain([target, 'optionalAccess', _76 => _76.mask, 'optionalAccess', _77 => _77.source]);
4553
+ const depthSource = _optionalChain([target, 'optionalAccess', _70 => _70.mask, 'optionalAccess', _71 => _71.source]);
4822
4554
  const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
4823
4555
  return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
4824
4556
  }
@@ -4843,7 +4575,7 @@ function isLegacyShape(stack) {
4843
4575
  let adjustments = 0;
4844
4576
  for (; i < layers.length && layers[i].type === "adjustment"; i++) {
4845
4577
  const l = layers[i];
4846
- if (l.clipped || l.locks || _optionalChain([l, 'access', _78 => _78.mask, 'optionalAccess', _79 => _79.source]) || l.effects) return false;
4578
+ if (l.clipped || l.locks || _optionalChain([l, 'access', _72 => _72.mask, 'optionalAccess', _73 => _73.source]) || l.effects) return false;
4847
4579
  adjustments++;
4848
4580
  }
4849
4581
  for (; i < layers.length; i++) {
@@ -4883,7 +4615,7 @@ function identityTransform(box2) {
4883
4615
  }
4884
4616
  function cornersFromMatrix(box2, m) {
4885
4617
  const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2);
4886
- return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
4618
+ return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[3])];
4887
4619
  }
4888
4620
  function matrixFromCorners(box2, corners, eps = 1e-6) {
4889
4621
  const [tl, tr, br, bl] = corners;
@@ -4900,7 +4632,7 @@ function transformHomography(geometry) {
4900
4632
  function hasWarp(geometry) {
4901
4633
  const w = geometry.warp;
4902
4634
  if (!w) return false;
4903
- const id = _chunkW3GXSUSQcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
4635
+ const id = _chunkLPLCWZTMcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
4904
4636
  if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
4905
4637
  return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
4906
4638
  }
@@ -4915,7 +4647,7 @@ function transformMap(geometry) {
4915
4647
  const { box: box2 } = geometry;
4916
4648
  const warp = hasWarp(geometry) ? geometry.warp : null;
4917
4649
  if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
4918
- return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
4650
+ return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkLPLCWZTMcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
4919
4651
  }
4920
4652
  function transformedPoint(geometry, fx, fy) {
4921
4653
  const f = transformMap(geometry);
@@ -4959,8 +4691,8 @@ function matrixFromParams(box2, params) {
4959
4691
  const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
4960
4692
  const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
4961
4693
  const ref = referencePoint(box2, params.reference);
4962
- const linear = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
4963
- return _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.matrixAbout.call(void 0, linear, ref), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
4694
+ const linear = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
4695
+ return _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _chunkLPLCWZTMcjs.matrixAbout.call(void 0, linear, ref), _chunkLPLCWZTMcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
4964
4696
  }
4965
4697
  function describeTransform(geometry, reference = "center") {
4966
4698
  const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
@@ -4977,7 +4709,7 @@ function describeTransform(geometry, reference = "center") {
4977
4709
  const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
4978
4710
  const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
4979
4711
  const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
4980
- const at = _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, ref);
4712
+ const at = _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, ref);
4981
4713
  const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
4982
4714
  return {
4983
4715
  affine: true,
@@ -4995,24 +4727,24 @@ function applyParams(geometry, params) {
4995
4727
  const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
4996
4728
  const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
4997
4729
  const c = geometry.corners;
4998
- return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[3])];
4730
+ return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[3])];
4999
4731
  }
5000
4732
  function flipCorners(geometry, axis) {
5001
4733
  const c = anchorPoint(geometry, "center");
5002
4734
  const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
5003
4735
  const q2 = geometry.corners;
5004
- return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
4736
+ return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[3])];
5005
4737
  }
5006
4738
  function boxPointOf(geometry, p) {
5007
4739
  const m = matrixFromCorners(geometry.box, geometry.corners);
5008
- if (m) return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, m), p);
4740
+ if (m) return _chunkLPLCWZTMcjs.applyMatrix.call(void 0, _chunkLPLCWZTMcjs.invertMatrix.call(void 0, m), p);
5009
4741
  return null;
5010
4742
  }
5011
4743
  function presetWarp(box2, preset) {
5012
- return _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0, preset, box2);
4744
+ return _chunkLPLCWZTMcjs.warpPresetMesh.call(void 0, preset, box2);
5013
4745
  }
5014
4746
  function isValidWarp(mesh) {
5015
- return _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, mesh);
4747
+ return _chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, mesh);
5016
4748
  }
5017
4749
  function geometryHomography(geometry) {
5018
4750
  const m = matrixFromCorners(geometry.box, geometry.corners);
@@ -5023,7 +4755,7 @@ function geometryHomography(geometry) {
5023
4755
  var fail4 = (message) => {
5024
4756
  throw new LayerOperationError(message);
5025
4757
  };
5026
- var SMART_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
4758
+ var SMART_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
5027
4759
  function newContentsId() {
5028
4760
  return newLayerId("so");
5029
4761
  }
@@ -5041,7 +4773,7 @@ function isContentsDecoded(contents) {
5041
4773
  }
5042
4774
  function requireDecoded(layer, action) {
5043
4775
  if (isContentsDecoded(layer.contents)) return;
5044
- const what = _optionalChain([layer, 'access', _80 => _80.contents, 'access', _81 => _81.file, 'optionalAccess', _82 => _82.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4776
+ const what = _optionalChain([layer, 'access', _74 => _74.contents, 'access', _75 => _75.file, 'optionalAccess', _76 => _76.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
5045
4777
  fail4(
5046
4778
  `The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
5047
4779
  );
@@ -5056,26 +4788,26 @@ function contentsSurface(contents) {
5056
4788
  let s = contentsPixels.get(contents);
5057
4789
  if (s) return s;
5058
4790
  if (contents.kind === "raster") {
5059
- s = _nullishCoalesce(contents.raster, () => ( _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4)));
4791
+ s = _nullishCoalesce(contents.raster, () => ( _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4)));
5060
4792
  } else {
5061
4793
  const doc = contents.document;
5062
- if (!doc) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
4794
+ if (!doc) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
5063
4795
  const W = contents.width;
5064
4796
  const H = contents.height;
5065
4797
  const data = new LayerCompositor().composite(doc.layers, { x: 0, y: 0, width: W, height: H }, {
5066
4798
  width: W,
5067
4799
  height: H,
5068
4800
  globalLight: doc.globalLight,
5069
- pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _83 => _83.patterns, 'optionalAccess', _84 => _84.find, 'call', _85 => _85((p) => p.id === id)]), () => ( null))
4801
+ pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _77 => _77.patterns, 'optionalAccess', _78 => _78.find, 'call', _79 => _79((p) => p.id === id)]), () => ( null))
5070
4802
  });
5071
- s = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
4803
+ s = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
5072
4804
  }
5073
4805
  contentsPixels.set(contents, s);
5074
4806
  return s;
5075
4807
  }
5076
4808
  function rasterContents(pixels, name, id = newContentsId()) {
5077
4809
  if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail4("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
5078
- return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
4810
+ return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
5079
4811
  }
5080
4812
  function documentContents(document, width, height, name, id = newContentsId()) {
5081
4813
  if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail4("Contents width and height must be positive whole numbers.");
@@ -5101,7 +4833,7 @@ function placeContents(layer, canvas, options = {}) {
5101
4833
  const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
5102
4834
  const key = placementKey(placement, canvas);
5103
4835
  if (!preview) {
5104
- const hit = _optionalChain([placedCache, 'access', _86 => _86.get, 'call', _87 => _87(contents), 'optionalAccess', _88 => _88.get, 'call', _89 => _89(key)]);
4836
+ const hit = _optionalChain([placedCache, 'access', _80 => _80.get, 'call', _81 => _81(contents), 'optionalAccess', _82 => _82.get, 'call', _83 => _83(key)]);
5105
4837
  if (hit) return hit;
5106
4838
  }
5107
4839
  const src = contentsSurface(contents);
@@ -5119,7 +4851,7 @@ function placeContents(layer, canvas, options = {}) {
5119
4851
  let out;
5120
4852
  const move = integerMove(layer);
5121
4853
  if (move && !options.clip) {
5122
- out = _chunkXIOMMGPDcjs.translateSurface.call(void 0, src, move.x, move.y);
4854
+ out = _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, src, move.x, move.y);
5123
4855
  } else {
5124
4856
  const g = placementGeometry(layer);
5125
4857
  const interpolation = preview ? placement.interpolation === "nearest" ? "nearest" : "bilinear" : _nullishCoalesce(placement.interpolation, () => ( "bicubic"));
@@ -5128,10 +4860,10 @@ function placeContents(layer, canvas, options = {}) {
5128
4860
  let k = 1;
5129
4861
  if (step > 1) {
5130
4862
  k = step;
5131
- let r = _optionalChain([options, 'access', _90 => _90.reduced, 'optionalAccess', _91 => _91.get, 'call', _92 => _92(k)]);
4863
+ let r = _optionalChain([options, 'access', _84 => _84.reduced, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(k)]);
5132
4864
  if (!r) {
5133
- r = _chunkPOGBUYWEcjs.reduceSurface.call(void 0, src, k);
5134
- _optionalChain([options, 'access', _93 => _93.reduced, 'optionalAccess', _94 => _94.set, 'call', _95 => _95(k, r)]);
4865
+ r = _chunkST7E3NEEcjs.reduceSurface.call(void 0, src, k);
4866
+ _optionalChain([options, 'access', _87 => _87.reduced, 'optionalAccess', _88 => _88.set, 'call', _89 => _89(k, r)]);
5135
4867
  }
5136
4868
  source = r;
5137
4869
  }
@@ -5140,15 +4872,15 @@ function placeContents(layer, canvas, options = {}) {
5140
4872
  if (hasWarp(g)) {
5141
4873
  const f = transformMap(g);
5142
4874
  if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
5143
- out = _chunkPOGBUYWEcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
4875
+ out = _chunkST7E3NEEcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
5144
4876
  } else {
5145
4877
  const h = transformHomography(g);
5146
4878
  if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
5147
4879
  const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
5148
- out = _chunkPOGBUYWEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
4880
+ out = _chunkST7E3NEEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
5149
4881
  }
5150
4882
  } catch (e) {
5151
- if (e instanceof _chunkPOGBUYWEcjs.TransformTooLargeError) fail4(e.message);
4883
+ if (e instanceof _chunkST7E3NEEcjs.TransformTooLargeError) fail4(e.message);
5152
4884
  throw e;
5153
4885
  }
5154
4886
  }
@@ -5164,14 +4896,14 @@ function placeContents(layer, canvas, options = {}) {
5164
4896
  return out;
5165
4897
  }
5166
4898
  function activeSmartFilters(stack) {
5167
- if (!_optionalChain([stack, 'optionalAccess', _96 => _96.enabled])) return [];
4899
+ if (!_optionalChain([stack, 'optionalAccess', _90 => _90.enabled])) return [];
5168
4900
  return stack.filters.filter((f) => f.kind !== "psd" && isActiveFilter(f) && f.opacity > 0);
5169
4901
  }
5170
4902
  function filterMaskCoverage(mask, canvas) {
5171
4903
  if (!mask || mask.enabled === false || mask.source) return null;
5172
4904
  const W = canvas.width;
5173
4905
  const H = canvas.height;
5174
- const bytes = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
4906
+ const bytes = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
5175
4907
  let v = new Float32Array(W * H);
5176
4908
  let all = true;
5177
4909
  for (let i = 0; i < v.length; i++) {
@@ -5180,7 +4912,7 @@ function filterMaskCoverage(mask, canvas) {
5180
4912
  }
5181
4913
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
5182
4914
  if (all && !(feather > 0)) return null;
5183
- if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
4915
+ if (feather > 0) v = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
5184
4916
  const density = _nullishCoalesce(mask.density, () => ( 1));
5185
4917
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
5186
4918
  return v;
@@ -5193,7 +4925,7 @@ function applySmartFilters(placed, stack, canvas) {
5193
4925
  const key = JSON.stringify([W, H, active.map((f) => ({ ...f, id: void 0 }))]);
5194
4926
  let entry = filteredCache.get(placed);
5195
4927
  if (!entry || entry.key !== key) {
5196
- const base = _chunkXIOMMGPDcjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
4928
+ const base = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
5197
4929
  let acc = new Uint8ClampedArray(base);
5198
4930
  for (const f of active) {
5199
4931
  const out = new Uint8ClampedArray(acc);
@@ -5202,7 +4934,7 @@ function applySmartFilters(placed, stack, canvas) {
5202
4934
  if (f.opacity >= 1) acc = out;
5203
4935
  else lerpInto(acc, out, f.opacity, null);
5204
4936
  } else {
5205
- _chunkPOGBUYWEcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
4937
+ _chunkST7E3NEEcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
5206
4938
  }
5207
4939
  }
5208
4940
  entry = { key, base, filtered: acc };
@@ -5214,7 +4946,7 @@ function applySmartFilters(placed, stack, canvas) {
5214
4946
  result = new Uint8ClampedArray(entry.base);
5215
4947
  lerpInto(result, entry.filtered, 1, cov);
5216
4948
  }
5217
- return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
4949
+ return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
5218
4950
  }
5219
4951
  function lerpInto(dst, src, k, coverage) {
5220
4952
  for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
@@ -5239,17 +4971,17 @@ function rerender(layer, canvas, action = "change") {
5239
4971
  return { ...layer, surface: renderSmartObject(layer, canvas) };
5240
4972
  }
5241
4973
  function normalizePlacement(raw, contents) {
5242
- const c = _optionalChain([raw, 'optionalAccess', _97 => _97.corners]);
4974
+ const c = _optionalChain([raw, 'optionalAccess', _91 => _91.corners]);
5243
4975
  if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
5244
4976
  fail4("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
5245
4977
  }
5246
4978
  const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
5247
4979
  if (raw.warp) {
5248
- if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
4980
+ if (!_chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
5249
4981
  out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
5250
4982
  }
5251
4983
  if (raw.interpolation !== void 0) {
5252
- if (!_chunkPOGBUYWEcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
4984
+ if (!_chunkST7E3NEEcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
5253
4985
  if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
5254
4986
  }
5255
4987
  const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
@@ -5269,7 +5001,7 @@ function followMask(mask, before, after) {
5269
5001
  const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
5270
5002
  if (!inv) return mask;
5271
5003
  const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
5272
- const surface = _chunkPOGBUYWEcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
5004
+ const surface = _chunkST7E3NEEcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
5273
5005
  return { ...mask, surface };
5274
5006
  }
5275
5007
  function setSmartPlacement(layers, id, placement, canvas) {
@@ -5284,13 +5016,13 @@ function setSmartPlacement(layers, id, placement, canvas) {
5284
5016
  masksMoved ||= m !== layer.mask;
5285
5017
  next.mask = m;
5286
5018
  }
5287
- if (_optionalChain([next, 'access', _98 => _98.smartFilters, 'optionalAccess', _99 => _99.mask])) {
5019
+ if (_optionalChain([next, 'access', _92 => _92.smartFilters, 'optionalAccess', _93 => _93.mask])) {
5288
5020
  const m = followMask(next.smartFilters.mask, layer, next);
5289
5021
  masksMoved ||= m !== next.smartFilters.mask;
5290
5022
  next.smartFilters = { ...next.smartFilters, mask: m };
5291
5023
  }
5292
5024
  next = rerender(next, canvas, "be transformed");
5293
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
5025
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
5294
5026
  }
5295
5027
  function offsetSmartObject(layers, id, dx, dy, canvas) {
5296
5028
  const layer = requireSmartObject(layers, id);
@@ -5300,26 +5032,26 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
5300
5032
  if (!mx && !my) return layers;
5301
5033
  const corners = layer.placement.corners.map((p) => ({ x: p.x + mx, y: p.y + my }));
5302
5034
  let next = { ...layer, placement: { ...layer.placement, corners } };
5303
- const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
5035
+ const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
5304
5036
  if (layer.mask) next.mask = moveMask(layer.mask);
5305
- if (_optionalChain([layer, 'access', _100 => _100.smartFilters, 'optionalAccess', _101 => _101.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5037
+ if (_optionalChain([layer, 'access', _94 => _94.smartFilters, 'optionalAccess', _95 => _95.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5306
5038
  const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur");
5307
- const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
5039
+ const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
5308
5040
  const m = SMART_RENDER_MARGIN;
5309
5041
  const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
5310
- if (!spatial && !cut && !(_optionalChain([next, 'access', _102 => _102.smartFilters, 'optionalAccess', _103 => _103.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5311
- next = { ...next, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, mx, my) };
5042
+ if (!spatial && !cut && !(_optionalChain([next, 'access', _96 => _96.smartFilters, 'optionalAccess', _97 => _97.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5043
+ next = { ...next, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, mx, my) };
5312
5044
  } else {
5313
5045
  next = rerender(next, canvas, "move");
5314
5046
  }
5315
- return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
5047
+ return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
5316
5048
  }
5317
5049
  function translateLayer(layer, dx, dy) {
5318
5050
  if (!dx && !dy) return layer;
5319
5051
  const moveMask = (m) => {
5320
5052
  if (!m) return m;
5321
5053
  if (m.source) fail4(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
5322
- return { ...m, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m.surface, dx, dy) };
5054
+ return { ...m, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, m.surface, dx, dy) };
5323
5055
  };
5324
5056
  switch (layer.type) {
5325
5057
  case "pixel":
@@ -5328,11 +5060,11 @@ function translateLayer(layer, dx, dy) {
5328
5060
  const next = {
5329
5061
  ...layer,
5330
5062
  placement: { ...layer.placement, corners: layer.placement.corners.map((p) => ({ x: p.x + dx, y: p.y + dy })) },
5331
- surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
5063
+ surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy),
5332
5064
  mask: moveMask(layer.mask)
5333
5065
  };
5334
5066
  if (!next.mask) delete next.mask;
5335
- if (_optionalChain([layer, 'access', _104 => _104.smartFilters, 'optionalAccess', _105 => _105.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5067
+ if (_optionalChain([layer, 'access', _98 => _98.smartFilters, 'optionalAccess', _99 => _99.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5336
5068
  return next;
5337
5069
  }
5338
5070
  case "group": {
@@ -5348,8 +5080,8 @@ function translateLayer(layer, dx, dy) {
5348
5080
  case "shape": {
5349
5081
  const next = {
5350
5082
  ...layer,
5351
- components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)),
5352
- surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
5083
+ components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy)),
5084
+ surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy),
5353
5085
  mask: moveMask(layer.mask)
5354
5086
  };
5355
5087
  if (!next.mask) delete next.mask;
@@ -5357,7 +5089,7 @@ function translateLayer(layer, dx, dy) {
5357
5089
  return next;
5358
5090
  }
5359
5091
  case "type": {
5360
- const next = { ...transformTypeLayer(layer, _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
5092
+ const next = { ...transformTypeLayer(layer, _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
5361
5093
  if (!next.mask) delete next.mask;
5362
5094
  return next;
5363
5095
  }
@@ -5372,7 +5104,7 @@ function layerExtent(layer, surfaceOf, canvas) {
5372
5104
  const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
5373
5105
  if (s.defaultValue !== 0) b = full;
5374
5106
  else {
5375
- const c = _chunkXIOMMGPDcjs.contentBounds.call(void 0, s);
5107
+ const c = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, s);
5376
5108
  b = c ? { x: c.x + layer.offset.x, y: c.y + layer.offset.y, width: c.width, height: c.height } : null;
5377
5109
  }
5378
5110
  } else if (layer.type === "group") {
@@ -5380,7 +5112,7 @@ function layerExtent(layer, surfaceOf, canvas) {
5380
5112
  } else {
5381
5113
  b = full;
5382
5114
  }
5383
- const m = _chunkPOGBUYWEcjs.effectsMargin.call(void 0, layer.effects);
5115
+ const m = _chunkST7E3NEEcjs.effectsMargin.call(void 0, layer.effects);
5384
5116
  if (b && m > 0) b = { x: b.x - Math.ceil(m), y: b.y - Math.ceil(m), width: b.width + 2 * Math.ceil(m), height: b.height + 2 * Math.ceil(m) };
5385
5117
  return b;
5386
5118
  }
@@ -5392,14 +5124,14 @@ function union(a, b) {
5392
5124
  return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
5393
5125
  }
5394
5126
  function asSmartFilters(filters) {
5395
- if (!_optionalChain([filters, 'optionalAccess', _106 => _106.length])) return void 0;
5127
+ if (!_optionalChain([filters, 'optionalAccess', _100 => _100.length])) return void 0;
5396
5128
  return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
5397
5129
  }
5398
5130
  function convertToSmartObject(layers, ids, canvas, options) {
5399
5131
  if (!ids.length) fail4("Give at least one layer id to convert.");
5400
5132
  const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
5401
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _107 => _107[0], 'access', _108 => _108.parent, 'optionalAccess', _109 => _109.id]), () => ( null));
5402
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _110 => _110.parent, 'optionalAccess', _111 => _111.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
5133
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _101 => _101[0], 'access', _102 => _102.parent, 'optionalAccess', _103 => _103.id]), () => ( null));
5134
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _104 => _104.parent, 'optionalAccess', _105 => _105.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
5403
5135
  for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
5404
5136
  const ordered = locs.sort((a, b) => a.index - b.index);
5405
5137
  const top = ordered[ordered.length - 1];
@@ -5408,7 +5140,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5408
5140
  if (single && single.type === "pixel") {
5409
5141
  const surface = options.surfaceOf(single);
5410
5142
  if (surface.defaultValue !== 0) fail4(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
5411
- const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
5143
+ const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, surface);
5412
5144
  if (!b) fail4(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
5413
5145
  const contents = {
5414
5146
  id: newContentsId(),
@@ -5416,7 +5148,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5416
5148
  width: b.width,
5417
5149
  height: b.height,
5418
5150
  kind: "raster",
5419
- raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -b.x, -b.y)
5151
+ raster: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, surface, -b.x, -b.y)
5420
5152
  };
5421
5153
  smart = {
5422
5154
  type: "smart",
@@ -5427,14 +5159,14 @@ function convertToSmartObject(layers, ids, canvas, options) {
5427
5159
  blend: single.blend,
5428
5160
  contents,
5429
5161
  placement: placementAt(contents, b.x + single.offset.x, b.y + single.offset.y),
5430
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
5162
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
5431
5163
  offset: { x: 0, y: 0 }
5432
5164
  };
5433
5165
  if (single.clipped) smart.clipped = true;
5434
5166
  if (single.fillOpacity !== void 0) smart.fillOpacity = single.fillOpacity;
5435
5167
  if (single.effects) smart.effects = single.effects;
5436
5168
  if (single.mask) {
5437
- smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
5169
+ smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
5438
5170
  }
5439
5171
  const filters = asSmartFilters(single.filters);
5440
5172
  if (filters) smart.smartFilters = filters;
@@ -5449,7 +5181,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5449
5181
  delete resolved.source;
5450
5182
  layer = resolved;
5451
5183
  }
5452
- if (_chunkPOGBUYWEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5184
+ if (_chunkST7E3NEEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5453
5185
  return translateLayer(layer, -b.x, -b.y);
5454
5186
  });
5455
5187
  if (nested[0].clipped) {
@@ -5457,7 +5189,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5457
5189
  delete first.clipped;
5458
5190
  nested[0] = first;
5459
5191
  }
5460
- const name = _optionalChain([options, 'access', _112 => _112.name, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]) || top.layer.name || "Smart Object";
5192
+ const name = _optionalChain([options, 'access', _106 => _106.name, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]) || top.layer.name || "Smart Object";
5461
5193
  const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
5462
5194
  smart = {
5463
5195
  type: "smart",
@@ -5468,16 +5200,16 @@ function convertToSmartObject(layers, ids, canvas, options) {
5468
5200
  blend: "normal",
5469
5201
  contents,
5470
5202
  placement: placementAt(contents, b.x, b.y),
5471
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
5203
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
5472
5204
  offset: { x: 0, y: 0 }
5473
5205
  };
5474
5206
  }
5475
- if (_optionalChain([options, 'access', _115 => _115.name, 'optionalAccess', _116 => _116.trim, 'call', _117 => _117()])) smart.name = options.name.trim();
5207
+ if (_optionalChain([options, 'access', _109 => _109.name, 'optionalAccess', _110 => _110.trim, 'call', _111 => _111()])) smart.name = options.name.trim();
5476
5208
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
5477
5209
  const below = ordered.filter((l) => l.index < top.index).length;
5478
5210
  let out = layers;
5479
- for (const l of ordered) out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5480
- return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
5211
+ for (const l of ordered) out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5212
+ return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
5481
5213
  }
5482
5214
  function rasterizeSmartObject(layers, id) {
5483
5215
  const layer = requireSmartObject(layers, id);
@@ -5497,29 +5229,29 @@ function rasterizeSmartObject(layers, id) {
5497
5229
  if (layer.locks) out.locks = layer.locks;
5498
5230
  if (layer.effects) out.effects = layer.effects;
5499
5231
  if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
5500
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
5232
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
5501
5233
  }
5502
5234
  function copySmartObject(layers, id, linked, name) {
5503
5235
  const loc = requireLayer(layers, id);
5504
5236
  const layer = requireSmartObject(layers, id);
5505
- const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]) || `${layer.name || "Smart Object"} copy` };
5237
+ const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _112 => _112.trim, 'call', _113 => _113()]) || `${layer.name || "Smart Object"} copy` };
5506
5238
  delete copy.locks;
5507
5239
  delete copy.psd;
5508
5240
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
5509
5241
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
5510
- return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _120 => _120.parent, 'optionalAccess', _121 => _121.id]), () => ( null)), loc.index + 1), layer: copy };
5242
+ return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _114 => _114.parent, 'optionalAccess', _115 => _115.id]), () => ( null)), loc.index + 1), layer: copy };
5511
5243
  }
5512
5244
  function instancesOf(layers, contentsId) {
5513
- return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
5245
+ return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
5514
5246
  }
5515
5247
  function replaceContents(layers, contentsId, contents, canvas) {
5516
5248
  const ids = instancesOf(layers, contentsId);
5517
5249
  if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
5518
- for (const id of ids) requireUnlocked(_chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
5250
+ for (const id of ids) requireUnlocked(_chunkST7E3NEEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
5519
5251
  const next = { ...contents, id: contentsId };
5520
5252
  let out = layers;
5521
5253
  for (const id of ids) {
5522
- out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, id, (l) => {
5254
+ out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, id, (l) => {
5523
5255
  const layer = l;
5524
5256
  return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
5525
5257
  });
@@ -5543,14 +5275,14 @@ function refitPlacement(layer, contents) {
5543
5275
  });
5544
5276
  const out = { corners: pts };
5545
5277
  if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
5546
- if (layer.placement.warp) out.warp = _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
5278
+ if (layer.placement.warp) out.warp = _chunkLPLCWZTMcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
5547
5279
  return out;
5548
5280
  }
5549
5281
  function normalizeSmartFilter(raw, id = newLayerId("flt")) {
5550
5282
  if (raw.kind === "psd") fail4("Photoshop filters can only come from a PSD; add develop or blur.");
5551
5283
  const base = normalizeFilter(raw, id);
5552
5284
  const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
5553
- if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5285
+ if (!_chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5554
5286
  const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
5555
5287
  if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
5556
5288
  return { ...base, blend, opacity };
@@ -5565,7 +5297,7 @@ function stackOf(layer) {
5565
5297
  return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
5566
5298
  }
5567
5299
  function requireFilter(layer, filterId) {
5568
- const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _122 => _122.smartFilters, 'optionalAccess', _123 => _123.filters]), () => ( []));
5300
+ const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _116 => _116.smartFilters, 'optionalAccess', _117 => _117.filters]), () => ( []));
5569
5301
  const i = list2.findIndex((f) => f.id === filterId);
5570
5302
  if (i === -1) fail4(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
5571
5303
  return i;
@@ -5582,7 +5314,7 @@ function addSmartFilter(layers, id, filter, canvas, index) {
5582
5314
  const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
5583
5315
  filters.splice(at, 0, filter);
5584
5316
  const next = withStack(layer, { ...stack, filters }, canvas);
5585
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
5317
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
5586
5318
  }
5587
5319
  function updateSmartFilter(layers, id, filterId, changes, canvas) {
5588
5320
  const layer = editableSmart(layers, id);
@@ -5594,7 +5326,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
5594
5326
  const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
5595
5327
  if (extra.length) fail4(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
5596
5328
  const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
5597
- if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5329
+ if (!_chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5598
5330
  const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
5599
5331
  if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
5600
5332
  merged2 = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
@@ -5604,7 +5336,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
5604
5336
  const filters = [...layer.smartFilters.filters];
5605
5337
  filters[i] = merged2;
5606
5338
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
5607
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
5339
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
5608
5340
  }
5609
5341
  function removeSmartFilter(layers, id, filterId, canvas) {
5610
5342
  const layer = editableSmart(layers, id);
@@ -5612,7 +5344,7 @@ function removeSmartFilter(layers, id, filterId, canvas) {
5612
5344
  const stack = layer.smartFilters;
5613
5345
  const filters = stack.filters.filter((f) => f.id !== filterId);
5614
5346
  const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
5615
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5347
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5616
5348
  }
5617
5349
  function moveSmartFilter(layers, id, filterId, index, canvas) {
5618
5350
  const layer = editableSmart(layers, id);
@@ -5623,21 +5355,21 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
5623
5355
  const [f] = filters.splice(i, 1);
5624
5356
  filters.splice(index, 0, f);
5625
5357
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
5626
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5358
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5627
5359
  }
5628
5360
  function setSmartFiltersEnabled(layers, id, enabled, canvas) {
5629
5361
  const layer = editableSmart(layers, id);
5630
5362
  const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
5631
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5363
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5632
5364
  }
5633
5365
  function setSmartFilterMask(layers, id, mask, canvas) {
5634
5366
  const layer = editableSmart(layers, id);
5635
- if (_optionalChain([mask, 'optionalAccess', _124 => _124.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5367
+ if (_optionalChain([mask, 'optionalAccess', _118 => _118.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5636
5368
  const stack = { ...stackOf(layer) };
5637
5369
  if (mask) stack.mask = mask;
5638
5370
  else delete stack.mask;
5639
5371
  const next = withStack(layer, stack, canvas);
5640
- return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5372
+ return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5641
5373
  }
5642
5374
  function withFilterMaskSurface(layer, surface, canvas) {
5643
5375
  const stack = stackOf(layer);
@@ -5651,7 +5383,7 @@ function placementBounds(layer) {
5651
5383
  // src/image-editor/layers/serialize.ts
5652
5384
  var LAYERED_SCHEMA_VERSION = 3;
5653
5385
  function serializePatterns(patterns) {
5654
- return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
5386
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkST7E3NEEcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
5655
5387
  }
5656
5388
  function deserializePatterns(raw, problems = []) {
5657
5389
  if (!Array.isArray(raw)) return [];
@@ -5670,15 +5402,51 @@ function deserializePatterns(raw, problems = []) {
5670
5402
  var encodedCache = /* @__PURE__ */ new WeakMap();
5671
5403
  function encodeSurface(surface) {
5672
5404
  if (encodedCache.has(surface)) return encodedCache.get(surface);
5673
- const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
5405
+ const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, surface);
5674
5406
  let out = null;
5675
5407
  if (b) {
5676
- const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, surface, b);
5677
- out = { url: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
5408
+ const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, b);
5409
+ out = { url: _chunkST7E3NEEcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
5678
5410
  }
5679
5411
  encodedCache.set(surface, out);
5680
5412
  return out;
5681
5413
  }
5414
+ var deepCache = /* @__PURE__ */ new WeakMap();
5415
+ function encodeDeepSurface(surface) {
5416
+ if (deepCache.has(surface)) return deepCache.get(surface);
5417
+ let out = null;
5418
+ const depth = _chunkST7E3NEEcjs.surfaceDepth.call(void 0, surface);
5419
+ const b = depth === 8 ? null : _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, surface);
5420
+ if (depth !== 8 && b) {
5421
+ const samples = _chunkST7E3NEEcjs.readDeepRegion.call(void 0, surface, b, depth);
5422
+ const bytes = new Uint8Array(samples.byteLength);
5423
+ const view = new DataView(bytes.buffer);
5424
+ if (samples instanceof Uint16Array) for (let i = 0; i < samples.length; i++) view.setUint16(2 * i, samples[i], true);
5425
+ else for (let i = 0; i < samples.length; i++) view.setFloat32(4 * i, samples[i], true);
5426
+ out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, _chunk643B2HKCcjs.deflate.call(void 0, bytes)) };
5427
+ }
5428
+ deepCache.set(surface, out);
5429
+ return out;
5430
+ }
5431
+ function decodeDeepSurface(surface, raw, problems, label) {
5432
+ const d = raw;
5433
+ if (!d || typeof d !== "object") return surface;
5434
+ try {
5435
+ if (d.depth !== 16 && d.depth !== 32 || !(d.width > 0 && d.height > 0) || !Number.isInteger(d.x) || !Number.isInteger(d.y) || typeof d.data !== "string") throw new Error("malformed");
5436
+ const n = d.width * d.height * 4;
5437
+ const size = d.depth === 16 ? 2 : 4;
5438
+ const bytes = _chunk643B2HKCcjs.inflate.call(void 0, _chunkST7E3NEEcjs.base64ToBytes.call(void 0, d.data), { maxOutput: n * size });
5439
+ if (bytes.length !== n * size) throw new Error("wrong length");
5440
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
5441
+ const samples = d.depth === 16 ? new Uint16Array(n) : new Float32Array(n);
5442
+ if (samples instanceof Uint16Array) for (let i = 0; i < n; i++) samples[i] = view.getUint16(2 * i, true);
5443
+ else for (let i = 0; i < n; i++) samples[i] = view.getFloat32(4 * i, true);
5444
+ return _chunkST7E3NEEcjs.writeDeepRegion.call(void 0, surface, { x: d.x, y: d.y, width: d.width, height: d.height }, samples);
5445
+ } catch (e6) {
5446
+ problems.push(`${label}: its ${d.depth}-bit samples could not be read, so it was opened at 8 bits`);
5447
+ return surface;
5448
+ }
5449
+ }
5682
5450
  function baseFields(layer, ctx) {
5683
5451
  const out = {
5684
5452
  id: layer.id,
@@ -5696,7 +5464,7 @@ function baseFields(layer, ctx) {
5696
5464
  function serializeEffects(effects) {
5697
5465
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
5698
5466
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
5699
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, effects.psd.data) };
5467
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, effects.psd.data) };
5700
5468
  return out;
5701
5469
  }
5702
5470
  function deserializeEffects(raw) {
@@ -5706,12 +5474,12 @@ function deserializeEffects(raw) {
5706
5474
  const p = r.psd;
5707
5475
  if (p && typeof p.key === "string" && typeof p.data === "string") {
5708
5476
  try {
5709
- psd = { key: p.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, p.data) };
5710
- } catch (e6) {
5477
+ psd = { key: p.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, p.data) };
5478
+ } catch (e7) {
5711
5479
  psd = void 0;
5712
5480
  }
5713
5481
  }
5714
- return _chunkPOGBUYWEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5482
+ return _chunkST7E3NEEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5715
5483
  }
5716
5484
  function serializeMask(mask, hint, ctx) {
5717
5485
  const out = { defaultValue: mask.defaultValue };
@@ -5746,7 +5514,11 @@ function serializeLayer(layer, ctx) {
5746
5514
  }
5747
5515
  }
5748
5516
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5749
- if (_optionalChain([layer, 'access', _125 => _125.filters, 'optionalAccess', _126 => _126.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5517
+ if (_optionalChain([layer, 'access', _119 => _119.filters, 'optionalAccess', _120 => _120.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5518
+ if (layer.source !== "document") {
5519
+ const deep = encodeDeepSurface(layer.surface);
5520
+ if (deep) out.deep = deep;
5521
+ }
5750
5522
  return out;
5751
5523
  }
5752
5524
  case "adjustment":
@@ -5784,12 +5556,12 @@ function serializeType(layer, base, ctx) {
5784
5556
  out.x = enc.x;
5785
5557
  out.y = enc.y;
5786
5558
  }
5787
- if (_optionalChain([layer, 'access', _127 => _127.missingFonts, 'optionalAccess', _128 => _128.length])) out.missingFonts = [...layer.missingFonts];
5559
+ if (_optionalChain([layer, 'access', _121 => _121.missingFonts, 'optionalAccess', _122 => _122.length])) out.missingFonts = [...layer.missingFonts];
5788
5560
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5789
- if (_optionalChain([layer, 'access', _129 => _129.psd, 'optionalAccess', _130 => _130.tySh]) || _optionalChain([layer, 'access', _131 => _131.psd, 'optionalAccess', _132 => _132.blocks, 'optionalAccess', _133 => _133.length])) {
5561
+ if (_optionalChain([layer, 'access', _123 => _123.psd, 'optionalAccess', _124 => _124.tySh]) || _optionalChain([layer, 'access', _125 => _125.psd, 'optionalAccess', _126 => _126.blocks, 'optionalAccess', _127 => _127.length])) {
5790
5562
  out.psd = {};
5791
- if (layer.psd.tySh) out.psd.tySh = _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5792
- if (_optionalChain([layer, 'access', _134 => _134.psd, 'access', _135 => _135.blocks, 'optionalAccess', _136 => _136.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) }));
5563
+ if (layer.psd.tySh) out.psd.tySh = _chunkST7E3NEEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5564
+ if (_optionalChain([layer, 'access', _128 => _128.psd, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, b.data) }));
5793
5565
  if (layer.psd.signature) out.psd.signature = layer.psd.signature;
5794
5566
  }
5795
5567
  return out;
@@ -5799,27 +5571,27 @@ function readType(r, base, ctx) {
5799
5571
  try {
5800
5572
  const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
5801
5573
  const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
5802
- length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _137 => _137.length]), 0, 1e9, 0))),
5803
- style: patchTextStyle(DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _138 => _138.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5574
+ length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _131 => _131.length]), 0, 1e9, 0))),
5575
+ style: patchTextStyle(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _132 => _132.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5804
5576
  }));
5805
5577
  const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
5806
- length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _139 => _139.length]), 0, 1e9, 0))),
5807
- style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _140 => _140.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5578
+ length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _133 => _133.length]), 0, 1e9, 0))),
5579
+ style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _134 => _134.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5808
5580
  }));
5809
5581
  const f = r.frame;
5810
- const frame = _optionalChain([f, 'optionalAccess', _141 => _141.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _142 => _142.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5582
+ const frame = _optionalChain([f, 'optionalAccess', _135 => _135.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _136 => _136.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5811
5583
  const m = Array.isArray(r.transform) && r.transform.length === 6 && r.transform.every((v) => typeof v === "number" && Number.isFinite(v)) ? r.transform : void 0;
5812
5584
  const layer = {
5813
5585
  ...base,
5814
5586
  type: "type",
5815
5587
  text: text3,
5816
- runs: fitRuns(runs, text3.length, DEFAULT_TEXT_STYLE),
5817
- paragraphs: fitParagraphRuns(paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
5588
+ runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
5589
+ paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
5818
5590
  frame,
5819
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
5591
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
5820
5592
  offset: { x: 0, y: 0 }
5821
5593
  };
5822
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _143 => _143[0], 'optionalAccess', _144 => _144.style]), () => ( DEFAULT_TEXT_STYLE)) }];
5594
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _137 => _137[0], 'optionalAccess', _138 => _138.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)) }];
5823
5595
  if (m) layer.transform = m;
5824
5596
  if (r.antiAlias === false) layer.antiAlias = false;
5825
5597
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
@@ -5827,16 +5599,16 @@ function readType(r, base, ctx) {
5827
5599
  if (r.annotation && typeof r.annotation === "object" && r.annotation.type === "text") layer.annotation = JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) }));
5828
5600
  if (r.psd && typeof r.psd === "object") {
5829
5601
  const psd = {};
5830
- if (typeof r.psd.tySh === "string") psd.tySh = _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.tySh);
5831
- if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, b.data) }));
5602
+ if (typeof r.psd.tySh === "string") psd.tySh = _chunkST7E3NEEcjs.base64ToBytes.call(void 0, r.psd.tySh);
5603
+ if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, b.data) }));
5832
5604
  if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
5833
- if (psd.tySh || _optionalChain([psd, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) layer.psd = psd;
5605
+ if (psd.tySh || _optionalChain([psd, 'access', _139 => _139.blocks, 'optionalAccess', _140 => _140.length])) layer.psd = psd;
5834
5606
  }
5835
5607
  if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
5836
- const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _147 => _147.text, 'optionalAccess', _148 => _148.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _149 => _149.text, 'optionalAccess', _150 => _150.createCanvas]) };
5608
+ const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _141 => _141.text, 'optionalAccess', _142 => _142.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _143 => _143.text, 'optionalAccess', _144 => _144.createCanvas]) };
5837
5609
  try {
5838
5610
  return rerenderText(layer, env);
5839
- } catch (e7) {
5611
+ } catch (e8) {
5840
5612
  return { ...layer, rendering: "stored" };
5841
5613
  }
5842
5614
  } catch (e) {
@@ -5856,7 +5628,7 @@ function serializeShape(layer, base) {
5856
5628
  if (layer.inverted) out.inverted = true;
5857
5629
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5858
5630
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5859
- if (_optionalChain([layer, 'access', _151 => _151.psd, 'optionalAccess', _152 => _152.blocks, 'optionalAccess', _153 => _153.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5631
+ if (_optionalChain([layer, 'access', _145 => _145.psd, 'optionalAccess', _146 => _146.blocks, 'optionalAccess', _147 => _147.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5860
5632
  return out;
5861
5633
  }
5862
5634
  function readShape(r, base, ctx) {
@@ -5870,12 +5642,12 @@ function readShape(r, base, ctx) {
5870
5642
  if (!data) {
5871
5643
  if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
5872
5644
  const components = r.components.map((c, i) => {
5873
- const op = requireOperation(_optionalChain([c, 'optionalAccess', _154 => _154.op]), `components[${i}].op`);
5874
- if (_optionalChain([c, 'optionalAccess', _155 => _155.live])) {
5645
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _148 => _148.op]), `components[${i}].op`);
5646
+ if (_optionalChain([c, 'optionalAccess', _149 => _149.live])) {
5875
5647
  const live = normalizeLiveShape(c.live, `components[${i}].live`);
5876
5648
  return { op, subpaths: liveShapeSubpaths(live), live };
5877
5649
  }
5878
- return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _156 => _156.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _157 => _157.subpaths]), `components[${i}].subpaths`) };
5650
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _150 => _150.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _151 => _151.subpaths]), `components[${i}].subpaths`) };
5879
5651
  });
5880
5652
  data = {
5881
5653
  components,
@@ -5888,7 +5660,7 @@ function readShape(r, base, ctx) {
5888
5660
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5889
5661
  if (a && shapeFromAnnotation(a)) out.annotation = a;
5890
5662
  if (r.psd && Array.isArray(r.psd.blocks)) {
5891
- const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, b.data) }));
5663
+ const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, b.data) }));
5892
5664
  if (blocks.length) out.psd = { blocks };
5893
5665
  if (out.psd && typeof r.psd.signature === "string") out.psd.signature = r.psd.signature;
5894
5666
  }
@@ -5901,7 +5673,7 @@ function readShape(r, base, ctx) {
5901
5673
  function serializeSmartFilters(stack, layerId, ctx) {
5902
5674
  const out = {
5903
5675
  enabled: stack.enabled,
5904
- filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5676
+ filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5905
5677
  };
5906
5678
  if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
5907
5679
  return out;
@@ -5927,7 +5699,7 @@ function serializeSmartObject(layer, base, ctx) {
5927
5699
  }
5928
5700
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5929
5701
  if (layer.psd) {
5930
- out.psd = { key: layer.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.data) };
5702
+ out.psd = { key: layer.psd.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, layer.psd.data) };
5931
5703
  if (layer.psd.placed) out.psd.placed = layer.psd.placed;
5932
5704
  }
5933
5705
  return out;
@@ -5938,17 +5710,17 @@ function serializeContents(c, ctx) {
5938
5710
  const enc = encodeSurface(c.raster);
5939
5711
  if (enc) {
5940
5712
  if (enc.x !== 0 || enc.y !== 0) {
5941
- const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
5942
- out.asset = ctx.addAsset(_chunkPOGBUYWEcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5713
+ const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
5714
+ out.asset = ctx.addAsset(_chunkST7E3NEEcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5943
5715
  } else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
5944
5716
  }
5945
5717
  }
5946
5718
  if (c.kind === "document" && c.document) {
5947
5719
  out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
5948
5720
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
5949
- if (_optionalChain([c, 'access', _158 => _158.document, 'access', _159 => _159.patterns, 'optionalAccess', _160 => _160.length])) out.patterns = serializePatterns(c.document.patterns);
5721
+ if (_optionalChain([c, 'access', _152 => _152.document, 'access', _153 => _153.patterns, 'optionalAccess', _154 => _154.length])) out.patterns = serializePatterns(c.document.patterns);
5950
5722
  }
5951
- if (c.file) out.file = { type: c.file.type, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, c.file.bytes) };
5723
+ if (c.file) out.file = { type: c.file.type, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, c.file.bytes) };
5952
5724
  if (c.linked) out.linked = { path: c.linked.path };
5953
5725
  return out;
5954
5726
  }
@@ -5984,7 +5756,7 @@ async function serializeLayersExternal(layers, store) {
5984
5756
  for (const [id, url] of Object.entries(inline.assets)) {
5985
5757
  let ref = refs.get(url);
5986
5758
  if (!ref) {
5987
- const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
5759
+ const parsed = _chunkST7E3NEEcjs.parseDataUrl.call(void 0, url);
5988
5760
  const png = decodePngHeader(parsed.bytes);
5989
5761
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
5990
5762
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -6012,7 +5784,7 @@ async function resolveExternalAssets(assets, store, problems) {
6012
5784
  try {
6013
5785
  const blob = await store.get(ref);
6014
5786
  const bytes = new Uint8Array(await blob.arrayBuffer());
6015
- out[id] = `data:image/png;base64,${_chunkPOGBUYWEcjs.bytesToBase64.call(void 0, bytes)}`;
5787
+ out[id] = `data:image/png;base64,${_chunkST7E3NEEcjs.bytesToBase64.call(void 0, bytes)}`;
6016
5788
  } catch (err) {
6017
5789
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
6018
5790
  }
@@ -6020,9 +5792,9 @@ async function resolveExternalAssets(assets, store, problems) {
6020
5792
  return out;
6021
5793
  }
6022
5794
  function decodePngDataUrl(url, channels) {
6023
- const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
5795
+ const parsed = _chunkST7E3NEEcjs.parseDataUrl.call(void 0, url);
6024
5796
  if (!parsed) throw new Error("Asset is not a data URL.");
6025
- const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
5797
+ const png = _chunkST7E3NEEcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
6026
5798
  if (png.channels === channels) return png;
6027
5799
  if (channels === 1) {
6028
5800
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -6040,18 +5812,18 @@ function decodePngDataUrl(url, channels) {
6040
5812
  }
6041
5813
  var num2 = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
6042
5814
  function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
6043
- if (typeof ref !== "string" || !ref) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5815
+ if (typeof ref !== "string" || !ref) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, channels, defaultValue);
6044
5816
  const url = ctx.assets[ref];
6045
5817
  if (typeof url !== "string") {
6046
5818
  ctx.problems.push(`${what}: asset "${ref}" is missing`);
6047
- return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5819
+ return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, channels, defaultValue);
6048
5820
  }
6049
5821
  try {
6050
5822
  const px2 = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
6051
- return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
5823
+ return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
6052
5824
  } catch (err) {
6053
5825
  ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
6054
- return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5826
+ return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, channels, defaultValue);
6055
5827
  }
6056
5828
  }
6057
5829
  function readMask(raw, ctx, what) {
@@ -6059,7 +5831,7 @@ function readMask(raw, ctx, what) {
6059
5831
  const r = raw;
6060
5832
  const defaultValue = r.defaultValue === 255 ? 255 : 0;
6061
5833
  const mask = {
6062
- surface: r.source ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
5834
+ surface: r.source ? _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
6063
5835
  defaultValue: r.source ? 255 : defaultValue
6064
5836
  };
6065
5837
  if (typeof r.density === "number" && r.density !== 1) mask.density = num2(r.density, 0, 1, 1);
@@ -6107,7 +5879,7 @@ function deserializeLayer(raw, ctx) {
6107
5879
  name: typeof r.name === "string" ? r.name : "",
6108
5880
  visible: r.visible !== false,
6109
5881
  opacity: num2(r.opacity, 0, 1, 1),
6110
- blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend)
5882
+ blend: _chunkTFOPHZ3Ucjs.normalizeBlendMode.call(void 0, r.blend)
6111
5883
  };
6112
5884
  if (r.clipped === true) base.clipped = true;
6113
5885
  const mask = readMask(r.mask, ctx, `Layer "${base.name || id}"`);
@@ -6124,10 +5896,11 @@ function deserializeLayer(raw, ctx) {
6124
5896
  const layer = {
6125
5897
  ...base,
6126
5898
  type: "pixel",
6127
- surface: r.source === "document" ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
6128
- offset: { x: Math.round(num2(_optionalChain([r, 'access', _161 => _161.offset, 'optionalAccess', _162 => _162.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _163 => _163.offset, 'optionalAccess', _164 => _164.y]), -1e7, 1e7, 0)) }
5899
+ surface: r.source === "document" ? _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
5900
+ offset: { x: Math.round(num2(_optionalChain([r, 'access', _155 => _155.offset, 'optionalAccess', _156 => _156.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _157 => _157.offset, 'optionalAccess', _158 => _158.y]), -1e7, 1e7, 0)) }
6129
5901
  };
6130
5902
  if (r.source === "document") layer.source = "document";
5903
+ else if (r.deep) layer.surface = decodeDeepSurface(layer.surface, r.deep, ctx.problems, `Layer "${base.name || id}"`);
6131
5904
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
6132
5905
  const filters = readFilters(r.filters);
6133
5906
  if (filters) layer.filters = filters;
@@ -6143,7 +5916,7 @@ function deserializeLayer(raw, ctx) {
6143
5916
  }
6144
5917
  case "group": {
6145
5918
  const children = Array.isArray(r.children) ? r.children.map((c) => deserializeLayer(c, ctx)).filter(Boolean) : [];
6146
- const blend = r.blend === "pass-through" ? "pass-through" : _chunkXIOMMGPDcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
5919
+ const blend = r.blend === "pass-through" ? "pass-through" : _chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
6147
5920
  const group = { ...base, type: "group", blend, children };
6148
5921
  if (r.collapsed === true) group.collapsed = true;
6149
5922
  return group;
@@ -6155,7 +5928,7 @@ function deserializeLayer(raw, ctx) {
6155
5928
  return null;
6156
5929
  }
6157
5930
  const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
6158
- const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _165 => _165.text, 'optionalAccess', _166 => _166.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _167 => _167.text, 'optionalAccess', _168 => _168.createCanvas]) });
5931
+ const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _159 => _159.text, 'optionalAccess', _160 => _160.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _161 => _161.text, 'optionalAccess', _162 => _162.createCanvas]) });
6159
5932
  if (migrated.type === "shape" || migrated.type === "type") {
6160
5933
  const blend = base.blend === "normal" ? migrated.blend : base.blend;
6161
5934
  return { ...migrated, ...base, blend, id, name: base.name };
@@ -6195,15 +5968,15 @@ function readContents(id, ctx) {
6195
5968
  const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
6196
5969
  if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
6197
5970
  try {
6198
- c.file = { type: raw.file.type, bytes: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, raw.file.data) };
6199
- } catch (e8) {
5971
+ c.file = { type: raw.file.type, bytes: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, raw.file.data) };
5972
+ } catch (e9) {
6200
5973
  ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
6201
5974
  }
6202
5975
  }
6203
5976
  if (raw.linked && typeof raw.linked.path === "string") c.linked = { path: raw.linked.path };
6204
5977
  if (c.kind === "raster") {
6205
5978
  if (typeof raw.asset === "string") c.raster = readSurface(raw.asset, 0, 0, 4, 0, ctx, `Smart object contents "${c.name}"`);
6206
- else if (!c.file) c.raster = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
5979
+ else if (!c.file) c.raster = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
6207
5980
  } else {
6208
5981
  const outer = ctx.canvas;
6209
5982
  ctx.canvas = { width, height };
@@ -6226,12 +5999,12 @@ function readSmartFilters(raw, ctx, what) {
6226
5999
  let k = 0;
6227
6000
  for (const f of list2) {
6228
6001
  if (!f || typeof f !== "object") continue;
6229
- const blend = _chunkXIOMMGPDcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
6002
+ const blend = _chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
6230
6003
  const opacity = num2(f.opacity, 0, 1, 1);
6231
6004
  if (f.kind === "psd") {
6232
6005
  try {
6233
- filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
6234
- } catch (e9) {
6006
+ filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
6007
+ } catch (e10) {
6235
6008
  ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
6236
6009
  }
6237
6010
  } else if (f.kind === "develop" || f.kind === "blur") {
@@ -6255,22 +6028,22 @@ function readSmartObject(r, base, ctx) {
6255
6028
  let placement;
6256
6029
  try {
6257
6030
  const raw = { corners: p.corners };
6258
- if (p.warp && _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
6259
- if (_chunkPOGBUYWEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
6031
+ if (p.warp && _chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
6032
+ if (_chunkST7E3NEEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
6260
6033
  placement = normalizePlacement(raw, contents);
6261
6034
  } catch (e) {
6262
6035
  ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
6263
6036
  placement = { corners: [{ x: 0, y: 0 }, { x: contents.width, y: 0 }, { x: contents.width, y: contents.height }, { x: 0, y: contents.height }] };
6264
6037
  }
6265
- const layer = { ...base, type: "smart", contents, placement, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
6038
+ const layer = { ...base, type: "smart", contents, placement, surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
6266
6039
  const filters = readSmartFilters(r.smartFilters, ctx, what);
6267
6040
  if (filters) layer.smartFilters = filters;
6268
6041
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
6269
6042
  if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
6270
6043
  try {
6271
- layer.psd = { key: r.psd.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.data) };
6044
+ layer.psd = { key: r.psd.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, r.psd.data) };
6272
6045
  if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
6273
- } catch (e10) {
6046
+ } catch (e11) {
6274
6047
  }
6275
6048
  }
6276
6049
  if (typeof r.asset === "string") layer.surface = readSurface(r.asset, r.x, r.y, 4, 0, ctx, what);
@@ -6513,7 +6286,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
6513
6286
  function decodeLegacyName(b) {
6514
6287
  try {
6515
6288
  return new TextDecoder("utf-8", { fatal: true }).decode(b);
6516
- } catch (e11) {
6289
+ } catch (e12) {
6517
6290
  return String.fromCharCode(...b);
6518
6291
  }
6519
6292
  }
@@ -6534,7 +6307,7 @@ function descriptor(classId, items = []) {
6534
6307
  return { name: "", classId, items };
6535
6308
  }
6536
6309
  function descGet(d, key) {
6537
- return _optionalChain([d, 'access', _169 => _169.items, 'access', _170 => _170.find, 'call', _171 => _171(([k]) => k === key), 'optionalAccess', _172 => _172[1]]);
6310
+ return _optionalChain([d, 'access', _163 => _163.items, 'access', _164 => _164.find, 'call', _165 => _165(([k]) => k === key), 'optionalAccess', _166 => _166[1]]);
6538
6311
  }
6539
6312
  function descNumber(d, key) {
6540
6313
  const v = descGet(d, key);
@@ -6544,7 +6317,7 @@ function descNumber(d, key) {
6544
6317
  }
6545
6318
  function descBool(d, key) {
6546
6319
  const v = descGet(d, key);
6547
- return _optionalChain([v, 'optionalAccess', _173 => _173.type]) === "bool" ? v.value : void 0;
6320
+ return _optionalChain([v, 'optionalAccess', _167 => _167.type]) === "bool" ? v.value : void 0;
6548
6321
  }
6549
6322
  function descObject(d, key) {
6550
6323
  const v = descGet(d, key);
@@ -7015,7 +6788,7 @@ function parseAdjustmentBlock(key, data) {
7015
6788
  default:
7016
6789
  return null;
7017
6790
  }
7018
- } catch (e12) {
6791
+ } catch (e13) {
7019
6792
  return null;
7020
6793
  }
7021
6794
  }
@@ -7238,7 +7011,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
7238
7011
  const fr = (p) => ({ x: p.x / w, y: p.y / h });
7239
7012
  const subpaths = [];
7240
7013
  components.forEach((c, ci) => {
7241
- _chunkW3GXSUSQcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
7014
+ _chunkLPLCWZTMcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
7242
7015
  if (!sp.anchors.length) return;
7243
7016
  subpaths.push({
7244
7017
  closed: sp.closed,
@@ -7265,12 +7038,12 @@ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
7265
7038
  var obj = (d) => ({ type: "Objc", value: d });
7266
7039
  var enumOf = (d, key) => {
7267
7040
  const v = descGet(d, key);
7268
- return _optionalChain([v, 'optionalAccess', _174 => _174.type]) === "enum" ? v.value : void 0;
7041
+ return _optionalChain([v, 'optionalAccess', _168 => _168.type]) === "enum" ? v.value : void 0;
7269
7042
  };
7270
7043
  function read(data) {
7271
7044
  try {
7272
7045
  return parseVersionedDescriptor(data);
7273
- } catch (e13) {
7046
+ } catch (e14) {
7274
7047
  return null;
7275
7048
  }
7276
7049
  }
@@ -7347,7 +7120,7 @@ function strokeFromVstk(data, dpi, notes) {
7347
7120
  const miter = descNumber(d, "strokeStyleMiterLimit");
7348
7121
  if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
7349
7122
  const dashes = descGet(d, "strokeStyleLineDashSet");
7350
- if (_optionalChain([dashes, 'optionalAccess', _175 => _175.type]) === "VlLs") {
7123
+ if (_optionalChain([dashes, 'optionalAccess', _169 => _169.type]) === "VlLs") {
7351
7124
  const list2 = dashes.items.map((v) => v.type === "UntF" || v.type === "doub" || v.type === "long" ? v.value : NaN).filter((v) => Number.isFinite(v) && v >= 0);
7352
7125
  if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
7353
7126
  }
@@ -7499,7 +7272,7 @@ function vogkBytes(components, dpi) {
7499
7272
  ["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
7500
7273
  ["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
7501
7274
  ["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
7502
- ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _176 => _176.concavity]) ? head.concavity * 100 : 0)]
7275
+ ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _170 => _170.concavity]) ? head.concavity * 100 : 0)]
7503
7276
  ];
7504
7277
  }
7505
7278
  const m = live.transform;
@@ -7532,7 +7305,7 @@ function shapeSignature(layer) {
7532
7305
  return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
7533
7306
  }
7534
7307
  function shapeFromBlocks(blocks, width, height, dpi, notes) {
7535
- const block = (k) => _optionalChain([blocks, 'access', _177 => _177.find, 'call', _178 => _178((b) => b.key === k), 'optionalAccess', _179 => _179.data]);
7308
+ const block = (k) => _optionalChain([blocks, 'access', _171 => _171.find, 'call', _172 => _172((b) => b.key === k), 'optionalAccess', _173 => _173.data]);
7536
7309
  const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
7537
7310
  const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
7538
7311
  if (!path) return null;
@@ -7545,7 +7318,7 @@ function shapeFromBlocks(blocks, width, height, dpi, notes) {
7545
7318
  const d = data && (() => {
7546
7319
  try {
7547
7320
  return parseVersionedDescriptor(data);
7548
- } catch (e14) {
7321
+ } catch (e15) {
7549
7322
  return null;
7550
7323
  }
7551
7324
  })();
@@ -7587,18 +7360,18 @@ function sameExtent(sub, c) {
7587
7360
  return a.every((v, i) => Math.abs(v - b[i]) < 1);
7588
7361
  }
7589
7362
  function shapeBlocks(layer, width, height, dpi, notes) {
7590
- const kept = _optionalChain([layer, 'access', _180 => _180.psd, 'optionalAccess', _181 => _181.blocks]);
7591
- if (_optionalChain([kept, 'optionalAccess', _182 => _182.length]) && _optionalChain([layer, 'access', _183 => _183.psd, 'optionalAccess', _184 => _184.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
7363
+ const kept = _optionalChain([layer, 'access', _174 => _174.psd, 'optionalAccess', _175 => _175.blocks]);
7364
+ if (_optionalChain([kept, 'optionalAccess', _176 => _176.length]) && _optionalChain([layer, 'access', _177 => _177.psd, 'optionalAccess', _178 => _178.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
7592
7365
  const out = [];
7593
7366
  out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
7594
7367
  if (layer.fillRule === "evenodd" && layer.components.some((c) => c.subpaths.length > 1)) notes.add("Even-odd fill rules were written as nonzero (Photoshop fills shapes nonzero)");
7595
7368
  const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
7596
- if (_optionalChain([layer, 'access', _185 => _185.fill, 'optionalAccess', _186 => _186.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
7369
+ if (_optionalChain([layer, 'access', _179 => _179.fill, 'optionalAccess', _180 => _180.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
7597
7370
  out.push({ key: "vscg", data: vscgBytes(fill) });
7598
7371
  if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
7599
7372
  const vogk = vogkBytes(layer.components, dpi);
7600
7373
  if (vogk) out.push({ key: "vogk", data: vogk });
7601
- if (layer.components.some((c) => _optionalChain([c, 'access', _187 => _187.live, 'optionalAccess', _188 => _188.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
7374
+ if (layer.components.some((c) => _optionalChain([c, 'access', _181 => _181.live, 'optionalAccess', _182 => _182.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
7602
7375
  notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
7603
7376
  }
7604
7377
  return out;
@@ -7807,7 +7580,7 @@ var E = {
7807
7580
  bool: (value) => ({ t: "bool", value })
7808
7581
  };
7809
7582
  function eGet(v, key) {
7810
- return _optionalChain([v, 'optionalAccess', _189 => _189.t]) === "dict" ? _optionalChain([v, 'access', _190 => _190.items, 'access', _191 => _191.find, 'call', _192 => _192(([k]) => k === key), 'optionalAccess', _193 => _193[1]]) : void 0;
7583
+ return _optionalChain([v, 'optionalAccess', _183 => _183.t]) === "dict" ? _optionalChain([v, 'access', _184 => _184.items, 'access', _185 => _185.find, 'call', _186 => _186(([k]) => k === key), 'optionalAccess', _187 => _187[1]]) : void 0;
7811
7584
  }
7812
7585
  function ePath(v, keys) {
7813
7586
  return keys.reduce((at, k) => eGet(at, k), v);
@@ -7825,7 +7598,7 @@ function eStr(v) {
7825
7598
  return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
7826
7599
  }
7827
7600
  function eArray(v) {
7828
- return _optionalChain([v, 'optionalAccess', _194 => _194.t]) === "array" ? v.items : [];
7601
+ return _optionalChain([v, 'optionalAccess', _188 => _188.t]) === "array" ? v.items : [];
7829
7602
  }
7830
7603
  function eSet(d, key, value) {
7831
7604
  if (d.t !== "dict") return;
@@ -7852,12 +7625,12 @@ function parseTySh(data) {
7852
7625
  try {
7853
7626
  r.u16();
7854
7627
  warp = readVersionedDescriptor(r);
7855
- } catch (e15) {
7628
+ } catch (e16) {
7856
7629
  r.pos = at;
7857
7630
  }
7858
7631
  }
7859
7632
  return { transform: m, text: text3, warp, tail: r.rest() };
7860
- } catch (e16) {
7633
+ } catch (e17) {
7861
7634
  return null;
7862
7635
  }
7863
7636
  }
@@ -7927,7 +7700,7 @@ function fontFromPostScript(ps) {
7927
7700
  }
7928
7701
  family += suffix;
7929
7702
  const s = style.toLowerCase();
7930
- const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _195 => _195.find, 'call', _196 => _196(([re]) => re.test(s)), 'optionalAccess', _197 => _197[1]]), () => ( 400));
7703
+ const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _189 => _189.find, 'call', _190 => _190(([re]) => re.test(s)), 'optionalAccess', _191 => _191[1]]), () => ( 400));
7931
7704
  return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
7932
7705
  }
7933
7706
  var STYLE_NAMES = [
@@ -7952,7 +7725,7 @@ var hex22 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).pa
7952
7725
  function merged(levels) {
7953
7726
  const items = [];
7954
7727
  for (const l of levels) {
7955
- if (_optionalChain([l, 'optionalAccess', _198 => _198.t]) !== "dict") continue;
7728
+ if (_optionalChain([l, 'optionalAccess', _192 => _192.t]) !== "dict") continue;
7956
7729
  for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
7957
7730
  }
7958
7731
  return E.dict(items);
@@ -7960,7 +7733,7 @@ function merged(levels) {
7960
7733
  function charStyle(d, fonts, notes) {
7961
7734
  const n = (k) => eNum(eGet(d, k));
7962
7735
  const flag = (k) => eBool(eGet(d, k));
7963
- const s = { ...DEFAULT_TEXT_STYLE };
7736
+ const s = { ..._chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE };
7964
7737
  const fi = n("Font");
7965
7738
  const ps = fi !== void 0 ? fonts[fi] : void 0;
7966
7739
  if (ps) {
@@ -8023,27 +7796,27 @@ function typeFromTySh(data, notes) {
8023
7796
  const t = parseTySh(data);
8024
7797
  if (!t) return null;
8025
7798
  const txtV = descGet(t.text, "Txt ");
8026
- const txt = _optionalChain([txtV, 'optionalAccess', _199 => _199.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
7799
+ const txt = _optionalChain([txtV, 'optionalAccess', _193 => _193.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
8027
7800
  const ed = descGet(t.text, "EngineData");
8028
7801
  let engine = null;
8029
- if (_optionalChain([ed, 'optionalAccess', _200 => _200.type]) === "tdta") {
7802
+ if (_optionalChain([ed, 'optionalAccess', _194 => _194.type]) === "tdta") {
8030
7803
  try {
8031
7804
  engine = parseEngineData(ed.data);
8032
- } catch (e17) {
7805
+ } catch (e18) {
8033
7806
  notes.add("the text engine data could not be read; the text came in in one style");
8034
7807
  }
8035
7808
  }
8036
7809
  const anti = descGet(t.text, "AntA");
8037
- const antiAlias = !(_optionalChain([anti, 'optionalAccess', _201 => _201.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
7810
+ const antiAlias = !(_optionalChain([anti, 'optionalAccess', _195 => _195.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
8038
7811
  const ornt = descGet(t.text, "Ornt");
8039
- if (_optionalChain([ornt, 'optionalAccess', _202 => _202.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
7812
+ if (_optionalChain([ornt, 'optionalAccess', _196 => _196.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
8040
7813
  if (t.warp) {
8041
7814
  const style = descGet(t.warp, "warpStyle");
8042
- if (_optionalChain([style, 'optionalAccess', _203 => _203.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
7815
+ if (_optionalChain([style, 'optionalAccess', _197 => _197.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
8043
7816
  }
8044
7817
  const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
8045
7818
  const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
8046
- let runs = [{ length: text3.length, style: { ...DEFAULT_TEXT_STYLE } }];
7819
+ let runs = [{ length: text3.length, style: { ..._chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE } }];
8047
7820
  let paragraphs = [{ length: text3.length, style: {} }];
8048
7821
  let frame = { kind: "point" };
8049
7822
  let transform = t.transform;
@@ -8088,7 +7861,7 @@ function typeFromTySh(data, notes) {
8088
7861
  let at = 0;
8089
7862
  runs = ssheets.map((sheet, i) => {
8090
7863
  const own = named(styleSet, sheet);
8091
- const paraDefault = _optionalChain([paraBases, 'access', _204 => _204[paraAt(at)], 'optionalAccess', _205 => _205.charDefault]);
7864
+ const paraDefault = _optionalChain([paraBases, 'access', _198 => _198[paraAt(at)], 'optionalAccess', _199 => _199.charDefault]);
8092
7865
  at += _nullishCoalesce(slens[i], () => ( 0));
8093
7866
  const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
8094
7867
  return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes) };
@@ -8099,14 +7872,14 @@ function typeFromTySh(data, notes) {
8099
7872
  const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
8100
7873
  if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
8101
7874
  frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
8102
- transform = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
7875
+ transform = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
8103
7876
  }
8104
7877
  }
8105
7878
  }
8106
7879
  return {
8107
7880
  text: text3,
8108
- runs: fitRuns(runs, text3.length, DEFAULT_TEXT_STYLE),
8109
- paragraphs: fitParagraphRuns(paragraphs, text3),
7881
+ runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
7882
+ paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs, text3),
8110
7883
  frame,
8111
7884
  transform,
8112
7885
  antiAlias,
@@ -8167,8 +7940,8 @@ var fontEntry = (name) => E.dict([
8167
7940
  ["Synthetic", E.int(0)]
8168
7941
  ]);
8169
7942
  function buildEngineData(layer, template) {
8170
- const e = _optionalChain([template, 'optionalAccess', _206 => _206.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
8171
- if (_optionalChain([eGet, 'call', _207 => _207(e, "EngineDict"), 'optionalAccess', _208 => _208.t]) !== "dict") eSet(e, "EngineDict", E.dict());
7943
+ const e = _optionalChain([template, 'optionalAccess', _200 => _200.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
7944
+ if (_optionalChain([eGet, 'call', _201 => _201(e, "EngineDict"), 'optionalAccess', _202 => _202.t]) !== "dict") eSet(e, "EngineDict", E.dict());
8172
7945
  const dict = eGet(e, "EngineDict");
8173
7946
  const text3 = layer.text.replace(/\n/g, "\r");
8174
7947
  const edText = `${text3}\r`;
@@ -8180,7 +7953,7 @@ function buildEngineData(layer, template) {
8180
7953
  fonts.push(ps);
8181
7954
  return fonts.length - 1;
8182
7955
  };
8183
- const runs = fitRuns(layer.runs, layer.text.length, DEFAULT_TEXT_STYLE);
7956
+ const runs = _chunkLPLCWZTMcjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE);
8184
7957
  const sruns = [];
8185
7958
  const slens = [];
8186
7959
  runs.forEach((r, i) => {
@@ -8188,10 +7961,10 @@ function buildEngineData(layer, template) {
8188
7961
  slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
8189
7962
  });
8190
7963
  if (!runs.length) {
8191
- sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(DEFAULT_TEXT_STYLE)))]])]]));
7964
+ sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)))]])]]));
8192
7965
  slens.push(E.int(1));
8193
7966
  }
8194
- const paras = fitParagraphRuns(layer.paragraphs, layer.text);
7967
+ const paras = _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
8195
7968
  const pruns = [];
8196
7969
  const plens = [];
8197
7970
  paras.forEach((p, i) => {
@@ -8247,7 +8020,7 @@ function buildEngineData(layer, template) {
8247
8020
  eSet(e, key, rd);
8248
8021
  }
8249
8022
  eSet(rd, "FontSet", fontSet);
8250
- if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _209 => _209[0], 'optionalAccess', _210 => _210.style]), () => ( DEFAULT_TEXT_STYLE)), 0)]])]));
8023
+ if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _203 => _203[0], 'optionalAccess', _204 => _204.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8251
8024
  if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
8252
8025
  if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
8253
8026
  if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
@@ -8256,27 +8029,27 @@ function buildEngineData(layer, template) {
8256
8029
  }
8257
8030
  function inkBounds2(layer) {
8258
8031
  if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
8259
- const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
8032
+ const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
8260
8033
  if (!b) return [0, 0, 0, 0];
8261
- const inv = _chunkW3GXSUSQcjs.invertMatrix.call(void 0, textMatrix(layer));
8034
+ const inv = _chunkLPLCWZTMcjs.invertMatrix.call(void 0, textMatrix(layer));
8262
8035
  const pts = [
8263
8036
  { x: b.x, y: b.y },
8264
8037
  { x: b.x + b.width, y: b.y },
8265
8038
  { x: b.x + b.width, y: b.y + b.height },
8266
8039
  { x: b.x, y: b.y + b.height }
8267
- ].map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, inv, p));
8040
+ ].map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, inv, p));
8268
8041
  return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
8269
8042
  }
8270
8043
  function tyShForLayer(layer) {
8271
- const raw = _optionalChain([layer, 'access', _211 => _211.psd, 'optionalAccess', _212 => _212.tySh]);
8272
- if (raw && _optionalChain([layer, 'access', _213 => _213.psd, 'optionalAccess', _214 => _214.signature]) === typeSignature(layer)) return raw;
8044
+ const raw = _optionalChain([layer, 'access', _205 => _205.psd, 'optionalAccess', _206 => _206.tySh]);
8045
+ if (raw && _optionalChain([layer, 'access', _207 => _207.psd, 'optionalAccess', _208 => _208.signature]) === typeSignature(layer)) return raw;
8273
8046
  const old = raw ? parseTySh(raw) : null;
8274
8047
  const oldEd = old ? descGet(old.text, "EngineData") : void 0;
8275
8048
  let template = null;
8276
- if (_optionalChain([oldEd, 'optionalAccess', _215 => _215.type]) === "tdta") {
8049
+ if (_optionalChain([oldEd, 'optionalAccess', _209 => _209.type]) === "tdta") {
8277
8050
  try {
8278
8051
  template = parseEngineData(oldEd.data);
8279
- } catch (e18) {
8052
+ } catch (e19) {
8280
8053
  template = null;
8281
8054
  }
8282
8055
  }
@@ -8305,8 +8078,8 @@ function tyShForLayer(layer) {
8305
8078
  set("boundingBox", rect("boundingBox"));
8306
8079
  if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
8307
8080
  set("EngineData", { type: "tdta", data: writeEngineData(engine) });
8308
- const warpStyle = _optionalChain([old, 'optionalAccess', _216 => _216.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8309
- const warp = _optionalChain([old, 'optionalAccess', _217 => _217.warp]) && _optionalChain([warpStyle, 'optionalAccess', _218 => _218.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8081
+ const warpStyle = _optionalChain([old, 'optionalAccess', _210 => _210.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8082
+ const warp = _optionalChain([old, 'optionalAccess', _211 => _211.warp]) && _optionalChain([warpStyle, 'optionalAccess', _212 => _212.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8310
8083
  return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
8311
8084
  }
8312
8085
 
@@ -8375,9 +8148,9 @@ function packbitsDecodeInto(src, expected, out, at) {
8375
8148
  function inflateChecked(data, expected) {
8376
8149
  let out;
8377
8150
  try {
8378
- out = _chunkPOGBUYWEcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
8151
+ out = _chunk643B2HKCcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
8379
8152
  } catch (e) {
8380
- throw new PsdError(`ZIP channel data: ${e instanceof _chunkPOGBUYWEcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
8153
+ throw new PsdError(`ZIP channel data: ${e instanceof _chunk643B2HKCcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
8381
8154
  }
8382
8155
  if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
8383
8156
  return out.length === expected ? out : out.subarray(0, expected);
@@ -8465,6 +8238,36 @@ function encodeRle(decoded2, l) {
8465
8238
  out.set(packed.subarray(0, at), counts.length);
8466
8239
  return out;
8467
8240
  }
8241
+ function predict(buf, l) {
8242
+ const rb = rowBytes(l.width, l.depth);
8243
+ if (rb === 0) return;
8244
+ const w = l.width;
8245
+ const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
8246
+ for (let o = 0; o + rb <= buf.length; o += rb) {
8247
+ if (l.depth === 1 || l.depth === 8) {
8248
+ for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
8249
+ } else if (l.depth === 16) {
8250
+ for (let i = w - 1; i > 0; i--) {
8251
+ const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
8252
+ const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
8253
+ const v = a - b & 65535;
8254
+ buf[o + 2 * i] = v >> 8;
8255
+ buf[o + 2 * i + 1] = v & 255;
8256
+ }
8257
+ } else if (l.depth === 32) {
8258
+ scratch.set(buf.subarray(o, o + rb));
8259
+ for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + k * w + i] = scratch[4 * i + k];
8260
+ for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
8261
+ } else {
8262
+ throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
8263
+ }
8264
+ }
8265
+ }
8266
+ function encodeZipPredicted(decoded2, l) {
8267
+ const buf = decoded2.slice();
8268
+ predict(buf, l);
8269
+ return _chunk643B2HKCcjs.deflate.call(void 0, buf);
8270
+ }
8468
8271
 
8469
8272
  // src/image-editor/psd/smart.ts
8470
8273
  var dbl2 = (value) => ({ type: "doub", value });
@@ -8476,15 +8279,15 @@ var textV = (value) => ({ type: "TEXT", value });
8476
8279
  var obj2 = (d) => ({ type: "Objc", value: d });
8477
8280
  var text = (d, key) => {
8478
8281
  const v = descGet(d, key);
8479
- return _optionalChain([v, 'optionalAccess', _219 => _219.type]) === "TEXT" ? v.value : void 0;
8282
+ return _optionalChain([v, 'optionalAccess', _213 => _213.type]) === "TEXT" ? v.value : void 0;
8480
8283
  };
8481
8284
  var enumOf2 = (d, key) => {
8482
8285
  const v = descGet(d, key);
8483
- return _optionalChain([v, 'optionalAccess', _220 => _220.type]) === "enum" ? v.value : void 0;
8286
+ return _optionalChain([v, 'optionalAccess', _214 => _214.type]) === "enum" ? v.value : void 0;
8484
8287
  };
8485
8288
  var numbers = (d, key) => {
8486
8289
  const v = descGet(d, key);
8487
- if (_optionalChain([v, 'optionalAccess', _221 => _221.type]) !== "VlLs") return null;
8290
+ if (_optionalChain([v, 'optionalAccess', _215 => _215.type]) !== "VlLs") return null;
8488
8291
  const out = [];
8489
8292
  for (const it of v.items) {
8490
8293
  if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
@@ -8528,7 +8331,7 @@ function readLinkedItem(item) {
8528
8331
  try {
8529
8332
  const d = readVersionedDescriptor(r);
8530
8333
  path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
8531
- } catch (e19) {
8334
+ } catch (e20) {
8532
8335
  path = void 0;
8533
8336
  }
8534
8337
  void version;
@@ -8545,7 +8348,7 @@ function parseLinkedFiles(data) {
8545
8348
  try {
8546
8349
  const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
8547
8350
  if (item) out.push(item);
8548
- } catch (e20) {
8351
+ } catch (e21) {
8549
8352
  }
8550
8353
  at = at + 8 + len + 3 & ~3;
8551
8354
  }
@@ -8672,21 +8475,21 @@ function filterMaskFromItem(item) {
8672
8475
  const height = rect.bottom - rect.top;
8673
8476
  if (!(width > 0 && height > 0) || width * height > 1 << 28) return null;
8674
8477
  const bytes = decodePlanes(plane.compression, plane.data, { planes: 1, width, height, depth: 8, psb: true });
8675
- const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
8478
+ const surface = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
8676
8479
  return { surface, defaultValue: 255 };
8677
8480
  }
8678
8481
  function filterMaskItem(placed, mask, area) {
8679
- const painted = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
8482
+ const painted = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, mask.surface);
8680
8483
  let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
8681
8484
  if (mask.defaultValue !== 255 && area) {
8682
- const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _222 => _222.x]), () => ( area.x)));
8683
- const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _223 => _223.y]), () => ( area.y)));
8485
+ const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _216 => _216.x]), () => ( area.x)));
8486
+ const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _217 => _217.y]), () => ( area.y)));
8684
8487
  const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
8685
8488
  const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
8686
8489
  b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
8687
8490
  }
8688
8491
  const rect = { top: b.y, left: b.x, bottom: b.y + b.height, right: b.x + b.width };
8689
- const values = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, b);
8492
+ const values = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, b);
8690
8493
  const plane = new Uint8Array(values.buffer, values.byteOffset, values.length);
8691
8494
  return {
8692
8495
  id: placed,
@@ -8700,8 +8503,8 @@ function filterMaskItem(placed, mask, area) {
8700
8503
  }
8701
8504
  var warpStyleOf = (name) => {
8702
8505
  if (!name.startsWith("warp")) return null;
8703
- const s = _optionalChain([name, 'access', _224 => _224[4], 'optionalAccess', _225 => _225.toLowerCase, 'call', _226 => _226()]) + name.slice(5);
8704
- return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
8506
+ const s = _optionalChain([name, 'access', _218 => _218[4], 'optionalAccess', _219 => _219.toLowerCase, 'call', _220 => _220()]) + name.slice(5);
8507
+ return _chunkLPLCWZTMcjs.WARP_STYLES.includes(s) ? s : null;
8705
8508
  };
8706
8509
  function warpFromDescriptor(w, contents) {
8707
8510
  const full = { x: 0, y: 0, width: contents.width, height: contents.height };
@@ -8722,7 +8525,7 @@ function warpFromDescriptor(w, contents) {
8722
8525
  if (!arr || arr.type !== "ObAr") return void 0;
8723
8526
  const xs = descGet(arr.body, "Hrzn");
8724
8527
  const ys = descGet(arr.body, "Vrtc");
8725
- if (_optionalChain([xs, 'optionalAccess', _227 => _227.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _228 => _228.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
8528
+ if (_optionalChain([xs, 'optionalAccess', _221 => _221.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _222 => _222.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
8726
8529
  mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
8727
8530
  const px2 = mesh.points.map((p) => p.x);
8728
8531
  const py = mesh.points.map((p) => p.y);
@@ -8731,7 +8534,7 @@ function warpFromDescriptor(w, contents) {
8731
8534
  } else {
8732
8535
  const style = warpStyleOf(styleName);
8733
8536
  if (!style) return void 0;
8734
- mesh = _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0,
8537
+ mesh = _chunkLPLCWZTMcjs.warpPresetMesh.call(void 0,
8735
8538
  {
8736
8539
  style,
8737
8540
  bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
@@ -8746,7 +8549,7 @@ function warpFromDescriptor(w, contents) {
8746
8549
  const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
8747
8550
  if (!same) {
8748
8551
  const m = mesh;
8749
- mesh = _chunkW3GXSUSQcjs.fitWarpMesh.call(void 0, (s, t) => _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
8552
+ mesh = _chunkLPLCWZTMcjs.fitWarpMesh.call(void 0, (s, t) => _chunkLPLCWZTMcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
8750
8553
  }
8751
8554
  return { mesh, frame };
8752
8555
  }
@@ -8843,13 +8646,13 @@ function parsePlaced(key, data) {
8843
8646
  r.u32();
8844
8647
  try {
8845
8648
  warp = readVersionedDescriptor(r);
8846
- } catch (e21) {
8649
+ } catch (e22) {
8847
8650
  warp = void 0;
8848
8651
  }
8849
8652
  }
8850
8653
  return { key, idnt, placed: idnt, quad, warp };
8851
8654
  }
8852
- } catch (e22) {
8655
+ } catch (e23) {
8853
8656
  return null;
8854
8657
  }
8855
8658
  return null;
@@ -8889,13 +8692,13 @@ function blendOptions(f) {
8889
8692
  function smartFiltersFromPsd(fx, newId, notes) {
8890
8693
  const filters = [];
8891
8694
  const list2 = descGet(fx, "filterFXList");
8892
- for (const v of _optionalChain([list2, 'optionalAccess', _229 => _229.type]) === "VlLs" ? list2.items : []) {
8695
+ for (const v of _optionalChain([list2, 'optionalAccess', _223 => _223.type]) === "VlLs" ? list2.items : []) {
8893
8696
  if (v.type !== "Objc" && v.type !== "GlbO") continue;
8894
8697
  const item = v.value;
8895
8698
  const { blend, opacity } = blendOptionsOf(item);
8896
8699
  const enabled = descBool(item, "enab") !== false;
8897
8700
  const fltr = descObject(item, "Fltr");
8898
- const radius = _optionalChain([fltr, 'optionalAccess', _230 => _230.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
8701
+ const radius = _optionalChain([fltr, 'optionalAccess', _224 => _224.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
8899
8702
  if (radius !== void 0 && radius >= 0 && radius <= 50) {
8900
8703
  filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
8901
8704
  continue;
@@ -9174,7 +8977,7 @@ function parseMask(d) {
9174
8977
  }
9175
8978
  if (!realFirst) m.real = readReal();
9176
8979
  return m;
9177
- } catch (e23) {
8980
+ } catch (e24) {
9178
8981
  return void 0;
9179
8982
  }
9180
8983
  }
@@ -9248,14 +9051,14 @@ function readPsd(bytes) {
9248
9051
  return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
9249
9052
  }
9250
9053
  function layerBlock(rec, key) {
9251
- return _optionalChain([rec, 'access', _231 => _231.blocks, 'access', _232 => _232.find, 'call', _233 => _233((b) => b.key === key), 'optionalAccess', _234 => _234.data]);
9054
+ return _optionalChain([rec, 'access', _225 => _225.blocks, 'access', _226 => _226.find, 'call', _227 => _227((b) => b.key === key), 'optionalAccess', _228 => _228.data]);
9252
9055
  }
9253
9056
  function layerName(rec) {
9254
9057
  const luni = layerBlock(rec, "luni");
9255
9058
  if (luni) {
9256
9059
  try {
9257
9060
  return new PsdReader(luni).unicode();
9258
- } catch (e24) {
9061
+ } catch (e25) {
9259
9062
  }
9260
9063
  }
9261
9064
  return rec.legacyName;
@@ -9279,7 +9082,7 @@ function u8Block(rec, key) {
9279
9082
  function layerTree(file) {
9280
9083
  const stack = [[]];
9281
9084
  file.layers.forEach((rec, index) => {
9282
- const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _235 => _235(rec), 'optionalAccess', _236 => _236.kind]), () => ( SECTION_OTHER));
9085
+ const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _229 => _229(rec), 'optionalAccess', _230 => _230.kind]), () => ( SECTION_OTHER));
9283
9086
  if (kind === SECTION_DIVIDER) {
9284
9087
  stack.push([]);
9285
9088
  } else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
@@ -9297,7 +9100,7 @@ function layerTree(file) {
9297
9100
  }
9298
9101
  function channelRect(rec, id) {
9299
9102
  if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
9300
- if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _237 => _237.mask, 'access', _238 => _238.real, 'optionalAccess', _239 => _239.rect]), () => ( rec.mask.rect));
9103
+ if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _231 => _231.mask, 'access', _232 => _232.real, 'optionalAccess', _233 => _233.rect]), () => ( rec.mask.rect));
9301
9104
  return rec.rect;
9302
9105
  }
9303
9106
  function decodeLayerChannel(file, rec, id) {
@@ -9315,7 +9118,7 @@ function decodeMergedImage(file) {
9315
9118
  return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
9316
9119
  }
9317
9120
  function resource(file, id) {
9318
- return _optionalChain([file, 'access', _240 => _240.resources, 'access', _241 => _241.find, 'call', _242 => _242((r) => r.id === id), 'optionalAccess', _243 => _243.data]);
9121
+ return _optionalChain([file, 'access', _234 => _234.resources, 'access', _235 => _235.find, 'call', _236 => _236((r) => r.id === id), 'optionalAccess', _237 => _237.data]);
9319
9122
  }
9320
9123
  function resolution(file) {
9321
9124
  const d = resource(file, 1005);
@@ -9405,23 +9208,31 @@ function writePsd(file, encodeName) {
9405
9208
  w.endLen(res);
9406
9209
  const lm = w.beginLen(psb);
9407
9210
  if (file.layers.length || file.globalBlocks.length) {
9408
- const li = w.beginLen(psb);
9409
- if (file.layers.length) {
9410
- const start = w.length;
9411
- w.i16(file.mergedAlpha ? -file.layers.length : file.layers.length);
9412
- for (const rec of file.layers) writeLayerRecord(w, rec, psb, encodeName(rec.legacyName));
9211
+ const writeLayerInfo = (out) => {
9212
+ const start = out.length;
9213
+ out.i16(file.mergedAlpha ? -file.layers.length : file.layers.length);
9214
+ for (const rec of file.layers) writeLayerRecord(out, rec, psb, encodeName(rec.legacyName));
9413
9215
  for (const rec of file.layers) {
9414
9216
  for (const c of rec.channels) {
9415
9217
  if (c.compression === null) continue;
9416
- w.u16(c.compression);
9417
- w.bytes(c.data);
9218
+ out.u16(c.compression);
9219
+ out.bytes(c.data);
9418
9220
  }
9419
9221
  }
9420
- if ((w.length - start) % 2) w.u8(0);
9421
- }
9222
+ if ((out.length - start) % 2) out.u8(0);
9223
+ };
9224
+ const deepKey = header.depth === 16 ? "Lr16" : header.depth === 32 ? "Lr32" : null;
9225
+ let blocks = file.globalBlocks;
9226
+ const li = w.beginLen(psb);
9227
+ if (file.layers.length && !deepKey) writeLayerInfo(w);
9422
9228
  w.endLen(li);
9229
+ if (file.layers.length && deepKey) {
9230
+ const lw = new PsdWriter();
9231
+ writeLayerInfo(lw);
9232
+ blocks = [{ key: deepKey, data: lw.result() }, ...blocks];
9233
+ }
9423
9234
  w.u32(0);
9424
- writeBlocks(w, file.globalBlocks, psb, 4);
9235
+ writeBlocks(w, blocks, psb, 4);
9425
9236
  }
9426
9237
  w.endLen(lm);
9427
9238
  w.u16(file.imageCompression);
@@ -9430,6 +9241,7 @@ function writePsd(file, encodeName) {
9430
9241
  }
9431
9242
 
9432
9243
  // src/image-editor/psd/pixels.ts
9244
+ var MODE_BITMAP = 0;
9433
9245
  var MODE_INDEXED = 2;
9434
9246
  var MODE_RGB = 3;
9435
9247
  var MODE_CMYK = 4;
@@ -9553,6 +9365,99 @@ function toRgba8(set) {
9553
9365
  }
9554
9366
  return out;
9555
9367
  }
9368
+ function toRgbaDeep(set) {
9369
+ const { width, height, depth, mode } = set;
9370
+ if (depth !== 16 && depth !== 32 || mode === MODE_INDEXED || mode === MODE_BITMAP) return null;
9371
+ const n = width * height;
9372
+ const isLab = mode === MODE_LAB;
9373
+ const cmyk = mode === MODE_CMYK;
9374
+ const raw = (plane, fill) => {
9375
+ if (!plane) return () => fill;
9376
+ if (depth === 16) return (i) => (plane[2 * i] << 8 | plane[2 * i + 1]) / 65535;
9377
+ const view = new DataView(plane.buffer, plane.byteOffset, plane.byteLength);
9378
+ return (i) => view.getFloat32(4 * i, false) || 0;
9379
+ };
9380
+ const planes = set.color.map((p) => raw(p, cmyk ? 1 : 0));
9381
+ const alpha = raw(set.alpha, 1);
9382
+ if (depth === 16) {
9383
+ const out2 = new Uint16Array(n * 4);
9384
+ const q2 = (v) => Math.round(clamp012(v) * 65535);
9385
+ for (let i = 0, o = 0; i < n; i++, o += 4) {
9386
+ let r;
9387
+ let g;
9388
+ let b;
9389
+ if (mode === MODE_CMYK) {
9390
+ const k = planes[3] ? planes[3](i) : 1;
9391
+ r = planes[0](i) * k;
9392
+ g = planes[1](i) * k;
9393
+ b = planes[2](i) * k;
9394
+ } else if (isLab) {
9395
+ [r, g, b] = labToSrgb(planes[0](i) * 100, planes[1](i) * 255 - 128, planes[2](i) * 255 - 128);
9396
+ } else if (mode === MODE_RGB || mode === MODE_MULTICHANNEL) {
9397
+ r = planes[0](i);
9398
+ g = planes[1] ? planes[1](i) : r;
9399
+ b = planes[2] ? planes[2](i) : r;
9400
+ } else r = g = b = planes[0](i);
9401
+ out2[o] = q2(r);
9402
+ out2[o + 1] = q2(g);
9403
+ out2[o + 2] = q2(b);
9404
+ out2[o + 3] = q2(alpha(i));
9405
+ }
9406
+ return out2;
9407
+ }
9408
+ const out = new Float32Array(n * 4);
9409
+ for (let i = 0, o = 0; i < n; i++, o += 4) {
9410
+ let r;
9411
+ let g;
9412
+ let b;
9413
+ if (isLab) {
9414
+ [r, g, b] = labToSrgb(planes[0](i) * 100, planes[1](i) * 255 - 128, planes[2](i) * 255 - 128).map(srgbToLinear);
9415
+ } else if (cmyk) {
9416
+ const k = planes[3] ? planes[3](i) : 1;
9417
+ r = planes[0](i) * k;
9418
+ g = planes[1](i) * k;
9419
+ b = planes[2](i) * k;
9420
+ } else if (mode === MODE_RGB || mode === MODE_MULTICHANNEL) {
9421
+ r = planes[0](i);
9422
+ g = planes[1] ? planes[1](i) : r;
9423
+ b = planes[2] ? planes[2](i) : r;
9424
+ } else r = g = b = planes[0](i);
9425
+ out[o] = r;
9426
+ out[o + 1] = g;
9427
+ out[o + 2] = b;
9428
+ out[o + 3] = clamp012(alpha(i));
9429
+ }
9430
+ return out;
9431
+ }
9432
+ function deepToPlanes(data, n) {
9433
+ const bytes = data instanceof Uint16Array ? 2 : 4;
9434
+ const planes = [0, 1, 2, 3].map(() => new Uint8Array(n * bytes));
9435
+ if (data instanceof Uint16Array) {
9436
+ for (let i = 0; i < n; i++) {
9437
+ for (let c = 0; c < 4; c++) {
9438
+ const v = data[i * 4 + c];
9439
+ planes[c][2 * i] = v >> 8;
9440
+ planes[c][2 * i + 1] = v & 255;
9441
+ }
9442
+ }
9443
+ } else {
9444
+ const views = planes.map((p) => new DataView(p.buffer));
9445
+ for (let i = 0; i < n; i++) for (let c = 0; c < 4; c++) views[c].setFloat32(4 * i, data[i * 4 + c], false);
9446
+ }
9447
+ return planes;
9448
+ }
9449
+ function planeAtDepth(plane, depth) {
9450
+ if (depth === 8) return plane;
9451
+ if (depth === 16) {
9452
+ const out2 = new Uint8Array(plane.length * 2);
9453
+ for (let i = 0; i < plane.length; i++) out2[2 * i] = out2[2 * i + 1] = plane[i];
9454
+ return out2;
9455
+ }
9456
+ const out = new Uint8Array(plane.length * 4);
9457
+ const view = new DataView(out.buffer);
9458
+ for (let i = 0; i < plane.length; i++) view.setFloat32(4 * i, plane[i] / 255, false);
9459
+ return out;
9460
+ }
9556
9461
  function toMask8(plane, width, height, depth) {
9557
9462
  if (depth === 8) return new Uint8ClampedArray(plane.buffer, plane.byteOffset, width * height);
9558
9463
  const s = sampler(plane, depth, width, false, 0);
@@ -9587,6 +9492,16 @@ function matteWhite(data) {
9587
9492
  }
9588
9493
  return out;
9589
9494
  }
9495
+ function matteWhiteDeep(data) {
9496
+ const out = data.slice();
9497
+ const one = out instanceof Uint16Array ? 65535 : 1;
9498
+ for (let i = 0; i < out.length; i += 4) {
9499
+ const a = Math.min(1, Math.max(0, out[i + 3] / one));
9500
+ if (a >= 1) continue;
9501
+ for (let c = 0; c < 3; c++) out[i + c] = out instanceof Uint16Array ? Math.round(out[i + c] * a + one * (1 - a)) : out[i + c] * a + one * (1 - a);
9502
+ }
9503
+ return out;
9504
+ }
9590
9505
 
9591
9506
  // src/image-editor/psd/patterns.ts
9592
9507
  var MAX_EDGE = 3e4;
@@ -9818,12 +9733,12 @@ function safeSize(ctx, rect, name) {
9818
9733
  }
9819
9734
  function recordPixels(ctx, rec, name) {
9820
9735
  const { width, height } = safeSize(ctx, rec.rect, name);
9821
- if (!width || !height || ctx.skipPixels) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
9736
+ if (!width || !height || ctx.skipPixels) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
9822
9737
  const ids = [...Array.from({ length: ctx.colorCount }, (_, i) => i), CHANNEL_ALPHA];
9823
9738
  const planes = ids.map((id) => rec.channels.some((c) => c.id === id) ? _nullishCoalesce(decodeOr(ctx, rec, id, name), () => ( null)) : void 0);
9824
- if (planes.some((p) => p === null)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
9825
- if (planes.every((p) => p === void 0)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
9826
- const data = toRgba8({
9739
+ if (planes.some((p) => p === null)) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
9740
+ if (planes.every((p) => p === void 0)) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
9741
+ const set = {
9827
9742
  width,
9828
9743
  height,
9829
9744
  depth: ctx.file.header.depth,
@@ -9831,8 +9746,10 @@ function recordPixels(ctx, rec, name) {
9831
9746
  color: planes.slice(0, ctx.colorCount),
9832
9747
  alpha: planes[ctx.colorCount],
9833
9748
  palette: ctx.palette
9834
- });
9835
- return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, rec.rect.left, rec.rect.top);
9749
+ };
9750
+ const deep = toRgbaDeep(set);
9751
+ if (deep) return _chunkST7E3NEEcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
9752
+ return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data: toRgba8(set) }, 4, rec.rect.left, rec.rect.top);
9836
9753
  }
9837
9754
  function recordMask(ctx, rec, name) {
9838
9755
  const m = rec.mask;
@@ -9843,11 +9760,11 @@ function recordMask(ctx, rec, name) {
9843
9760
  const rect = useReal ? m.real.rect : m.rect;
9844
9761
  const def = (useReal ? m.real.background : m.defaultColor) >= 128 ? 255 : 0;
9845
9762
  const flags = useReal ? m.real.flags : m.flags;
9846
- let surface = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, def);
9763
+ let surface = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 1, def);
9847
9764
  const { width, height } = safeSize(ctx, rect, name);
9848
9765
  if (width && height && !ctx.skipPixels) {
9849
9766
  const plane = decodeOr(ctx, rec, id, name);
9850
- if (plane) surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, ctx.file.header.depth) }, 1, rect.left, rect.top, def);
9767
+ if (plane) surface = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, ctx.file.header.depth) }, 1, rect.left, rect.top, def);
9851
9768
  }
9852
9769
  const mask = { surface, defaultValue: def };
9853
9770
  if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
@@ -9907,7 +9824,7 @@ function recordEffects(ctx, rec, name, notes, group) {
9907
9824
  }
9908
9825
  for (const e of parsed.effects.items) {
9909
9826
  for (const id of patternIds(e)) {
9910
- if (ctx.patterns.has(id) || _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)) continue;
9827
+ if (ctx.patterns.has(id) || _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)) continue;
9911
9828
  ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
9912
9829
  notes.push(`pattern "${id}" is not in the file`);
9913
9830
  }
@@ -9936,7 +9853,7 @@ function importNode(ctx, node, depth) {
9936
9853
  if (node.children) {
9937
9854
  const props2 = baseProps(ctx, rec, name, notes);
9938
9855
  const divider = sectionDivider(rec);
9939
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _244 => _244.blendKey]), () => ( rec.blendKey));
9856
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _238 => _238.blendKey]), () => ( rec.blendKey));
9940
9857
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
9941
9858
  const children = [];
9942
9859
  for (const child of node.children) {
@@ -9946,7 +9863,7 @@ function importNode(ctx, node, depth) {
9946
9863
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
9947
9864
  const effects2 = recordEffects(ctx, rec, name, notes, true);
9948
9865
  if (effects2) group.effects = effects2;
9949
- if (_optionalChain([divider, 'optionalAccess', _245 => _245.kind]) === SECTION_CLOSED) group.collapsed = true;
9866
+ if (_optionalChain([divider, 'optionalAccess', _239 => _239.kind]) === SECTION_CLOSED) group.collapsed = true;
9950
9867
  const mask2 = recordMask(ctx, rec, name);
9951
9868
  if (mask2) group.mask = mask2;
9952
9869
  entry.type = "group";
@@ -9986,7 +9903,7 @@ function importNode(ctx, node, depth) {
9986
9903
  if (!file || file.kind !== "liFD") notes.push("linked contents come in as the stored pixels");
9987
9904
  entry.type = "smart";
9988
9905
  entry.status = notes.length ? "approximated" : "mapped";
9989
- return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
9906
+ return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
9990
9907
  }
9991
9908
  }
9992
9909
  if (kind === "smart-object" && !ctx.skipPixels) {
@@ -10049,7 +9966,7 @@ function importShape(ctx, rec, name, notes, props) {
10049
9966
  components: data.components,
10050
9967
  fill: data.fill,
10051
9968
  stroke: data.stroke,
10052
- surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
9969
+ surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
10053
9970
  offset: { x: 0, y: 0 }
10054
9971
  };
10055
9972
  if (data.inverted) layer.inverted = true;
@@ -10117,8 +10034,8 @@ function contentsFor(ctx, placed, name, notes) {
10117
10034
  document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
10118
10035
  };
10119
10036
  } else if (t.ext === "png") {
10120
- const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, file.bytes);
10121
- out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
10037
+ const png = _chunkST7E3NEEcjs.decodePng.call(void 0, file.bytes);
10038
+ out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
10122
10039
  } else {
10123
10040
  const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
10124
10041
  if (!(size.width > 0 && size.height > 0)) throw new PsdError("the contents have no stored size");
@@ -10159,7 +10076,7 @@ function importSmart(ctx, rec, name, notes, props) {
10159
10076
  if (placement && (size.width !== contents.width || size.height !== contents.height)) {
10160
10077
  const kx = contents.width / size.width;
10161
10078
  const ky = contents.height / size.height;
10162
- if (placement.warp) placement = { ...placement, warp: _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
10079
+ if (placement.warp) placement = { ...placement, warp: _chunkLPLCWZTMcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
10163
10080
  }
10164
10081
  }
10165
10082
  if (!contents || !placement) {
@@ -10169,11 +10086,11 @@ function importSmart(ctx, rec, name, notes, props) {
10169
10086
  const file = ctx.linked.get(placed.idnt);
10170
10087
  contents = {
10171
10088
  id: placed.idnt || ctx.newId(`${name}-contents`),
10172
- name: _optionalChain([file, 'optionalAccess', _246 => _246.name]) || `${name}.png`,
10089
+ name: _optionalChain([file, 'optionalAccess', _240 => _240.name]) || `${name}.png`,
10173
10090
  width,
10174
10091
  height,
10175
10092
  kind: "raster",
10176
- raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
10093
+ raster: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
10177
10094
  };
10178
10095
  if (file && file.kind !== "liFD") {
10179
10096
  contents.linked = { path: _nullishCoalesce(file.path, () => ( file.name)) };
@@ -10230,7 +10147,7 @@ function mergedLayer(ctx) {
10230
10147
  const plane = (i) => i < header.channels ? planes.subarray(i * size, (i + 1) * size) : void 0;
10231
10148
  const cc = ctx.colorCount;
10232
10149
  const hasAlpha = header.channels > cc && (ctx.file.layers.length === 0 || ctx.file.mergedAlpha);
10233
- const data = toRgba8({
10150
+ const set = {
10234
10151
  width,
10235
10152
  height,
10236
10153
  depth: header.depth,
@@ -10238,8 +10155,15 @@ function mergedLayer(ctx) {
10238
10155
  color: Array.from({ length: cc }, (_, i) => plane(i)),
10239
10156
  alpha: hasAlpha ? plane(cc) : void 0,
10240
10157
  palette: ctx.palette
10241
- });
10242
- if (hasAlpha) unmatteWhite(data);
10158
+ };
10159
+ const deep = hasAlpha ? null : toRgbaDeep(set);
10160
+ let surface;
10161
+ if (deep) surface = _chunkST7E3NEEcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4);
10162
+ else {
10163
+ const data = toRgba8(set);
10164
+ if (hasAlpha) unmatteWhite(data);
10165
+ surface = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data }, 4);
10166
+ }
10243
10167
  return {
10244
10168
  type: "pixel",
10245
10169
  id: ctx.newId("Background"),
@@ -10247,7 +10171,7 @@ function mergedLayer(ctx) {
10247
10171
  visible: true,
10248
10172
  opacity: 1,
10249
10173
  blend: "normal",
10250
- surface: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4),
10174
+ surface,
10251
10175
  offset: { x: 0, y: 0 }
10252
10176
  };
10253
10177
  }
@@ -10291,10 +10215,11 @@ function psdToLayers(file, options = {}) {
10291
10215
  }
10292
10216
  }
10293
10217
  const mode = _nullishCoalesce(COLOR_MODES[header.colorMode], () => ( `mode ${header.colorMode}`));
10294
- if (mode !== "rgb" || header.depth !== 8) {
10218
+ if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
10219
+ warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
10220
+ } else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
10295
10221
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB.`);
10296
10222
  }
10297
- if (resource(file, 1039)) warn.extra.push("The embedded ICC profile is ignored; colours are read as sRGB.");
10298
10223
  let layers = [];
10299
10224
  if (file.layers.length) {
10300
10225
  const tree = layerTree(file);
@@ -10327,7 +10252,9 @@ function psdToLayers(file, options = {}) {
10327
10252
  resolution: resolution(file),
10328
10253
  patterns: [...ctx.patterns.values()],
10329
10254
  ...angle !== void 0 || altitude !== void 0 ? { globalLight: { angle: Math.max(-360, Math.min(360, _nullishCoalesce(angle, () => ( 120)))), altitude: Math.max(0, Math.min(90, _nullishCoalesce(altitude, () => ( 30)))) } } : {},
10330
- info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels }
10255
+ info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels },
10256
+ ...resource(file, 1039) ? { iccProfile: resource(file, 1039).slice() } : {},
10257
+ bitDepth: (header.depth === 16 || header.depth === 32) && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP ? header.depth : 8
10331
10258
  };
10332
10259
  }
10333
10260
  function importPsd(bytes, options = {}) {
@@ -10395,15 +10322,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
10395
10322
  var bool = (d, key) => descBool(d, key) === true;
10396
10323
  var enumOf3 = (d, key) => {
10397
10324
  const v = descGet(d, key);
10398
- return _optionalChain([v, 'optionalAccess', _247 => _247.type]) === "enum" ? v.value : void 0;
10325
+ return _optionalChain([v, 'optionalAccess', _241 => _241.type]) === "enum" ? v.value : void 0;
10399
10326
  };
10400
10327
  var text2 = (d, key) => {
10401
10328
  const v = d ? descGet(d, key) : void 0;
10402
- return _optionalChain([v, 'optionalAccess', _248 => _248.type]) === "TEXT" ? v.value : "";
10329
+ return _optionalChain([v, 'optionalAccess', _242 => _242.type]) === "TEXT" ? v.value : "";
10403
10330
  };
10404
10331
  var list = (d, key) => {
10405
10332
  const v = descGet(d, key);
10406
- if (_optionalChain([v, 'optionalAccess', _249 => _249.type]) !== "VlLs") return [];
10333
+ if (_optionalChain([v, 'optionalAccess', _243 => _243.type]) !== "VlLs") return [];
10407
10334
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
10408
10335
  };
10409
10336
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -10425,34 +10352,34 @@ function blendOf(d, key, fallback, notes) {
10425
10352
  function colorOf(d, fallback = "#000000") {
10426
10353
  if (!d) return fallback;
10427
10354
  const g = (k) => descNumber(d, k);
10428
- if (g("redFloat") !== void 0) return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
10355
+ if (g("redFloat") !== void 0) return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
10429
10356
  switch (d.classId) {
10430
10357
  case "HSBC": {
10431
10358
  const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
10432
- return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
10359
+ return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10433
10360
  }
10434
10361
  case "CMYC": {
10435
10362
  const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
10436
10363
  const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
10437
- return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
10364
+ return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10438
10365
  }
10439
10366
  case "LbCl": {
10440
10367
  const rgb = decodePsdColor(7, [(_nullishCoalesce(g("Lmnc"), () => ( 0))) * 100, Math.round((_nullishCoalesce(g("A "), () => ( 0))) * 100) & 65535, Math.round((_nullishCoalesce(g("B "), () => ( 0))) * 100) & 65535]);
10441
- return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
10368
+ return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10442
10369
  }
10443
10370
  case "Grsc": {
10444
10371
  const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
10445
- return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [v, v, v]);
10372
+ return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [v, v, v]);
10446
10373
  }
10447
10374
  }
10448
10375
  const r = g("Rd ");
10449
10376
  const gr = g("Grn ");
10450
10377
  const b = g("Bl ");
10451
10378
  if (r === void 0 || gr === void 0 || b === void 0) return fallback;
10452
- return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
10379
+ return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
10453
10380
  }
10454
10381
  function colorDesc(hex) {
10455
- const [r, g, b] = _nullishCoalesce(_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
10382
+ const [r, g, b] = _nullishCoalesce(_chunkST7E3NEEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
10456
10383
  return descriptor("RGBC", [
10457
10384
  ["Rd ", dbl3(r * 255)],
10458
10385
  ["Grn ", dbl3(g * 255)],
@@ -10473,8 +10400,8 @@ function contourOf(d, key) {
10473
10400
  return { name, points };
10474
10401
  }
10475
10402
  function contourDesc(c) {
10476
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _250 => _250.name]), () => ( "Linear"));
10477
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _251 => _251.points]), () => ( [
10403
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _244 => _244.name]), () => ( "Linear"));
10404
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _245 => _245.points]), () => ( [
10478
10405
  { input: 0, output: 0 },
10479
10406
  { input: 1, output: 1 }
10480
10407
  ]));
@@ -10509,7 +10436,7 @@ function gradientOf(d, notes) {
10509
10436
  { position: 0, color: "#000000" },
10510
10437
  { position: 1, color: "#ffffff" }
10511
10438
  ],
10512
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _252 => _252.find, 'call', _253 => _253(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _254 => _254[0]]), () => ( "linear")),
10439
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _246 => _246.find, 'call', _247 => _247(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _248 => _248[0]]), () => ( "linear")),
10513
10440
  angle: clamp3(num3(d, "Angl", 90), -360, 360),
10514
10441
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
10515
10442
  reverse: bool(d, "Rvrs"),
@@ -10535,9 +10462,9 @@ function gradientOf(d, notes) {
10535
10462
  raw.forEach((s, i) => {
10536
10463
  if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
10537
10464
  const a = raw[i - 1];
10538
- const ca = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, a.color);
10539
- const cb = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, s.color);
10540
- stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkPOGBUYWEcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
10465
+ const ca = _chunkST7E3NEEcjs.parseEffectColor.call(void 0, a.color);
10466
+ const cb = _chunkST7E3NEEcjs.parseEffectColor.call(void 0, s.color);
10467
+ stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkST7E3NEEcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
10541
10468
  notes.add("gradient midpoints are drawn as straight segments");
10542
10469
  }
10543
10470
  stops.push({ position: s.position, color: s.color });
@@ -10563,7 +10490,7 @@ function gradientItems(g) {
10563
10490
  )
10564
10491
  )
10565
10492
  };
10566
- const op = _optionalChain([g, 'access', _255 => _255.opacityStops, 'optionalAccess', _256 => _256.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10493
+ const op = _optionalChain([g, 'access', _249 => _249.opacityStops, 'optionalAccess', _250 => _250.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10567
10494
  const trns = {
10568
10495
  type: "VlLs",
10569
10496
  items: op.map(
@@ -10649,8 +10576,8 @@ var KINDS = [
10649
10576
  ["FrFX", "frameFXMulti", "stroke"]
10650
10577
  ];
10651
10578
  function common(d, kind, notes) {
10652
- const def = _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, "x");
10653
- return { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
10579
+ const def = _chunkST7E3NEEcjs.defaultLayerEffect.call(void 0, kind, "x");
10580
+ return { id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
10654
10581
  }
10655
10582
  function readOne(kind, d, notes) {
10656
10583
  const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
@@ -10693,7 +10620,7 @@ function readOne(kind, d, notes) {
10693
10620
  case "bevel-emboss": {
10694
10621
  const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
10695
10622
  const out = {
10696
- id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ),
10623
+ id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ),
10697
10624
  enabled: descBool(d, "enab") !== false,
10698
10625
  kind,
10699
10626
  style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
@@ -10759,7 +10686,7 @@ function parseLfx2(data) {
10759
10686
  let d;
10760
10687
  try {
10761
10688
  d = parseVersionedDescriptor(data.subarray(4));
10762
- } catch (e25) {
10689
+ } catch (e26) {
10763
10690
  return null;
10764
10691
  }
10765
10692
  const notes = /* @__PURE__ */ new Set();
@@ -10904,10 +10831,10 @@ function writeLfx2(effects) {
10904
10831
  ["Scl ", unit3("#Prc", 100)],
10905
10832
  ["masterFXSwitch", boolV3(effects.enabled)]
10906
10833
  ];
10907
- const scale = _chunkPOGBUYWEcjs.effectsScale.call(void 0, effects);
10834
+ const scale = _chunkST7E3NEEcjs.effectsScale.call(void 0, effects);
10908
10835
  let dropped = 0;
10909
10836
  for (const [single, multi, kind] of KINDS) {
10910
- const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPOGBUYWEcjs.scaleLayerEffect.call(void 0, e, scale)));
10837
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkST7E3NEEcjs.scaleLayerEffect.call(void 0, e, scale)));
10911
10838
  if (!of.length) continue;
10912
10839
  if (of.length === 1) items.push([single, obj3(of[0])]);
10913
10840
  else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
@@ -10939,7 +10866,7 @@ function parseLrfx(data) {
10939
10866
  const colorAt = (rd) => {
10940
10867
  rd.u16();
10941
10868
  const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
10942
- return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
10869
+ return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
10943
10870
  };
10944
10871
  const blendAt = (rd) => {
10945
10872
  rd.skip(4);
@@ -10958,7 +10885,7 @@ function parseLrfx(data) {
10958
10885
  const enabled = b.u8() !== 0;
10959
10886
  const useGlobalLight = b.u8() !== 0;
10960
10887
  const opacity = b.u8() / 255;
10961
- const base = { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
10888
+ const base = { id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
10962
10889
  items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
10963
10890
  } else if (key === "oglw" || key === "iglw") {
10964
10891
  b.u32();
@@ -10968,7 +10895,7 @@ function parseLrfx(data) {
10968
10895
  const blend = blendAt(b);
10969
10896
  const enabled = b.u8() !== 0;
10970
10897
  const opacity = b.u8() / 255;
10971
- const base = { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
10898
+ const base = { id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
10972
10899
  items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
10973
10900
  } else if (key === "sofi") {
10974
10901
  b.u32();
@@ -10976,11 +10903,11 @@ function parseLrfx(data) {
10976
10903
  const color = colorAt(b);
10977
10904
  const opacity = b.u8() / 255;
10978
10905
  const enabled = b.u8() !== 0;
10979
- items.push({ id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
10906
+ items.push({ id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
10980
10907
  } else if (key === "bevl") notes.add("legacy bevels are not read");
10981
10908
  }
10982
10909
  return { effects: { enabled: true, items }, notes: [...notes] };
10983
- } catch (e26) {
10910
+ } catch (e27) {
10984
10911
  return null;
10985
10912
  }
10986
10913
  }
@@ -11020,22 +10947,30 @@ function sectionBlock(kind, blendKey) {
11020
10947
  return w.result();
11021
10948
  }
11022
10949
  var toRect = (r) => ({ top: r.y, left: r.x, bottom: r.y + r.height, right: r.x + r.width });
11023
- function rleChannel(id, plane, width, height, psb) {
11024
- return { id, compression: 1, data: encodeRle(plane, { planes: 1, width, height, depth: 8, psb }) };
10950
+ function rleChannel(id, plane, width, height, psb, depth = 8) {
10951
+ const layout = { planes: 1, width, height, depth, psb };
10952
+ if (depth === 32) return { id, compression: 3, data: encodeZipPredicted(plane, layout) };
10953
+ return { id, compression: 1, data: encodeRle(plane, layout) };
10954
+ }
10955
+ function surfacePlanes(surface, bounds, depth) {
10956
+ const n = bounds.width * bounds.height;
10957
+ if (depth === 8) return rgbaToPlanes(_chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, bounds), n);
10958
+ return deepToPlanes(_chunkST7E3NEEcjs.readDeepRegion.call(void 0, surface, bounds, depth), n);
11025
10959
  }
11026
10960
  var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
11027
- function maskChannel(mask, ox, oy, psb) {
10961
+ function maskChannel(mask, ox, oy, psb, depth = 8) {
11028
10962
  if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
11029
- const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
10963
+ const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, mask.surface);
11030
10964
  const def = mask.defaultValue;
11031
10965
  const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
11032
10966
  const m = { rect: EMPTY_RECT, defaultColor: def, flags };
11033
10967
  if ((_nullishCoalesce(mask.density, () => ( 1))) < 1) m.userDensity = Math.round(Math.max(0, _nullishCoalesce(mask.density, () => ( 1))) * 255);
11034
10968
  if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) m.userFeather = mask.feather;
11035
10969
  if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
11036
- const plane = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, bounds);
10970
+ const plane = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, bounds);
11037
10971
  m.rect = toRect({ ...bounds, x: bounds.x + ox, y: bounds.y + oy });
11038
- return { channel: rleChannel(CHANNEL_USER_MASK, new Uint8Array(plane.buffer, plane.byteOffset, plane.length), bounds.width, bounds.height, psb), mask: m };
10972
+ const bytes = planeAtDepth(new Uint8Array(plane.buffer, plane.byteOffset, plane.length), depth);
10973
+ return { channel: rleChannel(CHANNEL_USER_MASK, bytes, bounds.width, bounds.height, psb, depth), mask: m };
11039
10974
  }
11040
10975
  function lockBits(layer) {
11041
10976
  const l = layer.locks;
@@ -11048,9 +10983,9 @@ function prepareNestedLayers(layers) {
11048
10983
  if (l.type === "annotation") continue;
11049
10984
  let next = l;
11050
10985
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
11051
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _257 => _257.filters, 'optionalAccess', _258 => _258.length]) || l.source === "document")) {
10986
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _251 => _251.filters, 'optionalAccess', _252 => _252.length]) || l.source === "document")) {
11052
10987
  const p = { ...l };
11053
- if (_optionalChain([l, 'access', _259 => _259.filters, 'optionalAccess', _260 => _260.some, 'call', _261 => _261(isActiveFilter)])) {
10988
+ if (_optionalChain([l, 'access', _253 => _253.filters, 'optionalAccess', _254 => _254.some, 'call', _255 => _255(isActiveFilter)])) {
11054
10989
  const b = l.surface.bounds;
11055
10990
  if (b) {
11056
10991
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -11060,14 +10995,14 @@ function prepareNestedLayers(layers) {
11060
10995
  delete plain.effects;
11061
10996
  delete plain.fillOpacity;
11062
10997
  const data = new LayerCompositor().composite([plain], r, { width: r.x + r.width, height: r.y + r.height });
11063
- p.surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
10998
+ p.surface = _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
11064
10999
  }
11065
11000
  }
11066
11001
  delete p.filters;
11067
11002
  delete p.source;
11068
11003
  next = p;
11069
11004
  }
11070
- if (_optionalChain([next, 'access', _262 => _262.mask, 'optionalAccess', _263 => _263.source])) {
11005
+ if (_optionalChain([next, 'access', _256 => _256.mask, 'optionalAccess', _257 => _257.source])) {
11071
11006
  next = { ...next };
11072
11007
  delete next.mask;
11073
11008
  }
@@ -11079,11 +11014,11 @@ function smartContentsFile(c) {
11079
11014
  const base = c.name.replace(/\.\w+$/, "") || "Contents";
11080
11015
  if (c.file) return { name: c.name, bytes: c.file.bytes };
11081
11016
  if (c.kind === "raster") {
11082
- const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
11083
- return { name: `${base}.png`, bytes: _chunkPOGBUYWEcjs.encodePng.call(void 0, c.width, c.height, data) };
11017
+ const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
11018
+ return { name: `${base}.png`, bytes: _chunkST7E3NEEcjs.encodePng.call(void 0, c.width, c.height, data) };
11084
11019
  }
11085
11020
  const doc = c.document;
11086
- const merged2 = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
11021
+ const merged2 = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
11087
11022
  const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged: merged2, patterns: doc.patterns, globalLight: doc.globalLight });
11088
11023
  return { name: `${base}.${res.psb ? "psb" : "psd"}`, bytes: res.bytes };
11089
11024
  }
@@ -11114,6 +11049,7 @@ function placedUnchanged(layer, idnt, placedId) {
11114
11049
  }
11115
11050
  function exportPsd(input) {
11116
11051
  const { width, height } = input;
11052
+ const depth = _nullishCoalesce(input.depth, () => ( 8));
11117
11053
  if (width < 1 || height < 1) throw new PsdError("The document is empty.");
11118
11054
  const psb = width > PSD_MAX_DIMENSION || height > PSD_MAX_DIMENSION;
11119
11055
  const records = [];
@@ -11131,7 +11067,7 @@ function exportPsd(input) {
11131
11067
  const key = layer.type === "group" ? "lfxs" : "lfx2";
11132
11068
  if (fx.psd) {
11133
11069
  const original = parseLfx2(fx.psd.data);
11134
- if (original ? _chunkPOGBUYWEcjs.effectsFingerprint.call(void 0, original.effects) === _chunkPOGBUYWEcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
11070
+ if (original ? _chunkST7E3NEEcjs.effectsFingerprint.call(void 0, original.effects) === _chunkST7E3NEEcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
11135
11071
  }
11136
11072
  if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
11137
11073
  const { data, dropped } = writeLfx2(fx);
@@ -11148,7 +11084,7 @@ function exportPsd(input) {
11148
11084
  return {
11149
11085
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
11150
11086
  clipping: layer.clipped ? 1 : 0,
11151
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _264 => _264.locks, 'optionalAccess', _265 => _265.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11087
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _258 => _258.locks, 'optionalAccess', _259 => _259.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11152
11088
  legacyName: name,
11153
11089
  blocks
11154
11090
  };
@@ -11180,7 +11116,7 @@ function exportPsd(input) {
11180
11116
  flags: base.flags | FLAG_PIXELS_IRRELEVANT
11181
11117
  };
11182
11118
  if (layer.mask) {
11183
- const m = maskChannel(layer.mask, 0, 0, psb);
11119
+ const m = maskChannel(layer.mask, 0, 0, psb, depth);
11184
11120
  rec.channels.push(m.channel);
11185
11121
  rec.mask = m.mask;
11186
11122
  }
@@ -11196,7 +11132,7 @@ function exportPsd(input) {
11196
11132
  blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm"))
11197
11133
  };
11198
11134
  if (layer.mask) {
11199
- const m = maskChannel(layer.mask, 0, 0, psb);
11135
+ const m = maskChannel(layer.mask, 0, 0, psb, depth);
11200
11136
  rec.channels.push(m.channel);
11201
11137
  rec.mask = m.mask;
11202
11138
  }
@@ -11205,28 +11141,27 @@ function exportPsd(input) {
11205
11141
  }
11206
11142
  case "pixel": {
11207
11143
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
11208
- if (_optionalChain([layer, 'access', _266 => _266.filters, 'optionalAccess', _267 => _267.some, 'call', _268 => _268(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11144
+ if (_optionalChain([layer, 'access', _260 => _260.filters, 'optionalAccess', _261 => _261.some, 'call', _262 => _262(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11209
11145
  const extra = [];
11210
11146
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
11211
11147
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
11212
11148
  }
11213
11149
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11214
- const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
11150
+ const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11215
11151
  if (bounds) {
11216
- const n2 = bounds.width * bounds.height;
11217
- const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
11152
+ const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11218
11153
  rec.rect = toRect({ ...bounds, x: bounds.x + layer.offset.x, y: bounds.y + layer.offset.y });
11219
11154
  rec.channels = [
11220
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
11221
- rleChannel(0, r2, bounds.width, bounds.height, psb),
11222
- rleChannel(1, g2, bounds.width, bounds.height, psb),
11223
- rleChannel(2, b2, bounds.width, bounds.height, psb)
11155
+ rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11156
+ rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11157
+ rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11158
+ rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11224
11159
  ];
11225
11160
  } else {
11226
11161
  rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11227
11162
  }
11228
11163
  if (layer.mask) {
11229
- const m = maskChannel(layer.mask, layer.offset.x, layer.offset.y, psb);
11164
+ const m = maskChannel(layer.mask, layer.offset.x, layer.offset.y, psb, depth);
11230
11165
  rec.channels.push(m.channel);
11231
11166
  rec.mask = m.mask;
11232
11167
  }
@@ -11244,7 +11179,7 @@ function exportPsd(input) {
11244
11179
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
11245
11180
  linkedFiles.set(idnt, smartContentsFile(c));
11246
11181
  }
11247
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _269 => _269.psd, 'optionalAccess', _270 => _270.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11182
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _263 => _263.psd, 'optionalAccess', _264 => _264.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11248
11183
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
11249
11184
  placedIds.add(placedId);
11250
11185
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -11254,30 +11189,29 @@ function exportPsd(input) {
11254
11189
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
11255
11190
  if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
11256
11191
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
11257
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _271 => _271.descriptor]) };
11192
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _265 => _265.descriptor]) };
11258
11193
  const wnotes = [];
11259
11194
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
11260
11195
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
11261
11196
  }
11262
- const fm = _optionalChain([layer, 'access', _272 => _272.smartFilters, 'optionalAccess', _273 => _273.mask]);
11197
+ const fm = _optionalChain([layer, 'access', _266 => _266.smartFilters, 'optionalAccess', _267 => _267.mask]);
11263
11198
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
11264
11199
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11265
- const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
11200
+ const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11266
11201
  if (bounds) {
11267
- const n2 = bounds.width * bounds.height;
11268
- const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
11202
+ const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11269
11203
  rec.rect = toRect(bounds);
11270
11204
  rec.channels = [
11271
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
11272
- rleChannel(0, r2, bounds.width, bounds.height, psb),
11273
- rleChannel(1, g2, bounds.width, bounds.height, psb),
11274
- rleChannel(2, b2, bounds.width, bounds.height, psb)
11205
+ rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11206
+ rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11207
+ rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11208
+ rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11275
11209
  ];
11276
11210
  } else {
11277
11211
  rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11278
11212
  }
11279
11213
  if (layer.mask) {
11280
- const m = maskChannel(layer.mask, 0, 0, psb);
11214
+ const m = maskChannel(layer.mask, 0, 0, psb, depth);
11281
11215
  rec.channels.push(m.channel);
11282
11216
  rec.mask = m.mask;
11283
11217
  }
@@ -11294,28 +11228,27 @@ function exportPsd(input) {
11294
11228
  const losses = /* @__PURE__ */ new Set();
11295
11229
  for (const b2 of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b2.key, data: padEven(b2.data) });
11296
11230
  for (const n2 of losses) note(n2, layer.name);
11297
- if (_optionalChain([layer, 'access', _274 => _274.fill, 'optionalAccess', _275 => _275.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11298
- if (_optionalChain([layer, 'access', _276 => _276.stroke, 'optionalAccess', _277 => _277.paint, 'access', _278 => _278.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11231
+ if (_optionalChain([layer, 'access', _268 => _268.fill, 'optionalAccess', _269 => _269.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11232
+ if (_optionalChain([layer, 'access', _270 => _270.stroke, 'optionalAccess', _271 => _271.paint, 'access', _272 => _272.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11299
11233
  } else {
11300
11234
  extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
11301
11235
  }
11302
11236
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11303
- const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
11237
+ const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11304
11238
  if (bounds) {
11305
- const n2 = bounds.width * bounds.height;
11306
- const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
11239
+ const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11307
11240
  rec.rect = toRect(bounds);
11308
11241
  rec.channels = [
11309
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
11310
- rleChannel(0, r2, bounds.width, bounds.height, psb),
11311
- rleChannel(1, g2, bounds.width, bounds.height, psb),
11312
- rleChannel(2, b2, bounds.width, bounds.height, psb)
11242
+ rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11243
+ rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11244
+ rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11245
+ rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11313
11246
  ];
11314
11247
  } else {
11315
11248
  rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11316
11249
  }
11317
11250
  if (layer.mask) {
11318
- const m = maskChannel(layer.mask, 0, 0, psb);
11251
+ const m = maskChannel(layer.mask, 0, 0, psb, depth);
11319
11252
  rec.channels.push(m.channel);
11320
11253
  rec.mask = m.mask;
11321
11254
  }
@@ -11332,9 +11265,15 @@ function exportPsd(input) {
11332
11265
  if (input.merged.length < n * 4) throw new PsdError(`The merged image has ${input.merged.length} bytes, expected ${n * 4}.`);
11333
11266
  const [r, g, b, a] = rgbaToPlanes(matteWhite(input.merged), n);
11334
11267
  const transparent = a.some((v) => v !== 255);
11335
- const planes = transparent ? [r, g, b, a] : [r, g, b];
11336
- const merged2 = new Uint8Array(n * planes.length);
11337
- planes.forEach((p, i) => merged2.set(p, i * n));
11268
+ let planes = (transparent ? [r, g, b, a] : [r, g, b]).map((p) => planeAtDepth(p, depth));
11269
+ const deep = input.mergedDeep;
11270
+ if (deep && depth !== 8 && deep.length >= n * 4 && (deep instanceof Uint16Array ? depth === 16 : depth === 32)) {
11271
+ const dp = deepToPlanes(matteWhiteDeep(deep), n);
11272
+ planes = transparent ? dp : dp.slice(0, 3);
11273
+ }
11274
+ const planeBytes = n * (depth >> 3);
11275
+ const merged2 = new Uint8Array(planeBytes * planes.length);
11276
+ planes.forEach((p, i) => merged2.set(p, i * planeBytes));
11338
11277
  const res = Math.max(1, _nullishCoalesce(input.resolution, () => ( 72)));
11339
11278
  const rw = new PsdWriter();
11340
11279
  for (let k = 0; k < 2; k++) {
@@ -11352,6 +11291,7 @@ function exportPsd(input) {
11352
11291
  { id: 1005, name: "", data: rw.result() },
11353
11292
  { id: 1057, name: "", data: version.result() }
11354
11293
  ];
11294
+ if (_optionalChain([input, 'access', _273 => _273.iccProfile, 'optionalAccess', _274 => _274.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11355
11295
  if (input.globalLight) {
11356
11296
  const i32 = (v) => {
11357
11297
  const w = new PsdWriter();
@@ -11365,7 +11305,7 @@ function exportPsd(input) {
11365
11305
  const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
11366
11306
  const embed = [];
11367
11307
  for (const id of patternIds2) {
11368
- const p = _nullishCoalesce(byId.get(id), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
11308
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)));
11369
11309
  if (p) embed.push(p);
11370
11310
  else note(`Pattern "${id}" is not in the document and was not embedded`, id);
11371
11311
  }
@@ -11384,14 +11324,14 @@ function exportPsd(input) {
11384
11324
  if (filterItems.length) globalBlocks.push({ key: "FEid", data: writeFilterEffects(filterItems) });
11385
11325
  const bytes = writePsd(
11386
11326
  {
11387
- header: { psb, channels: planes.length, width, height, depth: 8, colorMode: 3 },
11327
+ header: { psb, channels: planes.length, width, height, depth, colorMode: 3 },
11388
11328
  colorModeData: new Uint8Array(0),
11389
11329
  resources,
11390
11330
  layers: records,
11391
11331
  mergedAlpha: transparent && records.length > 0,
11392
11332
  globalBlocks,
11393
- imageCompression: 1,
11394
- imageData: encodeRle(merged2, { planes: planes.length, width, height, depth: 8, psb })
11333
+ imageCompression: depth === 32 ? 0 : 1,
11334
+ imageData: depth === 32 ? merged2 : encodeRle(merged2, { planes: planes.length, width, height, depth, psb })
11395
11335
  },
11396
11336
  encodeLegacyName
11397
11337
  );
@@ -11755,13 +11695,5 @@ function exportPsd(input) {
11755
11695
 
11756
11696
 
11757
11697
 
11758
-
11759
-
11760
-
11761
-
11762
-
11763
-
11764
-
11765
-
11766
- exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.DEFAULT_TEXT_STYLE = DEFAULT_TEXT_STYLE; exports.DEFAULT_AUTO_LEADING = DEFAULT_AUTO_LEADING; exports.fitRuns = fitRuns; exports.styleAt = styleAt; exports.restyleRange = restyleRange; exports.spliceRuns = spliceRuns; exports.paragraphRanges = paragraphRanges; exports.fitParagraphRuns = fitParagraphRuns; exports.fontOf = fontOf; exports.layoutText = layoutText; exports.textIndexAt = textIndexAt; exports.caretAt = caretAt; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
11767
- //# sourceMappingURL=chunk-YGIMK4NX.cjs.map
11698
+ exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
11699
+ //# sourceMappingURL=chunk-5OVJHMZQ.cjs.map