@pixerate/editor 0.120.0 → 0.121.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 (48) hide show
  1. package/dist/{chunk-UMVW2Q66.js → chunk-4I54JSJ6.js} +2 -2
  2. package/dist/{chunk-N3467VD6.js → chunk-7QN76ESJ.js} +1 -179
  3. package/dist/chunk-7QN76ESJ.js.map +1 -0
  4. package/dist/{chunk-EJVDBITD.cjs → chunk-DCLJNVZS.cjs} +2 -180
  5. package/dist/chunk-DCLJNVZS.cjs.map +1 -0
  6. package/dist/{chunk-BOWUU4LJ.js → chunk-E6N5KLMA.js} +11 -9
  7. package/dist/{chunk-BOWUU4LJ.js.map → chunk-E6N5KLMA.js.map} +1 -1
  8. package/dist/{chunk-HTAFDTNR.cjs → chunk-GLOOH65Y.cjs} +156 -154
  9. package/dist/chunk-GLOOH65Y.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-TS5IEUW6.cjs → chunk-K7V27T72.cjs} +178 -3
  13. package/dist/chunk-K7V27T72.cjs.map +1 -0
  14. package/dist/{chunk-WMRIG4XQ.cjs → chunk-LL3RAN55.cjs} +17 -17
  15. package/dist/{chunk-WMRIG4XQ.cjs.map → chunk-LL3RAN55.cjs.map} +1 -1
  16. package/dist/chunk-MUUXNRU4.cjs +181 -0
  17. package/dist/chunk-MUUXNRU4.cjs.map +1 -0
  18. package/dist/{chunk-YHW26LS2.js → chunk-ZZPGTNXJ.js} +177 -2
  19. package/dist/chunk-ZZPGTNXJ.js.map +1 -0
  20. package/dist/image-editor/index.cjs +754 -734
  21. package/dist/image-editor/index.cjs.map +1 -1
  22. package/dist/image-editor/index.d.cts +1 -1
  23. package/dist/image-editor/index.d.ts +1 -1
  24. package/dist/image-editor/index.js +31 -11
  25. package/dist/image-editor/index.js.map +1 -1
  26. package/dist/paint/index.cjs +22 -2
  27. package/dist/paint/index.cjs.map +1 -1
  28. package/dist/paint/index.d.cts +159 -1
  29. package/dist/paint/index.d.ts +159 -1
  30. package/dist/paint/index.js +21 -1
  31. package/dist/paint-editor/index.cjs +95 -94
  32. package/dist/paint-editor/index.cjs.map +1 -1
  33. package/dist/paint-editor/index.js +12 -11
  34. package/dist/paint-editor/index.js.map +1 -1
  35. package/dist/raster/index.cjs +5 -4
  36. package/dist/raster/index.cjs.map +1 -1
  37. package/dist/raster/index.js +11 -10
  38. package/dist/vector/index.cjs +14 -12
  39. package/dist/vector/index.cjs.map +1 -1
  40. package/dist/vector/index.js +7 -5
  41. package/dist/vector/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-EJVDBITD.cjs.map +0 -1
  44. package/dist/chunk-HTAFDTNR.cjs.map +0 -1
  45. package/dist/chunk-N3467VD6.js.map +0 -1
  46. package/dist/chunk-TS5IEUW6.cjs.map +0 -1
  47. package/dist/chunk-YHW26LS2.js.map +0 -1
  48. /package/dist/{chunk-UMVW2Q66.js.map → chunk-4I54JSJ6.js.map} +0 -0
@@ -7,7 +7,7 @@ var _chunkSMJGE7HMcjs = require('../chunk-SMJGE7HM.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkHTAFDTNRcjs = require('../chunk-HTAFDTNR.cjs');
10
+ var _chunkGLOOH65Ycjs = require('../chunk-GLOOH65Y.cjs');
11
11
 
12
12
 
13
13
 
@@ -15,7 +15,8 @@ var _chunkHTAFDTNRcjs = require('../chunk-HTAFDTNR.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkWMRIG4XQcjs = require('../chunk-WMRIG4XQ.cjs');
18
+ var _chunkLL3RAN55cjs = require('../chunk-LL3RAN55.cjs');
19
+ require('../chunk-MUUXNRU4.cjs');
19
20
 
20
21
 
21
22
 
@@ -24,7 +25,6 @@ var _chunkWMRIG4XQcjs = require('../chunk-WMRIG4XQ.cjs');
24
25
 
25
26
 
26
27
 
27
- var _chunkEJVDBITDcjs = require('../chunk-EJVDBITD.cjs');
28
28
 
29
29
 
30
30
 
@@ -60,6 +60,7 @@ var _chunkEJVDBITDcjs = require('../chunk-EJVDBITD.cjs');
60
60
 
61
61
 
62
62
 
63
+ var _chunkL3PXFMOFcjs = require('../chunk-L3PXFMOF.cjs');
63
64
 
64
65
 
65
66
 
@@ -68,7 +69,6 @@ var _chunkEJVDBITDcjs = require('../chunk-EJVDBITD.cjs');
68
69
 
69
70
 
70
71
 
71
- var _chunkL3PXFMOFcjs = require('../chunk-L3PXFMOF.cjs');
72
72
 
73
73
 
74
74
 
@@ -82,6 +82,7 @@ var _chunkL3PXFMOFcjs = require('../chunk-L3PXFMOF.cjs');
82
82
 
83
83
 
84
84
 
85
+ var _chunk7ISPWEJAcjs = require('../chunk-7ISPWEJA.cjs');
85
86
 
86
87
 
87
88
 
@@ -90,7 +91,7 @@ var _chunkL3PXFMOFcjs = require('../chunk-L3PXFMOF.cjs');
90
91
 
91
92
 
92
93
 
93
- var _chunk7ISPWEJAcjs = require('../chunk-7ISPWEJA.cjs');
94
+ var _chunkDCLJNVZScjs = require('../chunk-DCLJNVZS.cjs');
94
95
  require('../chunk-G5NMLUVF.cjs');
95
96
  require('../chunk-643B2HKC.cjs');
96
97
 
@@ -2592,15 +2593,15 @@ function reliefInfo(ch) {
2592
2593
  function thickToJSON(ch) {
2593
2594
  const b = ch.height.bounds;
2594
2595
  if (!b) return null;
2595
- return { rect: { ...b }, height: _chunkEJVDBITDcjs.pngDataUrl.call(void 0, b.width, b.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, ch.height, b), 1), material: _chunkEJVDBITDcjs.pngDataUrl.call(void 0, b.width, b.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, ch.material, b), 4) };
2596
+ return { rect: { ...b }, height: _chunkDCLJNVZScjs.pngDataUrl.call(void 0, b.width, b.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, ch.height, b), 1), material: _chunkDCLJNVZScjs.pngDataUrl.call(void 0, b.width, b.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, ch.material, b), 4) };
2596
2597
  }
