@pixerate/editor 0.109.0 → 0.111.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 (66) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -0
  2. package/dist/blending-DXl06NSx.d.ts +486 -0
  3. package/dist/blending-aOE6Y3UE.d.cts +486 -0
  4. package/dist/chunk-7VOHOPLW.cjs +1136 -0
  5. package/dist/chunk-7VOHOPLW.cjs.map +1 -0
  6. package/dist/chunk-FTBZPI77.cjs +1 -0
  7. package/dist/chunk-FTBZPI77.cjs.map +1 -0
  8. package/dist/{chunk-RE77QYUF.js → chunk-HHZ6ZJTW.js} +880 -86
  9. package/dist/chunk-HHZ6ZJTW.js.map +1 -0
  10. package/dist/{chunk-WMBIJCHA.js → chunk-HNS7UHCM.js} +5 -1
  11. package/dist/{chunk-WMBIJCHA.js.map → chunk-HNS7UHCM.js.map} +1 -1
  12. package/dist/{chunk-CFMWALBM.js → chunk-LQEEDHOP.js} +2 -2
  13. package/dist/{chunk-D37BX2ZA.cjs → chunk-PHUMLSCW.cjs} +1141 -347
  14. package/dist/chunk-PHUMLSCW.cjs.map +1 -0
  15. package/dist/{chunk-AZTZRLDI.cjs → chunk-POGBUYWE.cjs} +92 -92
  16. package/dist/{chunk-AZTZRLDI.cjs.map → chunk-POGBUYWE.cjs.map} +1 -1
  17. package/dist/chunk-VKK5VS2T.js +1 -0
  18. package/dist/{chunk-SZ6KMZNM.cjs → chunk-XIOMMGPD.cjs} +6 -2
  19. package/dist/chunk-XIOMMGPD.cjs.map +1 -0
  20. package/dist/{chunk-3PHA3UKI.js → chunk-Z4BC6M74.js} +523 -121
  21. package/dist/chunk-Z4BC6M74.js.map +1 -0
  22. package/dist/{export-BLPLaE6Z.d.ts → export-DBNVwb6h.d.ts} +521 -12
  23. package/dist/{export-DSUc4fQD.d.cts → export-DoDhCszr.d.cts} +521 -12
  24. package/dist/image-editor/index.cjs +1630 -900
  25. package/dist/image-editor/index.cjs.map +1 -1
  26. package/dist/image-editor/index.d.cts +104 -16
  27. package/dist/image-editor/index.d.ts +104 -16
  28. package/dist/image-editor/index.js +776 -46
  29. package/dist/image-editor/index.js.map +1 -1
  30. package/dist/paint/index.cjs +28 -4
  31. package/dist/paint/index.cjs.map +1 -1
  32. package/dist/paint/index.d.cts +3 -89
  33. package/dist/paint/index.d.ts +3 -89
  34. package/dist/paint/index.js +27 -3
  35. package/dist/paint-editor/index.cjs +1052 -286
  36. package/dist/paint-editor/index.cjs.map +1 -1
  37. package/dist/paint-editor/index.d.cts +302 -23
  38. package/dist/paint-editor/index.d.ts +302 -23
  39. package/dist/paint-editor/index.js +848 -82
  40. package/dist/paint-editor/index.js.map +1 -1
  41. package/dist/raster/index.cjs +5 -3
  42. package/dist/raster/index.cjs.map +1 -1
  43. package/dist/raster/index.d.cts +2 -2
  44. package/dist/raster/index.d.ts +2 -2
  45. package/dist/raster/index.js +4 -2
  46. package/dist/{render-C-fO_mes.d.cts → render-BEriFuqK.d.cts} +1 -1
  47. package/dist/{render-OLIMk_v0.d.ts → render-tjzKaik-.d.ts} +1 -1
  48. package/dist/{surface-CkKOHGPm.d.cts → surface-C8RRg_Bh.d.cts} +109 -1
  49. package/dist/{surface-CkKOHGPm.d.ts → surface-C8RRg_Bh.d.ts} +109 -1
  50. package/package.json +1 -1
  51. package/skills/pixerate-image-editor/SKILL.md +27 -30
  52. package/skills/pixerate-image-editor/references/shapes-and-type.md +60 -0
  53. package/skills/pixerate-paint-editor/SKILL.md +49 -13
  54. package/dist/chunk-3PHA3UKI.js.map +0 -1
  55. package/dist/chunk-6BU5WU4R.cjs +0 -1
  56. package/dist/chunk-6BU5WU4R.cjs.map +0 -1
  57. package/dist/chunk-D37BX2ZA.cjs.map +0 -1
  58. package/dist/chunk-HUFQD4CB.cjs +0 -734
  59. package/dist/chunk-HUFQD4CB.cjs.map +0 -1
  60. package/dist/chunk-RE77QYUF.js.map +0 -1
  61. package/dist/chunk-SZ6KMZNM.cjs.map +0 -1
  62. package/dist/chunk-XYBJKUAU.js +0 -1
  63. package/dist/mixer-5ziHU8OS.d.cts +0 -282
  64. package/dist/mixer-DNqiYXYQ.d.ts +0 -282
  65. /package/dist/{chunk-CFMWALBM.js.map → chunk-LQEEDHOP.js.map} +0 -0
  66. /package/dist/{chunk-XYBJKUAU.js.map → chunk-VKK5VS2T.js.map} +0 -0
@@ -41,7 +41,7 @@
41
41
 
42
42
 
43
43
 
44
- var _chunkAZTZRLDIcjs = require('./chunk-AZTZRLDI.cjs');
44
+ var _chunkPOGBUYWEcjs = require('./chunk-POGBUYWE.cjs');
45
45
 
46
46
 
47
47
 
@@ -68,7 +68,7 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
68
68
 
69
69
 
70
70
 
71
- var _chunkSZ6KMZNMcjs = require('./chunk-SZ6KMZNM.cjs');
71
+ var _chunkXIOMMGPDcjs = require('./chunk-XIOMMGPD.cjs');
72
72
 
73
73
 
74
74
 
@@ -99,6 +99,7 @@ var _chunkW3GXSUSQcjs = require('./chunk-W3GXSUSQ.cjs');
99
99
 
100
100
 
101
101
 
102
+
102
103
  var _chunkXGD3FSNCcjs = require('./chunk-XGD3FSNC.cjs');
103
104
 
104
105
  // src/image-editor/color.ts
@@ -1111,7 +1112,7 @@ function smoothCoverage(m, w, h, r) {
1111
1112
  return src;
1112
1113
  }
1113
1114
  function featherCoverage(m, w, h, radius) {
1114
- const out = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1115
+ const out = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1115
1116
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1116
1117
  return out;
1117
1118
  }
@@ -1259,7 +1260,7 @@ function layerMaskCoverage(mask) {
1259
1260
  let v = new Float32Array(sel.data.length);
1260
1261
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1261
1262
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1262
- if (feather > 0) v = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1263
+ if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1263
1264
  const density = _nullishCoalesce(mask.density, () => ( 1));
1264
1265
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1265
1266
  return v;
@@ -1480,7 +1481,7 @@ function normalizeAdjustmentLayer(raw) {
1480
1481
  kind: r.kind,
1481
1482
  enabled: r.enabled !== false,
1482
1483
  opacity: clampTo(r.opacity, 0, 1, 1),
1483
- blend: _chunkSZ6KMZNMcjs.normalizeBlendMode.call(void 0, r.blend),
1484
+ blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend),
1484
1485
  params: normParams(r.kind, r.params)
1485
1486
  };
1486
1487
  if (typeof r.name === "string" && r.name) layer.name = r.name;
@@ -1502,7 +1503,7 @@ function normalizeAdjustmentLayers(raw) {
1502
1503
  return out;
1503
1504
  }
1504
1505
  function curveLutFromLevels(points) {
1505
- return _chunkAZTZRLDIcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1506
+ return _chunkPOGBUYWEcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1506
1507
  }
