@pixerate/editor 0.189.0 → 0.191.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 (41) hide show
  1. package/dist/{chunk-ED4L4UD6.cjs → chunk-2UR4OX3B.cjs} +1002 -787
  2. package/dist/{chunk-M7XIC2FC.js → chunk-RQ2EM5TY.js} +333 -0
  3. package/dist/{chunk-ZEHTUR7Z.js → chunk-TXYXF32N.js} +968 -753
  4. package/dist/{chunk-5UEFNX24.cjs → chunk-ZQGZWFPU.cjs} +344 -11
  5. package/dist/image-editor/controller.d.cts +73 -1
  6. package/dist/image-editor/controller.d.ts +73 -1
  7. package/dist/image-editor/free-transform.d.cts +3 -6
  8. package/dist/image-editor/free-transform.d.ts +3 -6
  9. package/dist/image-editor/index.cjs +1382 -904
  10. package/dist/image-editor/index.d.cts +1 -0
  11. package/dist/image-editor/index.d.ts +1 -0
  12. package/dist/image-editor/index.js +485 -7
  13. package/dist/image-editor/layer-tools.d.cts +1 -1
  14. package/dist/image-editor/layer-tools.d.ts +1 -1
  15. package/dist/image-editor/layers/compositor.d.cts +3 -0
  16. package/dist/image-editor/layers/compositor.d.ts +3 -0
  17. package/dist/image-editor/layers/model.d.cts +23 -0
  18. package/dist/image-editor/layers/model.d.ts +23 -0
  19. package/dist/image-editor/layers/panel.d.cts +11 -1
  20. package/dist/image-editor/layers/panel.d.ts +11 -1
  21. package/dist/image-editor/layers/serialize.d.cts +11 -0
  22. package/dist/image-editor/layers/serialize.d.ts +11 -0
  23. package/dist/image-editor/layers/shape.d.cts +5 -0
  24. package/dist/image-editor/layers/shape.d.ts +5 -0
  25. package/dist/image-editor/layers/vector-mask.d.cts +51 -0
  26. package/dist/image-editor/layers/vector-mask.d.ts +51 -0
  27. package/dist/image-editor/psd/import.d.cts +0 -7
  28. package/dist/image-editor/psd/import.d.ts +0 -7
  29. package/dist/image-editor/selection/index.d.cts +1 -0
  30. package/dist/image-editor/selection/index.d.ts +1 -0
  31. package/dist/image-editor/selection/path.d.cts +37 -0
  32. package/dist/image-editor/selection/path.d.ts +37 -0
  33. package/dist/paint-editor/index.cjs +6 -6
  34. package/dist/paint-editor/index.js +1 -1
  35. package/dist/vector/index.cjs +21 -303
  36. package/dist/vector/index.js +15 -297
  37. package/dist/vector/trace.d.cts +8 -1
  38. package/dist/vector/trace.d.ts +8 -1
  39. package/package.json +1 -1
  40. package/skills/pixerate-image-editor/SKILL.md +8 -0
  41. package/skills/pixerate-image-selection-masking/SKILL.md +10 -2
@@ -2589,192 +2589,6 @@ function removeAlpha(imageData) {
2589
2589
  }
2590
2590
  }
2591
2591
 
2592
- // src/text/types.ts
2593
- var TEXT_ALIGNS = ["left", "center", "right", "justify"];
2594
-
2595
- // src/image-editor/layers/model.ts
2596
- var MAX_EFFECT_ANIMATION_MS = 6e4;
2597
- var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
2598
- var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
2599
- var idCounter = 0;
2600
- function newLayerId(prefix = "layer") {
2601
- return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2602
- }
2603
- function pixelLayers(layers) {
2604
- return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2605
- }
2606
- function developFilter(layer) {
2607
- return _optionalChain([layer, 'access', _14 => _14.filters, 'optionalAccess', _15 => _15.find, 'call', _16 => _16((f) => f.kind === "develop")]);
2608
- }
2609
- function blurFilter(layer) {
2610
- return _optionalChain([layer, 'access', _17 => _17.filters, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((f) => f.kind === "blur")]);
2611
- }
2612
- function isActiveFilter(f) {
2613
- if (!f.enabled) return false;
2614
- if (f.kind === "blur") return Math.min(Math.round(f.radius), 40) >= 1;
2615
- return Boolean(f.brightness || f.contrast || f.saturation || f.exposure || f.temperature || f.tint);
2616
- }
2617
- function isSpatialFilter(f) {
2618
- return f.kind === "blur";
2619
- }
2620
- function pixelLayerBounds(layer, surface = layer.surface) {
2621
- const b = surface.bounds;
2622
- if (!b) return null;
2623
- return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
2624
- }
2625
- function layerTypeLabel(type) {
2626
- return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : type === "type" ? "Type layer" : "Annotation";
2627
- }
2628
- function hasSurface(layer) {
2629
- return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2630
- }
2631
- function isRenderedLayer(layer) {
2632
- return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2633
- }
2634
- function shapeLayers(layers) {
2635
- return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2636
- }
2637
- function smartObjectLayers(layers) {
2638
- return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2639
- }
2640
-
2641
- // src/image-editor/layers/compositor.ts
2642
- var legacyViewCache = /* @__PURE__ */ new WeakMap();
2643
- function adjustmentNodeAsLayer(node) {
2644
- let view = legacyViewCache.get(node);
2645
- if (!view) {
2646
- view = {
2647
- id: node.id,
2648
- kind: node.kind,
2649
- enabled: node.visible,
2650
- opacity: node.opacity,
2651
- blend: node.blend,
2652
- params: node.params
2653
- };
2654
- legacyViewCache.set(node, view);
2655
- }
2656
- return view;
2657
- }
2658
- function developAdjustments(f) {
2659
- return {
2660
- brightness: f.brightness,
2661
- contrast: f.contrast,
2662
- saturation: f.saturation,
2663
- exposure: f.exposure,
2664
- temperature: f.temperature,
2665
- tint: _nullishCoalesce(f.tint, () => ( 0)),
2666
- blur: 0,
2667
- opacity: 1,
2668
- process: f.process
2669
- };
2670
- }
2671
- function applyPixelFilters(data, filters) {
2672
- for (const f of filters) {
2673
- if (!isActiveFilter(f) || f.kind !== "develop") continue;
2674
- const adj = developAdjustments(f);
2675
- if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Adjustments({ data }, adj);
2676
- else applyLegacyAdjustments({ data }, adj);
2677
- }
2678
- }
2679
- function depthMaskAlpha(depth, options) {
2680
- const { mode, depthRange, softness, invert } = options;
2681
- let v = invert ? 255 - depth : depth;
2682
- const soft = Math.max(1, softness || 10);
2683
- const [lo, hi] = depthRange;
2684
- if (mode === "threshold") {
2685
- if (v >= hi + soft) return 0;
2686
- if (v > hi) return Math.round((hi + soft - v) / soft * 255);
2687
- if (v >= lo) return 255;
2688
- if (v < lo - soft) return 0;
2689
- return Math.round((v - (lo - soft)) / soft * 255);
2690
- }
2691
- v += lo;
2692
- return v < 0 ? 0 : v > 255 ? 255 : v;
2693
- }
2694
- function runLayerFilters(data, width, height, filters) {
2695
- for (const f of filters) {
2696
- if (!isActiveFilter(f)) continue;
2697
- if (f.kind === "develop") applyPixelFilters(data, [f]);
2698
- else if (f.kind === "blur") applyBoxBlur({ width, height, data }, Math.min(Math.round(f.radius), 40));
2699
- }
2700
- }
2701
- function runLayerFiltersFloat(data, width, height, filters, linear) {
2702
- for (const f of filters) {
2703
- if (!isActiveFilter(f)) continue;
2704
- if (f.kind === "blur") applyBoxBlurFloat({ width, height, data }, Math.min(Math.round(f.radius), 40));
2705
- else if (f.kind === "develop") {
2706
- const adj = developAdjustments(f);
2707
- if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Float(data, adj, linear);
2708
- else applyLegacyFloat(data, adj, linear);
2709
- }
2710
- }
2711
- }
2712
- function filterReach(filters) {
2713
- let r = 0;
2714
- for (const f of filters) if (isActiveFilter(f) && f.kind === "blur") r += Math.min(Math.round(f.radius), 40);
2715
- return r;
2716
- }
2717
- var filterSpecCache = /* @__PURE__ */ new WeakMap();
2718
- function pixelFilterSpec(layer) {
2719
- const list2 = layer.filters;
2720
- if (!_optionalChain([list2, 'optionalAccess', _20 => _20.length])) return null;
2721
- if (filterSpecCache.has(list2)) return filterSpecCache.get(list2);
2722
- const filters = list2.filter(isActiveFilter);
2723
- let spec = null;
2724
- if (filters.length) {
2725
- const spatial = filters.some(isSpatialFilter);
2726
- spec = {
2727
- key: JSON.stringify(filters),
2728
- spatial,
2729
- apply: (data, width, height) => runLayerFilters(data, width, height, filters)
2730
- };
2731
- }
2732
- filterSpecCache.set(list2, spec);
2733
- return spec;
2734
- }
2735
- var PHOTO_PROFILE = {
2736
- isFilterLayer: (l) => l.type === "adjustment",
2737
- applyFilterRun: (layers, acc, _r, masks) => {
2738
- const views = layers.map(adjustmentNodeAsLayer);
2739
- applyAdjustmentLayers({ data: acc }, views, masks);
2740
- },
2741
- contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _21 => _21.rasterizeAnnotation, 'optionalCall', _22 => _22(l.annotation, r)]), () => ( null)) : null,
2742
- /** Annotation layers draw with their annotation's blend mode unless the layer sets one. */
2743
- contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
2744
- layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
2745
- pixelFilters: (l) => l.type === "pixel" ? pixelFilterSpec(l) : null,
2746
- /**
2747
- * A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
2748
- * layer, and a shape layer the pixels rendered from its paths.
2749
- */
2750
- isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
2751
- maskSourcePlane: (source, W, H, sources) => {
2752
- const opts = source;
2753
- const depth = _nullishCoalesce(_optionalChain([sources, 'access', _23 => _23.depthMap, 'optionalCall', _24 => _24(opts)]), () => ( null));
2754
- if (!depth || depth.width !== W || depth.height !== H) return null;
2755
- const v = new Float32Array(W * H);
2756
- for (let i = 0; i < v.length; i++) v[i] = depthMaskAlpha(depth.data[i * 4], opts) / 255;
2757
- return v;
2758
- }
2759
- };
2760
- var LayerCompositor = class extends _chunkHGTDMKNEcjs.RasterCompositor {
2761
- constructor(options = {}) {
2762
- super(PHOTO_PROFILE, options);
2763
- }
2764
- };
2765
- function compositeDeep(layers, rect, sources, depth) {
2766
- const deep = new (0, _chunkHGTDMKNEcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
2767
- applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
2768
- pixelFiltersDeep: (l) => {
2769
- if (l.type !== "pixel") return null;
2770
- const filters = (_nullishCoalesce(l.filters, () => ( []))).filter(isActiveFilter);
2771
- if (!filters.length) return null;
2772
- return { reach: filterReach(filters), apply: (data, width, height, linear) => runLayerFiltersFloat(data, width, height, filters, linear) };
2773
- }
2774
- }, depth);
2775
- return deep.composite(layers, rect, sources);
2776
- }
2777
-
2778
2592
  // src/image-editor/layers/vector-raster.ts
2779
2593
  var FLATNESS = 0.01;