2597
2598
  function thickFromJSON(raw) {
2598
2599
  const r = raw;
2599
2600
  if (!r || typeof r !== "object" || !r.rect || typeof r.height !== "string" || typeof r.material !== "string") throw new Error("not saved thick-paint channels");
2600
2601
  const decode = (url, gray) => {
2601
- const parsed = _chunkEJVDBITDcjs.parseDataUrl.call(void 0, url);
2602
+ const parsed = _chunkDCLJNVZScjs.parseDataUrl.call(void 0, url);
2602
2603
  if (!parsed) throw new Error("a channel is not a PNG data URL");
2603
- return _chunkEJVDBITDcjs.decodePng.call(void 0, parsed.bytes, { keepGray: gray });
2604
+ return _chunkDCLJNVZScjs.decodePng.call(void 0, parsed.bytes, { keepGray: gray });
2604
2605
  };
2605
2606
  const h = decode(r.height, true);
2606
2607
  const m = decode(r.material, false);
@@ -3223,7 +3224,7 @@ var PROFILE = {
3223
3224
  }
3224
3225
  };
3225
3226
  function createPaintCompositor() {
3226
- return new (0, _chunkWMRIG4XQcjs.RasterCompositor)(PROFILE);
3227
+ return new (0, _chunkLL3RAN55cjs.RasterCompositor)(PROFILE);
3227
3228
  }
3228
3229
  function downsampleRgba(data, width, height, tw, th) {
3229
3230
  tw = Math.max(1, Math.round(tw));
@@ -3298,11 +3299,11 @@ function header(state, options) {
3298
3299
  return out;
3299
3300
  }
3300
3301
  function serializePaintDocument(state, options = {}) {
3301
- const { layers, assets } = _chunkHTAFDTNRcjs.serializeLayers.call(void 0, state.layers);
3302
+ const { layers, assets } = _chunkGLOOH65Ycjs.serializeLayers.call(void 0, state.layers);
3302
3303
  return { ...header(state, options), layers, assets };
3303
3304
  }
3304
3305
  async function serializePaintDocumentExternal(state, store, options = {}) {
3305
- const { layers, assets } = await _chunkHTAFDTNRcjs.serializeLayersExternal.call(void 0, state.layers, store);
3306
+ const { layers, assets } = await _chunkGLOOH65Ycjs.serializeLayersExternal.call(void 0, state.layers, store);
3306
3307
  return { ...header(state, options), layers, assets };
3307
3308
  }
3308
3309
  function paintLayersOnly(layers, problems) {
@@ -3339,9 +3340,9 @@ function deserializePaintDocument(raw) {
3339
3340
  const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
3340
3341
  const paper = normalizePaper(_nullishCoalesce(r.paper, () => ( {})));
3341
3342
  const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
3342
- const layers = paintLayersOnly(_chunkHTAFDTNRcjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
3343
+ const layers = paintLayersOnly(_chunkGLOOH65Ycjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
3343
3344
  const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
3344
- const activeLayerId = wanted && _chunkWMRIG4XQcjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkWMRIG4XQcjs.flattenLayers.call(void 0, layers), 'access', _73 => _73.filter, 'call', _74 => _74((l) => l.type === "pixel"), 'access', _75 => _75.pop, 'call', _76 => _76(), 'optionalAccess', _77 => _77.id]), () => ( null));
3345
+ const activeLayerId = wanted && _chunkLL3RAN55cjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkLL3RAN55cjs.flattenLayers.call(void 0, layers), 'access', _73 => _73.filter, 'call', _74 => _74((l) => l.type === "pixel"), 'access', _75 => _75.pop, 'call', _76 => _76(), 'optionalAccess', _77 => _77.id]), () => ( null));
3345
3346
  const wetEvents = Array.isArray(r.wetEvents) ? r.wetEvents.filter((e) => e && typeof e === "object" && Number.isInteger(e.clock) && typeof e.kind === "string") : [];
3346
3347
  const state = { canvas, paper, layers, activeLayerId, strokes: readStrokes(r.strokes, problems) };
3347
3348
  if (wetEvents.length) state.wetEvents = wetEvents;
@@ -3353,7 +3354,7 @@ async function deserializePaintDocumentAsync(raw, store) {
3353
3354
  if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
3354
3355
  const r = raw;
3355
3356
  const problems = [];
3356
- const assets = await _chunkHTAFDTNRcjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
3357
+ const assets = await _chunkGLOOH65Ycjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
3357
3358
  const loaded = deserializePaintDocument({ ...r, assets });
3358
3359
  return { ...loaded, problems: [...problems, ...loaded.problems] };
3359
3360
  }
@@ -4550,13 +4551,13 @@ var MixingPad = (_class16 = class {constructor() { _class16.prototype.__init82.c
4550
4551
  }
4551
4552
  /** The pad's pixels as a PNG data URL (with alpha), for saving. */
4552
4553
  toPng() {
4553
- return _chunkEJVDBITDcjs.pngDataUrl.call(void 0, this.width, this.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, this.surface, { x: 0, y: 0, width: this.width, height: this.height }));
4554
+ return _chunkDCLJNVZScjs.pngDataUrl.call(void 0, this.width, this.height, _chunk7ISPWEJAcjs.readRegion.call(void 0, this.surface, { x: 0, y: 0, width: this.width, height: this.height }));
4554
4555
  }
4555
4556
  /** Replaces the pad with a PNG (data URL or base64) of the pad's size, as `toPng` writes. */
4556
4557
  fromPng(png) {
4557
- const bytes = png.startsWith("data:") ? _optionalChain([_chunkEJVDBITDcjs.parseDataUrl.call(void 0, png), 'optionalAccess', _125 => _125.bytes]) : _chunkEJVDBITDcjs.base64ToBytes.call(void 0, png);
4558
- if (!bytes || !_chunkEJVDBITDcjs.isPng.call(void 0, bytes)) throw new Error("The pad image is not a PNG data URL or base64 PNG.");
4559
- const img = _chunkEJVDBITDcjs.decodePng.call(void 0, bytes);
4558
+ const bytes = png.startsWith("data:") ? _optionalChain([_chunkDCLJNVZScjs.parseDataUrl.call(void 0, png), 'optionalAccess', _125 => _125.bytes]) : _chunkDCLJNVZScjs.base64ToBytes.call(void 0, png);
4559
+ if (!bytes || !_chunkDCLJNVZScjs.isPng.call(void 0, bytes)) throw new Error("The pad image is not a PNG data URL or base64 PNG.");
4560
+ const img = _chunkDCLJNVZScjs.decodePng.call(void 0, bytes);
4560
4561
  if (img.width !== this.width || img.height !== this.height) throw new Error(`The pad image is ${img.width}\xD7${img.height}; a mixing pad is ${this.width}\xD7${this.height}.`);
4561
4562
  this.surface = _chunk7ISPWEJAcjs.surfaceFromPixels.call(void 0, { width: img.width, height: img.height, data: img.data }, 4);
4562
4563
  this.version++;
@@ -4591,7 +4592,7 @@ function replayItems(doc) {
4591
4592
  }
4592
4593
  function emptiedLayers(layers) {
4593
4594
  let out = [...layers];
4594
- for (const l of _chunkWMRIG4XQcjs.flattenLayers.call(void 0, layers)) if (l.type === "pixel") out = _chunkWMRIG4XQcjs.mapLayer.call(void 0, out, l.id, () => ({ ...l, surface: _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } }));
4595
+ for (const l of _chunkLL3RAN55cjs.flattenLayers.call(void 0, layers)) if (l.type === "pixel") out = _chunkLL3RAN55cjs.mapLayer.call(void 0, out, l.id, () => ({ ...l, surface: _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } }));
4595
4596
  return out;
4596
4597
  }