1507
1508
  var toUnitLevels = (c) => ({
1508
1509
  inBlack: c.inBlack / 255,
@@ -1825,7 +1826,7 @@ function compileAdjustmentLayer(layer) {
1825
1826
  return (c) => {
1826
1827
  const g = blackWhiteGray(c, weights);
1827
1828
  if (tint) {
1828
- const t = _chunkSZ6KMZNMcjs.setLum.call(void 0, tint, g);
1829
+ const t = _chunkXIOMMGPDcjs.setLum.call(void 0, tint, g);
1829
1830
  c[0] = clamp01(t[0]);
1830
1831
  c[1] = clamp01(t[1]);
1831
1832
  c[2] = clamp01(t[2]);
@@ -1844,7 +1845,7 @@ function compileAdjustmentLayer(layer) {
1844
1845
  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])));
1845
1846
  if (preserve) {
1846
1847
  const target = 0.3 * c[0] + 0.59 * c[1] + 0.11 * c[2];
1847
- f = _chunkSZ6KMZNMcjs.setLum.call(void 0, f, target);
1848
+ f = _chunkXIOMMGPDcjs.setLum.call(void 0, f, target);
1848
1849
  }
1849
1850
  c[0] = clamp01(f[0]);
1850
1851
  c[1] = clamp01(f[1]);
@@ -1911,10 +1912,10 @@ function applyLayer(c, layer, op, coverage = 1) {
1911
1912
  const cb0 = c[0], cb1 = c[1], cb2 = c[2];
1912
1913
  op(c);
1913
1914
  if (blend === "pigment") {
1914
- _chunkSZ6KMZNMcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
1915
+ _chunkXIOMMGPDcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
1915
1916
  return;
1916
1917
  }
1917
- const b = blend === "normal" ? c : _chunkSZ6KMZNMcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
1918
+ const b = blend === "normal" ? c : _chunkXIOMMGPDcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
1918
1919
  c[0] = (1 - alpha) * cb0 + alpha * b[0];
1919
1920
  c[1] = (1 - alpha) * cb1 + alpha * b[1];
1920
1921
  c[2] = (1 - alpha) * cb2 + alpha * b[2];
@@ -2224,12 +2225,13 @@ function removeAlpha(imageData) {
2224
2225
  // src/image-editor/layers/model.ts
2225
2226
  var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
2226
2227
  var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
2228
+ var TEXT_ALIGNS = ["left", "center", "right", "justify"];
2227
2229
  var idCounter = 0;
2228
2230
  function newLayerId(prefix = "layer") {
2229
2231
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2230
2232
  }
2231
2233
  function pixelLayers(layers) {
2232
- return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2234
+ return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2233
2235
  }
2234
2236
  function developFilter(layer) {
2235
2237
  return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
@@ -2251,19 +2253,19 @@ function pixelLayerBounds(layer, surface = layer.surface) {
2251
2253
  return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
2252
2254
  }
2253
2255
  function layerTypeLabel(type) {
2254
- return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : "Annotation";
2256
+ return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : type === "type" ? "Type layer" : "Annotation";
2255
2257
  }
2256
2258
  function hasSurface(layer) {
2257
- return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape";
2259
+ return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2258
2260
  }
2259
2261
  function isRenderedLayer(layer) {
2260
- return layer.type === "smart" || layer.type === "shape";
2262
+ return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2261
2263
  }
2262
2264
  function shapeLayers(layers) {
2263
- return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2265
+ return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2264
2266
  }
2265
2267
  function smartObjectLayers(layers) {
2266
- return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2268
+ return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2267
2269
  }
2268
2270
 
2269
2271
  // src/image-editor/layers/compositor.ts
@@ -2359,7 +2361,7 @@ var PHOTO_PROFILE = {
2359
2361
  * A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
2360
2362
  * layer, and a shape layer the pixels rendered from its paths.
2361
2363
  */
2362
- isPixelLike: (l) => l.type === "smart" || l.type === "shape",
2364
+ isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
2363
2365
  maskSourcePlane: (source, W, H, sources) => {
2364
2366
  const opts = source;
2365
2367
  const depth = _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.depthMap, 'optionalCall', _18 => _18(opts)]), () => ( null));
@@ -2369,7 +2371,7 @@ var PHOTO_PROFILE = {
2369
2371
  return v;
2370
2372
  }
2371
2373
  };
2372
- var LayerCompositor = class extends _chunkAZTZRLDIcjs.RasterCompositor {
2374
+ var LayerCompositor = class extends _chunkPOGBUYWEcjs.RasterCompositor {
2373
2375
  constructor(options = {}) {
2374
2376
  super(PHOTO_PROFILE, options);
2375
2377
  }
@@ -2888,14 +2890,14 @@ function parseCssColor(value) {
2888
2890
  if (h.length <= 4) h = h.replace(/./g, (c) => c + c);
2889
2891
  return { hex: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
2890
2892
  }
2891
- const num3 = "([+-]?[\\d.]+%?)";
2892
- m = new RegExp(`^rgba?\\(\\s*${num3}[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
2893
+ const num4 = "([+-]?[\\d.]+%?)";
2894
+ m = new RegExp(`^rgba?\\(\\s*${num4}[\\s,]+${num4}[\\s,]+${num4}(?:\\s*[,/]\\s*${num4})?\\s*\\)$`).exec(text3);
2893
2895
  if (m) {
2894
2896
  const rgb = [m[1], m[2], m[3]].map(channel);
2895
2897
  if (!rgb.every(Number.isFinite)) return null;
2896
2898
  return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
2897
2899
  }
2898
- m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
2900
+ m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${num4}[\\s,]+${num4}(?:\\s*[,/]\\s*${num4})?\\s*\\)$`).exec(text3);
2899
2901
  if (m) {
2900
2902
  const rgb = hslToRgb2(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
2901
2903
  if (!rgb.every(Number.isFinite)) return null;
@@ -2915,54 +2917,54 @@ var fail = (message) => {
2915
2917
  throw new LayerOperationError(message);
2916
2918
  };
2917
2919
  function requireLayer(layers, id) {
2918
- const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, layers, id);
2920
+ const loc = _chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id);
2919
2921
  if (!loc) {
2920
- const ids = _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2922
+ const ids = _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2921
2923
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
2922
2924
  }
2923
2925
  return loc;
2924
2926
  }
2925
2927
  function requireUnlocked(layer, what, action) {
2926
- if (_chunkAZTZRLDIcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2927
- if (what !== "all" && _chunkAZTZRLDIcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${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}.`);
2928
2930
  }
2929
2931
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
2930
2932
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
2931
2933
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
2932
2934
  if (placement.aboveId || placement.belowId) {
2933
2935
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
2934
- return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
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));
2935
2937
  }
2936
2938
  if (placement.parentId) {
2937
2939
  const ref = requireLayer(layers, placement.parentId);
2938
2940
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
2939
- return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2941
+ return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2940
2942
  }
2941
- return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2943
+ return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2942
2944
  }
2943
2945
  function removeLayer(layers, id) {
2944
2946
  const loc = requireLayer(layers, id);
2945
2947
  requireUnlocked(loc.layer, "all", "delete it");
2946
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
2948
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
2947
2949
  }
2948
2950
  function moveLayer(layers, id, placement) {
2949
2951
  const loc = requireLayer(layers, id);
2950
2952
  requireUnlocked(loc.layer, "all", "move it");
2951
2953
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
2952
2954
  if (target === id) fail("A layer cannot be placed relative to itself.");
2953
- if (target && loc.layer.type === "group" && _chunkAZTZRLDIcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
2955
+ if (target && loc.layer.type === "group" && _chunkPOGBUYWEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
2954
2956
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
2955
2957
  }
2956
2958
  if (target) requireLayer(layers, target);
2957
2959
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
2958
- const without = _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
2960
+ const without = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
2959
2961
  return placeLayer(without, loc.layer, placement);
2960
2962
  }
2961
2963
  function withNewIds(layer) {
2962
2964
  const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
2963
2965
  if (next.type === "group") next.children = next.children.map(withNewIds);
2964
2966
  if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
2965
- if (next.type === "shape") delete next.annotation;
2967
+ if (next.type === "shape" || next.type === "type") delete next.annotation;
2966
2968
  if (next.type === "smart" && _optionalChain([next, 'access', _21 => _21.psd, 'optionalAccess', _22 => _22.placed])) {
2967
2969
  next.psd = { ...next.psd };
2968
2970
  delete next.psd.placed;
@@ -2974,7 +2976,7 @@ function duplicateLayer(layers, id, name) {
2974
2976
  const copy = withNewIds(loc.layer);
2975
2977
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
2976
2978
  delete copy.locks;
2977
- return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.id]), () => ( null)), loc.index + 1), id: copy.id };
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 };
2978
2980
  }
2979
2981
  function setLayerProperties(layers, id, props) {
2980
2982
  const loc = requireLayer(layers, id);
@@ -2992,7 +2994,7 @@ function setLayerProperties(layers, id, props) {
2992
2994
  next.opacity = props.opacity;
2993
2995
  }
2994
2996
  if (props.fillOpacity !== void 0) {
2995
- if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape") fail(`fillOpacity applies to pixel, shape and smart object layers; "${id}" is a ${layer.type} layer.`);
2997
+ if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape" && layer.type !== "type") fail(`fillOpacity applies to pixel, shape, type and smart object layers; "${id}" is a ${layer.type} layer.`);
2996
2998
  if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail("fillOpacity must be a number from 0 to 1.");
2997
2999
  const p = next;
2998
3000
  if (props.fillOpacity === 1) delete p.fillOpacity;
@@ -3001,7 +3003,7 @@ function setLayerProperties(layers, id, props) {
3001
3003
  if (props.blend !== void 0) {
3002
3004
  if (props.blend === "pass-through") {
3003
3005
  if (layer.type !== "group") fail("pass-through is only for groups.");
3004
- } else if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
3006
+ } else if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
3005
3007
  next.blend = props.blend;
3006
3008
  }
3007
3009
  if (props.clipped !== void 0) {
@@ -3021,7 +3023,7 @@ function setLayerProperties(layers, id, props) {
3021
3023
  if (props.collapsed) g.collapsed = true;
3022
3024
  else delete g.collapsed;
3023
3025
  }
3024
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3026
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3025
3027
  }
3026
3028
  function groupLayers(layers, ids, name = "Group") {
3027
3029
  if (!ids.length) fail("Give at least one layer id to group.");
@@ -3050,17 +3052,17 @@ function groupLayers(layers, ids, name = "Group") {
3050
3052
  group.children[0] = c;
3051
3053
  }
3052
3054
  let out = layers;
3053
- for (const l of ordered) out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3054
- return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
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 };
3055
3057
  }
3056
3058
  function ungroupLayer(layers, id) {
3057
3059
  const loc = requireLayer(layers, id);
3058
3060
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
3059
3061
  requireUnlocked(loc.layer, "all", "ungroup it");
3060
3062
  const group = loc.layer;
3061
- let out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
3063
+ let out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
3062
3064
  group.children.forEach((c, i) => {
3063
- out = _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.id]), () => ( null)), loc.index + 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);
3064
3066
  });
3065
3067
  return { layers: out, ids: group.children.map((c) => c.id) };
3066
3068
  }
@@ -3073,14 +3075,14 @@ function offsetLayer(layers, id, offset) {
3073
3075
  const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
3074
3076
  const mask = layer.mask;
3075
3077
  if (mask && mask.linked === false && !mask.source) {
3076
- next.mask = { ...mask, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3078
+ next.mask = { ...mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3077
3079
  }
3078
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3080
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3079
3081
  }
3080
3082
  function setLayerMask(layers, id, mask) {
3081
3083
  const loc = requireLayer(layers, id);
3082
3084
  requireUnlocked(loc.layer, "all", "change its mask");
3083
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, (l) => {
3085
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, (l) => {
3084
3086
  const next = { ...l };
3085
3087
  if (mask) next.mask = mask;
3086
3088
  else delete next.mask;
@@ -3119,7 +3121,7 @@ function requirePixelLayer(layers, id) {
3119
3121
  function addLayerFilter(layers, id, filter) {
3120
3122
  const layer = requirePixelLayer(layers, id);
3121
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.`);
3122
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3124
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3123
3125
  }
3124
3126
  function updateLayerFilter(layers, id, filterId, changes) {
3125
3127
  const layer = requirePixelLayer(layers, id);
@@ -3130,7 +3132,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
3130
3132
  const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
3131
3133
  const filters = [...layer.filters];
3132
3134
  filters[i] = merged;
3133
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3135
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3134
3136
  }
3135
3137
  function removeLayerFilter(layers, id, filterId) {
3136
3138
  const layer = requirePixelLayer(layers, id);
@@ -3139,7 +3141,7 @@ function removeLayerFilter(layers, id, filterId) {
3139
3141
  const next = { ...layer };
3140
3142
  if (filters.length) next.filters = filters;
3141
3143
  else delete next.filters;
3142
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3144
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3143
3145
  }
3144
3146
  function requireEffectLayer(layers, id, action) {
3145
3147
  const layer = requireLayer(layers, id).layer;
@@ -3154,7 +3156,7 @@ function guard(fn) {
3154
3156
  try {
3155
3157
  return fn();
3156
3158
  } catch (e) {
3157
- if (e instanceof _chunkAZTZRLDIcjs.LayerEffectError) fail(e.message);
3159
+ if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail(e.message);
3158
3160
  throw e;
3159
3161
  }
3160
3162
  }
@@ -3162,20 +3164,20 @@ function setLayerEffects(layers, id, effects) {
3162
3164
  const layer = requireEffectLayer(layers, id, "change its effects");
3163
3165
  const next = { ...layer };
3164
3166
  if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
3165
- guard(() => _chunkAZTZRLDIcjs.validateLayerEffects.call(void 0, effects));
3167
+ guard(() => _chunkPOGBUYWEcjs.validateLayerEffects.call(void 0, effects));
3166
3168
  next.effects = effects;
3167
3169
  } else delete next.effects;
3168
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3170
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
3169
3171
  }
3170
3172
  function addLayerEffect(layers, id, kind, params = {}, index) {
3171
- if (!_chunkAZTZRLDIcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkAZTZRLDIcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3173
+ if (!_chunkPOGBUYWEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkPOGBUYWEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3172
3174
  const layer = requireEffectLayer(layers, id, "add effects");
3173
3175
  const current = layerEffectsOf(layer);
3174
3176
  const ids = new Set(current.items.map((e) => e.id));
3175
- let effectId = _chunkAZTZRLDIcjs.newEffectId.call(void 0, );
3176
- while (ids.has(effectId)) effectId = _chunkAZTZRLDIcjs.newEffectId.call(void 0, );
3177
+ let effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
3178
+ while (ids.has(effectId)) effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
3177
3179
  const { id: _ignored, kind: _kind, ...rest } = params;
3178
- const effect = guard(() => _chunkAZTZRLDIcjs.mergeLayerEffect.call(void 0, _chunkAZTZRLDIcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3180
+ const effect = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3179
3181
  const items = [...current.items];
3180
3182
  const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
3181
3183
  items.splice(at, 0, effect);
@@ -3192,7 +3194,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
3192
3194
  const i = requireEffect(layer, effectId);
3193
3195
  const current = layer.effects;
3194
3196
  const items = [...current.items];
3195
- items[i] = guard(() => _chunkAZTZRLDIcjs.mergeLayerEffect.call(void 0, items[i], changes));
3197
+ items[i] = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, items[i], changes));
3196
3198
  return setLayerEffects(layers, id, { ...current, items });
3197
3199
  }
3198
3200
  function removeLayerEffect(layers, id, effectId) {
@@ -3215,7 +3217,7 @@ function setLayerEffectsEnabled(layers, id, enabled, scale) {
3215
3217
  function parseBlend(value, allowPassThrough = false) {
3216
3218
  if (value === void 0) return void 0;
3217
3219
  if (value === "pass-through" && allowPassThrough) return value;
3218
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3220
+ if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3219
3221
  return value;
3220
3222
  }
3221
3223
  function unionRect(a, b) {
@@ -3227,7 +3229,7 @@ function unionRect(a, b) {
3227
3229
  }
3228
3230
 
3229
3231
  // src/image-editor/layers/shape.ts
3230
- var SHAPE_RENDER_MARGIN = _chunkAZTZRLDIcjs.MAX_EFFECT_REACH;
3232
+ var SHAPE_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
3231
3233
  var DEFAULT_MITER_LIMIT = 100;
3232
3234
  var fail2 = (message) => {
3233
3235
  throw new LayerOperationError(message);
@@ -3436,11 +3438,11 @@ function fillCoverage(geo, rect, rule) {
3436
3438
  function paintContext(env) {
3437
3439
  const tiles = /* @__PURE__ */ new Map();
3438
3440
  return {
3439
- light: _chunkAZTZRLDIcjs.DEFAULT_GLOBAL_LIGHT,
3441
+ light: _chunkPOGBUYWEcjs.DEFAULT_GLOBAL_LIGHT,
3440
3442
  pattern: (id) => {
3441
3443
  if (tiles.has(id)) return tiles.get(id);
3442
- const p = _nullishCoalesce(_optionalChain([env, 'access', _42 => _42.pattern, 'optionalCall', _43 => _43(id)]), () => ( _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)));
3443
- const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkAZTZRLDIcjs.PatternTile)(p) : null;
3444
+ const p = _nullishCoalesce(_optionalChain([env, 'access', _42 => _42.pattern, 'optionalCall', _43 => _43(id)]), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
3445
+ const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkPOGBUYWEcjs.PatternTile)(p) : null;
3444
3446
  tiles.set(id, t);
3445
3447
  return t;
3446
3448
  }
@@ -3471,9 +3473,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3471
3473
  if (!fCov && !sCov) return null;
3472
3474
  const canvas = { x: 0, y: 0, width: env.width, height: env.height };
3473
3475
  const anchor = { x: geo.frame.x, y: geo.frame.y };
3474
- const fc = fCov ? _chunkAZTZRLDIcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3476
+ const fc = fCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3475
3477
  const fo = _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.fill, 'optionalAccess', _45 => _45.opacity]), () => ( 1));
3476
- const sc = sCov ? _chunkAZTZRLDIcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3478
+ const sc = sCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3477
3479
  const so = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.stroke, 'optionalAccess', _47 => _47.paint, 'access', _48 => _48.opacity]), () => ( 1));
3478
3480
  const out = new Uint8ClampedArray(n * 4);
3479
3481
  let any = false;
@@ -3512,20 +3514,20 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3512
3514
  }
3513
3515
  function renderShape(layer, env, options = {}) {
3514
3516
  const geo = shapeGeometry(layer);
3515
- if (!geo.bounds) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
3517
+ if (!geo.bounds) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
3516
3518
  let region = intersect(geo.bounds, shapeRenderClip(env));
3517
3519
  if (region && options.clip) region = intersect(region, options.clip);
3518
- if (!region) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
3520
+ if (!region) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
3519
3521
  const ctx = paintContext(env);
3520
3522
  const tiles = /* @__PURE__ */ new Map();
3521
- for (const { tx, ty } of _chunkSZ6KMZNMcjs.tilesInRect.call(void 0, region)) {
3522
- const rect = { x: tx * _chunkSZ6KMZNMcjs.TILE, y: ty * _chunkSZ6KMZNMcjs.TILE, width: _chunkSZ6KMZNMcjs.TILE, height: _chunkSZ6KMZNMcjs.TILE };
3523
+ for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
3524
+ const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
3523
3525
  const px = renderShapeRect(layer, rect, env, ctx);
3524
3526
  if (!px) continue;
3525
- const tile = _chunkSZ6KMZNMcjs.finishTile.call(void 0, px, 4, 0);
3526
- if (tile) tiles.set(_chunkSZ6KMZNMcjs.tileKey.call(void 0, tx, ty), tile);
3527
+ const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px, 4, 0);
3528
+ if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
3527
3529
  }
3528
- return new (0, _chunkSZ6KMZNMcjs.TiledSurface)(4, tiles, 0);
3530
+ return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
3529
3531
  }
3530
3532
  function rerenderShape(layer, env) {
3531
3533
  return { ...layer, surface: renderShape(layer, env) };
@@ -3566,9 +3568,9 @@ function normalizeShapePaint(v, path = "paint") {
3566
3568
  offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
3567
3569
  };
3568
3570
  try {
3569
- _chunkAZTZRLDIcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3571
+ _chunkPOGBUYWEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3570
3572
  } catch (e) {
3571
- if (e instanceof _chunkAZTZRLDIcjs.LayerEffectError) fail2(e.message);
3573
+ if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail2(e.message);
3572
3574
  throw e;
3573
3575
  }
3574
3576
  if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
@@ -3749,7 +3751,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
3749
3751
  components: init.components,
3750
3752
  fill: init.fill === void 0 ? null : init.fill,
3751
3753
  stroke: _nullishCoalesce(init.stroke, () => ( null)),
3752
- surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
3754
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
3753
3755
  offset: { x: 0, y: 0 }
3754
3756
  };
3755
3757
  if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
@@ -3779,7 +3781,7 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
3779
3781
  if (!("annotation" in patch)) delete next.annotation;
3780
3782
  if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
3781
3783
  const rendered = rerenderShape(next, env);
3782
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3784
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3783
3785
  }
3784
3786
  function transformShapeComponents(components, f, affine) {
3785
3787
  return components.map((c) => {
@@ -3810,7 +3812,7 @@ function shapeAsPixelLayer(layer) {
3810
3812
  }
3811
3813
  function annotationPaint(color, opacity) {
3812
3814
  const c = parseCssColor(color);
3813
- if (!c || !_chunkAZTZRLDIcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3815
+ if (!c || !_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3814
3816
  const a = c.alpha * opacity;
3815
3817
  return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
3816
3818
  }
@@ -3874,7 +3876,7 @@ function shapeFromAnnotation(a) {
3874
3876
  }
3875
3877
  function annotationBlend(a, layerBlend) {
3876
3878
  if (layerBlend !== "normal") return layerBlend;
3877
- return a.blend && _chunkSZ6KMZNMcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3879
+ return a.blend && _chunkXIOMMGPDcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3878
3880
  }
3879
3881
  function annotationOfShape(layer) {
3880
3882
  const a = layer.annotation;
@@ -3887,6 +3889,671 @@ function annotationOfShape(layer) {
3887
3889
  return out;
3888
3890
  }
3889
3891
 
3892
+ // src/image-editor/layers/text.ts
3893
+ var fail3 = (message) => {
3894
+ throw new LayerOperationError(message);
3895
+ };
3896
+ var DEFAULT_TEXT_STYLE = { fontFamily: "sans-serif", fontWeight: 400, fontSize: 24, color: "#000000" };
3897
+ var DEFAULT_AUTO_LEADING = 1.2;
3898
+ var sameStyle = (a, b) => JSON.stringify(a) === JSON.stringify(b);
3899
+ function compact(runs) {
3900
+ const out = [];
3901
+ for (const r of runs) {
3902
+ if (r.length <= 0) continue;
3903
+ const last = out[out.length - 1];
3904
+ if (last && sameStyle(last.style, r.style)) out[out.length - 1] = { ...last, length: last.length + r.length };
3905
+ else out.push({ ...r });
3906
+ }
3907
+ return out;
3908
+ }
3909
+ function fitRuns(runs, length, fallback) {
3910
+ const out = [];
3911
+ let left = length;
3912
+ for (const r of runs) {
3913
+ if (left <= 0) break;
3914
+ const n = Math.min(Math.max(0, Math.floor(r.length)), left);
3915
+ if (n > 0) out.push({ ...r, length: n });
3916
+ left -= n;
3917
+ }
3918
+ if (left > 0) {
3919
+ if (out.length) out[out.length - 1] = { ...out[out.length - 1], length: out[out.length - 1].length + left };
3920
+ else out.push({ length: left, style: _nullishCoalesce(_optionalChain([runs, 'access', _59 => _59[runs.length - 1], 'optionalAccess', _60 => _60.style]), () => ( fallback)) });
3921
+ }
3922
+ return compact(out);
3923
+ }
3924
+ function styleAt(runs, index, fallback) {
3925
+ let at = 0;
3926
+ for (const r of runs) {
3927
+ if (index < at + r.length) return r.style;
3928
+ at += r.length;
3929
+ }
3930
+ return _nullishCoalesce(_optionalChain([runs, 'access', _61 => _61[runs.length - 1], 'optionalAccess', _62 => _62.style]), () => ( fallback));
3931
+ }
3932
+ function restyleRange(runs, start, end, patch) {
3933
+ const out = [];
3934
+ let at = 0;
3935
+ for (const r of runs) {
3936
+ const a = at;
3937
+ const b = at + r.length;
3938
+ at = b;
3939
+ const lo = Math.max(a, start);
3940
+ const hi = Math.min(b, end);
3941
+ if (hi <= lo) {
3942
+ out.push({ ...r });
3943
+ continue;
3944
+ }
3945
+ if (lo > a) out.push({ length: lo - a, style: r.style });
3946
+ out.push({ length: hi - lo, style: patch(r.style) });
3947
+ if (b > hi) out.push({ length: b - hi, style: r.style });
3948
+ }
3949
+ return compact(out);
3950
+ }
3951
+ function spliceRuns(runs, start, end, inserted, style) {
3952
+ const out = [];
3953
+ let at = 0;
3954
+ let placed = false;
3955
+ for (const r of runs) {
3956
+ const a = at;
3957
+ const b = at + r.length;
3958
+ at = b;
3959
+ if (b <= start) {
3960
+ out.push({ ...r });
3961
+ continue;
3962
+ }
3963
+ if (a < start) out.push({ length: start - a, style: r.style });
3964
+ if (!placed) {
3965
+ out.push({ length: inserted, style });
3966
+ placed = true;
3967
+ }
3968
+ if (b > end) out.push({ length: b - Math.max(end, a), style: r.style });
3969
+ }
3970
+ if (!placed) out.push({ length: inserted, style });
3971
+ return compact(out);
3972
+ }
3973
+ function paragraphRanges(text3) {
3974
+ const out = [];
3975
+ let start = 0;
3976
+ for (let i = 0; i < text3.length; i++) {
3977
+ if (text3[i] === "\n") {
3978
+ out.push({ start, end: i + 1, content: i });
3979
+ start = i + 1;
3980
+ }
3981
+ }
3982
+ out.push({ start, end: text3.length, content: text3.length });
3983
+ return out;
3984
+ }
3985
+ function fitParagraphRuns(runs, text3) {
3986
+ const fallback = _nullishCoalesce(_optionalChain([runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( {}));
3987
+ const out = compact(paragraphRanges(text3).map((p) => ({ length: p.end - p.start, style: styleAt(runs, p.start, fallback) })));
3988
+ return out.length ? out : [{ length: 0, style: fallback }];
3989
+ }
3990
+ function fontOf(style) {
3991
+ const f = { family: style.fontFamily, weight: style.fontWeight, italic: Boolean(style.italic), size: style.fontSize };
3992
+ if (style.postScriptName) f.postScriptName = style.postScriptName;
3993
+ return f;
3994
+ }
3995
+ var isBreakAfter = (c) => c === " " || c === " " || c === "-" || c === "\u2010" || c === "\u200B";
3996
+ var isSpace = (c) => c === " " || c === " ";
3997
+ var isWide = (code) => code >= 11904 && code <= 40959 || code >= 44032 && code <= 55215 || code >= 63744 && code <= 64255 || code >= 65280 && code <= 65519;
3998
+ var layoutCache = /* @__PURE__ */ new WeakMap();
3999
+ function layoutText(layer, shaper) {
4000
+ let byShaper = layoutCache.get(layer);
4001
+ const hit = _optionalChain([byShaper, 'optionalAccess', _65 => _65.get, 'call', _66 => _66(shaper.id)]);
4002
+ if (hit) return hit;
4003
+ const out = computeLayout(layer, shaper);
4004
+ if (!byShaper) {
4005
+ byShaper = /* @__PURE__ */ new Map();
4006
+ layoutCache.set(layer, byShaper);
4007
+ }
4008
+ byShaper.set(shaper.id, out);
4009
+ return out;
4010
+ }
4011
+ function computeLayout(layer, shaper) {
4012
+ const { text: text3, frame } = layer;
4013
+ const runs = fitRuns(layer.runs, text3.length, DEFAULT_TEXT_STYLE);
4014
+ const missing = /* @__PURE__ */ new Set();
4015
+ const resolved = /* @__PURE__ */ new Map();
4016
+ const familyOf = (font) => {
4017
+ const key = `${font.family}|${font.weight}|${font.italic}|${_nullishCoalesce(font.postScriptName, () => ( ""))}`;
4018
+ let fam = resolved.get(key);
4019
+ if (fam === void 0) {
4020
+ const r = shaper.resolve(font);
4021
+ fam = r.family;
4022
+ if (!r.available) missing.add(font.family);
4023
+ resolved.set(key, fam);
4024
+ }
4025
+ return fam;
4026
+ };
4027
+ const resolvedFont = (style) => ({ ...fontOf(style), family: familyOf(fontOf(style)) });
4028
+ const box2 = frame.kind === "box" ? frame : null;
4029
+ const lines = [];
4030
+ let y = 0;
4031
+ let first = true;
4032
+ const paragraphs = paragraphRanges(text3);
4033
+ paragraphs.forEach((para, pi) => {
4034
+ const pstyle = styleAt(layer.paragraphs, para.start, {});
4035
+ const autoLeading = _nullishCoalesce(pstyle.autoLeading, () => ( DEFAULT_AUTO_LEADING));
4036
+ if (pi > 0) y += _nullishCoalesce(pstyle.spaceBefore, () => ( 0));
4037
+ const chars = [];
4038
+ let i = para.start;
4039
+ while (i < para.content) {
4040
+ const style = styleAt(runs, i, DEFAULT_TEXT_STYLE);
4041
+ let j = i + 1;
4042
+ while (j < para.content && styleAt(runs, j, DEFAULT_TEXT_STYLE) === style) j++;
4043
+ const seg = text3.slice(i, j);
4044
+ const carets = shaper.measure(seg, resolvedFont(style));
4045
+ const track = (_nullishCoalesce(style.tracking, () => ( 0))) / 1e3 * style.fontSize;
4046
+ 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 });
4047
+ i = j;
4048
+ }
4049
+ const startIndent = _nullishCoalesce(pstyle.startIndent, () => ( 0));
4050
+ const endIndent = _nullishCoalesce(pstyle.endIndent, () => ( 0));
4051
+ const firstIndent = _nullishCoalesce(pstyle.firstLineIndent, () => ( 0));
4052
+ const breaks = [];
4053
+ if (!box2 || !chars.length) breaks.push([0, chars.length]);
4054
+ else {
4055
+ let s = 0;
4056
+ while (s < chars.length) {
4057
+ const avail = box2.width - startIndent - endIndent - (breaks.length === 0 ? firstIndent : 0);
4058
+ let w = 0;
4059
+ let e = s;
4060
+ let lastBreak = -1;
4061
+ while (e < chars.length) {
4062
+ const c = chars[e];
4063
+ if (!isSpace(c.ch) && w + c.advance > avail && e > s) break;
4064
+ w += c.advance;
4065
+ if (isBreakAfter(c.ch) || isWide(c.ch.charCodeAt(0)) || e + 1 < chars.length && isWide(chars[e + 1].ch.charCodeAt(0))) lastBreak = e + 1;
4066
+ e++;
4067
+ }
4068
+ if (e < chars.length && lastBreak > s) e = lastBreak;
4069
+ while (e < chars.length && isSpace(chars[e].ch)) e++;
4070
+ breaks.push([s, e]);
4071
+ s = e;
4072
+ }
4073
+ }
4074
+ const align = _nullishCoalesce(pstyle.align, () => ( "left"));
4075
+ breaks.forEach(([s, e], li) => {
4076
+ const lineChars = chars.slice(s, e);
4077
+ let visibleEnd = lineChars.length;
4078
+ while (visibleEnd > 0 && isSpace(lineChars[visibleEnd - 1].ch)) visibleEnd--;
4079
+ 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)];
4080
+ let ascent = 0;
4081
+ let descent = 0;
4082
+ let leading = 0;
4083
+ for (const st of styles) {
4084
+ const m = shaper.metrics(resolvedFont(st));
4085
+ ascent = Math.max(ascent, m.ascent);
4086
+ descent = Math.max(descent, m.descent);
4087
+ leading = Math.max(leading, _nullishCoalesce(st.leading, () => ( autoLeading * st.fontSize)));
4088
+ }
4089
+ if (first) {
4090
+ y = frame.kind === "box" || frame.kind === "point" && frame.origin === "top" ? ascent : 0;
4091
+ first = false;
4092
+ } else y += leading;
4093
+ const indent = startIndent + (li === 0 ? firstIndent : 0);
4094
+ let width = 0;
4095
+ for (let k2 = 0; k2 < visibleEnd; k2++) width += lineChars[k2].advance;
4096
+ const lastLine = li === breaks.length - 1;
4097
+ let extraPerSpace = 0;
4098
+ if (box2 && align === "justify" && !lastLine) {
4099
+ const spaces = lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
4100
+ const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
4101
+ if (spaces > 0 && avail > width) extraPerSpace = (avail - width) / spaces;
4102
+ }
4103
+ let x0;
4104
+ const fullWidth = width + extraPerSpace * lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
4105
+ if (box2) {
4106
+ const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
4107
+ x0 = indent + (align === "center" ? (avail - fullWidth) / 2 : align === "right" ? avail - fullWidth : 0);
4108
+ } else x0 = indent + (align === "center" ? -fullWidth / 2 : align === "right" ? -fullWidth : 0);
4109
+ const laid = [];
4110
+ let x = x0;
4111
+ for (const c of lineChars) {
4112
+ const adv = c.advance + (isSpace(c.ch) ? extraPerSpace : 0);
4113
+ laid.push({ index: c.index, x, advance: adv });
4114
+ x += adv;
4115
+ }
4116
+ const fragments = [];
4117
+ let k = 0;
4118
+ while (k < lineChars.length) {
4119
+ const st = lineChars[k].style;
4120
+ let m = k + 1;
4121
+ while (m < lineChars.length && lineChars[m].style === st) m++;
4122
+ const font = resolvedFont(st);
4123
+ const fx = laid[k].x;
4124
+ const carets = [0];
4125
+ for (let q2 = k; q2 < m; q2++) carets.push(laid[q2].x + laid[q2].advance - fx);
4126
+ fragments.push({
4127
+ start: lineChars[k].index,
4128
+ end: lineChars[m - 1].index + 1,
4129
+ style: st,
4130
+ font,
4131
+ family: font.family,
4132
+ x: fx,
4133
+ y: y - (_nullishCoalesce(st.baselineShift, () => ( 0))),
4134
+ carets,
4135
+ spaced: Boolean(st.tracking) || extraPerSpace > 0
4136
+ });
4137
+ k = m;
4138
+ }
4139
+ const lineStart = lineChars.length ? lineChars[0].index : para.start;
4140
+ 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 });
4141
+ });
4142
+ y += _nullishCoalesce(pstyle.spaceAfter, () => ( 0));
4143
+ });
4144
+ let bounds;
4145
+ if (box2) bounds = { x: 0, y: 0, width: box2.width, height: box2.height };
4146
+ else {
4147
+ let x0 = Infinity;
4148
+ let x1 = -Infinity;
4149
+ for (const l of lines) {
4150
+ x0 = Math.min(x0, l.x);
4151
+ x1 = Math.max(x1, l.x + l.width);
4152
+ }
4153
+ if (!Number.isFinite(x0)) x0 = x1 = 0;
4154
+ const top = lines.length ? lines[0].baseline - lines[0].ascent : 0;
4155
+ const last = lines[lines.length - 1];
4156
+ const bottom = last ? last.baseline + last.descent : 0;
4157
+ bounds = { x: x0, y: top, width: Math.max(0, x1 - x0), height: Math.max(0, bottom - top) };
4158
+ }
4159
+ return { lines, bounds, missingFonts: [...missing] };
4160
+ }
4161
+ function textIndexAt(layout, p) {
4162
+ if (!layout.lines.length) return 0;
4163
+ let line = layout.lines[layout.lines.length - 1];
4164
+ for (const l of layout.lines) {
4165
+ if (p.y <= l.baseline + l.descent) {
4166
+ line = l;
4167
+ break;
4168
+ }
4169
+ }
4170
+ if (!line.chars.length) return line.start;
4171
+ for (const c of line.chars) if (p.x < c.x + c.advance / 2) return c.index;
4172
+ const lastChar = line.chars[line.chars.length - 1];
4173
+ return lastChar.index + 1;
4174
+ }
4175
+ function caretAt(layout, index) {
4176
+ const lines = layout.lines;
4177
+ if (!lines.length) return { x: 0, top: 0, bottom: 0, line: 0 };
4178
+ for (let li = 0; li < lines.length; li++) {
4179
+ const l2 = lines[li];
4180
+ const next = lines[li + 1];
4181
+ if (next && index >= next.start && (next.chars.length || index > l2.end || next.start > l2.end)) continue;
4182
+ const c = l2.chars.find((ch) => ch.index === index);
4183
+ const prev = l2.chars.find((ch) => ch.index === index - 1);
4184
+ const x = c ? c.x : prev ? prev.x + prev.advance : l2.x;
4185
+ return { x, top: l2.baseline - l2.ascent, bottom: l2.baseline + l2.descent, line: li };
4186
+ }
4187
+ const l = lines[lines.length - 1];
4188
+ return { x: l.x + l.width, top: l.baseline - l.ascent, bottom: l.baseline + l.descent, line: lines.length - 1 };
4189
+ }
4190
+ var TEXT_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
4191
+ function textMatrix(layer) {
4192
+ return _nullishCoalesce(layer.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX));
4193
+ }
4194
+ function rectCorners(r) {
4195
+ return [
4196
+ { x: r.x, y: r.y },
4197
+ { x: r.x + r.width, y: r.y },
4198
+ { x: r.x + r.width, y: r.y + r.height },
4199
+ { x: r.x, y: r.y + r.height }
4200
+ ];
4201
+ }
4202
+ function docRect(r, m) {
4203
+ const pts = rectCorners(r).map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p));
4204
+ const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
4205
+ const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
4206
+ const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
4207
+ const y1 = Math.ceil(Math.max(...pts.map((p) => p.y)));
4208
+ return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
4209
+ }
4210
+ function intersect2(a, b) {
4211
+ const x0 = Math.max(a.x, b.x);
4212
+ const y0 = Math.max(a.y, b.y);
4213
+ const x1 = Math.min(a.x + a.width, b.x + b.width);
4214
+ const y1 = Math.min(a.y + a.height, b.y + b.height);
4215
+ return x1 > x0 && y1 > y0 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;
4216
+ }
4217
+ function inkBounds(layout) {
4218
+ let b = null;
4219
+ for (const l of layout.lines) {
4220
+ for (const f of l.fragments) {
4221
+ const pad = f.style.fontSize * 0.5;
4222
+ const w = f.carets[f.carets.length - 1];
4223
+ const r = { x: f.x - pad, y: f.y - l.ascent - pad, width: w + 2 * pad, height: l.ascent + l.descent + 2 * pad };
4224
+ if (!b) b = r;
4225
+ else {
4226
+ const x0 = Math.min(b.x, r.x);
4227
+ const y0 = Math.min(b.y, r.y);
4228
+ b = { x: x0, y: y0, width: Math.max(b.x + b.width, r.x + r.width) - x0, height: Math.max(b.y + b.height, r.y + r.height) - y0 };
4229
+ }
4230
+ }
4231
+ }
4232
+ return b;
4233
+ }
4234
+ function decorations(f, l) {
4235
+ const out = [];
4236
+ const t = Math.max(1, f.style.fontSize / 15);
4237
+ const w = f.carets[f.carets.length - 1];
4238
+ if (f.style.underline) out.push({ x: f.x, y: f.y + Math.max(t, l.descent * 0.35), width: w, height: t });
4239
+ if (f.style.strikethrough) out.push({ x: f.x, y: f.y - l.ascent * 0.3 - t / 2, width: w, height: t });
4240
+ return out;
4241
+ }
4242
+ var rectPath = (r) => [
4243
+ { type: "M", x: r.x, y: r.y },
4244
+ { type: "L", x: r.x + r.width, y: r.y },
4245
+ { type: "L", x: r.x + r.width, y: r.y + r.height },
4246
+ { type: "L", x: r.x, y: r.y + r.height },
4247
+ { type: "Z" }
4248
+ ];
4249
+ function fragmentOutline(shaper, text3, f) {
4250
+ const s = text3.slice(f.start, f.end);
4251
+ if (!f.spaced) return shaper.outline(s, f.font, f.x, f.y);
4252
+ const out = [];
4253
+ for (let k = 0; k < s.length; k++) {
4254
+ if (isSpace(s[k])) continue;
4255
+ out.push(...shaper.outline(s[k], f.font, f.x + f.carets[k], f.y));
4256
+ }
4257
+ return out;
4258
+ }
4259
+ function textOutlines(layer, shaper) {
4260
+ if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
4261
+ const layout = layoutText(layer, shaper);
4262
+ const m = textMatrix(layer);
4263
+ const out = [];
4264
+ for (const l of layout.lines) {
4265
+ for (const f of l.fragments) {
4266
+ let path = fragmentOutline(shaper, layer.text, f);
4267
+ for (const r of decorations(f, l)) path = [...path, ...rectPath(r)];
4268
+ out.push({ fragment: f, path: _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
4269
+ }
4270
+ }
4271
+ return out;
4272
+ }
4273
+ var rgbOf = (hex) => {
4274
+ const c = parseCssColor(hex);
4275
+ const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _67 => _67.hex]), () => ( "#000000"))).slice(1);
4276
+ return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
4277
+ };
4278
+ function renderOutlines(layer, shaper, region) {
4279
+ const parts = textOutlines(layer, shaper).map(({ fragment, path }) => ({ style: fragment.style, flat: flattenPath(path) }));
4280
+ const tiles = /* @__PURE__ */ new Map();
4281
+ for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
4282
+ const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
4283
+ const n = _chunkXIOMMGPDcjs.TILE * _chunkXIOMMGPDcjs.TILE;
4284
+ const acc = new Float32Array(n * 4);
4285
+ let any = false;
4286
+ for (const p of parts) {
4287
+ const cov = rasterizeCoverageSampled(p.flat, rect, "nonzero");
4288
+ if (!cov) continue;
4289
+ const [r, g, b] = rgbOf(p.style.color);
4290
+ const op = _nullishCoalesce(p.style.opacity, () => ( 1));
4291
+ for (let i = 0; i < n; i++) {
4292
+ const sa = layer.antiAlias === false ? cov[i] >= 0.5 ? op : 0 : cov[i] * op;
4293
+ if (!(sa > 0)) continue;
4294
+ const k = i * 4;
4295
+ const da = acc[k + 3];
4296
+ const ao = sa + da * (1 - sa);
4297
+ acc[k] = (r * sa + acc[k] * da * (1 - sa)) / ao;
4298
+ acc[k + 1] = (g * sa + acc[k + 1] * da * (1 - sa)) / ao;
4299
+ acc[k + 2] = (b * sa + acc[k + 2] * da * (1 - sa)) / ao;
4300
+ acc[k + 3] = ao;
4301
+ any = true;
4302
+ }
4303
+ }
4304
+ if (!any) continue;
4305
+ const px = new Uint8ClampedArray(n * 4);
4306
+ for (let i = 0; i < n * 4; i += 4) {
4307
+ const a = Math.round(acc[i + 3] * 255);
4308
+ if (!a) continue;
4309
+ px[i] = Math.round(acc[i]);
4310
+ px[i + 1] = Math.round(acc[i + 1]);
4311
+ px[i + 2] = Math.round(acc[i + 2]);
4312
+ px[i + 3] = a;
4313
+ }
4314
+ const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px, 4, 0);
4315
+ if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
4316
+ }
4317
+ return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
4318
+ }
4319
+ function renderOnCanvas(layer, shaper, region, env) {
4320
+ if (!env.createCanvas) return null;
4321
+ const canvas = env.createCanvas(region.width, region.height);
4322
+ const ctx = canvas.getContext("2d");
4323
+ if (!ctx || typeof ctx.getImageData !== "function") return null;
4324
+ const layout = layoutText(layer, shaper);
4325
+ const m = textMatrix(layer);
4326
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
4327
+ ctx.clearRect(0, 0, region.width, region.height);
4328
+ ctx.setTransform(m[0], m[1], m[2], m[3], m[4] - region.x, m[5] - region.y);
4329
+ for (const l of layout.lines) {
4330
+ for (const f of l.fragments) {
4331
+ const [r, g, b] = rgbOf(f.style.color);
4332
+ ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
4333
+ ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
4334
+ const s = layer.text.slice(f.start, f.end);
4335
+ if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
4336
+ 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);
4337
+ for (const d of decorations(f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
4338
+ }
4339
+ }
4340
+ ctx.globalAlpha = 1;
4341
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
4342
+ const data = ctx.getImageData(0, 0, region.width, region.height).data;
4343
+ return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: region.width, height: region.height, data: new Uint8ClampedArray(data) }, 4, region.x, region.y);
4344
+ }
4345
+ function renderText(layer, env) {
4346
+ const shaper = env.shaper;
4347
+ if (!shaper || !shaper.outline && !shaper.draw) return null;
4348
+ const layout = layoutText(layer, shaper);
4349
+ const ink = inkBounds(layout);
4350
+ const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
4351
+ const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
4352
+ if (!region) return { surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), missingFonts: layout.missingFonts };
4353
+ if (shaper.outline) return { surface: renderOutlines(layer, shaper, region), missingFonts: layout.missingFonts };
4354
+ const surface = renderOnCanvas(layer, shaper, region, env);
4355
+ return surface ? { surface, missingFonts: layout.missingFonts } : null;
4356
+ }
4357
+ function rerenderText(layer, env) {
4358
+ const r = renderText(layer, env);
4359
+ if (!r) return fail3("Type layers need a text shaper to draw them, and none is set here (no 2D canvas). Pass textShaper in the editor options (for example createOutlineTextShaper with your fonts), or edit in a browser.");
4360
+ const next = { ...layer, surface: r.surface };
4361
+ delete next.rendering;
4362
+ if (r.missingFonts.length) next.missingFonts = r.missingFonts;
4363
+ else delete next.missingFonts;
4364
+ return next;
4365
+ }
4366
+ var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
4367
+ function num(v, path, min, max) {
4368
+ if (!isNum2(v) || v < min || v > max) fail3(`${path} must be a number from ${min} to ${max}, got ${JSON.stringify(v)}.`);
4369
+ return v;
4370
+ }
4371
+ var TEXT_STYLE_FIELDS = ["fontFamily", "fontWeight", "italic", "fontSize", "color", "opacity", "tracking", "leading", "baselineShift", "underline", "strikethrough"];
4372
+ function patchTextStyle(base, patch, path = "style") {
4373
+ const out = { ...base };
4374
+ const o = out;
4375
+ for (const [k, v] of Object.entries(patch)) {
4376
+ if (v === void 0) continue;
4377
+ switch (k) {
4378
+ case "fontFamily":
4379
+ if (typeof v !== "string" || !v.trim()) fail3(`${path}.fontFamily must be a font family name.`);
4380
+ out.fontFamily = v.trim();
4381
+ if (out.postScriptName) delete out.postScriptName;
4382
+ break;
4383
+ case "fontWeight": {
4384
+ const w = v === "normal" ? 400 : v === "bold" ? 700 : v;
4385
+ out.fontWeight = Math.round(num(w, `${path}.fontWeight`, 1, 1e3));
4386
+ if (out.postScriptName) delete out.postScriptName;
4387
+ break;
4388
+ }
4389
+ case "italic":
4390
+ case "underline":
4391
+ case "strikethrough":
4392
+ if (typeof v !== "boolean" && v !== null) fail3(`${path}.${k} must be true or false.`);
4393
+ if (v) o[k] = true;
4394
+ else delete o[k];
4395
+ if (k === "italic" && out.postScriptName) delete out.postScriptName;
4396
+ break;
4397
+ case "fontSize":
4398
+ out.fontSize = num(v, `${path}.fontSize`, 0.5, 5e3);
4399
+ break;
4400
+ case "color": {
4401
+ const c = parseCssColor(v);
4402
+ if (!c) fail3(`${path}.color must be a colour such as #rrggbb.`);
4403
+ out.color = c.hex;
4404
+ if (c.alpha < 1) out.opacity = c.alpha;
4405
+ break;
4406
+ }
4407
+ case "opacity":
4408
+ case "tracking":
4409
+ case "leading":
4410
+ case "baselineShift": {
4411
+ if (v === null) {
4412
+ delete o[k];
4413
+ break;
4414
+ }
4415
+ const [min, max] = k === "opacity" ? [0, 1] : k === "tracking" ? [-1e3, 1e4] : k === "leading" ? [0, 1e4] : [-5e3, 5e3];
4416
+ const value = num(v, `${path}.${k}`, min, max);
4417
+ if (k === "opacity" && value === 1 || (k === "tracking" || k === "baselineShift") && value === 0) delete o[k];
4418
+ else o[k] = value;
4419
+ break;
4420
+ }
4421
+ default:
4422
+ fail3(`${path}.${k} is not a character style field; use ${TEXT_STYLE_FIELDS.join(", ")}.`);
4423
+ }
4424
+ }
4425
+ return out;
4426
+ }
4427
+ var PARAGRAPH_STYLE_FIELDS = ["align", "autoLeading", "firstLineIndent", "startIndent", "endIndent", "spaceBefore", "spaceAfter"];
4428
+ function patchParagraphStyle(base, patch, path = "paragraph") {
4429
+ const out = { ...base };
4430
+ const o = out;
4431
+ for (const [k, v] of Object.entries(patch)) {
4432
+ if (v === void 0) continue;
4433
+ if (k === "align") {
4434
+ if (!TEXT_ALIGNS.includes(v)) fail3(`${path}.align must be one of ${TEXT_ALIGNS.join(", ")}.`);
4435
+ if (v === "left") delete out.align;
4436
+ else out.align = v;
4437
+ } else if (PARAGRAPH_STYLE_FIELDS.includes(k)) {
4438
+ if (v === null) {
4439
+ delete o[k];
4440
+ continue;
4441
+ }
4442
+ const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
4443
+ if (k === "autoLeading" && value === DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
4444
+ else o[k] = value;
4445
+ } else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
4446
+ }
4447
+ return out;
4448
+ }
4449
+ function textRange(text3, start, end) {
4450
+ const s = start === void 0 ? 0 : start;
4451
+ const e = end === void 0 ? text3.length : end;
4452
+ if (!Number.isInteger(s) || !Number.isInteger(e) || s < 0 || e > text3.length || s > e) {
4453
+ fail3(`start and end must be whole numbers with 0 \u2264 start \u2264 end \u2264 ${text3.length} (the text's length in UTF-16 code units), got ${String(start)} and ${String(end)}.`);
4454
+ }
4455
+ return [s, e];
4456
+ }
4457
+ function requireTypeLayer(layers, id) {
4458
+ const layer = requireLayer(layers, id).layer;
4459
+ if (layer.type !== "type") fail3(`Layer "${layer.name || id}" is a ${layer.type} layer, not a type layer; list_layers shows each layer's type.`);
4460
+ return layer;
4461
+ }
4462
+ function normalizeText(text3, path = "text") {
4463
+ if (typeof text3 !== "string") return fail3(`${path} must be a string.`);
4464
+ return text3.replace(/\r\n?/g, "\n");
4465
+ }
4466
+ function typeLayerName(text3) {
4467
+ const line = _nullishCoalesce(text3.split("\n").find((l) => l.trim()), () => ( ""));
4468
+ return line.trim().slice(0, 32) || "Text";
4469
+ }
4470
+ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
4471
+ const text3 = normalizeText(init.text);
4472
+ const layer = {
4473
+ type: "type",
4474
+ id,
4475
+ name: _nullishCoalesce(init.name, () => ( typeLayerName(text3))),
4476
+ visible: true,
4477
+ opacity: 1,
4478
+ blend: "normal",
4479
+ text: text3,
4480
+ runs: fitRuns(init.runs, text3.length, DEFAULT_TEXT_STYLE),
4481
+ paragraphs: fitParagraphRuns(_nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
4482
+ frame: init.frame,
4483
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4484
+ offset: { x: 0, y: 0 }
4485
+ };
4486
+ 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)) }];
4487
+ if (init.transform && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4488
+ if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
4489
+ return rerenderText(layer, env);
4490
+ }
4491
+ function updateTypeLayer(layers, id, change, env, action = "edit it") {
4492
+ const current = requireTypeLayer(layers, id);
4493
+ requireUnlocked(current, "pixels", action);
4494
+ const patch = change(current);
4495
+ const next = { ...current, ...patch };
4496
+ if (!("annotation" in patch)) delete next.annotation;
4497
+ 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)));
4498
+ if (!next.runs.length) next.runs = [{ length: 0, style: styleAt(current.runs, 0, DEFAULT_TEXT_STYLE) }];
4499
+ if ("text" in patch || "paragraphs" in patch) next.paragraphs = fitParagraphRuns(next.paragraphs, next.text);
4500
+ const rendered = rerenderText(next, env);
4501
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4502
+ }
4503
+ function replaceTextRange(layer, start, end, insert) {
4504
+ const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
4505
+ const style = styleAt(layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, DEFAULT_TEXT_STYLE);
4506
+ const runs = spliceRuns(layer.runs, start, end, insert.length, style);
4507
+ const pstyle = styleAt(layer.paragraphs, start, {});
4508
+ const paragraphs = spliceRuns(layer.paragraphs, start, end, insert.length, pstyle);
4509
+ return { text: text3, runs, paragraphs: fitParagraphRuns(paragraphs, text3) };
4510
+ }
4511
+ function transformTypeLayer(layer, m) {
4512
+ const t = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
4513
+ const next = { ...layer };
4514
+ if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
4515
+ else next.transform = t;
4516
+ delete next.annotation;
4517
+ return next;
4518
+ }
4519
+ function typeFrame(layer, shaper) {
4520
+ if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
4521
+ if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
4522
+ const b = layoutText(layer, shaper).bounds;
4523
+ return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
4524
+ }
4525
+ function typeAsPixelLayer(layer) {
4526
+ const { text: _t, runs: _r, paragraphs: _p, frame: _f, transform: _m, antiAlias: _a, rendering: _g, missingFonts: _mf, annotation: _an, psd: _psd, type: _ty, ...rest } = layer;
4527
+ return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
4528
+ }
4529
+ function toTextSpace(layer, p) {
4530
+ return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
4531
+ }
4532
+ function typeFromAnnotation(a) {
4533
+ if (a.type !== "text") return null;
4534
+ const t = a;
4535
+ const c = parseCssColor(t.color);
4536
+ if (!c) return null;
4537
+ const weight = t.fontWeight === void 0 || t.fontWeight === "normal" ? 400 : t.fontWeight === "bold" ? 700 : Number(t.fontWeight);
4538
+ if (!Number.isFinite(weight)) return null;
4539
+ const style = { fontFamily: t.fontFamily || "sans-serif", fontWeight: weight, fontSize: t.fontSize, color: c.hex };
4540
+ const op = c.alpha * (_nullishCoalesce(t.opacity, () => ( 1)));
4541
+ if (op !== 1) style.opacity = op;
4542
+ const text3 = t.text.replace(/\r?\n|\r/g, " ");
4543
+ const translate = [1, 0, 0, 1, t.x, t.y];
4544
+ const transform = t.rotation ? _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, translate, _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
4545
+ return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
4546
+ }
4547
+ function annotationOfType(layer) {
4548
+ const a = layer.annotation;
4549
+ if (!a) return null;
4550
+ if ((_nullishCoalesce(a.blend, () => ( "normal"))) === layer.blend) return a;
4551
+ const out = { ...a };
4552
+ if (layer.blend === "normal") delete out.blend;
4553
+ else out.blend = layer.blend;
4554
+ return out;
4555
+ }
4556
+
3890
4557
  // src/image-editor/layers/defaults.ts