2780
2594
  function flattenPath(path, tolerance = FLATNESS) {
@@ -3108,355 +2922,59 @@ function combineCoverage(a, b, op, n) {
3108
2922
  return out;
3109
2923
  }
3110
2924
 
3111
- // src/image-editor/layers/ops.ts
3112
- var LayerOperationError = class extends Error {
3113
-
3114
- constructor(message, userMessage) {
3115
- super(message);
3116
- this.name = "LayerOperationError";
3117
- if (userMessage) this.userMessage = userMessage;
3118
- }
3119
- };
3120
- function userErrorMessage(err) {
3121
- if (err instanceof LayerOperationError && err.userMessage) return err.userMessage;
3122
- return err instanceof Error ? err.message : String(err);
2925
+ // src/text/types.ts
2926
+ var TEXT_ALIGNS = ["left", "center", "right", "justify"];
2927
+
2928
+ // src/image-editor/layers/model.ts
2929
+ var MAX_EFFECT_ANIMATION_MS = 6e4;
2930
+ var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
2931
+ var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
2932
+ var idCounter = 0;
2933
+ function newLayerId(prefix = "layer") {
2934
+ return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
3123
2935
  }
3124
- function isPaintableLayer(layer) {
3125
- return layer.type === "pixel" && layer.visible && !_chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, "pixels");
2936
+ function pixelLayers(layers) {
2937
+ return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
3126
2938
  }
3127
- function defaultActiveLayerId(layers) {
3128
- const pixels = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
3129
- for (let i = pixels.length - 1; i >= 0; i--) if (isPaintableLayer(pixels[i])) return pixels[i].id;
3130
- return _nullishCoalesce(_optionalChain([pixels, 'access', _25 => _25[pixels.length - 1], 'optionalAccess', _26 => _26.id]), () => ( null));
2939
+ function developFilter(layer) {
2940
+ return _optionalChain([layer, 'access', _14 => _14.filters, 'optionalAccess', _15 => _15.find, 'call', _16 => _16((f) => f.kind === "develop")]);
3131
2941
  }
3132
- function activeLayerAfterRemoval(prev, next, removedId) {
3133
- const before = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, prev);
3134
- const at = before.findIndex((l) => l.id === removedId);
3135
- for (let i = at - 1; i >= 0; i--) {
3136
- const loc = _chunkHGTDMKNEcjs.findLayer.call(void 0, next, before[i].id);
3137
- if (loc && isPaintableLayer(loc.layer)) return loc.layer.id;
3138
- }
3139
- return defaultActiveLayerId(next);
2942
+ function blurFilter(layer) {
2943
+ return _optionalChain([layer, 'access', _17 => _17.filters, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((f) => f.kind === "blur")]);
3140
2944
  }
3141
- var fail = (message) => {
3142
- throw new LayerOperationError(message);
3143
- };
3144
- function requireLayer(layers, id) {
3145
- const loc = _chunkHGTDMKNEcjs.findLayer.call(void 0, layers, id);
3146
- if (!loc) {
3147
- const ids = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
3148
- fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
3149
- }
3150
- return loc;
2945
+ function isActiveFilter(f) {
2946
+ if (!f.enabled) return false;
2947
+ if (f.kind === "blur") return Math.min(Math.round(f.radius), 40) >= 1;
2948
+ return Boolean(f.brightness || f.contrast || f.saturation || f.exposure || f.temperature || f.tint);
3151
2949
  }
3152
- function requireUnlocked(layer, what, action) {
3153
- if (_chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
3154
- if (what !== "all" && _chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2950
+ function isSpatialFilter(f) {
2951
+ return f.kind === "blur";
3155
2952
  }
3156
- function placeLayer(layers, layer, placement = {}, defaultIndex) {
3157
- const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
3158
- if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
3159
- if (placement.aboveId || placement.belowId) {
3160
- const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
3161
- return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _27 => _27.parent, 'optionalAccess', _28 => _28.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
3162
- }
3163
- if (placement.parentId) {
3164
- const ref = requireLayer(layers, placement.parentId);
3165
- if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
3166
- return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
3167
- }
3168
- return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2953
+ function pixelLayerBounds(layer, surface = layer.surface) {
2954
+ const b = surface.bounds;
2955
+ if (!b) return null;
2956
+ return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
3169
2957
  }
3170
- function removeLayer(layers, id) {
3171
- const loc = requireLayer(layers, id);
3172
- requireUnlocked(loc.layer, "all", "delete it");
3173
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3174
- }
3175
- function moveLayer(layers, id, placement) {
3176
- const loc = requireLayer(layers, id);
3177
- requireUnlocked(loc.layer, "all", "move it");
3178
- const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
3179
- if (target === id) fail("A layer cannot be placed relative to itself.");
3180
- if (target && loc.layer.type === "group" && _chunkHGTDMKNEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
3181
- fail(`Group "${id}" cannot be moved into its own child "${target}".`);
3182
- }
3183
- if (target) requireLayer(layers, target);
3184
- if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
3185
- const without = _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3186
- return placeLayer(without, loc.layer, placement);
3187
- }
3188
- function withNewIds(layer) {
3189
- const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
3190
- if (next.type === "group") next.children = next.children.map(withNewIds);
3191
- if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
3192
- if (next.type === "shape" || next.type === "type") delete next.annotation;
3193
- if (next.type === "smart" && _optionalChain([next, 'access', _29 => _29.psd, 'optionalAccess', _30 => _30.placed])) {
3194
- next.psd = { ...next.psd };
3195
- delete next.psd.placed;
3196
- }
3197
- return next;
3198
- }
3199
- function duplicateLayer(layers, id, name) {
3200
- const loc = requireLayer(layers, id);
3201
- const copy = withNewIds(loc.layer);
3202
- copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
3203
- delete copy.locks;
3204
- return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _31 => _31.parent, 'optionalAccess', _32 => _32.id]), () => ( null)), loc.index + 1), id: copy.id };
3205
- }
3206
- function setLayerProperties(layers, id, props) {
3207
- const loc = requireLayer(layers, id);
3208
- const layer = loc.layer;
3209
- const onlyUnlocking = Object.keys(props).every((k) => k === "locks" || k === "visible" || k === "collapsed");
3210
- if (!onlyUnlocking) requireUnlocked(layer, "all", "change its properties");
3211
- const next = { ...layer };
3212
- if (props.name !== void 0) {
3213
- if (typeof props.name !== "string" || !props.name.trim()) fail("name must be a non-empty string.");
3214
- next.name = props.name.trim();
3215
- }
3216
- if (props.visible !== void 0) next.visible = Boolean(props.visible);
3217
- if (props.opacity !== void 0) {
3218
- if (!(typeof props.opacity === "number" && props.opacity >= 0 && props.opacity <= 1)) fail("opacity must be a number from 0 to 1.");
3219
- next.opacity = props.opacity;
3220
- }
3221
- if (props.fillOpacity !== void 0) {
3222
- if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape" && layer.type !== "type") fail(`fillOpacity applies to pixel, shape, type and smart object layers; "${id}" is a ${layer.type} layer.`);
3223
- if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail("fillOpacity must be a number from 0 to 1.");
3224
- const p = next;
3225
- if (props.fillOpacity === 1) delete p.fillOpacity;
3226
- else p.fillOpacity = props.fillOpacity;
3227
- }
3228
- if (props.blend !== void 0) {
3229
- if (props.blend === "pass-through") {
3230
- if (layer.type !== "group") fail("pass-through is only for groups.");
3231
- } else if (!_chunkCWM3CUUXcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
3232
- next.blend = props.blend;
3233
- }
3234
- if (props.clipped !== void 0) {
3235
- if (props.clipped && loc.index === 0) fail("The bottom layer of a group or the stack has nothing below to clip to.");
3236
- if (props.clipped) next.clipped = true;
3237
- else delete next.clipped;
3238
- }
3239
- if (props.locks !== void 0) {
3240
- const locks = {};
3241
- for (const k of ["pixels", "transparency", "position", "all"]) if (props.locks[k]) locks[k] = true;
3242
- if (Object.keys(locks).length) next.locks = locks;
3243
- else delete next.locks;
3244
- }
3245
- if (props.collapsed !== void 0) {
3246
- if (layer.type !== "group") fail("collapsed applies to groups.");
3247
- const g = next;
3248
- if (props.collapsed) g.collapsed = true;
3249
- else delete g.collapsed;
3250
- }
3251
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
3252
- }
3253
- function groupLayers(layers, ids, name = "Group") {
3254
- if (!ids.length) fail("Give at least one layer id to group.");
3255
- const locs = ids.map((id) => requireLayer(layers, id));
3256
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _33 => _33[0], 'access', _34 => _34.parent, 'optionalAccess', _35 => _35.id]), () => ( null));
3257
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _36 => _36.parent, 'optionalAccess', _37 => _37.id]), () => ( null))) !== parent)) fail("Layers to group must share one parent; move them next to each other first.");
3258
- for (const l of locs) requireUnlocked(l.layer, "all", "group it");
3259
- const ordered = [...new Set(locs)].sort((a, b) => a.index - b.index);
3260
- const top = ordered[ordered.length - 1].index;
3261
- const below = ordered.filter((l) => l.index < top).length;
3262
- const group = {
3263
- type: "group",
3264
- id: newLayerId("group"),
3265
- name,
3266
- visible: true,
3267
- opacity: 1,
3268
- blend: "pass-through",
3269
- children: ordered.map((l) => {
3270
- const c = { ...l.layer };
3271
- return c;
3272
- })
3273
- };
3274
- if (_optionalChain([group, 'access', _38 => _38.children, 'access', _39 => _39[0], 'optionalAccess', _40 => _40.clipped])) {
3275
- const c = { ...group.children[0] };
3276
- delete c.clipped;
3277
- group.children[0] = c;
3278
- }
3279
- let out = layers;
3280
- for (const l of ordered) out = _chunkHGTDMKNEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3281
- return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3282
- }
3283
- function ungroupLayer(layers, id) {
3284
- const loc = requireLayer(layers, id);
3285
- if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
3286
- requireUnlocked(loc.layer, "all", "ungroup it");
3287
- const group = loc.layer;
3288
- let out = _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3289
- group.children.forEach((c, i) => {
3290
- out = _chunkHGTDMKNEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _41 => _41.parent, 'optionalAccess', _42 => _42.id]), () => ( null)), loc.index + i);
3291
- });
3292
- return { layers: out, ids: group.children.map((c) => c.id) };
3293
- }
3294
- function offsetLayer(layers, id, offset) {
3295
- const loc = requireLayer(layers, id);
3296
- if (loc.layer.type !== "pixel") fail(`Only pixel layers move; "${id}" is a ${loc.layer.type} layer.`);
3297
- requireUnlocked(loc.layer, "position", "move it");
3298
- if (!Number.isFinite(offset.x) || !Number.isFinite(offset.y)) fail("x and y must be numbers.");
3299
- const layer = loc.layer;
3300
- const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
3301
- const mask = layer.mask;
3302
- if (mask && mask.linked === false && !mask.source) {
3303
- next.mask = { ...mask, surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3304
- }
3305
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
3306
- }
3307
- function setLayerMask(layers, id, mask) {
3308
- const loc = requireLayer(layers, id);
3309
- requireUnlocked(loc.layer, "all", "change its mask");
3310
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, (l) => {
3311
- const next = { ...l };
3312
- if (mask) next.mask = mask;
3313
- else delete next.mask;
3314
- return next;
3315
- });
3316
- }
3317
- var DEVELOP_FIELDS = ["brightness", "contrast", "saturation", "exposure", "temperature", "tint"];
3318
- function normalizeFilter(raw, id = newLayerId("flt")) {
3319
- const enabled = raw.enabled !== false;
3320
- if (raw.kind === "blur") {
3321
- const r = raw.radius;
3322
- if (r !== void 0 && !(typeof r === "number" && r >= 0 && r <= 50)) fail("blur radius must be a number from 0 to 50 px.");
3323
- return { id, kind: "blur", enabled, radius: typeof r === "number" ? r : 2 };
3324
- }
3325
- if (raw.kind !== "develop") fail(`Unknown filter kind "${raw.kind}". Use develop or blur.`);
3326
- const out = { id, kind: "develop", enabled, brightness: 0, contrast: 0, saturation: 0, exposure: 0, temperature: 0, tint: 0, process: 2 };
3327
- for (const k of DEVELOP_FIELDS) {
3328
- const v = raw[k];
3329
- if (v === void 0) continue;
3330
- if (!(typeof v === "number" && v >= -100 && v <= 100)) fail(`${k} must be a number from -100 to 100.`);
3331
- out[k] = v;
3332
- }
3333
- const p = raw.process;
3334
- if (p !== void 0) {
3335
- if (p !== 1 && p !== 2) fail("process must be 1 or 2.");
3336
- out.process = p;
3337
- }
3338
- return out;
3339
- }
3340
- function requirePixelLayer(layers, id) {
3341
- const loc = requireLayer(layers, id);
3342
- if (loc.layer.type !== "pixel") fail(`Filters belong to pixel layers; "${id}" is a ${loc.layer.type} layer.`);
3343
- requireUnlocked(loc.layer, "all", "change its filters");
3344
- return loc.layer;
3345
- }
3346
- function addLayerFilter(layers, id, filter) {
3347
- const layer = requirePixelLayer(layers, id);
3348
- if (_optionalChain([layer, 'access', _43 => _43.filters, 'optionalAccess', _44 => _44.some, 'call', _45 => _45((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3349
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3350
- }
3351
- function updateLayerFilter(layers, id, filterId, changes) {
3352
- const layer = requirePixelLayer(layers, id);
3353
- const i = (_nullishCoalesce(layer.filters, () => ( []))).findIndex((f) => f.id === filterId);
3354
- if (i === -1) fail(`Layer "${id}" has no filter "${filterId}". Filters: ${(_nullishCoalesce(layer.filters, () => ( []))).map((f) => f.id).join(", ") || "none"}.`);
3355
- const current = layer.filters[i];
3356
- if ("kind" in changes && changes.kind !== current.kind) fail("A filter kind cannot change; remove it and add another.");
3357
- const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
3358
- const filters = [...layer.filters];
3359
- filters[i] = merged2;
3360
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3361
- }
3362
- function removeLayerFilter(layers, id, filterId) {
3363
- const layer = requirePixelLayer(layers, id);
3364
- if (!(_nullishCoalesce(layer.filters, () => ( []))).some((f) => f.id === filterId)) fail(`Layer "${id}" has no filter "${filterId}".`);
3365
- const filters = layer.filters.filter((f) => f.id !== filterId);
3366
- const next = { ...layer };
3367
- if (filters.length) next.filters = filters;
3368
- else delete next.filters;
3369
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
3370
- }
3371
- function requireEffectLayer(layers, id, action) {
3372
- const layer = requireLayer(layers, id).layer;
3373
- if (layer.type === "adjustment") fail(`Layer "${layer.name || id}" is an adjustment layer; effects go on pixel, annotation and group layers.`);
3374
- requireUnlocked(layer, "all", action);
3375
- return layer;
3376
- }
3377
- function layerEffectsOf(layer) {
3378
- return _nullishCoalesce(layer.effects, () => ( { enabled: true, items: [] }));
3379
- }
3380
- function guard(fn) {
3381
- try {
3382
- return fn();
3383
- } catch (e) {
3384
- if (e instanceof _chunkHGTDMKNEcjs.LayerEffectError) fail(e.message);
3385
- throw e;
3386
- }
3387
- }
3388
- function setLayerEffects(layers, id, effects) {
3389
- const layer = requireEffectLayer(layers, id, "change its effects");
3390
- const next = { ...layer };
3391
- if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
3392
- guard(() => _chunkHGTDMKNEcjs.validateLayerEffects.call(void 0, effects));
3393
- next.effects = effects;
3394
- } else delete next.effects;
3395
- return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
3396
- }
3397
- function addLayerEffect(layers, id, kind, params = {}, index) {
3398
- if (!_chunkHGTDMKNEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkHGTDMKNEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3399
- const layer = requireEffectLayer(layers, id, "add effects");
3400
- const current = layerEffectsOf(layer);
3401
- const ids = new Set(current.items.map((e) => e.id));
3402
- let effectId = _chunkHGTDMKNEcjs.newEffectId.call(void 0, );
3403
- while (ids.has(effectId)) effectId = _chunkHGTDMKNEcjs.newEffectId.call(void 0, );
3404
- const { id: _ignored, kind: _kind, ...rest } = params;
3405
- const effect = guard(() => _chunkHGTDMKNEcjs.mergeLayerEffect.call(void 0, _chunkHGTDMKNEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3406
- const items = [...current.items];
3407
- const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
3408
- items.splice(at, 0, effect);
3409
- return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
3410
- }
3411
- function requireEffect(layer, effectId) {
3412
- const items = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.effects, 'optionalAccess', _47 => _47.items]), () => ( []));
3413
- const i = items.findIndex((e) => e.id === effectId);
3414
- if (i === -1) fail(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
3415
- return i;
3416
- }
3417
- function updateLayerEffect(layers, id, effectId, changes) {
3418
- const layer = requireEffectLayer(layers, id, "change its effects");
3419
- const i = requireEffect(layer, effectId);
3420
- const current = layer.effects;
3421
- const items = [...current.items];
3422
- items[i] = guard(() => _chunkHGTDMKNEcjs.mergeLayerEffect.call(void 0, items[i], changes));
3423
- return setLayerEffects(layers, id, { ...current, items });
2958
+ function layerTypeLabel(type) {
2959
+ return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : type === "type" ? "Type layer" : "Annotation";
3424
2960
  }
3425
- function removeLayerEffect(layers, id, effectId) {
3426
- const layer = requireEffectLayer(layers, id, "change its effects");
3427
- requireEffect(layer, effectId);
3428
- const current = layer.effects;
3429
- return setLayerEffects(layers, id, { ...current, items: current.items.filter((e) => e.id !== effectId) });
2961
+ function hasSurface(layer) {
2962
+ return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type";
3430
2963
  }
3431
- function setLayerEffectsEnabled(layers, id, enabled, scale) {
3432
- const layer = requireEffectLayer(layers, id, "change its effects");
3433
- if (scale !== void 0 && !(Number.isFinite(scale) && scale >= 0.01 && scale <= 10)) fail(`scale must be from 0.01 to 10 (1 = 100 %), got ${scale}.`);
3434
- const current = layerEffectsOf(layer);
3435
- const next = { ...current, enabled };
3436
- if (scale !== void 0) {
3437
- if (scale === 1) delete next.scale;
3438
- else next.scale = scale;
3439
- }
3440
- return setLayerEffects(layers, id, next);
2964
+ function isRenderedLayer(layer) {
2965
+ return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
3441
2966
  }
3442
- function parseBlend(value, allowPassThrough = false) {
3443
- if (value === void 0) return void 0;
3444
- if (value === "pass-through" && allowPassThrough) return value;
3445
- if (!_chunkCWM3CUUXcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3446
- return value;
2967
+ function shapeLayers(layers) {
2968
+ return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
3447
2969
  }
3448
- function unionRect(a, b) {
3449
- if (!a) return b;
3450
- if (!b) return a;
3451
- const x = Math.min(a.x, b.x);
3452
- const y = Math.min(a.y, b.y);
3453
- return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
2970
+ function smartObjectLayers(layers) {
2971
+ return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
3454
2972
  }
3455
2973
 
3456
2974
  // src/image-editor/layers/shape.ts
3457
2975
  var SHAPE_RENDER_MARGIN = _chunkHGTDMKNEcjs.MAX_EFFECT_REACH;
3458
2976
  var DEFAULT_MITER_LIMIT = 100;
3459
- var fail2 = (message) => {
2977
+ var fail = (message) => {
3460
2978
  throw new LayerOperationError(message);
3461
2979
  };
3462
2980
  var orientation = (anchors) => {
@@ -3597,7 +3115,7 @@ function closedOutline(path) {
3597
3115
  function strokeArea(path, stroke, double) {
3598
3116
  const w = stroke.width * (double ? 2 : 1);
3599
3117
  if (!(w > 0) || !path.length) return [];
3600
- const dashes = _optionalChain([stroke, 'access', _48 => _48.dashes, 'optionalAccess', _49 => _49.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
3118
+ const dashes = _optionalChain([stroke, 'access', _20 => _20.dashes, 'optionalAccess', _21 => _21.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
3601
3119
  const options = {
3602
3120
  width: w,
3603
3121
  cap: _nullishCoalesce(stroke.cap, () => ( "butt")),
@@ -3667,13 +3185,17 @@ function fillCoverage(geo, rect, rule, inverted = false) {
3667
3185
  });
3668
3186
  return acc;
3669
3187
  }
3188
+ function componentsCoverage(components, rect, rule = "nonzero", inverted = false) {
3189
+ const geo = { fills: components.map((c) => ({ op: c.op, flat: flattenPath(componentPath(c)) })) };
3190
+ return _nullishCoalesce(fillCoverage(geo, rect, rule, inverted), () => ( new Float32Array(rect.width * rect.height)));
3191
+ }
3670
3192
  function paintContext(env) {
3671
3193
  const tiles = /* @__PURE__ */ new Map();
3672
3194
  return {
3673
3195
  light: _chunkHGTDMKNEcjs.DEFAULT_GLOBAL_LIGHT,
3674
3196
  pattern: (id) => {
3675
3197
  if (tiles.has(id)) return tiles.get(id);
3676
- const p = _nullishCoalesce(_optionalChain([env, 'access', _50 => _50.pattern, 'optionalCall', _51 => _51(id)]), () => ( _chunkHGTDMKNEcjs.builtinPattern.call(void 0, id)));
3198
+ const p = _nullishCoalesce(_optionalChain([env, 'access', _22 => _22.pattern, 'optionalCall', _23 => _23(id)]), () => ( _chunkHGTDMKNEcjs.builtinPattern.call(void 0, id)));
3677
3199
  const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkHGTDMKNEcjs.PatternTile)(p) : null;
3678
3200
  tiles.set(id, t);
3679
3201
  return t;
@@ -3706,9 +3228,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3706
3228
  const canvas = { x: 0, y: 0, width: env.width, height: env.height };
3707
3229
  const anchor = { x: geo.frame.x, y: geo.frame.y };
3708
3230
  const fc = fCov ? _chunkHGTDMKNEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3709
- const fo = _nullishCoalesce(_optionalChain([layer, 'access', _52 => _52.fill, 'optionalAccess', _53 => _53.opacity]), () => ( 1));
3231
+ const fo = _nullishCoalesce(_optionalChain([layer, 'access', _24 => _24.fill, 'optionalAccess', _25 => _25.opacity]), () => ( 1));
3710
3232
  const sc = sCov ? _chunkHGTDMKNEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3711
- const so = _nullishCoalesce(_optionalChain([layer, 'access', _54 => _54.stroke, 'optionalAccess', _55 => _55.paint, 'access', _56 => _56.opacity]), () => ( 1));
3233
+ const so = _nullishCoalesce(_optionalChain([layer, 'access', _26 => _26.stroke, 'optionalAccess', _27 => _27.paint, 'access', _28 => _28.opacity]), () => ( 1));
3712
3234
  const out = new Uint8ClampedArray(n * 4);
3713
3235
  let any = false;
3714
3236
  for (let i = 0; i < n; i++) {
@@ -3766,31 +3288,31 @@ function rerenderShape(layer, env) {
3766
3288
  }
3767
3289
  var isNum = (v) => typeof v === "number" && Number.isFinite(v);
3768
3290
  function requireNum(v, path, min = -Infinity, max = Infinity) {
3769
- if (!isNum(v)) fail2(`${path} must be a finite number.`);
3770
- if (v < min || v > max) fail2(`${path} must be between ${min} and ${max}, got ${v}.`);
3291
+ if (!isNum(v)) fail(`${path} must be a finite number.`);
3292
+ if (v < min || v > max) fail(`${path} must be between ${min} and ${max}, got ${v}.`);
3771
3293
  return v;
3772
3294
  }
3773
3295
  function normalizeShapePaint(v, path = "paint") {
3774
3296
  if (typeof v === "string") {
3775
3297
  const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, v);
3776
- if (!c) return fail2(`${path}: "${v}" is not a colour; use #rrggbb (or #rrggbbaa, rgb(), a CSS colour name).`);
3298
+ if (!c) return fail(`${path}: "${v}" is not a colour; use #rrggbb (or #rrggbbaa, rgb(), a CSS colour name).`);
3777
3299
  return c.alpha < 1 ? { type: "color", color: c.hex, opacity: c.alpha } : { type: "color", color: c.hex };
3778
3300
  }
3779
- if (!v || typeof v !== "object") return fail2(`${path} must be a colour string or an object with type color, gradient or pattern.`);
3301
+ if (!v || typeof v !== "object") return fail(`${path} must be a colour string or an object with type color, gradient or pattern.`);
3780
3302
  const o = v;
3781
3303
  const opacity = o.opacity === void 0 ? void 0 : requireNum(o.opacity, `${path}.opacity`, 0, 1);
3782
3304
  const withOpacity = (p) => opacity !== void 0 && opacity !== 1 ? { ...p, opacity } : p;
3783
3305
  if (o.type === "color") {
3784
3306
  const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, o.color);
3785
- if (!c) return fail2(`${path}.color must be a colour such as #rrggbb.`);
3307
+ if (!c) return fail(`${path}.color must be a colour such as #rrggbb.`);
3786
3308
  const op = (_nullishCoalesce(opacity, () => ( 1))) * c.alpha;
3787
3309
  return op !== 1 ? { type: "color", color: c.hex, opacity: op } : { type: "color", color: c.hex };
3788
3310
  }
3789
3311
  if (o.type === "gradient") {
3790
3312
  const g = o.gradient;
3791
- if (!g || typeof g !== "object") return fail2(`${path}.gradient is required: { stops: [{ position, color }], style, angle, \u2026 }.`);
3313
+ if (!g || typeof g !== "object") return fail(`${path}.gradient is required: { stops: [{ position, color }], style, angle, \u2026 }.`);
3792
3314
  const gradient = {
3793
- stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([_chunkA2IS7EHEcjs.parseCssColor.call(void 0, s.color), 'optionalAccess', _57 => _57.hex]), () => ( s.color)) })) : [],
3315
+ stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([_chunkA2IS7EHEcjs.parseCssColor.call(void 0, s.color), 'optionalAccess', _29 => _29.hex]), () => ( s.color)) })) : [],
3794
3316
  ...g.opacityStops ? { opacityStops: g.opacityStops } : {},
3795
3317
  style: _nullishCoalesce(g.style, () => ( "linear")),
3796
3318
  angle: _nullishCoalesce(g.angle, () => ( 90)),
@@ -3802,52 +3324,52 @@ function normalizeShapePaint(v, path = "paint") {
3802
3324
  try {
3803
3325
  _chunkHGTDMKNEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3804
3326
  } catch (e) {
3805
- if (e instanceof _chunkHGTDMKNEcjs.LayerEffectError) fail2(e.message);
3327
+ if (e instanceof _chunkHGTDMKNEcjs.LayerEffectError) fail(e.message);
3806
3328
  throw e;
3807
3329
  }
3808
- if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
3330
+ if (gradient.stops.length < 1) fail(`${path}.gradient.stops needs at least one { position, color }.`);
3809
3331
  return withOpacity({ type: "gradient", gradient });
3810
3332
  }
3811
3333
  if (o.type === "pattern") {
3812
- if (typeof o.patternId !== "string" || !o.patternId) fail2(`${path}.patternId is required (a document or built-in pattern id).`);
3334
+ if (typeof o.patternId !== "string" || !o.patternId) fail(`${path}.patternId is required (a document or built-in pattern id).`);
3813
3335
  const p = { type: "pattern", patternId: o.patternId, scale: o.scale === void 0 ? 1 : requireNum(o.scale, `${path}.scale`, 0.01, 10) };
3814
3336
  if (typeof o.name === "string") p.name = o.name;
3815
3337
  if (o.angle !== void 0) p.angle = requireNum(o.angle, `${path}.angle`, -360, 360);
3816
3338
  if (o.link !== void 0) p.link = Boolean(o.link);
3817
3339
  if (o.phase !== void 0) {
3818
3340
  const ph = o.phase;
3819
- p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _58 => _58.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _59 => _59.y]), `${path}.phase.y`) };
3341
+ p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _30 => _30.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _31 => _31.y]), `${path}.phase.y`) };
3820
3342
  }
3821
3343
  return withOpacity(p);
3822
3344
  }
3823
- return fail2(`${path}.type must be color, gradient or pattern, got ${JSON.stringify(o.type)}.`);
3345
+ return fail(`${path}.type must be color, gradient or pattern, got ${JSON.stringify(o.type)}.`);
3824
3346
  }
3825
3347
  function normalizeShapeStroke(v, path = "stroke", base) {
3826
- if (!v || typeof v !== "object") return fail2(`${path} must be an object { width, paint, align?, cap?, join?, miterLimit?, dashes?, dashOffset? } or null.`);
3348
+ if (!v || typeof v !== "object") return fail(`${path} must be an object { width, paint, align?, cap?, join?, miterLimit?, dashes?, dashOffset? } or null.`);
3827
3349
  const o = v;
3828
3350
  const width = o.width === void 0 && base ? base.width : requireNum(o.width, `${path}.width`, 0, 1e4);
3829
3351
  const paint = o.paint === void 0 && base ? base.paint : o.paint === void 0 && o.color !== void 0 ? normalizeShapePaint(o.color, `${path}.color`) : normalizeShapePaint(o.paint, `${path}.paint`);
3830
3352
  const out = { width, paint };
3831
3353
  const pick = (k, allowed) => {
3832
- const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _60 => _60[k]]) : o[k];
3354
+ const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _32 => _32[k]]) : o[k];
3833
3355
  if (value === void 0) return;
3834
- if (!allowed.includes(value)) fail2(`${path}.${k} must be one of ${allowed.join(", ")}, got ${JSON.stringify(value)}.`);
3356
+ if (!allowed.includes(value)) fail(`${path}.${k} must be one of ${allowed.join(", ")}, got ${JSON.stringify(value)}.`);
3835
3357
  if (value !== (k === "align" ? "center" : k === "cap" ? "butt" : "miter")) out[k] = value;
3836
3358
  };
3837
3359
  pick("align", ["inside", "center", "outside"]);
3838
3360
  pick("cap", ["butt", "round", "square"]);
3839
3361
  pick("join", ["miter", "round", "bevel"]);
3840
- const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _61 => _61.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
3362
+ const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _33 => _33.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
3841
3363
  if (miter !== void 0 && miter !== DEFAULT_MITER_LIMIT) out.miterLimit = miter;
3842
- const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _62 => _62.dashes]) : o.dashes;
3364
+ const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _34 => _34.dashes]) : o.dashes;
3843
3365
  if (dashes !== void 0 && dashes !== null) {
3844
- if (!Array.isArray(dashes) || dashes.length > 32 || !dashes.every((d) => isNum(d) && d >= 0 && d <= 1e4)) fail2(`${path}.dashes must be at most 32 lengths 0..10000 (multiples of the width).`);
3366
+ if (!Array.isArray(dashes) || dashes.length > 32 || !dashes.every((d) => isNum(d) && d >= 0 && d <= 1e4)) fail(`${path}.dashes must be at most 32 lengths 0..10000 (multiples of the width).`);
3845
3367
  if (dashes.length) {
3846
- if (dashes.reduce((s, d) => s + d, 0) < 0.01) fail2(`${path}.dashes must add up to at least 0.01 widths.`);
3368
+ if (dashes.reduce((s, d) => s + d, 0) < 0.01) fail(`${path}.dashes must add up to at least 0.01 widths.`);
3847
3369
  out.dashes = [...dashes];
3848
3370
  }
3849
3371
  }