4597
4598
  async function replayPainting(source, target, options = {}) {
@@ -4723,7 +4724,7 @@ async function buildTimeLapse(source, target, options = {}) {
4723
4724
  const f = replayFrame(target, maxSide, stroke);
4724
4725
  width = f.width;
4725
4726
  height = f.height;
4726
- frames.push(_chunkEJVDBITDcjs.encodePng.call(void 0, f.width, f.height, f.data));
4727
+ frames.push(_chunkDCLJNVZScjs.encodePng.call(void 0, f.width, f.height, f.data));
4727
4728
  };
4728
4729
  shoot(0);
4729
4730
  await replayPainting(source, target, {
@@ -4852,12 +4853,12 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
4852
4853
  canvas: () => this.doc.canvas,
4853
4854
  paper: () => this.doc.paper,
4854
4855
  layerSurface: (id) => {
4855
- const l = _optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _143 => _143.layer]);
4856
+ const l = _optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _143 => _143.layer]);
4856
4857
  return isPixelLayer(l) ? l.surface : null;
4857
4858
  },
4858
4859
  updateSurfaces: (surfaces, rects) => {
4859
4860
  let layers = this.doc.layers;
4860
- for (const [id, surface] of surfaces) if (_chunkWMRIG4XQcjs.findLayer.call(void 0, layers, id)) layers = _chunkWMRIG4XQcjs.mapLayer.call(void 0, layers, id, (l) => ({ ...l, surface }));
4861
+ for (const [id, surface] of surfaces) if (_chunkLL3RAN55cjs.findLayer.call(void 0, layers, id)) layers = _chunkLL3RAN55cjs.mapLayer.call(void 0, layers, id, (l) => ({ ...l, surface }));
4861
4862
  this.doc = { ...this.doc, layers };
4862
4863
  this.emit(rects.length ? rects : "all");
4863
4864
  },
@@ -5098,7 +5099,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5098
5099
  }
5099
5100
  // --- Layers --------------------------------------------------------------------
5100
5101
  getLayer(id) {
5101
- return _optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _155 => _155.layer]);
5102
+ return _optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _155 => _155.layer]);
5102
5103
  }
5103
5104
  /** The active pixel layer (or `undefined`). */
5104
5105
  getActiveLayer() {
@@ -5117,12 +5118,12 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5117
5118
  walk(this.doc.layers, null, 0);
5118
5119
  return out;
5119
5120
  }
5120
- describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _156 => _156.parent, 'optionalAccess', _157 => _157.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _158 => _158.path, 'access', _159 => _159.length]), () => ( 0))) {
5121
+ describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _156 => _156.parent, 'optionalAccess', _157 => _157.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _158 => _158.path, 'access', _159 => _159.length]), () => ( 0))) {
5121
5122
  let bounds = null;
5122
5123
  if (l.type === "pixel") {
5123
5124
  const b = _chunk7ISPWEJAcjs.contentBounds.call(void 0, l.surface);
5124
5125
  bounds = b ? { ...b, x: b.x + l.offset.x, y: b.y + l.offset.y } : null;
5125
- } else for (const c of _chunkWMRIG4XQcjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
5126
+ } else for (const c of _chunkLL3RAN55cjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
5126
5127
  return {
5127
5128
  id: l.id,
5128
5129
  name: l.name,
@@ -5149,7 +5150,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5149
5150
  if (!id) throw new PaintEditorError(`There is no active layer to ${what}; add one with add_layer.`);
5150
5151
  const l = this.requireLayer(id);
5151
5152
  if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; ${what} a pixel layer inside it.`);
5152
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) before you ${what} it.`);
5153
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) before you ${what} it.`);
5153
5154
  if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) before you ${what} it.`);
5154
5155
  return l;
5155
5156
  }
@@ -5162,7 +5163,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5162
5163
  /** Adds an empty pixel layer or group above `aboveId` (default: the active layer) and makes it active. */
5163
5164
  addLayer(options = {}) {
5164
5165
  this.requireIdle("adding a layer");
5165
- const count = _chunkWMRIG4XQcjs.flattenLayers.call(void 0, this.doc.layers).length;
5166
+ const count = _chunkLL3RAN55cjs.flattenLayers.call(void 0, this.doc.layers).length;
5166
5167
  const type = _nullishCoalesce(options.type, () => ( "pixel"));
5167
5168
  const name = _optionalChain([options, 'access', _160 => _160.name, 'optionalAccess', _161 => _161.trim, 'call', _162 => _162()]) || (type === "group" ? `Group ${count + 1}` : `Layer ${count + 1}`);
5168
5169
  const layer = type === "group" ? { type: "group", id: newPaintLayerId(), name, visible: true, opacity: 1, blend: "pass-through", children: [] } : createPaintLayer(name);
@@ -5174,19 +5175,19 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5174
5175
  if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
5175
5176
  parentId = g.id;
5176
5177
  } else if (above) {
5177
- const loc = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, above);
5178
+ const loc = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, above);
5178
5179
  if (!loc) throw new PaintEditorError(`Unknown layer "${above}". Call list_layers for the ids.`);
5179
5180
  parentId = _nullishCoalesce(_optionalChain([loc, 'access', _163 => _163.parent, 'optionalAccess', _164 => _164.id]), () => ( null));
5180
5181
  index = loc.index + 1;
5181
5182
  }
5182
- const layers = _chunkWMRIG4XQcjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
5183
+ const layers = _chunkLL3RAN55cjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
5183
5184
  this.commit(type === "group" ? "Add group" : "Add layer", { ...this.doc, layers, activeLayerId: layer.id });
5184
5185
  return this.describeLayer(layer);
5185
5186
  }
5186
5187
  updateLayer(id, update) {
5187
5188
  this.requireIdle("changing a layer");
5188
5189
  const l = this.requireLayer(id);
5189
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "all") && Object.keys(update).some((k) => k !== "locks")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it first (locks {all: false}).`);
5190
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "all") && Object.keys(update).some((k) => k !== "locks")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it first (locks {all: false}).`);
5190
5191
  if (update.opacity !== void 0 && !(update.opacity >= 0 && update.opacity <= 1)) throw new PaintEditorError(`opacity ${update.opacity} is out of range; use 0..1.`);
5191
5192
  if (update.blend !== void 0 && !_chunk7ISPWEJAcjs.isBlendMode.call(void 0, update.blend) && !(l.type === "group" && update.blend === "pass-through")) {
5192
5193
  throw new PaintEditorError(`Unknown blend mode "${update.blend}". Call get_canvas_info for the blend modes.`);
@@ -5202,31 +5203,31 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5202
5203
  const locks = { ..._nullishCoalesce(l.locks, () => ( {})), ...update.locks };
5203
5204
  next.locks = Object.values(locks).some(Boolean) ? locks : void 0;
5204
5205
  }