3891
4558
  var DEFAULT_ADJUSTMENTS_VALUES = {
3892
4559
  brightness: 0,
@@ -3923,7 +4590,7 @@ function rasterMaskFromLegacy(mask, width, height) {
3923
4590
  const sel = decodeLayerMask(mask);
3924
4591
  if (!sel) return null;
3925
4592
  const sized = sel.width === width && sel.height === height ? sel : resizeSelection(sel, width, height);
3926
- const surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
4593
+ const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
3927
4594
  legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
3928
4595
  const out = { surface, defaultValue: 0 };
3929
4596
  if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
@@ -3942,7 +4609,7 @@ function hasResampledLegacyMask(layers, width, height) {
3942
4609
  function legacyMaskOf(mask, width, height) {
3943
4610
  let memo = legacyMaskMemo.get(mask.surface);
3944
4611
  if (!memo) {
3945
- const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
4612
+ const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
3946
4613
  memo = { width, height, rle: encodeSelectionRle(new Uint8Array(data.buffer, data.byteOffset, data.length)) };
3947
4614
  legacyMaskMemo.set(mask.surface, memo);
3948
4615
  }
@@ -3988,6 +4655,12 @@ function annotationLayerName(annotation) {
3988
4655
  }
3989
4656
  }
3990
4657
  function annotationLayerFor(annotation, canvas) {
4658
+ const blend = annotation.blend && annotation.blend !== "normal" ? annotation.blend : "normal";
4659
+ const type = canvas ? typeFromAnnotation(annotation) : null;
4660
+ if (type) {
4661
+ const layer = createTypeLayer({ ...type, name: annotationLayerName(annotation) }, { shaper: null, ...canvas }, annotation.id, true);
4662
+ return { ...layer, blend, annotation };
4663
+ }
3991
4664
  const shape = canvas ? shapeFromAnnotation(annotation) : null;
3992
4665
  if (shape) {
3993
4666
  const layer = createShapeLayer(
@@ -4010,6 +4683,7 @@ function annotationLayerFor(annotation, canvas) {
4010
4683
  function annotationOfLayer(layer) {
4011
4684
  if (layer.type === "annotation") return layer.annotation;
4012
4685
  if (layer.type === "shape") return annotationOfShape(layer);
4686
+ if (layer.type === "type") return annotationOfType(layer);
4013
4687
  return null;
4014
4688
  }
4015
4689
  function adjustmentNodeFromLegacy(layer, width, height) {
@@ -4037,7 +4711,7 @@ function backgroundLayer(filters = [], mask) {
4037
4711
  visible: true,
4038
4712
  opacity: 1,
4039
4713
  blend: "normal",
4040
- surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
4714
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4041
4715
  offset: { x: 0, y: 0 },
4042
4716
  source: "document",
4043
4717
  filters
@@ -4047,7 +4721,7 @@ function backgroundLayer(filters = [], mask) {
4047
4721
  }
4048
4722
  function depthRasterMask(source) {
4049
4723
  const out = {
4050
- surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 1, 255),
4724
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255),
4051
4725
  defaultValue: 255,
4052
4726
  source: { ...source, depthRange: [...source.depthRange] }
4053
4727
  };
@@ -4107,7 +4781,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4107
4781
  const { layers } = stack;
4108
4782
  const target = developTarget(layers, activeLayerId);
4109
4783
  const develop = target ? developFilter(target) : void 0;
4110
- const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _59 => _59(target), 'optionalAccess', _60 => _60.radius]) : void 0))), () => ( 0));
4784
+ const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _74 => _74(target), 'optionalAccess', _75 => _75.radius]) : void 0))), () => ( 0));
4111
4785
  const adjustments = {
4112
4786
  ...DEFAULT_ADJUSTMENTS_VALUES,
4113
4787
  ...develop ? {
@@ -4136,7 +4810,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4136
4810
  };
4137
4811
  walk(layers);
4138
4812
  if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
4139
- const depthSource = _optionalChain([target, 'optionalAccess', _61 => _61.mask, 'optionalAccess', _62 => _62.source]);
4813
+ const depthSource = _optionalChain([target, 'optionalAccess', _76 => _76.mask, 'optionalAccess', _77 => _77.source]);
4140
4814
  const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
4141
4815
  return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
4142
4816
  }