3850
- const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _63 => _63.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
3372
+ const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _35 => _35.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
3851
3373
  if (offset) out.dashOffset = offset;
3852
3374
  return out;
3853
3375
  }
@@ -3861,7 +3383,7 @@ function box(o, path) {
3861
3383
  }
3862
3384
  function arrowhead(v, path) {
3863
3385
  if (v === null || v === void 0 || v === false) return null;
3864
- if (typeof v !== "object") return fail2(`${path} must be { width, length, concavity? } in pixels, or null.`);
3386
+ if (typeof v !== "object") return fail(`${path} must be { width, length, concavity? } in pixels, or null.`);
3865
3387
  const o = v;
3866
3388
  const head = { width: requireNum(o.width, `${path}.width`, 0, 1e5), length: requireNum(o.length, `${path}.length`, 0, 1e5) };
3867
3389
  if (o.concavity !== void 0 && o.concavity !== 0) head.concavity = requireNum(o.concavity, `${path}.concavity`, -0.5, 0.5);
@@ -3869,13 +3391,13 @@ function arrowhead(v, path) {
3869
3391
  }
3870
3392
  function matrixArg(v, path) {
3871
3393
  if (v === void 0 || v === null) return void 0;
3872
- if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
3394
+ if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail(`${path} must be six numbers [a, b, c, d, e, f].`);
3873
3395
  const m = v;
3874
- if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
3396
+ if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail(`${path} is singular.`);
3875
3397
  return _chunkEGZM52EOcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3876
3398
  }
3877
3399
  function normalizeLiveShape(v, path = "shape") {
3878
- if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
3400
+ if (!v || typeof v !== "object") return fail(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
3879
3401
  const o = v;
3880
3402
  const transform = matrixArg(o.transform, `${path}.transform`);
3881
3403
  const t = transform ? { transform } : {};
@@ -3886,7 +3408,7 @@ function normalizeLiveShape(v, path = "shape") {
3886
3408
  if (o.radii !== void 0 || o.radius !== void 0) {
3887
3409
  const r = _nullishCoalesce(o.radii, () => ( o.radius));
3888
3410
  const list2 = typeof r === "number" ? [r, r, r, r] : r;
3889
- if (!Array.isArray(list2) || list2.length !== 4 || !list2.every((x) => isNum(x) && x >= 0)) fail2(`${path}.radii must be four radii \u2265 0 [top-left, top-right, bottom-right, bottom-left] (or radius, one number).`);
3411
+ if (!Array.isArray(list2) || list2.length !== 4 || !list2.every((x) => isNum(x) && x >= 0)) fail(`${path}.radii must be four radii \u2265 0 [top-left, top-right, bottom-right, bottom-left] (or radius, one number).`);
3890
3412
  if (list2.some((x) => x > 0)) radii = [...list2];
3891
3413
  }
3892
3414
  return { kind: "rect", ...b, ...radii ? { radii } : {}, ...t };
@@ -3917,16 +3439,16 @@ function normalizeLiveShape(v, path = "shape") {
3917
3439
  const e = arrowhead(o.endArrow, `${path}.endArrow`);
3918
3440
  if (s) line.startArrow = s;
3919
3441
  if (e) line.endArrow = e;
3920
- if (line.x1 === line.x2 && line.y1 === line.y2) fail2(`${path}: the line's two ends are the same point.`);
3442
+ if (line.x1 === line.x2 && line.y1 === line.y2) fail(`${path}: the line's two ends are the same point.`);
3921
3443
  return line;
3922
3444
  }
3923
3445
  default:
3924
- return fail2(`${path}.kind must be one of ${LIVE_SHAPE_KINDS.join(", ")}, got ${JSON.stringify(o.kind)}.`);
3446
+ return fail(`${path}.kind must be one of ${LIVE_SHAPE_KINDS.join(", ")}, got ${JSON.stringify(o.kind)}.`);
3925
3447
  }
3926
3448
  }
3927
3449
  function point(v, path) {
3928
3450
  const p = v;
3929
- if (!p || typeof p !== "object") return fail2(`${path} must be { x, y } in document pixels.`);
3451
+ if (!p || typeof p !== "object") return fail(`${path} must be { x, y } in document pixels.`);
3930
3452
  return { x: requireNum(p.x, `${path}.x`), y: requireNum(p.y, `${path}.y`) };
3931
3453
  }
3932
3454
  function normalizeSubpaths(v, path = "subpaths") {
@@ -3935,15 +3457,15 @@ function normalizeSubpaths(v, path = "subpaths") {
3935
3457
  try {
3936
3458
  subs = _chunkEGZM52EOcjs.bezierToSubpaths.call(void 0, v);
3937
3459
  } catch (e5) {
3938
- return fail2(`${path}: could not read the SVG path data.`);
3460
+ return fail(`${path}: could not read the SVG path data.`);
3939
3461
  }
3940
- if (!subs.length || !subs.every((s) => s.anchors.every((a) => isNum(a.x) && isNum(a.y)))) fail2(`${path}: the SVG path data holds no drawable subpath.`);
3462
+ if (!subs.length || !subs.every((s) => s.anchors.every((a) => isNum(a.x) && isNum(a.y)))) fail(`${path}: the SVG path data holds no drawable subpath.`);
3941
3463
  return subs;
3942
3464
  }
3943
- if (!Array.isArray(v) || !v.length) return fail2(`${path} must be a non-empty array of { anchors: [{ x, y, in?, out? }], closed } (or SVG path data).`);
3465
+ if (!Array.isArray(v) || !v.length) return fail(`${path} must be a non-empty array of { anchors: [{ x, y, in?, out? }], closed } (or SVG path data).`);
3944
3466
  return v.map((s, i) => {
3945
3467
  const sp = s;
3946
- if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 1) fail2(`${path}[${i}].anchors must be a non-empty array.`);
3468
+ if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 1) fail(`${path}[${i}].anchors must be a non-empty array.`);
3947
3469
  const anchors = sp.anchors.map((a, j) => {
3948
3470
  const at = `${path}[${i}].anchors[${j}]`;
3949
3471
  const p = point(a, at);
@@ -3963,16 +3485,16 @@ function normalizeSubpaths(v, path = "subpaths") {
3963
3485
  }
3964
3486
  function requireOperation(v, path = "op") {
3965
3487
  if (v === void 0) return "combine";
3966
- if (!SHAPE_OPERATIONS.includes(v)) fail2(`${path} must be one of ${SHAPE_OPERATIONS.join(", ")}, got ${JSON.stringify(v)}.`);
3488
+ if (!SHAPE_OPERATIONS.includes(v)) fail(`${path} must be one of ${SHAPE_OPERATIONS.join(", ")}, got ${JSON.stringify(v)}.`);
3967
3489
  return v;
3968
3490
  }
3969
3491
  function requireShapeLayer(layers, id) {
3970
3492
  const layer = requireLayer(layers, id).layer;
3971
- if (layer.type !== "shape") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer, not a shape layer; list_layers shows each layer's type.`);
3493
+ if (layer.type !== "shape") fail(`Layer "${layer.name || id}" is a ${layer.type} layer, not a shape layer; list_layers shows each layer's type.`);
3972
3494
  return layer;
3973
3495
  }
3974
3496
  function createShapeLayer(init, env, id = newLayerId()) {
3975
- if (!init.components.length) fail2("A shape needs at least one component.");
3497
+ if (!init.components.length) fail("A shape needs at least one component.");
3976
3498
  const layer = {
3977
3499
  type: "shape",
3978
3500
  id,
@@ -3991,7 +3513,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
3991
3513
  return rerenderShape(layer, env);
3992
3514
  }
3993
3515
  function defaultShapeName(c) {
3994
- switch (_optionalChain([c, 'optionalAccess', _64 => _64.live, 'optionalAccess', _65 => _65.kind])) {
3516
+ switch (_optionalChain([c, 'optionalAccess', _36 => _36.live, 'optionalAccess', _37 => _37.kind])) {
3995
3517
  case "rect":
3996
3518
  return "Rectangle";
3997
3519
  case "ellipse":
@@ -4012,7 +3534,7 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
4012
3534
  const patch = change(current);
4013
3535
  const next = { ...current, ...patch };
4014
3536
  if (!("annotation" in patch)) delete next.annotation;
4015
- if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
3537
+ if (!next.components.length) fail("A shape needs at least one component; delete the layer instead.");
4016
3538
  const rendered = rerenderShape(next, env);
4017
3539
  return { layers: _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4018
3540
  }
@@ -4036,7 +3558,7 @@ function mergeShapeComponents(components, fillRule = "nonzero") {
4036
3558
  if (components.length < 2) return [...components];
4037
3559
  const path = shapeOutline(components, fillRule);
4038
3560
  const subpaths = _chunkEGZM52EOcjs.bezierToSubpaths.call(void 0, path);
4039
- if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
3561
+ if (!subpaths.length) fail("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
4040
3562
  return [{ op: "combine", subpaths }];
4041
3563
  }
4042
3564
  function shapeAsPixelLayer(layer) {
@@ -4107,19 +3629,641 @@ function shapeFromAnnotation(a) {
4107
3629
  return null;
4108
3630
  }
4109
3631
  }
4110
- function annotationBlend(a, layerBlend) {
4111
- if (layerBlend !== "normal") return layerBlend;
4112
- return a.blend && _chunkCWM3CUUXcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
4113
- }
4114
- function annotationOfShape(layer) {
4115
- const a = layer.annotation;
4116
- if (!a) return null;
4117
- const blend = layer.blend;
4118
- if ((_nullishCoalesce(a.blend, () => ( "normal"))) === blend) return a;
4119
- const out = { ...a };
4120
- if (blend === "normal") delete out.blend;
4121
- else out.blend = blend;
4122
- return out;
3632
+ function annotationBlend(a, layerBlend) {
3633
+ if (layerBlend !== "normal") return layerBlend;
3634
+ return a.blend && _chunkCWM3CUUXcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3635
+ }
3636
+ function annotationOfShape(layer) {
3637
+ const a = layer.annotation;
3638
+ if (!a) return null;
3639
+ const blend = layer.blend;
3640
+ if ((_nullishCoalesce(a.blend, () => ( "normal"))) === blend) return a;
3641
+ const out = { ...a };
3642
+ if (blend === "normal") delete out.blend;
3643
+ else out.blend = blend;
3644
+ return out;
3645
+ }
3646
+
3647
+ // src/image-editor/layers/vector-mask.ts
3648
+ function isActiveVectorMask(vm) {
3649
+ return Boolean(vm && vm.enabled !== false);
3650
+ }
3651
+ function vectorMaskCoverage(vm, width, height) {
3652
+ let v = componentsCoverage(vm.components, { x: 0, y: 0, width, height }, _nullishCoalesce(vm.fillRule, () => ( "nonzero")), vm.inverted === true);
3653
+ if ((_nullishCoalesce(vm.feather, () => ( 0))) > 0) v = _chunkHGTDMKNEcjs.gaussianBlur.call(void 0, v, width, height, vm.feather, "clamp");
3654
+ const density = _nullishCoalesce(vm.density, () => ( 1));
3655
+ if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
3656
+ return v;
3657
+ }
3658
+ function outsideValue(vm) {
3659
+ return 1 - (_nullishCoalesce(vm.density, () => ( 1))) * (1 - (vm.inverted ? 1 : 0));
3660
+ }
3661
+ function rasterCoverage(mask, ox, oy, width, height) {
3662
+ const bytes = _chunkCWM3CUUXcjs.readRegion.call(void 0, mask.surface, { x: -ox, y: -oy, width, height });
3663
+ let v = new Float32Array(width * height);
3664
+ for (let i = 0; i < v.length; i++) v[i] = bytes[i] / 255;
3665
+ if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) v = _chunkHGTDMKNEcjs.gaussianBlur.call(void 0, v, width, height, mask.feather, "clamp");
3666
+ const density = _nullishCoalesce(mask.density, () => ( 1));
3667
+ if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
3668
+ return v;
3669
+ }
3670
+ var layerOffset = (layer) => layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
3671
+ function effectiveLayerMask(layer, width, height) {
3672
+ const vm = layer.vectorMask;
3673
+ const raster = layer.mask;
3674
+ if (!isActiveVectorMask(vm) || _optionalChain([raster, 'optionalAccess', _38 => _38.source]) || width < 1 || height < 1) return raster;
3675
+ const { x: ox, y: oy } = layerOffset(layer);
3676
+ const v = vectorMaskCoverage(vm, width, height);
3677
+ let outside = outsideValue(vm);
3678
+ if (raster && raster.enabled !== false) {
3679
+ const r = rasterCoverage(raster, ox, oy, width, height);
3680
+ for (let i = 0; i < v.length; i++) v[i] *= r[i];
3681
+ outside *= 1 - (_nullishCoalesce(raster.density, () => ( 1))) * (1 - raster.defaultValue / 255);
3682
+ }
3683
+ const bytes = new Uint8ClampedArray(v.length);
3684
+ for (let i = 0; i < v.length; i++) bytes[i] = Math.round(v[i] * 255);
3685
+ const defaultValue = outside >= 0.5 ? 255 : 0;
3686
+ return { surface: _chunkCWM3CUUXcjs.writeRegion.call(void 0, _chunkCWM3CUUXcjs.emptySurface.call(void 0, 1, defaultValue), { x: -ox, y: -oy, width, height }, bytes), defaultValue };
3687
+ }
3688
+ var resolved = /* @__PURE__ */ new WeakMap();
3689
+ function hasVectorMask(layers) {
3690
+ for (const l of layers) {
3691
+ if (isActiveVectorMask(l.vectorMask)) return true;
3692
+ if (l.type === "group" && hasVectorMask(l.children)) return true;
3693
+ }
3694
+ return false;
3695
+ }
3696
+ function resolveVectorMasks(layers, width, height) {
3697
+ if (!hasVectorMask(layers)) return layers;
3698
+ return layers.map((l) => resolveLayer(l, width, height));
3699
+ }
3700
+ function resolveLayer(layer, width, height) {
3701
+ let next = layer;
3702
+ if (layer.type === "group" && hasVectorMask(layer.children)) {
3703
+ const key2 = `${width}x${height}`;
3704
+ const hit2 = resolved.get(layer);
3705
+ if (_optionalChain([hit2, 'optionalAccess', _39 => _39.key]) === key2) return hit2.layer;
3706
+ next = { ...layer, children: layer.children.map((c) => resolveLayer(c, width, height)) };
3707
+ if (!isActiveVectorMask(layer.vectorMask)) {
3708
+ resolved.set(layer, { key: key2, layer: next });
3709
+ return next;
3710
+ }
3711
+ }
3712
+ if (!isActiveVectorMask(layer.vectorMask)) return layer;
3713
+ const key = `${width}x${height}:v`;
3714
+ const hit = resolved.get(layer);
3715
+ if (_optionalChain([hit, 'optionalAccess', _40 => _40.key]) === key) return hit.layer;
3716
+ const mask = effectiveLayerMask(layer, width, height);
3717
+ const out = { ...next, mask };
3718
+ delete out.vectorMask;
3719
+ if (!mask) delete out.mask;
3720
+ resolved.set(layer, { key, layer: out });
3721
+ return out;
3722
+ }
3723
+ function offsetVectorMask(vm, dx, dy) {
3724
+ if (!dx && !dy) return vm;
3725
+ return { ...vm, components: vm.components.map((c) => ({ ...c, subpaths: mapSubpaths(c.subpaths, (p) => ({ x: p.x + dx, y: p.y + dy })), ...c.live ? { live: offsetLive(c.live, dx, dy) } : {} })) };
3726
+ }
3727
+ function offsetLive(live, dx, dy) {
3728
+ if (live.kind === "line") return { ...live, x1: live.x1 + dx, y1: live.y1 + dy, x2: live.x2 + dx, y2: live.y2 + dy };
3729
+ return { ...live, x: live.x + dx, y: live.y + dy };
3730
+ }
3731
+ function transformVectorMask(vm, f, affine) {
3732
+ return { ...vm, components: transformShapeComponents(vm.components, f, affine) };
3733
+ }
3734
+ function followLayerMove(layer, dx, dy) {
3735
+ const vm = layer.vectorMask;
3736
+ if (!vm || vm.linked === false || !dx && !dy) return layer;
3737
+ return { ...layer, vectorMask: offsetVectorMask(vm, dx, dy) };
3738
+ }
3739
+ function vectorMaskBounds(vm) {
3740
+ let x0 = Infinity;
3741
+ let y0 = Infinity;
3742
+ let x1 = -Infinity;
3743
+ let y1 = -Infinity;
3744
+ for (const c of vm.components) {
3745
+ for (const ring of flattenPath(componentPath(c))) {
3746
+ for (let k = 0; k + 1 < ring.length; k += 2) {
3747
+ x0 = Math.min(x0, ring[k]);
3748
+ x1 = Math.max(x1, ring[k]);
3749
+ y0 = Math.min(y0, ring[k + 1]);
3750
+ y1 = Math.max(y1, ring[k + 1]);
3751
+ }
3752
+ }
3753
+ }
3754
+ return x0 === Infinity ? null : { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
3755
+ }
3756
+ var thumbCache = /* @__PURE__ */ new WeakMap();
3757
+ function vectorMaskThumbnail(vm, width, height, maxSide = 64) {
3758
+ const key = `${width}x${height}:${maxSide}`;
3759
+ const hit = thumbCache.get(vm);
3760
+ if (_optionalChain([hit, 'optionalAccess', _41 => _41.key]) === key) return hit.pixels;
3761
+ const k = Math.min(1, maxSide / Math.max(1, width, height));
3762
+ const tw = Math.max(1, Math.round(width * k));
3763
+ const th = Math.max(1, Math.round(height * k));
3764
+ const scaled = transformVectorMask(vm, (p) => ({ x: p.x * k, y: p.y * k }), [k, 0, 0, k, 0, 0]);
3765
+ const cov = componentsCoverage(scaled.components, { x: 0, y: 0, width: tw, height: th }, _nullishCoalesce(vm.fillRule, () => ( "nonzero")), vm.inverted === true);
3766
+ const data = new Uint8ClampedArray(tw * th * 4);
3767
+ for (let i = 0; i < cov.length; i++) {
3768
+ const v = Math.round(Math.min(1, Math.max(0, cov[i])) * 255);
3769
+ data[i * 4] = data[i * 4 + 1] = data[i * 4 + 2] = v;
3770
+ data[i * 4 + 3] = 255;
3771
+ }
3772
+ const pixels = { width: tw, height: th, data };
3773
+ thumbCache.set(vm, { key, pixels });
3774
+ return pixels;
3775
+ }
3776
+
3777
+ // src/image-editor/layers/ops.ts
3778
+ var LayerOperationError = class extends Error {
3779
+
3780
+ constructor(message, userMessage) {
3781
+ super(message);
3782
+ this.name = "LayerOperationError";
3783
+ if (userMessage) this.userMessage = userMessage;
3784
+ }
3785
+ };
3786
+ function userErrorMessage(err) {
3787
+ if (err instanceof LayerOperationError && err.userMessage) return err.userMessage;
3788
+ return err instanceof Error ? err.message : String(err);
3789
+ }
3790
+ function isPaintableLayer(layer) {
3791
+ return layer.type === "pixel" && layer.visible && !_chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, "pixels");
3792
+ }
3793
+ function defaultActiveLayerId(layers) {
3794
+ const pixels = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
3795
+ for (let i = pixels.length - 1; i >= 0; i--) if (isPaintableLayer(pixels[i])) return pixels[i].id;
3796
+ return _nullishCoalesce(_optionalChain([pixels, 'access', _42 => _42[pixels.length - 1], 'optionalAccess', _43 => _43.id]), () => ( null));
3797
+ }
3798
+ function activeLayerAfterRemoval(prev, next, removedId) {
3799
+ const before = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, prev);
3800
+ const at = before.findIndex((l) => l.id === removedId);
3801
+ for (let i = at - 1; i >= 0; i--) {
3802
+ const loc = _chunkHGTDMKNEcjs.findLayer.call(void 0, next, before[i].id);
3803
+ if (loc && isPaintableLayer(loc.layer)) return loc.layer.id;
3804
+ }
3805
+ return defaultActiveLayerId(next);
3806
+ }
3807
+ var fail2 = (message) => {
3808
+ throw new LayerOperationError(message);
3809
+ };
3810
+ function requireLayer(layers, id) {
3811
+ const loc = _chunkHGTDMKNEcjs.findLayer.call(void 0, layers, id);
3812
+ if (!loc) {
3813
+ const ids = _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
3814
+ fail2(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
3815
+ }
3816
+ return loc;
3817
+ }
3818
+ function requireUnlocked(layer, what, action) {
3819
+ if (_chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, "all")) fail2(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
3820
+ if (what !== "all" && _chunkHGTDMKNEcjs.isLayerLocked.call(void 0, layer, what)) fail2(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
3821
+ }
3822
+ function placeLayer(layers, layer, placement = {}, defaultIndex) {
3823
+ const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
3824
+ if (given > 1) fail2("Give only one of aboveId, belowId and parentId.");
3825
+ if (placement.aboveId || placement.belowId) {
3826
+ const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
3827
+ return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _44 => _44.parent, 'optionalAccess', _45 => _45.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
3828
+ }
3829
+ if (placement.parentId) {
3830
+ const ref = requireLayer(layers, placement.parentId);
3831
+ if (ref.layer.type !== "group") fail2(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
3832
+ return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
3833
+ }
3834
+ return _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
3835
+ }
3836
+ function removeLayer(layers, id) {
3837
+ const loc = requireLayer(layers, id);
3838
+ requireUnlocked(loc.layer, "all", "delete it");
3839
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3840
+ }
3841
+ function moveLayer(layers, id, placement) {
3842
+ const loc = requireLayer(layers, id);
3843
+ requireUnlocked(loc.layer, "all", "move it");
3844
+ const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
3845
+ if (target === id) fail2("A layer cannot be placed relative to itself.");
3846
+ if (target && loc.layer.type === "group" && _chunkHGTDMKNEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
3847
+ fail2(`Group "${id}" cannot be moved into its own child "${target}".`);
3848
+ }
3849
+ if (target) requireLayer(layers, target);
3850
+ if (!target && placement.index === void 0) fail2("Give aboveId, belowId, parentId or index.");
3851
+ const without = _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3852
+ return placeLayer(without, loc.layer, placement);
3853
+ }
3854
+ function withNewIds(layer) {
3855
+ const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
3856
+ if (next.type === "group") next.children = next.children.map(withNewIds);
3857
+ if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
3858
+ if (next.type === "shape" || next.type === "type") delete next.annotation;
3859
+ if (next.type === "smart" && _optionalChain([next, 'access', _46 => _46.psd, 'optionalAccess', _47 => _47.placed])) {
3860
+ next.psd = { ...next.psd };
3861
+ delete next.psd.placed;
3862
+ }
3863
+ return next;
3864
+ }
3865
+ function duplicateLayer(layers, id, name) {
3866
+ const loc = requireLayer(layers, id);
3867
+ const copy = withNewIds(loc.layer);
3868
+ copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
3869
+ delete copy.locks;
3870
+ return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _48 => _48.parent, 'optionalAccess', _49 => _49.id]), () => ( null)), loc.index + 1), id: copy.id };
3871
+ }
3872
+ function setLayerProperties(layers, id, props) {
3873
+ const loc = requireLayer(layers, id);
3874
+ const layer = loc.layer;
3875
+ const onlyUnlocking = Object.keys(props).every((k) => k === "locks" || k === "visible" || k === "collapsed");
3876
+ if (!onlyUnlocking) requireUnlocked(layer, "all", "change its properties");
3877
+ const next = { ...layer };
3878
+ if (props.name !== void 0) {
3879
+ if (typeof props.name !== "string" || !props.name.trim()) fail2("name must be a non-empty string.");
3880
+ next.name = props.name.trim();
3881
+ }
3882
+ if (props.visible !== void 0) next.visible = Boolean(props.visible);
3883
+ if (props.opacity !== void 0) {
3884
+ if (!(typeof props.opacity === "number" && props.opacity >= 0 && props.opacity <= 1)) fail2("opacity must be a number from 0 to 1.");
3885
+ next.opacity = props.opacity;
3886
+ }
3887
+ if (props.fillOpacity !== void 0) {
3888
+ if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape" && layer.type !== "type") fail2(`fillOpacity applies to pixel, shape, type and smart object layers; "${id}" is a ${layer.type} layer.`);
3889
+ if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail2("fillOpacity must be a number from 0 to 1.");
3890
+ const p = next;
3891
+ if (props.fillOpacity === 1) delete p.fillOpacity;
3892
+ else p.fillOpacity = props.fillOpacity;
3893
+ }
3894
+ if (props.blend !== void 0) {
3895
+ if (props.blend === "pass-through") {
3896
+ if (layer.type !== "group") fail2("pass-through is only for groups.");
3897
+ } else if (!_chunkCWM3CUUXcjs.isBlendMode.call(void 0, props.blend)) fail2(`Unknown blend mode "${props.blend}".`);
3898
+ next.blend = props.blend;
3899
+ }
3900
+ if (props.clipped !== void 0) {
3901
+ if (props.clipped && loc.index === 0) fail2("The bottom layer of a group or the stack has nothing below to clip to.");
3902
+ if (props.clipped) next.clipped = true;
3903
+ else delete next.clipped;
3904
+ }
3905
+ if (props.locks !== void 0) {
3906
+ const locks = {};
3907
+ for (const k of ["pixels", "transparency", "position", "all"]) if (props.locks[k]) locks[k] = true;
3908
+ if (Object.keys(locks).length) next.locks = locks;
3909
+ else delete next.locks;
3910
+ }
3911
+ if (props.collapsed !== void 0) {
3912
+ if (layer.type !== "group") fail2("collapsed applies to groups.");
3913
+ const g = next;
3914
+ if (props.collapsed) g.collapsed = true;
3915
+ else delete g.collapsed;
3916
+ }
3917
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
3918
+ }
3919
+ function groupLayers(layers, ids, name = "Group") {
3920
+ if (!ids.length) fail2("Give at least one layer id to group.");
3921
+ const locs = ids.map((id) => requireLayer(layers, id));
3922
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _50 => _50[0], 'access', _51 => _51.parent, 'optionalAccess', _52 => _52.id]), () => ( null));
3923
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _53 => _53.parent, 'optionalAccess', _54 => _54.id]), () => ( null))) !== parent)) fail2("Layers to group must share one parent; move them next to each other first.");
3924
+ for (const l of locs) requireUnlocked(l.layer, "all", "group it");
3925
+ const ordered = [...new Set(locs)].sort((a, b) => a.index - b.index);
3926
+ const top = ordered[ordered.length - 1].index;
3927
+ const below = ordered.filter((l) => l.index < top).length;
3928
+ const group = {
3929
+ type: "group",
3930
+ id: newLayerId("group"),
3931
+ name,
3932
+ visible: true,
3933
+ opacity: 1,
3934
+ blend: "pass-through",
3935
+ children: ordered.map((l) => {
3936
+ const c = { ...l.layer };
3937
+ return c;
3938
+ })
3939
+ };
3940
+ if (_optionalChain([group, 'access', _55 => _55.children, 'access', _56 => _56[0], 'optionalAccess', _57 => _57.clipped])) {
3941
+ const c = { ...group.children[0] };
3942
+ delete c.clipped;
3943
+ group.children[0] = c;
3944
+ }
3945
+ let out = layers;
3946
+ for (const l of ordered) out = _chunkHGTDMKNEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3947
+ return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3948
+ }
3949
+ function ungroupLayer(layers, id) {
3950
+ const loc = requireLayer(layers, id);
3951
+ if (loc.layer.type !== "group") fail2(`Layer "${id}" is not a group.`);
3952
+ requireUnlocked(loc.layer, "all", "ungroup it");
3953
+ const group = loc.layer;
3954
+ let out = _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => null);
3955
+ group.children.forEach((c, i) => {
3956
+ out = _chunkHGTDMKNEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _58 => _58.parent, 'optionalAccess', _59 => _59.id]), () => ( null)), loc.index + i);
3957
+ });
3958
+ return { layers: out, ids: group.children.map((c) => c.id) };
3959
+ }
3960
+ function offsetLayer(layers, id, offset) {
3961
+ const loc = requireLayer(layers, id);
3962
+ if (loc.layer.type !== "pixel") fail2(`Only pixel layers move; "${id}" is a ${loc.layer.type} layer.`);
3963
+ requireUnlocked(loc.layer, "position", "move it");
3964
+ if (!Number.isFinite(offset.x) || !Number.isFinite(offset.y)) fail2("x and y must be numbers.");
3965
+ const layer = loc.layer;
3966
+ const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
3967
+ const mask = layer.mask;
3968
+ if (mask && mask.linked === false && !mask.source) {
3969
+ next.mask = { ...mask, surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3970
+ }
3971
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => followLayerMove(next, next.offset.x - layer.offset.x, next.offset.y - layer.offset.y));
3972
+ }
3973
+ function setLayerMask(layers, id, mask) {
3974
+ const loc = requireLayer(layers, id);
3975
+ requireUnlocked(loc.layer, "all", "change its mask");
3976
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, (l) => {
3977
+ const next = { ...l };
3978
+ if (mask) next.mask = mask;
3979
+ else delete next.mask;
3980
+ return next;
3981
+ });
3982
+ }
3983
+ var DEVELOP_FIELDS = ["brightness", "contrast", "saturation", "exposure", "temperature", "tint"];
3984
+ function normalizeFilter(raw, id = newLayerId("flt")) {
3985
+ const enabled = raw.enabled !== false;
3986
+ if (raw.kind === "blur") {
3987
+ const r = raw.radius;
3988
+ if (r !== void 0 && !(typeof r === "number" && r >= 0 && r <= 50)) fail2("blur radius must be a number from 0 to 50 px.");
3989
+ return { id, kind: "blur", enabled, radius: typeof r === "number" ? r : 2 };
3990
+ }
3991
+ if (raw.kind !== "develop") fail2(`Unknown filter kind "${raw.kind}". Use develop or blur.`);
3992
+ const out = { id, kind: "develop", enabled, brightness: 0, contrast: 0, saturation: 0, exposure: 0, temperature: 0, tint: 0, process: 2 };
3993
+ for (const k of DEVELOP_FIELDS) {
3994
+ const v = raw[k];
3995
+ if (v === void 0) continue;
3996
+ if (!(typeof v === "number" && v >= -100 && v <= 100)) fail2(`${k} must be a number from -100 to 100.`);
3997
+ out[k] = v;
3998
+ }
3999
+ const p = raw.process;
4000
+ if (p !== void 0) {
4001
+ if (p !== 1 && p !== 2) fail2("process must be 1 or 2.");
4002
+ out.process = p;
4003
+ }
4004
+ return out;
4005
+ }
4006
+ function requirePixelLayer(layers, id) {
4007
+ const loc = requireLayer(layers, id);
4008
+ if (loc.layer.type !== "pixel") fail2(`Filters belong to pixel layers; "${id}" is a ${loc.layer.type} layer.`);
4009
+ requireUnlocked(loc.layer, "all", "change its filters");
4010
+ return loc.layer;
4011
+ }
4012
+ function addLayerFilter(layers, id, filter) {
4013
+ const layer = requirePixelLayer(layers, id);
4014
+ if (_optionalChain([layer, 'access', _60 => _60.filters, 'optionalAccess', _61 => _61.some, 'call', _62 => _62((f) => f.kind === filter.kind)])) fail2(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
4015
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
4016
+ }
4017
+ function updateLayerFilter(layers, id, filterId, changes) {
4018
+ const layer = requirePixelLayer(layers, id);
4019
+ const i = (_nullishCoalesce(layer.filters, () => ( []))).findIndex((f) => f.id === filterId);
4020
+ if (i === -1) fail2(`Layer "${id}" has no filter "${filterId}". Filters: ${(_nullishCoalesce(layer.filters, () => ( []))).map((f) => f.id).join(", ") || "none"}.`);
4021
+ const current = layer.filters[i];
4022
+ if ("kind" in changes && changes.kind !== current.kind) fail2("A filter kind cannot change; remove it and add another.");
4023
+ const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
4024
+ const filters = [...layer.filters];
4025
+ filters[i] = merged2;
4026
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
4027
+ }
4028
+ function removeLayerFilter(layers, id, filterId) {
4029
+ const layer = requirePixelLayer(layers, id);
4030
+ if (!(_nullishCoalesce(layer.filters, () => ( []))).some((f) => f.id === filterId)) fail2(`Layer "${id}" has no filter "${filterId}".`);
4031
+ const filters = layer.filters.filter((f) => f.id !== filterId);
4032
+ const next = { ...layer };
4033
+ if (filters.length) next.filters = filters;
4034
+ else delete next.filters;
4035
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
4036
+ }
4037
+ function requireEffectLayer(layers, id, action) {
4038
+ const layer = requireLayer(layers, id).layer;
4039
+ if (layer.type === "adjustment") fail2(`Layer "${layer.name || id}" is an adjustment layer; effects go on pixel, annotation and group layers.`);
4040
+ requireUnlocked(layer, "all", action);
4041
+ return layer;
4042
+ }
4043
+ function layerEffectsOf(layer) {
4044
+ return _nullishCoalesce(layer.effects, () => ( { enabled: true, items: [] }));
4045
+ }
4046
+ function guard(fn) {
4047
+ try {
4048
+ return fn();
4049
+ } catch (e) {
4050
+ if (e instanceof _chunkHGTDMKNEcjs.LayerEffectError) fail2(e.message);
4051
+ throw e;
4052
+ }
4053
+ }
4054
+ function setLayerEffects(layers, id, effects) {
4055
+ const layer = requireEffectLayer(layers, id, "change its effects");
4056
+ const next = { ...layer };
4057
+ if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
4058
+ guard(() => _chunkHGTDMKNEcjs.validateLayerEffects.call(void 0, effects));
4059
+ next.effects = effects;
4060
+ } else delete next.effects;
4061
+ return _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => next);
4062
+ }
4063
+ function addLayerEffect(layers, id, kind, params = {}, index) {
4064
+ if (!_chunkHGTDMKNEcjs.isLayerEffectKind.call(void 0, kind)) fail2(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkHGTDMKNEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
4065
+ const layer = requireEffectLayer(layers, id, "add effects");
4066
+ const current = layerEffectsOf(layer);
4067
+ const ids = new Set(current.items.map((e) => e.id));
4068
+ let effectId = _chunkHGTDMKNEcjs.newEffectId.call(void 0, );
4069
+ while (ids.has(effectId)) effectId = _chunkHGTDMKNEcjs.newEffectId.call(void 0, );
4070
+ const { id: _ignored, kind: _kind, ...rest } = params;
4071
+ const effect = guard(() => _chunkHGTDMKNEcjs.mergeLayerEffect.call(void 0, _chunkHGTDMKNEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
4072
+ const items = [...current.items];
4073
+ const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
4074
+ items.splice(at, 0, effect);
4075
+ return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
4076
+ }
4077
+ function requireEffect(layer, effectId) {
4078
+ const items = _nullishCoalesce(_optionalChain([layer, 'access', _63 => _63.effects, 'optionalAccess', _64 => _64.items]), () => ( []));
4079
+ const i = items.findIndex((e) => e.id === effectId);
4080
+ if (i === -1) fail2(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
4081
+ return i;
4082
+ }
4083
+ function updateLayerEffect(layers, id, effectId, changes) {
4084
+ const layer = requireEffectLayer(layers, id, "change its effects");
4085
+ const i = requireEffect(layer, effectId);
4086
+ const current = layer.effects;
4087
+ const items = [...current.items];
4088
+ items[i] = guard(() => _chunkHGTDMKNEcjs.mergeLayerEffect.call(void 0, items[i], changes));
4089
+ return setLayerEffects(layers, id, { ...current, items });
4090
+ }
4091
+ function removeLayerEffect(layers, id, effectId) {
4092
+ const layer = requireEffectLayer(layers, id, "change its effects");
4093
+ requireEffect(layer, effectId);
4094
+ const current = layer.effects;
4095
+ return setLayerEffects(layers, id, { ...current, items: current.items.filter((e) => e.id !== effectId) });
4096
+ }
4097
+ function setLayerEffectsEnabled(layers, id, enabled, scale) {
4098
+ const layer = requireEffectLayer(layers, id, "change its effects");
4099
+ if (scale !== void 0 && !(Number.isFinite(scale) && scale >= 0.01 && scale <= 10)) fail2(`scale must be from 0.01 to 10 (1 = 100 %), got ${scale}.`);
4100
+ const current = layerEffectsOf(layer);
4101
+ const next = { ...current, enabled };
4102
+ if (scale !== void 0) {
4103
+ if (scale === 1) delete next.scale;
4104
+ else next.scale = scale;
4105
+ }
4106
+ return setLayerEffects(layers, id, next);
4107
+ }
4108
+ function parseBlend(value, allowPassThrough = false) {
4109
+ if (value === void 0) return void 0;
4110
+ if (value === "pass-through" && allowPassThrough) return value;
4111
+ if (!_chunkCWM3CUUXcjs.isBlendMode.call(void 0, value)) fail2(`Unknown blend mode "${String(value)}".`);
4112
+ return value;
4113
+ }
4114
+ function unionRect(a, b) {
4115
+ if (!a) return b;
4116
+ if (!b) return a;
4117
+ const x = Math.min(a.x, b.x);
4118
+ const y = Math.min(a.y, b.y);
4119
+ return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
4120
+ }
4121
+
4122
+ // src/image-editor/layers/compositor.ts
4123
+ var legacyViewCache = /* @__PURE__ */ new WeakMap();
4124
+ function adjustmentNodeAsLayer(node) {
4125
+ let view = legacyViewCache.get(node);
4126
+ if (!view) {
4127
+ view = {
4128
+ id: node.id,
4129
+ kind: node.kind,
4130
+ enabled: node.visible,
4131
+ opacity: node.opacity,
4132
+ blend: node.blend,
4133
+ params: node.params
4134
+ };
4135
+ legacyViewCache.set(node, view);
4136
+ }
4137
+ return view;
4138
+ }
4139
+ function developAdjustments(f) {
4140
+ return {
4141
+ brightness: f.brightness,
4142
+ contrast: f.contrast,
4143
+ saturation: f.saturation,
4144
+ exposure: f.exposure,
4145
+ temperature: f.temperature,
4146
+ tint: _nullishCoalesce(f.tint, () => ( 0)),
4147
+ blur: 0,
4148
+ opacity: 1,
4149
+ process: f.process
4150
+ };
4151
+ }
4152
+ function applyPixelFilters(data, filters) {
4153
+ for (const f of filters) {
4154
+ if (!isActiveFilter(f) || f.kind !== "develop") continue;
4155
+ const adj = developAdjustments(f);
4156
+ if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Adjustments({ data }, adj);
4157
+ else applyLegacyAdjustments({ data }, adj);
4158
+ }
4159
+ }
4160
+ function depthMaskAlpha(depth, options) {
4161
+ const { mode, depthRange, softness, invert } = options;
4162
+ let v = invert ? 255 - depth : depth;
4163
+ const soft = Math.max(1, softness || 10);
4164
+ const [lo, hi] = depthRange;
4165
+ if (mode === "threshold") {
4166
+ if (v >= hi + soft) return 0;
4167
+ if (v > hi) return Math.round((hi + soft - v) / soft * 255);
4168
+ if (v >= lo) return 255;
4169
+ if (v < lo - soft) return 0;
4170
+ return Math.round((v - (lo - soft)) / soft * 255);
4171
+ }
4172
+ v += lo;
4173
+ return v < 0 ? 0 : v > 255 ? 255 : v;
4174
+ }
4175
+ function runLayerFilters(data, width, height, filters) {
4176
+ for (const f of filters) {
4177
+ if (!isActiveFilter(f)) continue;
4178
+ if (f.kind === "develop") applyPixelFilters(data, [f]);
4179
+ else if (f.kind === "blur") applyBoxBlur({ width, height, data }, Math.min(Math.round(f.radius), 40));
4180
+ }
4181
+ }
4182
+ function runLayerFiltersFloat(data, width, height, filters, linear) {
4183
+ for (const f of filters) {
4184
+ if (!isActiveFilter(f)) continue;
4185
+ if (f.kind === "blur") applyBoxBlurFloat({ width, height, data }, Math.min(Math.round(f.radius), 40));
4186
+ else if (f.kind === "develop") {
4187
+ const adj = developAdjustments(f);
4188
+ if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Float(data, adj, linear);
4189
+ else applyLegacyFloat(data, adj, linear);
4190
+ }
4191
+ }
4192
+ }
4193
+ function filterReach(filters) {
4194
+ let r = 0;
4195
+ for (const f of filters) if (isActiveFilter(f) && f.kind === "blur") r += Math.min(Math.round(f.radius), 40);
4196
+ return r;
4197
+ }
4198
+ var filterSpecCache = /* @__PURE__ */ new WeakMap();
4199
+ function pixelFilterSpec(layer) {
4200
+ const list2 = layer.filters;
4201
+ if (!_optionalChain([list2, 'optionalAccess', _65 => _65.length])) return null;
4202
+ if (filterSpecCache.has(list2)) return filterSpecCache.get(list2);
4203
+ const filters = list2.filter(isActiveFilter);
4204
+ let spec = null;
4205
+ if (filters.length) {
4206
+ const spatial = filters.some(isSpatialFilter);
4207
+ spec = {
4208
+ key: JSON.stringify(filters),
4209
+ spatial,
4210
+ apply: (data, width, height) => runLayerFilters(data, width, height, filters)
4211
+ };
4212
+ }
4213
+ filterSpecCache.set(list2, spec);
4214
+ return spec;
4215
+ }
4216
+ var PHOTO_PROFILE = {
4217
+ isFilterLayer: (l) => l.type === "adjustment",
4218
+ applyFilterRun: (layers, acc, _r, masks) => {
4219
+ const views = layers.map(adjustmentNodeAsLayer);
4220
+ applyAdjustmentLayers({ data: acc }, views, masks);
4221
+ },
4222
+ contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _66 => _66.rasterizeAnnotation, 'optionalCall', _67 => _67(l.annotation, r)]), () => ( null)) : null,
4223
+ /** Annotation layers draw with their annotation's blend mode unless the layer sets one. */
4224
+ contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
4225
+ layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
4226
+ pixelFilters: (l) => l.type === "pixel" ? pixelFilterSpec(l) : null,
4227
+ /**
4228
+ * A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
4229
+ * layer, and a shape layer the pixels rendered from its paths.
4230
+ */
4231
+ isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
4232
+ maskSourcePlane: (source, W, H, sources) => {
4233
+ const opts = source;
4234
+ const depth = _nullishCoalesce(_optionalChain([sources, 'access', _68 => _68.depthMap, 'optionalCall', _69 => _69(opts)]), () => ( null));
4235
+ if (!depth || depth.width !== W || depth.height !== H) return null;
4236
+ const v = new Float32Array(W * H);
4237
+ for (let i = 0; i < v.length; i++) v[i] = depthMaskAlpha(depth.data[i * 4], opts) / 255;
4238
+ return v;
4239
+ }
4240
+ };
4241
+ var LayerCompositor = class extends _chunkHGTDMKNEcjs.RasterCompositor {
4242
+ constructor(options = {}) {
4243
+ super(PHOTO_PROFILE, options);
4244
+ }
4245
+ // Vector masks reach the engine as part of each layer's raster mask (see `resolveVectorMasks`).
4246
+ composite(layers, rect, sources, options) {
4247
+ return super.composite(resolveVectorMasks(layers, sources.width, sources.height), rect, sources, options);
4248
+ }
4249
+ compositeTiles(layers, rect, sources, onTile, options) {
4250
+ super.compositeTiles(resolveVectorMasks(layers, sources.width, sources.height), rect, sources, onTile, options);
4251
+ }
4252
+ tile(layers, tx, ty, sources) {
4253
+ return super.tile(resolveVectorMasks(layers, sources.width, sources.height), tx, ty, sources);
4254
+ }
4255
+ };
4256
+ function compositeDeep(layers, rect, sources, depth) {
4257
+ const deep = new (0, _chunkHGTDMKNEcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
4258
+ applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
4259
+ pixelFiltersDeep: (l) => {
4260
+ if (l.type !== "pixel") return null;
4261
+ const filters = (_nullishCoalesce(l.filters, () => ( []))).filter(isActiveFilter);
4262
+ if (!filters.length) return null;
4263
+ return { reach: filterReach(filters), apply: (data, width, height, linear) => runLayerFiltersFloat(data, width, height, filters, linear) };
4264
+ }
4265
+ }, depth);
4266
+ return deep.composite(resolveVectorMasks(layers, sources.width, sources.height), rect, sources);
4123
4267
  }