5205
- this.commit("Layer properties", { ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
5206
+ this.commit("Layer properties", { ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
5206
5207
  return this.describeLayer(next);
5207
5208
  }
5208
5209
  removeLayer(id) {
5209
5210
  this.requireIdle("removing a layer");
5210
5211
  const l = this.requireLayer(id);
5211
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
5212
- const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" && _chunkWMRIG4XQcjs.findLayer.call(void 0, l.children, x));
5212
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
5213
+ const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" && _chunkLL3RAN55cjs.findLayer.call(void 0, l.children, x));
5213
5214
  if (wetIds.length) {
5214
5215
  this.beginWetOp();
5215
5216
  for (const x of wetIds) this.wet.world.removeLane(x);
5216
5217
  }
5217
- const layers = _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
5218
+ const layers = _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
5218
5219
  let active = this.doc.activeLayerId;
5219
- if (active && !_chunkWMRIG4XQcjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkWMRIG4XQcjs.flattenLayers.call(void 0, layers), 'access', _165 => _165.filter, 'call', _166 => _166((x) => x.type === "pixel"), 'access', _167 => _167.pop, 'call', _168 => _168(), 'optionalAccess', _169 => _169.id]), () => ( null));
5220
- this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(_chunkWMRIG4XQcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)), ...this.stickersWithout(_chunkWMRIG4XQcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)) });
5220
+ if (active && !_chunkLL3RAN55cjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkLL3RAN55cjs.flattenLayers.call(void 0, layers), 'access', _165 => _165.filter, 'call', _166 => _166((x) => x.type === "pixel"), 'access', _167 => _167.pop, 'call', _168 => _168(), 'optionalAccess', _169 => _169.id]), () => ( null));
5221
+ this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(_chunkLL3RAN55cjs.flattenLayers.call(void 0, [l]).map((x) => x.id)), ...this.stickersWithout(_chunkLL3RAN55cjs.flattenLayers.call(void 0, [l]).map((x) => x.id)) });
5221
5222
  return { removed: id, activeLayerId: active };
5222
5223
  }
5223
5224
  duplicateLayer(id) {
5224
5225
  this.requireIdle("duplicating a layer");
5225
- if (_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id)) {
5226
+ if (_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id)) {
5226
5227
  const inside = (l) => l.type === "group" ? l.children.flatMap(inside) : [l.id];
5227
- this.dryLayersFirst(inside(_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id).layer));
5228
+ this.dryLayersFirst(inside(_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id).layer));
5228
5229
  }
5229
- const loc = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id);
5230
+ const loc = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id);
5230
5231
  if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
5231
5232
  const thick = { ..._nullishCoalesce(this.doc.thick, () => ( {})) };
5232
5233
  const stickers = { ..._nullishCoalesce(this.doc.stickers, () => ( {})) };
@@ -5237,43 +5238,43 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5237
5238
  return l.type === "group" ? { ...l, id: id2, children: l.children.map(copy) } : { ...l, id: id2 };
5238
5239
  };
5239
5240
  const dup = { ...copy(loc.layer), name: `${loc.layer.name} copy` };
5240
- const layers = _chunkWMRIG4XQcjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _170 => _170.parent, 'optionalAccess', _171 => _171.id]), () => ( null)), loc.index + 1);
5241
+ const layers = _chunkLL3RAN55cjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _170 => _170.parent, 'optionalAccess', _171 => _171.id]), () => ( null)), loc.index + 1);
5241
5242
  this.commit("Duplicate layer", this.withWetEvents({ ...this.doc, layers, activeLayerId: dup.id, ...this.doc.thick ? { thick } : {}, ...this.doc.stickers ? { stickers } : {} }));
5242
5243
  return this.describeLayer(dup);
5243
5244
  }
5244
5245
  /** Moves a layer to `index` (0 = bottom) within `parentId` (default its own parent; `null` = top level). */
5245
5246
  moveLayer(id, index, parentId) {
5246
5247
  this.requireIdle("moving a layer");
5247
- const loc = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id);
5248
+ const loc = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id);
5248
5249
  if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
5249
5250
  const target = parentId === void 0 ? _nullishCoalesce(_optionalChain([loc, 'access', _172 => _172.parent, 'optionalAccess', _173 => _173.id]), () => ( null)) : parentId;
5250
5251
  if (target) {
5251
5252
  const g = this.requireLayer(target);
5252
5253
  if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
5253
- if (target === id || loc.layer.type === "group" && _chunkWMRIG4XQcjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
5254
+ if (target === id || loc.layer.type === "group" && _chunkLL3RAN55cjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
5254
5255
  }
5255
- const without = _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
5256
- const siblings = target ? _chunkWMRIG4XQcjs.findLayer.call(void 0, without, target).layer.children : without;
5256
+ const without = _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
5257
+ const siblings = target ? _chunkLL3RAN55cjs.findLayer.call(void 0, without, target).layer.children : without;
5257
5258
  if (!Number.isInteger(index) || index < 0 || index > siblings.length) throw new PaintEditorError(`index ${index} is out of range; use 0..${siblings.length} (0 is the bottom).`);
5258
- const layers = _chunkWMRIG4XQcjs.insertLayer.call(void 0, without, loc.layer, target, index);
5259
+ const layers = _chunkLL3RAN55cjs.insertLayer.call(void 0, without, loc.layer, target, index);
5259
5260
  this.commit("Move layer", { ...this.doc, layers });
5260
5261
  return this.describeLayer(loc.layer);
5261
5262
  }
5262
5263
  /** Merges a pixel layer into the pixel layer below it (keeping the lower one's settings). */
5263
5264
  mergeDown(id) {
5264
5265
  this.requireIdle("merging");
5265
- const pre = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id);
5266
+ const pre = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id);
5266
5267
  if (pre) {
5267
5268
  const sib = pre.parent ? pre.parent.children : this.doc.layers;
5268
5269
  this.dryLayersFirst([id, _optionalChain([sib, 'access', _174 => _174[pre.index - 1], 'optionalAccess', _175 => _175.id])].filter((x) => Boolean(x)));
5269
5270
  }
5270
- const loc = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id);
5271
+ const loc = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id);
5271
5272
  if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
5272
5273
  const siblings = loc.parent ? loc.parent.children : this.doc.layers;
5273
5274
  const below = siblings[loc.index - 1];
5274
5275
  const upper = loc.layer;
5275
5276
  if (!isPixelLayer(upper) || !isPixelLayer(below)) throw new PaintEditorError("Merge down needs a pixel layer directly above another pixel layer in the same group.");
5276
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
5277
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
5277
5278
  const rect = unionRect(this.describeLayer(below).bounds, this.describeLayer(upper).bounds);
5278
5279
  let surface = _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4);
5279
5280
  if (rect) {
@@ -5283,7 +5284,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5283
5284
  surface = _chunk7ISPWEJAcjs.surfaceFromPixels.call(void 0, { width: rect.width, height: rect.height, data: px }, 4, rect.x, rect.y);
5284
5285
  }