@@ -4161,12 +4835,12 @@ function isLegacyShape(stack) {
4161
4835
  let adjustments = 0;
4162
4836
  for (; i < layers.length && layers[i].type === "adjustment"; i++) {
4163
4837
  const l = layers[i];
4164
- if (l.clipped || l.locks || _optionalChain([l, 'access', _63 => _63.mask, 'optionalAccess', _64 => _64.source]) || l.effects) return false;
4838
+ if (l.clipped || l.locks || _optionalChain([l, 'access', _78 => _78.mask, 'optionalAccess', _79 => _79.source]) || l.effects) return false;
4165
4839
  adjustments++;
4166
4840
  }
4167
4841
  for (; i < layers.length; i++) {
4168
4842
  const l = layers[i];
4169
- if (l.type === "shape") {
4843
+ if (l.type === "shape" || l.type === "type") {
4170
4844
  const a = l.annotation;
4171
4845
  if (!a || (_nullishCoalesce(a.blend, () => ( "normal"))) !== l.blend || !isPlain({ ...l, blend: "normal" }) || l.fillOpacity !== void 0) return false;
4172
4846
  if (l.id !== a.id || l.name !== annotationLayerName(a)) return false;
@@ -4338,10 +5012,10 @@ function geometryHomography(geometry) {
4338
5012
  }
4339
5013
 
4340
5014
  // src/image-editor/layers/smart.ts
4341
- var fail3 = (message) => {
5015
+ var fail4 = (message) => {
4342
5016
  throw new LayerOperationError(message);
4343
5017
  };
4344
- var SMART_RENDER_MARGIN = _chunkAZTZRLDIcjs.MAX_EFFECT_REACH;
5018
+ var SMART_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
4345
5019
  function newContentsId() {
4346
5020
  return newLayerId("so");
4347
5021
  }
@@ -4359,14 +5033,14 @@ function isContentsDecoded(contents) {
4359
5033
  }
4360
5034
  function requireDecoded(layer, action) {
4361
5035
  if (isContentsDecoded(layer.contents)) return;
4362
- const what = _optionalChain([layer, 'access', _65 => _65.contents, 'access', _66 => _66.file, 'optionalAccess', _67 => _67.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4363
- fail3(
5036
+ 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";
5037
+ fail4(
4364
5038
  `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.`
4365
5039
  );
4366
5040
  }
4367
5041
  function requireSmartObject(layers, id) {
4368
5042
  const layer = requireLayer(layers, id).layer;
4369
- if (layer.type !== "smart") fail3(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
5043
+ if (layer.type !== "smart") fail4(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
4370
5044
  return layer;
4371
5045
  }
4372
5046
  var contentsPixels = /* @__PURE__ */ new WeakMap();
@@ -4374,29 +5048,29 @@ function contentsSurface(contents) {
4374
5048
  let s = contentsPixels.get(contents);
4375
5049
  if (s) return s;
4376
5050
  if (contents.kind === "raster") {
4377
- s = _nullishCoalesce(contents.raster, () => ( _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4)));
5051
+ s = _nullishCoalesce(contents.raster, () => ( _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4)));
4378
5052
  } else {
4379
5053
  const doc = contents.document;
4380
- if (!doc) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
5054
+ if (!doc) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
4381
5055
  const W = contents.width;
4382
5056
  const H = contents.height;
4383
5057
  const data = new LayerCompositor().composite(doc.layers, { x: 0, y: 0, width: W, height: H }, {
4384
5058
  width: W,
4385
5059
  height: H,
4386
5060
  globalLight: doc.globalLight,
4387
- pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _68 => _68.patterns, 'optionalAccess', _69 => _69.find, 'call', _70 => _70((p) => p.id === id)]), () => ( null))
5061
+ pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _83 => _83.patterns, 'optionalAccess', _84 => _84.find, 'call', _85 => _85((p) => p.id === id)]), () => ( null))
4388
5062
  });
4389
- s = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
5063
+ s = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
4390
5064
  }
4391
5065
  contentsPixels.set(contents, s);
4392
5066
  return s;
4393
5067
  }
4394
5068
  function rasterContents(pixels, name, id = newContentsId()) {
4395
- if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail3("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
4396
- return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
5069
+ 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.");
5070
+ return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
4397
5071
  }
4398
5072
  function documentContents(document, width, height, name, id = newContentsId()) {
4399
- if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail3("Contents width and height must be positive whole numbers.");
5073
+ if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail4("Contents width and height must be positive whole numbers.");
4400
5074
  return { id, name, width, height, kind: "document", document };
4401
5075
  }
4402
5076
  var placedCache = /* @__PURE__ */ new WeakMap();
@@ -4419,7 +5093,7 @@ function placeContents(layer, canvas, options = {}) {
4419
5093
  const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
4420
5094
  const key = placementKey(placement, canvas);
4421
5095
  if (!preview) {
4422
- const hit = _optionalChain([placedCache, 'access', _71 => _71.get, 'call', _72 => _72(contents), 'optionalAccess', _73 => _73.get, 'call', _74 => _74(key)]);
5096
+ const hit = _optionalChain([placedCache, 'access', _86 => _86.get, 'call', _87 => _87(contents), 'optionalAccess', _88 => _88.get, 'call', _89 => _89(key)]);
4423
5097
  if (hit) return hit;
4424
5098
  }
4425
5099
  const src = contentsSurface(contents);
@@ -4437,7 +5111,7 @@ function placeContents(layer, canvas, options = {}) {
4437
5111
  let out;
4438
5112
  const move = integerMove(layer);
4439
5113
  if (move && !options.clip) {
4440
- out = _chunkSZ6KMZNMcjs.translateSurface.call(void 0, src, move.x, move.y);
5114
+ out = _chunkXIOMMGPDcjs.translateSurface.call(void 0, src, move.x, move.y);
4441
5115
  } else {
4442
5116
  const g = placementGeometry(layer);
4443
5117
  const interpolation = preview ? placement.interpolation === "nearest" ? "nearest" : "bilinear" : _nullishCoalesce(placement.interpolation, () => ( "bicubic"));
@@ -4446,10 +5120,10 @@ function placeContents(layer, canvas, options = {}) {
4446
5120
  let k = 1;
4447
5121
  if (step > 1) {
4448
5122
  k = step;
4449
- let r = _optionalChain([options, 'access', _75 => _75.reduced, 'optionalAccess', _76 => _76.get, 'call', _77 => _77(k)]);
5123
+ let r = _optionalChain([options, 'access', _90 => _90.reduced, 'optionalAccess', _91 => _91.get, 'call', _92 => _92(k)]);
4450
5124
  if (!r) {
4451
- r = _chunkAZTZRLDIcjs.reduceSurface.call(void 0, src, k);
4452
- _optionalChain([options, 'access', _78 => _78.reduced, 'optionalAccess', _79 => _79.set, 'call', _80 => _80(k, r)]);
5125
+ r = _chunkPOGBUYWEcjs.reduceSurface.call(void 0, src, k);
5126
+ _optionalChain([options, 'access', _93 => _93.reduced, 'optionalAccess', _94 => _94.set, 'call', _95 => _95(k, r)]);
4453
5127
  }
4454
5128
  source = r;
4455
5129
  }
@@ -4457,16 +5131,16 @@ function placeContents(layer, canvas, options = {}) {
4457
5131
  try {
4458
5132
  if (hasWarp(g)) {
4459
5133
  const f = transformMap(g);
4460
- if (!f) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4461
- out = _chunkAZTZRLDIcjs.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 });
5134
+ if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
5135
+ 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 });
4462
5136
  } else {
4463
5137
  const h = transformHomography(g);
4464
- if (!h) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
5138
+ if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4465
5139
  const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
4466
- out = _chunkAZTZRLDIcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
5140
+ out = _chunkPOGBUYWEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
4467
5141
  }
4468
5142
  } catch (e) {
4469
- if (e instanceof _chunkAZTZRLDIcjs.TransformTooLargeError) fail3(e.message);
5143
+ if (e instanceof _chunkPOGBUYWEcjs.TransformTooLargeError) fail4(e.message);
4470
5144
  throw e;
4471
5145
  }
4472
5146
  }
@@ -4482,14 +5156,14 @@ function placeContents(layer, canvas, options = {}) {
4482
5156
  return out;
4483
5157
  }
4484
5158
  function activeSmartFilters(stack) {
4485
- if (!_optionalChain([stack, 'optionalAccess', _81 => _81.enabled])) return [];
5159
+ if (!_optionalChain([stack, 'optionalAccess', _96 => _96.enabled])) return [];
4486
5160
  return stack.filters.filter((f) => f.kind !== "psd" && isActiveFilter(f) && f.opacity > 0);
4487
5161
  }
4488
5162
  function filterMaskCoverage(mask, canvas) {
4489
5163
  if (!mask || mask.enabled === false || mask.source) return null;
4490
5164
  const W = canvas.width;
4491
5165
  const H = canvas.height;
4492
- const bytes = _chunkSZ6KMZNMcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
5166
+ const bytes = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
4493
5167
  let v = new Float32Array(W * H);
4494
5168
  let all = true;
4495
5169
  for (let i = 0; i < v.length; i++) {
@@ -4498,7 +5172,7 @@ function filterMaskCoverage(mask, canvas) {
4498
5172
  }
4499
5173
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
4500
5174
  if (all && !(feather > 0)) return null;
4501
- if (feather > 0) v = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
5175
+ if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
4502
5176
  const density = _nullishCoalesce(mask.density, () => ( 1));
4503
5177
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
4504
5178
  return v;
@@ -4511,7 +5185,7 @@ function applySmartFilters(placed, stack, canvas) {
4511
5185
  const key = JSON.stringify([W, H, active.map((f) => ({ ...f, id: void 0 }))]);
4512
5186
  let entry = filteredCache.get(placed);
4513
5187
  if (!entry || entry.key !== key) {
4514
- const base = _chunkSZ6KMZNMcjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
5188
+ const base = _chunkXIOMMGPDcjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
4515
5189
  let acc = new Uint8ClampedArray(base);
4516
5190
  for (const f of active) {
4517
5191
  const out = new Uint8ClampedArray(acc);
@@ -4520,7 +5194,7 @@ function applySmartFilters(placed, stack, canvas) {
4520
5194
  if (f.opacity >= 1) acc = out;
4521
5195
  else lerpInto(acc, out, f.opacity, null);
4522
5196
  } else {
4523
- _chunkAZTZRLDIcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
5197
+ _chunkPOGBUYWEcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
4524
5198
  }
4525
5199
  }
4526
5200
  entry = { key, base, filtered: acc };
@@ -4532,7 +5206,7 @@ function applySmartFilters(placed, stack, canvas) {
4532
5206
  result = new Uint8ClampedArray(entry.base);
4533
5207
  lerpInto(result, entry.filtered, 1, cov);
4534
5208
  }
4535
- return _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
5209
+ return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
4536
5210
  }
4537
5211
  function lerpInto(dst, src, k, coverage) {
4538
5212
  for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
@@ -4557,21 +5231,21 @@ function rerender(layer, canvas, action = "change") {
4557
5231
  return { ...layer, surface: renderSmartObject(layer, canvas) };
4558
5232
  }
4559
5233
  function normalizePlacement(raw, contents) {
4560
- const c = _optionalChain([raw, 'optionalAccess', _82 => _82.corners]);
5234
+ const c = _optionalChain([raw, 'optionalAccess', _97 => _97.corners]);
4561
5235
  if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
4562
- fail3("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
5236
+ fail4("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
4563
5237
  }
4564
5238
  const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
4565
5239
  if (raw.warp) {
4566
- if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp)) fail3("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.");
5240
+ 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.");
4567
5241
  out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
4568
5242
  }
4569
5243
  if (raw.interpolation !== void 0) {
4570
- if (!_chunkAZTZRLDIcjs.isInterpolation.call(void 0, raw.interpolation)) fail3(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
5244
+ if (!_chunkPOGBUYWEcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
4571
5245
  if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
4572
5246
  }
4573
5247
  const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
4574
- if (!transformHomography(g)) fail3("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
5248
+ if (!transformHomography(g)) fail4("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
4575
5249
  if (out.warp && !hasWarp(g)) delete out.warp;
4576
5250
  return out;
4577
5251
  }
@@ -4587,7 +5261,7 @@ function followMask(mask, before, after) {
4587
5261
  const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
4588
5262
  if (!inv) return mask;
4589
5263
  const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
4590
- const surface = _chunkAZTZRLDIcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
5264
+ const surface = _chunkPOGBUYWEcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
4591
5265
  return { ...mask, surface };
4592
5266
  }
4593
5267
  function setSmartPlacement(layers, id, placement, canvas) {
@@ -4602,13 +5276,13 @@ function setSmartPlacement(layers, id, placement, canvas) {
4602
5276
  masksMoved ||= m !== layer.mask;
4603
5277
  next.mask = m;
4604
5278
  }
4605
- if (_optionalChain([next, 'access', _83 => _83.smartFilters, 'optionalAccess', _84 => _84.mask])) {
5279
+ if (_optionalChain([next, 'access', _98 => _98.smartFilters, 'optionalAccess', _99 => _99.mask])) {
4606
5280
  const m = followMask(next.smartFilters.mask, layer, next);
4607
5281
  masksMoved ||= m !== next.smartFilters.mask;
4608
5282
  next.smartFilters = { ...next.smartFilters, mask: m };
4609
5283
  }
4610
5284
  next = rerender(next, canvas, "be transformed");
4611
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
5285
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
4612
5286
  }
4613
5287
  function offsetSmartObject(layers, id, dx, dy, canvas) {
4614
5288
  const layer = requireSmartObject(layers, id);
@@ -4618,26 +5292,26 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
4618
5292
  if (!mx && !my) return layers;
4619
5293
  const corners = layer.placement.corners.map((p) => ({ x: p.x + mx, y: p.y + my }));
4620
5294
  let next = { ...layer, placement: { ...layer.placement, corners } };
4621
- const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
5295
+ const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
4622
5296
  if (layer.mask) next.mask = moveMask(layer.mask);
4623
- if (_optionalChain([layer, 'access', _85 => _85.smartFilters, 'optionalAccess', _86 => _86.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5297
+ if (_optionalChain([layer, 'access', _100 => _100.smartFilters, 'optionalAccess', _101 => _101.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4624
5298
  const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur");
4625
- const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, layer.surface);
5299
+ const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
4626
5300
  const m = SMART_RENDER_MARGIN;
4627
5301
  const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
4628
- if (!spatial && !cut && !(_optionalChain([next, 'access', _87 => _87.smartFilters, 'optionalAccess', _88 => _88.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
4629
- next = { ...next, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, layer.surface, mx, my) };
5302
+ if (!spatial && !cut && !(_optionalChain([next, 'access', _102 => _102.smartFilters, 'optionalAccess', _103 => _103.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5303
+ next = { ...next, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, mx, my) };
4630
5304
  } else {
4631
5305
  next = rerender(next, canvas, "move");
4632
5306
  }
4633
- return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
5307
+ return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
4634
5308
  }
4635
5309
  function translateLayer(layer, dx, dy) {
4636
5310
  if (!dx && !dy) return layer;
4637
5311
  const moveMask = (m) => {
4638
5312
  if (!m) return m;
4639
- if (m.source) fail3(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
4640
- return { ...m, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, m.surface, dx, dy) };
5313
+ 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.`);
5314
+ return { ...m, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m.surface, dx, dy) };
4641
5315
  };
4642
5316
  switch (layer.type) {
4643
5317
  case "pixel":
@@ -4646,11 +5320,11 @@ function translateLayer(layer, dx, dy) {
4646
5320
  const next = {
4647
5321
  ...layer,
4648
5322
  placement: { ...layer.placement, corners: layer.placement.corners.map((p) => ({ x: p.x + dx, y: p.y + dy })) },
4649
- surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, layer.surface, dx, dy),
5323
+ surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
4650
5324
  mask: moveMask(layer.mask)
4651
5325
  };
4652
5326
  if (!next.mask) delete next.mask;
4653
- if (_optionalChain([layer, 'access', _89 => _89.smartFilters, 'optionalAccess', _90 => _90.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5327
+ if (_optionalChain([layer, 'access', _104 => _104.smartFilters, 'optionalAccess', _105 => _105.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4654
5328
  return next;
4655
5329
  }
4656
5330
  case "group": {
@@ -4667,25 +5341,30 @@ function translateLayer(layer, dx, dy) {
4667
5341
  const next = {
4668
5342
  ...layer,
4669
5343
  components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)),
4670
- surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, layer.surface, dx, dy),
5344
+ surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
4671
5345
  mask: moveMask(layer.mask)
4672
5346
  };
4673
5347
  if (!next.mask) delete next.mask;
4674
5348
  delete next.annotation;
4675
5349
  return next;
4676
5350
  }
5351
+ case "type": {
5352
+ 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) };
5353
+ if (!next.mask) delete next.mask;
5354
+ return next;
5355
+ }
4677
5356
  case "annotation":
4678
- return fail3(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
5357
+ return fail4(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
4679
5358
  }
4680
5359
  }
4681
5360
  function layerExtent(layer, surfaceOf, canvas) {
4682
5361
  const full = { x: 0, y: 0, width: canvas.width, height: canvas.height };
4683
5362
  let b = null;
4684
- if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape") {
5363
+ if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type") {
4685
5364
  const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
4686
5365
  if (s.defaultValue !== 0) b = full;
4687
5366
  else {
4688
- const c = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, s);
5367
+ const c = _chunkXIOMMGPDcjs.contentBounds.call(void 0, s);
4689
5368
  b = c ? { x: c.x + layer.offset.x, y: c.y + layer.offset.y, width: c.width, height: c.height } : null;
4690
5369
  }
4691
5370
  } else if (layer.type === "group") {
@@ -4693,7 +5372,7 @@ function layerExtent(layer, surfaceOf, canvas) {
4693
5372
  } else {
4694
5373
  b = full;
4695
5374
  }
4696
- const m = _chunkAZTZRLDIcjs.effectsMargin.call(void 0, layer.effects);
5375
+ const m = _chunkPOGBUYWEcjs.effectsMargin.call(void 0, layer.effects);
4697
5376
  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) };
4698
5377
  return b;
4699
5378
  }
@@ -4705,14 +5384,14 @@ function union(a, b) {
4705
5384
  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 };
4706
5385
  }
4707
5386
  function asSmartFilters(filters) {
4708
- if (!_optionalChain([filters, 'optionalAccess', _91 => _91.length])) return void 0;
5387
+ if (!_optionalChain([filters, 'optionalAccess', _106 => _106.length])) return void 0;
4709
5388
  return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
4710
5389
  }
4711
5390
  function convertToSmartObject(layers, ids, canvas, options) {
4712
- if (!ids.length) fail3("Give at least one layer id to convert.");
5391
+ if (!ids.length) fail4("Give at least one layer id to convert.");
4713
5392
  const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
4714
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _92 => _92[0], 'access', _93 => _93.parent, 'optionalAccess', _94 => _94.id]), () => ( null));
4715
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _95 => _95.parent, 'optionalAccess', _96 => _96.id]), () => ( null))) !== parent)) fail3("Layers to convert must share one parent; move them next to each other first.");
5393
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _107 => _107[0], 'access', _108 => _108.parent, 'optionalAccess', _109 => _109.id]), () => ( null));
5394
+ 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.");
4716
5395
  for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
4717
5396
  const ordered = locs.sort((a, b) => a.index - b.index);
4718
5397
  const top = ordered[ordered.length - 1];
@@ -4720,16 +5399,16 @@ function convertToSmartObject(layers, ids, canvas, options) {
4720
5399
  const single = ordered.length === 1 ? ordered[0].layer : null;
4721
5400
  if (single && single.type === "pixel") {
4722
5401
  const surface = options.surfaceOf(single);
4723
- if (surface.defaultValue !== 0) fail3(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
4724
- const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, surface);
4725
- if (!b) fail3(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
5402
+ if (surface.defaultValue !== 0) fail4(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
5403
+ const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
5404
+ if (!b) fail4(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
4726
5405
  const contents = {
4727
5406
  id: newContentsId(),
4728
5407
  name: `${single.name || "Layer"}.png`,
4729
5408
  width: b.width,
4730
5409
  height: b.height,
4731
5410
  kind: "raster",
4732
- raster: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, surface, -b.x, -b.y)
5411
+ raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -b.x, -b.y)
4733
5412
  };
4734
5413
  smart = {
4735
5414
  type: "smart",
@@ -4740,21 +5419,21 @@ function convertToSmartObject(layers, ids, canvas, options) {
4740
5419
  blend: single.blend,
4741
5420
  contents,
4742
5421
  placement: placementAt(contents, b.x + single.offset.x, b.y + single.offset.y),
4743
- surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
5422
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4744
5423
  offset: { x: 0, y: 0 }
4745
5424
  };
4746
5425
  if (single.clipped) smart.clipped = true;
4747
5426
  if (single.fillOpacity !== void 0) smart.fillOpacity = single.fillOpacity;
4748
5427
  if (single.effects) smart.effects = single.effects;
4749
5428
  if (single.mask) {
4750
- smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
5429
+ smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
4751
5430
  }
4752
5431
  const filters = asSmartFilters(single.filters);
4753
5432
  if (filters) smart.smartFilters = filters;
4754
5433
  } else {
4755
5434
  let b = null;
4756
5435
  for (const l of ordered) b = union(b, layerExtent(l.layer, options.surfaceOf, canvas));
4757
- if (!b || !(b.width > 0 && b.height > 0)) fail3("The layers have no pixels to convert; paint something first.");
5436
+ if (!b || !(b.width > 0 && b.height > 0)) fail4("The layers have no pixels to convert; paint something first.");
4758
5437
  const nested = ordered.map((l) => {
4759
5438
  let layer = l.layer;
4760
5439
  if (layer.type === "pixel" && layer.source === "document") {
@@ -4762,7 +5441,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
4762
5441
  delete resolved.source;
4763
5442
  layer = resolved;
4764
5443
  }
4765
- if (_chunkAZTZRLDIcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail3(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5444
+ 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.`);
4766
5445
  return translateLayer(layer, -b.x, -b.y);
4767
5446
  });
4768
5447
  if (nested[0].clipped) {
@@ -4770,7 +5449,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
4770
5449
  delete first.clipped;
4771
5450
  nested[0] = first;
4772
5451
  }
4773
- const name = _optionalChain([options, 'access', _97 => _97.name, 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()]) || top.layer.name || "Smart Object";
5452
+ const name = _optionalChain([options, 'access', _112 => _112.name, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]) || top.layer.name || "Smart Object";
4774
5453
  const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
4775
5454
  smart = {
4776
5455
  type: "smart",
@@ -4781,16 +5460,16 @@ function convertToSmartObject(layers, ids, canvas, options) {
4781
5460
  blend: "normal",
4782
5461
  contents,
4783
5462
  placement: placementAt(contents, b.x, b.y),
4784
- surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
5463
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
4785
5464
  offset: { x: 0, y: 0 }
4786
5465
  };
4787
5466
  }
4788
- if (_optionalChain([options, 'access', _100 => _100.name, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])) smart.name = options.name.trim();
5467
+ if (_optionalChain([options, 'access', _115 => _115.name, 'optionalAccess', _116 => _116.trim, 'call', _117 => _117()])) smart.name = options.name.trim();
4789
5468
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
4790
5469
  const below = ordered.filter((l) => l.index < top.index).length;
4791
5470
  let out = layers;
4792
- for (const l of ordered) out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
4793
- return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
5471
+ for (const l of ordered) out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5472
+ return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
4794
5473
  }
4795
5474
  function rasterizeSmartObject(layers, id) {
4796
5475
  const layer = requireSmartObject(layers, id);
@@ -4810,29 +5489,29 @@ function rasterizeSmartObject(layers, id) {
4810
5489
  if (layer.locks) out.locks = layer.locks;
4811
5490
  if (layer.effects) out.effects = layer.effects;
4812
5491
  if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
4813
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
5492
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
4814
5493
  }
4815
5494
  function copySmartObject(layers, id, linked, name) {
4816
5495
  const loc = requireLayer(layers, id);
4817
5496
  const layer = requireSmartObject(layers, id);
4818
- const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _103 => _103.trim, 'call', _104 => _104()]) || `${layer.name || "Smart Object"} copy` };
5497
+ const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]) || `${layer.name || "Smart Object"} copy` };
4819
5498
  delete copy.locks;
4820
5499
  delete copy.psd;
4821
5500
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
4822
5501
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
4823
- return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _105 => _105.parent, 'optionalAccess', _106 => _106.id]), () => ( null)), loc.index + 1), layer: copy };
5502
+ 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 };
4824
5503
  }
4825
5504
  function instancesOf(layers, contentsId) {
4826
- return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
5505
+ return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
4827
5506
  }
4828
5507
  function replaceContents(layers, contentsId, contents, canvas) {
4829
5508
  const ids = instancesOf(layers, contentsId);
4830
- if (!ids.length) fail3(`No smart object uses contents "${contentsId}".`);
4831
- for (const id of ids) requireUnlocked(_chunkAZTZRLDIcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
5509
+ if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
5510
+ for (const id of ids) requireUnlocked(_chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
4832
5511
  const next = { ...contents, id: contentsId };
4833
5512
  let out = layers;
4834
5513
  for (const id of ids) {
4835
- out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, id, (l) => {
5514
+ out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, id, (l) => {
4836
5515
  const layer = l;
4837
5516
  return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
4838
5517
  });
@@ -4860,12 +5539,12 @@ function refitPlacement(layer, contents) {
4860
5539
  return out;
4861
5540
  }
4862
5541
  function normalizeSmartFilter(raw, id = newLayerId("flt")) {
4863
- if (raw.kind === "psd") fail3("Photoshop filters can only come from a PSD; add develop or blur.");
5542
+ if (raw.kind === "psd") fail4("Photoshop filters can only come from a PSD; add develop or blur.");
4864
5543
  const base = normalizeFilter(raw, id);
4865
5544
  const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
4866
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5545
+ if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
4867
5546
  const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
4868
- if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
5547
+ if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
4869
5548
  return { ...base, blend, opacity };
4870
5549
  }
4871
5550
  function withStack(layer, stack, canvas) {
@@ -4878,9 +5557,9 @@ function stackOf(layer) {
4878
5557
  return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
4879
5558
  }
4880
5559
  function requireFilter(layer, filterId) {
4881
- const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _107 => _107.smartFilters, 'optionalAccess', _108 => _108.filters]), () => ( []));
5560
+ const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _122 => _122.smartFilters, 'optionalAccess', _123 => _123.filters]), () => ( []));
4882
5561
  const i = list2.findIndex((f) => f.id === filterId);
4883
- if (i === -1) fail3(`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.`);
5562
+ 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.`);
4884
5563
  return i;
4885
5564
  }
4886
5565
  function editableSmart(layers, id) {
@@ -4895,21 +5574,21 @@ function addSmartFilter(layers, id, filter, canvas, index) {
4895
5574
  const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
4896
5575
  filters.splice(at, 0, filter);
4897
5576
  const next = withStack(layer, { ...stack, filters }, canvas);
4898
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
5577
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
4899
5578
  }
4900
5579
  function updateSmartFilter(layers, id, filterId, changes, canvas) {
4901
5580
  const layer = editableSmart(layers, id);
4902
5581
  const i = requireFilter(layer, filterId);
4903
5582
  const current = layer.smartFilters.filters[i];
4904
- if ("kind" in changes && changes.kind !== current.kind) fail3("A smart filter kind cannot change; remove it and add another.");
5583
+ if ("kind" in changes && changes.kind !== current.kind) fail4("A smart filter kind cannot change; remove it and add another.");
4905
5584
  let merged;
4906
5585
  if (current.kind === "psd") {
4907
5586
  const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
4908
- if (extra.length) fail3(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
5587
+ 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(", ")}.`);
4909
5588
  const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
4910
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
5589
+ if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
4911
5590
  const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
4912
- if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
5591
+ if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
4913
5592
  merged = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
4914
5593
  } else {
4915
5594
  merged = normalizeSmartFilter({ ...current, ...changes, kind: current.kind }, current.id);
@@ -4917,7 +5596,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
4917
5596
  const filters = [...layer.smartFilters.filters];
4918
5597
  filters[i] = merged;
4919
5598
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
4920
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged };
5599
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged };
4921
5600
  }
4922
5601
  function removeSmartFilter(layers, id, filterId, canvas) {
4923
5602
  const layer = editableSmart(layers, id);
@@ -4925,36 +5604,36 @@ function removeSmartFilter(layers, id, filterId, canvas) {
4925
5604
  const stack = layer.smartFilters;
4926
5605
  const filters = stack.filters.filter((f) => f.id !== filterId);
4927
5606
  const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
4928
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5607
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4929
5608
  }
4930
5609
  function moveSmartFilter(layers, id, filterId, index, canvas) {
4931
5610
  const layer = editableSmart(layers, id);
4932
5611
  const i = requireFilter(layer, filterId);
4933
5612
  const list2 = layer.smartFilters.filters;
4934
- if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail3(`index must be a whole number from 0 to ${list2.length - 1}.`);
5613
+ if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail4(`index must be a whole number from 0 to ${list2.length - 1}.`);
4935
5614
  const filters = [...list2];
4936
5615
  const [f] = filters.splice(i, 1);
4937
5616
  filters.splice(index, 0, f);
4938
5617
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
4939
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5618
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4940
5619
  }
4941
5620
  function setSmartFiltersEnabled(layers, id, enabled, canvas) {
4942
5621
  const layer = editableSmart(layers, id);
4943
5622
  const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
4944
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5623
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4945
5624
  }
4946
5625
  function setSmartFilterMask(layers, id, mask, canvas) {
4947
5626
  const layer = editableSmart(layers, id);
4948
- if (_optionalChain([mask, 'optionalAccess', _109 => _109.source])) fail3("A smart filter mask is painted, not generated; use a raster mask.");
5627
+ if (_optionalChain([mask, 'optionalAccess', _124 => _124.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
4949
5628
  const stack = { ...stackOf(layer) };
4950
5629
  if (mask) stack.mask = mask;
4951
5630
  else delete stack.mask;
4952
5631
  const next = withStack(layer, stack, canvas);
4953
- return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5632
+ return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4954
5633
  }
4955
5634
  function withFilterMaskSurface(layer, surface, canvas) {
4956
5635
  const stack = stackOf(layer);
4957
- if (!stack.mask) fail3(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
5636
+ if (!stack.mask) fail4(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
4958
5637
  return withStack(layer, { ...stack, mask: { ...stack.mask, surface } }, canvas);
4959
5638
  }
4960
5639
  function placementBounds(layer) {
@@ -4964,7 +5643,7 @@ function placementBounds(layer) {
4964
5643
  // src/image-editor/layers/serialize.ts
4965
5644
  var LAYERED_SCHEMA_VERSION = 3;
4966
5645
  function serializePatterns(patterns) {
4967
- return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkAZTZRLDIcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
5646
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
4968
5647
  }
4969
5648
  function deserializePatterns(raw, problems = []) {
4970
5649
  if (!Array.isArray(raw)) return [];
@@ -4983,11 +5662,11 @@ function deserializePatterns(raw, problems = []) {
4983
5662
  var encodedCache = /* @__PURE__ */ new WeakMap();
4984
5663
  function encodeSurface(surface) {
4985
5664
  if (encodedCache.has(surface)) return encodedCache.get(surface);
4986
- const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, surface);
5665
+ const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
4987
5666
  let out = null;
4988
5667
  if (b) {
4989
- const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, surface, b);
4990
- out = { url: _chunkAZTZRLDIcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
5668
+ const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, surface, b);
5669
+ out = { url: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4991
5670
  }
4992
5671
  encodedCache.set(surface, out);
4993
5672
  return out;
@@ -5009,7 +5688,7 @@ function baseFields(layer, ctx) {
5009
5688
  function serializeEffects(effects) {
5010
5689
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
5011
5690
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
5012
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, effects.psd.data) };
5691
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, effects.psd.data) };
5013
5692
  return out;
5014
5693
  }
5015
5694
  function deserializeEffects(raw) {
@@ -5019,12 +5698,12 @@ function deserializeEffects(raw) {
5019
5698
  const p = r.psd;
5020
5699
  if (p && typeof p.key === "string" && typeof p.data === "string") {
5021
5700
  try {
5022
- psd = { key: p.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, p.data) };
5701
+ psd = { key: p.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, p.data) };
5023
5702
  } catch (e6) {
5024
5703
  psd = void 0;
5025
5704
  }
5026
5705
  }
5027
- return _chunkAZTZRLDIcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5706
+ return _chunkPOGBUYWEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5028
5707
  }
5029
5708
  function serializeMask(mask, hint, ctx) {
5030
5709
  const out = { defaultValue: mask.defaultValue };
@@ -5059,7 +5738,7 @@ function serializeLayer(layer, ctx) {
5059
5738
  }
5060
5739
  }
5061
5740
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5062
- if (_optionalChain([layer, 'access', _110 => _110.filters, 'optionalAccess', _111 => _111.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5741
+ if (_optionalChain([layer, 'access', _125 => _125.filters, 'optionalAccess', _126 => _126.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5063
5742
  return out;
5064
5743
  }
5065
5744
  case "adjustment":
@@ -5075,6 +5754,84 @@ function serializeLayer(layer, ctx) {
5075
5754
  return serializeSmartObject(layer, base, ctx);
5076
5755
  case "shape":
5077
5756
  return serializeShape(layer, base);
5757
+ case "type":
5758
+ return serializeType(layer, base, ctx);
5759
+ }
5760
+ }
5761
+ function serializeType(layer, base, ctx) {
5762
+ const out = {
5763
+ ...base,
5764
+ type: "type",
5765
+ text: layer.text,
5766
+ runs: JSON.parse(JSON.stringify(layer.runs)),
5767
+ paragraphs: JSON.parse(JSON.stringify(layer.paragraphs)),
5768
+ frame: { ...layer.frame }
5769
+ };
5770
+ if (layer.transform) out.transform = [...layer.transform];
5771
+ if (layer.antiAlias === false) out.antiAlias = false;
5772
+ if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5773
+ const enc = encodeSurface(layer.surface);
5774
+ if (enc) {
5775
+ out.asset = ctx.addAsset(enc.url, layer.id);
5776
+ out.x = enc.x;
5777
+ out.y = enc.y;
5778
+ }
5779
+ if (_optionalChain([layer, 'access', _127 => _127.missingFonts, 'optionalAccess', _128 => _128.length])) out.missingFonts = [...layer.missingFonts];
5780
+ if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5781
+ 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])) {
5782
+ out.psd = {};
5783
+ if (layer.psd.tySh) out.psd.tySh = _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5784
+ 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) }));
5785
+ }
5786
+ return out;
5787
+ }
5788
+ function readType(r, base, ctx) {
5789
+ const label = `Layer "${base.name || base.id}"`;
5790
+ try {
5791
+ const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
5792
+ const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
5793
+ length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _137 => _137.length]), 0, 1e9, 0))),
5794
+ style: patchTextStyle(DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _138 => _138.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5795
+ }));
5796
+ const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
5797
+ length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _139 => _139.length]), 0, 1e9, 0))),
5798
+ style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _140 => _140.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5799
+ }));
5800
+ const f = r.frame;
5801
+ 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" };
5802
+ const m = Array.isArray(r.transform) && r.transform.length === 6 && r.transform.every((v) => typeof v === "number" && Number.isFinite(v)) ? r.transform : void 0;
5803
+ const layer = {
5804
+ ...base,
5805
+ type: "type",
5806
+ text: text3,
5807
+ runs: fitRuns(runs, text3.length, DEFAULT_TEXT_STYLE),
5808
+ paragraphs: fitParagraphRuns(paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
5809
+ frame,
5810
+ surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
5811
+ offset: { x: 0, y: 0 }
5812
+ };
5813
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _143 => _143[0], 'optionalAccess', _144 => _144.style]), () => ( DEFAULT_TEXT_STYLE)) }];
5814
+ if (m) layer.transform = m;
5815
+ if (r.antiAlias === false) layer.antiAlias = false;
5816
+ if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5817
+ if (Array.isArray(r.missingFonts)) layer.missingFonts = r.missingFonts.filter((x) => typeof x === "string");
5818
+ 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)) }));
5819
+ if (r.psd && typeof r.psd === "object") {
5820
+ const psd = {};
5821
+ if (typeof r.psd.tySh === "string") psd.tySh = _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.tySh);
5822
+ 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) }));
5823
+ if (psd.tySh || _optionalChain([psd, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) layer.psd = psd;
5824
+ }
5825
+ if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
5826
+ 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]) };
5827
+ try {
5828
+ return rerenderText(layer, env);
5829
+ } catch (e7) {
5830
+ return { ...layer, rendering: "stored" };
5831
+ }
5832
+ } catch (e) {
5833
+ ctx.problems.push(`${label}: the text could not be read (${e instanceof Error ? e.message : String(e)})`);
5834
+ return null;
5078
5835
  }