4124
4268
 
4125
4269
  // src/image-editor/layers/text.ts
@@ -4186,7 +4330,7 @@ function textOutlines(layer, shaper) {
4186
4330
  }
4187
4331
  var rgbOf = (hex) => {
4188
4332
  const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, hex);
4189
- const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _66 => _66.hex]), () => ( "#000000"))).slice(1);
4333
+ const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _70 => _70.hex]), () => ( "#000000"))).slice(1);
4190
4334
  return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
4191
4335
  };
4192
4336
  function renderOutlines(layer, shaper, region) {
@@ -4402,7 +4546,7 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
4402
4546
  surface: _chunkCWM3CUUXcjs.emptySurface.call(void 0, 4),
4403
4547
  offset: { x: 0, y: 0 }
4404
4548
  };
4405
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _67 => _67.runs, 'access', _68 => _68[0], 'optionalAccess', _69 => _69.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)) }];
4549
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _71 => _71.runs, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)) }];
4406
4550
  if (init.transform && !_chunkEGZM52EOcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4407
4551
  if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
4408
4552
  return rerenderText(layer, env);
@@ -4413,7 +4557,7 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
4413
4557
  const patch = change(current);
4414
4558
  const next = { ...current, ...patch };
4415
4559
  if (!("annotation" in patch)) delete next.annotation;
4416
- if ("text" in patch || "runs" in patch) next.runs = _chunkEGZM52EOcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _70 => _70.runs, 'access', _71 => _71[0], 'optionalAccess', _72 => _72.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)));
4560
+ if ("text" in patch || "runs" in patch) next.runs = _chunkEGZM52EOcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _74 => _74.runs, 'access', _75 => _75[0], 'optionalAccess', _76 => _76.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)));
4417
4561
  if (!next.runs.length) next.runs = [{ length: 0, style: _chunkEGZM52EOcjs.styleAt.call(void 0, current.runs, 0, _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE) }];