5285
5286
  const merged = { ...below, surface, offset: { x: 0, y: 0 } };
5286
- const layers = _chunkWMRIG4XQcjs.mapLayer.call(void 0, _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
5287
+ const layers = _chunkLL3RAN55cjs.mapLayer.call(void 0, _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
5287
5288
  this.commit("Merge down", this.withWetEvents({ ...this.doc, layers, activeLayerId: below.id, ...this.thickWithout([upper.id]), ...this.stickersWithout([upper.id, below.id]) }));
5288
5289
  return this.describeLayer(merged);
5289
5290
  }
@@ -5296,7 +5297,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5296
5297
  this.wet.world.removeLane(l.id);
5297
5298
  }
5298
5299
  const bounds = this.describeLayer(l).bounds;
5299
- this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4) })), ...this.thickWithout([l.id]), ...this.stickersWithout([l.id]) }, { kind: "clear", layerId: l.id }));
5300
+ this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4) })), ...this.thickWithout([l.id]), ...this.stickersWithout([l.id]) }, { kind: "clear", layerId: l.id }));
5300
5301
  return { layerId: l.id, bounds };
5301
5302
  }
5302
5303
  /**
@@ -5334,12 +5335,12 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5334
5335
  background: rgbaOf(this.doc.paper.color),
5335
5336
  opacity,
5336
5337
  blend,
5337
- lockTransparency: _chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "transparency"),
5338
+ lockTransparency: _chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "transparency"),
5338
5339
  selection: null,
5339
5340
  offset: l.offset
5340
5341
  };
5341
5342
  const surface = this.applyCoverage(l, coverage, rect, apply);
5342
- this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) }), { kind: "fill", layerId: l.id, data: { color, opacity, grain: grainAmount, pressure, blend } }));
5343
+ this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) }), { kind: "fill", layerId: l.id, data: { color, opacity, grain: grainAmount, pressure, blend } }));
5343
5344
  return { layerId: l.id, bounds: rect };
5344
5345
  }
5345
5346
  applyCoverage(l, coverage, rect, apply) {
@@ -5535,11 +5536,11 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5535
5536
  let layer = (() => {
5536
5537
  const id = _nullishCoalesce(init.layerId, () => ( doc.activeLayerId));
5537
5538
  if (!id) throw new PaintEditorError("There is no active layer to paint on; add one with add_layer.");
5538
- const loc = _chunkWMRIG4XQcjs.findLayer.call(void 0, doc.layers, id);
5539
+ const loc = _chunkLL3RAN55cjs.findLayer.call(void 0, doc.layers, id);
5539
5540
  if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
5540
5541
  const l = loc.layer;
5541
5542
  if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; paint on a pixel layer inside it.`);
5542
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) to paint on it.`);
5543
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) to paint on it.`);
5543
5544
  if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) to paint on it.`);
5544
5545
  return l;
5545
5546
  })();
@@ -5555,8 +5556,8 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5555
5556
  this.requireWetIdle("painting");
5556
5557
  if (layer.offset.x || layer.offset.y) {
5557
5558
  const moved = { ...layer, surface: _chunk7ISPWEJAcjs.translateSurface.call(void 0, layer.surface, layer.offset.x, layer.offset.y), offset: { x: 0, y: 0 } };
5558
- this.doc = { ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => moved) };
5559
- if (doc !== this.doc) doc = { ...doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, doc.layers, layer.id, () => moved) };
5559
+ this.doc = { ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => moved) };
5560
+ if (doc !== this.doc) doc = { ...doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, doc.layers, layer.id, () => moved) };
5560
5561
  layer = moved;
5561
5562
  }
5562
5563
  if (!this.wet.wetLayerIds().includes(layer.id) && this.wet.wetLayerIds().length >= _chunkL3PXFMOFcjs.MAX_WET_LANES) {
@@ -5586,7 +5587,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5586
5587
  wet = { driver, surface: () => world.display(id).surface };
5587
5588
  } else if (this.wet.wetLayerIds().includes(layer.id)) {
5588
5589
  this.dryLayersFirst([layer.id]);
5589
- const dried = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, layer.id).layer;
5590
+ const dried = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, layer.id).layer;
5590
5591
  layer = dried;
5591
5592
  }
5592
5593
  let color = init.color === void 0 ? this.color : parseColor(init.color);
@@ -5605,7 +5606,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5605
5606
  layerId: layer.id,
5606
5607
  surface: layer.surface,
5607
5608
  offset: layer.offset,
5608
- lockTransparency: _chunkWMRIG4XQcjs.isLayerLocked.call(void 0, layer, "transparency"),
5609
+ lockTransparency: _chunkLL3RAN55cjs.isLayerLocked.call(void 0, layer, "transparency"),
5609
5610
  brush,
5610
5611
  color: rgba,
5611
5612
  background: rgbaOf(doc.paper.color),
@@ -5698,7 +5699,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5698
5699
  const thick = ch ? { ..._nullishCoalesce(this.doc.thick, () => ( {})), [l.id]: ch } : this.doc.thick;
5699
5700
  const sprayed = s.stickers();
5700
5701
  const stickers = sprayed ? { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([this, 'access', _198 => _198.doc, 'access', _199 => _199.stickers, 'optionalAccess', _200 => _200[l.id]]), () => ( [])), ...sprayed] } : this.doc.stickers;
5701
- this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke], ...thick ? { thick } : {}, ...stickers ? { stickers } : {} }), wetStroke ? before : this.doc);
5702
+ this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke], ...thick ? { thick } : {}, ...stickers ? { stickers } : {} }), wetStroke ? before : this.doc);
5702
5703
  }
5703
5704
  };
5704
5705
  let session;
@@ -5726,13 +5727,13 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5726
5727
  if (cancelled || !surface) return;
5727
5728
  const stroke = this.record(s);
5728
5729
  s.result.strokeId = stroke.id;
5729
- const l = _chunkWMRIG4XQcjs.findLayer.call(void 0, out.layers, s.layerId).layer;
5730
+ const l = _chunkLL3RAN55cjs.findLayer.call(void 0, out.layers, s.layerId).layer;
5730
5731
  const offset = s.init.wet ? { x: 0, y: 0 } : l.offset;
5731
5732
  const ch = s.thickChannels();
5732
5733
  const sprayed = s.stickers();
5733
5734
  out = {
5734
5735
  ...out,
5735
- layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface, offset })),
5736
+ layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface, offset })),
5736
5737
  strokes: [...out.strokes, stroke],
5737
5738
  ...ch ? { thick: { ..._nullishCoalesce(out.thick, () => ( {})), [l.id]: ch } } : {},
5738
5739
  ...sprayed ? { stickers: { ..._nullishCoalesce(out.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([out, 'access', _201 => _201.stickers, 'optionalAccess', _202 => _202[l.id]]), () => ( [])), ...sprayed] } } : {}
@@ -5747,8 +5748,8 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5747
5748
  if (this.wet.instantDry && result.strokeId) {
5748
5749
  this.wet.dry(session.layerId);
5749
5750
  this.logWet({ kind: "dry", layerId: session.layerId, at: out.strokes.length });
5750
- const dried = _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, session.layerId).layer.surface;
5751
- out = { ...out, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, out.layers, session.layerId, (l) => ({ ...l, surface: dried })) };
5751
+ const dried = _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, session.layerId).layer.surface;
5752
+ out = { ...out, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, out.layers, session.layerId, (l) => ({ ...l, surface: dried })) };
5752
5753
  }
5753
5754
  result.wet = this.wet.isWet(session.layerId);
5754
5755
  }
@@ -5826,7 +5827,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5826
5827
  brush = normalizePaintBrush({ tip: { ...b.tip, size: b.tip.size * (v.brush.tip.size / s.brush.tip.size) } }, b);
5827
5828
  }
5828
5829
  const layerId = _nullishCoalesce(options.layerId, () => ( s.layerId));
5829
- if (!_chunkWMRIG4XQcjs.findLayer.call(void 0, doc.layers, layerId)) throw new PaintEditorError(`Stroke "${s.id}" was painted on layer "${layerId}", which no longer exists; pass layerId to replay it elsewhere.`);
5830
+ if (!_chunkLL3RAN55cjs.findLayer.call(void 0, doc.layers, layerId)) throw new PaintEditorError(`Stroke "${s.id}" was painted on layer "${layerId}", which no longer exists; pass layerId to replay it elsewhere.`);
5830
5831
  let load = s.load;
5831
5832
  if (load && options.color !== void 0 && load.reservoir) {
5832
5833
  const [r, g, b] = hexToRgb8(options.color);
@@ -5921,7 +5922,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
5921
5922
  /** `renderHighRes` as PNG bytes. */