5079
5836
  }
5080
5837
  function serializeShape(layer, base) {
@@ -5088,7 +5845,7 @@ function serializeShape(layer, base) {
5088
5845
  if (layer.fillRule === "evenodd") out.fillRule = "evenodd";
5089
5846
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5090
5847
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5091
- if (_optionalChain([layer, 'access', _112 => _112.psd, 'optionalAccess', _113 => _113.blocks, 'optionalAccess', _114 => _114.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, b.data) })) };
5848
+ 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) })) };
5092
5849
  return out;
5093
5850
  }
5094
5851
  function readShape(r, base, ctx) {
@@ -5102,12 +5859,12 @@ function readShape(r, base, ctx) {
5102
5859
  if (!data) {
5103
5860
  if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
5104
5861
  const components = r.components.map((c, i) => {
5105
- const op = requireOperation(_optionalChain([c, 'optionalAccess', _115 => _115.op]), `components[${i}].op`);
5106
- if (_optionalChain([c, 'optionalAccess', _116 => _116.live])) {
5862
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _154 => _154.op]), `components[${i}].op`);
5863
+ if (_optionalChain([c, 'optionalAccess', _155 => _155.live])) {
5107
5864
  const live = normalizeLiveShape(c.live, `components[${i}].live`);
5108
5865
  return { op, subpaths: liveShapeSubpaths(live), live };
5109
5866
  }
5110
- return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _117 => _117.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _118 => _118.subpaths]), `components[${i}].subpaths`) };
5867
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _156 => _156.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _157 => _157.subpaths]), `components[${i}].subpaths`) };
5111
5868
  });
