@pixerate/editor 0.96.0 → 0.98.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 (52) hide show
  1. package/THIRD_PARTY_NOTICES.md +4 -2
  2. package/dist/animation-editor/index.cjs +55 -53
  3. package/dist/animation-editor/index.cjs.map +1 -1
  4. package/dist/animation-editor/index.d.cts +3 -2
  5. package/dist/animation-editor/index.d.ts +3 -2
  6. package/dist/animation-editor/index.js +11 -9
  7. package/dist/animation-editor/index.js.map +1 -1
  8. package/dist/chunk-DWGZUSES.cjs +694 -0
  9. package/dist/chunk-DWGZUSES.cjs.map +1 -0
  10. package/dist/chunk-GX332W2C.js +181 -0
  11. package/dist/chunk-GX332W2C.js.map +1 -0
  12. package/dist/{chunk-7MD7C6XQ.cjs → chunk-JF5PXN7W.cjs} +96 -744
  13. package/dist/chunk-JF5PXN7W.cjs.map +1 -0
  14. package/dist/chunk-KKREERP2.js +694 -0
  15. package/dist/chunk-KKREERP2.js.map +1 -0
  16. package/dist/chunk-MUUXNRU4.cjs +181 -0
  17. package/dist/chunk-MUUXNRU4.cjs.map +1 -0
  18. package/dist/{chunk-KFTQ2PKP.js → chunk-WIR377F6.js} +1001 -61
  19. package/dist/chunk-WIR377F6.js.map +1 -0
  20. package/dist/{chunk-T422YCHR.cjs → chunk-WT6ZAWJP.cjs} +1023 -83
  21. package/dist/chunk-WT6ZAWJP.cjs.map +1 -0
  22. package/dist/{chunk-4JLB2USO.js → chunk-YGZNGDIT.js} +45 -693
  23. package/dist/chunk-YGZNGDIT.js.map +1 -0
  24. package/dist/image-editor/index.cjs +1519 -360
  25. package/dist/image-editor/index.cjs.map +1 -1
  26. package/dist/image-editor/index.d.cts +378 -5
  27. package/dist/image-editor/index.d.ts +378 -5
  28. package/dist/image-editor/index.js +1244 -85
  29. package/dist/image-editor/index.js.map +1 -1
  30. package/dist/raster/index.cjs +25 -2
  31. package/dist/raster/index.cjs.map +1 -1
  32. package/dist/raster/index.d.cts +143 -4
  33. package/dist/raster/index.d.ts +143 -4
  34. package/dist/raster/index.js +25 -2
  35. package/dist/{svg-ymShkNtu.d.cts → svg-C9r284x8.d.cts} +6 -9
  36. package/dist/{svg-Dh17jCyA.d.ts → svg-MVKBqwD4.d.ts} +6 -9
  37. package/dist/types-CwMPoRMU.d.cts +40 -0
  38. package/dist/types-CwMPoRMU.d.ts +40 -0
  39. package/dist/vector/index.cjs +490 -554
  40. package/dist/vector/index.cjs.map +1 -1
  41. package/dist/vector/index.d.cts +154 -292
  42. package/dist/vector/index.d.ts +154 -292
  43. package/dist/vector/index.js +91 -155
  44. package/dist/vector/index.js.map +1 -1
  45. package/dist/warp-B8rAguzs.d.ts +165 -0
  46. package/dist/warp-nYs2DPrx.d.cts +165 -0
  47. package/package.json +1 -1
  48. package/skills/pixerate-image-editor/SKILL.md +49 -3
  49. package/dist/chunk-4JLB2USO.js.map +0 -1
  50. package/dist/chunk-7MD7C6XQ.cjs.map +0 -1
  51. package/dist/chunk-KFTQ2PKP.js.map +0 -1
  52. package/dist/chunk-T422YCHR.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;
2
2
 
3
3
  var _chunkD6FH2YAXcjs = require('../chunk-D6FH2YAX.cjs');
4
4
 
@@ -58,7 +58,28 @@ var _chunkVJUVNERTcjs = require('../chunk-VJUVNERT.cjs');
58
58
 
59
59
 
60
60
 
61
- var _chunkT422YCHRcjs = require('../chunk-T422YCHR.cjs');
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+ var _chunkWT6ZAWJPcjs = require('../chunk-WT6ZAWJP.cjs');
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+ var _chunkMUUXNRU4cjs = require('../chunk-MUUXNRU4.cjs');
62
83
 
63
84
 
64
85
 
@@ -137,6 +158,28 @@ var _chunkZZOTHJ4Kcjs = require('../chunk-ZZOTHJ4K.cjs');
137
158
 
138
159
  var _chunkCRMAXIUVcjs = require('../chunk-CRMAXIUV.cjs');
139
160
 
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ var _chunkDWGZUSEScjs = require('../chunk-DWGZUSES.cjs');
182
+
140
183
  // src/image-editor/color.ts
141
184
  var LEGACY_PROCESS_VERSION = 1;
142
185
  var LATEST_PROCESS_VERSION = 2;
@@ -557,20 +600,20 @@ function hitTestCrop(canvasPt, state, vpWidth, vpHeight, handleThreshold = 14, c
557
600
  }