5922
5923
  async exportHighResPng(options) {
5923
5924
  const img = await this.renderHighRes(options);
5924
- return _chunkEJVDBITDcjs.encodePng.call(void 0, img.width, img.height, img.data);
5925
+ return _chunkDCLJNVZScjs.encodePng.call(void 0, img.width, img.height, img.data);
5925
5926
  }
5926
5927
  async renderHighRes(options) {
5927
5928
  const target = this.createReplayTarget(options.scale);
@@ -6017,7 +6018,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6017
6018
  wetPaper(options = {}) {
6018
6019
  this.requireIdle("wetting the paper");
6019
6020
  const l = this.wetLayer(options.layerId, "wet the paper of");
6020
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it first.`);
6021
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it first.`);
6021
6022
  const amount = _nullishCoalesce(options.amount, () => ( 1));
6022
6023
  if (!(amount > 0 && amount <= 1)) throw new PaintEditorError(`amount ${amount} is out of range; use above 0 up to 1.`);
6023
6024
  const rect = _nullishCoalesce(this.checkRect(options.rect), () => ( { x: 0, y: 0, width: this.doc.canvas.width, height: this.doc.canvas.height }));
@@ -6101,7 +6102,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6101
6102
  const live = this.live;
6102
6103
  if (!live) return this.doc.layers;
6103
6104
  if (_optionalChain([this, 'access', _212 => _212.liveLayers, 'optionalAccess', _213 => _213.key]) === live.surface) return this.liveLayers.layers;
6104
- const layers = _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
6105
+ const layers = _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
6105
6106
  this.liveLayers = { key: live.surface, layers };
6106
6107
  return layers;
6107
6108
  }
@@ -6130,7 +6131,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6130
6131
  let out = layers;
6131
6132
  for (const id of ids) {
6132
6133
  const baked = this.wet.bakedSurface(id);
6133
- if (baked && _chunkWMRIG4XQcjs.findLayer.call(void 0, out, id)) out = _chunkWMRIG4XQcjs.mapLayer.call(void 0, out, id, (l) => ({ ...l, surface: baked }));
6134
+ if (baked && _chunkLL3RAN55cjs.findLayer.call(void 0, out, id)) out = _chunkLL3RAN55cjs.mapLayer.call(void 0, out, id, (l) => ({ ...l, surface: baked }));
6134
6135
  }
6135
6136
  return out;
6136
6137
  }
@@ -6143,12 +6144,12 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6143
6144
  const ids = /* @__PURE__ */ new Set([...Object.keys(_nullishCoalesce(thick, () => ( {}))), ...live ? [live.layerId] : []]);
6144
6145
  for (const id of ids) {
6145
6146
  const ch = _optionalChain([live, 'optionalAccess', _216 => _216.layerId]) === id ? live.channels : _optionalChain([thick, 'optionalAccess', _217 => _217[id]]);
6146
- const l = ch && _optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, out, id), 'optionalAccess', _218 => _218.layer]);
6147
+ const l = ch && _optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, out, id), 'optionalAccess', _218 => _218.layer]);
6147
6148
  if (!ch || !isPixelLayer(l)) continue;
6148
6149
  let cache = this.litCaches.get(id);
6149
6150
  if (!cache) this.litCaches.set(id, cache = new LitCache());
6150
6151
  const lit = cache.lit(l.surface, ch, this.lighting);
6151
- if (lit !== l.surface) out = _chunkWMRIG4XQcjs.mapLayer.call(void 0, out, id, () => ({ ...l, surface: lit }));
6152
+ if (lit !== l.surface) out = _chunkLL3RAN55cjs.mapLayer.call(void 0, out, id, () => ({ ...l, surface: lit }));
6152
6153
  }
6153
6154
  return out;
6154
6155
  }
@@ -6156,7 +6157,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6156
6157
  let layers = this.litLayers((_nullishCoalesce(options.wet, () => ( "display"))) === "dried" ? this.driedLayers() : this.currentLayers());
6157
6158
  if (options.layerIds) {
6158
6159
  const picked = [];
6159
- for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, layers, id), 'optionalAccess', _219 => _219.layer]), () => ( this.requireLayer(id))));
6160
+ for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, layers, id), 'optionalAccess', _219 => _219.layer]), () => ( this.requireLayer(id))));
6160
6161
  layers = picked.map((l) => ({ ...l, visible: true }));
6161
6162
  }
6162
6163
  const under = options.paper === false ? [] : [paperNode(this.doc.paper, this.lighting)];
@@ -6198,7 +6199,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6198
6199
  /** Wet settings saved with the document (`null` when they are all defaults). */
6199
6200
  wetJSON() {
6200
6201
  const layers = {};
6201
- for (const [id, set] of this.wet.settings) if (_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id)) layers[id] = { params: { ...set.params }, flow: { ...set.flow } };
6202
+ for (const [id, set] of this.wet.settings) if (_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id)) layers[id] = { params: { ...set.params }, flow: { ...set.flow } };
6202
6203
  const flat = this.wet.tilt.angle === 0;
6203
6204
  if (!Object.keys(layers).length && flat) return void 0;
6204
6205
  return { tilt: { ...this.wet.tilt }, layers };
@@ -6224,14 +6225,14 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6224
6225
  const ext = { ...this.extensions };
6225
6226
  const channels = {};