5112
5869
  data = {
5113
5870
  components,
@@ -5117,10 +5874,10 @@ function readShape(r, base, ctx) {
5117
5874
  }
5118
5875
  const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero" }, env, base.id);
5119
5876
  const out = { ...layer, ...base, type: "shape", components: layer.components, fill: layer.fill, stroke: layer.stroke, surface: layer.surface, offset: { x: 0, y: 0 } };
5120
- if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num(r.fillOpacity, 0, 1, 1);
5877
+ if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5121
5878
  if (a && shapeFromAnnotation(a)) out.annotation = a;
5122
5879
  if (r.psd && Array.isArray(r.psd.blocks)) {
5123
- const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, b.data) }));
5880
+ 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) }));
5124
5881
  if (blocks.length) out.psd = { blocks };
5125
5882
  }
5126
5883
  return out;
@@ -5132,7 +5889,7 @@ function readShape(r, base, ctx) {
5132
5889
  function serializeSmartFilters(stack, layerId, ctx) {
5133
5890
  const out = {
5134
5891
  enabled: stack.enabled,
5135
- filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5892
+ filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5136
5893
  };
5137
5894
  if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
5138
5895
  return out;
@@ -5158,7 +5915,7 @@ function serializeSmartObject(layer, base, ctx) {
5158
5915
  }
5159
5916
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5160
5917
  if (layer.psd) {
5161
- out.psd = { key: layer.psd.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, layer.psd.data) };
5918
+ out.psd = { key: layer.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.data) };
5162
5919
  if (layer.psd.placed) out.psd.placed = layer.psd.placed;
5163
5920
  }
5164
5921
  return out;
@@ -5169,17 +5926,17 @@ function serializeContents(c, ctx) {
5169
5926
  const enc = encodeSurface(c.raster);
5170
5927
  if (enc) {
5171
5928
  if (enc.x !== 0 || enc.y !== 0) {
5172
- const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
5173
- out.asset = ctx.addAsset(_chunkAZTZRLDIcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5929
+ const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
5930
+ out.asset = ctx.addAsset(_chunkPOGBUYWEcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5174
5931
  } else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
5175
5932
  }
5176
5933
  }
5177
5934
  if (c.kind === "document" && c.document) {
5178
5935
  out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
5179
5936
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
5180
- if (_optionalChain([c, 'access', _119 => _119.document, 'access', _120 => _120.patterns, 'optionalAccess', _121 => _121.length])) out.patterns = serializePatterns(c.document.patterns);
5937
+ if (_optionalChain([c, 'access', _158 => _158.document, 'access', _159 => _159.patterns, 'optionalAccess', _160 => _160.length])) out.patterns = serializePatterns(c.document.patterns);
5181
5938
  }
5182
- if (c.file) out.file = { type: c.file.type, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, c.file.bytes) };
5939
+ if (c.file) out.file = { type: c.file.type, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, c.file.bytes) };
5183
5940
  if (c.linked) out.linked = { path: c.linked.path };
5184
5941
  return out;
5185
5942
  }
@@ -5215,7 +5972,7 @@ async function serializeLayersExternal(layers, store) {
5215
5972
  for (const [id, url] of Object.entries(inline.assets)) {
5216
5973
  let ref = refs.get(url);
5217
5974
  if (!ref) {
5218
- const parsed = _chunkAZTZRLDIcjs.parseDataUrl.call(void 0, url);
5975
+ const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
5219
5976
  const png = decodePngHeader(parsed.bytes);
5220
5977
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
5221
5978
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -5243,7 +6000,7 @@ async function resolveExternalAssets(assets, store, problems) {
5243
6000
  try {
5244
6001
  const blob = await store.get(ref);
5245
6002
  const bytes = new Uint8Array(await blob.arrayBuffer());
5246
- out[id] = `data:image/png;base64,${_chunkAZTZRLDIcjs.bytesToBase64.call(void 0, bytes)}`;
6003
+ out[id] = `data:image/png;base64,${_chunkPOGBUYWEcjs.bytesToBase64.call(void 0, bytes)}`;
5247
6004
  } catch (err) {
5248
6005
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
5249
6006
  }
@@ -5251,9 +6008,9 @@ async function resolveExternalAssets(assets, store, problems) {
5251
6008
  return out;
5252
6009
  }
5253
6010
  function decodePngDataUrl(url, channels) {
5254
- const parsed = _chunkAZTZRLDIcjs.parseDataUrl.call(void 0, url);
6011
+ const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
5255
6012
  if (!parsed) throw new Error("Asset is not a data URL.");
5256
- const png = _chunkAZTZRLDIcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
6013
+ const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
5257
6014
  if (png.channels === channels) return png;
5258
6015
  if (channels === 1) {
5259
6016
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -5269,20 +6026,20 @@ function decodePngDataUrl(url, channels) {
5269
6026
  }
5270
6027
  return { width: png.width, height: png.height, data: out };
5271
6028
  }
5272
- var num = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
6029
+ var num2 = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
5273
6030
  function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
5274
- if (typeof ref !== "string" || !ref) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, channels, defaultValue);
6031
+ if (typeof ref !== "string" || !ref) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5275
6032
  const url = ctx.assets[ref];
5276
6033
  if (typeof url !== "string") {
5277
6034
  ctx.problems.push(`${what}: asset "${ref}" is missing`);
5278
- return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, channels, defaultValue);
6035
+ return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5279
6036
  }
5280
6037
  try {
5281
6038
  const px = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
5282
- return _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
6039
+ return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
5283
6040
  } catch (err) {
5284
6041
  ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
5285
- return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, channels, defaultValue);
6042
+ return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
5286
6043
  }
5287
6044
  }
5288
6045
  function readMask(raw, ctx, what) {
@@ -5290,11 +6047,11 @@ function readMask(raw, ctx, what) {
5290
6047
  const r = raw;
5291
6048
  const defaultValue = r.defaultValue === 255 ? 255 : 0;
5292
6049
  const mask = {
5293
- surface: r.source ? _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
6050
+ surface: r.source ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
5294
6051
  defaultValue: r.source ? 255 : defaultValue
5295
6052
  };
5296
- if (typeof r.density === "number" && r.density !== 1) mask.density = num(r.density, 0, 1, 1);
5297
- if (typeof r.feather === "number" && r.feather > 0) mask.feather = num(r.feather, 0, 1e3, 0);
6053
+ if (typeof r.density === "number" && r.density !== 1) mask.density = num2(r.density, 0, 1, 1);
6054
+ if (typeof r.feather === "number" && r.feather > 0) mask.feather = num2(r.feather, 0, 1e3, 0);
5298
6055
  if (r.enabled === false) mask.enabled = false;
5299
6056
  if (r.linked === false) mask.linked = false;
5300
6057
  if (r.source && typeof r.source === "object") {
@@ -5311,18 +6068,18 @@ function readFilters(raw) {
5311
6068
  const r = f;
5312
6069
  const id = typeof r.id === "string" && r.id ? r.id : newLayerId("flt");
5313
6070
  const enabled = r.enabled !== false;
5314
- if (r.kind === "blur") out.push({ id, kind: "blur", enabled, radius: num(r.radius, 0, 50, 0) });
6071
+ if (r.kind === "blur") out.push({ id, kind: "blur", enabled, radius: num2(r.radius, 0, 50, 0) });
5315
6072
  else if (r.kind === "develop") {
5316
6073
  out.push({
5317
6074
  id,
5318
6075
  kind: "develop",
5319
6076
  enabled,
5320
- brightness: num(r.brightness, -100, 100, 0),
5321
- contrast: num(r.contrast, -100, 100, 0),
5322
- saturation: num(r.saturation, -100, 100, 0),
5323
- exposure: num(r.exposure, -100, 100, 0),
5324
- temperature: num(r.temperature, -100, 100, 0),
5325
- tint: num(r.tint, -100, 100, 0),
6077
+ brightness: num2(r.brightness, -100, 100, 0),
6078
+ contrast: num2(r.contrast, -100, 100, 0),
6079
+ saturation: num2(r.saturation, -100, 100, 0),
6080
+ exposure: num2(r.exposure, -100, 100, 0),
6081
+ temperature: num2(r.temperature, -100, 100, 0),
6082
+ tint: num2(r.tint, -100, 100, 0),
5326
6083
  process: normalizeProcessVersion(r.process)
5327
6084
  });
5328
6085
  }
@@ -5337,8 +6094,8 @@ function deserializeLayer(raw, ctx) {
5337
6094
  id,
5338
6095
  name: typeof r.name === "string" ? r.name : "",
5339
6096
  visible: r.visible !== false,
5340
- opacity: num(r.opacity, 0, 1, 1),
5341
- blend: _chunkSZ6KMZNMcjs.normalizeBlendMode.call(void 0, r.blend)
6097
+ opacity: num2(r.opacity, 0, 1, 1),
6098
+ blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend)
5342
6099
  };
5343
6100
  if (r.clipped === true) base.clipped = true;
5344
6101
  const mask = readMask(r.mask, ctx, `Layer "${base.name || id}"`);
@@ -5355,11 +6112,11 @@ function deserializeLayer(raw, ctx) {
5355
6112
  const layer = {
5356
6113
  ...base,
5357
6114
  type: "pixel",
5358
- surface: r.source === "document" ? _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
5359
- offset: { x: Math.round(num(_optionalChain([r, 'access', _122 => _122.offset, 'optionalAccess', _123 => _123.x]), -1e7, 1e7, 0)), y: Math.round(num(_optionalChain([r, 'access', _124 => _124.offset, 'optionalAccess', _125 => _125.y]), -1e7, 1e7, 0)) }
6115
+ surface: r.source === "document" ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
6116
+ 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)) }
5360
6117
  };
5361
6118
  if (r.source === "document") layer.source = "document";
5362
- if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
6119
+ if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5363
6120
  const filters = readFilters(r.filters);
5364
6121
  if (filters) layer.filters = filters;
5365
6122
  return layer;
@@ -5374,7 +6131,7 @@ function deserializeLayer(raw, ctx) {
5374
6131
  }
5375
6132
  case "group": {
5376
6133
  const children = Array.isArray(r.children) ? r.children.map((c) => deserializeLayer(c, ctx)).filter(Boolean) : [];
5377
- const blend = r.blend === "pass-through" ? "pass-through" : _chunkSZ6KMZNMcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
6134
+ const blend = r.blend === "pass-through" ? "pass-through" : _chunkXIOMMGPDcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
5378
6135
  const group = { ...base, type: "group", blend, children };
5379
6136
  if (r.collapsed === true) group.collapsed = true;
5380
6137
  return group;
@@ -5386,15 +6143,17 @@ function deserializeLayer(raw, ctx) {
5386
6143
  return null;
5387
6144
  }
5388
6145
  const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
5389
- const migrated = annotationLayerFor(annotation, _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })));
5390
- if (migrated.type === "shape") {
6146
+ 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]) });
6147
+ if (migrated.type === "shape" || migrated.type === "type") {
5391
6148
  const blend = base.blend === "normal" ? migrated.blend : base.blend;
5392
- return { ...migrated, ...base, blend, type: "shape", id, name: base.name };
6149
+ return { ...migrated, ...base, blend, id, name: base.name };
5393
6150
  }
5394
6151
  return { ...base, type: "annotation", annotation };
5395
6152
  }
5396
6153
  case "shape":
5397
6154
  return readShape(r, base, ctx);
6155
+ case "type":
6156
+ return readType(r, base, ctx);
5398
6157
  case "smart":
5399
6158
  return readSmartObject(r, base, ctx);
5400
6159
  default:
@@ -5414,8 +6173,8 @@ function readContents(id, ctx) {
5414
6173
  ctx.problems.push(`Smart object contents "${id}" are missing`);
5415
6174
  return null;
5416
6175
  }
5417
- const width = Math.round(num(raw.width, 0, 3e5, 0));
5418
- const height = Math.round(num(raw.height, 0, 3e5, 0));
6176
+ const width = Math.round(num2(raw.width, 0, 3e5, 0));
6177
+ const height = Math.round(num2(raw.height, 0, 3e5, 0));
5419
6178
  if (!(width > 0 && height > 0)) {
5420
6179
  ctx.problems.push(`Smart object contents "${id}" have no size`);
5421
6180
  return null;
@@ -5424,22 +6183,22 @@ function readContents(id, ctx) {
5424
6183
  const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
5425
6184
  if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
5426
6185
  try {
5427
- c.file = { type: raw.file.type, bytes: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, raw.file.data) };
5428
- } catch (e7) {
6186
+ c.file = { type: raw.file.type, bytes: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, raw.file.data) };
6187
+ } catch (e8) {
5429
6188
  ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
5430
6189
  }
5431
6190
  }
5432
6191
  if (raw.linked && typeof raw.linked.path === "string") c.linked = { path: raw.linked.path };
5433
6192
  if (c.kind === "raster") {
5434
6193
  if (typeof raw.asset === "string") c.raster = readSurface(raw.asset, 0, 0, 4, 0, ctx, `Smart object contents "${c.name}"`);
5435
- else if (!c.file) c.raster = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
6194
+ else if (!c.file) c.raster = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
5436
6195
  } else {
5437
6196
  const outer = ctx.canvas;
5438
6197
  ctx.canvas = { width, height };
5439
6198
  const layers = deserializeLayers(raw.layers, ctx);
5440
6199
  ctx.canvas = outer;
5441
6200
  c.document = { layers };
5442
- if (raw.globalLight && typeof raw.globalLight === "object") c.document.globalLight = { angle: num(raw.globalLight.angle, -360, 360, 120), altitude: num(raw.globalLight.altitude, 0, 90, 30) };
6201
+ if (raw.globalLight && typeof raw.globalLight === "object") c.document.globalLight = { angle: num2(raw.globalLight.angle, -360, 360, 120), altitude: num2(raw.globalLight.altitude, 0, 90, 30) };
5443
6202
  const patterns = deserializePatterns(raw.patterns, ctx.problems);
5444
6203
  if (patterns.length) c.document.patterns = patterns;
5445
6204
  }