558
601
  function hitTestCropRect(canvasPt, rect, handleThreshold) {
559
602
  const { x, y, width: w, height: h } = rect;
560
- const px = canvasPt.x;
603
+ const px2 = canvasPt.x;
561
604
  const py = canvasPt.y;
562
605
  const dist = (x1, y1, x2, y2) => Math.hypot(x1 - x2, y1 - y2);
563
- if (dist(px, py, x, y) <= handleThreshold) return "nw";
564
- if (dist(px, py, x + w, y) <= handleThreshold) return "ne";
565
- if (dist(px, py, x + w, y + h) <= handleThreshold) return "se";
566
- if (dist(px, py, x, y + h) <= handleThreshold) return "sw";
567
- const nearX = px >= x - handleThreshold && px <= x + w + handleThreshold;
606
+ if (dist(px2, py, x, y) <= handleThreshold) return "nw";
607
+ if (dist(px2, py, x + w, y) <= handleThreshold) return "ne";
608
+ if (dist(px2, py, x + w, y + h) <= handleThreshold) return "se";
609
+ if (dist(px2, py, x, y + h) <= handleThreshold) return "sw";
610
+ const nearX = px2 >= x - handleThreshold && px2 <= x + w + handleThreshold;
568
611
  const nearY = py >= y - handleThreshold && py <= y + h + handleThreshold;
569
612
  if (nearX && Math.abs(py - y) <= handleThreshold) return "n";
570
613
  if (nearX && Math.abs(py - (y + h)) <= handleThreshold) return "s";
571
- if (nearY && Math.abs(px - x) <= handleThreshold) return "w";
572
- if (nearY && Math.abs(px - (x + w)) <= handleThreshold) return "e";
573
- if (px >= x && px <= x + w && py >= y && py <= y + h) {
614
+ if (nearY && Math.abs(px2 - x) <= handleThreshold) return "w";
615
+ if (nearY && Math.abs(px2 - (x + w)) <= handleThreshold) return "e";
616
+ if (px2 >= x && px2 <= x + w && py >= y && py <= y + h) {
574
617
  return "inside";
575
618
  }
576
619
  return null;
@@ -1147,7 +1190,7 @@ function smoothCoverage(m, w, h, r) {
1147
1190
  return src;
1148
1191
  }
1149
1192
  function featherCoverage(m, w, h, radius) {
1150
- const out = _chunkT422YCHRcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1193
+ const out = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1151
1194
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1152
1195
  return out;
1153
1196
  }
@@ -1295,7 +1338,7 @@ function layerMaskCoverage(mask) {
1295
1338
  let v = new Float32Array(sel.data.length);
1296
1339
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1297
1340
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1298
- if (feather > 0) v = _chunkT422YCHRcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1341
+ if (feather > 0) v = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1299
1342
  const density = _nullishCoalesce(mask.density, () => ( 1));
1300
1343
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1301
1344
  return v;
@@ -1538,7 +1581,7 @@ function normalizeAdjustmentLayers(raw) {
1538
1581
  return out;
1539
1582
  }
1540
1583
  function curveLutFromLevels(points) {
1541
- return _chunkT422YCHRcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1584
+ return _chunkWT6ZAWJPcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1542
1585
  }
1543
1586
  var toUnitLevels = (c) => ({
1544
1587
  inBlack: c.inBlack / 255,
@@ -1598,13 +1641,13 @@ function hslToRgb(h, s, l) {
1598
1641
  };
1599
1642
  return [f(h + 1 / 3), f(h), f(h - 1 / 3)];
1600
1643
  }
1601
- function hueRangeWeight(range, deg) {
1644
+ function hueRangeWeight(range, deg2) {
1602
1645
  const [a, b0, c0, d0] = range.bounds;
1603
1646
  const rel = (x) => Number.isFinite(x) && Number.isFinite(a) ? remEuclid(x - a, 360) : 0;
1604
1647
  const b = rel(b0);
1605
1648
  const c = Math.max(rel(c0), b);
1606
1649
  const d = Math.max(rel(d0), c);
1607
- const h = rel(deg);
1650
+ const h = rel(deg2);
1608
1651
  if (h <= b) return b <= 0 ? 1 : h / b;
1609
1652
  if (h <= c) return 1;
1610
1653
  if (h <= d) return d <= c ? 1 : (d - h) / (d - c);
@@ -1616,9 +1659,9 @@ function hueRangeTables(ranges) {
1616
1659
  const t = [new Float32Array(n), new Float32Array(n), new Float32Array(n)];
1617
1660
  const active = ranges.filter((r) => !isNeutralRange(r));
1618
1661
  for (let k = 0; k < n; k++) {
1619
- const deg = k / (n - 1) * 360;
1662
+ const deg2 = k / (n - 1) * 360;
1620
1663
  for (const r of active) {
1621
- const w = hueRangeWeight(r, deg);
1664
+ const w = hueRangeWeight(r, deg2);
1622
1665
  t[0][k] += w * r.hue;
1623
1666
  t[1][k] += w * r.saturation / 100;
1624
1667
  t[2][k] += w * r.lightness / 100;
@@ -2181,8 +2224,8 @@ function applyFastBoxBlur(imageData, radius) {
2181
2224
  let r = 0, g = 0, b = 0, a = 0;
2182
2225
  let count = 0;
2183
2226
  for (let k = -radius; k <= radius; k++) {
2184
- const px = Math.min(w - 1, Math.max(0, x + k));
2185
- const idx = (y * w + px) * 4;
2227
+ const px2 = Math.min(w - 1, Math.max(0, x + k));
2228
+ const idx = (y * w + px2) * 4;
2186
2229
  r += src[idx];
2187
2230
  g += src[idx + 1];
2188
2231
  b += src[idx + 2];
@@ -2364,7 +2407,7 @@ function newLayerId(prefix = "layer") {
2364
2407
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2365
2408
  }
2366
2409
  function pixelLayers(layers) {
2367
- return _chunkT422YCHRcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2410
+ return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2368
2411
  }
2369
2412
  function developFilter(layer) {
2370
2413
  return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
@@ -2485,7 +2528,7 @@ var PHOTO_PROFILE = {
2485
2528
  return v;
2486
2529
  }
2487
2530
  };
2488
- var LayerCompositor = class extends _chunkT422YCHRcjs.RasterCompositor {
2531
+ var LayerCompositor = class extends _chunkWT6ZAWJPcjs.RasterCompositor {
2489
2532
  constructor(options = {}) {
2490
2533
  super(PHOTO_PROFILE, options);
2491
2534
  }
@@ -3137,13 +3180,13 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3137
3180
  ctx.save();
3138
3181
  try {
3139
3182
  applyImageProjectionToContext(ctx, projection);
3140
- const px = 1 / (projection.scale || 1);
3183
+ const px2 = 1 / (projection.scale || 1);
3141
3184
  ctx.beginPath();
3142
- ctx.arc(b.x, b.y, Math.max(px, b.diameter / 2), 0, Math.PI * 2);
3143
- ctx.lineWidth = 2 * px;
3185
+ ctx.arc(b.x, b.y, Math.max(px2, b.diameter / 2), 0, Math.PI * 2);
3186
+ ctx.lineWidth = 2 * px2;
3144
3187
  ctx.strokeStyle = "rgba(0,0,0,0.6)";
3145
3188
  ctx.stroke();
3146
- ctx.lineWidth = px;
3189
+ ctx.lineWidth = px2;
3147
3190
  ctx.strokeStyle = "#ffffff";
3148
3191
  ctx.stroke();
3149
3192
  } catch (e5) {
@@ -3262,7 +3305,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3262
3305
  /** Loads what the compositor reads synchronously: depth maps (at canvas size) and annotation images. */
3263
3306
  /** Loads depth maps and annotation images the compositor reads synchronously. */
3264
3307
  async prepareLayerAssets(layers, width, height) {
3265
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) {
3308
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
3266
3309
  const source = _optionalChain([l, 'access', _57 => _57.mask, 'optionalAccess', _58 => _58.source]);
3267
3310
  if (_optionalChain([source, 'optionalAccess', _59 => _59.enabled]) && source.maskSource) {
3268
3311
  const key = `${source.maskSource}|${width}x${height}`;
@@ -3426,32 +3469,32 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3426
3469
  this.outlineCache.set(selection, segs);
3427
3470
  }
3428
3471
  if (!segs.length) return;
3429
- const px = 1 / (scale || 1);
3472
+ const px2 = 1 / (scale || 1);
3430
3473
  ctx.beginPath();
3431
3474
  for (let i = 0; i < segs.length; i += 4) {
3432
3475
  ctx.moveTo(segs[i], segs[i + 1]);
3433
3476
  ctx.lineTo(segs[i + 2], segs[i + 3]);
3434
3477
  }
3435
- ctx.lineWidth = px;
3478
+ ctx.lineWidth = px2;
3436
3479
  ctx.strokeStyle = "#ffffff";
3437
3480
  ctx.stroke();
3438
3481
  if (typeof ctx.setLineDash === "function") {
3439
- ctx.setLineDash([4 * px, 4 * px]);
3440
- ctx.lineDashOffset = -offset * px;
3482
+ ctx.setLineDash([4 * px2, 4 * px2]);
3483
+ ctx.lineDashOffset = -offset * px2;
3441
3484
  }
3442
3485
  ctx.strokeStyle = "#000000";
3443
3486
  ctx.stroke();
3444
3487
  if (typeof ctx.setLineDash === "function") ctx.setLineDash([]);
3445
3488
  }
3446
3489
  drawDraftPath(ctx, points, scale) {
3447
- const px = 1 / (scale || 1);
3490
+ const px2 = 1 / (scale || 1);
3448
3491
  ctx.beginPath();
3449
3492
  points.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
3450
3493
  ctx.closePath();
3451
- ctx.lineWidth = px;
3494
+ ctx.lineWidth = px2;
3452
3495
  ctx.strokeStyle = "#ffffff";
3453
3496
  ctx.stroke();
3454
- if (typeof ctx.setLineDash === "function") ctx.setLineDash([4 * px, 4 * px]);
3497
+ if (typeof ctx.setLineDash === "function") ctx.setLineDash([4 * px2, 4 * px2]);
3455
3498
  ctx.strokeStyle = "#000000";
3456
3499
  ctx.stroke();
3457
3500
  if (typeof ctx.setLineDash === "function") ctx.setLineDash([]);
@@ -4297,8 +4340,8 @@ var gfRadius = (p) => Math.min(64, Math.max(1, Math.ceil(p.radius)));
4297
4340
  var smoothSigma = (p) => p.smooth / 100 * 4;
4298
4341
  var featherSigma = (p) => p.feather / 2;
4299
4342
  function shiftAmount(p) {
4300
- const px = p.shiftEdge / 100 * Math.max(p.radius, 4);
4301
- return Number.isFinite(px) ? Math.min(64, Math.max(-64, px)) : 0;
4343
+ const px2 = p.shiftEdge / 100 * Math.max(p.radius, 4);
4344
+ return Number.isFinite(px2) ? Math.min(64, Math.max(-64, px2)) : 0;
4302
4345
  }
4303
4346
  function refineEdgeHalo(params = {}) {
4304
4347
  const p = normalizeRefineEdgeParams(params);
@@ -4445,11 +4488,11 @@ function refineCoverage(guide, m, w, h, params = {}) {
4445
4488
  }
4446
4489
  const ss = smoothSigma(p);
4447
4490
  if (ss >= 0.3) {
4448
- a = _chunkT422YCHRcjs.gaussianBlur.call(void 0, a, w, h, ss, "clamp");
4491
+ a = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, a, w, h, ss, "clamp");
4449
4492
  const gain = 1 + ss;
4450
4493
  for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
4451
4494
  }
4452
- a = _chunkT422YCHRcjs.gaussianBlur.call(void 0, a, w, h, featherSigma(p), "clamp");
4495
+ a = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, a, w, h, featherSigma(p), "clamp");
4453
4496
  if (p.contrast > 0) {
4454
4497
  const gain = 1 / (1 - 0.99 * p.contrast / 100);
4455
4498
  for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
@@ -4507,7 +4550,7 @@ function refineSelection(pixels, mask, params = {}) {
4507
4550
  // src/image-editor/layers/serialize.ts
4508
4551
  var LAYERED_SCHEMA_VERSION = 3;
4509
4552
  function serializePatterns(patterns) {
4510
- return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkT422YCHRcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
4553
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkWT6ZAWJPcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
4511
4554
  }
4512
4555
  function deserializePatterns(raw, problems = []) {
4513
4556
  if (!Array.isArray(raw)) return [];
@@ -4530,7 +4573,7 @@ function encodeSurface(surface) {
4530
4573
  let out = null;
4531
4574
  if (b) {
4532
4575
  const data = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, b);
4533
- out = { url: _chunkT422YCHRcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4576
+ out = { url: _chunkWT6ZAWJPcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4534
4577
  }
4535
4578
  encodedCache.set(surface, out);
4536
4579
  return out;
@@ -4552,7 +4595,7 @@ function baseFields(layer, ctx) {
4552
4595
  function serializeEffects(effects) {
4553
4596
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
4554
4597
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
4555
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkT422YCHRcjs.bytesToBase64.call(void 0, effects.psd.data) };
4598
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, effects.psd.data) };
4556
4599
  return out;
4557
4600
  }
4558
4601
  function deserializeEffects(raw) {
@@ -4562,12 +4605,12 @@ function deserializeEffects(raw) {
4562
4605
  const p = r.psd;
4563
4606
  if (p && typeof p.key === "string" && typeof p.data === "string") {
4564
4607
  try {
4565
- psd = { key: p.key, data: _chunkT422YCHRcjs.base64ToBytes.call(void 0, p.data) };
4608
+ psd = { key: p.key, data: _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, p.data) };
4566
4609
  } catch (e12) {
4567
4610
  psd = void 0;
4568
4611
  }
4569
4612
  }
4570
- return _chunkT422YCHRcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
4613
+ return _chunkWT6ZAWJPcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
4571
4614
  }
4572
4615
  function serializeMask(mask, hint, ctx) {
4573
4616
  const out = { defaultValue: mask.defaultValue };
@@ -4584,6 +4627,7 @@ function serializeMask(mask, hint, ctx) {
4584
4627
  if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
4585
4628
  if (mask.feather) out.feather = mask.feather;
4586
4629
  if (mask.enabled === false) out.enabled = false;
4630
+ if (mask.linked === false) out.linked = false;
4587
4631
  return out;
4588
4632
  }
4589
4633
  function serializeLayer(layer, ctx) {
@@ -4639,7 +4683,7 @@ async function serializeLayersExternal(layers, store) {
4639
4683
  for (const [id, url] of Object.entries(inline.assets)) {
4640
4684
  let ref = refs.get(url);
4641
4685
  if (!ref) {
4642
- const parsed = _chunkT422YCHRcjs.parseDataUrl.call(void 0, url);
4686
+ const parsed = _chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, url);
4643
4687
  const png = decodePngHeader(parsed.bytes);
4644
4688
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
4645
4689
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -4667,7 +4711,7 @@ async function resolveExternalAssets(assets, store, problems) {
4667
4711
  try {
4668
4712
  const blob = await store.get(ref);
4669
4713
  const bytes = new Uint8Array(await blob.arrayBuffer());
4670
- out[id] = `data:image/png;base64,${_chunkT422YCHRcjs.bytesToBase64.call(void 0, bytes)}`;
4714
+ out[id] = `data:image/png;base64,${_chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, bytes)}`;
4671
4715
  } catch (err) {
4672
4716
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
4673
4717
  }
@@ -4675,9 +4719,9 @@ async function resolveExternalAssets(assets, store, problems) {
4675
4719
  return out;
4676
4720
  }
4677
4721
  function decodePngDataUrl(url, channels) {
4678
- const parsed = _chunkT422YCHRcjs.parseDataUrl.call(void 0, url);
4722
+ const parsed = _chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, url);
4679
4723
  if (!parsed) throw new Error("Asset is not a data URL.");
4680
- const png = _chunkT422YCHRcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
4724
+ const png = _chunkWT6ZAWJPcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
4681
4725
  if (png.channels === channels) return png;
4682
4726
  if (channels === 1) {
4683
4727
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -4702,8 +4746,8 @@ function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
4702
4746
  return _chunkCRMAXIUVcjs.emptySurface.call(void 0, channels, defaultValue);
4703
4747
  }
4704
4748
  try {
4705
- const px = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
4706
- return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
4749
+ const px2 = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
4750
+ return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
4707
4751
  } catch (err) {
4708
4752
  ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
4709
4753
  return _chunkCRMAXIUVcjs.emptySurface.call(void 0, channels, defaultValue);
@@ -4720,6 +4764,7 @@ function readMask(raw, ctx, what) {
4720
4764
  if (typeof r.density === "number" && r.density !== 1) mask.density = num(r.density, 0, 1, 1);
4721
4765
  if (typeof r.feather === "number" && r.feather > 0) mask.feather = num(r.feather, 0, 1e3, 0);
4722
4766
  if (r.enabled === false) mask.enabled = false;
4767
+ if (r.linked === false) mask.linked = false;
4723
4768
  if (r.source && typeof r.source === "object") {
4724
4769
  const s = { ...DEFAULT_DEPTH_MASK_VALUES, ...r.source };
4725
4770
  mask.source = { ...s, depthRange: [...s.depthRange] };
@@ -4839,47 +4884,47 @@ var fail = (message) => {
4839
4884
  throw new LayerOperationError(message);
4840
4885
  };
4841
4886
  function requireLayer(layers, id) {
4842
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, layers, id);
4887
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, id);
4843
4888
  if (!loc) {
4844
- const ids = _chunkT422YCHRcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
4889
+ const ids = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
4845
4890
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
4846
4891
  }
4847
4892
  return loc;
4848
4893
  }
4849
4894
  function requireUnlocked(layer, what, action) {
4850
- if (_chunkT422YCHRcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
4851
- if (what !== "all" && _chunkT422YCHRcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
4895
+ if (_chunkWT6ZAWJPcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
4896
+ if (what !== "all" && _chunkWT6ZAWJPcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
4852
4897
  }
4853
4898
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
4854
4899
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
4855
4900
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
4856
4901
  if (placement.aboveId || placement.belowId) {
4857
4902
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
4858
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _79 => _79.parent, 'optionalAccess', _80 => _80.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
4903
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _79 => _79.parent, 'optionalAccess', _80 => _80.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
4859
4904
  }
4860
4905
  if (placement.parentId) {
4861
4906
  const ref = requireLayer(layers, placement.parentId);
4862
4907
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
4863
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
4908
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
4864
4909
  }
4865
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
4910
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
4866
4911
  }
4867
4912
  function removeLayer(layers, id) {
4868
4913
  const loc = requireLayer(layers, id);
4869
4914
  requireUnlocked(loc.layer, "all", "delete it");
4870
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => null);
4915
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
4871
4916
  }
4872
4917
  function moveLayer(layers, id, placement) {
4873
4918
  const loc = requireLayer(layers, id);
4874
4919
  requireUnlocked(loc.layer, "all", "move it");
4875
4920
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
4876
4921
  if (target === id) fail("A layer cannot be placed relative to itself.");
4877
- if (target && loc.layer.type === "group" && _chunkT422YCHRcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
4922
+ if (target && loc.layer.type === "group" && _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
4878
4923
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
4879
4924
  }
4880
4925
  if (target) requireLayer(layers, target);
4881
4926
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
4882
- const without = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => null);
4927
+ const without = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
4883
4928
  return placeLayer(without, loc.layer, placement);
4884
4929
  }
4885
4930
  function withNewIds(layer) {
@@ -4893,7 +4938,7 @@ function duplicateLayer(layers, id, name) {
4893
4938
  const copy = withNewIds(loc.layer);
4894
4939
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
4895
4940
  delete copy.locks;
4896
- return { layers: _chunkT422YCHRcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.id]), () => ( null)), loc.index + 1), id: copy.id };
4941
+ return { layers: _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.id]), () => ( null)), loc.index + 1), id: copy.id };
4897
4942
  }
4898
4943
  function setLayerProperties(layers, id, props) {
4899
4944
  const loc = requireLayer(layers, id);
@@ -4940,7 +4985,7 @@ function setLayerProperties(layers, id, props) {
4940
4985
  if (props.collapsed) g.collapsed = true;
4941
4986
  else delete g.collapsed;
4942
4987
  }
4943
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => next);
4988
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
4944
4989
  }
4945
4990
  function groupLayers(layers, ids, name = "Group") {
4946
4991
  if (!ids.length) fail("Give at least one layer id to group.");
@@ -4969,17 +5014,17 @@ function groupLayers(layers, ids, name = "Group") {
4969
5014
  group.children[0] = c;
4970
5015
  }
4971
5016
  let out = layers;
4972
- for (const l of ordered) out = _chunkT422YCHRcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
4973
- return { layers: _chunkT422YCHRcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
5017
+ for (const l of ordered) out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5018
+ return { layers: _chunkWT6ZAWJPcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
4974
5019
  }
4975
5020
  function ungroupLayer(layers, id) {
4976
5021
  const loc = requireLayer(layers, id);
4977
5022
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
4978
5023
  requireUnlocked(loc.layer, "all", "ungroup it");
4979
5024
  const group = loc.layer;
4980
- let out = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => null);
5025
+ let out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
4981
5026
  group.children.forEach((c, i) => {
4982
- out = _chunkT422YCHRcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _91 => _91.parent, 'optionalAccess', _92 => _92.id]), () => ( null)), loc.index + i);
5027
+ out = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _91 => _91.parent, 'optionalAccess', _92 => _92.id]), () => ( null)), loc.index + i);
4983
5028
  });
4984
5029
  return { layers: out, ids: group.children.map((c) => c.id) };
4985
5030
  }
@@ -4989,12 +5034,17 @@ function offsetLayer(layers, id, offset) {
4989
5034
  requireUnlocked(loc.layer, "position", "move it");
4990
5035
  if (!Number.isFinite(offset.x) || !Number.isFinite(offset.y)) fail("x and y must be numbers.");
4991
5036
  const layer = loc.layer;
4992
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } }));
5037
+ const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
5038
+ const mask = layer.mask;
5039
+ if (mask && mask.linked === false && !mask.source) {
5040
+ next.mask = { ...mask, surface: _chunkCRMAXIUVcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
5041
+ }
5042
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
4993
5043
  }
4994
5044
  function setLayerMask(layers, id, mask) {
4995
5045
  const loc = requireLayer(layers, id);
4996
5046
  requireUnlocked(loc.layer, "all", "change its mask");
4997
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, (l) => {
5047
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, (l) => {
4998
5048
  const next = { ...l };
4999
5049
  if (mask) next.mask = mask;
5000
5050
  else delete next.mask;
@@ -5033,7 +5083,7 @@ function requirePixelLayer(layers, id) {
5033
5083
  function addLayerFilter(layers, id, filter) {
5034
5084
  const layer = requirePixelLayer(layers, id);
5035
5085
  if (_optionalChain([layer, 'access', _93 => _93.filters, 'optionalAccess', _94 => _94.some, 'call', _95 => _95((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
5036
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
5086
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
5037
5087
  }
5038
5088
  function updateLayerFilter(layers, id, filterId, changes) {
5039
5089
  const layer = requirePixelLayer(layers, id);
@@ -5044,7 +5094,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
5044
5094
  const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
5045
5095
  const filters = [...layer.filters];
5046
5096
  filters[i] = merged;
5047
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
5097
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
5048
5098
  }
5049
5099
  function removeLayerFilter(layers, id, filterId) {
5050
5100
  const layer = requirePixelLayer(layers, id);
@@ -5053,7 +5103,7 @@ function removeLayerFilter(layers, id, filterId) {
5053
5103
  const next = { ...layer };
5054
5104
  if (filters.length) next.filters = filters;
5055
5105
  else delete next.filters;
5056
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => next);
5106
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
5057
5107
  }
5058
5108
  function requireEffectLayer(layers, id, action) {
5059
5109
  const layer = requireLayer(layers, id).layer;
@@ -5068,7 +5118,7 @@ function guard(fn) {
5068
5118
  try {
5069
5119
  return fn();
5070
5120
  } catch (e) {
5071
- if (e instanceof _chunkT422YCHRcjs.LayerEffectError) fail(e.message);
5121
+ if (e instanceof _chunkWT6ZAWJPcjs.LayerEffectError) fail(e.message);
5072
5122
  throw e;
5073
5123
  }
5074
5124
  }
@@ -5076,20 +5126,20 @@ function setLayerEffects(layers, id, effects) {
5076
5126
  const layer = requireEffectLayer(layers, id, "change its effects");
5077
5127
  const next = { ...layer };
5078
5128
  if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
5079
- guard(() => _chunkT422YCHRcjs.validateLayerEffects.call(void 0, effects));
5129
+ guard(() => _chunkWT6ZAWJPcjs.validateLayerEffects.call(void 0, effects));
5080
5130
  next.effects = effects;
5081
5131
  } else delete next.effects;
5082
- return _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => next);
5132
+ return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
5083
5133
  }
5084
5134
  function addLayerEffect(layers, id, kind, params = {}, index) {
5085
- if (!_chunkT422YCHRcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkT422YCHRcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
5135
+ if (!_chunkWT6ZAWJPcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
5086
5136
  const layer = requireEffectLayer(layers, id, "add effects");
5087
5137
  const current = layerEffectsOf(layer);
5088
5138
  const ids = new Set(current.items.map((e) => e.id));
5089
- let effectId = _chunkT422YCHRcjs.newEffectId.call(void 0, );
5090
- while (ids.has(effectId)) effectId = _chunkT422YCHRcjs.newEffectId.call(void 0, );
5139
+ let effectId = _chunkWT6ZAWJPcjs.newEffectId.call(void 0, );
5140
+ while (ids.has(effectId)) effectId = _chunkWT6ZAWJPcjs.newEffectId.call(void 0, );
5091
5141
  const { id: _ignored, kind: _kind, ...rest } = params;
5092
- const effect = guard(() => _chunkT422YCHRcjs.mergeLayerEffect.call(void 0, _chunkT422YCHRcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
5142
+ const effect = guard(() => _chunkWT6ZAWJPcjs.mergeLayerEffect.call(void 0, _chunkWT6ZAWJPcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
5093
5143
  const items = [...current.items];
5094
5144
  const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
5095
5145
  items.splice(at, 0, effect);
@@ -5106,7 +5156,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
5106
5156
  const i = requireEffect(layer, effectId);
5107
5157
  const current = layer.effects;
5108
5158
  const items = [...current.items];
5109
- items[i] = guard(() => _chunkT422YCHRcjs.mergeLayerEffect.call(void 0, items[i], changes));
5159
+ items[i] = guard(() => _chunkWT6ZAWJPcjs.mergeLayerEffect.call(void 0, items[i], changes));
5110
5160
  return setLayerEffects(layers, id, { ...current, items });
5111
5161
  }
5112
5162
  function removeLayerEffect(layers, id, effectId) {
@@ -6041,9 +6091,9 @@ function packbitsDecodeInto(src, expected, out, at) {
6041
6091
  function inflateChecked(data, expected) {
6042
6092
  let out;
6043
6093
  try {
6044
- out = _chunkT422YCHRcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
6094
+ out = _chunkWT6ZAWJPcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
6045
6095
  } catch (e) {
6046
- throw new PsdError(`ZIP channel data: ${e instanceof _chunkT422YCHRcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
6096
+ throw new PsdError(`ZIP channel data: ${e instanceof _chunkWT6ZAWJPcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
6047
6097
  }
6048
6098
  if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
6049
6099
  return out.length === expected ? out : out.subarray(0, expected);
@@ -6175,6 +6225,7 @@ var CHANNEL_USER_MASK = -2;
6175
6225
  var CHANNEL_REAL_USER_MASK = -3;
6176
6226
  var LAYER_FLAG_TRANSPARENCY_PROTECTED = 1;
6177
6227
  var LAYER_FLAG_HIDDEN = 2;
6228
+ var MASK_FLAG_UNLINKED = 1;
6178
6229
  var MASK_FLAG_DISABLED = 2;
6179
6230
  var MASK_FLAG_PARAMETERS = 16;
6180
6231
  var SECTION_OTHER = 0;
@@ -6780,34 +6831,34 @@ function blendOf(d, key, fallback, notes) {
6780
6831
  function colorOf(d, fallback = "#000000") {
6781
6832
  if (!d) return fallback;
6782
6833
  const g = (k) => descNumber(d, k);
6783
- if (g("redFloat") !== void 0) return _chunkT422YCHRcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
6834
+ if (g("redFloat") !== void 0) return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
6784
6835
  switch (d.classId) {
6785
6836
  case "HSBC": {
6786
6837
  const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
6787
- return rgb ? _chunkT422YCHRcjs.effectColorHex.call(void 0, rgb) : fallback;
6838
+ return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
6788
6839
  }
6789
6840
  case "CMYC": {
6790
6841
  const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
6791
6842
  const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
6792
- return rgb ? _chunkT422YCHRcjs.effectColorHex.call(void 0, rgb) : fallback;
6843
+ return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
6793
6844
  }
6794
6845
  case "LbCl": {
6795
6846
  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]);
6796
- return rgb ? _chunkT422YCHRcjs.effectColorHex.call(void 0, rgb) : fallback;
6847
+ return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
6797
6848
  }
6798
6849
  case "Grsc": {
6799
6850
  const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
6800
- return _chunkT422YCHRcjs.effectColorHex.call(void 0, [v, v, v]);
6851
+ return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [v, v, v]);
6801
6852
  }
6802
6853
  }
6803
6854
  const r = g("Rd ");
6804
6855
  const gr = g("Grn ");
6805
6856
  const b = g("Bl ");
6806
6857
  if (r === void 0 || gr === void 0 || b === void 0) return fallback;
6807
- return _chunkT422YCHRcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
6858
+ return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
6808
6859
  }
6809
6860
  function colorDesc(hex) {
6810
- const [r, g, b] = _nullishCoalesce(_chunkT422YCHRcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
6861
+ const [r, g, b] = _nullishCoalesce(_chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
6811
6862
  return descriptor("RGBC", [
6812
6863
  ["Rd ", dbl(r * 255)],
6813
6864
  ["Grn ", dbl(g * 255)],
@@ -6890,9 +6941,9 @@ function gradientOf(d, notes) {
6890
6941
  raw.forEach((s, i) => {
6891
6942
  if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
6892
6943
  const a = raw[i - 1];
6893
- const ca = _chunkT422YCHRcjs.parseEffectColor.call(void 0, a.color);
6894
- const cb = _chunkT422YCHRcjs.parseEffectColor.call(void 0, s.color);
6895
- stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkT422YCHRcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
6944
+ const ca = _chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, a.color);
6945
+ const cb = _chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, s.color);
6946
+ stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
6896
6947
  notes.add("gradient midpoints are drawn as straight segments");
6897
6948
  }
6898
6949
  stops.push({ position: s.position, color: s.color });
@@ -7004,8 +7055,8 @@ var KINDS = [
7004
7055
  ["FrFX", "frameFXMulti", "stroke"]
7005
7056
  ];
7006
7057
  function common(d, kind, notes) {
7007
- const def = _chunkT422YCHRcjs.defaultLayerEffect.call(void 0, kind, "x");
7008
- return { id: _chunkT422YCHRcjs.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) };
7058
+ const def = _chunkWT6ZAWJPcjs.defaultLayerEffect.call(void 0, kind, "x");
7059
+ return { id: _chunkWT6ZAWJPcjs.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) };
7009
7060
  }
7010
7061
  function readOne(kind, d, notes) {
7011
7062
  const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
@@ -7048,7 +7099,7 @@ function readOne(kind, d, notes) {
7048
7099
  case "bevel-emboss": {
7049
7100
  const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
7050
7101
  const out = {
7051
- id: _chunkT422YCHRcjs.newEffectId.call(void 0, ),
7102
+ id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ),
7052
7103
  enabled: descBool(d, "enab") !== false,
7053
7104
  kind,
7054
7105
  style: _nullishCoalesce(styles[_nullishCoalesce(enumOf(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
@@ -7259,10 +7310,10 @@ function writeLfx2(effects) {
7259
7310
  ["Scl ", unit("#Prc", 100)],
7260
7311
  ["masterFXSwitch", boolV(effects.enabled)]
7261
7312
  ];
7262
- const scale = _chunkT422YCHRcjs.effectsScale.call(void 0, effects);
7313
+ const scale = _chunkWT6ZAWJPcjs.effectsScale.call(void 0, effects);
7263
7314
  let dropped = 0;
7264
7315
  for (const [single, multi, kind] of KINDS) {
7265
- const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkT422YCHRcjs.scaleLayerEffect.call(void 0, e, scale)));
7316
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkWT6ZAWJPcjs.scaleLayerEffect.call(void 0, e, scale)));
7266
7317
  if (!of.length) continue;
7267
7318
  if (of.length === 1) items.push([single, obj(of[0])]);
7268
7319
  else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj) }]);
@@ -7294,7 +7345,7 @@ function parseLrfx(data) {
7294
7345
  const colorAt = (rd) => {
7295
7346
  rd.u16();
7296
7347
  const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
7297
- return _chunkT422YCHRcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
7348
+ return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
7298
7349
  };
7299
7350
  const blendAt = (rd) => {
7300
7351
  rd.skip(4);
@@ -7313,7 +7364,7 @@ function parseLrfx(data) {
7313
7364
  const enabled = b.u8() !== 0;
7314
7365
  const useGlobalLight = b.u8() !== 0;
7315
7366
  const opacity = b.u8() / 255;
7316
- const base = { id: _chunkT422YCHRcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
7367
+ const base = { id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
7317
7368
  items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
7318
7369
  } else if (key === "oglw" || key === "iglw") {
7319
7370
  b.u32();
@@ -7323,7 +7374,7 @@ function parseLrfx(data) {
7323
7374
  const blend = blendAt(b);
7324
7375
  const enabled = b.u8() !== 0;
7325
7376
  const opacity = b.u8() / 255;
7326
- const base = { id: _chunkT422YCHRcjs.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 };
7377
+ const base = { id: _chunkWT6ZAWJPcjs.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 };
7327
7378
  items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
7328
7379
  } else if (key === "sofi") {
7329
7380
  b.u32();
@@ -7331,7 +7382,7 @@ function parseLrfx(data) {
7331
7382
  const color = colorAt(b);
7332
7383
  const opacity = b.u8() / 255;
7333
7384
  const enabled = b.u8() !== 0;
7334
- items.push({ id: _chunkT422YCHRcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
7385
+ items.push({ id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
7335
7386
  } else if (key === "bevl") notes.add("legacy bevels are not read");
7336
7387
  }
7337
7388
  return { effects: { enabled: true, items }, notes: [...notes] };
@@ -7604,6 +7655,7 @@ function recordMask(ctx, rec, name) {
7604
7655
  if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
7605
7656
  if (m.userFeather !== void 0 && m.userFeather > 0) mask.feather = Math.min(1e3, m.userFeather);
7606
7657
  if (flags & MASK_FLAG_DISABLED) mask.enabled = false;
7658
+ if (flags & MASK_FLAG_UNLINKED) mask.linked = false;
7607
7659
  return mask;
7608
7660
  }
7609
7661
  function baseProps(ctx, rec, name, notes) {
@@ -7657,7 +7709,7 @@ function recordEffects(ctx, rec, name, notes, group) {
7657
7709
  }
7658
7710
  for (const e of parsed.effects.items) {
7659
7711
  for (const id of patternIds(e)) {
7660
- if (ctx.patterns.has(id) || _chunkT422YCHRcjs.builtinPattern.call(void 0, id)) continue;
7712
+ if (ctx.patterns.has(id) || _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id)) continue;
7661
7713
  ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
7662
7714
  notes.push(`pattern "${id}" is not in the file`);
7663
7715
  }
@@ -7890,7 +7942,8 @@ function maskChannel(mask, ox, oy, psb) {
7890
7942
  if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
7891
7943
  const bounds = _chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface);
7892
7944
  const def = mask.defaultValue;
7893
- const m = { rect: EMPTY_RECT, defaultColor: def, flags: mask.enabled === false ? MASK_FLAG_DISABLED : 0 };
7945
+ const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
7946
+ const m = { rect: EMPTY_RECT, defaultColor: def, flags };
7894
7947
  if ((_nullishCoalesce(mask.density, () => ( 1))) < 1) m.userDensity = Math.round(Math.max(0, _nullishCoalesce(mask.density, () => ( 1))) * 255);
7895
7948
  if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) m.userFeather = mask.feather;
7896
7949
  if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
@@ -7919,7 +7972,7 @@ function exportPsd(input) {
7919
7972
  const key = layer.type === "group" ? "lfxs" : "lfx2";
7920
7973
  if (fx.psd) {
7921
7974
  const original = parseLfx2(fx.psd.data);
7922
- if (original ? _chunkT422YCHRcjs.effectsFingerprint.call(void 0, original.effects) === _chunkT422YCHRcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
7975
+ if (original ? _chunkWT6ZAWJPcjs.effectsFingerprint.call(void 0, original.effects) === _chunkWT6ZAWJPcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
7923
7976
  }
7924
7977
  if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
7925
7978
  const { data, dropped } = writeLfx2(fx);
@@ -8064,7 +8117,7 @@ function exportPsd(input) {
8064
8117
  const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
8065
8118
  const embed = [];
8066
8119
  for (const id of patternIds2) {
8067
- const p = _nullishCoalesce(byId.get(id), () => ( _chunkT422YCHRcjs.builtinPattern.call(void 0, id)));
8120
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id)));
8068
8121
  if (p) embed.push(p);
8069
8122
  else note(`Pattern "${id}" is not in the document and was not embedded`, id);
8070
8123
  }
@@ -8087,6 +8140,499 @@ function exportPsd(input) {
8087
8140
  return { bytes, psb, records: records.length, warnings };
8088
8141
  }
8089
8142
 
8143
+ // src/image-editor/transform.ts
8144
+ var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
8145
+ var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
8146
+ var ANCHOR_FRACTION = {
8147
+ "top-left": [0, 0],
8148
+ top: [0.5, 0],
8149
+ "top-right": [1, 0],
8150
+ left: [0, 0.5],
8151
+ center: [0.5, 0.5],
8152
+ right: [1, 0.5],
8153
+ "bottom-left": [0, 1],
8154
+ bottom: [0.5, 1],
8155
+ "bottom-right": [1, 1]
8156
+ };
8157
+ function isTransformAnchor(value) {
8158
+ return typeof value === "string" && value in ANCHOR_FRACTION;
8159
+ }
8160
+ function identityTransform(box) {
8161
+ return { box: { ...box }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box) };
8162
+ }
8163
+ function cornersFromMatrix(box, m) {
8164
+ const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box);
8165
+ return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
8166
+ }
8167
+ function matrixFromCorners(box, corners, eps = 1e-6) {
8168
+ const [tl, tr, br, bl] = corners;
8169
+ const size = 1 + Math.max(box.width, box.height);
8170
+ if (Math.abs(tl.x + br.x - tr.x - bl.x) > eps * size || Math.abs(tl.y + br.y - tr.y - bl.y) > eps * size) return null;
8171
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box, corners);
8172
+ return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
8173
+ }
8174
+ function transformHomography(geometry) {
8175
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
8176
+ if (!h) return null;
8177
+ return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
8178
+ }
8179
+ function hasWarp(geometry) {
8180
+ const w = geometry.warp;
8181
+ if (!w) return false;
8182
+ const id = _chunkDWGZUSEScjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
8183
+ if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
8184
+ return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
8185
+ }
8186
+ function isIdentityTransform(geometry) {
8187
+ if (hasWarp(geometry)) return false;
8188
+ const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
8189
+ return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
8190
+ }
8191
+ function transformMap(geometry) {
8192
+ const h = transformHomography(geometry);
8193
+ if (!h) return null;
8194
+ const { box } = geometry;
8195
+ const warp = hasWarp(geometry) ? geometry.warp : null;
8196
+ if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
8197
+ return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkDWGZUSEScjs.evalWarpMesh.call(void 0, warp, (p.x - box.x) / box.width, (p.y - box.y) / box.height));
8198
+ }
8199
+ function transformedPoint(geometry, fx, fy) {
8200
+ const f = transformMap(geometry);
8201
+ const { box } = geometry;
8202
+ return f ? f({ x: box.x + fx * box.width, y: box.y + fy * box.height }) : null;
8203
+ }
8204
+ function anchorPoint(geometry, anchor) {
8205
+ const [fx, fy] = ANCHOR_FRACTION[anchor];
8206
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
8207
+ const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
8208
+ return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
8209
+ }
8210
+ function transformedBox(geometry) {
8211
+ const f = transformMap(geometry);
8212
+ if (!f) return null;
8213
+ const { box } = geometry;
8214
+ const pts = [];
8215
+ const n = hasWarp(geometry) ? 16 : 1;
8216
+ for (let i = 0; i <= n; i++) {
8217
+ const t = i / n;
8218
+ for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
8219
+ const p = f({ x: box.x + fx * box.width, y: box.y + fy * box.height });
8220
+ if (!p) return null;
8221
+ pts.push(p);
8222
+ }
8223
+ }
8224
+ const xs = pts.map((p) => p.x);
8225
+ const ys = pts.map((p) => p.y);
8226
+ const x = Math.min(...xs);
8227
+ const y = Math.min(...ys);
8228
+ return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
8229
+ }
8230
+ function referencePoint(box, reference) {
8231
+ if (reference && typeof reference === "object") return { x: reference.x, y: reference.y };
8232
+ const [fx, fy] = ANCHOR_FRACTION[_nullishCoalesce(reference, () => ( "center"))];
8233
+ return { x: box.x + fx * box.width, y: box.y + fy * box.height };
8234
+ }
8235
+ function matrixFromParams(box, params) {
8236
+ const sx = (_nullishCoalesce(params.scaleX, () => ( 100))) / 100;
8237
+ const sy = (_nullishCoalesce(params.scaleY, () => ( 100))) / 100;
8238
+ const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
8239
+ const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
8240
+ const ref = referencePoint(box, params.reference);
8241
+ const linear = _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkDWGZUSEScjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
8242
+ return _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.matrixAbout.call(void 0, linear, ref), _chunkDWGZUSEScjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
8243
+ }
8244
+ function describeTransform(geometry, reference = "center") {
8245
+ const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
8246
+ const ref = referencePoint(geometry.box, reference);
8247
+ const bounds = transformedBox(geometry);
8248
+ if (!m) {
8249
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
8250
+ const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
8251
+ return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
8252
+ }
8253
+ const [a, b, c, d] = m;
8254
+ const sxAbs = Math.hypot(a, b);
8255
+ const rot = Math.atan2(b, a) * 180 / Math.PI;
8256
+ const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
8257
+ const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
8258
+ const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
8259
+ const at = _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, ref);
8260
+ const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
8261
+ return {
8262
+ affine: true,
8263
+ scaleX: clean(sxAbs * 100),
8264
+ scaleY: clean(sy * 100),
8265
+ rotate: clean(rot === -180 ? 180 : rot),
8266
+ skewX: clean(skew),
8267
+ x: at.x,
8268
+ y: at.y,
8269
+ bounds,
8270
+ corners: geometry.corners
8271
+ };
8272
+ }
8273
+ function applyParams(geometry, params) {
8274
+ const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
8275
+ const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
8276
+ const c = geometry.corners;
8277
+ return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[3])];
8278
+ }
8279
+ function flipCorners(geometry, axis) {
8280
+ const c = anchorPoint(geometry, "center");
8281
+ const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
8282
+ const q2 = geometry.corners;
8283
+ return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
8284
+ }
8285
+ function boxPointOf(geometry, p) {
8286
+ const m = matrixFromCorners(geometry.box, geometry.corners);
8287
+ if (m) return _chunkDWGZUSEScjs.applyMatrix.call(void 0, _chunkDWGZUSEScjs.invertMatrix.call(void 0, m), p);
8288
+ return null;
8289
+ }
8290
+ function presetWarp(box, preset) {
8291
+ return _chunkDWGZUSEScjs.warpPresetMesh.call(void 0, preset, box);
8292
+ }
8293
+ function isValidWarp(mesh) {
8294
+ return _chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, mesh);
8295
+ }
8296
+ function geometryHomography(geometry) {
8297
+ const m = matrixFromCorners(geometry.box, geometry.corners);
8298
+ return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
8299
+ }
8300
+
8301
+ // src/image-editor/free-transform.ts
8302
+ var FREE_TRANSFORM_CONTENTS = ["auto", "layer", "selection", "selection-copy", "selection-outline"];
8303
+ var fail2 = (message) => {
8304
+ throw new LayerOperationError(message);
8305
+ };
8306
+ var T = (x, y) => [1, 0, x, 0, 1, y, 0, 0, 1];
8307
+ function previewStep(scale) {
8308
+ if (!scale || !(scale > 0) || scale >= 1) return 1;
8309
+ return Math.min(8, 2 ** Math.floor(Math.log2(1 / scale)));
8310
+ }
8311
+ function toDoc(r, o) {
8312
+ return r ? { x: r.x + o.x, y: r.y + o.y, width: r.width, height: r.height } : null;
8313
+ }
8314
+ function selectionSurface(sel) {
8315
+ return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: sel.width, height: sel.height, data: sel.data }, 1, 0, 0, 0);
8316
+ }
8317
+ function liftPixels(surface, sel, o) {
8318
+ const sb = sel.bounds;
8319
+ const area = { x: sb.x - o.x, y: sb.y - o.y, width: sb.width, height: sb.height };
8320
+ const px2 = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, area);
8321
+ const kept = new Uint8ClampedArray(px2);
8322
+ for (let y = 0; y < area.height; y++) {
8323
+ for (let x = 0; x < area.width; x++) {
8324
+ const k = sel.data[(sb.y + y) * sel.width + sb.x + x] / 255;
8325
+ const i = (y * area.width + x) * 4;
8326
+ if (k <= 0) {
8327
+ px2[i] = px2[i + 1] = px2[i + 2] = px2[i + 3] = 0;
8328
+ continue;
8329
+ }
8330
+ px2[i + 3] = px2[i + 3] * k;
8331
+ if (!px2[i + 3]) px2[i] = px2[i + 1] = px2[i + 2] = 0;
8332
+ kept[i + 3] = kept[i + 3] * (1 - k);
8333
+ if (!kept[i + 3]) kept[i] = kept[i + 1] = kept[i + 2] = 0;
8334
+ }
8335
+ }
8336
+ return { lifted: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: area.width, height: area.height, data: px2 }, 4, area.x, area.y), rest: _chunkCRMAXIUVcjs.writeRegion.call(void 0, surface, area, kept) };
8337
+ }
8338
+ function liftMask(mask, sel, o) {
8339
+ const sb = sel.bounds;
8340
+ const area = { x: sb.x - o.x, y: sb.y - o.y, width: sb.width, height: sb.height };
8341
+ const v = _chunkCRMAXIUVcjs.readRegion.call(void 0, mask, area);
8342
+ const def = mask.defaultValue;
8343
+ const lifted = new Uint8ClampedArray(area.width * area.height * 4);
8344
+ const rest = new Uint8ClampedArray(v.length);
8345
+ for (let y = 0; y < area.height; y++) {
8346
+ for (let x = 0; x < area.width; x++) {
8347
+ const i = y * area.width + x;
8348
+ const k = sel.data[(sb.y + y) * sel.width + sb.x + x] / 255;
8349
+ const g = v[i];
8350
+ if (k > 0) {
8351
+ lifted[i * 4] = lifted[i * 4 + 1] = lifted[i * 4 + 2] = g;
8352
+ lifted[i * 4 + 3] = k * 255;
8353
+ }
8354
+ rest[i] = g * (1 - k) + def * k;
8355
+ }
8356
+ }
8357
+ return { lifted: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: area.width, height: area.height, data: lifted }, 4, area.x, area.y), rest: _chunkCRMAXIUVcjs.writeRegion.call(void 0, mask, area, rest) };
8358
+ }
8359
+ var FreeTransformSession = (_class6 = class {
8360
+ constructor(host, init = {}) {;_class6.prototype.__init28.call(this);_class6.prototype.__init29.call(this);_class6.prototype.__init30.call(this);
8361
+ this.host = host;
8362
+ if (init.interpolation !== void 0 && !_chunkWT6ZAWJPcjs.isInterpolation.call(void 0, init.interpolation)) fail2(`Unknown interpolation "${String(init.interpolation)}"; use nearest, bilinear or bicubic.`);
8363
+ this.interp = _nullishCoalesce(init.interpolation, () => ( "bicubic"));
8364
+ const sel = host.selection();
8365
+ const selected = Boolean(_optionalChain([sel, 'optionalAccess', _133 => _133.bounds]));
8366
+ let content = _nullishCoalesce(init.content, () => ( "auto"));
8367
+ if (!["auto", "layer", "selection", "selection-copy", "selection-outline"].includes(content)) {
8368
+ fail2(`Unknown content "${String(content)}"; use auto, layer, selection, selection-copy or selection-outline.`);
8369
+ }
8370
+ if (content === "auto") content = selected ? "selection" : "layer";
8371
+ this.content = content;
8372
+ if (content !== "layer" && !selected) fail2(`Nothing is selected; ${content} needs a selection. Select first, or use content layer.`);
8373
+ const layers = host.layers();
8374
+ this.startLayers = layers;
8375
+ this.startSelection = sel;
8376
+ this.startActive = host.activeLayerId();
8377
+ this.before = host.capture();
8378
+ const moves = [];
8379
+ let box = null;
8380
+ if (content === "selection-outline") {
8381
+ this.layerId = null;
8382
+ this.parts.push({ what: "selection", offset: { x: 0, y: 0 }, moving: selectionSurface(sel), base: null, reduced: /* @__PURE__ */ new Map() });
8383
+ moves.push("selection");
8384
+ box = { ...sel.bounds };
8385
+ } else {
8386
+ const id = _nullishCoalesce(init.layerId, () => ( host.activeLayerId()));
8387
+ if (!id) fail2("No layer given and none is active; pass layerId (see list_layers).");
8388
+ const layer = requireLayer(layers, id).layer;
8389
+ this.layerId = layer.id;
8390
+ const mask = layer.mask && !layer.mask.source ? layer.mask : void 0;
8391
+ const channel = _nullishCoalesce(init.channel, () => ( (layer.id === host.activeLayerId() ? host.activeTarget() : "pixels")));
8392
+ if (channel !== "pixels" && channel !== "mask") fail2(`Unknown channel "${String(channel)}"; use pixels or mask.`);
8393
+ const linked = _optionalChain([mask, 'optionalAccess', _134 => _134.linked]) !== false;
8394
+ const maskAlone = channel === "mask" && (!linked || layer.type !== "pixel");
8395
+ if (channel === "mask" && !mask) fail2(_optionalChain([layer, 'access', _135 => _135.mask, 'optionalAccess', _136 => _136.source]) ? `Layer "${layer.name || id}" has a depth mask, which is generated, not transformed.` : `Layer "${layer.name || id}" has no mask to transform; add one with add_layer_mask, or transform its pixels.`);
8396
+ if (!maskAlone && layer.type !== "pixel") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer; Free Transform works on pixel layers, layer masks (channel mask) and selections.`);
8397
+ if (!layer.visible && content !== "selection-copy") fail2(`Layer "${layer.name || id}" is hidden; show it before you transform it.`);
8398
+ if (content !== "selection-copy") {
8399
+ requireUnlocked(layer, "position", "transform it");
8400
+ if (!maskAlone) requireUnlocked(layer, "pixels", "transform it");
8401
+ }
8402
+ const o = layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
8403
+ const pixels = layer.type === "pixel" ? host.pixelsOf(layer) : null;
8404
+ if (maskAlone) {
8405
+ if (content === "selection-copy") fail2("Layer via Copy copies pixels; transform a mask with content layer or selection.");
8406
+ if (content === "selection") {
8407
+ const { lifted, rest } = liftMask(mask.surface, sel, o);
8408
+ this.parts.push({ what: "mask", offset: o, moving: lifted, base: rest, reduced: /* @__PURE__ */ new Map() });
8409
+ box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
8410
+ } else {
8411
+ this.parts.push({ what: "mask", offset: o, moving: mask.surface, base: null, reduced: /* @__PURE__ */ new Map() });
8412
+ box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface), o);
8413
+ }
8414
+ moves.push("mask");
8415
+ } else if (content === "layer") {
8416
+ this.parts.push({ what: "pixels", offset: o, moving: pixels, base: null, reduced: /* @__PURE__ */ new Map() });
8417
+ moves.push("pixels");
8418
+ box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, pixels), o);
8419
+ if (mask && linked) {
8420
+ this.parts.push({ what: "mask", offset: o, moving: mask.surface, base: null, reduced: /* @__PURE__ */ new Map() });
8421
+ moves.push("mask");
8422
+ if (!box) box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface), o);
8423
+ }
8424
+ } else if (content === "selection") {
8425
+ const { lifted, rest } = liftPixels(pixels, sel, o);
8426
+ this.parts.push({ what: "pixels", offset: o, moving: lifted, base: rest, reduced: /* @__PURE__ */ new Map() });
8427
+ moves.push("pixels");
8428
+ box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
8429
+ if (mask && linked) {
8430
+ const m = liftMask(mask.surface, sel, o);
8431
+ this.parts.push({ what: "mask", offset: o, moving: m.lifted, base: m.rest, reduced: /* @__PURE__ */ new Map() });
8432
+ moves.push("mask");
8433
+ }
8434
+ } else {
8435
+ const { lifted } = liftPixels(pixels, sel, o);
8436
+ box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
8437
+ if (box) {
8438
+ const copy = {
8439
+ type: "pixel",
8440
+ id: newLayerId(),
8441
+ name: `${layer.name || "Layer"} copy`,
8442
+ visible: true,
8443
+ opacity: 1,
8444
+ blend: "normal",
8445
+ surface: lifted,
8446
+ offset: { ...o }
8447
+ };
8448
+ this.copyId = copy.id;
8449
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, layer.id);
8450
+ this.startLayers = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _137 => _137.parent, 'optionalAccess', _138 => _138.id]), () => ( null)), loc.index + 1);
8451
+ this.parts.push({ what: "pixels", offset: o, moving: lifted, base: null, reduced: /* @__PURE__ */ new Map() });
8452
+ moves.push("pixels");
8453
+ }
8454
+ }
8455
+ if (content !== "layer") {
8456
+ this.parts.push({ what: "selection", offset: { x: 0, y: 0 }, moving: selectionSurface(sel), base: null, reduced: /* @__PURE__ */ new Map() });
8457
+ moves.push("selection");
8458
+ }
8459
+ }
8460
+ if (!box && moves[0] === "mask") fail2("The mask holds nothing but its default value, so there is nothing to transform; paint it first, or transform the pixels (channel pixels).");
8461
+ if (!box) fail2(content === "layer" ? "The layer has no pixels to transform." : "The selection holds no pixels of this layer; select some, or transform the outline (content selection-outline).");
8462
+ this.box = box;
8463
+ this.moves = moves;
8464
+ this.geometryValue = identityTransform(box);
8465
+ this.shown = this.startLayers;
8466
+ if (this.copyId) host.show(this.startLayers, sel, this.copyId);
8467
+ this.shown = host.layers();
8468
+ }
8469
+
8470
+
8471
+ /** The layer being transformed (`null` for `selection-outline`). */
8472
+
8473
+ /** The new layer of a `selection-copy`. */
8474
+ __init28() {this.copyId = null}
8475
+ /** The frame (document pixels). */
8476
+
8477
+ /** What moves. */
8478
+
8479
+
8480
+
8481
+ __init29() {this.parts = []}
8482
+
8483
+
8484
+
8485
+
8486
+ /** The stack this session last showed: anything else means the document changed under it. */
8487
+
8488
+ __init30() {this.closed = false}
8489
+ /** The current geometry. */
8490
+ get geometry() {
8491
+ return this.geometryValue;
8492
+ }
8493
+ get interpolation() {
8494
+ return this.interp;
8495
+ }
8496
+ get isOpen() {
8497
+ return !this.closed;
8498
+ }
8499
+ check() {
8500
+ if (this.closed) fail2("This transform has already been committed or cancelled; begin a new one.");
8501
+ if (this.host.layers() !== this.shown) {
8502
+ this.closed = true;
8503
+ fail2("The document changed while the transform was open, so it was abandoned; begin a new one.");
8504
+ }
8505
+ }
8506
+ /**
8507
+ * Changes the geometry (`corners`, `warp`) or the interpolation and, unless `preview` is `false`,
8508
+ * shows the result live (no history). Returns the geometry.
8509
+ */
8510
+ update(changes, preview = {}) {
8511
+ this.check();
8512
+ if (changes.interpolation !== void 0) {
8513
+ if (!_chunkWT6ZAWJPcjs.isInterpolation.call(void 0, changes.interpolation)) fail2(`Unknown interpolation "${String(changes.interpolation)}"; use nearest, bilinear or bicubic.`);
8514
+ this.interp = changes.interpolation;
8515
+ }
8516
+ const next = {
8517
+ box: this.box,
8518
+ corners: (_nullishCoalesce(changes.corners, () => ( this.geometryValue.corners))).map((p) => ({ x: p.x, y: p.y })),
8519
+ warp: changes.warp === void 0 ? _nullishCoalesce(this.geometryValue.warp, () => ( null)) : changes.warp
8520
+ };
8521
+ if (next.corners.length !== 4 || !next.corners.every((p) => Number.isFinite(p.x) && Number.isFinite(p.y))) fail2("corners must be four finite points: top-left, top-right, bottom-right, bottom-left.");
8522
+ if (!transformMap(next)) fail2("These corners fold the frame over itself or through the horizon; keep the quad convex.");
8523
+ this.geometryValue = next;
8524
+ if (preview !== false) this.render(preview);
8525
+ return next;
8526
+ }
8527
+ /** Resamples every part for the current geometry and shows it (or returns it, for commit). */
8528
+ resample(final, preview = {}) {
8529
+ const g = this.geometryValue;
8530
+ const identity = isIdentityTransform(g);
8531
+ const warp = hasWarp(g);
8532
+ const h = warp ? null : geometryHomography(g);
8533
+ const f = warp ? transformMap(g) : null;
8534
+ const step = final ? 1 : previewStep(preview.scale);
8535
+ const interpolation = final ? this.interp : this.interp === "nearest" ? "nearest" : "bilinear";
8536
+ let layers = this.startLayers;
8537
+ let selection = this.startSelection;
8538
+ const targetId = _nullishCoalesce(this.copyId, () => ( this.layerId));
8539
+ for (const part of this.parts) {
8540
+ const o = part.offset;
8541
+ let moved;
8542
+ if (identity) moved = part.moving;
8543
+ else {
8544
+ let src = part.moving;
8545
+ let k = 1;
8546
+ if (step > 1) {
8547
+ k = step;
8548
+ let r = part.reduced.get(k);
8549
+ if (!r) {
8550
+ r = _chunkWT6ZAWJPcjs.reduceSurface.call(void 0, part.moving, k);
8551
+ part.reduced.set(k, r);
8552
+ }
8553
+ src = r;
8554
+ }
8555
+ const opts = { interpolation, step: step > 1 ? step : void 0 };
8556
+ if (preview.clip && !final) opts.clip = { x: Math.floor(preview.clip.x - o.x), y: Math.floor(preview.clip.y - o.y), width: Math.ceil(preview.clip.width) + 1, height: Math.ceil(preview.clip.height) + 1 };
8557
+ try {
8558
+ if (f) {
8559
+ moved = _chunkWT6ZAWJPcjs.warpSurface.call(void 0, src, (p) => {
8560
+ const q2 = f({ x: p.x * k + o.x, y: p.y * k + o.y });
8561
+ return q2 && { x: q2.x - o.x, y: q2.y - o.y };
8562
+ }, opts);
8563
+ } else {
8564
+ const hl = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], T(o.x, o.y)), h), T(-o.x, -o.y));
8565
+ moved = _chunkWT6ZAWJPcjs.transformSurface.call(void 0, src, hl, opts);
8566
+ }
8567
+ } catch (e) {
8568
+ if (e instanceof _chunkWT6ZAWJPcjs.TransformTooLargeError) fail2(e.message);
8569
+ throw e;
8570
+ }
8571
+ }
8572
+ const result = part.base ? _chunkWT6ZAWJPcjs.compositeSurfaceOver.call(void 0, part.base, moved) : moved;
8573
+ if (part.what === "selection") {
8574
+ const { width, height } = this.host.canvas();
8575
+ const data = new Uint8Array(_chunkCRMAXIUVcjs.readRegion.call(void 0, result, { x: 0, y: 0, width, height }).buffer);
8576
+ const next = createSelectionMask(width, height, data);
8577
+ selection = next.bounds ? next : null;
8578
+ } else if (part.what === "pixels") {
8579
+ layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, targetId, (l) => {
8580
+ const next = { ...l, surface: result };
8581
+ delete next.source;
8582
+ return next;
8583
+ });
8584
+ } else {
8585
+ layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, targetId, (l) => ({ ...l, mask: { ...l.mask, surface: result } }));
8586
+ }
8587
+ }
8588
+ return { layers, selection };
8589
+ }
8590
+ render(preview) {
8591
+ const { layers, selection } = this.resample(false, preview);
8592
+ this.host.show(layers, selection, _nullishCoalesce(this.copyId, () => ( this.startActive)));
8593
+ this.shown = this.host.layers();
8594
+ }
8595
+ /** Finishes the transform with full-quality resampling, as one undo step. */
8596
+ commit() {
8597
+ this.check();
8598
+ const g = this.geometryValue;
8599
+ const changed = !isIdentityTransform(g) || Boolean(this.copyId);
8600
+ if (!changed) {
8601
+ this.closed = true;
8602
+ this.host.restore(this.before);
8603
+ return this.result(false, this.startLayers, this.startSelection);
8604
+ }
8605
+ const { layers, selection } = this.resample(true);
8606
+ this.closed = true;
8607
+ this.host.show(layers, selection, _nullishCoalesce(this.copyId, () => ( this.startActive)));
8608
+ this.host.record(this.before);
8609
+ return this.result(true, layers, selection);
8610
+ }
8611
+ /** Abandons the transform and puts everything back (no history). */
8612
+ cancel() {
8613
+ if (this.closed) return;
8614
+ this.closed = true;
8615
+ this.host.restore(this.before);
8616
+ }
8617
+ result(changed, layers, selection) {
8618
+ let bounds = null;
8619
+ const id = _nullishCoalesce(this.copyId, () => ( this.layerId));
8620
+ const layer = id ? _optionalChain([_chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, id), 'optionalAccess', _139 => _139.layer]) : void 0;
8621
+ if (this.moves.includes("pixels") && _optionalChain([layer, 'optionalAccess', _140 => _140.type]) === "pixel") bounds = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, this.host.pixelsOf(layer)), layer.offset);
8622
+ else if (this.moves.includes("mask") && _optionalChain([layer, 'optionalAccess', _141 => _141.mask])) bounds = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, layer.mask.surface), layer.type === "pixel" ? layer.offset : { x: 0, y: 0 });
8623
+ else if (this.moves.includes("selection")) bounds = _optionalChain([selection, 'optionalAccess', _142 => _142.bounds]) ? { ...selection.bounds } : null;
8624
+ return {
8625
+ layerId: _nullishCoalesce(this.copyId, () => ( this.layerId)),
8626
+ content: this.content,
8627
+ moved: [...this.moves],
8628
+ box: { ...this.box },
8629
+ corners: this.geometryValue.corners,
8630
+ bounds,
8631
+ changed
8632
+ };
8633
+ }
8634
+ }, _class6);
8635
+
8090
8636
  // src/image-editor/controller.ts
8091
8637
  var IMAGE_EDITOR_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION;
8092
8638
  function paintCoverageInto(base, coverage, apply, rects) {
@@ -8097,7 +8643,7 @@ function paintCoverageInto(base, coverage, apply, rects) {
8097
8643
  const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, t.tx, t.ty);
8098
8644
  if (done.has(key)) continue;
8099
8645
  done.add(key);
8100
- const src = _nullishCoalesce(_optionalChain([base, 'access', _133 => _133.tiles, 'access', _134 => _134.get, 'call', _135 => _135(key), 'optionalAccess', _136 => _136.data]), () => ( defaultTile(base)));
8646
+ const src = _nullishCoalesce(_optionalChain([base, 'access', _143 => _143.tiles, 'access', _144 => _144.get, 'call', _145 => _145(key), 'optionalAccess', _146 => _146.data]), () => ( defaultTile(base)));
8101
8647
  const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, coverage, src, base.channels, t.tx, t.ty, apply);
8102
8648
  const tile = _chunkCRMAXIUVcjs.finishTile.call(void 0, data, base.channels, base.defaultValue);
8103
8649
  if (tile) tiles.set(key, tile);
@@ -8111,8 +8657,8 @@ function defaultTile(s) {
8111
8657
  if (s.defaultValue) d.fill(s.defaultValue);
8112
8658
  return d;
8113
8659
  }
8114
- var PaintStrokeSession = (_class6 = class {
8115
- constructor(controller, target, stroke, apply) {;_class6.prototype.__init28.call(this);_class6.prototype.__init29.call(this);_class6.prototype.__init30.call(this);_class6.prototype.__init31.call(this);_class6.prototype.__init32.call(this);
8660
+ var PaintStrokeSession = (_class7 = class {
8661
+ constructor(controller, target, stroke, apply) {;_class7.prototype.__init31.call(this);_class7.prototype.__init32.call(this);_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);
8116
8662
  this.controller = controller;
8117
8663
  this.target = target;
8118
8664
  this.apply = apply;
@@ -8134,14 +8680,14 @@ var PaintStrokeSession = (_class6 = class {
8134
8680
 
8135
8681
 
8136
8682
 
8137
- __init28() {this.touched = /* @__PURE__ */ new Set()}
8683
+ __init31() {this.touched = /* @__PURE__ */ new Set()}
8138
8684
 
8139
8685
 
8140
- __init29() {this.mixerInit = null}
8686
+ __init32() {this.mixerInit = null}
8141
8687
  /** Mixer tiles written since the last update: they get new tile objects so the compositor sees them change. */
8142
- __init30() {this.fresh = /* @__PURE__ */ new Set()}
8143
- __init31() {this.last = null}
8144
- __init32() {this.closed = false}
8688
+ __init33() {this.fresh = /* @__PURE__ */ new Set()}
8689
+ __init34() {this.last = null}
8690
+ __init35() {this.closed = false}
8145
8691
  /** The live pixels a mixer stroke reads and writes; base tiles are copied on first write. */
8146
8692
  mixerPixels() {
8147
8693
  const a = this.apply;
@@ -8149,11 +8695,11 @@ var PaintStrokeSession = (_class6 = class {
8149
8695
  offset: a.offset,
8150
8696
  lockTransparency: a.lockTransparency,
8151
8697
  selection: a.selection,
8152
- readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _137 => _137.live, 'access', _138 => _138.get, 'call', _139 => _139(_chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _140 => _140.data]), () => ( (this.base.defaultValue ? defaultTile(this.base) : null))),
8698
+ readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _147 => _147.live, 'access', _148 => _148.get, 'call', _149 => _149(_chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _150 => _150.data]), () => ( (this.base.defaultValue ? defaultTile(this.base) : null))),
8153
8699
  writeTile: (tx, ty) => {
8154
8700
  const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty);
8155
8701
  if (!this.touched.has(key)) {
8156
- const src = _nullishCoalesce(_optionalChain([this, 'access', _141 => _141.base, 'access', _142 => _142.tiles, 'access', _143 => _143.get, 'call', _144 => _144(key), 'optionalAccess', _145 => _145.data]), () => ( defaultTile(this.base)));
8702
+ const src = _nullishCoalesce(_optionalChain([this, 'access', _151 => _151.base, 'access', _152 => _152.tiles, 'access', _153 => _153.get, 'call', _154 => _154(key), 'optionalAccess', _155 => _155.data]), () => ( defaultTile(this.base)));
8157
8703
  this.live.set(key, { data: new Uint8ClampedArray(src), uniform: null });
8158
8704
  this.touched.add(key);
8159
8705
  }
@@ -8190,8 +8736,8 @@ var PaintStrokeSession = (_class6 = class {
8190
8736
  }
8191
8737
  }
8192
8738
  for (const [key, { tx, ty, r }] of regions) {
8193
- const src = _nullishCoalesce(_optionalChain([this, 'access', _146 => _146.base, 'access', _147 => _147.tiles, 'access', _148 => _148.get, 'call', _149 => _149(key), 'optionalAccess', _150 => _150.data]), () => ( defaultTile(this.base)));
8194
- const prev = this.touched.has(key) ? _optionalChain([this, 'access', _151 => _151.live, 'access', _152 => _152.get, 'call', _153 => _153(key), 'optionalAccess', _154 => _154.data]) : void 0;
8739
+ const src = _nullishCoalesce(_optionalChain([this, 'access', _156 => _156.base, 'access', _157 => _157.tiles, 'access', _158 => _158.get, 'call', _159 => _159(key), 'optionalAccess', _160 => _160.data]), () => ( defaultTile(this.base)));
8740
+ const prev = this.touched.has(key) ? _optionalChain([this, 'access', _161 => _161.live, 'access', _162 => _162.get, 'call', _163 => _163(key), 'optionalAccess', _164 => _164.data]) : void 0;
8195
8741
  this.touched.add(key);
8196
8742
  const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, stroke.coverage, src, ch, tx, ty, this.apply, prev ? { into: prev, region: r } : {});
8197
8743
  this.live.set(key, { data, uniform: null });
@@ -8229,7 +8775,7 @@ var PaintStrokeSession = (_class6 = class {
8229
8775
  this.closed = true;
8230
8776
  this.controller._strokeCommit(this.before, this.target.id, this.target.channel, null);
8231
8777
  }
8232
- }, _class6);
8778
+ }, _class7);
8233
8779
  function sameTile(a, b) {
8234
8780
  if (!a || !b) return !a && !b;
8235
8781
  if (a === b) return true;
@@ -8266,14 +8812,14 @@ function migrateSerializedImageEditorState(data) {
8266
8812
  const legacy = data;
8267
8813
  const adjustments = normalizeStoredAdjustments(legacy.adjustments);
8268
8814
  return {
8269
- version: _optionalChain([adjustments, 'access', _155 => _155.layers, 'optionalAccess', _156 => _156.length]) ? 2 : 1,
8815
+ version: _optionalChain([adjustments, 'access', _165 => _165.layers, 'optionalAccess', _166 => _166.length]) ? 2 : 1,
8270
8816
  crop: legacy.crop ? { ...legacy.crop } : null,
8271
8817
  transform: { ...DEFAULT_TRANSFORM, ...legacy.transform },
8272
8818
  adjustments: serializeAdjustments(adjustments),
8273
8819
  depthMask: {
8274
8820
  ...DEFAULT_DEPTH_MASK,
8275
8821
  ...legacy.depthMask,
8276
- depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access', _157 => _157.depthMask, 'optionalAccess', _158 => _158.depthRange]), () => ( DEFAULT_DEPTH_MASK.depthRange))]
8822
+ depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access', _167 => _167.depthMask, 'optionalAccess', _168 => _168.depthRange]), () => ( DEFAULT_DEPTH_MASK.depthRange))]
8277
8823
  },
8278
8824
  annotations: JSON.parse(JSON.stringify(_nullishCoalesce(legacy.annotations, () => ( [])))),
8279
8825
  ...legacy.selection ? { selection: { ...legacy.selection } } : {}
@@ -8302,29 +8848,29 @@ function migrateToLayeredState(data, size) {
8302
8848
  var DEFAULT_TRANSFORM = DEFAULT_TRANSFORM_VALUES;
8303
8849
  var DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK_VALUES;
8304
8850
  var DEVELOP_KEYS = ["brightness", "contrast", "saturation", "exposure", "temperature", "tint"];
8305
- var ImageEditorController = (_class7 = class {
8851
+ var ImageEditorController = (_class8 = class {
8306
8852
 
8307
8853
 
8308
- __init33() {this.imageElement = null}
8309
- __init34() {this.listeners = /* @__PURE__ */ new Set()}
8310
- __init35() {this.histogramListeners = /* @__PURE__ */ new Set()}
8854
+ __init36() {this.imageElement = null}
8855
+ __init37() {this.listeners = /* @__PURE__ */ new Set()}
8856
+ __init38() {this.histogramListeners = /* @__PURE__ */ new Set()}
8311
8857
 
8312
8858
  // History stacks
8313
- __init36() {this.undoStack = []}
8314
- __init37() {this.redoStack = []}
8859
+ __init39() {this.undoStack = []}
8860
+ __init40() {this.redoStack = []}
8315
8861
 
8316
8862
 
8317
- __init38() {this.isApplyingHistory = false}
8863
+ __init41() {this.isApplyingHistory = false}
8318
8864
 
8319
8865
  /** Pixels the selection tools sample (host-provided or read back from the source). */
8320
- __init39() {this.samplePixels = null}
8321
- __init40() {this.samplePixelsOverride = false}
8866
+ __init42() {this.samplePixels = null}
8867
+ __init43() {this.samplePixelsOverride = false}
8322
8868
  /** Decoded source pixels (the Background's surface), by the buffer or element they came from. */
8323
- __init41() {this.sourceSurfaces = /* @__PURE__ */ new WeakMap()}
8324
- __init42() {this.viewKey = []}
8869
+ __init44() {this.sourceSurfaces = /* @__PURE__ */ new WeakMap()}
8870
+ __init45() {this.viewKey = []}
8325
8871
  /** For `compositePixels` and mask evaluation (the renderer keeps its own for the viewport). */
8326
- __init43() {this.compositor = new LayerCompositor()}
8327
- constructor(options = {}) {;_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);_class7.prototype.__init39.call(this);_class7.prototype.__init40.call(this);_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);_class7.prototype.__init44.call(this);_class7.prototype.__init45.call(this);_class7.prototype.__init46.call(this);_class7.prototype.__init47.call(this);_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);_class7.prototype.__init52.call(this);
8872
+ __init46() {this.compositor = new LayerCompositor()}
8873
+ constructor(options = {}) {;_class8.prototype.__init36.call(this);_class8.prototype.__init37.call(this);_class8.prototype.__init38.call(this);_class8.prototype.__init39.call(this);_class8.prototype.__init40.call(this);_class8.prototype.__init41.call(this);_class8.prototype.__init42.call(this);_class8.prototype.__init43.call(this);_class8.prototype.__init44.call(this);_class8.prototype.__init45.call(this);_class8.prototype.__init46.call(this);_class8.prototype.__init47.call(this);_class8.prototype.__init48.call(this);_class8.prototype.__init49.call(this);_class8.prototype.__init50.call(this);_class8.prototype.__init51.call(this);_class8.prototype.__init52.call(this);_class8.prototype.__init53.call(this);_class8.prototype.__init54.call(this);_class8.prototype.__init55.call(this);_class8.prototype.__init56.call(this);
8328
8874
  this.maxHistoryDepth = _nullishCoalesce(options.maxHistoryDepth, () => ( 50));
8329
8875
  this.maxHistoryBytes = _nullishCoalesce(options.maxHistoryBytes, () => ( 512 * 1024 * 1024));
8330
8876
  this.onStateChange = options.onStateChange;
@@ -8337,7 +8883,7 @@ var ImageEditorController = (_class7 = class {
8337
8883
  sourceIsOpaque: () => this.sourceIsOpaque(),
8338
8884
  version: () => `${this.sourceVersion()}:${this.patternsVersion()}`,
8339
8885
  globalLight: () => this.state.globalLight,
8340
- pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _159 => _159.state, 'access', _160 => _160.patterns, 'optionalAccess', _161 => _161.find, 'call', _162 => _162((p) => p.id === id)]), () => ( null))
8886
+ pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _169 => _169.state, 'access', _170 => _170.patterns, 'optionalAccess', _171 => _171.find, 'call', _172 => _172((p) => p.id === id)]), () => ( null))
8341
8887
  };
8342
8888
  this.state = {
8343
8889
  sourceUrl: typeof options.image === "string" ? options.image : null,
@@ -8370,7 +8916,7 @@ var ImageEditorController = (_class7 = class {
8370
8916
  };
8371
8917
  }
8372
8918
  this.applyStored(_nullishCoalesce(options.initialState, () => ( {})));
8373
- if (_optionalChain([options, 'access', _163 => _163.initialState, 'optionalAccess', _164 => _164.selection])) {
8919
+ if (_optionalChain([options, 'access', _173 => _173.initialState, 'optionalAccess', _174 => _174.selection])) {
8374
8920
  try {
8375
8921
  this.state.selection = normalizeSelection(deserializeSelection(options.initialState.selection));
8376
8922
  } catch (e19) {
@@ -8447,13 +8993,13 @@ var ImageEditorController = (_class7 = class {
8447
8993
  * Where layer pixels changed since the last viewport render, when only strokes changed them
8448
8994
  * (the renderer then recomposites just those rectangles); `'all'` after any other change.
8449
8995
  */
8450
- __init44() {this.pendingDirty = "all"}
8996
+ __init47() {this.pendingDirty = "all"}
8451
8997
  notify(strokeRects) {
8452
8998
  if (strokeRects && this.pendingDirty !== "all") this.pendingDirty.push(...strokeRects);
8453
8999
  else if (!strokeRects) this.pendingDirty = "all";
8454
9000
  this.syncViews();
8455
9001
  const currentState = { ...this.state };
8456
- _optionalChain([this, 'access', _165 => _165.onStateChange, 'optionalCall', _166 => _166(currentState)]);
9002
+ _optionalChain([this, 'access', _175 => _175.onStateChange, 'optionalCall', _176 => _176(currentState)]);
8457
9003
  this.listeners.forEach((l) => l(currentState));
8458
9004
  }
8459
9005
  /** Recomputes the compatibility views (`adjustments`, `depthMask`, `annotations`) when the stack changed. */
@@ -8664,7 +9210,7 @@ var ImageEditorController = (_class7 = class {
8664
9210
  return this.state.layers;
8665
9211
  }
8666
9212
  getLayer(id) {
8667
- return _optionalChain([_chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, id), 'optionalAccess', _167 => _167.layer]);
9213
+ return _optionalChain([_chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id), 'optionalAccess', _177 => _177.layer]);
8668
9214
  }
8669
9215
  /** The active layer, or `undefined`. */
8670
9216
  getActiveLayer() {
@@ -8677,7 +9223,7 @@ var ImageEditorController = (_class7 = class {
8677
9223
  setActiveLayer(id, target = "pixels") {
8678
9224
  if (id !== null && !this.getLayer(id)) return false;
8679
9225
  const layer = id ? this.getLayer(id) : void 0;
8680
- const t = target === "mask" && _optionalChain([layer, 'optionalAccess', _168 => _168.mask]) ? "mask" : "pixels";
9226
+ const t = target === "mask" && _optionalChain([layer, 'optionalAccess', _178 => _178.mask]) ? "mask" : "pixels";
8681
9227
  if (this.state.activeLayerId === id && this.state.activeTarget === t) return true;
8682
9228
  this.state.activeLayerId = id;
8683
9229
  this.state.activeTarget = t;
@@ -8696,7 +9242,7 @@ var ImageEditorController = (_class7 = class {
8696
9242
  if (!b) return null;
8697
9243
  return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height, data: _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, b) };
8698
9244
  }
8699
- __init45() {this.boundsCache = /* @__PURE__ */ new WeakMap()}
9245
+ __init48() {this.boundsCache = /* @__PURE__ */ new WeakMap()}
8700
9246
  /**
8701
9247
  * Document bounds of a layer's non-transparent pixels (pixel layers; the Background's source
8702
9248
  * included), or `null` for an empty or non-pixel layer.
@@ -8723,7 +9269,7 @@ var ImageEditorController = (_class7 = class {
8723
9269
  let layers = this.state.layers;
8724
9270
  if (options.layerIds) {
8725
9271
  const keep = new Set(options.layerIds);
8726
- layers = _chunkT422YCHRcjs.flattenLayers.call(void 0, layers).filter((l) => keep.has(l.id) && l.type !== "group");
9272
+ layers = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => keep.has(l.id) && l.type !== "group");
8727
9273
  }
8728
9274
  const data = this.compositor.composite(layers, r, this.compositorSources());
8729
9275
  return { width: r.width, height: r.height, data };
@@ -8736,11 +9282,11 @@ var ImageEditorController = (_class7 = class {
8736
9282
  surfaceOf: (l) => this.surfaceOf(l),
8737
9283
  version: `${this.sourceVersion()}:${this.patternsVersion()}`,
8738
9284
  globalLight: this.state.globalLight,
8739
- pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _169 => _169.state, 'access', _170 => _170.patterns, 'optionalAccess', _171 => _171.find, 'call', _172 => _172((p) => p.id === id)]), () => ( null))
9285
+ pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _179 => _179.state, 'access', _180 => _180.patterns, 'optionalAccess', _181 => _181.find, 'call', _182 => _182((p) => p.id === id)]), () => ( null))
8740
9286
  };
8741
9287
  }
8742
- __init46() {this.sourceIds = /* @__PURE__ */ new WeakMap()}
8743
- __init47() {this.nextSourceId = 1}
9288
+ __init49() {this.sourceIds = /* @__PURE__ */ new WeakMap()}
9289
+ __init50() {this.nextSourceId = 1}
8744
9290
  /** Changes whenever the Background's source pixels can have changed. */
8745
9291
  sourceVersion() {
8746
9292
  const key = this.samplePixelsOverride ? this.samplePixels : _nullishCoalesce(this.imageElement, () => ( this.samplePixels));
@@ -8763,17 +9309,17 @@ var ImageEditorController = (_class7 = class {
8763
9309
  */
8764
9310
  sourceSurface() {
8765
9311
  const { width, height } = this.naturalSize;
8766
- const fromPixels = (px2) => {
8767
- let s = this.sourceSurfaces.get(px2);
9312
+ const fromPixels = (px3) => {
9313
+ let s = this.sourceSurfaces.get(px3);
8768
9314
  if (!s) {
8769
- s = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, 4);
8770
- this.sourceSurfaces.set(px2, s);
9315
+ s = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px3, 4);
9316
+ this.sourceSurfaces.set(px3, s);
8771
9317
  }
8772
9318
  return s;
8773
9319
  };
8774
- const px = this.samplePixels;
8775
- const fits = Boolean(px && px.width === width && px.height === height);
8776
- if (this.samplePixelsOverride && fits) return fromPixels(px);
9320
+ const px2 = this.samplePixels;
9321
+ const fits = Boolean(px2 && px2.width === width && px2.height === height);
9322
+ if (this.samplePixelsOverride && fits) return fromPixels(px2);
8777
9323
  const el = this.imageElement;
8778
9324
  if (el) {
8779
9325
  const cached = this.sourceSurfaces.get(el);
@@ -8787,9 +9333,9 @@ var ImageEditorController = (_class7 = class {
8787
9333
  return s;
8788
9334
  }
8789
9335
  }
8790
- return fits ? fromPixels(px) : null;
9336
+ return fits ? fromPixels(px2) : null;
8791
9337
  }
8792
- __init48() {this.opaqueCache = /* @__PURE__ */ new WeakMap()}
9338
+ __init51() {this.opaqueCache = /* @__PURE__ */ new WeakMap()}
8793
9339
  /** Whether every source pixel is opaque (some legacy renders depend on it). */
8794
9340
  sourceIsOpaque() {
8795
9341
  const s = this.sourceSurface();
@@ -8813,7 +9359,7 @@ var ImageEditorController = (_class7 = class {
8813
9359
  if (!ctx || typeof ctx.getImageData !== "function") return null;
8814
9360
  ctx.drawImage(el, 0, 0, width, height);
8815
9361
  const data = ctx.getImageData(0, 0, width, height);
8816
- if (!_optionalChain([data, 'optionalAccess', _173 => _173.data]) || data.data.length < width * height * 4) return null;
9362
+ if (!_optionalChain([data, 'optionalAccess', _183 => _183.data]) || data.data.length < width * height * 4) return null;
8817
9363
  return { width, height, data: data.data };
8818
9364
  } catch (e21) {
8819
9365
  return null;
@@ -8824,8 +9370,8 @@ var ImageEditorController = (_class7 = class {
8824
9370
  commitLayers(next, extra, commitToHistory = true) {
8825
9371
  if (commitToHistory) this.recordHistory();
8826
9372
  this.state.layers = next;
8827
- _optionalChain([extra, 'optionalCall', _174 => _174()]);
8828
- if (this.state.activeLayerId && !_chunkT422YCHRcjs.findLayer.call(void 0, next, this.state.activeLayerId)) {
9373
+ _optionalChain([extra, 'optionalCall', _184 => _184()]);
9374
+ if (this.state.activeLayerId && !_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, this.state.activeLayerId)) {
8829
9375
  this.state.activeLayerId = null;
8830
9376
  this.state.activeTarget = "pixels";
8831
9377
  }
@@ -8834,7 +9380,7 @@ var ImageEditorController = (_class7 = class {
8834
9380
  /** The default position of a new layer: above the active layer, else the top of the stack. */
8835
9381
  newLayerPlacement(placement) {
8836
9382
  if (placement.aboveId || placement.belowId || placement.parentId || placement.index !== void 0) return placement;
8837
- const active = this.state.activeLayerId ? _chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, this.state.activeLayerId) : null;
9383
+ const active = this.state.activeLayerId ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, this.state.activeLayerId) : null;
8838
9384
  return active ? { aboveId: active.layer.id } : {};
8839
9385
  }
8840
9386
  /**
@@ -8846,22 +9392,22 @@ var ImageEditorController = (_class7 = class {
8846
9392
  const { width, height } = this.naturalSize;
8847
9393
  let surface = _chunkCRMAXIUVcjs.emptySurface.call(void 0, 4);
8848
9394
  if (init.pixels) {
8849
- const px = init.pixels;
8850
- if (!(px.width > 0 && px.height > 0) || px.data.length < px.width * px.height * 4) {
9395
+ const px2 = init.pixels;
9396
+ if (!(px2.width > 0 && px2.height > 0) || px2.data.length < px2.width * px2.height * 4) {
8851
9397
  throw new LayerOperationError("pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
8852
9398
  }
8853
- surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px, 4);
9399
+ surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, 4);
8854
9400
  } else if (init.color !== void 0) {
8855
9401
  const c = parseColor(init.color);
8856
9402
  surface = _chunkCRMAXIUVcjs.solidSurface.call(void 0, 4, { x: 0, y: 0, width, height }, _chunkCRMAXIUVcjs.packRgba.call(void 0, c[0], c[1], c[2], c[3]));
8857
9403
  }
8858
9404
  const blend = parseBlend(init.blend);
8859
9405
  if (init.opacity !== void 0 && !(init.opacity >= 0 && init.opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
8860
- const ids = new Set(_chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
9406
+ const ids = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
8861
9407
  const layer = {
8862
9408
  type: "pixel",
8863
9409
  id: init.id && !ids.has(init.id) ? init.id : newLayerId(),
8864
- name: _optionalChain([init, 'access', _175 => _175.name, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]) || this.nextLayerName(),
9410
+ name: _optionalChain([init, 'access', _185 => _185.name, 'optionalAccess', _186 => _186.trim, 'call', _187 => _187()]) || this.nextLayerName(),
8865
9411
  visible: _nullishCoalesce(init.visible, () => ( true)),
8866
9412
  opacity: _nullishCoalesce(init.opacity, () => ( 1)),
8867
9413
  blend: _nullishCoalesce(blend, () => ( "normal")),
@@ -8888,23 +9434,23 @@ var ImageEditorController = (_class7 = class {
8888
9434
  async decodeImage(image) {
8889
9435
  const trimmed = image.trim();
8890
9436
  let png = null;
8891
- if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([_chunkT422YCHRcjs.parseDataUrl.call(void 0, trimmed), 'optionalAccess', _178 => _178.bytes]), () => ( null));
9437
+ if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([_chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, trimmed), 'optionalAccess', _188 => _188.bytes]), () => ( null));
8892
9438
  else if (/^[A-Za-z0-9+/=\s]+$/.test(trimmed) && trimmed.length > 16) {
8893
9439
  try {
8894
- const bytes = _chunkT422YCHRcjs.base64ToBytes.call(void 0, trimmed);
8895
- if (_chunkT422YCHRcjs.isPng.call(void 0, bytes)) png = bytes;
9440
+ const bytes = _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, trimmed);
9441
+ if (_chunkWT6ZAWJPcjs.isPng.call(void 0, bytes)) png = bytes;
8896
9442
  } catch (e22) {
8897
9443
  png = null;
8898
9444
  }
8899
9445
  }
8900
9446
  if (png) {
8901
9447
  try {
8902
- const d = _chunkT422YCHRcjs.decodePng.call(void 0, png);
9448
+ const d = _chunkWT6ZAWJPcjs.decodePng.call(void 0, png);
8903
9449
  return { width: d.width, height: d.height, data: d.data };
8904
9450
  } catch (e23) {
8905
9451
  }
8906
9452
  }
8907
- const src = png ? `data:image/png;base64,${_chunkT422YCHRcjs.bytesToBase64.call(void 0, png)}` : trimmed;
9453
+ const src = png ? `data:image/png;base64,${_chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, png)}` : trimmed;
8908
9454
  let img;
8909
9455
  try {
8910
9456
  img = await this.renderer.imageCache.get(src);
@@ -8920,7 +9466,7 @@ var ImageEditorController = (_class7 = class {
8920
9466
  return { width: w, height: h, data: data.data };
8921
9467
  }
8922
9468
  nextLayerName() {
8923
- const names = new Set(_chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.name));
9469
+ const names = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.name));
8924
9470
  let n = 1;
8925
9471
  while (names.has(`Layer ${n}`)) n++;
8926
9472
  return `Layer ${n}`;
@@ -8937,7 +9483,7 @@ var ImageEditorController = (_class7 = class {
8937
9483
  removeLayer(id) {
8938
9484
  const next = removeLayer(this.state.layers, id);
8939
9485
  this.commitLayers(next, () => {
8940
- if (this.state.selectedAnnotationId && !_chunkT422YCHRcjs.flattenLayers.call(void 0, next).some((l) => l.type === "annotation" && l.annotation.id === this.state.selectedAnnotationId)) {
9486
+ if (this.state.selectedAnnotationId && !_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, next).some((l) => l.type === "annotation" && l.annotation.id === this.state.selectedAnnotationId)) {
8941
9487
  this.state.selectedAnnotationId = null;
8942
9488
  }
8943
9489
  });
@@ -8945,10 +9491,10 @@ var ImageEditorController = (_class7 = class {
8945
9491
  /** Moves a layer above / below another, or into a group, as one undo step. Returns its new parent and index. */
8946
9492
  moveLayer(id, placement) {
8947
9493
  const next = moveLayer(this.state.layers, id, placement);
8948
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, next, id);
8949
- if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _179 => _179.parent, 'optionalAccess', _180 => _180.id]), () => ( null)), index: loc.index };
9494
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id);
9495
+ if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _189 => _189.parent, 'optionalAccess', _190 => _190.id]), () => ( null)), index: loc.index };
8950
9496
  this.commitLayers(next);
8951
- return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _181 => _181.parent, 'optionalAccess', _182 => _182.id]), () => ( null)), index: loc.index };
9497
+ return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _191 => _191.parent, 'optionalAccess', _192 => _192.id]), () => ( null)), index: loc.index };
8952
9498
  }
8953
9499
  /**
8954
9500
  * Changes name, visibility, opacity, fill, blend, clipping, locks or (groups) collapsed state, as
@@ -8957,7 +9503,7 @@ var ImageEditorController = (_class7 = class {
8957
9503
  setLayerProperties(id, props, commitToHistory = true) {
8958
9504
  const next = setLayerProperties(this.state.layers, id, props);
8959
9505
  this.commitLayers(next, void 0, commitToHistory);
8960
- return _chunkT422YCHRcjs.findLayer.call(void 0, next, id).layer;
9506
+ return _chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer;
8961
9507
  }
8962
9508
  /** Adds an empty pass-through group above the active layer (or at `placement`) and makes it active. Returns its id. */
8963
9509
  addGroup(init = {}) {
@@ -8965,7 +9511,7 @@ var ImageEditorController = (_class7 = class {
8965
9511
  const group = {
8966
9512
  type: "group",
8967
9513
  id: newLayerId("group"),
8968
- name: _optionalChain([init, 'access', _183 => _183.name, 'optionalAccess', _184 => _184.trim, 'call', _185 => _185()]) || "Group",
9514
+ name: _optionalChain([init, 'access', _193 => _193.name, 'optionalAccess', _194 => _194.trim, 'call', _195 => _195()]) || "Group",
8969
9515
  visible: true,
8970
9516
  opacity: 1,
8971
9517
  blend,
@@ -9015,7 +9561,7 @@ var ImageEditorController = (_class7 = class {
9015
9561
  let mask;
9016
9562
  if (from === "selection") {
9017
9563
  const sel = this.state.selection;
9018
- if (!_optionalChain([sel, 'optionalAccess', _186 => _186.bounds])) throw new LayerOperationError("Nothing is selected; select first, or use reveal-all / hide-all.");
9564
+ if (!_optionalChain([sel, 'optionalAccess', _196 => _196.bounds])) throw new LayerOperationError("Nothing is selected; select first, or use reveal-all / hide-all.");
9019
9565
  mask = this.maskFromSelection(sel, props);
9020
9566
  if (layer.type === "pixel" && (layer.offset.x || layer.offset.y)) {
9021
9567
  mask = { ...mask, surface: _chunkCRMAXIUVcjs.translateSurface.call(void 0, mask.surface, -layer.offset.x, -layer.offset.y) };
@@ -9038,7 +9584,7 @@ var ImageEditorController = (_class7 = class {
9038
9584
  if (this.state.activeLayerId === id) this.state.activeTarget = "pixels";
9039
9585
  });
9040
9586
  }
9041
- /** Changes any layer mask's density, feather or enabled flag (pixels kept). Returns the mask. */
9587
+ /** Changes any layer mask's density, feather, enabled or linked flag (pixels kept). Returns the mask. */
9042
9588
  setLayerMaskProps(id, props, commitToHistory = true) {
9043
9589
  const layer = requireLayer(this.state.layers, id).layer;
9044
9590
  if (!layer.mask) throw new LayerOperationError(`Layer "${layer.name || id}" has no mask; add one with add_layer_mask.`);
@@ -9078,7 +9624,7 @@ var ImageEditorController = (_class7 = class {
9078
9624
  const next = { ...layer, surface: out };
9079
9625
  delete next.mask;
9080
9626
  delete next.source;
9081
- this.commitLayers(_chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, id, () => next), () => {
9627
+ this.commitLayers(_chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next), () => {
9082
9628
  if (this.state.activeLayerId === id) this.state.activeTarget = "pixels";
9083
9629
  });
9084
9630
  }
@@ -9093,36 +9639,36 @@ var ImageEditorController = (_class7 = class {
9093
9639
  const layer = loc.layer;
9094
9640
  if (layer.type !== "pixel") throw new LayerOperationError(`Layer via copy needs a pixel layer; "${id}" is a ${layer.type} layer.`);
9095
9641
  const sel = this.state.selection;
9096
- if (!_optionalChain([sel, 'optionalAccess', _187 => _187.bounds])) throw new LayerOperationError("Nothing is selected; select the pixels to copy first.");
9642
+ if (!_optionalChain([sel, 'optionalAccess', _197 => _197.bounds])) throw new LayerOperationError("Nothing is selected; select the pixels to copy first.");
9097
9643
  if (options.cut) requireUnlocked(layer, "pixels", "cut from it");
9098
9644
  const surface = this.surfaceOf(layer);
9099
9645
  const sb = sel.bounds;
9100
9646
  const src = { x: sb.x - layer.offset.x, y: sb.y - layer.offset.y, width: sb.width, height: sb.height };
9101
- const px = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, src);
9102
- const kept = options.cut ? new Uint8ClampedArray(px) : null;
9647
+ const px2 = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, src);
9648
+ const kept = options.cut ? new Uint8ClampedArray(px2) : null;
9103
9649
  for (let y = 0; y < sb.height; y++) {
9104
9650
  for (let x = 0; x < sb.width; x++) {
9105
9651
  const c = sel.data[(sb.y + y) * sel.width + sb.x + x];
9106
9652
  const i = (y * sb.width + x) * 4 + 3;
9107
9653
  if (kept) kept[i] = Math.round(kept[i] * (1 - c / 255));
9108
- px[i] = Math.round(px[i] * (c / 255));
9654
+ px2[i] = Math.round(px2[i] * (c / 255));
9109
9655
  }
9110
9656
  }
9111
9657
  const copy = {
9112
9658
  type: "pixel",
9113
9659
  id: newLayerId(),
9114
- name: _optionalChain([options, 'access', _188 => _188.name, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()]) || `${layer.name || "Layer"} ${options.cut ? "cut" : "copy"}`,
9660
+ name: _optionalChain([options, 'access', _198 => _198.name, 'optionalAccess', _199 => _199.trim, 'call', _200 => _200()]) || `${layer.name || "Layer"} ${options.cut ? "cut" : "copy"}`,
9115
9661
  visible: true,
9116
9662
  opacity: 1,
9117
9663
  blend: "normal",
9118
- surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: src.width, height: src.height, data: px }, 4, src.x, src.y),
9664
+ surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: src.width, height: src.height, data: px2 }, 4, src.x, src.y),
9119
9665
  offset: { ...layer.offset }
9120
9666
  };
9121
- let next = _chunkT422YCHRcjs.insertLayer.call(void 0, this.state.layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _191 => _191.parent, 'optionalAccess', _192 => _192.id]), () => ( null)), loc.index + 1);
9667
+ let next = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _201 => _201.parent, 'optionalAccess', _202 => _202.id]), () => ( null)), loc.index + 1);
9122
9668
  if (kept) {
9123
9669
  const cutLayer = { ...layer, surface: _chunkCRMAXIUVcjs.writeRegion.call(void 0, surface, src, kept) };
9124
9670
  delete cutLayer.source;
9125
- next = _chunkT422YCHRcjs.mapLayer.call(void 0, next, id, () => cutLayer);
9671
+ next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, next, id, () => cutLayer);
9126
9672
  }
9127
9673
  this.commitLayers(next, () => {
9128
9674
  this.state.activeLayerId = copy.id;
@@ -9130,24 +9676,152 @@ var ImageEditorController = (_class7 = class {
9130
9676
  });
9131
9677
  return copy.id;
9132
9678
  }
9679
+ // --- Free Transform ---
9680
+ __init52() {this.openTransform = null}
9681
+ /** The Free Transform in progress (see `beginFreeTransform`), or `null`. */
9682
+ getFreeTransform() {
9683
+ if (this.openTransform && !this.openTransform.isOpen) this.openTransform = null;
9684
+ return this.openTransform;
9685
+ }
9686
+ transformHost() {
9687
+ return {
9688
+ layers: () => this.state.layers,
9689
+ activeLayerId: () => this.state.activeLayerId,
9690
+ activeTarget: () => this.state.activeTarget,
9691
+ selection: () => _optionalChain([this, 'access', _203 => _203.state, 'access', _204 => _204.selection, 'optionalAccess', _205 => _205.bounds]) ? this.state.selection : null,
9692
+ canvas: () => this.naturalSize,
9693
+ pixelsOf: (layer) => this.surfaceOf(layer),
9694
+ capture: () => this.captureHistoryEntry(),
9695
+ show: (layers, selection, active) => {
9696
+ this.state.layers = layers;
9697
+ this.state.selection = selection;
9698
+ if (active !== this.state.activeLayerId) {
9699
+ this.state.activeLayerId = active;
9700
+ this.state.activeTarget = "pixels";
9701
+ }
9702
+ this.notify();
9703
+ },
9704
+ record: (before) => {
9705
+ if (this.isApplyingHistory) return;
9706
+ this.undoStack.push(before);
9707
+ if (this.undoStack.length > this.maxHistoryDepth) this.undoStack.shift();
9708
+ this.redoStack = [];
9709
+ this.trimHistoryBytes();
9710
+ this.notify();
9711
+ },
9712
+ restore: (before) => {
9713
+ const e = before;
9714
+ this.state.layers = e.layers;
9715
+ this.state.selection = e.selection;
9716
+ this.state.activeLayerId = e.activeLayerId;
9717
+ this.state.activeTarget = e.activeTarget;
9718
+ this.notify();
9719
+ }
9720
+ };
9721
+ }
9722
+ /**
9723
+ * Starts a Free Transform (Edit › Free Transform, Transform Selection, or a transform of a Layer
9724
+ * via Copy): of the layer's pixels with its linked mask, an unlinked mask alone, the selected
9725
+ * pixels or just the selection outline (see `FreeTransformInit`). Change the geometry with
9726
+ * `session.update` (live preview, no history), then `commit()` (one undo step) or `cancel()`.
9727
+ * Refused while another transform is open.
9728
+ */
9729
+ beginFreeTransform(init = {}) {
9730
+ if (this.getFreeTransform()) throw new LayerOperationError("A Free Transform is already open; commit or cancel it first.");
9731
+ const session = new FreeTransformSession(this.transformHost(), init);
9732
+ this.openTransform = session;
9733
+ this.notify();
9734
+ return session;
9735
+ }
9736
+ /**
9737
+ * Transforms in one step (agents, scripts): begins a Free Transform for `spec`, sets its corners
9738
+ * from exactly one of `matrix` (document-space affine), `corners` (where the frame's corners go:
9739
+ * distort / perspective) or `params` (scale, rotate, skew and move about a reference point), and
9740
+ * commits it as one undo step. Returns what changed and the new bounds.
9741
+ */
9742
+ transformLayer(spec) {
9743
+ const given = [spec.matrix, spec.corners, spec.params].filter((v) => v !== void 0).length;
9744
+ if (given > 1) throw new LayerOperationError("Give only one of matrix, corners and params.");
9745
+ if (!given && spec.warp === void 0) throw new LayerOperationError("Give matrix, corners or params (or a warp).");
9746
+ if (spec.matrix && !(Array.isArray(spec.matrix) && spec.matrix.length === 6 && spec.matrix.every(Number.isFinite))) {
9747
+ throw new LayerOperationError("matrix must be six finite numbers [a, b, c, d, e, f] (x' = a\xB7x + c\xB7y + e, y' = b\xB7x + d\xB7y + f).");
9748
+ }
9749
+ if (spec.matrix) {
9750
+ const [a, b, c, d] = spec.matrix;
9751
+ if (Math.abs(a * d - b * c) < 1e-9) throw new LayerOperationError("matrix is singular (it collapses the layer to a line); its determinant a\xB7d \u2212 b\xB7c must not be 0.");
9752
+ }
9753
+ const session = this.beginFreeTransform(spec);
9754
+ try {
9755
+ const g = identityTransform(session.box);
9756
+ const corners = spec.matrix ? cornersFromMatrix(session.box, spec.matrix) : spec.corners ? spec.corners : spec.params ? applyParams(g, spec.params) : g.corners;
9757
+ let warp = null;
9758
+ if (spec.warp) {
9759
+ if ("style" in spec.warp) {
9760
+ if (!_chunkDWGZUSEScjs.WARP_STYLES.includes(spec.warp.style)) throw new LayerOperationError(`Unknown warp style "${String(spec.warp.style)}". Styles: ${_chunkDWGZUSEScjs.WARP_STYLES.join(", ")}.`);
9761
+ warp = presetWarp(session.box, spec.warp);
9762
+ } else {
9763
+ if (!isValidWarp(spec.warp)) throw new LayerOperationError("mesh must have us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points, row by row.");
9764
+ warp = spec.warp;
9765
+ }
9766
+ }
9767
+ session.update({ corners, warp }, false);
9768
+ return session.commit();
9769
+ } catch (e) {
9770
+ session.cancel();
9771
+ throw e;
9772
+ }
9773
+ }
9774
+ /** Flips the layer (or its selected pixels, or the outline) about the frame's centre, exactly (one undo step). */
9775
+ flipLayer(axis, init = {}) {
9776
+ if (axis !== "horizontal" && axis !== "vertical") throw new LayerOperationError(`axis must be horizontal or vertical, got "${String(axis)}".`);
9777
+ const session = this.beginFreeTransform({ interpolation: "nearest", ...init });
9778
+ try {
9779
+ session.update({ corners: flipCorners(identityTransform(session.box), axis) }, false);
9780
+ return session.commit();
9781
+ } catch (e) {
9782
+ session.cancel();
9783
+ throw e;
9784
+ }
9785
+ }
9786
+ /**
9787
+ * Rotates by a quarter turn (90 clockwise, −90 counter-clockwise) or 180 about the frame's
9788
+ * centre, snapped so pixels land on whole pixels: exact, no resampling (one undo step).
9789
+ */
9790
+ rotateLayer90(turn, init = {}) {
9791
+ if (turn !== 90 && turn !== -90 && turn !== 180) throw new LayerOperationError(`turn must be 90, -90 or 180, got ${String(turn)}.`);
9792
+ const session = this.beginFreeTransform({ interpolation: "nearest", ...init });
9793
+ try {
9794
+ const b = session.box;
9795
+ const cx = b.x + b.width / 2;
9796
+ const cy = b.y + b.height / 2;
9797
+ const ox = turn === 180 ? 0 : Math.round(cx - b.height / 2) - (cx - b.height / 2);
9798
+ const oy = turn === 180 ? 0 : Math.round(cy - b.width / 2) - (cy - b.width / 2);
9799
+ const m = turn === 90 ? [0, 1, -1, 0, cx + cy + ox, cy - cx + oy] : turn === -90 ? [0, -1, 1, 0, cx - cy + ox, cy + cx + oy] : [-1, 0, 0, -1, 2 * cx, 2 * cy];
9800
+ session.update({ corners: cornersFromMatrix(b, m) }, false);
9801
+ return session.commit();
9802
+ } catch (e) {
9803
+ session.cancel();
9804
+ throw e;
9805
+ }
9806
+ }
9133
9807
  /** Adds a `develop` or `blur` filter to a pixel layer (one undo step). Returns the layer's filters. */
9134
9808
  addLayerFilter(id, filter) {
9135
9809
  const f = normalizeFilter(filter);
9136
9810
  const next = addLayerFilter(this.state.layers, id, f);
9137
9811
  this.commitLayers(next);
9138
- return _nullishCoalesce(_chunkT422YCHRcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9812
+ return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9139
9813
  }
9140
9814
  /** Changes one filter (one undo step, or none with `commitToHistory = false` during a drag). Returns the filters. */
9141
9815
  updateLayerFilter(id, filterId, changes, commitToHistory = true) {
9142
9816
  const next = updateLayerFilter(this.state.layers, id, filterId, changes);
9143
9817
  this.commitLayers(next, void 0, commitToHistory);
9144
- return _nullishCoalesce(_chunkT422YCHRcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9818
+ return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9145
9819
  }
9146
9820
  /** Removes one filter (one undo step). Returns the remaining filters. */
9147
9821
  removeLayerFilter(id, filterId) {
9148
9822
  const next = removeLayerFilter(this.state.layers, id, filterId);
9149
9823
  this.commitLayers(next);
9150
- return _nullishCoalesce(_chunkT422YCHRcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9824
+ return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9151
9825
  }
9152
9826
  // --- Layer effects ---
9153
9827
  /** A layer's effects (an empty, enabled list when it has none). */
@@ -9183,7 +9857,7 @@ var ImageEditorController = (_class7 = class {
9183
9857
  this.commitLayers(setLayerEffects(this.state.layers, id, effects), void 0, commitToHistory);
9184
9858
  return this.getLayerEffects(id);
9185
9859
  }
9186
- __init49() {this.patternIds = /* @__PURE__ */ new WeakMap()}
9860
+ __init53() {this.patternIds = /* @__PURE__ */ new WeakMap()}
9187
9861
  /** Changes whenever the document's pattern list is replaced (the compositor then drops its caches). */
9188
9862
  patternsVersion() {
9189
9863
  const list2 = this.state.patterns;
@@ -9201,7 +9875,7 @@ var ImageEditorController = (_class7 = class {
9201
9875
  }
9202
9876
  /** The light effects with "use global light" follow. */
9203
9877
  getGlobalLight() {
9204
- return { ..._nullishCoalesce(this.state.globalLight, () => ( _chunkT422YCHRcjs.DEFAULT_GLOBAL_LIGHT)) };
9878
+ return { ..._nullishCoalesce(this.state.globalLight, () => ( _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT)) };
9205
9879
  }
9206
9880
  /** Sets the global light (one undo step). `angle` -360..360°, `altitude` 0..90°. Returns it. */
9207
9881
  setGlobalLight(light, commitToHistory = true) {
@@ -9209,7 +9883,7 @@ var ImageEditorController = (_class7 = class {
9209
9883
  if (!(Number.isFinite(next.angle) && next.angle >= -360 && next.angle <= 360)) throw new LayerOperationError(`angle must be from -360 to 360 degrees, got ${next.angle}.`);
9210
9884
  if (!(Number.isFinite(next.altitude) && next.altitude >= 0 && next.altitude <= 90)) throw new LayerOperationError(`altitude must be from 0 to 90 degrees, got ${next.altitude}.`);
9211
9885
  if (commitToHistory) this.recordHistory();
9212
- if (next.angle === _chunkT422YCHRcjs.DEFAULT_GLOBAL_LIGHT.angle && next.altitude === _chunkT422YCHRcjs.DEFAULT_GLOBAL_LIGHT.altitude) delete this.state.globalLight;
9886
+ if (next.angle === _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT.angle && next.altitude === _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT.altitude) delete this.state.globalLight;
9213
9887
  else this.state.globalLight = next;
9214
9888
  this.notify();
9215
9889
  return this.getGlobalLight();
@@ -9217,7 +9891,7 @@ var ImageEditorController = (_class7 = class {
9217
9891
  /** Composites `layers` (in isolation) over `rect` into a surface, loading depth maps first. */
9218
9892
  async compositeToSurface(layers, rect) {
9219
9893
  const { width, height } = this.naturalSize;
9220
- if (_chunkT422YCHRcjs.flattenLayers.call(void 0, layers).some((l) => l.type === "annotation" && l.visible) && !this.renderer.canRasterize()) {
9894
+ if (_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).some((l) => l.type === "annotation" && l.visible) && !this.renderer.canRasterize()) {
9221
9895
  throw new LayerOperationError("Merging annotation layers needs a canvas (a browser); hide or delete them first, or merge in the browser.");
9222
9896
  }
9223
9897
  await this.renderer.prepareLayerAssets(layers, width, height);
@@ -9257,7 +9931,7 @@ var ImageEditorController = (_class7 = class {
9257
9931
  requireUnlocked(upper, "all", "merge it");
9258
9932
  requireUnlocked(lower, "pixels", "merge into it");
9259
9933
  let rect = _nullishCoalesce(unionRect(this.paintBounds(lower), upper.type === "adjustment" ? null : this.paintBounds(upper)), () => ( { x: 0, y: 0, width: 1, height: 1 }));
9260
- const reach = Math.max(_chunkT422YCHRcjs.effectsMargin.call(void 0, lower.effects), upper.type === "adjustment" ? 0 : _chunkT422YCHRcjs.effectsMargin.call(void 0, upper.effects));
9934
+ const reach = Math.max(_chunkWT6ZAWJPcjs.effectsMargin.call(void 0, lower.effects), upper.type === "adjustment" ? 0 : _chunkWT6ZAWJPcjs.effectsMargin.call(void 0, upper.effects));
9261
9935
  if (reach) rect = { x: rect.x - reach, y: rect.y - reach, width: rect.width + 2 * reach, height: rect.height + 2 * reach };
9262
9936
  const base = { ...lower, blend: "normal", opacity: 1 };
9263
9937
  delete base.clipped;
@@ -9268,8 +9942,8 @@ var ImageEditorController = (_class7 = class {
9268
9942
  delete merged.filters;
9269
9943
  delete merged.source;
9270
9944
  delete merged.effects;
9271
- let next = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
9272
- next = _chunkT422YCHRcjs.mapLayer.call(void 0, next, lower.id, () => merged);
9945
+ let next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
9946
+ next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, next, lower.id, () => merged);
9273
9947
  this.commitLayers(next, () => {
9274
9948
  this.state.activeLayerId = merged.id;
9275
9949
  this.state.activeTarget = "pixels";
@@ -9326,7 +10000,7 @@ var ImageEditorController = (_class7 = class {
9326
10000
  });
9327
10001
  return bg.id;
9328
10002
  }
9329
- __init50() {this.thumbCache = /* @__PURE__ */ new WeakMap()}
10003
+ __init54() {this.thumbCache = /* @__PURE__ */ new WeakMap()}
9330
10004
  /**
9331
10005
  * A small RGBA preview of a pixel layer over the canvas (or of its mask with `mask: true`),
9332
10006
  * longest side `maxSide` px, point-sampled; `null` for layers without pixels.
@@ -9345,7 +10019,7 @@ var ImageEditorController = (_class7 = class {
9345
10019
  const oy = layer.type === "pixel" ? layer.offset.y : 0;
9346
10020
  const key = `${tw}x${th}:${ox},${oy}`;
9347
10021
  let byKey = this.thumbCache.get(surface);
9348
- const hit = _optionalChain([byKey, 'optionalAccess', _193 => _193.get, 'call', _194 => _194(key)]);
10022
+ const hit = _optionalChain([byKey, 'optionalAccess', _206 => _206.get, 'call', _207 => _207(key)]);
9349
10023
  if (hit) return hit;
9350
10024
  const out = new Uint8ClampedArray(tw * th * 4);
9351
10025
  for (let y = 0; y < th; y++) {
@@ -9433,7 +10107,7 @@ var ImageEditorController = (_class7 = class {
9433
10107
  if (!layer.visible) throw new LayerOperationError(`Layer "${layer.name || id}" is hidden; show it before you ${action}.`);
9434
10108
  const offset = layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
9435
10109
  const surface = ch === "mask" ? layer.mask.surface : this.surfaceOf(layer);
9436
- const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access', _195 => _195.locks, 'optionalAccess', _196 => _196.transparency]));
10110
+ const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access', _208 => _208.locks, 'optionalAccess', _209 => _209.transparency]));
9437
10111
  return { id, layer, channel: ch, offset, surface, lockTransparency };
9438
10112
  }
9439
10113
  /** The layer with its pixels (or mask) replaced by `surface`. */
@@ -9470,7 +10144,7 @@ var ImageEditorController = (_class7 = class {
9470
10144
  opacity: brush.opacity,
9471
10145
  blend: target.channel === "mask" ? "normal" : brush.blend,
9472
10146
  lockTransparency: target.lockTransparency,
9473
- selection: _optionalChain([this, 'access', _197 => _197.state, 'access', _198 => _198.selection, 'optionalAccess', _199 => _199.bounds]) ? this.state.selection : null,
10147
+ selection: _optionalChain([this, 'access', _210 => _210.state, 'access', _211 => _211.selection, 'optionalAccess', _212 => _212.bounds]) ? this.state.selection : null,
9474
10148
  offset: target.offset
9475
10149
  };
9476
10150
  if (tool === "mixer") return new PaintStrokeSession(this, target, this.mixerStroke(init, brush), apply);
@@ -9495,12 +10169,12 @@ var ImageEditorController = (_class7 = class {
9495
10169
  }
9496
10170
  /** @internal Shows a stroke's live surface (no history). */
9497
10171
  _strokeUpdate(layerId, channel, surface, rects) {
9498
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
10172
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
9499
10173
  this.notify(rects);
9500
10174
  }
9501
10175
  /** @internal Commits a finished stroke as one undo step (`before` is the pre-stroke state). */
9502
10176
  _strokeCommit(before, layerId, channel, surface) {
9503
- if (surface) this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
10177
+ if (surface) this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
9504
10178
  else this.state.layers = before.layers;
9505
10179
  if (surface && !this.isApplyingHistory) {
9506
10180
  this.undoStack.push(before);
@@ -9522,7 +10196,7 @@ var ImageEditorController = (_class7 = class {
9522
10196
  paintStroke(init) {
9523
10197
  if (!Array.isArray(init.points) || !init.points.length) throw new LayerOperationError("points must hold at least one { x, y } point.");
9524
10198
  for (const p of init.points) {
9525
- if (!Number.isFinite(_optionalChain([p, 'optionalAccess', _200 => _200.x])) || !Number.isFinite(_optionalChain([p, 'optionalAccess', _201 => _201.y]))) throw new LayerOperationError("Every point needs finite x and y (document pixels).");
10199
+ if (!Number.isFinite(_optionalChain([p, 'optionalAccess', _213 => _213.x])) || !Number.isFinite(_optionalChain([p, 'optionalAccess', _214 => _214.y]))) throw new LayerOperationError("Every point needs finite x and y (document pixels).");
9526
10200
  }
9527
10201
  const session = this.beginStroke(init);
9528
10202
  session.push(init.points);
@@ -9550,8 +10224,8 @@ var ImageEditorController = (_class7 = class {
9550
10224
  const opacity = _nullishCoalesce(options.opacity, () => ( 1));
9551
10225
  if (!(opacity >= 0 && opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
9552
10226
  const blend = _nullishCoalesce(parseBlend(options.blend), () => ( "normal"));
9553
- const sel = options.useSelection !== false && _optionalChain([this, 'access', _202 => _202.state, 'access', _203 => _203.selection, 'optionalAccess', _204 => _204.bounds]) ? this.state.selection : null;
9554
- const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _205 => _205.bounds]), () => ( { x: 0, y: 0, width, height }));
10227
+ const sel = options.useSelection !== false && _optionalChain([this, 'access', _215 => _215.state, 'access', _216 => _216.selection, 'optionalAccess', _217 => _217.bounds]) ? this.state.selection : null;
10228
+ const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _218 => _218.bounds]), () => ( { x: 0, y: 0, width, height }));
9555
10229
  const coverage = new (0, _chunkZZOTHJ4Kcjs.CoverageMap)();
9556
10230
  const ones = new Float32Array(region.width * region.height);
9557
10231
  if (sel) {
@@ -9577,7 +10251,7 @@ var ImageEditorController = (_class7 = class {
9577
10251
  offset: target.offset
9578
10252
  };
9579
10253
  const surface = paintCoverageInto(target.surface, coverage, apply, [region]);
9580
- const next = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => this.withSurface(l, target.channel, surface));
10254
+ const next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => this.withSurface(l, target.channel, surface));
9581
10255
  this.commitLayers(next);
9582
10256
  return { layerId: target.id, channel: target.channel, bounds: region, dabs: 0 };
9583
10257
  }
@@ -9599,12 +10273,12 @@ var ImageEditorController = (_class7 = class {
9599
10273
  const target = this.developLayer();
9600
10274
  let layers = this.state.layers;
9601
10275
  if (target && (DEVELOP_KEYS.some((k) => k in partial) || "process" in partial)) {
9602
- layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, target.id, (l) => withDevelop(l, partial));
10276
+ layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, target.id, (l) => withDevelop(l, partial));
9603
10277
  }
9604
10278
  if ("blur" in partial && typeof partial.blur === "number") {
9605
10279
  const blur = Math.max(0, partial.blur);
9606
10280
  if (this.state.legacyOutputBlur !== void 0) this.state.legacyOutputBlur = blur;
9607
- else if (target) layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, target.id, (l) => withBlur(l, blur));
10281
+ else if (target) layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, target.id, (l) => withBlur(l, blur));
9608
10282
  }
9609
10283
  if ("opacity" in partial && typeof partial.opacity === "number") {
9610
10284
  this.state.outputOpacity = Math.min(1, Math.max(0, partial.opacity));
@@ -9634,7 +10308,7 @@ var ImageEditorController = (_class7 = class {
9634
10308
  this.recordHistory();
9635
10309
  const target = this.developLayer();
9636
10310
  if (target) {
9637
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0,
10311
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0,
9638
10312
  this.state.layers,
9639
10313
  target.id,
9640
10314
  (l) => withBlur(withDevelop(l, { ...DEFAULT_ADJUSTMENTS, process: LATEST_PROCESS_VERSION }), 0)
@@ -9654,7 +10328,7 @@ var ImageEditorController = (_class7 = class {
9654
10328
  return this.getAdjustmentLayers().find((l) => l.id === id);
9655
10329
  }
9656
10330
  adjustmentNodes(layers = this.state.layers) {
9657
- return _chunkT422YCHRcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "adjustment");
10331
+ return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "adjustment");
9658
10332
  }
9659
10333
  /**
9660
10334
  * Where a new layer goes when no position is given: directly above the topmost layer that is
@@ -9668,26 +10342,26 @@ var ImageEditorController = (_class7 = class {
9668
10342
  /** Inserts `node` by `aboveId` / `parentId` / adjustment index / default position. */
9669
10343
  placeLayer(layers, node, where) {
9670
10344
  if (where.aboveId) {
9671
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, layers, where.aboveId);
9672
- if (loc) return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _206 => _206.parent, 'optionalAccess', _207 => _207.id]), () => ( null)), loc.index + 1);
10345
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, where.aboveId);
10346
+ if (loc) return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _219 => _219.parent, 'optionalAccess', _220 => _220.id]), () => ( null)), loc.index + 1);
9673
10347
  }
9674
10348
  if (where.parentId) {
9675
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, layers, where.parentId);
9676
- if (loc && loc.layer.type === "group") return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, node, loc.layer.id);
10349
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, where.parentId);
10350
+ if (loc && loc.layer.type === "group") return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, loc.layer.id);
9677
10351
  }
9678
10352
  if (where.adjustmentIndex !== void 0) {
9679
10353
  const nodes = this.adjustmentNodes(layers);
9680
10354
  const at = Math.max(0, Math.min(nodes.length, Math.round(where.adjustmentIndex)));
9681
10355
  if (at < nodes.length) {
9682
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, layers, nodes[at].id);
9683
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _208 => _208.parent, 'optionalAccess', _209 => _209.id]), () => ( null)), loc.index);
10356
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, nodes[at].id);
10357
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _221 => _221.parent, 'optionalAccess', _222 => _222.id]), () => ( null)), loc.index);
9684
10358
  }
9685
10359
  if (nodes.length) {
9686
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, layers, nodes[nodes.length - 1].id);
9687
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _210 => _210.parent, 'optionalAccess', _211 => _211.id]), () => ( null)), loc.index + 1);
10360
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, nodes[nodes.length - 1].id);
10361
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _223 => _223.parent, 'optionalAccess', _224 => _224.id]), () => ( null)), loc.index + 1);
9688
10362
  }
9689
10363
  }
9690
- return _chunkT422YCHRcjs.insertLayer.call(void 0, layers, node, null, this.defaultInsertIndex(layers));
10364
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, null, this.defaultInsertIndex(layers));
9691
10365
  }
9692
10366
  /** `setAdjustments({ layers })`: updates nodes by id in place, removes missing ones, adds new ones. */
9693
10367
  replaceAdjustmentNodes(layers, next) {
@@ -9696,7 +10370,7 @@ var ImageEditorController = (_class7 = class {
9696
10370
  let out = layers;
9697
10371
  for (const node of this.adjustmentNodes(layers)) {
9698
10372
  const update = byId.get(node.id);
9699
- out = _chunkT422YCHRcjs.mapLayer.call(void 0, out, node.id, () => update ? mergeAdjustmentNode(node, update, width, height) : null);
10373
+ out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, node.id, () => update ? mergeAdjustmentNode(node, update, width, height) : null);
9700
10374
  }
9701
10375
  const existing = new Set(this.adjustmentNodes(out).map((n) => n.id));
9702
10376
  for (const l of next) {
@@ -9715,7 +10389,7 @@ var ImageEditorController = (_class7 = class {
9715
10389
  */
9716
10390
  addAdjustmentLayer(init, index) {
9717
10391
  const spec = typeof init === "string" ? { kind: init } : init;
9718
- const ids = new Set(_chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
10392
+ const ids = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
9719
10393
  const layer = createAdjustmentLayer(spec.kind, {
9720
10394
  id: spec.id && !ids.has(spec.id) ? spec.id : void 0,
9721
10395
  name: spec.name,
@@ -9744,7 +10418,7 @@ var ImageEditorController = (_class7 = class {
9744
10418
  * Returns false for an unknown id.
9745
10419
  */
9746
10420
  updateAdjustmentLayer(id, update, commitToHistory = true) {
9747
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, id);
10421
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id);
9748
10422
  if (!loc || loc.layer.type !== "adjustment") return false;
9749
10423
  const { width, height } = this.naturalSize;
9750
10424
  const node = loc.layer;
@@ -9772,16 +10446,16 @@ var ImageEditorController = (_class7 = class {
9772
10446
  if (mask) next.mask = mask;
9773
10447
  else delete next.mask;
9774
10448
  }
9775
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, id, () => next);
10449
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next);
9776
10450
  this.notify();
9777
10451
  return true;
9778
10452
  }
9779
10453
  /** Removes a layer as one undo step. Returns false for an unknown id. */
9780
10454
  removeAdjustmentLayer(id) {
9781
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, id);
10455
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id);
9782
10456
  if (!loc || loc.layer.type !== "adjustment") return false;
9783
10457
  this.recordHistory();
9784
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
10458
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
9785
10459
  if (this.state.activeLayerId === id) this.state.activeLayerId = null;
9786
10460
  this.notify();
9787
10461
  return true;
@@ -9794,9 +10468,9 @@ var ImageEditorController = (_class7 = class {
9794
10468
  if (to === from) return layers;
9795
10469
  const node = nodes[from];
9796
10470
  const anchor = nodes[to];
9797
- const without = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, id, () => null);
9798
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, without, anchor.id);
9799
- return _chunkT422YCHRcjs.insertLayer.call(void 0, without, node, _nullishCoalesce(_optionalChain([loc, 'access', _212 => _212.parent, 'optionalAccess', _213 => _213.id]), () => ( null)), to > from ? loc.index + 1 : loc.index);
10471
+ const without = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
10472
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, without, anchor.id);
10473
+ return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, without, node, _nullishCoalesce(_optionalChain([loc, 'access', _225 => _225.parent, 'optionalAccess', _226 => _226.id]), () => ( null)), to > from ? loc.index + 1 : loc.index);
9800
10474
  }
9801
10475
  /** Moves a layer to `toIndex` among the adjustment layers (0 = bottom) as one undo step. Returns false if nothing moved. */
9802
10476
  moveAdjustmentLayer(id, toIndex) {
@@ -9821,7 +10495,7 @@ var ImageEditorController = (_class7 = class {
9821
10495
  if (!nodes.length) return;
9822
10496
  this.recordHistory();
9823
10497
  let layers = this.state.layers;
9824
- for (const n of nodes) layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, n.id, () => null);
10498
+ for (const n of nodes) layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, n.id, () => null);
9825
10499
  this.state.layers = layers;
9826
10500
  if (nodes.some((n) => n.id === this.state.activeLayerId)) this.state.activeLayerId = null;
9827
10501
  this.notify();
@@ -9832,7 +10506,7 @@ var ImageEditorController = (_class7 = class {
9832
10506
  return _nullishCoalesce(this.state.selection, () => ( null));
9833
10507
  }
9834
10508
  get hasSelection() {
9835
- return Boolean(_optionalChain([this, 'access', _214 => _214.state, 'access', _215 => _215.selection, 'optionalAccess', _216 => _216.bounds]));
10509
+ return Boolean(_optionalChain([this, 'access', _227 => _227.state, 'access', _228 => _228.selection, 'optionalAccess', _229 => _229.bounds]));
9836
10510
  }
9837
10511
  get naturalSize() {
9838
10512
  return {
@@ -9922,7 +10596,7 @@ var ImageEditorController = (_class7 = class {
9922
10596
  try {
9923
10597
  const canvas = await this.renderSource();
9924
10598
  const ctx = canvas.getContext("2d");
9925
- const data2 = _optionalChain([ctx, 'optionalAccess', _217 => _217.getImageData, 'optionalCall', _218 => _218(0, 0, width, height)]);
10599
+ const data2 = _optionalChain([ctx, 'optionalAccess', _230 => _230.getImageData, 'optionalCall', _231 => _231(0, 0, width, height)]);
9926
10600
  if (data2 && data2.data && data2.data.length >= width * height * 4) {
9927
10601
  base = { width, height, data: data2.data };
9928
10602
  this.samplePixels = base;
@@ -9988,7 +10662,7 @@ var ImageEditorController = (_class7 = class {
9988
10662
  /** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
9989
10663
  modifySelection(op, radius) {
9990
10664
  const sel = this.state.selection;
9991
- if (!_optionalChain([sel, 'optionalAccess', _219 => _219.bounds])) return false;
10665
+ if (!_optionalChain([sel, 'optionalAccess', _232 => _232.bounds])) return false;
9992
10666
  return this.setSelection(modifySelection(sel, op, radius));
9993
10667
  }
9994
10668
  /**
@@ -9997,7 +10671,7 @@ var ImageEditorController = (_class7 = class {
9997
10671
  */
9998
10672
  async refineSelection(params, options = {}) {
9999
10673
  const sel = this.state.selection;
10000
- if (!_optionalChain([sel, 'optionalAccess', _220 => _220.bounds])) return false;
10674
+ if (!_optionalChain([sel, 'optionalAccess', _233 => _233.bounds])) return false;
10001
10675
  const pixels = (_nullishCoalesce(params.radius, () => ( 0))) > 0 ? await this.requirePixels(options) : null;
10002
10676
  return this.setSelection(refineSelection(pixels, sel, params));
10003
10677
  }
@@ -10014,7 +10688,7 @@ var ImageEditorController = (_class7 = class {
10014
10688
  const canvas = this.renderer.createCanvas(w, h);
10015
10689
  const ctx = canvas.getContext("2d");
10016
10690
  if (ctx) ctx.drawImage(img, 0, 0, w, h);
10017
- const data = _optionalChain([ctx, 'optionalAccess', _221 => _221.getImageData, 'optionalCall', _222 => _222(0, 0, w, h)]);
10691
+ const data = _optionalChain([ctx, 'optionalAccess', _234 => _234.getImageData, 'optionalCall', _235 => _235(0, 0, w, h)]);
10018
10692
  if (!data) throw new Error("The mask image pixels are not available (no canvas access); pass pixels.");
10019
10693
  pixels = { width: w, height: h, data: data.data };
10020
10694
  } else {
@@ -10042,14 +10716,14 @@ var ImageEditorController = (_class7 = class {
10042
10716
  */
10043
10717
  applySelectionAsLayerMask(layerId, props = {}) {
10044
10718
  const sel = this.state.selection;
10045
- if (!_optionalChain([sel, 'optionalAccess', _223 => _223.bounds]) || !this.getAdjustmentLayer(layerId)) return false;
10719
+ if (!_optionalChain([sel, 'optionalAccess', _236 => _236.bounds]) || !this.getAdjustmentLayer(layerId)) return false;
10046
10720
  return this.setLayerMask(layerId, this.maskFromSelection(sel, props));
10047
10721
  }
10048
10722
  setLayerMask(layerId, mask, commitToHistory = true) {
10049
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, layerId);
10723
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, layerId);
10050
10724
  if (!loc) return false;
10051
10725
  if (commitToHistory) this.recordHistory();
10052
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => {
10726
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => {
10053
10727
  const next = { ...l };
10054
10728
  if (mask) next.mask = mask;
10055
10729
  else delete next.mask;
@@ -10073,7 +10747,7 @@ var ImageEditorController = (_class7 = class {
10073
10747
  /** Load Selection from a layer mask (its pixels; density and feather are not applied). */
10074
10748
  selectionFromLayerMask(layerId, mode = "replace") {
10075
10749
  const layer = this.getLayer(layerId);
10076
- if (!_optionalChain([layer, 'optionalAccess', _224 => _224.mask]) || layer.mask.source) return false;
10750
+ if (!_optionalChain([layer, 'optionalAccess', _237 => _237.mask]) || layer.mask.source) return false;
10077
10751
  const { width, height } = this.naturalSize;
10078
10752
  const ox = layer.type === "pixel" ? layer.offset.x : 0;
10079
10753
  const oy = layer.type === "pixel" ? layer.offset.y : 0;
@@ -10106,10 +10780,10 @@ var ImageEditorController = (_class7 = class {
10106
10780
  if (target) {
10107
10781
  const merged = { ...this.state.depthMask, ...partial };
10108
10782
  merged.depthRange = [...merged.depthRange];
10109
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10783
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10110
10784
  const next = { ...l };
10111
10785
  if (isDefaultDepthMask(merged)) {
10112
- if (_optionalChain([next, 'access', _225 => _225.mask, 'optionalAccess', _226 => _226.source])) delete next.mask;
10786
+ if (_optionalChain([next, 'access', _238 => _238.mask, 'optionalAccess', _239 => _239.source])) delete next.mask;
10113
10787
  } else next.mask = depthRasterMask(merged);
10114
10788
  return next;
10115
10789
  });
@@ -10119,8 +10793,8 @@ var ImageEditorController = (_class7 = class {
10119
10793
  resetDepthMask() {
10120
10794
  this.recordHistory();
10121
10795
  const target = this.developLayer();
10122
- if (_optionalChain([target, 'optionalAccess', _227 => _227.mask, 'optionalAccess', _228 => _228.source])) {
10123
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10796
+ if (_optionalChain([target, 'optionalAccess', _240 => _240.mask, 'optionalAccess', _241 => _241.source])) {
10797
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10124
10798
  const next = { ...l };
10125
10799
  delete next.mask;
10126
10800
  return next;
@@ -10130,7 +10804,7 @@ var ImageEditorController = (_class7 = class {
10130
10804
  }
10131
10805
  // --- Annotations & Layers ---
10132
10806
  annotationLayer(id) {
10133
- return _chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).find(
10807
+ return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).find(
10134
10808
  (l) => l.type === "annotation" && l.annotation.id === id
10135
10809
  );
10136
10810
  }
@@ -10140,8 +10814,8 @@ var ImageEditorController = (_class7 = class {
10140
10814
  const id = `ann_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
10141
10815
  const fullAnnotation = { ...annotation, id };
10142
10816
  const layer = annotationLayerFor(fullAnnotation);
10143
- const loc = placement.aboveId ? _chunkT422YCHRcjs.findLayer.call(void 0, this.state.layers, placement.aboveId) : null;
10144
- this.state.layers = loc ? _chunkT422YCHRcjs.insertLayer.call(void 0, this.state.layers, layer, _nullishCoalesce(_optionalChain([loc, 'access', _229 => _229.parent, 'optionalAccess', _230 => _230.id]), () => ( null)), loc.index + 1) : _chunkT422YCHRcjs.insertLayer.call(void 0, this.state.layers, layer, null);
10817
+ const loc = placement.aboveId ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, placement.aboveId) : null;
10818
+ this.state.layers = loc ? _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, layer, _nullishCoalesce(_optionalChain([loc, 'access', _242 => _242.parent, 'optionalAccess', _243 => _243.id]), () => ( null)), loc.index + 1) : _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, layer, null);
10145
10819
  this.state.selectedAnnotationId = id;
10146
10820
  this.notify();
10147
10821
  return id;
@@ -10154,14 +10828,14 @@ var ImageEditorController = (_class7 = class {
10154
10828
  if (layer) {
10155
10829
  const annotation = { ...layer.annotation, ...partial, id };
10156
10830
  const name = layer.name === annotationLayerName(layer.annotation) ? annotationLayerName(annotation) : layer.name;
10157
- this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => ({ ...layer, annotation, name }));
10831
+ this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => ({ ...layer, annotation, name }));
10158
10832
  }
10159
10833
  this.notify();
10160
10834
  }
10161
10835
  removeAnnotation(id) {
10162
10836
  this.recordHistory();
10163
10837
  const layer = this.annotationLayer(id);
10164
- if (layer) this.state.layers = _chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => null);
10838
+ if (layer) this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => null);
10165
10839
  if (this.state.selectedAnnotationId === id) {
10166
10840
  this.state.selectedAnnotationId = null;
10167
10841
  }
@@ -10170,7 +10844,7 @@ var ImageEditorController = (_class7 = class {
10170
10844
  clearAnnotations() {
10171
10845
  this.recordHistory();
10172
10846
  let layers = this.state.layers;
10173
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, l.id, () => null);
10847
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => null);
10174
10848
  this.state.layers = layers;
10175
10849
  this.state.selectedAnnotationId = null;
10176
10850
  this.notify();
@@ -10210,7 +10884,7 @@ var ImageEditorController = (_class7 = class {
10210
10884
  this.notify();
10211
10885
  }
10212
10886
  // --- Rendering & Export ---
10213
- __init51() {this.blankSource = null}
10887
+ __init55() {this.blankSource = null}
10214
10888
  /**
10215
10889
  * What the renderer draws from: the source image, or, for a document without one (an opened
10216
10890
  * PSD, a v3 document loaded on its own), a transparent canvas of the document size, since every
@@ -10247,9 +10921,9 @@ var ImageEditorController = (_class7 = class {
10247
10921
  return this.renderer.createCanvas(1, 1);
10248
10922
  }
10249
10923
  this.syncViews();
10250
- if (_optionalChain([options, 'optionalAccess', _231 => _231.layerIds])) {
10924
+ if (_optionalChain([options, 'optionalAccess', _244 => _244.layerIds])) {
10251
10925
  const keep = new Set(options.layerIds);
10252
- const layers = _chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => keep.has(l.id));
10926
+ const layers = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => keep.has(l.id));
10253
10927
  return this.renderer.renderExport(source, { ...this.state, layers }, options);
10254
10928
  }
10255
10929
  return this.renderer.renderExport(source, this.state, options);
@@ -10359,10 +11033,10 @@ var ImageEditorController = (_class7 = class {
10359
11033
  /** No source image, and no layer reading one (an opened PSD): the layers are the whole document. */
10360
11034
  isSourceless() {
10361
11035
  if (this.imageElement || this.state.sourceUrl || !this.state.layers.length) return false;
10362
- return !_chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).some((l) => l.type === "pixel" && l.source === "document");
11036
+ return !_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).some((l) => l.type === "pixel" && l.source === "document");
10363
11037
  }
10364
11038
  get isMultiLayer() {
10365
- return _chunkT422YCHRcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => l.type === "pixel" || l.type === "group").length > 1;
11039
+ return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => l.type === "pixel" || l.type === "group").length > 1;
10366
11040
  }
10367
11041
  /**
10368
11042
  * Applies an inpainted result (natural image space, see `toSourceDataURL`) as ONE undoable step.
@@ -10377,10 +11051,10 @@ var ImageEditorController = (_class7 = class {
10377
11051
  return;
10378
11052
  }
10379
11053
  const { width, height } = this.naturalSize;
10380
- let px = await this.decodeImage(newDataUrl);
10381
- if (px.width !== width || px.height !== height) px = resizePixels(px, width, height);
10382
- const data = new Uint8ClampedArray(px.data);
10383
- const sel = _optionalChain([this, 'access', _232 => _232.state, 'access', _233 => _233.selection, 'optionalAccess', _234 => _234.bounds]) ? this.state.selection : null;
11054
+ let px2 = await this.decodeImage(newDataUrl);
11055
+ if (px2.width !== width || px2.height !== height) px2 = resizePixels(px2, width, height);
11056
+ const data = new Uint8ClampedArray(px2.data);
11057
+ const sel = _optionalChain([this, 'access', _245 => _245.state, 'access', _246 => _246.selection, 'optionalAccess', _247 => _247.bounds]) ? this.state.selection : null;
10384
11058
  if (sel) for (let p = 0, i = 3; p < width * height; p++, i += 4) data[i] = Math.round(data[i] * sel.data[p] / 255);
10385
11059
  return this.addPixelLayer({ name: "Inpaint", pixels: { width, height, data } });
10386
11060
  }
@@ -10400,10 +11074,10 @@ var ImageEditorController = (_class7 = class {
10400
11074
  if (!target) throw new LayerOperationError("There is no pixel layer to mask.");
10401
11075
  requireUnlocked(target, "all", "mask it");
10402
11076
  const { width, height } = this.naturalSize;
10403
- let px = await this.decodeImage(newDataUrl);
10404
- if (px.width !== width || px.height !== height) px = resizePixels(px, width, height);
11077
+ let px2 = await this.decodeImage(newDataUrl);
11078
+ if (px2.width !== width || px2.height !== height) px2 = resizePixels(px2, width, height);
10405
11079
  const alpha = new Uint8ClampedArray(width * height);
10406
- for (let p = 0; p < alpha.length; p++) alpha[p] = px.data[p * 4 + 3];
11080
+ for (let p = 0; p < alpha.length; p++) alpha[p] = px2.data[p * 4 + 3];
10407
11081
  let surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width, height, data: alpha }, 1, 0, 0, 0);
10408
11082
  if (target.offset.x || target.offset.y) surface = _chunkCRMAXIUVcjs.translateSurface.call(void 0, surface, -target.offset.x, -target.offset.y);
10409
11083
  this.commitLayers(setLayerMask(this.state.layers, target.id, { surface, defaultValue: 0 }));
@@ -10432,7 +11106,7 @@ var ImageEditorController = (_class7 = class {
10432
11106
  if (layer.locks) next.locks = layer.locks;
10433
11107
  if (this.state.selectedAnnotationId === layer.annotation.id) this.state.selectedAnnotationId = null;
10434
11108
  } else if (layer.type === "pixel") {
10435
- if (!_optionalChain([layer, 'access', _235 => _235.filters, 'optionalAccess', _236 => _236.length])) throw new LayerOperationError(`Layer "${layer.name || id}" is already pixels with no filters to bake.`);
11109
+ if (!_optionalChain([layer, 'access', _248 => _248.filters, 'optionalAccess', _249 => _249.length])) throw new LayerOperationError(`Layer "${layer.name || id}" is already pixels with no filters to bake.`);
10436
11110
  requireUnlocked(layer, "pixels", "rasterize it");
10437
11111
  const spatial = layer.filters.some((f) => f.enabled && f.kind === "blur");
10438
11112
  const content = { ...layer, visible: true, opacity: 1, blend: "normal" };
@@ -10450,7 +11124,7 @@ var ImageEditorController = (_class7 = class {
10450
11124
  } else {
10451
11125
  throw new LayerOperationError(`Only annotation layers and pixel layers with filters rasterize; "${layer.name || id}" is a ${layer.type} layer. Merge it down or flatten instead.`);
10452
11126
  }
10453
- this.commitLayers(_chunkT422YCHRcjs.mapLayer.call(void 0, this.state.layers, id, () => next));
11127
+ this.commitLayers(_chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next));
10454
11128
  return id;
10455
11129
  }
10456
11130
  // --- PSD ---
@@ -10477,7 +11151,7 @@ var ImageEditorController = (_class7 = class {
10477
11151
  delete s.legacyOutputBlur;
10478
11152
  s.selection = null;
10479
11153
  s.selectedAnnotationId = null;
10480
- const pixels = _chunkT422YCHRcjs.flattenLayers.call(void 0, result.layers).filter((l) => l.type === "pixel");
11154
+ const pixels = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, result.layers).filter((l) => l.type === "pixel");
10481
11155
  s.activeLayerId = pixels.length ? pixels[pixels.length - 1].id : null;
10482
11156
  s.activeTarget = "pixels";
10483
11157
  this.psdResolution = result.resolution;
@@ -10488,7 +11162,7 @@ var ImageEditorController = (_class7 = class {
10488
11162
  this.lastLoadProblems = result.warnings;
10489
11163
  this.notify();
10490
11164
  return {
10491
- layerIds: _chunkT422YCHRcjs.flattenLayers.call(void 0, result.layers).map((l) => l.id),
11165
+ layerIds: _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, result.layers).map((l) => l.id),
10492
11166
  warnings: result.warnings,
10493
11167
  width: result.width,
10494
11168
  height: result.height,
@@ -10513,7 +11187,7 @@ var ImageEditorController = (_class7 = class {
10513
11187
  const compositor = new LayerCompositor();
10514
11188
  const bakeMask = (layer) => {
10515
11189
  const mask = layer.mask;
10516
- if (!_optionalChain([mask, 'optionalAccess', _237 => _237.source])) return mask;
11190
+ if (!_optionalChain([mask, 'optionalAccess', _250 => _250.source])) return mask;
10517
11191
  add("Parametric (depth) masks were baked into pixel masks", layer.name);
10518
11192
  const plain3 = { ...layer, mask: { ...mask, density: 1, feather: 0, enabled: true } };
10519
11193
  const ox = layer.type === "pixel" ? layer.offset.x : 0;
@@ -10530,7 +11204,7 @@ var ImageEditorController = (_class7 = class {
10530
11204
  };
10531
11205
  const prepare = async (layer) => {
10532
11206
  const p = await prepareLayer(layer);
10533
- if (_optionalChain([p, 'optionalAccess', _238 => _238.blend]) === "pigment") add("The Pigment blend mode has no PSD equivalent and was written as Normal", layer.name);
11207
+ if (_optionalChain([p, 'optionalAccess', _251 => _251.blend]) === "pigment") add("The Pigment blend mode has no PSD equivalent and was written as Normal", layer.name);
10534
11208
  return p;
10535
11209
  };
10536
11210
  const prepareLayer = async (layer) => {
@@ -10577,7 +11251,7 @@ var ImageEditorController = (_class7 = class {
10577
11251
  out.surface = this.surfaceOf(layer);
10578
11252
  delete out.source;
10579
11253
  }
10580
- const active = _nullishCoalesce(_optionalChain([layer, 'access', _239 => _239.filters, 'optionalAccess', _240 => _240.filter, 'call', _241 => _241(isActiveFilter)]), () => ( []));
11254
+ const active = _nullishCoalesce(_optionalChain([layer, 'access', _252 => _252.filters, 'optionalAccess', _253 => _253.filter, 'call', _254 => _254(isActiveFilter)]), () => ( []));
10581
11255
  if (active.length) {
10582
11256
  add("Layer filters (develop, blur) were baked into the pixels", layer.name);
10583
11257
  const content = { ...out, visible: true, opacity: 1, blend: "normal" };
@@ -10588,7 +11262,7 @@ var ImageEditorController = (_class7 = class {
10588
11262
  const data = compositor.composite([content], canvas, sources);
10589
11263
  out = { ...out, surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, -layer.offset.x, -layer.offset.y) };
10590
11264
  }
10591
- if (_optionalChain([layer, 'access', _242 => _242.filters, 'optionalAccess', _243 => _243.some, 'call', _244 => _244((f) => !f.enabled)])) add("Disabled layer filters were left out", layer.name);
11265
+ if (_optionalChain([layer, 'access', _255 => _255.filters, 'optionalAccess', _256 => _256.some, 'call', _257 => _257((f) => !f.enabled)])) add("Disabled layer filters were left out", layer.name);
10592
11266
  delete out.filters;
10593
11267
  const mask = bakeMask(layer);
10594
11268
  if (mask) out.mask = mask;
@@ -10641,16 +11315,16 @@ var ImageEditorController = (_class7 = class {
10641
11315
  );
10642
11316
  }
10643
11317
  layers = resizeLegacyMasks(layers, prev, next.dimensions);
10644
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) {
11318
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
10645
11319
  if (l.type === "annotation") {
10646
- layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, annotation: scaleAnnotation(l.annotation, sx, sy) }));
11320
+ layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, annotation: scaleAnnotation(l.annotation, sx, sy) }));
10647
11321
  }
10648
11322
  }
10649
11323
  }
10650
11324
  const bg = developTarget(layers, null);
10651
- if (bg && bg.source !== "document") layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, bg.id, () => ({ ...bg, source: "document" }));
11325
+ if (bg && bg.source !== "document") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, bg.id, () => ({ ...bg, source: "document" }));
10652
11326
  if (clearAnnotations) {
10653
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkT422YCHRcjs.mapLayer.call(void 0, layers, l.id, () => null);
11327
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => null);
10654
11328
  this.state.selectedAnnotationId = null;
10655
11329
  }
10656
11330
  this.state.layers = layers;
@@ -10658,7 +11332,7 @@ var ImageEditorController = (_class7 = class {
10658
11332
  }
10659
11333
  toJSON(options) {
10660
11334
  const out = this.serializeState();
10661
- if (_optionalChain([this, 'access', _245 => _245.state, 'access', _246 => _246.selection, 'optionalAccess', _247 => _247.bounds])) out.selection = serializeSelection(this.state.selection);
11335
+ if (_optionalChain([this, 'access', _258 => _258.state, 'access', _259 => _259.selection, 'optionalAccess', _260 => _260.bounds])) out.selection = serializeSelection(this.state.selection);
10662
11336
  if (!options || out.version !== LAYERED_SCHEMA_VERSION) return options ? Promise.resolve(out) : out;
10663
11337
  return serializeLayersExternal(this.state.layers, options.store).then(({ layers, assets }) => ({ ...out, layers, assets }));
10664
11338
  }
@@ -10694,7 +11368,7 @@ var ImageEditorController = (_class7 = class {
10694
11368
  this.notify();
10695
11369
  }
10696
11370
  /** Problems found by the last `loadJSON` / `initialState` of a v3 document (unreadable layers or assets). */
10697
- __init52() {this.lastLoadProblems = []}
11371
+ __init56() {this.lastLoadProblems = []}
10698
11372
  applyStored(raw) {
10699
11373
  const s = this.state;
10700
11374
  const data = migrateSerializedImageEditorState(raw);
@@ -10708,7 +11382,7 @@ var ImageEditorController = (_class7 = class {
10708
11382
  s.outputOpacity = data.opacity;
10709
11383
  if (typeof data.legacyOutputBlur === "number" && data.legacyOutputBlur >= 0) s.legacyOutputBlur = data.legacyOutputBlur;
10710
11384
  else delete s.legacyOutputBlur;
10711
- s.activeLayerId = data.activeLayerId && _chunkT422YCHRcjs.findLayer.call(void 0, s.layers, data.activeLayerId) ? data.activeLayerId : null;
11385
+ s.activeLayerId = data.activeLayerId && _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, data.activeLayerId) ? data.activeLayerId : null;
10712
11386
  const light = data.globalLight;
10713
11387
  if (light && Number.isFinite(light.angle) && Number.isFinite(light.altitude)) s.globalLight = { angle: light.angle, altitude: Math.min(90, Math.max(0, light.altitude)) };
10714
11388
  else delete s.globalLight;
@@ -10739,10 +11413,10 @@ var ImageEditorController = (_class7 = class {
10739
11413
  serializeState() {
10740
11414
  const { width, height } = this.naturalSize;
10741
11415
  const view = legacyView(this.stack(), width, height, null);
10742
- if (view.exact && !this.state.globalLight && !_optionalChain([this, 'access', _248 => _248.state, 'access', _249 => _249.patterns, 'optionalAccess', _250 => _250.length])) {
11416
+ if (view.exact && !this.state.globalLight && !_optionalChain([this, 'access', _261 => _261.state, 'access', _262 => _262.patterns, 'optionalAccess', _263 => _263.length])) {
10743
11417
  return {
10744
11418
  // States without adjustment layers keep schema 1, so they round-trip unchanged.
10745
- version: _optionalChain([view, 'access', _251 => _251.adjustments, 'access', _252 => _252.layers, 'optionalAccess', _253 => _253.length]) ? 2 : 1,
11419
+ version: _optionalChain([view, 'access', _264 => _264.adjustments, 'access', _265 => _265.layers, 'optionalAccess', _266 => _266.length]) ? 2 : 1,
10746
11420
  crop: this.state.crop ? { ...this.state.crop } : null,
10747
11421
  transform: { ...this.state.transform },
10748
11422
  adjustments: serializeAdjustments(view.adjustments),
@@ -10767,13 +11441,13 @@ var ImageEditorController = (_class7 = class {
10767
11441
  };
10768
11442
  if (this.state.legacyOutputBlur !== void 0) out.legacyOutputBlur = this.state.legacyOutputBlur;
10769
11443
  if (this.state.globalLight) out.globalLight = { ...this.state.globalLight };
10770
- if (_optionalChain([this, 'access', _254 => _254.state, 'access', _255 => _255.patterns, 'optionalAccess', _256 => _256.length])) out.patterns = serializePatterns(this.state.patterns);
11444
+ if (_optionalChain([this, 'access', _267 => _267.state, 'access', _268 => _268.patterns, 'optionalAccess', _269 => _269.length])) out.patterns = serializePatterns(this.state.patterns);
10771
11445
  return out;
10772
11446
  }
10773
- }, _class7);
11447
+ }, _class8);
10774
11448
  function serializeAdjustments(adjustments) {
10775
11449
  const out = { ...adjustments };
10776
- if (_optionalChain([out, 'access', _257 => _257.layers, 'optionalAccess', _258 => _258.length])) out.layers = JSON.parse(JSON.stringify(out.layers));
11450
+ if (_optionalChain([out, 'access', _270 => _270.layers, 'optionalAccess', _271 => _271.length])) out.layers = JSON.parse(JSON.stringify(out.layers));
10777
11451
  else delete out.layers;
10778
11452
  if (normalizeProcessVersion(out.process) === LEGACY_PROCESS_VERSION) {
10779
11453
  delete out.process;
@@ -10809,11 +11483,11 @@ function withDevelop(layer, partial) {
10809
11483
  return { ...layer, filters };
10810
11484
  }
10811
11485
  function withBlur(layer, radius) {
10812
- const existing = _optionalChain([layer, 'access', _259 => _259.filters, 'optionalAccess', _260 => _260.find, 'call', _261 => _261((f) => f.kind === "blur")]);
11486
+ const existing = _optionalChain([layer, 'access', _272 => _272.filters, 'optionalAccess', _273 => _273.find, 'call', _274 => _274((f) => f.kind === "blur")]);
10813
11487
  const filters = (_nullishCoalesce(layer.filters, () => ( []))).filter((f) => f.kind !== "blur");
10814
11488
  if (radius > 0) {
10815
11489
  filters.push({
10816
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _262 => _262.id]), () => ( (layer.source === "document" ? BLUR_FILTER_ID : newLayerId("flt")))),
11490
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _275 => _275.id]), () => ( (layer.source === "document" ? BLUR_FILTER_ID : newLayerId("flt")))),
10817
11491
  kind: "blur",
10818
11492
  enabled: true,
10819
11493
  radius
@@ -10868,6 +11542,10 @@ function withMaskProps(mask, props) {
10868
11542
  if (props.enabled) delete next.enabled;
10869
11543
  else next.enabled = false;
10870
11544
  }
11545
+ if (props.linked !== void 0) {
11546
+ if (props.linked) delete next.linked;
11547
+ else next.linked = false;
11548
+ }
10871
11549
  return next;
10872
11550
  }
10873
11551
  function resizeLegacyMasks(layers, from, to) {
@@ -10877,12 +11555,12 @@ function resizeLegacyMasks(layers, from, to) {
10877
11555
  const th = Math.max(1, Math.round(to.height));
10878
11556
  if (fw === tw && fh === th) return layers;
10879
11557
  let out = layers;
10880
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) {
11558
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
10881
11559
  if (l.type !== "adjustment" || !l.mask || l.mask.source) continue;
10882
11560
  const old = l.mask;
10883
11561
  const mask = rasterMaskFromLegacy(legacyMaskOf(old, fw, fh), tw, th);
10884
11562
  if (!mask) continue;
10885
- out = _chunkT422YCHRcjs.mapLayer.call(void 0, out, l.id, (n) => ({ ...n, mask: { ...mask, density: old.density, feather: old.feather, enabled: old.enabled } }));
11563
+ out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, l.id, (n) => ({ ...n, mask: { ...mask, density: old.density, feather: old.feather, enabled: old.enabled } }));
10886
11564
  }
10887
11565
  return out;
10888
11566
  }
@@ -10895,7 +11573,7 @@ function isOpaqueInside(surface, width, height) {
10895
11573
  return true;
10896
11574
  }
10897
11575
  function collectStateTiles(layers, into) {
10898
- for (const l of _chunkT422YCHRcjs.flattenLayers.call(void 0, layers)) {
11576
+ for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
10899
11577
  if (l.type === "pixel" && l.source !== "document") _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.surface, into);
10900
11578
  if (l.mask && !l.mask.source) _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.mask.surface, into);
10901
11579
  }
@@ -10905,7 +11583,7 @@ function pixelsOnly(layers) {
10905
11583
  for (const l of layers) {
10906
11584
  if (l.type === "adjustment") continue;
10907
11585
  if (l.type === "group") out.push({ ...l, children: pixelsOnly(l.children) });
10908
- else if (l.type === "pixel" && _optionalChain([l, 'access', _263 => _263.filters, 'optionalAccess', _264 => _264.length])) {
11586
+ else if (l.type === "pixel" && _optionalChain([l, 'access', _276 => _276.filters, 'optionalAccess', _277 => _277.length])) {
10909
11587
  const p = { ...l };
10910
11588
  delete p.filters;
10911
11589
  out.push(p);
@@ -10913,24 +11591,24 @@ function pixelsOnly(layers) {
10913
11591
  }
10914
11592
  return out;
10915
11593
  }
10916
- function resizePixels(px, width, height) {
10917
- const src = px.data;
11594
+ function resizePixels(px2, width, height) {
11595
+ const src = px2.data;
10918
11596
  const out = new Uint8ClampedArray(width * height * 4);
10919
- const kx = px.width / width;
10920
- const ky = px.height / height;
11597
+ const kx = px2.width / width;
11598
+ const ky = px2.height / height;
10921
11599
  for (let y = 0; y < height; y++) {
10922
- const fy = Math.min(px.height - 1, Math.max(0, (y + 0.5) * ky - 0.5));
11600
+ const fy = Math.min(px2.height - 1, Math.max(0, (y + 0.5) * ky - 0.5));
10923
11601
  const y0 = Math.floor(fy);
10924
- const y1 = Math.min(px.height - 1, y0 + 1);
11602
+ const y1 = Math.min(px2.height - 1, y0 + 1);
10925
11603
  const ty = fy - y0;
10926
11604
  for (let x = 0; x < width; x++) {
10927
- const fx = Math.min(px.width - 1, Math.max(0, (x + 0.5) * kx - 0.5));
11605
+ const fx = Math.min(px2.width - 1, Math.max(0, (x + 0.5) * kx - 0.5));
10928
11606
  const x0 = Math.floor(fx);
10929
- const x1 = Math.min(px.width - 1, x0 + 1);
11607
+ const x1 = Math.min(px2.width - 1, x0 + 1);
10930
11608
  const tx = fx - x0;
10931
11609
  for (let c = 0; c < 4; c++) {
10932
- const a = src[(y0 * px.width + x0) * 4 + c] * (1 - tx) + src[(y0 * px.width + x1) * 4 + c] * tx;
10933
- const b = src[(y1 * px.width + x0) * 4 + c] * (1 - tx) + src[(y1 * px.width + x1) * 4 + c] * tx;
11610
+ const a = src[(y0 * px2.width + x0) * 4 + c] * (1 - tx) + src[(y0 * px2.width + x1) * 4 + c] * tx;
11611
+ const b = src[(y1 * px2.width + x0) * 4 + c] * (1 - tx) + src[(y1 * px2.width + x1) * 4 + c] * tx;
10934
11612
  out[(y * width + x) * 4 + c] = a * (1 - ty) + b * ty;
10935
11613
  }
10936
11614
  }
@@ -10963,7 +11641,7 @@ function toHex2(c) {
10963
11641
  return "#" + [c[0], c[1], c[2]].map((v) => Math.round(v).toString(16).padStart(2, "0")).join("");
10964
11642
  }
10965
11643
  function normalizeSelection(mask) {
10966
- return _optionalChain([mask, 'optionalAccess', _265 => _265.bounds]) ? mask : null;
11644
+ return _optionalChain([mask, 'optionalAccess', _278 => _278.bounds]) ? mask : null;
10967
11645
  }
10968
11646
  function sameSelection(a, b) {
10969
11647
  if (a.width !== b.width || a.height !== b.height) return false;
@@ -11124,7 +11802,7 @@ function loadImageEditorDocument(input) {
11124
11802
  }
11125
11803
  const state = { version: 1, ...result.value };
11126
11804
  if (isV2) {
11127
- if (_optionalChain([state, 'access', _266 => _266.adjustments, 'access', _267 => _267.layers, 'optionalAccess', _268 => _268.length])) state.version = 2;
11805
+ if (_optionalChain([state, 'access', _279 => _279.adjustments, 'access', _280 => _280.layers, 'optionalAccess', _281 => _281.length])) state.version = 2;
11128
11806
  result.report.version = 2;
11129
11807
  }
11130
11808
  if (state.selection === void 0) delete state.selection;
@@ -11324,7 +12002,7 @@ function findAdjustmentControl(id) {
11324
12002
  }
11325
12003
  function findLayerControl(kind, id) {
11326
12004
  if (id === "opacity") return ADJUSTMENT_LAYER_OPACITY_CONTROL;
11327
- return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access', _269 => _269[kind], 'optionalAccess', _270 => _270.find, 'call', _271 => _271((c) => c.id === id)]);
12005
+ return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access', _282 => _282[kind], 'optionalAccess', _283 => _283.find, 'call', _284 => _284((c) => c.id === id)]);
11328
12006
  }
11329
12007
  function clampControlValue(spec, v) {
11330
12008
  if (typeof v !== "number" || !Number.isFinite(v)) return spec.default;
@@ -11425,8 +12103,8 @@ function describeSelection(mask) {
11425
12103
  if (!mask || !mask.bounds) return "No selection";
11426
12104
  let sum = 0;
11427
12105
  for (let i = 0; i < mask.data.length; i++) sum += mask.data[i];
11428
- const pct2 = sum / 255 / mask.data.length * 100;
11429
- const shown = pct2 >= 10 ? Math.round(pct2) : Math.round(pct2 * 10) / 10;
12106
+ const pct3 = sum / 255 / mask.data.length * 100;
12107
+ const shown = pct3 >= 10 ? Math.round(pct3) : Math.round(pct3 * 10) / 10;
11430
12108
  return `${mask.bounds.width} \xD7 ${mask.bounds.height} px selected (${shown}% of the image)`;
11431
12109
  }
11432
12110
 
@@ -11443,7 +12121,7 @@ function summary(controller) {
11443
12121
  const area = selectionArea(sel);
11444
12122
  return {
11445
12123
  empty: !sel,
11446
- bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _272 => _272.bounds]), () => ( null)),
12124
+ bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _285 => _285.bounds]), () => ( null)),
11447
12125
  /** Σ coverage in pixels. */
11448
12126
  area: Math.round(area),
11449
12127
  percent: Math.round(area / Math.max(1, width * height) * 1e4) / 100,
@@ -11687,7 +12365,7 @@ async function renderImageRegion(controller, request) {
11687
12365
  if (request.includeOverlays) {
11688
12366
  const s = request.scale;
11689
12367
  const selection = state.selection;
11690
- if (_optionalChain([selection, 'optionalAccess', _273 => _273.bounds]) && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
12368
+ if (_optionalChain([selection, 'optionalAccess', _286 => _286.bounds]) && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
11691
12369
  const shade = selectionShade(selection, document);
11692
12370
  if (shade) context.drawImage(shade, rect.x, rect.y, rect.width, rect.height, 0, 0, out.width, out.height);
11693
12371
  }
@@ -11712,7 +12390,7 @@ function createImageCaptureSurface(controller) {
11712
12390
  return {
11713
12391
  units: "image pixels",
11714
12392
  content: whole,
11715
- selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access', _274 => _274.getState, 'call', _275 => _275(), 'access', _276 => _276.selection, 'optionalAccess', _277 => _277.bounds]), () => ( null)) }),
12393
+ selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access', _287 => _287.getState, 'call', _288 => _288(), 'access', _289 => _289.selection, 'optionalAccess', _290 => _290.bounds]), () => ( null)) }),
11716
12394
  overlays: "a shade over unselected pixels and the crop box outline",
11717
12395
  maxScale: 8,
11718
12396
  render: (request) => renderImageRegion(controller, request)
@@ -11746,14 +12424,14 @@ function rebin(bins, count) {
11746
12424
  return out;
11747
12425
  }
11748
12426
  function histogramSummary(h, bins) {
11749
- const pct2 = (n) => h.samples ? round(n / h.samples * 100) : 0;
12427
+ const pct3 = (n) => h.samples ? round(n / h.samples * 100) : 0;
11750
12428
  const channels = { red: h.red, green: h.green, blue: h.blue, luminance: h.luminance };
11751
12429
  return {
11752
12430
  samples: h.samples,
11753
12431
  transparent: h.transparent,
11754
12432
  clipping: {
11755
- shadowsPercent: { red: pct2(h.shadows[0]), green: pct2(h.shadows[1]), blue: pct2(h.shadows[2]) },
11756
- highlightsPercent: { red: pct2(h.highlights[0]), green: pct2(h.highlights[1]), blue: pct2(h.highlights[2]) }
12433
+ shadowsPercent: { red: pct3(h.shadows[0]), green: pct3(h.shadows[1]), blue: pct3(h.shadows[2]) },
12434
+ highlightsPercent: { red: pct3(h.highlights[0]), green: pct3(h.highlights[1]), blue: pct3(h.highlights[2]) }
11757
12435
  },
11758
12436
  stats: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, binStats(v, h.samples)])),
11759
12437
  ...bins ? { bins: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, rebin(v, bins)])) } : {}
@@ -11985,6 +12663,7 @@ function maskSummary(mask) {
11985
12663
  const out = {
11986
12664
  kind: mask.source ? "depth" : "raster",
11987
12665
  enabled: mask.enabled !== false,
12666
+ linked: mask.linked !== false,
11988
12667
  density: _nullishCoalesce(mask.density, () => ( 1)),
11989
12668
  feather: _nullishCoalesce(mask.feather, () => ( 0))
11990
12669
  };
@@ -12049,11 +12728,11 @@ function placementFrom(args) {
12049
12728
  function createImageLayerTools(controller) {
12050
12729
  const describe = (id) => {
12051
12730
  const s = controller.getState();
12052
- const loc = _chunkT422YCHRcjs.findLayer.call(void 0, s.layers, id);
12731
+ const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, id);
12053
12732
  if (!loc) return null;
12054
12733
  return {
12055
12734
  ...describeLayer(loc.layer, s.activeLayerId, (x) => controller.getLayerBounds(x.id)),
12056
- parentId: _nullishCoalesce(_optionalChain([loc, 'access', _278 => _278.parent, 'optionalAccess', _279 => _279.id]), () => ( null)),
12735
+ parentId: _nullishCoalesce(_optionalChain([loc, 'access', _291 => _291.parent, 'optionalAccess', _292 => _292.id]), () => ( null)),
12057
12736
  index: loc.index
12058
12737
  };
12059
12738
  };
@@ -12361,23 +13040,29 @@ function createImageLayerTools(controller) {
12361
13040
  const maskProps = {
12362
13041
  name: "set_layer_mask_properties",
12363
13042
  title: "Set layer mask properties",
12364
- description: "Changes a layer mask's density (0..1), feather (px) or enabled flag; its pixels are kept. One undo step. Returns the mask summary.",
13043
+ description: "Changes a layer mask's density (0..1), feather (px), enabled flag or linked flag; its pixels are kept. An unlinked mask (linked false) stays in place when the layer is moved, transformed or warped; transform it alone with transform_layer target mask. One undo step. Returns the mask summary.",
12365
13044
  inputSchema: {
12366
13045
  type: "object",
12367
13046
  properties: {
12368
13047
  layerId: LAYER_ID2,
12369
13048
  density: { type: "number", minimum: 0, maximum: 1, description: "Density 0..1." },
12370
13049
  feather: { type: "number", minimum: 0, maximum: 1e3, description: "Feather \u03C3 in px." },
12371
- enabled: { type: "boolean", description: "false ignores the mask but keeps it." }
13050
+ enabled: { type: "boolean", description: "false ignores the mask but keeps it." },
13051
+ linked: { type: "boolean", description: "false unlinks the mask from the layer pixels (it stays put when they move or transform); true links it again." }
12372
13052
  },
12373
13053
  required: ["layerId"],
12374
13054
  additionalProperties: false
12375
13055
  },
12376
13056
  annotations: { title: "Set layer mask properties", ...WRITE_IDEMPOTENT2 },
12377
- handler: ({ layerId, density, feather, enabled }) => {
13057
+ handler: ({ layerId, density, feather, enabled, linked }) => {
12378
13058
  const id = exists(layerId);
12379
- if ([density, feather, enabled].every((v) => v === void 0)) throw new LayerOperationError("Give density, feather or enabled.");
12380
- const mask = controller.setLayerMaskProps(id, { density, feather, enabled });
13059
+ if ([density, feather, enabled, linked].every((v) => v === void 0)) throw new LayerOperationError("Give density, feather, enabled or linked.");
13060
+ const mask = controller.setLayerMaskProps(id, {
13061
+ density,
13062
+ feather,
13063
+ enabled,
13064
+ linked
13065
+ });
12381
13066
  return { layerId: id, mask: maskSummary(mask) };
12382
13067
  }
12383
13068
  };
@@ -12620,7 +13305,7 @@ var DEFS = {
12620
13305
  };
12621
13306
  var nullable = (schema, description) => ({ anyOf: [schema, { type: "null" }], description });
12622
13307
  function settingsSchema(forUpdate) {
12623
- const opt = (schema, description) => forUpdate ? nullable(schema, `${description} null removes it.`) : { ...schema, description };
13308
+ const opt2 = (schema, description) => forUpdate ? nullable(schema, `${description} null removes it.`) : { ...schema, description };
12624
13309
  return {
12625
13310
  type: "object",
12626
13311
  description: forUpdate ? "Settings to change (only these; nested objects are replaced whole). Which settings a kind takes: see add_layer_effect." : "Settings to change from Photoshop's defaults (all optional). Unknown settings for the kind are refused with the list of its settings.",
@@ -12635,7 +13320,7 @@ function settingsSchema(forUpdate) {
12635
13320
  spread: { type: "number", minimum: 0, maximum: 1, description: "drop-shadow, outer-glow: 0..1 of the size made solid (default 0)." },
12636
13321
  choke: { type: "number", minimum: 0, maximum: 1, description: "inner-shadow, inner-glow: 0..1 of the size made solid (default 0)." },
12637
13322
  size: { type: "number", minimum: 0, maximum: 250, description: "Shadows, glows, satin, bevel-emboss: blur / size in px (default 5; satin 14); stroke: width in px (default 3)." },
12638
- contour: opt({ $ref: "#/$defs/contour" }, "Shadows, glows, satin: coverage contour (default linear)."),
13323
+ contour: opt2({ $ref: "#/$defs/contour" }, "Shadows, glows, satin: coverage contour (default linear)."),
12639
13324
  antiAlias: { type: "boolean", description: "Shadows, glows, satin: smooth the contour (default false; satin true)." },
12640
13325
  noise: { type: "number", minimum: 0, maximum: 1, description: "Shadows, glows: speckle 0..1 (default 0)." },
12641
13326
  knocksOut: { type: "boolean", description: "drop-shadow: the layer hides the shadow beneath its see-through fill (default true)." },
@@ -12649,14 +13334,14 @@ function settingsSchema(forUpdate) {
12649
13334
  direction: { type: "string", enum: ["up", "down"], description: "bevel-emboss: raised (up, default) or sunk (down)." },
12650
13335
  soften: { type: "number", minimum: 0, maximum: 16, description: "bevel-emboss: blur of the height in px (default 0)." },
12651
13336
  altitude: { type: "number", minimum: 0, maximum: 90, description: "bevel-emboss: light altitude in degrees (default 30)." },
12652
- glossContour: opt({ $ref: "#/$defs/contour" }, "bevel-emboss: gloss contour over the shading (default linear)."),
13337
+ glossContour: opt2({ $ref: "#/$defs/contour" }, "bevel-emboss: gloss contour over the shading (default linear)."),
12653
13338
  highlightColor: { $ref: "#/$defs/color", description: "bevel-emboss: highlight colour (default #ffffff)." },
12654
13339
  highlightBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: highlight mode (default screen)." },
12655
13340
  highlightOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: highlight opacity (default 0.75)." },
12656
13341
  shadowColor: { $ref: "#/$defs/color", description: "bevel-emboss: shadow colour (default #000000)." },
12657
13342
  shadowBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: shadow mode (default multiply)." },
12658
13343
  shadowOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: shadow opacity (default 0.75)." },
12659
- contourElement: opt(
13344
+ contourElement: opt2(
12660
13345
  {
12661
13346
  type: "object",
12662
13347
  properties: {
@@ -12669,7 +13354,7 @@ function settingsSchema(forUpdate) {
12669
13354
  },
12670
13355
  "bevel-emboss: the Contour element, shaping the bevel's height profile (default off)."
12671
13356
  ),
12672
- texture: opt(
13357
+ texture: opt2(
12673
13358
  {
12674
13359
  type: "object",
12675
13360
  properties: {
@@ -12701,8 +13386,8 @@ function settingsSchema(forUpdate) {
12701
13386
  }
12702
13387
  function patternList(controller) {
12703
13388
  const doc = controller.getDocumentPatterns().map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
12704
- const builtins = _chunkT422YCHRcjs.builtinPatternIds.call(void 0, ).map((id) => {
12705
- const p = _chunkT422YCHRcjs.builtinPattern.call(void 0, id);
13389
+ const builtins = _chunkWT6ZAWJPcjs.builtinPatternIds.call(void 0, ).map((id) => {
13390
+ const p = _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id);
12706
13391
  return { id, name: p.name, width: p.width, height: p.height, builtin: true };
12707
13392
  });
12708
13393
  return [...doc, ...builtins];
@@ -12711,9 +13396,9 @@ function describeLayerEffects(effects) {
12711
13396
  return {
12712
13397
  enabled: effects.enabled,
12713
13398
  scale: _nullishCoalesce(effects.scale, () => ( 1)),
12714
- margin: _chunkT422YCHRcjs.effectsMargin.call(void 0, effects),
13399
+ margin: _chunkWT6ZAWJPcjs.effectsMargin.call(void 0, effects),
12715
13400
  fromPsd: Boolean(effects.psd),
12716
- effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkT422YCHRcjs.layerEffectLabel.call(void 0, e.kind) }))
13401
+ effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, e.kind) }))
12717
13402
  };
12718
13403
  }
12719
13404
  function createImageEffectTools(controller) {
@@ -12729,7 +13414,7 @@ function createImageEffectTools(controller) {
12729
13414
  description: "Returns a layer's effects: the master switch (enabled), Scale Effects (scale, 1 = 100 %), margin (px the effects reach beyond the shape), whether they came from a PSD, and every effect with its id, kind, label and all settings. Also returns the document global light and the pattern ids pattern effects can use.",
12730
13415
  inputSchema: { type: "object", properties: { layerId: LAYER_ID3 }, required: ["layerId"], additionalProperties: false },
12731
13416
  annotations: { title: "List layer effects", ...READ3 },
12732
- handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(controller), kinds: [..._chunkT422YCHRcjs.LAYER_EFFECT_KINDS] })
13417
+ handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(controller), kinds: [..._chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS] })
12733
13418
  };
12734
13419
  const add = {
12735
13420
  name: "add_layer_effect",
@@ -12740,7 +13425,7 @@ function createImageEffectTools(controller) {
12740
13425
  $defs: DEFS,
12741
13426
  properties: {
12742
13427
  layerId: LAYER_ID3,
12743
- kind: { type: "string", enum: [..._chunkT422YCHRcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
13428
+ kind: { type: "string", enum: [..._chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
12744
13429
  settings: settingsSchema(false),
12745
13430
  index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
12746
13431
  },
@@ -12750,7 +13435,7 @@ function createImageEffectTools(controller) {
12750
13435
  annotations: { title: "Add a layer effect", ...WRITE3 },
12751
13436
  handler: ({ layerId, kind, settings, index }) => {
12752
13437
  const id = layerArg(layerId);
12753
- if (!_chunkT422YCHRcjs.isLayerEffectKind.call(void 0, kind)) throw new LayerOperationError(`kind must be one of ${_chunkT422YCHRcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
13438
+ if (!_chunkWT6ZAWJPcjs.isLayerEffectKind.call(void 0, kind)) throw new LayerOperationError(`kind must be one of ${_chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
12754
13439
  const { effect } = controller.addLayerEffect(id, kind, _nullishCoalesce(settings, () => ( {})), index);
12755
13440
  return result(id, { effectId: effect.id });
12756
13441
  }
@@ -12909,15 +13594,15 @@ function pointerPressure(e) {
12909
13594
  if (e.pointerType === "pen" && typeof e.pressure === "number" && e.pressure > 0) return Math.min(1, e.pressure);
12910
13595
  return 1;
12911
13596
  }
12912
- var PaintGesture = (_class8 = class {
12913
- constructor(controller) {;_class8.prototype.__init53.call(this);_class8.prototype.__init54.call(this);_class8.prototype.__init55.call(this);
13597
+ var PaintGesture = (_class9 = class {
13598
+ constructor(controller) {;_class9.prototype.__init57.call(this);_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);
12914
13599
  this.controller = controller;
12915
13600
  }
12916
13601
 
12917
- __init53() {this.stroke = null}
12918
- __init54() {this.move = null}
13602
+ __init57() {this.stroke = null}
13603
+ __init58() {this.move = null}
12919
13604
  /** The last refusal (e.g. "layer is locked"), for the editor to show. */
12920
- __init55() {this.error = null}
13605
+ __init59() {this.error = null}
12921
13606
  get active() {
12922
13607
  return Boolean(this.stroke || this.move);
12923
13608
  }
@@ -12929,7 +13614,7 @@ var PaintGesture = (_class8 = class {
12929
13614
  const layer = this.controller.getActiveLayer();
12930
13615
  if (!layer) throw new Error("Select a layer to move in the Layers panel.");
12931
13616
  if (layer.type !== "pixel") throw new Error(`Only pixel layers move; "${layer.name}" is a ${layer.type} layer.`);
12932
- if (_optionalChain([layer, 'access', _280 => _280.locks, 'optionalAccess', _281 => _281.all]) || _optionalChain([layer, 'access', _282 => _282.locks, 'optionalAccess', _283 => _283.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
13617
+ if (_optionalChain([layer, 'access', _293 => _293.locks, 'optionalAccess', _294 => _294.all]) || _optionalChain([layer, 'access', _295 => _295.locks, 'optionalAccess', _296 => _296.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
12933
13618
  this.move = { id: layer.id, start: { x: sample.x, y: sample.y }, origin: { ...layer.offset }, moved: false };
12934
13619
  return null;
12935
13620
  }
@@ -12978,11 +13663,11 @@ var PaintGesture = (_class8 = class {
12978
13663
  this.move = null;
12979
13664
  }
12980
13665
  cancel() {
12981
- _optionalChain([this, 'access', _284 => _284.stroke, 'optionalAccess', _285 => _285.cancel, 'call', _286 => _286()]);
13666
+ _optionalChain([this, 'access', _297 => _297.stroke, 'optionalAccess', _298 => _298.cancel, 'call', _299 => _299()]);
12982
13667
  this.stroke = null;
12983
13668
  this.move = null;
12984
13669
  }
12985
- }, _class8);
13670
+ }, _class9);
12986
13671
 
12987
13672
  // src/image-editor/paint-tools.ts
12988
13673
  var READ4 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
@@ -13174,7 +13859,7 @@ function psdBytesFromBase64(data) {
13174
13859
  if (typeof data !== "string" || !data.trim()) throw new PsdError("data is required: the PSD file as base64.");
13175
13860
  const body = data.trim().replace(/^data:[^,]*;base64,/i, "");
13176
13861
  if (!/^[A-Za-z0-9+/=_\s-]+$/.test(body)) throw new PsdError("data is not base64; send the PSD file bytes base64-encoded.");
13177
- const bytes = _chunkT422YCHRcjs.base64ToBytes.call(void 0, body);
13862
+ const bytes = _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, body);
13178
13863
  if (bytes.length < 26) throw new PsdError(`data decodes to ${bytes.length} bytes, too short for a PSD (at least 26).`);
13179
13864
  return bytes;
13180
13865
  }
@@ -13225,7 +13910,7 @@ function createImagePsdTools(controller) {
13225
13910
  handler: async () => {
13226
13911
  const res = await controller.toPsd();
13227
13912
  return {
13228
- data: _chunkT422YCHRcjs.bytesToBase64.call(void 0, res.bytes),
13913
+ data: _chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, res.bytes),
13229
13914
  mimeType: "image/vnd.adobe.photoshop",
13230
13915
  size: res.bytes.length,
13231
13916
  psb: res.psb,
@@ -13238,6 +13923,248 @@ function createImagePsdTools(controller) {
13238
13923
  return [inspect, open, save];
13239
13924
  }
13240
13925
 
13926
+ // src/image-editor/transform-tools.ts
13927
+ var READ6 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
13928
+ var WRITE5 = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
13929
+ var round4 = (n, digits = 3) => Math.round(n * 10 ** digits) / 10 ** digits;
13930
+ var roundPoint = (p) => ({ x: round4(p.x), y: round4(p.y) });
13931
+ var POINT = {
13932
+ type: "object",
13933
+ properties: { x: { type: "number", description: "Document pixels from the left." }, y: { type: "number", description: "Document pixels from the top." } },
13934
+ required: ["x", "y"],
13935
+ additionalProperties: false
13936
+ };
13937
+ var TARGET2 = {
13938
+ layerId: { type: "string", description: "Layer to transform (from list_layers; default the active layer)." },
13939
+ content: {
13940
+ type: "string",
13941
+ enum: FREE_TRANSFORM_CONTENTS.filter((c) => c !== "selection-outline"),
13942
+ description: "What moves: layer (all its pixels with a linked mask), selection (only the selected pixels, committed back into the layer; the outline moves too), selection-copy (Layer via Copy: the selected pixels on a new layer above, then transformed; the original stays) or auto (default: selection when something is selected, else layer)."
13943
+ },
13944
+ channel: {
13945
+ type: "string",
13946
+ enum: ["pixels", "mask"],
13947
+ description: "pixels (default) moves the pixels and a linked mask; mask moves an unlinked mask alone (a linked mask always moves with its pixels)."
13948
+ },
13949
+ interpolation: { type: "string", enum: _chunkWT6ZAWJPcjs.INTERPOLATIONS, description: "Resampling: nearest (hard pixels), bilinear or bicubic (default, Photoshop\u2019s Bicubic)." }
13950
+ };
13951
+ var GEOMETRY = {
13952
+ scaleX: { type: "number", description: "Width in percent of the frame (default 100; negative flips horizontally)." },
13953
+ scaleY: { type: "number", description: "Height in percent of the frame (default 100; negative flips vertically)." },
13954
+ rotate: { type: "number", description: "Rotation in degrees, clockwise (default 0)." },
13955
+ skewX: { type: "number", minimum: -89, maximum: 89, description: "Horizontal skew in degrees: vertical edges lean right for positive angles (default 0)." },
13956
+ skewY: { type: "number", minimum: -89, maximum: 89, description: "Vertical skew in degrees: horizontal edges lean down for positive angles (default 0)." },
13957
+ dx: { type: "number", description: "Move right after scaling and rotating, in document pixels (default 0)." },
13958
+ dy: { type: "number", description: "Move down after scaling and rotating, in document pixels (default 0)." },
13959
+ reference: {
13960
+ description: "Fixed point of scale, skew and rotate: an anchor of the frame (top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right; default center) or a document point {x, y}.",
13961
+ anyOf: [{ type: "string", enum: TRANSFORM_ANCHORS }, POINT]
13962
+ },
13963
+ matrix: {
13964
+ type: "array",
13965
+ items: { type: "number" },
13966
+ minItems: 6,
13967
+ maxItems: 6,
13968
+ description: "Instead of the numeric fields: an affine matrix [a, b, c, d, e, f] in document pixels (x' = a\xB7x + c\xB7y + e, y' = b\xB7x + d\xB7y + f)."
13969
+ },
13970
+ corners: {
13971
+ type: "array",
13972
+ items: POINT,
13973
+ minItems: 4,
13974
+ maxItems: 4,
13975
+ description: "Instead of the numeric fields: where the frame\u2019s corners go, [top-left, top-right, bottom-right, bottom-left] in document pixels (Distort; for Perspective move a pair of corners symmetrically). The quad must stay convex. Get the frame and its corners from get_transform_frame."
13976
+ }
13977
+ };
13978
+ var NUMERIC = ["scaleX", "scaleY", "rotate", "skewX", "skewY", "dx", "dy", "reference"];
13979
+ function geometryFrom(args) {
13980
+ const numeric = NUMERIC.filter((k) => args[k] !== void 0);
13981
+ const ways = [numeric.length > 0, args.matrix !== void 0, args.corners !== void 0].filter(Boolean).length;
13982
+ if (ways === 0) throw new LayerOperationError("Give the transform one way: numeric fields (scaleX, scaleY, rotate, skewX, skewY, dx, dy, reference), matrix, or corners.");
13983
+ if (ways > 1) throw new LayerOperationError("Give the transform only one way: numeric fields, matrix or corners, not a mix.");
13984
+ if (args.matrix !== void 0) return { matrix: args.matrix };
13985
+ if (args.corners !== void 0) return { corners: args.corners };
13986
+ const params = {};
13987
+ for (const k of NUMERIC) if (args[k] !== void 0) params[k] = args[k];
13988
+ if (params.scaleX === 0 || params.scaleY === 0) throw new LayerOperationError("scaleX and scaleY must not be 0 (that collapses the layer to a line).");
13989
+ if (typeof params.reference === "string" && !isTransformAnchor(params.reference)) throw new LayerOperationError(`Unknown reference "${params.reference}". Use ${TRANSFORM_ANCHORS.join(", ")} or {x, y}.`);
13990
+ return { params };
13991
+ }
13992
+ function targetFrom(args) {
13993
+ const init = {};
13994
+ if (typeof args.layerId === "string") init.layerId = args.layerId;
13995
+ if (args.content !== void 0) init.content = args.content;
13996
+ init.channel = _nullishCoalesce(args.channel, () => ( "pixels"));
13997
+ if (args.interpolation !== void 0) init.interpolation = args.interpolation;
13998
+ return init;
13999
+ }
14000
+ function summary2(res) {
14001
+ return {
14002
+ layerId: res.layerId,
14003
+ content: res.content,
14004
+ moved: res.moved,
14005
+ changed: res.changed,
14006
+ frame: { ...res.box },
14007
+ corners: res.corners.map(roundPoint),
14008
+ bounds: res.bounds
14009
+ };
14010
+ }
14011
+ function createImageTransformTools(controller) {
14012
+ const getFrame = {
14013
+ name: "get_transform_frame",
14014
+ title: "Get the Free Transform frame",
14015
+ description: "Returns what a transform would move and its frame: content (layer, selection, selection-copy or selection-outline), moved (pixels, mask, selection), the frame (document bounds of the content), its corners [top-left, top-right, bottom-right, bottom-left] and centre. Pass meshColumns / meshRows to also get the identity warp mesh over the frame to edit for warp_layer. Changes nothing.",
14016
+ inputSchema: {
14017
+ type: "object",
14018
+ properties: {
14019
+ layerId: TARGET2.layerId,
14020
+ content: { type: "string", enum: FREE_TRANSFORM_CONTENTS, description: `${TARGET2.content.description} selection-outline frames the selection outline alone.` },
14021
+ channel: TARGET2.channel,
14022
+ meshColumns: { type: "integer", minimum: 1, maximum: 16, description: "Patch columns of an identity warp mesh to return (omit for none)." },
14023
+ meshRows: { type: "integer", minimum: 1, maximum: 16, description: "Patch rows of an identity warp mesh to return (default meshColumns)." }
14024
+ },
14025
+ additionalProperties: false
14026
+ },
14027
+ annotations: { title: "Get the Free Transform frame", ...READ6 },
14028
+ handler: (args) => {
14029
+ const init = targetFrom(args);
14030
+ if (init.content === "selection-copy") init.content = "selection";
14031
+ const s = controller.beginFreeTransform(init);
14032
+ const out = {
14033
+ layerId: s.layerId,
14034
+ content: args.content === "selection-copy" ? "selection-copy" : s.content,
14035
+ moved: [...s.moves],
14036
+ frame: { ...s.box },
14037
+ corners: identityTransform(s.box).corners.map(roundPoint),
14038
+ center: roundPoint({ x: s.box.x + s.box.width / 2, y: s.box.y + s.box.height / 2 })
14039
+ };
14040
+ s.cancel();
14041
+ if (args.meshColumns !== void 0) {
14042
+ const cols = args.meshColumns;
14043
+ const rows = _nullishCoalesce(args.meshRows, () => ( cols));
14044
+ const mesh = _chunkDWGZUSEScjs.identityWarpMesh.call(void 0, s.box, cols, rows);
14045
+ out.mesh = { columns: cols, rows, pointsPerRow: _chunkDWGZUSEScjs.warpMeshColumns.call(void 0, mesh), pointRows: _chunkDWGZUSEScjs.warpMeshRows.call(void 0, mesh), points: mesh.points.map(roundPoint) };
14046
+ }
14047
+ return out;
14048
+ }
14049
+ };
14050
+ const transformLayer = {
14051
+ name: "transform_layer",
14052
+ title: "Free Transform a layer",
14053
+ description: "Edit \u203A Free Transform: scales, rotates, skews, moves, distorts or puts in perspective a pixel layer (with its linked mask), the selected pixels, a copy of them on a new layer, or an unlinked mask. Give the transform one way: the numeric fields (as Photoshop\u2019s options bar, about a reference point), a matrix, or the frame\u2019s new corners (distort / perspective; read the frame with get_transform_frame). Resamples once, tile by tile; one undo step. Returns layerId (the new layer for selection-copy), what moved, the frame, the corners and the new document bounds.",
14054
+ inputSchema: {
14055
+ type: "object",
14056
+ properties: { ...TARGET2, ...GEOMETRY },
14057
+ additionalProperties: false
14058
+ },
14059
+ annotations: { title: "Free Transform a layer", ...WRITE5 },
14060
+ handler: (args) => summary2(controller.transformLayer({ ...targetFrom(args), ...geometryFrom(args) }))
14061
+ };
14062
+ const warpLayer = {
14063
+ name: "warp_layer",
14064
+ title: "Warp a layer",
14065
+ description: "Edit \u203A Transform \u203A Warp: bends a pixel layer (with its linked mask), the selected pixels, a copy of them, or an unlinked mask through a preset (style with bend and distortions in percent) or a B\xE9zier mesh over the frame (get the frame and an identity mesh to edit from get_transform_frame with meshColumns). Give style or mesh, not both. One undo step. Returns what moved and the new document bounds.",
14066
+ inputSchema: {
14067
+ type: "object",
14068
+ properties: {
14069
+ ...TARGET2,
14070
+ style: { type: "string", enum: _chunkDWGZUSEScjs.WARP_STYLES, description: "Preset warp (Photoshop\u2019s menu): arc, arcLower, arcUpper, arch, bulge, shellLower, shellUpper, flag, wave, fish, rise, fisheye, inflate, squeeze, twist." },
14071
+ bend: { type: "number", minimum: -100, maximum: 100, description: "Preset bend in percent, \u2212100..100 (default 50)." },
14072
+ horizontal: { type: "number", minimum: -100, maximum: 100, description: "Preset horizontal distortion in percent, \u2212100..100 (default 0)." },
14073
+ vertical: { type: "number", minimum: -100, maximum: 100, description: "Preset vertical distortion in percent, \u2212100..100 (default 0)." },
14074
+ orientation: { type: "string", enum: ["horizontal", "vertical"], description: "Bend along the horizontal (default) or vertical axis." },
14075
+ mesh: {
14076
+ type: "object",
14077
+ description: "A custom warp: patch columns and rows, and the (3\xB7columns + 1) \xD7 (3\xB7rows + 1) control points row by row in document pixels (anchors where both indices are multiples of 3, B\xE9zier handles between). Start from get_transform_frame\u2019s identity mesh.",
14078
+ properties: {
14079
+ columns: { type: "integer", minimum: 1, maximum: 16, description: "Patch columns." },
14080
+ rows: { type: "integer", minimum: 1, maximum: 16, description: "Patch rows." },
14081
+ points: { type: "array", items: POINT, minItems: 16, description: "Control points, row by row, document pixels." }
14082
+ },
14083
+ required: ["columns", "rows", "points"],
14084
+ additionalProperties: false
14085
+ }
14086
+ },
14087
+ additionalProperties: false
14088
+ },
14089
+ annotations: { title: "Warp a layer", ...WRITE5 },
14090
+ handler: (args) => {
14091
+ const hasPreset = ["style", "bend", "horizontal", "vertical", "orientation"].some((k) => args[k] !== void 0);
14092
+ if (hasPreset && args.mesh !== void 0) throw new LayerOperationError("Give a preset (style, bend, horizontal, vertical, orientation) or a mesh, not both.");
14093
+ if (!hasPreset && args.mesh === void 0) throw new LayerOperationError("Give a preset style or a mesh.");
14094
+ let warp;
14095
+ if (hasPreset) {
14096
+ if (args.style === void 0) throw new LayerOperationError(`style is required with a preset. Styles: ${_chunkDWGZUSEScjs.WARP_STYLES.join(", ")}.`);
14097
+ warp = {
14098
+ style: args.style,
14099
+ bend: _nullishCoalesce(args.bend, () => ( 50)),
14100
+ horizontal: args.horizontal,
14101
+ vertical: args.vertical,
14102
+ orientation: args.orientation
14103
+ };
14104
+ } else {
14105
+ const m = args.mesh;
14106
+ const want = (3 * m.columns + 1) * (3 * m.rows + 1);
14107
+ if (m.points.length !== want) throw new LayerOperationError(`A ${m.columns} \xD7 ${m.rows} mesh needs (3\xB7${m.columns} + 1) \xD7 (3\xB7${m.rows} + 1) = ${want} points, got ${m.points.length}.`);
14108
+ const knots = (n) => Array.from({ length: n + 1 }, (_, i) => i / n);
14109
+ warp = { us: knots(m.columns), vs: knots(m.rows), points: m.points.map((p) => ({ x: p.x, y: p.y })) };
14110
+ }
14111
+ return summary2(controller.transformLayer({ ...targetFrom(args), warp }));
14112
+ }
14113
+ };
14114
+ const transformSelection = {
14115
+ name: "transform_selection",
14116
+ title: "Transform the selection outline",
14117
+ description: "Select \u203A Transform Selection: scales, rotates, skews, moves or distorts only the selection outline; no pixels change. Give the transform one way: the numeric fields (about a reference point of the selection\u2019s bounds), a matrix, or the new corners of its bounds. Needs a selection. One undo step. Returns the new selection bounds.",
14118
+ inputSchema: {
14119
+ type: "object",
14120
+ properties: { interpolation: { ...TARGET2.interpolation, description: "Resampling of soft edges: nearest, bilinear or bicubic (default)." }, ...GEOMETRY },
14121
+ additionalProperties: false
14122
+ },
14123
+ annotations: { title: "Transform the selection outline", ...WRITE5 },
14124
+ handler: (args) => {
14125
+ const res = controller.transformLayer({ content: "selection-outline", interpolation: args.interpolation, ...geometryFrom(args) });
14126
+ return { changed: res.changed, frame: { ...res.box }, corners: res.corners.map(roundPoint), bounds: res.bounds };
14127
+ }
14128
+ };
14129
+ const flipLayer = {
14130
+ name: "flip_layer",
14131
+ title: "Flip a layer",
14132
+ description: "Edit \u203A Transform \u203A Flip Horizontal or Vertical: mirrors a pixel layer (with its linked mask), the selected pixels or a copy of them about the centre of their frame, exactly (no resampling). To flip the whole image use flip_image. One undo step. Returns the new bounds.",
14133
+ inputSchema: {
14134
+ type: "object",
14135
+ properties: {
14136
+ axis: { type: "string", enum: ["horizontal", "vertical"], description: "horizontal mirrors left \u2194 right, vertical top \u2194 bottom." },
14137
+ layerId: TARGET2.layerId,
14138
+ content: TARGET2.content,
14139
+ channel: TARGET2.channel
14140
+ },
14141
+ required: ["axis"],
14142
+ additionalProperties: false
14143
+ },
14144
+ annotations: { title: "Flip a layer", ...WRITE5 },
14145
+ handler: (args) => summary2(controller.flipLayer(args.axis, targetFrom(args)))
14146
+ };
14147
+ const rotate90 = {
14148
+ name: "rotate_layer_90",
14149
+ title: "Rotate a layer by quarter turns",
14150
+ description: "Edit \u203A Transform \u203A Rotate 90\xB0 / 180\xB0: turns a pixel layer (with its linked mask), the selected pixels or a copy of them about the centre of their frame, exactly (pixels land on whole pixels; no resampling). To rotate the whole image use set_rotation. One undo step. Returns the new bounds.",
14151
+ inputSchema: {
14152
+ type: "object",
14153
+ properties: {
14154
+ turn: { type: "integer", enum: [90, -90, 180], description: "Degrees: 90 clockwise, -90 counter-clockwise, or 180." },
14155
+ layerId: TARGET2.layerId,
14156
+ content: TARGET2.content,
14157
+ channel: TARGET2.channel
14158
+ },
14159
+ required: ["turn"],
14160
+ additionalProperties: false
14161
+ },
14162
+ annotations: { title: "Rotate a layer by quarter turns", ...WRITE5 },
14163
+ handler: (args) => summary2(controller.rotateLayer90(args.turn, targetFrom(args)))
14164
+ };
14165
+ return [getFrame, transformLayer, warpLayer, transformSelection, flipLayer, rotate90];
14166
+ }
14167
+
13241
14168
  // src/image-editor/tools.ts
13242
14169
  var LAYER_PATH = /^layers\.([^.]+)\.(.+)$/;
13243
14170
  function adjustmentsSummary(adjustments) {
@@ -13410,7 +14337,7 @@ function createImageEditorToolProvider(controller, options = {}) {
13410
14337
  for (const ref of [aboveId, parentId]) {
13411
14338
  if (ref !== void 0 && !controller.getLayer(ref)) throw new Error(`Unknown layer "${ref}". Call list_layers for ids.`);
13412
14339
  }
13413
- if (parentId !== void 0 && _optionalChain([controller, 'access', _287 => _287.getLayer, 'call', _288 => _288(parentId), 'optionalAccess', _289 => _289.type]) !== "group") throw new Error(`Layer "${parentId}" is not a group.`);
14340
+ if (parentId !== void 0 && _optionalChain([controller, 'access', _300 => _300.getLayer, 'call', _301 => _301(parentId), 'optionalAccess', _302 => _302.type]) !== "group") throw new Error(`Layer "${parentId}" is not a group.`);
13414
14341
  const id = controller.addAdjustmentLayer({ kind, params, opacity, blend, name, aboveId, parentId });
13415
14342
  const layer = controller.getAdjustmentLayer(id);
13416
14343
  return { layer: JSON.parse(JSON.stringify(layer)), index: controller.getAdjustmentLayers().findIndex((l) => l.id === id) };
@@ -13475,6 +14402,7 @@ function createImageEditorToolProvider(controller, options = {}) {
13475
14402
  ...createImageSelectionTools(controller),
13476
14403
  ...createImageEditTools(controller),
13477
14404
  ...createImageLayerTools(controller),
14405
+ ...createImageTransformTools(controller),
13478
14406
  ...createImageEffectTools(controller),
13479
14407
  ...createImagePaintTools(controller),
13480
14408
  ..._chunkZZOTHJ4Kcjs.createPigmentTools.call(void 0, ),
@@ -13538,19 +14466,19 @@ function removeCurvePoint(points, index) {
13538
14466
  var round22 = (v) => Math.round(v * 100) / 100;
13539
14467
 
13540
14468
  // src/image-editor/selection/gesture.ts
13541
- var SelectionGesture = (_class9 = class {
13542
- constructor(controller, getOptions) {;_class9.prototype.__init56.call(this);_class9.prototype.__init57.call(this);_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);_class9.prototype.__init60.call(this);
14469
+ var SelectionGesture = (_class10 = class {
14470
+ constructor(controller, getOptions) {;_class10.prototype.__init60.call(this);_class10.prototype.__init61.call(this);_class10.prototype.__init62.call(this);_class10.prototype.__init63.call(this);_class10.prototype.__init64.call(this);
13543
14471
  this.controller = controller;
13544
14472
  this.getOptions = getOptions;
13545
14473
  }
13546
14474
 
13547
14475
 
13548
- __init56() {this.start = null}
13549
- __init57() {this.points = []}
13550
- __init58() {this.current = null}
13551
- __init59() {this.modifiers = {}}
14476
+ __init60() {this.start = null}
14477
+ __init61() {this.points = []}
14478
+ __init62() {this.current = null}
14479
+ __init63() {this.modifiers = {}}
13552
14480
  /** The last error (e.g. pixels unavailable for the wand), for the UI to show. */
13553
- __init60() {this.error = null}
14481
+ __init64() {this.error = null}
13554
14482
  get active() {
13555
14483
  return this.start !== null;
13556
14484
  }
@@ -13638,7 +14566,7 @@ var SelectionGesture = (_class9 = class {
13638
14566
  this.current = null;
13639
14567
  this.points = [];
13640
14568
  }
13641
- }, _class9);
14569
+ }, _class10);
13642
14570
 
13643
14571
  // src/image-editor/mosaic-filter.ts
13644
14572
  function resolveMosaicRegionBounds(region, imgWidth, imgHeight) {
@@ -13686,8 +14614,8 @@ function applyRegionMosaic(imageData, regions, blockSize = 12) {
13686
14614
  const count = bw * bh;
13687
14615
  for (let py = by; py < by + bh; py++) {
13688
14616
  const rowOffset = py * width;
13689
- for (let px = bx; px < bx + bw; px++) {
13690
- const idx = (rowOffset + px) * 4;
14617
+ for (let px2 = bx; px2 < bx + bw; px2++) {
14618
+ const idx = (rowOffset + px2) * 4;
13691
14619
  rSum += data[idx];
13692
14620
  gSum += data[idx + 1];
13693
14621
  bSum += data[idx + 2];
@@ -13700,8 +14628,8 @@ function applyRegionMosaic(imageData, regions, blockSize = 12) {
13700
14628
  const aAvg = Math.round(aSum / count);
13701
14629
  for (let py = by; py < by + bh; py++) {
13702
14630
  const rowOffset = py * width;
13703
- for (let px = bx; px < bx + bw; px++) {
13704
- const idx = (rowOffset + px) * 4;
14631
+ for (let px2 = bx; px2 < bx + bw; px2++) {
14632
+ const idx = (rowOffset + px2) * 4;
13705
14633
  data[idx] = rAvg;
13706
14634
  data[idx + 1] = gAvg;
13707
14635
  data[idx + 2] = bAvg;
@@ -13821,7 +14749,7 @@ function dropZone(fraction, isGroup) {
13821
14749
  }
13822
14750
  function dropPlacement(layers, dragId, targetId, zone) {
13823
14751
  if (dragId === targetId) return null;
13824
- const target = _chunkT422YCHRcjs.findLayer.call(void 0, layers, targetId);
14752
+ const target = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, targetId);
13825
14753
  if (!target) return null;
13826
14754
  if (zone === "inside" && target.layer.type === "group") return { parentId: targetId };
13827
14755
  return zone === "above" ? { aboveId: targetId } : { belowId: targetId };
@@ -13829,35 +14757,35 @@ function dropPlacement(layers, dragId, targetId, zone) {
13829
14757
  function layerMenu(controller) {
13830
14758
  const s = controller.getState();
13831
14759
  const active = controller.getActiveLayer();
13832
- const loc = active ? _chunkT422YCHRcjs.findLayer.call(void 0, s.layers, active.id) : null;
14760
+ const loc = active ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, active.id) : null;
13833
14761
  const siblings = loc ? loc.parent ? loc.parent.children : s.layers : [];
13834
14762
  const below = loc ? siblings[loc.index - 1] : void 0;
13835
14763
  const hasSel = controller.hasSelection;
13836
- const isPixel = _optionalChain([active, 'optionalAccess', _290 => _290.type]) === "pixel";
14764
+ const isPixel = _optionalChain([active, 'optionalAccess', _303 => _303.type]) === "pixel";
13837
14765
  return [
13838
14766
  { action: "new-layer", label: "New Layer", enabled: true },
13839
14767
  { action: "new-group", label: "New Group", enabled: true },
13840
14768
  { action: "duplicate", label: "Duplicate Layer", enabled: Boolean(active) },
13841
14769
  { action: "delete", label: "Delete Layer", enabled: Boolean(active) },
13842
14770
  { action: "group-selected", label: "Group Layer", enabled: Boolean(active) },
13843
- { action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess', _291 => _291.type]) === "group" },
13844
- { action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess', _292 => _292.visible]) && _optionalChain([below, 'optionalAccess', _293 => _293.type]) === "pixel") },
14771
+ { action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess', _304 => _304.type]) === "group" },
14772
+ { action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess', _305 => _305.visible]) && _optionalChain([below, 'optionalAccess', _306 => _306.type]) === "pixel") },
13845
14773
  { action: "merge-visible", label: "Merge Visible", enabled: s.layers.some((l) => l.visible) },
13846
14774
  { action: "flatten", label: "Flatten Image", enabled: s.layers.length > 0 },
13847
14775
  { action: "via-copy", label: "Layer via Copy", enabled: isPixel && hasSel },
13848
14776
  { action: "via-cut", label: "Layer via Cut", enabled: isPixel && hasSel },
13849
14777
  { action: "add-mask", label: "Add Layer Mask", enabled: Boolean(active) },
13850
14778
  { action: "add-mask-selection", label: "Add Mask from Selection", enabled: Boolean(active) && hasSel },
13851
- { action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess', _294 => _294.mask])) },
13852
- { action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _295 => _295.mask])) },
13853
- { action: "toggle-mask", label: _optionalChain([active, 'optionalAccess', _296 => _296.mask, 'optionalAccess', _297 => _297.enabled]) === false ? "Enable Layer Mask" : "Disable Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _298 => _298.mask])) },
13854
- { action: "rasterize", label: "Rasterize Layer", enabled: _optionalChain([active, 'optionalAccess', _299 => _299.type]) === "annotation" || isPixel && Boolean(_optionalChain([active, 'optionalAccess', _300 => _300.type]) === "pixel" && _optionalChain([active, 'access', _301 => _301.filters, 'optionalAccess', _302 => _302.length])) },
13855
- { action: "toggle-clip", label: _optionalChain([active, 'optionalAccess', _303 => _303.clipped]) ? "Release Clipping Mask" : "Create Clipping Mask", enabled: Boolean(loc && loc.index > 0) }
14779
+ { action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess', _307 => _307.mask])) },
14780
+ { action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _308 => _308.mask])) },
14781
+ { action: "toggle-mask", label: _optionalChain([active, 'optionalAccess', _309 => _309.mask, 'optionalAccess', _310 => _310.enabled]) === false ? "Enable Layer Mask" : "Disable Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _311 => _311.mask])) },
14782
+ { action: "rasterize", label: "Rasterize Layer", enabled: _optionalChain([active, 'optionalAccess', _312 => _312.type]) === "annotation" || isPixel && Boolean(_optionalChain([active, 'optionalAccess', _313 => _313.type]) === "pixel" && _optionalChain([active, 'access', _314 => _314.filters, 'optionalAccess', _315 => _315.length])) },
14783
+ { action: "toggle-clip", label: _optionalChain([active, 'optionalAccess', _316 => _316.clipped]) ? "Release Clipping Mask" : "Create Clipping Mask", enabled: Boolean(loc && loc.index > 0) }
13856
14784
  ];
13857
14785
  }
13858
14786
  async function runLayerMenuAction(controller, action) {
13859
14787
  const active = controller.getActiveLayer();
13860
- const id = _optionalChain([active, 'optionalAccess', _304 => _304.id]);
14788
+ const id = _optionalChain([active, 'optionalAccess', _317 => _317.id]);
13861
14789
  try {
13862
14790
  switch (action) {
13863
14791
  case "new-layer":
@@ -13904,13 +14832,13 @@ async function runLayerMenuAction(controller, action) {
13904
14832
  if (id) controller.removeLayerMask(id);
13905
14833
  break;
13906
14834
  case "toggle-mask":
13907
- if (id && _optionalChain([active, 'optionalAccess', _305 => _305.mask])) controller.setLayerMaskProps(id, { enabled: active.mask.enabled === false });
14835
+ if (id && _optionalChain([active, 'optionalAccess', _318 => _318.mask])) controller.setLayerMaskProps(id, { enabled: active.mask.enabled === false });
13908
14836
  break;
13909
14837
  case "rasterize":
13910
14838
  if (id) await controller.rasterizeLayer(id);
13911
14839
  break;
13912
14840
  case "toggle-clip":
13913
- if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess', _306 => _306.clipped]) });
14841
+ if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess', _319 => _319.clipped]) });
13914
14842
  break;
13915
14843
  }
13916
14844
  return null;
@@ -13919,6 +14847,179 @@ async function runLayerMenuAction(controller, action) {
13919
14847
  }
13920
14848
  }
13921
14849
 
14850
+ // src/image-editor/layers/effects-ui.ts
14851
+ function layerEffectsPanel(layer) {
14852
+ const empty = { readOnly: true, enabled: true, scale: 1, rows: [] };
14853
+ if (!layer) return { ...empty, available: false, reason: "Select a layer to add effects." };
14854
+ if (layer.type === "adjustment") return { ...empty, available: false, reason: "Adjustment layers cannot have effects." };
14855
+ const fx = layer.effects;
14856
+ const readOnly = Boolean(_optionalChain([layer, 'access', _320 => _320.locks, 'optionalAccess', _321 => _321.all]));
14857
+ return {
14858
+ available: true,
14859
+ readOnly,
14860
+ reason: readOnly ? "The layer is locked; unlock it to change its effects." : void 0,
14861
+ enabled: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _322 => _322.enabled]), () => ( true)),
14862
+ scale: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _323 => _323.scale]), () => ( 1)),
14863
+ rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess', _324 => _324.items]), () => ( []))).map((e) => ({ id: e.id, kind: e.kind, label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, e.kind), enabled: e.enabled }))
14864
+ };
14865
+ }
14866
+ function layerEffectsBadge(layer) {
14867
+ if (!_optionalChain([layer, 'access', _325 => _325.effects, 'optionalAccess', _326 => _326.items, 'access', _327 => _327.length])) return null;
14868
+ return _chunkWT6ZAWJPcjs.hasActiveEffects.call(void 0, layer.effects) ? "on" : "off";
14869
+ }
14870
+ var LAYER_EFFECT_MENU = _chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.map((kind) => ({ kind, label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, kind) }));
14871
+ var BLENDS = _chunkCRMAXIUVcjs.BLEND_MODES.filter((m) => m.id !== "pigment").map((m) => ({ value: m.id, label: m.label }));
14872
+ var opt = (...pairs) => pairs.map(([value, label]) => ({ value, label }));
14873
+ function patternOptions(patterns) {
14874
+ return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ..._chunkWT6ZAWJPcjs.builtinPatternIds.call(void 0, ).map((id) => ({ value: id, label: _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id).name }))];
14875
+ }
14876
+ function getPath(o, path) {
14877
+ let v = o;
14878
+ for (const p of path.split(".")) {
14879
+ if (v === null || v === void 0) return void 0;
14880
+ if (Array.isArray(v)) v = p === "last" ? v[v.length - 1] : v[Number(p)];
14881
+ else v = v[p];
14882
+ }
14883
+ return v;
14884
+ }
14885
+ function setPath(o, parts, value) {
14886
+ if (!parts.length) return value;
14887
+ const [p, ...rest] = parts;
14888
+ if (Array.isArray(o)) {
14889
+ const i = p === "last" ? o.length - 1 : Number(p);
14890
+ const out = [...o];
14891
+ out[i] = setPath(o[i], rest, value);
14892
+ return out;
14893
+ }
14894
+ const r = _nullishCoalesce(o, () => ( {}));
14895
+ return { ...r, [p]: setPath(r[p], rest, value) };
14896
+ }
14897
+ function fillControls(f, allowPattern, patterns) {
14898
+ const types = allowPattern ? opt(["color", "Color"], ["gradient", "Gradient"], ["pattern", "Pattern"]) : opt(["color", "Color"], ["gradient", "Gradient"]);
14899
+ const out = [{ key: "fill.type", label: "Fill", type: "select", value: f.type, options: types }];
14900
+ if (f.type === "color") out.push({ key: "fill.color", label: "Color", type: "color", value: f.color });
14901
+ else if (f.type === "gradient") out.push(...gradientControls("fill.gradient", f.gradient));
14902
+ else {
14903
+ out.push(
14904
+ { key: "fill.patternId", label: "Pattern", type: "select", value: f.patternId, options: patternOptions(patterns) },
14905
+ { key: "fill.scale", label: "Scale", type: "range", min: 0.01, max: 10, step: 0.01, value: f.scale, percent: true, unit: "%" }
14906
+ );
14907
+ }
14908
+ return out;
14909
+ }
14910
+ function gradientControls(prefix, g) {
14911
+ return [
14912
+ { key: `${prefix}.stops.0.color`, label: "Start colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _328 => _328.stops, 'access', _329 => _329[0], 'optionalAccess', _330 => _330.color]), () => ( "#000000")) },
14913
+ { key: `${prefix}.stops.last.color`, label: "End colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _331 => _331.stops, 'access', _332 => _332[g.stops.length - 1], 'optionalAccess', _333 => _333.color]), () => ( "#ffffff")) },
14914
+ { key: `${prefix}.style`, label: "Style", type: "select", value: g.style, options: opt(["linear", "Linear"], ["radial", "Radial"], ["angle", "Angle"], ["reflected", "Reflected"], ["diamond", "Diamond"]) },
14915
+ { key: `${prefix}.angle`, label: "Angle", type: "range", min: -180, max: 180, step: 1, value: g.angle, unit: "\xB0" },
14916
+ { key: `${prefix}.scale`, label: "Scale", type: "range", min: 0.1, max: 1.5, step: 0.01, value: g.scale, percent: true, unit: "%" },
14917
+ { key: `${prefix}.reverse`, label: "Reverse", type: "checkbox", value: g.reverse },
14918
+ { key: `${prefix}.align`, label: "Align with layer", type: "checkbox", value: g.align }
14919
+ ];
14920
+ }
14921
+ var px = (key, label, value, max = 250) => ({ key, label, type: "range", min: 0, max, step: 1, value, unit: "px" });
14922
+ var pct2 = (key, label, value, min = 0, max = 1) => ({ key, label, type: "range", min, max, step: 0.01, value, percent: true, unit: "%" });
14923
+ var deg = (key, label, value, min = -180, max = 180) => ({ key, label, type: "range", min, max, step: 1, value, unit: "\xB0" });
14924
+ function layerEffectControls(e, patterns = []) {
14925
+ const blended = e.kind === "bevel-emboss" ? [] : [
14926
+ { key: "blend", label: "Blend mode", type: "select", value: e.blend, options: BLENDS },
14927
+ pct2("opacity", "Opacity", e.opacity)
14928
+ ];
14929
+ switch (e.kind) {
14930
+ case "drop-shadow":
14931
+ case "inner-shadow":
14932
+ return [
14933
+ ...blended,
14934
+ { key: "color", label: "Color", type: "color", value: e.color },
14935
+ { key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
14936
+ deg("angle", "Angle", e.angle),
14937
+ px("distance", "Distance", e.distance, 500),
14938
+ e.kind === "drop-shadow" ? pct2("spread", "Spread", e.spread) : pct2("choke", "Choke", e.choke),
14939
+ px("size", "Size", e.size),
14940
+ pct2("noise", "Noise", e.noise),
14941
+ ...e.kind === "drop-shadow" ? [{ key: "knocksOut", label: "Layer knocks out shadow", type: "checkbox", value: e.knocksOut }] : []
14942
+ ];
14943
+ case "outer-glow":
14944
+ case "inner-glow":
14945
+ return [
14946
+ ...blended,
14947
+ ...fillControls(e.fill, false, patterns),
14948
+ { key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["softer", "Softer"], ["precise", "Precise"]) },
14949
+ ...e.kind === "inner-glow" ? [{ key: "source", label: "Source", type: "select", value: e.source, options: opt(["edge", "Edge"], ["center", "Center"]) }] : [],
14950
+ e.kind === "outer-glow" ? pct2("spread", "Spread", e.spread) : pct2("choke", "Choke", e.choke),
14951
+ px("size", "Size", e.size),
14952
+ pct2("range", "Range", e.range, 0.01, 1),
14953
+ pct2("noise", "Noise", e.noise)
14954
+ ];
14955
+ case "bevel-emboss":
14956
+ return [
14957
+ { key: "style", label: "Style", type: "select", value: e.style, options: opt(["inner-bevel", "Inner Bevel"], ["outer-bevel", "Outer Bevel"], ["emboss", "Emboss"], ["pillow-emboss", "Pillow Emboss"], ["stroke-emboss", "Stroke Emboss"]) },
14958
+ { key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["smooth", "Smooth"], ["chisel-hard", "Chisel Hard"], ["chisel-soft", "Chisel Soft"]) },
14959
+ pct2("depth", "Depth", e.depth, 0, 10),
14960
+ { key: "direction", label: "Direction", type: "select", value: e.direction, options: opt(["up", "Up"], ["down", "Down"]) },
14961
+ px("size", "Size", e.size),
14962
+ px("soften", "Soften", e.soften, 16),
14963
+ { key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
14964
+ deg("angle", "Angle", e.angle),
14965
+ deg("altitude", "Altitude", e.altitude, 0, 90),
14966
+ { key: "highlightColor", label: "Highlight", type: "color", value: e.highlightColor },
14967
+ { key: "highlightBlend", label: "Highlight mode", type: "select", value: e.highlightBlend, options: BLENDS },
14968
+ pct2("highlightOpacity", "Highlight opacity", e.highlightOpacity),
14969
+ { key: "shadowColor", label: "Shadow", type: "color", value: e.shadowColor },
14970
+ { key: "shadowBlend", label: "Shadow mode", type: "select", value: e.shadowBlend, options: BLENDS },
14971
+ pct2("shadowOpacity", "Shadow opacity", e.shadowOpacity)
14972
+ ];
14973
+ case "satin":
14974
+ return [
14975
+ ...blended,
14976
+ { key: "color", label: "Color", type: "color", value: e.color },
14977
+ deg("angle", "Angle", e.angle),
14978
+ px("distance", "Distance", e.distance),
14979
+ px("size", "Size", e.size),
14980
+ { key: "invert", label: "Invert", type: "checkbox", value: e.invert }
14981
+ ];
14982
+ case "color-overlay":
14983
+ return [...blended, { key: "color", label: "Color", type: "color", value: e.color }];
14984
+ case "gradient-overlay":
14985
+ return [...blended, ...gradientControls("gradient", e.gradient)];
14986
+ case "pattern-overlay":
14987
+ return [
14988
+ ...blended,
14989
+ { key: "patternId", label: "Pattern", type: "select", value: e.patternId, options: patternOptions(patterns) },
14990
+ pct2("scale", "Scale", e.scale, 0.01, 10),
14991
+ deg("angle", "Angle", _nullishCoalesce(e.angle, () => ( 0))),
14992
+ { key: "link", label: "Link with layer", type: "checkbox", value: _nullishCoalesce(e.link, () => ( true)) }
14993
+ ];
14994
+ case "stroke":
14995
+ return [
14996
+ ...blended,
14997
+ px("size", "Size", e.size),
14998
+ { key: "position", label: "Position", type: "select", value: e.position, options: opt(["outside", "Outside"], ["inside", "Inside"], ["center", "Center"]) },
14999
+ ...fillControls(e.fill, true, patterns)
15000
+ ];
15001
+ }
15002
+ }
15003
+ function fillOfType(current, type, patterns) {
15004
+ if (type === "gradient") return { type: "gradient", gradient: _chunkWT6ZAWJPcjs.defaultEffectGradient.call(void 0, ) };
15005
+ if (type === "pattern") return { type: "pattern", patternId: _nullishCoalesce(_optionalChain([patterns, 'access', _334 => _334[0], 'optionalAccess', _335 => _335.id]), () => ( "checker")), scale: 1 };
15006
+ return { type: "color", color: current.type === "color" ? current.color : "#000000" };
15007
+ }
15008
+ function effectControlChange(effect, key, value, patterns = []) {
15009
+ const [top, ...rest] = key.split(".");
15010
+ if (top === "fill" && rest[0] === "type") return { fill: fillOfType(effect.fill, String(value), patterns) };
15011
+ if (top === "patternId" && !rest.length) {
15012
+ const name = _optionalChain([patternOptions, 'call', _336 => _336(patterns), 'access', _337 => _337.find, 'call', _338 => _338((o) => o.value === value), 'optionalAccess', _339 => _339.label]);
15013
+ return name ? { patternId: value, name } : { patternId: value };
15014
+ }
15015
+ if (!rest.length) return { [top]: value };
15016
+ if (top === "fill" && rest[0] === "patternId") {
15017
+ const name = _optionalChain([patternOptions, 'call', _340 => _340(patterns), 'access', _341 => _341.find, 'call', _342 => _342((o) => o.value === value), 'optionalAccess', _343 => _343.label]);
15018
+ return { fill: { ...effect.fill, patternId: value, ...name ? { name } : {} } };
15019
+ }
15020
+ return { [top]: setPath(getPath(effect, top), rest, value) };
15021
+ }
15022
+
13922
15023
  // src/image-editor/psd/ui.ts
13923
15024
  var PSD_FILE_ACCEPT = ".psd,.psb,image/vnd.adobe.photoshop,application/x-photoshop";
13924
15025
  function blobBytes(file) {
@@ -14422,5 +15523,63 @@ async function downloadPsd(controller, name = "image") {
14422
15523
 
14423
15524
 
14424
15525
 
14425
- exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_GLOBAL_LIGHT = _chunkT422YCHRcjs.DEFAULT_GLOBAL_LIGHT; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunkT422YCHRcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LAYER_EFFECT_KINDS = _chunkT422YCHRcjs.LAYER_EFFECT_KINDS; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerEffectError = _chunkT422YCHRcjs.LayerEffectError; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_EFFECT_REACH = _chunkT422YCHRcjs.MAX_EFFECT_REACH; exports.MAX_KELVIN = MAX_KELVIN; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PatternPlacement = _chunkT422YCHRcjs.PatternPlacement; exports.PatternTile = _chunkT422YCHRcjs.PatternTile; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunkT422YCHRcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunkT422YCHRcjs.adler32; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunkT422YCHRcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunkT422YCHRcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.builtinPattern = _chunkT422YCHRcjs.builtinPattern; exports.builtinPatternIds = _chunkT422YCHRcjs.builtinPatternIds; exports.bytesToBase64 = _chunkT422YCHRcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunkT422YCHRcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunkT422YCHRcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunkT422YCHRcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.defaultEffectGradient = _chunkT422YCHRcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunkT422YCHRcjs.defaultLayerEffect; exports.deflate = _chunkT422YCHRcjs.deflate; exports.deflateRaw = _chunkT422YCHRcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializePatterns = deserializePatterns; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.effectColorHex = _chunkT422YCHRcjs.effectColorHex; exports.effectReach = _chunkT422YCHRcjs.effectReach; exports.effectsFingerprint = _chunkT422YCHRcjs.effectsFingerprint; exports.effectsMargin = _chunkT422YCHRcjs.effectsMargin; exports.effectsScale = _chunkT422YCHRcjs.effectsScale; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunkT422YCHRcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunkT422YCHRcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunkT422YCHRcjs.flattenLayers; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunkT422YCHRcjs.gaussianBlur; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasActiveEffects = _chunkT422YCHRcjs.hasActiveEffects; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hashMaskContent = hashMaskContent; exports.hashNoise = _chunkT422YCHRcjs.hashNoise; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunkT422YCHRcjs.inflate; exports.inflateRaw = _chunkT422YCHRcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunkT422YCHRcjs.insertLayer; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isLayerEffectKind = _chunkT422YCHRcjs.isLayerEffectKind; exports.isLayerLocked = _chunkT422YCHRcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunkT422YCHRcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.kelvinToTemperature = kelvinToTemperature; exports.layerBadge = layerBadge; exports.layerEffectFields = _chunkT422YCHRcjs.layerEffectFields; exports.layerEffectLabel = _chunkT422YCHRcjs.layerEffectLabel; exports.layerEffectsOf = layerEffectsOf; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunkT422YCHRcjs.mapLayer; exports.maskSummary = maskSummary; exports.mergeLayerEffect = _chunkT422YCHRcjs.mergeLayerEffect; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newEffectId = _chunkT422YCHRcjs.newEffectId; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerEffects = _chunkT422YCHRcjs.normalizeLayerEffects; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunkT422YCHRcjs.parseDataUrl; exports.parseEffectColor = _chunkT422YCHRcjs.parseEffectColor; exports.parseLfx2 = parseLfx2; exports.parseLrfx = parseLrfx; exports.parsePatternBlock = parsePatternBlock; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunkT422YCHRcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.psdToLayers = psdToLayers; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayerEffects = _chunkT422YCHRcjs.renderLayerEffects; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.scaleLayerEffect = _chunkT422YCHRcjs.scaleLayerEffect; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializePatterns = serializePatterns; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.validateEffectGradient = _chunkT422YCHRcjs.validateEffectGradient; exports.validateLayerEffect = _chunkT422YCHRcjs.validateLayerEffect; exports.validateLayerEffects = _chunkT422YCHRcjs.validateLayerEffects; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writeLfx2 = writeLfx2; exports.writePatternBlock = writePatternBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
15526
+
15527
+
15528
+
15529
+
15530
+
15531
+
15532
+
15533
+
15534
+
15535
+
15536
+
15537
+
15538
+
15539
+
15540
+
15541
+
15542
+
15543
+
15544
+
15545
+
15546
+
15547
+
15548
+
15549
+
15550
+
15551
+
15552
+
15553
+
15554
+
15555
+
15556
+
15557
+
15558
+
15559
+
15560
+
15561
+
15562
+
15563
+
15564
+
15565
+
15566
+
15567
+
15568
+
15569
+
15570
+
15571
+
15572
+
15573
+
15574
+
15575
+
15576
+
15577
+
15578
+
15579
+
15580
+
15581
+
15582
+
15583
+
15584
+ exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_GLOBAL_LIGHT = _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunkWT6ZAWJPcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.FREE_TRANSFORM_CONTENTS = FREE_TRANSFORM_CONTENTS; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.FreeTransformSession = FreeTransformSession; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.INTERPOLATIONS = _chunkWT6ZAWJPcjs.INTERPOLATIONS; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LAYER_EFFECT_KINDS = _chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS; exports.LAYER_EFFECT_MENU = LAYER_EFFECT_MENU; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerEffectError = _chunkWT6ZAWJPcjs.LayerEffectError; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_EFFECT_REACH = _chunkWT6ZAWJPcjs.MAX_EFFECT_REACH; exports.MAX_KELVIN = MAX_KELVIN; exports.MAX_TRANSFORM_PIXELS = _chunkWT6ZAWJPcjs.MAX_TRANSFORM_PIXELS; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PatternPlacement = _chunkWT6ZAWJPcjs.PatternPlacement; exports.PatternTile = _chunkWT6ZAWJPcjs.PatternTile; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.TransformTooLargeError = _chunkWT6ZAWJPcjs.TransformTooLargeError; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.WARP_STYLES = _chunkDWGZUSEScjs.WARP_STYLES; exports.WARP_STYLE_LABELS = _chunkDWGZUSEScjs.WARP_STYLE_LABELS; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunkWT6ZAWJPcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunkWT6ZAWJPcjs.adler32; exports.anchorPoint = anchorPoint; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyHomography = _chunkMUUXNRU4cjs.applyHomography; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyParams = applyParams; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunkWT6ZAWJPcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunkWT6ZAWJPcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxPointOf = boxPointOf; exports.boxQuad = _chunkMUUXNRU4cjs.boxQuad; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.builtinPattern = _chunkWT6ZAWJPcjs.builtinPattern; exports.builtinPatternIds = _chunkWT6ZAWJPcjs.builtinPatternIds; exports.bytesToBase64 = _chunkWT6ZAWJPcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunkWT6ZAWJPcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.compositeSurfaceOver = _chunkWT6ZAWJPcjs.compositeSurfaceOver; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.cornersFromMatrix = cornersFromMatrix; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createImageTransformTools = createImageTransformTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunkWT6ZAWJPcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunkWT6ZAWJPcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.defaultEffectGradient = _chunkWT6ZAWJPcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunkWT6ZAWJPcjs.defaultLayerEffect; exports.deflate = _chunkWT6ZAWJPcjs.deflate; exports.deflateRaw = _chunkWT6ZAWJPcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.describeTransform = describeTransform; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializePatterns = deserializePatterns; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dragWarpMeshPoint = _chunkDWGZUSEScjs.dragWarpMeshPoint; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.effectColorHex = _chunkWT6ZAWJPcjs.effectColorHex; exports.effectControlChange = effectControlChange; exports.effectReach = _chunkWT6ZAWJPcjs.effectReach; exports.effectsFingerprint = _chunkWT6ZAWJPcjs.effectsFingerprint; exports.effectsMargin = _chunkWT6ZAWJPcjs.effectsMargin; exports.effectsScale = _chunkWT6ZAWJPcjs.effectsScale; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunkWT6ZAWJPcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evalWarpMesh = _chunkDWGZUSEScjs.evalWarpMesh; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunkWT6ZAWJPcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunkWT6ZAWJPcjs.flattenLayers; exports.flipCorners = flipCorners; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunkWT6ZAWJPcjs.gaussianBlur; exports.geometryHomography = geometryHomography; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasActiveEffects = _chunkWT6ZAWJPcjs.hasActiveEffects; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hasWarp = hasWarp; exports.hashMaskContent = hashMaskContent; exports.hashNoise = _chunkWT6ZAWJPcjs.hashNoise; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.homographyFromAffine = _chunkMUUXNRU4cjs.homographyFromAffine; exports.homographyFromPoints = _chunkMUUXNRU4cjs.homographyFromPoints; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.identityTransform = identityTransform; exports.identityWarpMesh = _chunkDWGZUSEScjs.identityWarpMesh; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunkWT6ZAWJPcjs.inflate; exports.inflateRaw = _chunkWT6ZAWJPcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunkWT6ZAWJPcjs.insertLayer; exports.invertHomography = _chunkMUUXNRU4cjs.invertHomography; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isIdentityTransform = isIdentityTransform; exports.isInterpolation = _chunkWT6ZAWJPcjs.isInterpolation; exports.isLayerEffectKind = _chunkWT6ZAWJPcjs.isLayerEffectKind; exports.isLayerLocked = _chunkWT6ZAWJPcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunkWT6ZAWJPcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.isTransformAnchor = isTransformAnchor; exports.isValidWarp = isValidWarp; exports.kelvinToTemperature = kelvinToTemperature; exports.keysWeight = _chunkWT6ZAWJPcjs.keysWeight; exports.layerBadge = layerBadge; exports.layerEffectControls = layerEffectControls; exports.layerEffectFields = _chunkWT6ZAWJPcjs.layerEffectFields; exports.layerEffectLabel = _chunkWT6ZAWJPcjs.layerEffectLabel; exports.layerEffectsBadge = layerEffectsBadge; exports.layerEffectsOf = layerEffectsOf; exports.layerEffectsPanel = layerEffectsPanel; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunkWT6ZAWJPcjs.mapLayer; exports.maskSummary = maskSummary; exports.matrixFromCorners = matrixFromCorners; exports.matrixFromParams = matrixFromParams; exports.mergeLayerEffect = _chunkWT6ZAWJPcjs.mergeLayerEffect; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newEffectId = _chunkWT6ZAWJPcjs.newEffectId; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerEffects = _chunkWT6ZAWJPcjs.normalizeLayerEffects; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunkWT6ZAWJPcjs.parseDataUrl; exports.parseEffectColor = _chunkWT6ZAWJPcjs.parseEffectColor; exports.parseLfx2 = parseLfx2; exports.parseLrfx = parseLrfx; exports.parsePatternBlock = parsePatternBlock; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunkWT6ZAWJPcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.presetWarp = presetWarp; exports.previewStep = previewStep; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.psdToLayers = psdToLayers; exports.pullWarpMesh = _chunkDWGZUSEScjs.pullWarpMesh; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.rectToQuad = _chunkMUUXNRU4cjs.rectToQuad; exports.reduceSurface = _chunkWT6ZAWJPcjs.reduceSurface; exports.referencePoint = referencePoint; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayerEffects = _chunkWT6ZAWJPcjs.renderLayerEffects; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resizeWarpMesh = _chunkDWGZUSEScjs.resizeWarpMesh; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.scaleLayerEffect = _chunkWT6ZAWJPcjs.scaleLayerEffect; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializePatterns = serializePatterns; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.transformHomography = transformHomography; exports.transformMap = transformMap; exports.transformSurface = _chunkWT6ZAWJPcjs.transformSurface; exports.transformedBounds = _chunkWT6ZAWJPcjs.transformedBounds; exports.transformedBox = transformedBox; exports.transformedPoint = transformedPoint; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.validateEffectGradient = _chunkWT6ZAWJPcjs.validateEffectGradient; exports.validateLayerEffect = _chunkWT6ZAWJPcjs.validateLayerEffect; exports.validateLayerEffects = _chunkWT6ZAWJPcjs.validateLayerEffects; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.warpMeshEditPoints = _chunkDWGZUSEScjs.warpMeshEditPoints; exports.warpMeshGridCurves = _chunkDWGZUSEScjs.warpMeshGridCurves; exports.warpMeshParamAt = _chunkDWGZUSEScjs.warpMeshParamAt; exports.warpPresetMesh = _chunkDWGZUSEScjs.warpPresetMesh; exports.warpSurface = _chunkWT6ZAWJPcjs.warpSurface; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writeLfx2 = writeLfx2; exports.writePatternBlock = writePatternBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
14426
15585
  //# sourceMappingURL=index.cjs.map