6226
6227
  for (const [id, ch] of Object.entries(_nullishCoalesce(this.doc.thick, () => ( {})))) {
6227
- if (!_chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id)) continue;
6228
+ if (!_chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id)) continue;
6228
6229
  const saved = thickToJSON(ch);
6229
6230
  if (saved) channels[id] = saved;
6230
6231
  }
6231
6232
  if (Object.keys(channels).length) ext.layerChannels = channels;
6232
6233
  else delete ext.layerChannels;
6233
6234
  const stickers = {};
6234
- for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length && _chunkWMRIG4XQcjs.findLayer.call(void 0, this.doc.layers, id)) stickers[id] = list.map((x) => ({ ...x }));
6235
+ for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length && _chunkLL3RAN55cjs.findLayer.call(void 0, this.doc.layers, id)) stickers[id] = list.map((x) => ({ ...x }));
6235
6236
  if (Object.keys(stickers).length) ext.stickers = stickers;
6236
6237
  else delete ext.stickers;
6237
6238
  if (this.lighting.azimuth !== DEFAULT_LIGHTING.azimuth || this.lighting.elevation !== DEFAULT_LIGHTING.elevation || this.lighting.relief !== DEFAULT_LIGHTING.relief) ext.lighting = { ...this.lighting };
@@ -6245,7 +6246,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6245
6246
  if (ext.stickers && typeof ext.stickers === "object") {
6246
6247
  const stickers = {};
6247
6248
  for (const [id, list] of Object.entries(ext.stickers)) {
6248
- if (!_chunkWMRIG4XQcjs.findLayer.call(void 0, state.layers, id) || !Array.isArray(list)) continue;
6249
+ if (!_chunkLL3RAN55cjs.findLayer.call(void 0, state.layers, id) || !Array.isArray(list)) continue;
6249
6250
  const ok = list.filter((x) => x && typeof x.id === "string" && STAMP_KINDS.includes(x.stamp) && Number.isFinite(x.x) && Number.isFinite(x.y) && x.size > 0);
6250
6251
  if (ok.length !== list.length) problems.push(`Some stickers of layer "${id}" could not be read; they were dropped.`);
6251
6252
  stickers[id] = ok.map((x) => ({ ...x }));
@@ -6256,7 +6257,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6256
6257
  if (!raw || typeof raw !== "object") return state;
6257
6258
  const thick = {};
6258
6259
  for (const [id, v] of Object.entries(raw)) {
6259
- if (!_chunkWMRIG4XQcjs.findLayer.call(void 0, state.layers, id)) continue;
6260
+ if (!_chunkLL3RAN55cjs.findLayer.call(void 0, state.layers, id)) continue;
6260
6261
  try {
6261
6262
  thick[id] = thickFromJSON(v);
6262
6263
  } catch (e) {
@@ -6315,7 +6316,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6315
6316
  /** The canvas as PNG bytes (paper included by default; `scale` below 1 shrinks it). */
6316
6317
  exportPng(options = {}) {
6317
6318
  const img = this.scaled(options);
6318
- return _chunkEJVDBITDcjs.encodePng.call(void 0, img.width, img.height, img.data);
6319
+ return _chunkDCLJNVZScjs.encodePng.call(void 0, img.width, img.height, img.data);
6319
6320
  }
6320
6321
  scaled(options) {
6321
6322
  const full = this.compositePixels(options);
@@ -6370,7 +6371,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6370
6371
  return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
6371
6372
  });
6372
6373
  const layers = toStandard(dried);
6373
- const result = _chunkHTAFDTNRcjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
6374
+ const result = _chunkGLOOH65Ycjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
6374
6375
  for (const [mode, names] of changed) {
6375
6376
  const label = _nullishCoalesce(_optionalChain([_chunk7ISPWEJAcjs.BLEND_MODES, 'access', _225 => _225.find, 'call', _226 => _226((m) => m.id === mode), 'optionalAccess', _227 => _227.label]), () => ( mode));
6376
6377
  const std = _nullishCoalesce(_optionalChain([_chunk7ISPWEJAcjs.BLEND_MODES, 'access', _228 => _228.find, 'call', _229 => _229((m) => m.id === _chunk7ISPWEJAcjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _230 => _230.label]), () => ( _chunk7ISPWEJAcjs.standardBlendMode.call(void 0, mode)));
@@ -6383,7 +6384,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6383
6384
  /** `render_preview` as a base64 PNG. */
6384
6385
  previewPngBase64(options = {}) {
6385
6386
  const img = this.renderPreview(options);
6386
- return { data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, _chunkEJVDBITDcjs.encodePng.call(void 0, img.width, img.height, img.data)), width: img.width, height: img.height };
6387
+ return { data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, _chunkDCLJNVZScjs.encodePng.call(void 0, img.width, img.height, img.data)), width: img.width, height: img.height };
6387
6388
  }
6388
6389
  // --- Guides --------------------------------------------------------------------
6389
6390
  setGuides(next) {
@@ -6421,17 +6422,17 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6421
6422
  pixels = this.decodeImage(input.png.trim().startsWith("data:") ? input.png.trim() : `data:image/png;base64,${input.png.trim()}`, what);
6422
6423
  } else throw new PaintEditorError(`${what}: pass png (a PNG as base64 or a data URL) or pixels.`);
6423
6424
  if (pixels.width > MAX_IMAGE_SIDE || pixels.height > MAX_IMAGE_SIDE) throw new PaintEditorError(`${what} is ${pixels.width}\xD7${pixels.height}; the limit is ${MAX_IMAGE_SIDE} px per side.`);
6424
- const src = _chunkEJVDBITDcjs.pngDataUrl.call(void 0, pixels.width, pixels.height, pixels.data);
6425
+ const src = _chunkDCLJNVZScjs.pngDataUrl.call(void 0, pixels.width, pixels.height, pixels.data);
6425
6426
  this.imagePixels.set(src, pixels);
6426
6427
  return { src, pixels };
6427
6428
  }
6428
6429
  decodeImage(src, what = "Image") {
6429
6430
  const cached = this.imagePixels.get(src);
6430
6431
  if (cached) return cached;
6431
- const parsed = _chunkEJVDBITDcjs.parseDataUrl.call(void 0, src);
6432
+ const parsed = _chunkDCLJNVZScjs.parseDataUrl.call(void 0, src);
6432
6433
  if (!parsed) throw new PaintEditorError(`${what} is not a data URL or base64 PNG.`);
6433
6434
  try {
6434
- const png = _chunkEJVDBITDcjs.decodePng.call(void 0, parsed.bytes);
6435
+ const png = _chunkDCLJNVZScjs.decodePng.call(void 0, parsed.bytes);
6435
6436
  const px = { width: png.width, height: png.height, data: png.data };
6436
6437
  this.imagePixels.set(src, px);
6437
6438
  return px;
@@ -6620,9 +6621,9 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6620
6621
  }
6621
6622
  /** Replaces a layer's stickers and redraws its pixels from them (one undo step). */
6622
6623
  commitStickers(label, layer, stickers) {
6623
- if (_chunkWMRIG4XQcjs.isLayerLocked.call(void 0, layer, "pixels")) throw new PaintEditorError(`Layer "${layer.name}" has its pixels locked; unlock it first.`);
6624
+ if (_chunkLL3RAN55cjs.isLayerLocked.call(void 0, layer, "pixels")) throw new PaintEditorError(`Layer "${layer.name}" has its pixels locked; unlock it first.`);
6624
6625
  const surface = stickerSurface(stickers);
6625
- const doc = { ...this.doc, layers: _chunkWMRIG4XQcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => ({ ...layer, surface, offset: { x: 0, y: 0 } })), stickers: { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [layer.id]: stickers } };
6626
+ const doc = { ...this.doc, layers: _chunkLL3RAN55cjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => ({ ...layer, surface, offset: { x: 0, y: 0 } })), stickers: { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [layer.id]: stickers } };
6626
6627
  this.commit(label, this.withPaintEvent(doc, { kind: "stickers", layerId: layer.id, data: { stickers: stickers.map((s) => ({ ...s })) } }));
6627
6628
  }
6628
6629
  /** Moves, turns, resizes, recolours or restamps one sticker (one undo step). Returns it. */
@@ -6868,7 +6869,7 @@ var PaintEditorController = (_class17 = class _PaintEditorController {
6868
6869
  }
6869
6870
  /** A layer's tile surface (live while stroking), for thumbnails. */
6870
6871
  layerSurface(id) {
6871
- const l = _optionalChain([_chunkWMRIG4XQcjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _253 => _253.layer]);
6872
+ const l = _optionalChain([_chunkLL3RAN55cjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _253 => _253.layer]);
6872
6873
  return isPixelLayer(l) ? l.surface : null;
6873
6874
  }
6874
6875
  }, _class17);