@@ -5455,12 +6214,12 @@ function readSmartFilters(raw, ctx, what) {
5455
6214
  let k = 0;
5456
6215
  for (const f of list2) {
5457
6216
  if (!f || typeof f !== "object") continue;
5458
- const blend = _chunkSZ6KMZNMcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
5459
- const opacity = num(f.opacity, 0, 1, 1);
6217
+ const blend = _chunkXIOMMGPDcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
6218
+ const opacity = num2(f.opacity, 0, 1, 1);
5460
6219
  if (f.kind === "psd") {
5461
6220
  try {
5462
- 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: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
5463
- } catch (e8) {
6221
+ 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 });
6222
+ } catch (e9) {
5464
6223
  ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
5465
6224
  }
5466
6225
  } else if (f.kind === "develop" || f.kind === "blur") {
@@ -5485,21 +6244,21 @@ function readSmartObject(r, base, ctx) {
5485
6244
  try {
5486
6245
  const raw = { corners: p.corners };
5487
6246
  if (p.warp && _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
5488
- if (_chunkAZTZRLDIcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
6247
+ if (_chunkPOGBUYWEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
5489
6248
  placement = normalizePlacement(raw, contents);
5490
6249
  } catch (e) {
5491
6250
  ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
5492
6251
  placement = { corners: [{ x: 0, y: 0 }, { x: contents.width, y: 0 }, { x: contents.width, y: contents.height }, { x: 0, y: contents.height }] };
5493
6252
  }
5494
- const layer = { ...base, type: "smart", contents, placement, surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
6253
+ const layer = { ...base, type: "smart", contents, placement, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
5495
6254
  const filters = readSmartFilters(r.smartFilters, ctx, what);
5496
6255
  if (filters) layer.smartFilters = filters;
5497
- if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
6256
+ if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5498
6257
  if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
5499
6258
  try {
5500
- layer.psd = { key: r.psd.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, r.psd.data) };
6259
+ layer.psd = { key: r.psd.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.data) };
5501
6260
  if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
5502
- } catch (e9) {
6261
+ } catch (e10) {
5503
6262
  }
5504
6263
  }
5505
6264
  if (typeof r.asset === "string") layer.surface = readSurface(r.asset, r.x, r.y, 4, 0, ctx, what);
@@ -5742,7 +6501,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
5742
6501
  function decodeLegacyName(b) {
5743
6502
  try {
5744
6503
  return new TextDecoder("utf-8", { fatal: true }).decode(b);
5745
- } catch (e10) {
6504
+ } catch (e11) {
5746
6505
  return String.fromCharCode(...b);
5747
6506
  }
5748
6507
  }
@@ -5821,9 +6580,9 @@ function packbitsDecodeInto(src, expected, out, at) {
5821
6580
  function inflateChecked(data, expected) {
5822
6581
  let out;
5823
6582
  try {
5824
- out = _chunkAZTZRLDIcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
6583
+ out = _chunkPOGBUYWEcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
5825
6584
  } catch (e) {
5826
- throw new PsdError(`ZIP channel data: ${e instanceof _chunkAZTZRLDIcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
6585
+ throw new PsdError(`ZIP channel data: ${e instanceof _chunkPOGBUYWEcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
5827
6586
  }
5828
6587
  if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
5829
6588
  return out.length === expected ? out : out.subarray(0, expected);
@@ -5919,7 +6678,7 @@ function descriptor(classId, items = []) {
5919
6678
  return { name: "", classId, items };
5920
6679
  }
5921
6680
  function descGet(d, key) {
5922
- return _optionalChain([d, 'access', _126 => _126.items, 'access', _127 => _127.find, 'call', _128 => _128(([k]) => k === key), 'optionalAccess', _129 => _129[1]]);
6681
+ return _optionalChain([d, 'access', _169 => _169.items, 'access', _170 => _170.find, 'call', _171 => _171(([k]) => k === key), 'optionalAccess', _172 => _172[1]]);
5923
6682
  }
5924
6683
  function descNumber(d, key) {
5925
6684
  const v = descGet(d, key);
@@ -5929,7 +6688,7 @@ function descNumber(d, key) {
5929
6688
  }
5930
6689
  function descBool(d, key) {
5931
6690
  const v = descGet(d, key);
5932
- return _optionalChain([v, 'optionalAccess', _130 => _130.type]) === "bool" ? v.value : void 0;
6691
+ return _optionalChain([v, 'optionalAccess', _173 => _173.type]) === "bool" ? v.value : void 0;
5933
6692
  }
5934
6693
  function descObject(d, key) {
5935
6694
  const v = descGet(d, key);
@@ -6400,7 +7159,7 @@ function parseAdjustmentBlock(key, data) {
6400
7159
  default:
6401
7160
  return null;
6402
7161
  }
6403
- } catch (e11) {
7162
+ } catch (e12) {
6404
7163
  return null;
6405
7164
  }
6406
7165
  }
@@ -6521,15 +7280,15 @@ var textV = (value) => ({ type: "TEXT", value });
6521
7280
  var obj = (d) => ({ type: "Objc", value: d });
6522
7281
  var text = (d, key) => {
6523
7282
  const v = descGet(d, key);
6524
- return _optionalChain([v, 'optionalAccess', _131 => _131.type]) === "TEXT" ? v.value : void 0;
7283
+ return _optionalChain([v, 'optionalAccess', _174 => _174.type]) === "TEXT" ? v.value : void 0;
6525
7284
  };
6526
7285
  var enumOf = (d, key) => {
6527
7286
  const v = descGet(d, key);
6528
- return _optionalChain([v, 'optionalAccess', _132 => _132.type]) === "enum" ? v.value : void 0;
7287
+ return _optionalChain([v, 'optionalAccess', _175 => _175.type]) === "enum" ? v.value : void 0;
6529
7288
  };
6530
7289
  var numbers = (d, key) => {
6531
7290
  const v = descGet(d, key);
6532
- if (_optionalChain([v, 'optionalAccess', _133 => _133.type]) !== "VlLs") return null;
7291
+ if (_optionalChain([v, 'optionalAccess', _176 => _176.type]) !== "VlLs") return null;
6533
7292
  const out = [];
6534
7293
  for (const it of v.items) {
6535
7294
  if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
@@ -6573,7 +7332,7 @@ function readLinkedItem(item) {
6573
7332
  try {
6574
7333
  const d = readVersionedDescriptor(r);
6575
7334
  path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
6576
- } catch (e12) {
7335
+ } catch (e13) {
6577
7336
  path = void 0;
6578
7337
  }
6579
7338
  void version;
@@ -6590,7 +7349,7 @@ function parseLinkedFiles(data) {
6590
7349
  try {
6591
7350
  const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
6592
7351
  if (item) out.push(item);
6593
- } catch (e13) {
7352
+ } catch (e14) {
6594
7353
  }
6595
7354
  at = at + 8 + len + 3 & ~3;
6596
7355
  }
@@ -6717,21 +7476,21 @@ function filterMaskFromItem(item) {
6717
7476
  const height = rect.bottom - rect.top;
6718
7477
  if (!(width > 0 && height > 0) || width * height > 1 << 28) return null;
6719
7478
  const bytes = decodePlanes(plane.compression, plane.data, { planes: 1, width, height, depth: 8, psb: true });
6720
- const surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
7479
+ const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
6721
7480
  return { surface, defaultValue: 255 };
6722
7481
  }
6723
7482
  function filterMaskItem(placed, mask, area) {
6724
- const painted = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, mask.surface);
7483
+ const painted = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
6725
7484
  let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
6726
7485
  if (mask.defaultValue !== 255 && area) {
6727
- const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _134 => _134.x]), () => ( area.x)));
6728
- const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _135 => _135.y]), () => ( area.y)));
7486
+ const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _177 => _177.x]), () => ( area.x)));
7487
+ const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _178 => _178.y]), () => ( area.y)));
6729
7488
  const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
6730
7489
  const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
6731
7490
  b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
6732
7491
  }
6733
7492
  const rect = { top: b.y, left: b.x, bottom: b.y + b.height, right: b.x + b.width };
6734
- const values = _chunkSZ6KMZNMcjs.readRegion.call(void 0, mask.surface, b);
7493
+ const values = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, b);
6735
7494
  const plane = new Uint8Array(values.buffer, values.byteOffset, values.length);
6736
7495
  return {
6737
7496
  id: placed,
@@ -6745,7 +7504,7 @@ function filterMaskItem(placed, mask, area) {
6745
7504
  }
6746
7505
  var warpStyleOf = (name) => {
6747
7506
  if (!name.startsWith("warp")) return null;
6748
- const s = _optionalChain([name, 'access', _136 => _136[4], 'optionalAccess', _137 => _137.toLowerCase, 'call', _138 => _138()]) + name.slice(5);
7507
+ const s = _optionalChain([name, 'access', _179 => _179[4], 'optionalAccess', _180 => _180.toLowerCase, 'call', _181 => _181()]) + name.slice(5);
6749
7508
  return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
6750
7509
  };
6751
7510
  function warpFromDescriptor(w, contents) {
@@ -6767,7 +7526,7 @@ function warpFromDescriptor(w, contents) {
6767
7526
  if (!arr || arr.type !== "ObAr") return void 0;
6768
7527
  const xs = descGet(arr.body, "Hrzn");
6769
7528
  const ys = descGet(arr.body, "Vrtc");
6770
- if (_optionalChain([xs, 'optionalAccess', _139 => _139.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _140 => _140.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
7529
+ if (_optionalChain([xs, 'optionalAccess', _182 => _182.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _183 => _183.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
6771
7530
  mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
6772
7531
  const px = mesh.points.map((p) => p.x);
6773
7532
  const py = mesh.points.map((p) => p.y);
@@ -6888,13 +7647,13 @@ function parsePlaced(key, data) {
6888
7647
  r.u32();
6889
7648
  try {
6890
7649
  warp = readVersionedDescriptor(r);
6891
- } catch (e14) {
7650
+ } catch (e15) {
6892
7651
  warp = void 0;
6893
7652
  }
6894
7653
  }
6895
7654
  return { key, idnt, placed: idnt, quad, warp };
6896
7655
  }
6897
- } catch (e15) {
7656
+ } catch (e16) {
6898
7657
  return null;
6899
7658
  }
6900
7659
  return null;
@@ -6934,13 +7693,13 @@ function blendOptions(f) {
6934
7693
  function smartFiltersFromPsd(fx, newId, notes) {
6935
7694
  const filters = [];
6936
7695
  const list2 = descGet(fx, "filterFXList");
6937
- for (const v of _optionalChain([list2, 'optionalAccess', _141 => _141.type]) === "VlLs" ? list2.items : []) {
7696
+ for (const v of _optionalChain([list2, 'optionalAccess', _184 => _184.type]) === "VlLs" ? list2.items : []) {
6938
7697
  if (v.type !== "Objc" && v.type !== "GlbO") continue;
6939
7698
  const item = v.value;
6940
7699
  const { blend, opacity } = blendOptionsOf(item);
6941
7700
  const enabled = descBool(item, "enab") !== false;
6942
7701
  const fltr = descObject(item, "Fltr");
6943
- const radius = _optionalChain([fltr, 'optionalAccess', _142 => _142.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
7702
+ const radius = _optionalChain([fltr, 'optionalAccess', _185 => _185.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
6944
7703
  if (radius !== void 0 && radius >= 0 && radius <= 50) {
6945
7704
  filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
6946
7705
  continue;
@@ -7219,7 +7978,7 @@ function parseMask(d) {
7219
7978
  }
7220
7979
  if (!realFirst) m.real = readReal();
7221
7980
  return m;
7222
- } catch (e16) {
7981
+ } catch (e17) {
7223
7982
  return void 0;
7224
7983
  }
7225
7984
  }
@@ -7293,14 +8052,14 @@ function readPsd(bytes) {
7293
8052
  return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
7294
8053
  }
7295
8054
  function layerBlock(rec, key) {
7296
- return _optionalChain([rec, 'access', _143 => _143.blocks, 'access', _144 => _144.find, 'call', _145 => _145((b) => b.key === key), 'optionalAccess', _146 => _146.data]);
8055
+ return _optionalChain([rec, 'access', _186 => _186.blocks, 'access', _187 => _187.find, 'call', _188 => _188((b) => b.key === key), 'optionalAccess', _189 => _189.data]);
7297
8056
  }
7298
8057
  function layerName(rec) {
7299
8058
  const luni = layerBlock(rec, "luni");
7300
8059
  if (luni) {
7301
8060
  try {
7302
8061
  return new PsdReader(luni).unicode();
7303
- } catch (e17) {
8062
+ } catch (e18) {
7304
8063
  }
7305
8064
  }
7306
8065
  return rec.legacyName;
@@ -7324,7 +8083,7 @@ function u8Block(rec, key) {
7324
8083
  function layerTree(file) {
7325
8084
  const stack = [[]];
7326
8085
  file.layers.forEach((rec, index) => {
7327
- const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _147 => _147(rec), 'optionalAccess', _148 => _148.kind]), () => ( SECTION_OTHER));
8086
+ const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _190 => _190(rec), 'optionalAccess', _191 => _191.kind]), () => ( SECTION_OTHER));
7328
8087
  if (kind === SECTION_DIVIDER) {
7329
8088
  stack.push([]);
7330
8089
  } else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
@@ -7342,7 +8101,7 @@ function layerTree(file) {
7342
8101
  }
7343
8102
  function channelRect(rec, id) {
7344
8103
  if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
7345
- if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _149 => _149.mask, 'access', _150 => _150.real, 'optionalAccess', _151 => _151.rect]), () => ( rec.mask.rect));
8104
+ if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _192 => _192.mask, 'access', _193 => _193.real, 'optionalAccess', _194 => _194.rect]), () => ( rec.mask.rect));
7346
8105
  return rec.rect;
7347
8106
  }
7348
8107
  function decodeLayerChannel(file, rec, id) {
@@ -7360,7 +8119,7 @@ function decodeMergedImage(file) {
7360
8119
  return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
7361
8120
  }
7362
8121
  function resource(file, id) {
7363
- return _optionalChain([file, 'access', _152 => _152.resources, 'access', _153 => _153.find, 'call', _154 => _154((r) => r.id === id), 'optionalAccess', _155 => _155.data]);
8122
+ return _optionalChain([file, 'access', _195 => _195.resources, 'access', _196 => _196.find, 'call', _197 => _197((r) => r.id === id), 'optionalAccess', _198 => _198.data]);
7364
8123
  }
7365
8124
  function resolution(file) {
7366
8125
  const d = resource(file, 1005);
@@ -7863,11 +8622,11 @@ function safeSize(ctx, rect, name) {
7863
8622
  }
7864
8623
  function recordPixels(ctx, rec, name) {
7865
8624
  const { width, height } = safeSize(ctx, rec.rect, name);
7866
- if (!width || !height || ctx.skipPixels) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
8625
+ if (!width || !height || ctx.skipPixels) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
7867
8626
  const ids = [...Array.from({ length: ctx.colorCount }, (_, i) => i), CHANNEL_ALPHA];
7868
8627
  const planes = ids.map((id) => rec.channels.some((c) => c.id === id) ? _nullishCoalesce(decodeOr(ctx, rec, id, name), () => ( null)) : void 0);
7869
- if (planes.some((p) => p === null)) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
7870
- if (planes.every((p) => p === void 0)) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
8628
+ if (planes.some((p) => p === null)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
8629
+ if (planes.every((p) => p === void 0)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
7871
8630
  const data = toRgba8({
7872
8631
  width,
7873
8632
  height,
@@ -7877,7 +8636,7 @@ function recordPixels(ctx, rec, name) {
7877
8636
  alpha: planes[ctx.colorCount],
7878
8637
  palette: ctx.palette
7879
8638
  });
7880
- return _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, rec.rect.left, rec.rect.top);
8639
+ return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, rec.rect.left, rec.rect.top);
7881
8640
  }
7882
8641
  function recordMask(ctx, rec, name) {
7883
8642
  const m = rec.mask;
@@ -7888,11 +8647,11 @@ function recordMask(ctx, rec, name) {
7888
8647
  const rect = useReal ? m.real.rect : m.rect;
7889
8648
  const def = (useReal ? m.real.background : m.defaultColor) >= 128 ? 255 : 0;
7890
8649
  const flags = useReal ? m.real.flags : m.flags;
7891
- let surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 1, def);
8650
+ let surface = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, def);
7892
8651
  const { width, height } = safeSize(ctx, rect, name);
7893
8652
  if (width && height && !ctx.skipPixels) {
7894
8653
  const plane = decodeOr(ctx, rec, id, name);
7895
- if (plane) surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, ctx.file.header.depth) }, 1, rect.left, rect.top, def);
8654
+ 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);
7896
8655
  }
7897
8656
  const mask = { surface, defaultValue: def };
7898
8657
  if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
@@ -7952,7 +8711,7 @@ function recordEffects(ctx, rec, name, notes, group) {
7952
8711
  }
7953
8712
  for (const e of parsed.effects.items) {
7954
8713
  for (const id of patternIds(e)) {
7955
- if (ctx.patterns.has(id) || _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)) continue;
8714
+ if (ctx.patterns.has(id) || _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)) continue;
7956
8715
  ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
7957
8716
  notes.push(`pattern "${id}" is not in the file`);
7958
8717
  }
@@ -7981,7 +8740,7 @@ function importNode(ctx, node, depth) {
7981
8740
  if (node.children) {
7982
8741
  const props2 = baseProps(ctx, rec, name, notes);
7983
8742
  const divider = sectionDivider(rec);
7984
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _156 => _156.blendKey]), () => ( rec.blendKey));
8743
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _199 => _199.blendKey]), () => ( rec.blendKey));
7985
8744
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
7986
8745
  const children = [];
7987
8746
  for (const child of node.children) {
@@ -7991,7 +8750,7 @@ function importNode(ctx, node, depth) {
7991
8750
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
7992
8751
  const effects2 = recordEffects(ctx, rec, name, notes, true);
7993
8752
  if (effects2) group.effects = effects2;
7994
- if (_optionalChain([divider, 'optionalAccess', _157 => _157.kind]) === SECTION_CLOSED) group.collapsed = true;
8753
+ if (_optionalChain([divider, 'optionalAccess', _200 => _200.kind]) === SECTION_CLOSED) group.collapsed = true;
7995
8754
  const mask2 = recordMask(ctx, rec, name);
7996
8755
  if (mask2) group.mask = mask2;
7997
8756
  entry.type = "group";
@@ -8031,7 +8790,7 @@ function importNode(ctx, node, depth) {
8031
8790
  if (!file || file.kind !== "liFD") notes.push("linked contents come in as the stored pixels");
8032
8791
  entry.type = "smart";
8033
8792
  entry.status = notes.length ? "approximated" : "mapped";
8034
- return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
8793
+ return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
8035
8794
  }
8036
8795
  }
8037
8796
  if (kind === "smart-object" && !ctx.skipPixels) {
@@ -8081,8 +8840,8 @@ function contentsFor(ctx, placed, name, notes) {
8081
8840
  document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
8082
8841
  };
8083
8842
  } else if (t.ext === "png") {
8084
- const png = _chunkAZTZRLDIcjs.decodePng.call(void 0, file.bytes);
8085
- out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
8843
+ const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, file.bytes);
8844
+ out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
8086
8845
  } else {
8087
8846
  const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
8088
8847
  if (!(size.width > 0 && size.height > 0)) throw new PsdError("the contents have no stored size");
@@ -8133,11 +8892,11 @@ function importSmart(ctx, rec, name, notes, props) {
8133
8892
  const file = ctx.linked.get(placed.idnt);
8134
8893
  contents = {
8135
8894
  id: placed.idnt || ctx.newId(`${name}-contents`),
8136
- name: _optionalChain([file, 'optionalAccess', _158 => _158.name]) || `${name}.png`,
8895
+ name: _optionalChain([file, 'optionalAccess', _201 => _201.name]) || `${name}.png`,
8137
8896
  width,
8138
8897
  height,
8139
8898
  kind: "raster",
8140
- raster: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
8899
+ raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
8141
8900
  };
8142
8901
  if (file && file.kind !== "liFD") {
8143
8902
  contents.linked = { path: _nullishCoalesce(file.path, () => ( file.name)) };
@@ -8211,7 +8970,7 @@ function mergedLayer(ctx) {
8211
8970
  visible: true,
8212
8971
  opacity: 1,
8213
8972
  blend: "normal",
8214
- surface: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4),
8973
+ surface: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4),
8215
8974
  offset: { x: 0, y: 0 }
8216
8975
  };
8217
8976
  }
@@ -8353,20 +9112,20 @@ function blendFromPsdId(id) {
8353
9112
  function psdBlendId(mode) {
8354
9113
  return _nullishCoalesce(BLEND_ID.get(mode), () => ( "Nrml"));
8355
9114
  }
8356
- var num2 = (d, key, fallback) => _nullishCoalesce(descNumber(d, key), () => ( fallback));
8357
- var pct = (d, key, fallback) => num2(d, key, fallback * 100) / 100;
9115
+ var num3 = (d, key, fallback) => _nullishCoalesce(descNumber(d, key), () => ( fallback));
9116
+ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
8358
9117
  var bool = (d, key) => descBool(d, key) === true;
8359
9118
  var enumOf2 = (d, key) => {
8360
9119
  const v = descGet(d, key);
8361
- return _optionalChain([v, 'optionalAccess', _159 => _159.type]) === "enum" ? v.value : void 0;
9120
+ return _optionalChain([v, 'optionalAccess', _202 => _202.type]) === "enum" ? v.value : void 0;
8362
9121
  };
8363
9122
  var text2 = (d, key) => {
8364
9123
  const v = d ? descGet(d, key) : void 0;
8365
- return _optionalChain([v, 'optionalAccess', _160 => _160.type]) === "TEXT" ? v.value : "";
9124
+ return _optionalChain([v, 'optionalAccess', _203 => _203.type]) === "TEXT" ? v.value : "";
8366
9125
  };
8367
9126
  var list = (d, key) => {
8368
9127
  const v = descGet(d, key);
8369
- if (_optionalChain([v, 'optionalAccess', _161 => _161.type]) !== "VlLs") return [];
9128
+ if (_optionalChain([v, 'optionalAccess', _204 => _204.type]) !== "VlLs") return [];
8370
9129
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
8371
9130
  };
8372
9131
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -8388,34 +9147,34 @@ function blendOf(d, key, fallback, notes) {
8388
9147
  function colorOf(d, fallback = "#000000") {
8389
9148
  if (!d) return fallback;
8390
9149
  const g = (k) => descNumber(d, k);
8391
- if (g("redFloat") !== void 0) return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
9150
+ if (g("redFloat") !== void 0) return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
8392
9151
  switch (d.classId) {
8393
9152
  case "HSBC": {
8394
9153
  const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
8395
- return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
9154
+ return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
8396
9155
  }
8397
9156
  case "CMYC": {
8398
9157
  const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
8399
9158
  const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
8400
- return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
9159
+ return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
8401
9160
  }
8402
9161
  case "LbCl": {
8403
9162
  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]);
8404
- return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
9163
+ return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
8405
9164
  }
8406
9165
  case "Grsc": {
8407
9166
  const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
8408
- return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [v, v, v]);
9167
+ return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [v, v, v]);
8409
9168
  }
8410
9169
  }
8411
9170
  const r = g("Rd ");
8412
9171
  const gr = g("Grn ");
8413
9172
  const b = g("Bl ");
8414
9173
  if (r === void 0 || gr === void 0 || b === void 0) return fallback;
8415
- return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
9174
+ return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
8416
9175
  }
8417
9176
  function colorDesc(hex) {
8418
- const [r, g, b] = _nullishCoalesce(_chunkAZTZRLDIcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
9177
+ const [r, g, b] = _nullishCoalesce(_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
8419
9178
  return descriptor("RGBC", [
8420
9179
  ["Rd ", dbl2(r * 255)],
8421
9180
  ["Grn ", dbl2(g * 255)],
@@ -8427,7 +9186,7 @@ function contourOf(d, key) {
8427
9186
  if (!c) return void 0;
8428
9187
  const name = text2(c, "Nm ");
8429
9188
  const points = list(c, "Crv ").map((p) => {
8430
- const out = { input: clamp3(num2(p, "Hrzn", 0) / 255, 0, 1), output: clamp3(num2(p, "Vrtc", 0) / 255, 0, 1) };
9189
+ const out = { input: clamp3(num3(p, "Hrzn", 0) / 255, 0, 1), output: clamp3(num3(p, "Vrtc", 0) / 255, 0, 1) };
8431
9190
  if (descBool(p, "Cnty") === false) out.corner = true;
8432
9191
  return out;
8433
9192
  });
@@ -8436,8 +9195,8 @@ function contourOf(d, key) {
8436
9195
  return { name, points };
8437
9196
  }
8438
9197
  function contourDesc(c) {
8439
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _162 => _162.name]), () => ( "Linear"));
8440
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _163 => _163.points]), () => ( [
9198
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _205 => _205.name]), () => ( "Linear"));
9199
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _206 => _206.points]), () => ( [
8441
9200
  { input: 0, output: 0 },
8442
9201
  { input: 1, output: 1 }
8443
9202
  ]));