4418
4562
  if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkEGZM52EOcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
4419
4563
  const rendered = rerenderText(next, env);
@@ -4700,7 +4844,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4700
4844
  const { layers } = stack;
4701
4845
  const target = developTarget(layers, activeLayerId);
4702
4846
  const develop = target ? developFilter(target) : void 0;
4703
- const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _73 => _73(target), 'optionalAccess', _74 => _74.radius]) : void 0))), () => ( 0));
4847
+ const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _77 => _77(target), 'optionalAccess', _78 => _78.radius]) : void 0))), () => ( 0));
4704
4848
  const adjustments = {
4705
4849
  ...DEFAULT_ADJUSTMENTS_VALUES,
4706
4850
  ...develop ? {
@@ -4729,7 +4873,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4729
4873
  };
4730
4874
  walk(layers);
4731
4875
  if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
4732
- const depthSource = _optionalChain([target, 'optionalAccess', _75 => _75.mask, 'optionalAccess', _76 => _76.source]);
4876
+ const depthSource = _optionalChain([target, 'optionalAccess', _79 => _79.mask, 'optionalAccess', _80 => _80.source]);
4733
4877
  const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
4734
4878
  return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
4735
4879
  }
@@ -4754,7 +4898,7 @@ function isLegacyShape(stack) {
4754
4898
  let adjustments = 0;
4755
4899
  for (; i < layers.length && layers[i].type === "adjustment"; i++) {
4756
4900
  const l = layers[i];
4757
- if (l.clipped || l.locks || _optionalChain([l, 'access', _77 => _77.mask, 'optionalAccess', _78 => _78.source]) || l.effects) return false;
4901
+ if (l.clipped || l.locks || _optionalChain([l, 'access', _81 => _81.mask, 'optionalAccess', _82 => _82.source]) || l.effects) return false;
4758
4902
  adjustments++;
4759
4903
  }
4760
4904
  for (; i < layers.length; i++) {
@@ -4961,7 +5105,7 @@ function isContentsDecoded(contents) {
4961
5105
  }
4962
5106
  function requireDecoded(layer, action) {
4963
5107
  if (isContentsDecoded(layer.contents)) return;
4964
- const what = _optionalChain([layer, 'access', _79 => _79.contents, 'access', _80 => _80.file, 'optionalAccess', _81 => _81.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
5108
+ const what = _optionalChain([layer, 'access', _83 => _83.contents, 'access', _84 => _84.file, 'optionalAccess', _85 => _85.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4965
5109
  fail4(
4966
5110
  `The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
4967
5111
  );
@@ -4986,7 +5130,7 @@ function contentsSurface(contents) {
4986
5130
  width: W,
4987
5131
  height: H,
4988
5132
  globalLight: doc.globalLight,
4989
- pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _82 => _82.patterns, 'optionalAccess', _83 => _83.find, 'call', _84 => _84((p) => p.id === id)]), () => ( null))
5133
+ pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _86 => _86.patterns, 'optionalAccess', _87 => _87.find, 'call', _88 => _88((p) => p.id === id)]), () => ( null))
4990
5134
  });
4991
5135
  s = _chunkCWM3CUUXcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
4992
5136
  }
@@ -5021,7 +5165,7 @@ function placeContents(layer, canvas, options = {}) {
5021
5165
  const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
5022
5166
  const key = placementKey(placement, canvas);
5023
5167
  if (!preview) {
5024
- const hit = _optionalChain([placedCache, 'access', _85 => _85.get, 'call', _86 => _86(contents), 'optionalAccess', _87 => _87.get, 'call', _88 => _88(key)]);
5168
+ const hit = _optionalChain([placedCache, 'access', _89 => _89.get, 'call', _90 => _90(contents), 'optionalAccess', _91 => _91.get, 'call', _92 => _92(key)]);
5025
5169
  if (hit) return hit;
5026
5170
  }
5027
5171
  const src = contentsSurface(contents);
@@ -5048,10 +5192,10 @@ function placeContents(layer, canvas, options = {}) {
5048
5192
  let k = 1;
5049
5193
  if (step > 1) {
5050
5194
  k = step;
5051
- let r = _optionalChain([options, 'access', _89 => _89.reduced, 'optionalAccess', _90 => _90.get, 'call', _91 => _91(k)]);
5195
+ let r = _optionalChain([options, 'access', _93 => _93.reduced, 'optionalAccess', _94 => _94.get, 'call', _95 => _95(k)]);
5052
5196
  if (!r) {
5053
5197
  r = _chunkHGTDMKNEcjs.reduceSurface.call(void 0, src, k);
5054
- _optionalChain([options, 'access', _92 => _92.reduced, 'optionalAccess', _93 => _93.set, 'call', _94 => _94(k, r)]);
5198
+ _optionalChain([options, 'access', _96 => _96.reduced, 'optionalAccess', _97 => _97.set, 'call', _98 => _98(k, r)]);
5055
5199
  }
5056
5200
  source = r;
5057
5201
  }
@@ -5084,15 +5228,15 @@ function placeContents(layer, canvas, options = {}) {
5084
5228
  return out;
5085
5229
  }
5086
5230
  function activeSmartFilters(stack) {
5087
- if (!_optionalChain([stack, 'optionalAccess', _95 => _95.enabled])) return [];
5231
+ if (!_optionalChain([stack, 'optionalAccess', _99 => _99.enabled])) return [];
5088
5232
  return stack.filters.filter((f) => f.kind !== "psd" && f.kind !== "effect" && isActiveFilter(f) && f.opacity > 0);
5089
5233
  }
5090
5234
  function activeEffectSmartFilters(stack) {
5091
- if (!_optionalChain([stack, 'optionalAccess', _96 => _96.enabled])) return [];
5235
+ if (!_optionalChain([stack, 'optionalAccess', _100 => _100.enabled])) return [];
5092
5236
  return stack.filters.filter((f) => f.kind === "effect" && f.enabled && f.opacity > 0);
5093
5237
  }
5094
5238
  function runnableSmartFilters(stack) {
5095
- if (!_optionalChain([stack, 'optionalAccess', _97 => _97.enabled])) return [];
5239
+ if (!_optionalChain([stack, 'optionalAccess', _101 => _101.enabled])) return [];
5096
5240
  return stack.filters.filter((f) => f.opacity > 0 && (f.kind === "effect" ? f.enabled : f.kind !== "psd" && isActiveFilter(f)));
5097
5241
  }
5098
5242
  function filterMaskCoverage(mask, canvas) {
@@ -5118,7 +5262,7 @@ function applySmartFilters(placed, stack, canvas) {
5118
5262
  if (!active.length || !(canvas.width > 0 && canvas.height > 0)) return placed;
5119
5263
  const W = canvas.width;
5120
5264
  const H = canvas.height;
5121
- const token = active.some((f) => f.kind === "effect") ? _nullishCoalesce(_optionalChain([canvas, 'access', _98 => _98.effects, 'optionalAccess', _99 => _99.token]), () => ( -1)) : 0;
5265
+ const token = active.some((f) => f.kind === "effect") ? _nullishCoalesce(_optionalChain([canvas, 'access', _102 => _102.effects, 'optionalAccess', _103 => _103.token]), () => ( -1)) : 0;
5122
5266
  const key = JSON.stringify([W, H, token, active.map((f) => ({ ...f, id: void 0 }))]);
5123
5267
  let entry = filteredCache.get(placed);
5124
5268
  let incomplete = false;
@@ -5130,9 +5274,9 @@ function applySmartFilters(placed, stack, canvas) {
5130
5274
  if (f.kind === "effect") {
5131
5275
  if (incomplete) continue;
5132
5276
  const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => ({ ...x, id: void 0, blend: x === f ? void 0 : x.blend, opacity: x === f ? void 0 : x.opacity }))]);
5133
- const r = _optionalChain([canvas, 'access', _100 => _100.effects, 'optionalAccess', _101 => _101.resolve, 'call', _102 => _102(f, acc, W, H, inputKey)]);
5134
- if (!_optionalChain([r, 'optionalAccess', _103 => _103.result])) {
5135
- if (_optionalChain([r, 'optionalAccess', _104 => _104.pending])) incomplete = true;
5277
+ const r = _optionalChain([canvas, 'access', _104 => _104.effects, 'optionalAccess', _105 => _105.resolve, 'call', _106 => _106(f, acc, W, H, inputKey)]);
5278
+ if (!_optionalChain([r, 'optionalAccess', _107 => _107.result])) {
5279
+ if (_optionalChain([r, 'optionalAccess', _108 => _108.pending])) incomplete = true;
5136
5280
  continue;
5137
5281
  }
5138
5282
  out2 = new Uint8ClampedArray(r.result);
@@ -5183,7 +5327,7 @@ function rerender(layer, canvas, action = "change") {
5183
5327
  return { ...layer, surface: renderSmartObject(layer, canvas) };
5184
5328
  }
5185
5329
  function normalizePlacement(raw, contents) {
5186
- const c = _optionalChain([raw, 'optionalAccess', _105 => _105.corners]);
5330
+ const c = _optionalChain([raw, 'optionalAccess', _109 => _109.corners]);
5187
5331
  if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
5188
5332
  fail4("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
5189
5333
  }
@@ -5228,7 +5372,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
5228
5372
  masksMoved ||= m !== layer.mask;
5229
5373
  next.mask = m;
5230
5374
  }
5231
- if (_optionalChain([next, 'access', _106 => _106.smartFilters, 'optionalAccess', _107 => _107.mask])) {
5375
+ if (_optionalChain([next, 'access', _110 => _110.smartFilters, 'optionalAccess', _111 => _111.mask])) {
5232
5376
  const m = followMask(next.smartFilters.mask, layer, next);
5233
5377
  masksMoved ||= m !== next.smartFilters.mask;
5234
5378
  next.smartFilters = { ...next.smartFilters, mask: m };
@@ -5246,12 +5390,13 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
5246
5390
  let next = { ...layer, placement: { ...layer.placement, corners } };
5247
5391
  const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
5248
5392
  if (layer.mask) next.mask = moveMask(layer.mask);
5249
- if (_optionalChain([layer, 'access', _108 => _108.smartFilters, 'optionalAccess', _109 => _109.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5393
+ if (_optionalChain([layer, 'access', _112 => _112.smartFilters, 'optionalAccess', _113 => _113.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5394
+ next = followLayerMove(next, mx, my);
5250
5395
  const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur") || activeEffectSmartFilters(layer.smartFilters).length > 0;
5251
5396
  const b = _chunkCWM3CUUXcjs.contentBounds.call(void 0, layer.surface);
5252
5397
  const m = SMART_RENDER_MARGIN;
5253
5398
  const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
5254
- if (!spatial && !cut && !(_optionalChain([next, 'access', _110 => _110.smartFilters, 'optionalAccess', _111 => _111.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5399
+ if (!spatial && !cut && !(_optionalChain([next, 'access', _114 => _114.smartFilters, 'optionalAccess', _115 => _115.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5255
5400
  next = { ...next, surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, layer.surface, mx, my) };
5256
5401
  } else {
5257
5402
  next = rerender(next, canvas, "move");
@@ -5276,7 +5421,7 @@ function translateLayer(layer, dx, dy) {
5276
5421
  mask: moveMask(layer.mask)
5277
5422
  };
5278
5423
  if (!next.mask) delete next.mask;
5279
- if (_optionalChain([layer, 'access', _112 => _112.smartFilters, 'optionalAccess', _113 => _113.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5424
+ if (_optionalChain([layer, 'access', _116 => _116.smartFilters, 'optionalAccess', _117 => _117.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5280
5425
  return next;
5281
5426
  }
5282
5427
  case "group": {
@@ -5336,14 +5481,14 @@ function union(a, b) {
5336
5481
  return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
5337
5482
  }
5338
5483
  function asSmartFilters(filters) {
5339
- if (!_optionalChain([filters, 'optionalAccess', _114 => _114.length])) return void 0;
5484
+ if (!_optionalChain([filters, 'optionalAccess', _118 => _118.length])) return void 0;
5340
5485
  return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
5341
5486
  }
5342
5487
  function convertToSmartObject(layers, ids, canvas, options) {
5343
5488
  if (!ids.length) fail4("Give at least one layer id to convert.");
5344
5489
  const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
5345
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _115 => _115[0], 'access', _116 => _116.parent, 'optionalAccess', _117 => _117.id]), () => ( null));
5346
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _118 => _118.parent, 'optionalAccess', _119 => _119.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
5490
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _119 => _119[0], 'access', _120 => _120.parent, 'optionalAccess', _121 => _121.id]), () => ( null));
5491
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _122 => _122.parent, 'optionalAccess', _123 => _123.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
5347
5492
  for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
5348
5493
  const ordered = locs.sort((a, b) => a.index - b.index);
5349
5494
  const top = ordered[ordered.length - 1];
@@ -5389,9 +5534,9 @@ function convertToSmartObject(layers, ids, canvas, options) {
5389
5534
  const nested = ordered.map((l) => {
5390
5535
  let layer = l.layer;
5391
5536
  if (layer.type === "pixel" && layer.source === "document") {
5392
- const resolved = { ...layer, surface: options.surfaceOf(layer) };
5393
- delete resolved.source;
5394
- layer = resolved;
5537
+ const resolved2 = { ...layer, surface: options.surfaceOf(layer) };
5538
+ delete resolved2.source;
5539
+ layer = resolved2;
5395
5540
  }
5396
5541
  if (_chunkHGTDMKNEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5397
5542
  return translateLayer(layer, -b.x, -b.y);
@@ -5401,7 +5546,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5401
5546
  delete first.clipped;
5402
5547
  nested[0] = first;
5403
5548
  }
5404
- const name = _optionalChain([options, 'access', _120 => _120.name, 'optionalAccess', _121 => _121.trim, 'call', _122 => _122()]) || top.layer.name || "Smart Object";
5549
+ const name = _optionalChain([options, 'access', _124 => _124.name, 'optionalAccess', _125 => _125.trim, 'call', _126 => _126()]) || top.layer.name || "Smart Object";
5405
5550
  const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
5406
5551
  smart = {
5407
5552
  type: "smart",
@@ -5416,7 +5561,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5416
5561
  offset: { x: 0, y: 0 }
5417
5562
  };
5418
5563
  }
5419
- if (_optionalChain([options, 'access', _123 => _123.name, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()])) smart.name = options.name.trim();
5564
+ if (_optionalChain([options, 'access', _127 => _127.name, 'optionalAccess', _128 => _128.trim, 'call', _129 => _129()])) smart.name = options.name.trim();
5420
5565
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
5421
5566
  const below = ordered.filter((l) => l.index < top.index).length;
5422
5567
  let out = layers;
@@ -5446,12 +5591,12 @@ function rasterizeSmartObject(layers, id) {
5446
5591
  function copySmartObject(layers, id, linked, name) {
5447
5592
  const loc = requireLayer(layers, id);
5448
5593
  const layer = requireSmartObject(layers, id);
5449
- const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _126 => _126.trim, 'call', _127 => _127()]) || `${layer.name || "Smart Object"} copy` };
5594
+ const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _130 => _130.trim, 'call', _131 => _131()]) || `${layer.name || "Smart Object"} copy` };
5450
5595
  delete copy.locks;
5451
5596
  delete copy.psd;
5452
5597
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
5453
5598
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
5454
- return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _128 => _128.parent, 'optionalAccess', _129 => _129.id]), () => ( null)), loc.index + 1), layer: copy };
5599
+ return { layers: _chunkHGTDMKNEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _132 => _132.parent, 'optionalAccess', _133 => _133.id]), () => ( null)), loc.index + 1), layer: copy };
5455
5600
  }
5456
5601
  function instancesOf(layers, contentsId) {
5457
5602
  return _chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
@@ -5523,7 +5668,7 @@ function stackOf(layer) {
5523
5668
  return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
5524
5669
  }
5525
5670
  function requireFilter(layer, filterId) {
5526
- const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _130 => _130.smartFilters, 'optionalAccess', _131 => _131.filters]), () => ( []));
5671
+ const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _134 => _134.smartFilters, 'optionalAccess', _135 => _135.filters]), () => ( []));
5527
5672
  const i = list2.findIndex((f) => f.id === filterId);
5528
5673
  if (i === -1) fail4(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
5529
5674
  return i;
@@ -5590,7 +5735,7 @@ function setSmartFiltersEnabled(layers, id, enabled, canvas) {
5590
5735
  }
5591
5736
  function setSmartFilterMask(layers, id, mask, canvas) {
5592
5737
  const layer = editableSmart(layers, id);
5593
- if (_optionalChain([mask, 'optionalAccess', _132 => _132.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5738
+ if (_optionalChain([mask, 'optionalAccess', _136 => _136.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5594
5739
  const stack = { ...stackOf(layer) };
5595
5740
  if (mask) stack.mask = mask;
5596
5741
  else delete stack.mask;
@@ -5683,6 +5828,7 @@ function baseFields(layer, ctx) {
5683
5828
  };
5684
5829
  if (layer.clipped) out.clipped = true;
5685
5830
  if (layer.mask) out.mask = serializeMask(layer.mask, `${layer.id}-mask`, ctx);
5831
+ if (layer.vectorMask) out.vectorMask = serializeVectorMask(layer.vectorMask);
5686
5832
  if (layer.locks && Object.values(layer.locks).some(Boolean)) out.locks = { ...layer.locks };
5687
5833
  if (layer.effects) out.effects = serializeEffects(layer.effects);
5688
5834
  return out;
@@ -5707,6 +5853,36 @@ function deserializeEffects(raw) {
5707
5853
  }
5708
5854
  return _chunkHGTDMKNEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5709
5855
  }
5856
+ function serializeVectorMask(vm) {
5857
+ const out = { components: JSON.parse(JSON.stringify(vm.components)) };
5858
+ if (vm.fillRule === "evenodd") out.fillRule = "evenodd";
5859
+ if (vm.inverted) out.inverted = true;
5860
+ if (vm.enabled === false) out.enabled = false;
5861
+ if (vm.linked === false) out.linked = false;
5862
+ if (vm.density !== void 0 && vm.density !== 1) out.density = vm.density;
5863
+ if (vm.feather) out.feather = vm.feather;
5864
+ return out;
5865
+ }
5866
+ function readVectorMask(r) {
5867
+ if (!Array.isArray(r.components)) throw new Error("its components are missing");
5868
+ const components = r.components.map((raw, i) => {
5869
+ const c = raw;
5870
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _137 => _137.op]), `components[${i}].op`);
5871
+ if (_optionalChain([c, 'optionalAccess', _138 => _138.live])) {
5872
+ const live = normalizeLiveShape(c.live, `components[${i}].live`);
5873
+ return { op, subpaths: liveShapeSubpaths(live), live };
5874
+ }
5875
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _139 => _139.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _140 => _140.subpaths]), `components[${i}].subpaths`) };
5876
+ });
5877
+ const vm = { components };
5878
+ if (r.fillRule === "evenodd") vm.fillRule = "evenodd";
5879
+ if (r.inverted === true) vm.inverted = true;
5880
+ if (r.enabled === false) vm.enabled = false;
5881
+ if (r.linked === false) vm.linked = false;
5882
+ if (typeof r.density === "number" && r.density !== 1) vm.density = num2(r.density, 0, 1, 1);
5883
+ if (typeof r.feather === "number" && r.feather > 0) vm.feather = num2(r.feather, 0, 1e3, 0);
5884
+ return vm;
5885
+ }
5710
5886
  function serializeMask(mask, hint, ctx) {
5711
5887
  const out = { defaultValue: mask.defaultValue };
5712
5888
  if (!mask.source) {
@@ -5742,7 +5918,7 @@ function serializeLayer(layer, ctx) {
5742
5918
  }
5743
5919
  }
5744
5920
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5745
- if (_optionalChain([layer, 'access', _133 => _133.filters, 'optionalAccess', _134 => _134.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5921
+ if (_optionalChain([layer, 'access', _141 => _141.filters, 'optionalAccess', _142 => _142.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5746
5922
  if (layer.generator) out.generator = JSON.parse(JSON.stringify(layer.generator));
5747
5923
  if (layer.source !== "document") {
5748
5924
  const deep = encodeDeepSurface(layer.surface);
@@ -5785,12 +5961,12 @@ function serializeType(layer, base, ctx) {
5785
5961
  out.x = enc.x;
5786
5962
  out.y = enc.y;
5787
5963
  }
5788
- if (_optionalChain([layer, 'access', _135 => _135.missingFonts, 'optionalAccess', _136 => _136.length])) out.missingFonts = [...layer.missingFonts];
5964
+ if (_optionalChain([layer, 'access', _143 => _143.missingFonts, 'optionalAccess', _144 => _144.length])) out.missingFonts = [...layer.missingFonts];
5789
5965
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5790
- if (_optionalChain([layer, 'access', _137 => _137.psd, 'optionalAccess', _138 => _138.tySh]) || _optionalChain([layer, 'access', _139 => _139.psd, 'optionalAccess', _140 => _140.blocks, 'optionalAccess', _141 => _141.length])) {
5966
+ if (_optionalChain([layer, 'access', _145 => _145.psd, 'optionalAccess', _146 => _146.tySh]) || _optionalChain([layer, 'access', _147 => _147.psd, 'optionalAccess', _148 => _148.blocks, 'optionalAccess', _149 => _149.length])) {
5791
5967
  out.psd = {};
5792
5968
  if (layer.psd.tySh) out.psd.tySh = _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5793
- if (_optionalChain([layer, 'access', _142 => _142.psd, 'access', _143 => _143.blocks, 'optionalAccess', _144 => _144.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, b.data) }));
5969
+ if (_optionalChain([layer, 'access', _150 => _150.psd, 'access', _151 => _151.blocks, 'optionalAccess', _152 => _152.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, b.data) }));
5794
5970
  if (layer.psd.signature) out.psd.signature = layer.psd.signature;
5795
5971
  }
5796
5972
  return out;
@@ -5800,15 +5976,15 @@ function readType(r, base, ctx) {
5800
5976
  try {
5801
5977
  const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
5802
5978
  const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
5803
- length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _145 => _145.length]), 0, 1e9, 0))),
5804
- style: patchTextStyle(_chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _146 => _146.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5979
+ length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _153 => _153.length]), 0, 1e9, 0))),
5980
+ style: patchTextStyle(_chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _154 => _154.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5805
5981
  }));
5806
5982
  const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
5807
- length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _147 => _147.length]), 0, 1e9, 0))),
5808
- style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _148 => _148.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5983
+ length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _155 => _155.length]), 0, 1e9, 0))),
5984
+ style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _156 => _156.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5809
5985
  }));
5810
5986
  const f = r.frame;
5811
- const frame = _optionalChain([f, 'optionalAccess', _149 => _149.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _150 => _150.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5987
+ const frame = _optionalChain([f, 'optionalAccess', _157 => _157.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _158 => _158.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5812
5988
  const m = Array.isArray(r.transform) && r.transform.length === 6 && r.transform.every((v) => typeof v === "number" && Number.isFinite(v)) ? r.transform : void 0;
5813
5989
  const layer = {
5814
5990
  ...base,
@@ -5820,7 +5996,7 @@ function readType(r, base, ctx) {
5820
5996
  surface: _chunkCWM3CUUXcjs.emptySurface.call(void 0, 4),
5821
5997
  offset: { x: 0, y: 0 }
5822
5998
  };
5823
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _151 => _151[0], 'optionalAccess', _152 => _152.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)) }];
5999
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _159 => _159[0], 'optionalAccess', _160 => _160.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)) }];
5824
6000
  if (m) layer.transform = m;
5825
6001
  if (r.antiAlias === false) layer.antiAlias = false;
5826
6002
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
@@ -5831,10 +6007,10 @@ function readType(r, base, ctx) {
5831
6007
  if (typeof r.psd.tySh === "string") psd.tySh = _chunkCWM3CUUXcjs.base64ToBytes.call(void 0, r.psd.tySh);
5832
6008
  if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkCWM3CUUXcjs.base64ToBytes.call(void 0, b.data) }));
5833
6009
  if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
5834
- if (psd.tySh || _optionalChain([psd, 'access', _153 => _153.blocks, 'optionalAccess', _154 => _154.length])) layer.psd = psd;
6010
+ if (psd.tySh || _optionalChain([psd, 'access', _161 => _161.blocks, 'optionalAccess', _162 => _162.length])) layer.psd = psd;
5835
6011
  }
5836
6012
  if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
5837
- const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _155 => _155.text, 'optionalAccess', _156 => _156.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _157 => _157.text, 'optionalAccess', _158 => _158.createCanvas]) };
6013
+ const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _163 => _163.text, 'optionalAccess', _164 => _164.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _165 => _165.text, 'optionalAccess', _166 => _166.createCanvas]) };
5838
6014
  try {
5839
6015
  return rerenderText(layer, env);
5840
6016
  } catch (e8) {
@@ -5857,7 +6033,7 @@ function serializeShape(layer, base) {
5857
6033
  if (layer.inverted) out.inverted = true;
5858
6034
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5859
6035
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5860
- if (_optionalChain([layer, 'access', _159 => _159.psd, 'optionalAccess', _160 => _160.blocks, 'optionalAccess', _161 => _161.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
6036
+ if (_optionalChain([layer, 'access', _167 => _167.psd, 'optionalAccess', _168 => _168.blocks, 'optionalAccess', _169 => _169.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5861
6037
  return out;
5862
6038
  }
5863
6039
  function readShape(r, base, ctx) {
@@ -5871,12 +6047,12 @@ function readShape(r, base, ctx) {
5871
6047
  if (!data) {
5872
6048
  if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
5873
6049
  const components = r.components.map((c, i) => {
5874
- const op = requireOperation(_optionalChain([c, 'optionalAccess', _162 => _162.op]), `components[${i}].op`);
5875
- if (_optionalChain([c, 'optionalAccess', _163 => _163.live])) {
6050
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _170 => _170.op]), `components[${i}].op`);
6051
+ if (_optionalChain([c, 'optionalAccess', _171 => _171.live])) {
5876
6052
  const live = normalizeLiveShape(c.live, `components[${i}].live`);
5877
6053
  return { op, subpaths: liveShapeSubpaths(live), live };
5878
6054
  }
5879
- return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _164 => _164.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _165 => _165.subpaths]), `components[${i}].subpaths`) };
6055
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _172 => _172.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _173 => _173.subpaths]), `components[${i}].subpaths`) };
5880
6056
  });
5881
6057
  data = {
5882
6058
  components,
@@ -5947,7 +6123,7 @@ function serializeContents(c, ctx) {
5947
6123
  if (c.kind === "document" && c.document) {
5948
6124
  out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
5949
6125
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
5950
- if (_optionalChain([c, 'access', _166 => _166.document, 'access', _167 => _167.patterns, 'optionalAccess', _168 => _168.length])) out.patterns = serializePatterns(c.document.patterns);
6126
+ if (_optionalChain([c, 'access', _174 => _174.document, 'access', _175 => _175.patterns, 'optionalAccess', _176 => _176.length])) out.patterns = serializePatterns(c.document.patterns);
5951
6127
  }
5952
6128
  if (c.file) out.file = { type: c.file.type, data: _chunkCWM3CUUXcjs.bytesToBase64.call(void 0, c.file.bytes) };
5953
6129
  if (c.linked) out.linked = { path: c.linked.path };
@@ -6114,6 +6290,13 @@ function deserializeLayer(raw, ctx) {
6114
6290
  if (r.clipped === true) base.clipped = true;
6115
6291
  const mask = readMask(r.mask, ctx, `Layer "${base.name || id}"`);
6116
6292
  if (mask) base.mask = mask;
6293
+ if (r.vectorMask && typeof r.vectorMask === "object" && r.type !== "shape") {
6294
+ try {
6295
+ base.vectorMask = readVectorMask(r.vectorMask);
6296
+ } catch (err) {
6297
+ ctx.problems.push(`The vector mask of layer "${base.name || id}" could not be read (${err instanceof Error ? err.message : String(err)}); it was left out.`);
6298
+ }
6299
+ }
6117
6300
  if (r.locks && typeof r.locks === "object") {
6118
6301
  const locks = {};
6119
6302
  for (const k of ["pixels", "transparency", "position", "all"]) if (r.locks[k] === true) locks[k] = true;
@@ -6127,7 +6310,7 @@ function deserializeLayer(raw, ctx) {
6127
6310
  ...base,
6128
6311
  type: "pixel",
6129
6312
  surface: r.source === "document" ? _chunkCWM3CUUXcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
6130
- offset: { x: Math.round(num2(_optionalChain([r, 'access', _169 => _169.offset, 'optionalAccess', _170 => _170.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _171 => _171.offset, 'optionalAccess', _172 => _172.y]), -1e7, 1e7, 0)) }
6313
+ offset: { x: Math.round(num2(_optionalChain([r, 'access', _177 => _177.offset, 'optionalAccess', _178 => _178.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _179 => _179.offset, 'optionalAccess', _180 => _180.y]), -1e7, 1e7, 0)) }
6131
6314
  };
6132
6315
  if (r.source === "document") layer.source = "document";
6133
6316
  else if (r.deep) layer.surface = decodeDeepSurface(layer.surface, r.deep, ctx.problems, `Layer "${base.name || id}"`);
@@ -6136,7 +6319,7 @@ function deserializeLayer(raw, ctx) {
6136
6319
  if (filters) layer.filters = filters;
6137
6320
  const generator = readEffectRef(r.generator);
6138
6321
  if (generator) {
6139
- const duration = _optionalChain([r, 'access', _173 => _173.generator, 'access', _174 => _174.animate, 'optionalAccess', _175 => _175.duration]);
6322
+ const duration = _optionalChain([r, 'access', _181 => _181.generator, 'access', _182 => _182.animate, 'optionalAccess', _183 => _183.duration]);
6140
6323
  layer.generator = {
6141
6324
  ...generator,
6142
6325
  ...typeof r.generator.time === "number" && r.generator.time > 0 ? { time: r.generator.time } : {},
@@ -6167,7 +6350,7 @@ function deserializeLayer(raw, ctx) {
6167
6350
  return null;
6168
6351
  }
6169
6352
  const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
6170
- const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _176 => _176.text, 'optionalAccess', _177 => _177.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _178 => _178.text, 'optionalAccess', _179 => _179.createCanvas]) });
6353
+ const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _184 => _184.text, 'optionalAccess', _185 => _185.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _186 => _186.text, 'optionalAccess', _187 => _187.createCanvas]) });
6171
6354
  if (migrated.type === "shape" || migrated.type === "type") {
6172
6355
  const blend = base.blend === "normal" ? migrated.blend : base.blend;
6173
6356
  return { ...migrated, ...base, blend, id, name: base.name };
@@ -6745,7 +6928,7 @@ function descriptor(classId, items = []) {
6745
6928
  return { name: "", classId, items };
6746
6929
  }
6747
6930
  function descGet(d, key) {
6748
- return _optionalChain([d, 'access', _180 => _180.items, 'access', _181 => _181.find, 'call', _182 => _182(([k]) => k === key), 'optionalAccess', _183 => _183[1]]);
6931
+ return _optionalChain([d, 'access', _188 => _188.items, 'access', _189 => _189.find, 'call', _190 => _190(([k]) => k === key), 'optionalAccess', _191 => _191[1]]);
6749
6932
  }
6750
6933
  function descNumber(d, key) {
6751
6934
  const v = descGet(d, key);
@@ -6755,7 +6938,7 @@ function descNumber(d, key) {
6755
6938
  }
6756
6939
  function descBool(d, key) {
6757
6940
  const v = descGet(d, key);
6758
- return _optionalChain([v, 'optionalAccess', _184 => _184.type]) === "bool" ? v.value : void 0;
6941
+ return _optionalChain([v, 'optionalAccess', _192 => _192.type]) === "bool" ? v.value : void 0;
6759
6942
  }
6760
6943
  function descObject(d, key) {
6761
6944
  const v = descGet(d, key);
@@ -7337,97 +7520,6 @@ function writeAdjustmentBlock(kind, params) {
7337
7520
  throw new Error(`Unknown adjustment kind "${kind}".`);
7338
7521
  }
7339
7522
 
7340
- // src/image-editor/psd/channels.ts
7341
- var hexToRgb2 = (hex) => {
7342
- const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _185 => _185.exec, 'call', _186 => _186(hex), 'optionalAccess', _187 => _187[1]]), () => ( "ff0000")), 16);
7343
- return [v >> 16 & 255, v >> 8 & 255, v & 255];
7344
- };
7345
- var rgbToHex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
7346
- function alphaChannelResources(channels) {
7347
- if (!channels.length) return [];
7348
- const names = new PsdWriter();
7349
- for (const c of channels) names.pascal(encodeLegacyName(c.name), 1);
7350
- const unicode = new PsdWriter();
7351
- for (const c of channels) unicode.unicode(c.name);
7352
- const display = new PsdWriter();
7353
- display.u32(1);
7354
- for (const c of channels) {
7355
- const [r, g, b] = hexToRgb2(c.color);
7356
- display.u16(0);
7357
- for (const v of [r, g, b, 0]) display.u16(v * 257);
7358
- display.u16(Math.round(Math.min(1, Math.max(0, c.opacity)) * 100));
7359
- display.u8(c.indicates === "selected" ? 0 : 1);
7360
- display.u8(0);
7361
- }
7362
- return [
7363
- { id: 1006, name: "", data: names.result() },
7364
- { id: 1045, name: "", data: unicode.result() },
7365
- { id: 1077, name: "", data: display.result() }
7366
- ];
7367
- }
7368
- function planeTo8(plane, n, depth) {
7369
- if (depth === 8) return plane.slice(0, n);
7370
- const out = new Uint8Array(n);
7371
- const view = new DataView(plane.buffer, plane.byteOffset, plane.byteLength);
7372
- for (let i = 0; i < n; i++) {
7373
- if (depth === 16) out[i] = plane[2 * i];
7374
- else out[i] = Math.round(Math.min(1, Math.max(0, view.getFloat32(4 * i, false))) * 255);
7375
- }
7376
- return out;
7377
- }
7378
- function readAlphaChannels(planes, header, first, resource2, warn) {
7379
- const count = header.channels - first;
7380
- if (count <= 0 || header.depth === 1) return [];
7381
- const size = rowBytes(header.width, header.depth) * header.height;
7382
- const n = header.width * header.height;
7383
- const names = [];
7384
- const unicode = resource2(1045);
7385
- if (unicode) {
7386
- const r = new PsdReader(unicode);
7387
- while (r.remaining >= 4 && names.length < count) names.push(r.unicode().replace(/\0+$/, ""));
7388
- } else {
7389
- const legacy = resource2(1006);
7390
- if (legacy) {
7391
- const r = new PsdReader(legacy);
7392
- while (r.remaining >= 1 && names.length < count) names.push(new TextDecoder("latin1").decode(r.pascal(1)));
7393
- }
7394
- }
7395
- const display = [];
7396
- const info = resource2(1077);
7397
- if (info && info.length >= 4) {
7398
- const r = new PsdReader(info);
7399
- r.u32();
7400
- while (r.remaining >= 14 && display.length < count) {
7401
- r.u16();
7402
- const [cr, cg, cb] = [r.u16(), r.u16(), r.u16()];
7403
- r.u16();
7404
- const opacity = r.u16();
7405
- const kind = r.u8();
7406
- r.u8();
7407
- display.push({ color: rgbToHex(cr >> 8, cg >> 8, cb >> 8), opacity: Math.min(100, opacity) / 100, kind });
7408
- }
7409
- }
7410
- const out = [];
7411
- for (let i = 0; i < count; i++) {
7412
- const start = (first + i) * size;
7413
- if (start + size > planes.length) break;
7414
- const d = display[i];
7415
- const name = names[i] || `Alpha ${i + 1}`;
7416
- if (_optionalChain([d, 'optionalAccess', _188 => _188.kind]) === 2) {
7417
- warn(`Spot colour channel "${name}" is not supported and was left out.`);
7418
- continue;
7419
- }
7420
- out.push({
7421
- name,
7422
- data: planeTo8(planes.subarray(start, start + size), n, header.depth),
7423
- color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _189 => _189.color]), () => ( "#ff0000")),
7424
- opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _190 => _190.opacity]), () => ( 0.5)),
7425
- indicates: _optionalChain([d, 'optionalAccess', _191 => _191.kind]) === 0 ? "selected" : "masked"
7426
- });
7427
- }
7428
- return out;
7429
- }
7430
-
7431
7523
  // src/image-editor/psd/paths.ts
7432
7524
  var RECORD = 26;
7433
7525
  var fixed = (v) => v / 16777216;
@@ -7487,6 +7579,8 @@ function writePathRecords(path) {
7487
7579
  return w.result();
7488
7580
  }
7489
7581
  var VMSK_INVERT = 1;
7582
+ var VMSK_NOT_LINKED = 2;
7583
+ var VMSK_DISABLED = 4;
7490
7584
  function readVectorBlock(data) {
7491
7585
  if (data.length < 8) return null;
7492
7586
  const r = new PsdReader(data);
@@ -7557,6 +7651,97 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
7557
7651
  return writeVectorBlock({ subpaths, initialFill: subpaths.length === 0 && inverted }, flags & ~VMSK_INVERT | (inverted && subpaths.length ? VMSK_INVERT : 0));
7558
7652
  }
7559
7653
 
7654
+ // src/image-editor/psd/channels.ts
7655
+ var hexToRgb2 = (hex) => {
7656
+ const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _193 => _193.exec, 'call', _194 => _194(hex), 'optionalAccess', _195 => _195[1]]), () => ( "ff0000")), 16);
7657
+ return [v >> 16 & 255, v >> 8 & 255, v & 255];
7658
+ };
7659
+ var rgbToHex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
7660
+ function alphaChannelResources(channels) {
7661
+ if (!channels.length) return [];
7662
+ const names = new PsdWriter();
7663
+ for (const c of channels) names.pascal(encodeLegacyName(c.name), 1);
7664
+ const unicode = new PsdWriter();
7665
+ for (const c of channels) unicode.unicode(c.name);
7666
+ const display = new PsdWriter();
7667
+ display.u32(1);
7668
+ for (const c of channels) {
7669
+ const [r, g, b] = hexToRgb2(c.color);
7670
+ display.u16(0);
7671
+ for (const v of [r, g, b, 0]) display.u16(v * 257);
7672
+ display.u16(Math.round(Math.min(1, Math.max(0, c.opacity)) * 100));
7673
+ display.u8(c.indicates === "selected" ? 0 : 1);
7674
+ display.u8(0);
7675
+ }
7676
+ return [
7677
+ { id: 1006, name: "", data: names.result() },
7678
+ { id: 1045, name: "", data: unicode.result() },
7679
+ { id: 1077, name: "", data: display.result() }
7680
+ ];
7681
+ }
7682
+ function planeTo8(plane, n, depth) {
7683
+ if (depth === 8) return plane.slice(0, n);
7684
+ const out = new Uint8Array(n);
7685
+ const view = new DataView(plane.buffer, plane.byteOffset, plane.byteLength);
7686
+ for (let i = 0; i < n; i++) {
7687
+ if (depth === 16) out[i] = plane[2 * i];
7688
+ else out[i] = Math.round(Math.min(1, Math.max(0, view.getFloat32(4 * i, false))) * 255);
7689
+ }
7690
+ return out;
7691
+ }
7692
+ function readAlphaChannels(planes, header, first, resource2, warn) {
7693
+ const count = header.channels - first;
7694
+ if (count <= 0 || header.depth === 1) return [];
7695
+ const size = rowBytes(header.width, header.depth) * header.height;
7696
+ const n = header.width * header.height;
7697
+ const names = [];
7698
+ const unicode = resource2(1045);
7699
+ if (unicode) {
7700
+ const r = new PsdReader(unicode);
7701
+ while (r.remaining >= 4 && names.length < count) names.push(r.unicode().replace(/\0+$/, ""));
7702
+ } else {
7703
+ const legacy = resource2(1006);
7704
+ if (legacy) {
7705
+ const r = new PsdReader(legacy);
7706
+ while (r.remaining >= 1 && names.length < count) names.push(new TextDecoder("latin1").decode(r.pascal(1)));
7707
+ }
7708
+ }
7709
+ const display = [];
7710
+ const info = resource2(1077);
7711
+ if (info && info.length >= 4) {
7712
+ const r = new PsdReader(info);
7713
+ r.u32();
7714
+ while (r.remaining >= 14 && display.length < count) {
7715
+ r.u16();
7716
+ const [cr, cg, cb] = [r.u16(), r.u16(), r.u16()];
7717
+ r.u16();
7718
+ const opacity = r.u16();
7719
+ const kind = r.u8();
7720
+ r.u8();
7721
+ display.push({ color: rgbToHex(cr >> 8, cg >> 8, cb >> 8), opacity: Math.min(100, opacity) / 100, kind });
7722
+ }
7723
+ }
7724
+ const out = [];
7725
+ for (let i = 0; i < count; i++) {
7726
+ const start = (first + i) * size;
7727
+ if (start + size > planes.length) break;
7728
+ const d = display[i];
7729
+ const name = names[i] || `Alpha ${i + 1}`;
7730
+ if (_optionalChain([d, 'optionalAccess', _196 => _196.kind]) === 2) {
7731
+ warn(`Spot colour channel "${name}" is not supported and was left out.`);
7732
+ continue;
7733
+ }
7734
+ out.push({
7735
+ name,
7736
+ data: planeTo8(planes.subarray(start, start + size), n, header.depth),
7737
+ color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _197 => _197.color]), () => ( "#ff0000")),
7738
+ opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _198 => _198.opacity]), () => ( 0.5)),
7739
+ indicates: _optionalChain([d, 'optionalAccess', _199 => _199.kind]) === 0 ? "selected" : "masked"
7740
+ });
7741
+ }
7742
+ return out;
7743
+ }
7744
+
7560
7745
  // src/image-editor/psd/shapes.ts
7561
7746
  var SHAPE_PSD_KEYS = ["vsms", "vmsk", "vscg", "vstk", "vogk", "SoCo", "GdFl", "PtFl"];
7562
7747
  var unit = (u, value) => ({ type: "UntF", unit: u, value });
@@ -7567,7 +7752,7 @@ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
7567
7752
  var obj = (d) => ({ type: "Objc", value: d });
7568
7753
  var enumOf = (d, key) => {
7569
7754
  const v = descGet(d, key);
7570
- return _optionalChain([v, 'optionalAccess', _192 => _192.type]) === "enum" ? v.value : void 0;
7755
+ return _optionalChain([v, 'optionalAccess', _200 => _200.type]) === "enum" ? v.value : void 0;
7571
7756
  };
7572
7757
  function read(data) {
7573
7758
  try {
@@ -7649,7 +7834,7 @@ function strokeFromVstk(data, dpi, notes) {
7649
7834
  const miter = descNumber(d, "strokeStyleMiterLimit");
7650
7835
  if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
7651
7836
  const dashes = descGet(d, "strokeStyleLineDashSet");
7652
- if (_optionalChain([dashes, 'optionalAccess', _193 => _193.type]) === "VlLs") {
7837
+ if (_optionalChain([dashes, 'optionalAccess', _201 => _201.type]) === "VlLs") {
7653
7838
  const list2 = dashes.items.map((v) => v.type === "UntF" || v.type === "doub" || v.type === "long" ? v.value : NaN).filter((v) => Number.isFinite(v) && v >= 0);
7654
7839
  if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
7655
7840
  }
@@ -7801,7 +7986,7 @@ function vogkBytes(components, dpi) {
7801
7986
  ["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
7802
7987
  ["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
7803
7988
  ["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
7804
- ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _194 => _194.concavity]) ? head.concavity * 100 : 0)]
7989
+ ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _202 => _202.concavity]) ? head.concavity * 100 : 0)]
7805
7990
  ];
7806
7991
  }
7807
7992
  const m = live.transform;
@@ -7834,7 +8019,7 @@ function shapeSignature(layer) {
7834
8019
  return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
7835
8020
  }
7836
8021
  function shapeFromBlocks(blocks, width, height, dpi, notes) {
7837
- const block = (k) => _optionalChain([blocks, 'access', _195 => _195.find, 'call', _196 => _196((b) => b.key === k), 'optionalAccess', _197 => _197.data]);
8022
+ const block = (k) => _optionalChain([blocks, 'access', _203 => _203.find, 'call', _204 => _204((b) => b.key === k), 'optionalAccess', _205 => _205.data]);
7838
8023
  const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
7839
8024
  const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
7840
8025
  if (!path) return null;
@@ -7889,18 +8074,18 @@ function sameExtent(sub, c) {
7889
8074
  return a.every((v, i) => Math.abs(v - b[i]) < 1);
7890
8075
  }
7891
8076
  function shapeBlocks(layer, width, height, dpi, notes) {
7892
- const kept = _optionalChain([layer, 'access', _198 => _198.psd, 'optionalAccess', _199 => _199.blocks]);
7893
- if (_optionalChain([kept, 'optionalAccess', _200 => _200.length]) && _optionalChain([layer, 'access', _201 => _201.psd, 'optionalAccess', _202 => _202.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
8077
+ const kept = _optionalChain([layer, 'access', _206 => _206.psd, 'optionalAccess', _207 => _207.blocks]);
8078
+ if (_optionalChain([kept, 'optionalAccess', _208 => _208.length]) && _optionalChain([layer, 'access', _209 => _209.psd, 'optionalAccess', _210 => _210.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
7894
8079
  const out = [];
7895
8080
  out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
7896
8081
  if (layer.fillRule === "evenodd" && layer.components.some((c) => c.subpaths.length > 1)) notes.add("Even-odd fill rules were written as nonzero (Photoshop fills shapes nonzero)");
7897
8082
  const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
7898
- if (_optionalChain([layer, 'access', _203 => _203.fill, 'optionalAccess', _204 => _204.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
8083
+ if (_optionalChain([layer, 'access', _211 => _211.fill, 'optionalAccess', _212 => _212.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
7899
8084
  out.push({ key: "vscg", data: vscgBytes(fill) });
7900
8085
  if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
7901
8086
  const vogk = vogkBytes(layer.components, dpi);
7902
8087
  if (vogk) out.push({ key: "vogk", data: vogk });
7903
- if (layer.components.some((c) => _optionalChain([c, 'access', _205 => _205.live, 'optionalAccess', _206 => _206.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
8088
+ if (layer.components.some((c) => _optionalChain([c, 'access', _213 => _213.live, 'optionalAccess', _214 => _214.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
7904
8089
  notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
7905
8090
  }
7906
8091
  return out;
@@ -8109,7 +8294,7 @@ var E = {
8109
8294
  bool: (value) => ({ t: "bool", value })
8110
8295
  };
8111
8296
  function eGet(v, key) {
8112
- return _optionalChain([v, 'optionalAccess', _207 => _207.t]) === "dict" ? _optionalChain([v, 'access', _208 => _208.items, 'access', _209 => _209.find, 'call', _210 => _210(([k]) => k === key), 'optionalAccess', _211 => _211[1]]) : void 0;
8297
+ return _optionalChain([v, 'optionalAccess', _215 => _215.t]) === "dict" ? _optionalChain([v, 'access', _216 => _216.items, 'access', _217 => _217.find, 'call', _218 => _218(([k]) => k === key), 'optionalAccess', _219 => _219[1]]) : void 0;
8113
8298
  }
8114
8299
  function ePath(v, keys) {
8115
8300
  return keys.reduce((at, k) => eGet(at, k), v);
@@ -8127,7 +8312,7 @@ function eStr(v) {
8127
8312
  return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
8128
8313
  }
8129
8314
  function eArray(v) {
8130
- return _optionalChain([v, 'optionalAccess', _212 => _212.t]) === "array" ? v.items : [];
8315
+ return _optionalChain([v, 'optionalAccess', _220 => _220.t]) === "array" ? v.items : [];
8131
8316
  }
8132
8317
  function eSet(d, key, value) {
8133
8318
  if (d.t !== "dict") return;
@@ -8229,7 +8414,7 @@ function fontFromPostScript(ps) {
8229
8414
  }
8230
8415
  family += suffix;
8231
8416
  const s = style.toLowerCase();
8232
- const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _213 => _213.find, 'call', _214 => _214(([re]) => re.test(s)), 'optionalAccess', _215 => _215[1]]), () => ( 400));
8417
+ const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _221 => _221.find, 'call', _222 => _222(([re]) => re.test(s)), 'optionalAccess', _223 => _223[1]]), () => ( 400));
8233
8418
  return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
8234
8419
  }
8235
8420
  var STYLE_NAMES = [
@@ -8254,7 +8439,7 @@ var hex2 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).pad
8254
8439
  function merged(levels) {
8255
8440
  const items = [];
8256
8441
  for (const l of levels) {
8257
- if (_optionalChain([l, 'optionalAccess', _216 => _216.t]) !== "dict") continue;
8442
+ if (_optionalChain([l, 'optionalAccess', _224 => _224.t]) !== "dict") continue;
8258
8443
  for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
8259
8444
  }
8260
8445
  return E.dict(items);
@@ -8325,10 +8510,10 @@ function typeFromTySh(data, notes) {
8325
8510
  const t = parseTySh(data);
8326
8511
  if (!t) return null;
8327
8512
  const txtV = descGet(t.text, "Txt ");
8328
- const txt = _optionalChain([txtV, 'optionalAccess', _217 => _217.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
8513
+ const txt = _optionalChain([txtV, 'optionalAccess', _225 => _225.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
8329
8514
  const ed = descGet(t.text, "EngineData");
8330
8515
  let engine = null;
8331
- if (_optionalChain([ed, 'optionalAccess', _218 => _218.type]) === "tdta") {
8516
+ if (_optionalChain([ed, 'optionalAccess', _226 => _226.type]) === "tdta") {
8332
8517
  try {
8333
8518
  engine = parseEngineData(ed.data);
8334
8519
  } catch (e18) {
@@ -8336,12 +8521,12 @@ function typeFromTySh(data, notes) {
8336
8521
  }
8337
8522
  }
8338
8523
  const anti = descGet(t.text, "AntA");
8339
- const antiAlias = !(_optionalChain([anti, 'optionalAccess', _219 => _219.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
8524
+ const antiAlias = !(_optionalChain([anti, 'optionalAccess', _227 => _227.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
8340
8525
  const ornt = descGet(t.text, "Ornt");
8341
- if (_optionalChain([ornt, 'optionalAccess', _220 => _220.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
8526
+ if (_optionalChain([ornt, 'optionalAccess', _228 => _228.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
8342
8527
  if (t.warp) {
8343
8528
  const style = descGet(t.warp, "warpStyle");
8344
- if (_optionalChain([style, 'optionalAccess', _221 => _221.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
8529
+ if (_optionalChain([style, 'optionalAccess', _229 => _229.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
8345
8530
  }
8346
8531
  const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
8347
8532
  const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
@@ -8390,7 +8575,7 @@ function typeFromTySh(data, notes) {
8390
8575
  let at = 0;
8391
8576
  runs = ssheets.map((sheet, i) => {
8392
8577
  const own = named(styleSet, sheet);
8393
- const paraDefault = _optionalChain([paraBases, 'access', _222 => _222[paraAt(at)], 'optionalAccess', _223 => _223.charDefault]);
8578
+ const paraDefault = _optionalChain([paraBases, 'access', _230 => _230[paraAt(at)], 'optionalAccess', _231 => _231.charDefault]);
8394
8579
  at += _nullishCoalesce(slens[i], () => ( 0));
8395
8580
  const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
8396
8581
  return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes) };
@@ -8469,8 +8654,8 @@ var fontEntry = (name) => E.dict([
8469
8654
  ["Synthetic", E.int(0)]
8470
8655
  ]);
8471
8656
  function buildEngineData(layer, template) {
8472
- const e = _optionalChain([template, 'optionalAccess', _224 => _224.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
8473
- if (_optionalChain([eGet, 'call', _225 => _225(e, "EngineDict"), 'optionalAccess', _226 => _226.t]) !== "dict") eSet(e, "EngineDict", E.dict());
8657
+ const e = _optionalChain([template, 'optionalAccess', _232 => _232.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
8658
+ if (_optionalChain([eGet, 'call', _233 => _233(e, "EngineDict"), 'optionalAccess', _234 => _234.t]) !== "dict") eSet(e, "EngineDict", E.dict());
8474
8659
  const dict = eGet(e, "EngineDict");
8475
8660
  const text3 = layer.text.replace(/\n/g, "\r");
8476
8661
  const edText = `${text3}\r`;
@@ -8549,7 +8734,7 @@ function buildEngineData(layer, template) {
8549
8734
  eSet(e, key, rd);
8550
8735
  }
8551
8736
  eSet(rd, "FontSet", fontSet);
8552
- if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _227 => _227[0], 'optionalAccess', _228 => _228.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8737
+ if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _235 => _235[0], 'optionalAccess', _236 => _236.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8553
8738
  if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
8554
8739
  if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
8555
8740
  if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
@@ -8570,12 +8755,12 @@ function inkBounds2(layer) {
8570
8755
  return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
8571
8756
  }
8572
8757
  function tyShForLayer(layer) {
8573
- const raw = _optionalChain([layer, 'access', _229 => _229.psd, 'optionalAccess', _230 => _230.tySh]);
8574
- if (raw && _optionalChain([layer, 'access', _231 => _231.psd, 'optionalAccess', _232 => _232.signature]) === typeSignature(layer)) return raw;
8758
+ const raw = _optionalChain([layer, 'access', _237 => _237.psd, 'optionalAccess', _238 => _238.tySh]);
8759
+ if (raw && _optionalChain([layer, 'access', _239 => _239.psd, 'optionalAccess', _240 => _240.signature]) === typeSignature(layer)) return raw;
8575
8760
  const old = raw ? parseTySh(raw) : null;
8576
8761
  const oldEd = old ? descGet(old.text, "EngineData") : void 0;
8577
8762
  let template = null;
8578
- if (_optionalChain([oldEd, 'optionalAccess', _233 => _233.type]) === "tdta") {
8763
+ if (_optionalChain([oldEd, 'optionalAccess', _241 => _241.type]) === "tdta") {
8579
8764
  try {
8580
8765
  template = parseEngineData(oldEd.data);
8581
8766
  } catch (e19) {
@@ -8607,8 +8792,8 @@ function tyShForLayer(layer) {
8607
8792
  set("boundingBox", rect("boundingBox"));
8608
8793
  if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
8609
8794
  set("EngineData", { type: "tdta", data: writeEngineData(engine) });
8610
- const warpStyle = _optionalChain([old, 'optionalAccess', _234 => _234.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8611
- const warp = _optionalChain([old, 'optionalAccess', _235 => _235.warp]) && _optionalChain([warpStyle, 'optionalAccess', _236 => _236.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8795
+ const warpStyle = _optionalChain([old, 'optionalAccess', _242 => _242.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8796
+ const warp = _optionalChain([old, 'optionalAccess', _243 => _243.warp]) && _optionalChain([warpStyle, 'optionalAccess', _244 => _244.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8612
8797
  return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
8613
8798
  }
8614
8799
 
@@ -8622,15 +8807,15 @@ var textV = (value) => ({ type: "TEXT", value });
8622
8807
  var obj2 = (d) => ({ type: "Objc", value: d });
8623
8808
  var text = (d, key) => {
8624
8809
  const v = descGet(d, key);
8625
- return _optionalChain([v, 'optionalAccess', _237 => _237.type]) === "TEXT" ? v.value : void 0;
8810
+ return _optionalChain([v, 'optionalAccess', _245 => _245.type]) === "TEXT" ? v.value : void 0;
8626
8811
  };
8627
8812
  var enumOf2 = (d, key) => {
8628
8813
  const v = descGet(d, key);
8629
- return _optionalChain([v, 'optionalAccess', _238 => _238.type]) === "enum" ? v.value : void 0;
8814
+ return _optionalChain([v, 'optionalAccess', _246 => _246.type]) === "enum" ? v.value : void 0;
8630
8815
  };
8631
8816
  var numbers = (d, key) => {
8632
8817
  const v = descGet(d, key);
8633
- if (_optionalChain([v, 'optionalAccess', _239 => _239.type]) !== "VlLs") return null;
8818
+ if (_optionalChain([v, 'optionalAccess', _247 => _247.type]) !== "VlLs") return null;
8634
8819
  const out = [];
8635
8820
  for (const it of v.items) {
8636
8821
  if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
@@ -8825,8 +9010,8 @@ function filterMaskItem(placed, mask, area) {
8825
9010
  const painted = _chunkCWM3CUUXcjs.contentBounds.call(void 0, mask.surface);
8826
9011
  let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
8827
9012
  if (mask.defaultValue !== 255 && area) {
8828
- const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _240 => _240.x]), () => ( area.x)));
8829
- const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _241 => _241.y]), () => ( area.y)));
9013
+ const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _248 => _248.x]), () => ( area.x)));
9014
+ const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _249 => _249.y]), () => ( area.y)));
8830
9015
  const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
8831
9016
  const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
8832
9017
  b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
@@ -8846,7 +9031,7 @@ function filterMaskItem(placed, mask, area) {
8846
9031
  }
8847
9032
  var warpStyleOf = (name) => {
8848
9033
  if (!name.startsWith("warp")) return null;
8849
- const s = _optionalChain([name, 'access', _242 => _242[4], 'optionalAccess', _243 => _243.toLowerCase, 'call', _244 => _244()]) + name.slice(5);
9034
+ const s = _optionalChain([name, 'access', _250 => _250[4], 'optionalAccess', _251 => _251.toLowerCase, 'call', _252 => _252()]) + name.slice(5);
8850
9035
  return _chunkEGZM52EOcjs.WARP_STYLES.includes(s) ? s : null;
8851
9036
  };
8852
9037
  function warpFromDescriptor(w, contents) {
@@ -8868,7 +9053,7 @@ function warpFromDescriptor(w, contents) {
8868
9053
  if (!arr || arr.type !== "ObAr") return void 0;
8869
9054
  const xs = descGet(arr.body, "Hrzn");
8870
9055
  const ys = descGet(arr.body, "Vrtc");
8871
- if (_optionalChain([xs, 'optionalAccess', _245 => _245.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _246 => _246.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
9056
+ if (_optionalChain([xs, 'optionalAccess', _253 => _253.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _254 => _254.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
8872
9057
  mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
8873
9058
  const px2 = mesh.points.map((p) => p.x);
8874
9059
  const py = mesh.points.map((p) => p.y);
@@ -9035,13 +9220,13 @@ function blendOptions(f) {
9035
9220
  function smartFiltersFromPsd(fx, newId, notes) {
9036
9221
  const filters = [];
9037
9222
  const list2 = descGet(fx, "filterFXList");
9038
- for (const v of _optionalChain([list2, 'optionalAccess', _247 => _247.type]) === "VlLs" ? list2.items : []) {
9223
+ for (const v of _optionalChain([list2, 'optionalAccess', _255 => _255.type]) === "VlLs" ? list2.items : []) {
9039
9224
  if (v.type !== "Objc" && v.type !== "GlbO") continue;
9040
9225
  const item = v.value;
9041
9226
  const { blend, opacity } = blendOptionsOf(item);
9042
9227
  const enabled = descBool(item, "enab") !== false;
9043
9228
  const fltr = descObject(item, "Fltr");
9044
- const radius = _optionalChain([fltr, 'optionalAccess', _248 => _248.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
9229
+ const radius = _optionalChain([fltr, 'optionalAccess', _256 => _256.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
9045
9230
  if (radius !== void 0 && radius >= 0 && radius <= 50) {
9046
9231
  filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
9047
9232
  continue;
@@ -9394,7 +9579,7 @@ function readPsd(bytes) {
9394
9579
  return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
9395
9580
  }
9396
9581
  function layerBlock(rec, key) {
9397
- return _optionalChain([rec, 'access', _249 => _249.blocks, 'access', _250 => _250.find, 'call', _251 => _251((b) => b.key === key), 'optionalAccess', _252 => _252.data]);
9582
+ return _optionalChain([rec, 'access', _257 => _257.blocks, 'access', _258 => _258.find, 'call', _259 => _259((b) => b.key === key), 'optionalAccess', _260 => _260.data]);
9398
9583
  }
9399
9584
  function layerName(rec) {
9400
9585
  const luni = layerBlock(rec, "luni");
@@ -9425,7 +9610,7 @@ function u8Block(rec, key) {
9425
9610
  function layerTree(file) {
9426
9611
  const stack = [[]];
9427
9612
  file.layers.forEach((rec, index) => {
9428
- const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _253 => _253(rec), 'optionalAccess', _254 => _254.kind]), () => ( SECTION_OTHER));
9613
+ const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _261 => _261(rec), 'optionalAccess', _262 => _262.kind]), () => ( SECTION_OTHER));
9429
9614
  if (kind === SECTION_DIVIDER) {
9430
9615
  stack.push([]);
9431
9616
  } else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
@@ -9443,7 +9628,7 @@ function layerTree(file) {
9443
9628
  }
9444
9629
  function channelRect(rec, id) {
9445
9630
  if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
9446
- if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _255 => _255.mask, 'access', _256 => _256.real, 'optionalAccess', _257 => _257.rect]), () => ( rec.mask.rect));
9631
+ if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _263 => _263.mask, 'access', _264 => _264.real, 'optionalAccess', _265 => _265.rect]), () => ( rec.mask.rect));
9447
9632
  return rec.rect;
9448
9633
  }
9449
9634
  function decodeLayerChannel(file, rec, id) {
@@ -9461,7 +9646,7 @@ function decodeMergedImage(file) {
9461
9646
  return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
9462
9647
  }
9463
9648
  function resource(file, id) {
9464
- return _optionalChain([file, 'access', _258 => _258.resources, 'access', _259 => _259.find, 'call', _260 => _260((r) => r.id === id), 'optionalAccess', _261 => _261.data]);
9649
+ return _optionalChain([file, 'access', _266 => _266.resources, 'access', _267 => _267.find, 'call', _268 => _268((r) => r.id === id), 'optionalAccess', _269 => _269.data]);
9465
9650
  }
9466
9651
  function resolution(file) {
9467
9652
  const d = resource(file, 1005);
@@ -10188,9 +10373,22 @@ function baseProps(ctx, rec, name, notes) {
10188
10373
  ctx.warn.add("Artboards are not supported; they came in as plain groups, without their background colour and clipping", name);
10189
10374
  notes.push("artboard imported as a group");
10190
10375
  }
10191
- if (rec.blocks.some((b) => VECTOR_KEYS.includes(b.key)) && psdKind(rec) === "pixel") {
10192
- ctx.warn.add("Vector masks are not supported and were ignored", name);
10193
- notes.push("vector mask ignored");
10376
+ const vectorBlock = psdKind(rec) === "shape" ? void 0 : _nullishCoalesce(rec.blocks.find((b) => b.key === "vsms"), () => ( rec.blocks.find((b) => b.key === "vmsk")));
10377
+ if (vectorBlock) {
10378
+ const read2 = componentsFromVectorBlock(vectorBlock.data, ctx.file.header.width, ctx.file.header.height);
10379
+ if (read2) {
10380
+ const vm = { components: read2.components };
10381
+ if (read2.inverted) vm.inverted = true;
10382
+ if (read2.flags & VMSK_NOT_LINKED) vm.linked = false;
10383
+ if (read2.flags & VMSK_DISABLED) vm.enabled = false;
10384
+ const m = rec.mask;
10385
+ if (_optionalChain([m, 'optionalAccess', _270 => _270.vectorDensity]) !== void 0 && m.vectorDensity < 255) vm.density = percent(m.vectorDensity);
10386
+ if (_optionalChain([m, 'optionalAccess', _271 => _271.vectorFeather]) !== void 0 && m.vectorFeather > 0) vm.feather = Math.min(1e3, m.vectorFeather);
10387
+ props.vectorMask = vm;
10388
+ } else {
10389
+ ctx.warn.add("A vector mask could not be read and was ignored", name);
10390
+ notes.push("vector mask ignored");
10391
+ }
10194
10392
  }
10195
10393
  return props;
10196
10394
  }
@@ -10245,7 +10443,7 @@ function importNode(ctx, node, depth) {
10245
10443
  if (node.children) {
10246
10444
  const props2 = baseProps(ctx, rec, name, notes);
10247
10445
  const divider = sectionDivider(rec);
10248
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _262 => _262.blendKey]), () => ( rec.blendKey));
10446
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _272 => _272.blendKey]), () => ( rec.blendKey));
10249
10447
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
10250
10448
  const children = [];
10251
10449
  for (const child of node.children) {
@@ -10255,7 +10453,7 @@ function importNode(ctx, node, depth) {
10255
10453
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
10256
10454
  const effects2 = recordEffects(ctx, rec, name, notes, true);
10257
10455
  if (effects2) group.effects = effects2;
10258
- if (_optionalChain([divider, 'optionalAccess', _263 => _263.kind]) === SECTION_CLOSED) group.collapsed = true;
10456
+ if (_optionalChain([divider, 'optionalAccess', _273 => _273.kind]) === SECTION_CLOSED) group.collapsed = true;
10259
10457
  const mask2 = recordMask(ctx, rec, name);
10260
10458
  if (mask2) group.mask = mask2;
10261
10459
  entry.type = "group";
@@ -10478,7 +10676,7 @@ function importSmart(ctx, rec, name, notes, props) {
10478
10676
  const file = ctx.linked.get(placed.idnt);
10479
10677
  contents = {
10480
10678
  id: placed.idnt || ctx.newId(`${name}-contents`),
10481
- name: _optionalChain([file, 'optionalAccess', _264 => _264.name]) || `${name}.png`,
10679
+ name: _optionalChain([file, 'optionalAccess', _274 => _274.name]) || `${name}.png`,
10482
10680
  width,
10483
10681
  height,
10484
10682
  kind: "raster",
@@ -10635,7 +10833,7 @@ function psdToLayers(file, options = {}) {
10635
10833
  if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
10636
10834
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
10637
10835
  } else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
10638
- const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _265 => _265.name]), () => ( "its profile"))}` : "";
10836
+ const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _275 => _275.name]), () => ( "its profile"))}` : "";
10639
10837
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB${how}.`);
10640
10838
  }
10641
10839
  let layers = [];
@@ -10752,15 +10950,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
10752
10950
  var bool = (d, key) => descBool(d, key) === true;
10753
10951
  var enumOf3 = (d, key) => {
10754
10952
  const v = descGet(d, key);
10755
- return _optionalChain([v, 'optionalAccess', _266 => _266.type]) === "enum" ? v.value : void 0;
10953
+ return _optionalChain([v, 'optionalAccess', _276 => _276.type]) === "enum" ? v.value : void 0;
10756
10954
  };
10757
10955
  var text2 = (d, key) => {
10758
10956
  const v = d ? descGet(d, key) : void 0;
10759
- return _optionalChain([v, 'optionalAccess', _267 => _267.type]) === "TEXT" ? v.value : "";
10957
+ return _optionalChain([v, 'optionalAccess', _277 => _277.type]) === "TEXT" ? v.value : "";
10760
10958
  };
10761
10959
  var list = (d, key) => {
10762
10960
  const v = descGet(d, key);
10763
- if (_optionalChain([v, 'optionalAccess', _268 => _268.type]) !== "VlLs") return [];
10961
+ if (_optionalChain([v, 'optionalAccess', _278 => _278.type]) !== "VlLs") return [];
10764
10962
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
10765
10963
  };
10766
10964
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -10830,8 +11028,8 @@ function contourOf(d, key) {
10830
11028
  return { name, points };
10831
11029
  }
10832
11030
  function contourDesc(c) {
10833
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _269 => _269.name]), () => ( "Linear"));
10834
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _270 => _270.points]), () => ( [
11031
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _279 => _279.name]), () => ( "Linear"));
11032
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _280 => _280.points]), () => ( [
10835
11033
  { input: 0, output: 0 },
10836
11034
  { input: 1, output: 1 }
10837
11035
  ]));