@@ -7537,7 +7538,7 @@ function createPaintGuideTools(c) {
7537
7538
  const pad = c.mixingPad;
7538
7539
  return {
7539
7540
  content: [
7540
- { type: "image", data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, _chunkEJVDBITDcjs.encodePng.call(void 0, pad.width, pad.height, pad.pixels())), mimeType: "image/png" },
7541
+ { type: "image", data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, _chunkDCLJNVZScjs.encodePng.call(void 0, pad.width, pad.height, pad.pixels())), mimeType: "image/png" },
7541
7542
  { type: "text", text: `Mixing pad ${pad.width}\xD7${pad.height}` }
7542
7543
  ]
7543
7544
  };
@@ -7822,7 +7823,7 @@ function createPaintReplayTools(c) {
7822
7823
  await c.wetIdle();
7823
7824
  const tl = await c.timeLapse({ frames: a.frames, fps: a.fps, maxSide: a.maxSide, wetStepsPerFrame: a.wetStepsPerFrame, holdMs: a.holdMs });
7824
7825
  const pick = [0, Math.floor(tl.frames.length / 3), Math.floor(2 * tl.frames.length / 3), tl.frames.length - 1].filter((v, i, arr) => arr.indexOf(v) === i);
7825
- const sheet = contactSheet(pick.map((i) => _chunkEJVDBITDcjs.decodePng.call(void 0, tl.frames[i])), pick.length, 160);
7826
+ const sheet = contactSheet(pick.map((i) => _chunkDCLJNVZScjs.decodePng.call(void 0, tl.frames[i])), pick.length, 160);
7826
7827
  const info = {
7827
7828
  frames: tl.frames.length,
7828
7829
  fps: tl.fps,
@@ -7831,9 +7832,9 @@ function createPaintReplayTools(c) {
7831
7832
  durationMs: tl.durationMs,
7832
7833
  ffmpeg: tl.ffmpeg.command,
7833
7834
  video: tl.video,
7834
- ...a.includeFrames ? { framesPng: tl.frames.map((f) => _chunkEJVDBITDcjs.bytesToBase64.call(void 0, f)) } : {}
7835
+ ...a.includeFrames ? { framesPng: tl.frames.map((f) => _chunkDCLJNVZScjs.bytesToBase64.call(void 0, f)) } : {}
7835
7836
  };
7836
- return { content: [{ type: "image", data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, _chunkEJVDBITDcjs.encodePng.call(void 0, sheet.width, sheet.height, sheet.data)), mimeType: "image/png" }, { type: "text", text: JSON.stringify(info) }] };
7837
+ return { content: [{ type: "image", data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, _chunkDCLJNVZScjs.encodePng.call(void 0, sheet.width, sheet.height, sheet.data)), mimeType: "image/png" }, { type: "text", text: JSON.stringify(info) }] };
7837
7838
  }
7838
7839
  },
7839
7840
  {
@@ -7853,8 +7854,8 @@ function createPaintReplayTools(c) {
7853
7854
  handler: async ({ scale, paper }) => {
7854
7855
  await c.wetIdle();
7855
7856
  const img = await c.renderHighRes({ scale, paper });
7856
- const bytes = _chunkEJVDBITDcjs.encodePng.call(void 0, img.width, img.height, img.data);
7857
- return { mimeType: "image/png", width: img.width, height: img.height, bytes: bytes.length, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, bytes) };
7857
+ const bytes = _chunkDCLJNVZScjs.encodePng.call(void 0, img.width, img.height, img.data);
7858
+ return { mimeType: "image/png", width: img.width, height: img.height, bytes: bytes.length, data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, bytes) };
7858
7859
  }
7859
7860
  }
7860
7861
  ];
@@ -8508,7 +8509,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
8508
8509
  const t = c.brushThumbnail(_nullishCoalesce(id, () => ( c.getState().brush.id)), { width, height, color });
8509
8510
  return {
8510
8511
  content: [
8511
- { type: "image", data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, _chunkEJVDBITDcjs.encodePng.call(void 0, t.width, t.height, t.data)), mimeType: "image/png" },
8512
+ { type: "image", data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, _chunkDCLJNVZScjs.encodePng.call(void 0, t.width, t.height, t.data)), mimeType: "image/png" },
8512
8513
  { type: "text", text: `Brush ${_nullishCoalesce(id, () => ( c.getState().brush.id))} ${t.width}\xD7${t.height}` }
8513
8514
  ]
8514
8515
  };
@@ -8764,7 +8765,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
8764
8765
  annotations: { title: "Export the painting", ...READ6 },
8765
8766
  handler: async ({ format, quality, scale, paper }) => {
8766
8767
  const bytes = await c.exportImage({ format, quality, scale, paper });
8767
- return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, bytes) };
8768
+ return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, bytes) };
8768
8769
  }
8769
8770
  });
8770
8771
  add({
@@ -8775,7 +8776,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
8775
8776
  annotations: { title: "Export as PSD", ...READ6 },
8776
8777
  handler: () => {
8777
8778
  const r = c.exportPsd();
8778
- return { data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, r.bytes), bytes: r.bytes.length, psb: r.psb, warnings: r.warnings };
8779
+ return { data: _chunkDCLJNVZScjs.bytesToBase64.call(void 0, r.bytes), bytes: r.bytes.length, psb: r.psb, warnings: r.warnings };
8779
8780
  }
8780
8781
  });
8781
8782
  add({