@@ -8472,8 +9231,8 @@ function gradientOf(d, notes) {
8472
9231
  { position: 0, color: "#000000" },
8473
9232
  { position: 1, color: "#ffffff" }
8474
9233
  ],
8475
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _164 => _164.find, 'call', _165 => _165(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _166 => _166[0]]), () => ( "linear")),
8476
- angle: clamp3(num2(d, "Angl", 90), -360, 360),
9234
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _207 => _207.find, 'call', _208 => _208(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _209 => _209[0]]), () => ( "linear")),
9235
+ angle: clamp3(num3(d, "Angl", 90), -360, 360),
8477
9236
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
8478
9237
  reverse: bool(d, "Rvrs"),
8479
9238
  align: descBool(d, "Algn") !== false,
@@ -8491,25 +9250,25 @@ function gradientOf(d, notes) {
8491
9250
  const type = enumOf2(s, "Type");
8492
9251
  if (type === "FrgC" || type === "BckC") notes.add("foreground / background gradient stops became black / white");
8493
9252
  const color = type === "BckC" ? "#ffffff" : colorOf(descObject(s, "Clr "));
8494
- return { position: clamp3(num2(s, "Lctn", 0) / 4096, 0, 1), color, mid: clamp3(num2(s, "Mdpn", 50) / 100, 0.05, 0.95) };
9253
+ return { position: clamp3(num3(s, "Lctn", 0) / 4096, 0, 1), color, mid: clamp3(num3(s, "Mdpn", 50) / 100, 0.05, 0.95) };
8495
9254
  }).sort((a, b) => a.position - b.position);
8496
9255
  if (raw.length) {
8497
9256
  const stops = [];
8498
9257
  raw.forEach((s, i) => {
8499
9258
  if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
8500
9259
  const a = raw[i - 1];
8501
- const ca = _chunkAZTZRLDIcjs.parseEffectColor.call(void 0, a.color);
8502
- const cb = _chunkAZTZRLDIcjs.parseEffectColor.call(void 0, s.color);
8503
- stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkAZTZRLDIcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
9260
+ const ca = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, a.color);
9261
+ const cb = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, s.color);
9262
+ 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)) });
8504
9263
  notes.add("gradient midpoints are drawn as straight segments");
8505
9264
  }
8506
9265
  stops.push({ position: s.position, color: s.color });
8507
9266
  });
8508
9267
  g.stops = stops;
8509
9268
  }
8510
- const opacity = list(grad, "Trns").map((s) => ({ position: clamp3(num2(s, "Lctn", 0) / 4096, 0, 1), opacity: clamp3(num2(s, "Opct", 100) / 100, 0, 1) })).sort((a, b) => a.position - b.position);
9269
+ const opacity = list(grad, "Trns").map((s) => ({ position: clamp3(num3(s, "Lctn", 0) / 4096, 0, 1), opacity: clamp3(num3(s, "Opct", 100) / 100, 0, 1) })).sort((a, b) => a.position - b.position);
8511
9270
  if (opacity.some((o) => o.opacity < 1)) g.opacityStops = opacity;
8512
- if (num2(grad, "Intr", 0) > 0) notes.add("gradient smoothness is drawn as straight segments");
9271
+ if (num3(grad, "Intr", 0) > 0) notes.add("gradient smoothness is drawn as straight segments");
8513
9272
  return g;
8514
9273
  }
8515
9274
  function gradientItems(g) {
@@ -8526,7 +9285,7 @@ function gradientItems(g) {
8526
9285
  )
8527
9286
  )
8528
9287
  };
8529
- const op = _optionalChain([g, 'access', _167 => _167.opacityStops, 'optionalAccess', _168 => _168.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
9288
+ const op = _optionalChain([g, 'access', _210 => _210.opacityStops, 'optionalAccess', _211 => _211.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
8530
9289
  const trns = {
8531
9290
  type: "VlLs",
8532
9291
  items: op.map(
@@ -8579,9 +9338,9 @@ function patternRefDesc(patternId, name) {
8579
9338
  function placementOf(d) {
8580
9339
  const phase = descObject(d, "phase");
8581
9340
  return {
8582
- angle: clamp3(num2(d, "Angl", 0), -360, 360),
9341
+ angle: clamp3(num3(d, "Angl", 0), -360, 360),
8583
9342
  link: descBool(d, "Algn") !== false,
8584
- phase: phase ? { x: num2(phase, "Hrzn", 0), y: num2(phase, "Vrtc", 0) } : { x: 0, y: 0 }
9343
+ phase: phase ? { x: num3(phase, "Hrzn", 0), y: num3(phase, "Vrtc", 0) } : { x: 0, y: 0 }
8585
9344
  };
8586
9345
  }
8587
9346
  function placementItems(angle, link, phase) {
@@ -8612,20 +9371,20 @@ var KINDS = [
8612
9371
  ["FrFX", "frameFXMulti", "stroke"]
8613
9372
  ];
8614
9373
  function common(d, kind, notes) {
8615
- const def = _chunkAZTZRLDIcjs.defaultLayerEffect.call(void 0, kind, "x");
8616
- return { id: _chunkAZTZRLDIcjs.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) };
9374
+ const def = _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, "x");
9375
+ 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) };
8617
9376
  }
8618
9377
  function readOne(kind, d, notes) {
8619
- const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
9378
+ const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
8620
9379
  switch (kind) {
8621
9380
  case "drop-shadow":
8622
9381
  case "inner-shadow": {
8623
9382
  const base = {
8624
9383
  ...common(d, kind, notes),
8625
9384
  color: colorOf(descObject(d, "Clr ")),
8626
- angle: clamp3(num2(d, "lagl", 120), -360, 360),
9385
+ angle: clamp3(num3(d, "lagl", 120), -360, 360),
8627
9386
  useGlobalLight: descBool(d, "uglg") !== false,
8628
- distance: clamp3(num2(d, "Dstn", 5), 0, 3e4),
9387
+ distance: clamp3(num3(d, "Dstn", 5), 0, 3e4),
8629
9388
  size: size("blur", 5),
8630
9389
  contour: contourOf(d, "TrnS"),
8631
9390
  antiAlias: bool(d, "AntA"),
@@ -8656,7 +9415,7 @@ function readOne(kind, d, notes) {
8656
9415
  case "bevel-emboss": {
8657
9416
  const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
8658
9417
  const out = {
8659
- id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ),
9418
+ id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ),
8660
9419
  enabled: descBool(d, "enab") !== false,
8661
9420
  kind,
8662
9421
  style: _nullishCoalesce(styles[_nullishCoalesce(enumOf2(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
@@ -8664,9 +9423,9 @@ function readOne(kind, d, notes) {
8664
9423
  depth: clamp3(pct(d, "srgR", 1), 0, 10),
8665
9424
  direction: enumOf2(d, "bvlD") === "Out " ? "down" : "up",
8666
9425
  size: size("blur", 5),
8667
- soften: clamp3(num2(d, "Sftn", 0), 0, 16),
8668
- angle: clamp3(num2(d, "lagl", 120), -360, 360),
8669
- altitude: clamp3(num2(d, "Lald", 30), 0, 90),
9426
+ soften: clamp3(num3(d, "Sftn", 0), 0, 16),
9427
+ angle: clamp3(num3(d, "lagl", 120), -360, 360),
9428
+ altitude: clamp3(num3(d, "Lald", 30), 0, 90),
8670
9429
  useGlobalLight: descBool(d, "uglg") !== false,
8671
9430
  glossContour: contourOf(d, "TrnS"),
8672
9431
  highlightColor: colorOf(descObject(d, "hglC"), "#ffffff"),
@@ -8689,7 +9448,7 @@ function readOne(kind, d, notes) {
8689
9448
  ...common(d, kind, notes),
8690
9449
  kind,
8691
9450
  color: colorOf(descObject(d, "Clr ")),
8692
- angle: clamp3(num2(d, "lagl", 19), -360, 360),
9451
+ angle: clamp3(num3(d, "lagl", 19), -360, 360),
8693
9452
  distance: size("Dstn", 11),
8694
9453
  size: size("blur", 14),
8695
9454
  contour: contourOf(d, "MpgS"),
@@ -8722,7 +9481,7 @@ function parseLfx2(data) {
8722
9481
  let d;
8723
9482
  try {
8724
9483
  d = parseVersionedDescriptor(data.subarray(4));
8725
- } catch (e18) {
9484
+ } catch (e19) {
8726
9485
  return null;
8727
9486
  }
8728
9487
  const notes = /* @__PURE__ */ new Set();
@@ -8867,10 +9626,10 @@ function writeLfx2(effects) {
8867
9626
  ["Scl ", unit2("#Prc", 100)],
8868
9627
  ["masterFXSwitch", boolV2(effects.enabled)]
8869
9628
  ];
8870
- const scale = _chunkAZTZRLDIcjs.effectsScale.call(void 0, effects);
9629
+ const scale = _chunkPOGBUYWEcjs.effectsScale.call(void 0, effects);
8871
9630
  let dropped = 0;
8872
9631
  for (const [single, multi, kind] of KINDS) {
8873
- const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkAZTZRLDIcjs.scaleLayerEffect.call(void 0, e, scale)));
9632
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPOGBUYWEcjs.scaleLayerEffect.call(void 0, e, scale)));
8874
9633
  if (!of.length) continue;
8875
9634
  if (of.length === 1) items.push([single, obj2(of[0])]);
8876
9635
  else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj2) }]);
@@ -8902,7 +9661,7 @@ function parseLrfx(data) {
8902
9661
  const colorAt = (rd) => {
8903
9662
  rd.u16();
8904
9663
  const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
8905
- return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
9664
+ return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
8906
9665
  };
8907
9666
  const blendAt = (rd) => {
8908
9667
  rd.skip(4);
@@ -8921,7 +9680,7 @@ function parseLrfx(data) {
8921
9680
  const enabled = b.u8() !== 0;
8922
9681
  const useGlobalLight = b.u8() !== 0;
8923
9682
  const opacity = b.u8() / 255;
8924
- const base = { id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
9683
+ 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 };
8925
9684
  items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
8926
9685
  } else if (key === "oglw" || key === "iglw") {
8927
9686
  b.u32();
@@ -8931,7 +9690,7 @@ function parseLrfx(data) {
8931
9690
  const blend = blendAt(b);
8932
9691
  const enabled = b.u8() !== 0;
8933
9692
  const opacity = b.u8() / 255;
8934
- const base = { id: _chunkAZTZRLDIcjs.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 };
9693
+ 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 };
8935
9694
  items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
8936
9695
  } else if (key === "sofi") {
8937
9696
  b.u32();
@@ -8939,11 +9698,11 @@ function parseLrfx(data) {
8939
9698
  const color = colorAt(b);
8940
9699
  const opacity = b.u8() / 255;
8941
9700
  const enabled = b.u8() !== 0;
8942
- items.push({ id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
9701
+ items.push({ id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
8943
9702
  } else if (key === "bevl") notes.add("legacy bevels are not read");
8944
9703
  }
8945
9704
  return { effects: { enabled: true, items }, notes: [...notes] };
8946
- } catch (e19) {
9705
+ } catch (e20) {
8947
9706
  return null;
8948
9707
  }
8949
9708
  }
@@ -8989,14 +9748,14 @@ function rleChannel(id, plane, width, height, psb) {
8989
9748
  var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
8990
9749
  function maskChannel(mask, ox, oy, psb) {
8991
9750
  if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
8992
- const bounds = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, mask.surface);
9751
+ const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
8993
9752
  const def = mask.defaultValue;
8994
9753
  const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
8995
9754
  const m = { rect: EMPTY_RECT, defaultColor: def, flags };
8996
9755
  if ((_nullishCoalesce(mask.density, () => ( 1))) < 1) m.userDensity = Math.round(Math.max(0, _nullishCoalesce(mask.density, () => ( 1))) * 255);
8997
9756
  if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) m.userFeather = mask.feather;
8998
9757
  if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
8999
- const plane = _chunkSZ6KMZNMcjs.readRegion.call(void 0, mask.surface, bounds);
9758
+ const plane = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, bounds);
9000
9759
  m.rect = toRect({ ...bounds, x: bounds.x + ox, y: bounds.y + oy });
9001
9760
  return { channel: rleChannel(CHANNEL_USER_MASK, new Uint8Array(plane.buffer, plane.byteOffset, plane.length), bounds.width, bounds.height, psb), mask: m };
9002
9761
  }
@@ -9011,9 +9770,9 @@ function prepareNestedLayers(layers) {
9011
9770
  if (l.type === "annotation") continue;
9012
9771
  let next = l;
9013
9772
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
9014
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _169 => _169.filters, 'optionalAccess', _170 => _170.length]) || l.source === "document")) {
9773
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _212 => _212.filters, 'optionalAccess', _213 => _213.length]) || l.source === "document")) {
9015
9774
  const p = { ...l };
9016
- if (_optionalChain([l, 'access', _171 => _171.filters, 'optionalAccess', _172 => _172.some, 'call', _173 => _173(isActiveFilter)])) {
9775
+ if (_optionalChain([l, 'access', _214 => _214.filters, 'optionalAccess', _215 => _215.some, 'call', _216 => _216(isActiveFilter)])) {
9017
9776
  const b = l.surface.bounds;
9018
9777
  if (b) {
9019
9778
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -9023,14 +9782,14 @@ function prepareNestedLayers(layers) {
9023
9782
  delete plain.effects;
9024
9783
  delete plain.fillOpacity;
9025
9784
  const data = new LayerCompositor().composite([plain], r, { width: r.x + r.width, height: r.y + r.height });
9026
- p.surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
9785
+ 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);
9027
9786
  }
9028
9787
  }
9029
9788
  delete p.filters;
9030
9789
  delete p.source;
9031
9790
  next = p;
9032
9791
  }
9033
- if (_optionalChain([next, 'access', _174 => _174.mask, 'optionalAccess', _175 => _175.source])) {
9792
+ if (_optionalChain([next, 'access', _217 => _217.mask, 'optionalAccess', _218 => _218.source])) {
9034
9793
  next = { ...next };
9035
9794
  delete next.mask;
9036
9795
  }
@@ -9042,11 +9801,11 @@ function smartContentsFile(c) {
9042
9801
  const base = c.name.replace(/\.\w+$/, "") || "Contents";
9043
9802
  if (c.file) return { name: c.name, bytes: c.file.bytes };
9044
9803
  if (c.kind === "raster") {
9045
- const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
9046
- return { name: `${base}.png`, bytes: _chunkAZTZRLDIcjs.encodePng.call(void 0, c.width, c.height, data) };
9804
+ const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
9805
+ return { name: `${base}.png`, bytes: _chunkPOGBUYWEcjs.encodePng.call(void 0, c.width, c.height, data) };
9047
9806
  }
9048
9807
  const doc = c.document;
9049
- const merged = _chunkSZ6KMZNMcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
9808
+ const merged = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
9050
9809
  const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged, patterns: doc.patterns, globalLight: doc.globalLight });
9051
9810
  return { name: `${base}.${res.psb ? "psb" : "psd"}`, bytes: res.bytes };
9052
9811
  }
@@ -9094,7 +9853,7 @@ function exportPsd(input) {
9094
9853
  const key = layer.type === "group" ? "lfxs" : "lfx2";
9095
9854
  if (fx.psd) {
9096
9855
  const original = parseLfx2(fx.psd.data);
9097
- if (original ? _chunkAZTZRLDIcjs.effectsFingerprint.call(void 0, original.effects) === _chunkAZTZRLDIcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
9856
+ 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) };
9098
9857
  }
9099
9858
  if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
9100
9859
  const { data, dropped } = writeLfx2(fx);
@@ -9111,7 +9870,7 @@ function exportPsd(input) {
9111
9870
  return {
9112
9871
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
9113
9872
  clipping: layer.clipped ? 1 : 0,
9114
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _176 => _176.locks, 'optionalAccess', _177 => _177.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
9873
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _219 => _219.locks, 'optionalAccess', _220 => _220.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
9115
9874
  legacyName: name,
9116
9875
  blocks
9117
9876
  };
@@ -9168,16 +9927,16 @@ function exportPsd(input) {
9168
9927
  }
9169
9928
  case "pixel": {
9170
9929
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
9171
- if (_optionalChain([layer, 'access', _178 => _178.filters, 'optionalAccess', _179 => _179.some, 'call', _180 => _180(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
9930
+ if (_optionalChain([layer, 'access', _221 => _221.filters, 'optionalAccess', _222 => _222.some, 'call', _223 => _223(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
9172
9931
  const extra = [];
9173
9932
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
9174
9933
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
9175
9934
  }
9176
9935
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
9177
- const bounds = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, layer.surface);
9936
+ const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
9178
9937
  if (bounds) {
9179
9938
  const n2 = bounds.width * bounds.height;
9180
- const [r2, g2, b2, a2] = rgbaToPlanes(_chunkSZ6KMZNMcjs.readRegion.call(void 0, layer.surface, bounds), n2);
9939
+ const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
9181
9940
  rec.rect = toRect({ ...bounds, x: bounds.x + layer.offset.x, y: bounds.y + layer.offset.y });
9182
9941
  rec.channels = [
9183
9942
  rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
@@ -9207,7 +9966,7 @@ function exportPsd(input) {
9207
9966
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
9208
9967
  linkedFiles.set(idnt, smartContentsFile(c));
9209
9968
  }
9210
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _181 => _181.psd, 'optionalAccess', _182 => _182.placed]), () => ( psdUuid(`${layer.id}:placed`)));
9969
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _224 => _224.psd, 'optionalAccess', _225 => _225.placed]), () => ( psdUuid(`${layer.id}:placed`)));
9211
9970
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
9212
9971
  placedIds.add(placedId);
9213
9972
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -9217,18 +9976,18 @@ function exportPsd(input) {
9217
9976
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
9218
9977
  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);
9219
9978
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
9220
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _183 => _183.descriptor]) };
9979
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _226 => _226.descriptor]) };
9221
9980
  const wnotes = [];
9222
9981
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
9223
9982
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
9224
9983
  }
9225
- const fm = _optionalChain([layer, 'access', _184 => _184.smartFilters, 'optionalAccess', _185 => _185.mask]);
9984
+ const fm = _optionalChain([layer, 'access', _227 => _227.smartFilters, 'optionalAccess', _228 => _228.mask]);
9226
9985
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
9227
9986
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
9228
- const bounds = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, layer.surface);
9987
+ const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
9229
9988
  if (bounds) {
9230
9989
  const n2 = bounds.width * bounds.height;
9231
- const [r2, g2, b2, a2] = rgbaToPlanes(_chunkSZ6KMZNMcjs.readRegion.call(void 0, layer.surface, bounds), n2);
9990
+ const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
9232
9991
  rec.rect = toRect(bounds);
9233
9992
  rec.channels = [
9234
9993
  rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
@@ -9290,7 +10049,7 @@ function exportPsd(input) {
9290
10049
  const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
9291
10050
  const embed = [];
9292
10051
  for (const id of patternIds2) {
9293
- const p = _nullishCoalesce(byId.get(id), () => ( _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)));
10052
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
9294
10053
  if (p) embed.push(p);
9295
10054
  else note(`Pattern "${id}" is not in the document and was not embedded`, id);
9296
10055
  }
@@ -9653,5 +10412,40 @@ function exportPsd(input) {
9653
10412
 
9654
10413
 
9655
10414
 
9656
- 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.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.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.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; 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.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;
9657
- //# sourceMappingURL=chunk-D37BX2ZA.cjs.map
10415
+
10416
+
10417
+
10418
+
10419
+
10420
+
10421
+
10422
+
10423
+
10424
+
10425
+
10426
+
10427
+
10428
+
10429
+
10430
+
10431
+
10432
+
10433
+
10434
+
10435
+
10436
+
10437
+
10438
+
10439
+
10440
+
10441
+
10442
+
10443
+
10444
+
10445
+
10446
+
10447
+
10448
+
10449
+
10450
+ 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.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; 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.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;
10451
+ //# sourceMappingURL=chunk-PHUMLSCW.cjs.map