@@ -10866,7 +11064,7 @@ function gradientOf(d, notes) {
10866
11064
  { position: 0, color: "#000000" },
10867
11065
  { position: 1, color: "#ffffff" }
10868
11066
  ],
10869
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _271 => _271.find, 'call', _272 => _272(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _273 => _273[0]]), () => ( "linear")),
11067
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _281 => _281.find, 'call', _282 => _282(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _283 => _283[0]]), () => ( "linear")),
10870
11068
  angle: clamp3(num3(d, "Angl", 90), -360, 360),
10871
11069
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
10872
11070
  reverse: bool(d, "Rvrs"),
@@ -10920,7 +11118,7 @@ function gradientItems(g) {
10920
11118
  )
10921
11119
  )
10922
11120
  };
10923
- const op = _optionalChain([g, 'access', _274 => _274.opacityStops, 'optionalAccess', _275 => _275.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
11121
+ const op = _optionalChain([g, 'access', _284 => _284.opacityStops, 'optionalAccess', _285 => _285.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10924
11122
  const trns = {
10925
11123
  type: "VlLs",
10926
11124
  items: op.map(
@@ -11417,9 +11615,9 @@ function prepareNestedLayers(layers) {
11417
11615
  if (l.type === "annotation") continue;
11418
11616
  let next = l;
11419
11617
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
11420
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _276 => _276.filters, 'optionalAccess', _277 => _277.length]) || l.source === "document")) {
11618
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _286 => _286.filters, 'optionalAccess', _287 => _287.length]) || l.source === "document")) {
11421
11619
  const p = { ...l };
11422
- if (_optionalChain([l, 'access', _278 => _278.filters, 'optionalAccess', _279 => _279.some, 'call', _280 => _280(isActiveFilter)])) {
11620
+ if (_optionalChain([l, 'access', _288 => _288.filters, 'optionalAccess', _289 => _289.some, 'call', _290 => _290(isActiveFilter)])) {
11423
11621
  const b = l.surface.bounds;
11424
11622
  if (b) {
11425
11623
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -11436,7 +11634,7 @@ function prepareNestedLayers(layers) {
11436
11634
  delete p.source;
11437
11635
  next = p;
11438
11636
  }
11439
- if (_optionalChain([next, 'access', _281 => _281.mask, 'optionalAccess', _282 => _282.source])) {
11637
+ if (_optionalChain([next, 'access', _291 => _291.mask, 'optionalAccess', _292 => _292.source])) {
11440
11638
  next = { ...next };
11441
11639
  delete next.mask;
11442
11640
  }
@@ -11539,10 +11737,17 @@ function exportPsd(input) {
11539
11737
  if (fx) blocks.push(fx);
11540
11738
  const locks = lockBits(layer);
11541
11739
  if (locks) blocks.push({ key: "lspf", data: u32Bytes(locks >>> 0) });
11740
+ const vm = layer.type !== "shape" ? layer.vectorMask : void 0;
11741
+ if (vm) {
11742
+ const flags = (vm.linked === false ? VMSK_NOT_LINKED : 0) | (vm.enabled === false ? VMSK_DISABLED : 0);
11743
+ blocks.push({ key: "vmsk", data: vectorBlockForComponents(vm.components, vm.inverted === true, width, height, flags) });
11744
+ if ((_nullishCoalesce(vm.density, () => ( 1))) !== 1 || (_nullishCoalesce(vm.feather, () => ( 0))) > 0) note("Vector mask density and feather are not written; the paths are", layer.name);
11745
+ if (vm.fillRule === "evenodd") note("Vector masks are written with the nonzero fill rule (Photoshop has no even-odd paths)", layer.name);
11746
+ }
11542
11747
  return {
11543
11748
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
11544
11749
  clipping: layer.clipped ? 1 : 0,
11545
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _283 => _283.locks, 'optionalAccess', _284 => _284.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11750
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _293 => _293.locks, 'optionalAccess', _294 => _294.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11546
11751
  legacyName: name,
11547
11752
  blocks
11548
11753
  };
@@ -11599,7 +11804,7 @@ function exportPsd(input) {
11599
11804
  }
11600
11805
  case "pixel": {
11601
11806
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
11602
- if (_optionalChain([layer, 'access', _285 => _285.filters, 'optionalAccess', _286 => _286.some, 'call', _287 => _287(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11807
+ if (_optionalChain([layer, 'access', _295 => _295.filters, 'optionalAccess', _296 => _296.some, 'call', _297 => _297(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11603
11808
  const extra = [];
11604
11809
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
11605
11810
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
@@ -11631,7 +11836,7 @@ function exportPsd(input) {
11631
11836
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
11632
11837
  linkedFiles.set(idnt, smartContentsFile(c));
11633
11838
  }
11634
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _288 => _288.psd, 'optionalAccess', _289 => _289.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11839
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _298 => _298.psd, 'optionalAccess', _299 => _299.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11635
11840
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
11636
11841
  placedIds.add(placedId);
11637
11842
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -11641,12 +11846,12 @@ function exportPsd(input) {
11641
11846
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
11642
11847
  if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
11643
11848
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
11644
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _290 => _290.descriptor]) };
11849
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _300 => _300.descriptor]) };
11645
11850
  const wnotes = [];
11646
11851
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
11647
11852
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
11648
11853
  }
11649
- const fm = _optionalChain([layer, 'access', _291 => _291.smartFilters, 'optionalAccess', _292 => _292.mask]);
11854
+ const fm = _optionalChain([layer, 'access', _301 => _301.smartFilters, 'optionalAccess', _302 => _302.mask]);
11650
11855
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
11651
11856
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11652
11857
  const bounds = _chunkCWM3CUUXcjs.contentBounds.call(void 0, layer.surface);
@@ -11674,8 +11879,8 @@ function exportPsd(input) {
11674
11879
  const losses = /* @__PURE__ */ new Set();
11675
11880
  for (const b of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b.key, data: padEven(b.data) });
11676
11881
  for (const n2 of losses) note(n2, layer.name);
11677
- if (_optionalChain([layer, 'access', _293 => _293.fill, 'optionalAccess', _294 => _294.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11678
- if (_optionalChain([layer, 'access', _295 => _295.stroke, 'optionalAccess', _296 => _296.paint, 'access', _297 => _297.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11882
+ if (_optionalChain([layer, 'access', _303 => _303.fill, 'optionalAccess', _304 => _304.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11883
+ if (_optionalChain([layer, 'access', _305 => _305.stroke, 'optionalAccess', _306 => _306.paint, 'access', _307 => _307.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11679
11884
  } else {
11680
11885
  extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
11681
11886
  }
@@ -11743,7 +11948,7 @@ function exportPsd(input) {
11743
11948
  { id: 1005, name: "", data: rw.result() },
11744
11949
  { id: 1057, name: "", data: version.result() }
11745
11950
  ];
11746
- if (_optionalChain([input, 'access', _298 => _298.iccProfile, 'optionalAccess', _299 => _299.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11951
+ if (_optionalChain([input, 'access', _308 => _308.iccProfile, 'optionalAccess', _309 => _309.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11747
11952
  resources.push(...alphaChannelResources(_nullishCoalesce(input.alphaChannels, () => ( []))));
11748
11953
  if (input.globalLight) {
11749
11954
  const i32 = (v) => {
@@ -12163,4 +12368,14 @@ function exportPsd(input) {
12163
12368
 
12164
12369
 
12165
12370
 
12166
- exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.selectionFromTiles = selectionFromTiles; exports.createSelectionMask = createSelectionMask; exports.selectionFromRegion = selectionFromRegion; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
12371
+
12372
+
12373
+
12374
+
12375
+
12376
+
12377
+
12378
+
12379
+
12380
+
12381
+ exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.selectionFromTiles = selectionFromTiles; exports.createSelectionMask = createSelectionMask; exports.selectionFromRegion = selectionFromRegion; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.componentsCoverage = componentsCoverage; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.isActiveVectorMask = isActiveVectorMask; exports.vectorMaskCoverage = vectorMaskCoverage; exports.effectiveLayerMask = effectiveLayerMask; exports.resolveVectorMasks = resolveVectorMasks; exports.offsetVectorMask = offsetVectorMask; exports.transformVectorMask = transformVectorMask; exports.followLayerMove = followLayerMove; exports.vectorMaskBounds = vectorMaskBounds; exports.vectorMaskThumbnail = vectorMaskThumbnail; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;