@codingfactory/mediables-vue 2.19.2 → 2.19.3
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.
- package/dist/{PixiFrameExporter-CRe8z6ua.js → PixiFrameExporter-BgKJMR1H.js} +2 -2
- package/dist/{PixiFrameExporter-CRe8z6ua.js.map → PixiFrameExporter-BgKJMR1H.js.map} +1 -1
- package/dist/{PixiFrameExporter-R6iQjzVw.cjs → PixiFrameExporter-CZkLc9b5.cjs} +2 -2
- package/dist/{PixiFrameExporter-R6iQjzVw.cjs.map → PixiFrameExporter-CZkLc9b5.cjs.map} +1 -1
- package/dist/editor-BDmZ747c.cjs +2 -0
- package/dist/editor-BDmZ747c.cjs.map +1 -0
- package/dist/{editor-BQ_nY4P6.js → editor-CcfSL2dI.js} +793 -773
- package/dist/editor-CcfSL2dI.js.map +1 -0
- package/dist/{index-B8LxZ37n.js → index-CSYvPx9Q.js} +3 -3
- package/dist/{index-B8LxZ37n.js.map → index-CSYvPx9Q.js.map} +1 -1
- package/dist/{index-DutUeSES.cjs → index-LL2h0nsa.cjs} +3 -3
- package/dist/{index-DutUeSES.cjs.map → index-LL2h0nsa.cjs.map} +1 -1
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/package.json +1 -1
- package/dist/editor-BQ_nY4P6.js.map +0 -1
- package/dist/editor-CUV1pIsV.cjs +0 -2
- package/dist/editor-CUV1pIsV.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var Me = Object.defineProperty;
|
|
2
|
-
var Fe = (
|
|
3
|
-
var
|
|
4
|
-
import { E as
|
|
2
|
+
var Fe = (g, e, t) => e in g ? Me(g, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[e] = t;
|
|
3
|
+
var ae = (g, e, t) => Fe(g, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { E as ne, d as Se } from "./index-Dae8SHT7.js";
|
|
5
5
|
const Re = Object.freeze(["normal", "multiply", "screen", "overlay"]), E = Object.freeze({
|
|
6
6
|
stroke: Object.freeze({ enabled: !1, color: "#000000", width: 0 }),
|
|
7
7
|
shadow: Object.freeze({ enabled: !1, color: "#000000", alpha: 0.5, blur: 0, distance: 0, angle: 45 }),
|
|
8
8
|
glow: Object.freeze({ enabled: !1, color: "#ffffff", alpha: 0.5, blur: 0 }),
|
|
9
9
|
backdrop: Object.freeze({ enabled: !1, color: "#000000", opacity: 0.5, padding: 0, radius: 0, blur: 0 })
|
|
10
10
|
});
|
|
11
|
-
class Te extends
|
|
11
|
+
class Te extends ne {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(), this.app = null, this.sprite = null, this.originalTexture = null, this.baseTexture = null, this.fitScale = 1, this.zoom = 1, this._container = null, this._lastExportDimensions = null, this._mountPromise = null, this._mountToken = 0, this._destroyed = !1, this._layerDocument = null, this._layerDisplayObjects = /* @__PURE__ */ new Map(), this._renderableLayerIds = [], this._loadedTextureUrl = null, this._layerRenderToken = 0, this._layerFilterFactory = null;
|
|
14
14
|
}
|
|
@@ -26,8 +26,8 @@ class Te extends se {
|
|
|
26
26
|
* canvas getter which throws when renderer is undefined.
|
|
27
27
|
*/
|
|
28
28
|
_getCssSize() {
|
|
29
|
-
var
|
|
30
|
-
const e = (
|
|
29
|
+
var s, r, o, n, a, l;
|
|
30
|
+
const e = (r = (s = this.app) == null ? void 0 : s.renderer) == null ? void 0 : r.canvas, t = (e == null ? void 0 : e.clientWidth) ?? ((n = (o = this.app) == null ? void 0 : o.screen) == null ? void 0 : n.width) ?? 0, i = (e == null ? void 0 : e.clientHeight) ?? ((l = (a = this.app) == null ? void 0 : a.screen) == null ? void 0 : l.height) ?? 0;
|
|
31
31
|
return { w: t, h: i };
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -52,15 +52,15 @@ class Te extends se {
|
|
|
52
52
|
t();
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
let i = !1,
|
|
56
|
-
const
|
|
57
|
-
i || (i = !0, window.clearTimeout(
|
|
55
|
+
let i = !1, s = 0;
|
|
56
|
+
const r = () => {
|
|
57
|
+
i || (i = !0, window.clearTimeout(s), t());
|
|
58
58
|
};
|
|
59
|
-
if (
|
|
60
|
-
window.requestAnimationFrame(() =>
|
|
59
|
+
if (s = window.setTimeout(r, e), typeof window.requestAnimationFrame == "function") {
|
|
60
|
+
window.requestAnimationFrame(() => r());
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
r();
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
@@ -72,16 +72,16 @@ class Te extends se {
|
|
|
72
72
|
if (!this.app || !e) return 1;
|
|
73
73
|
const { w: t, h: i } = this._getCssSize();
|
|
74
74
|
if (t <= 1 || i <= 1) return 1;
|
|
75
|
-
let
|
|
76
|
-
return (!Number.isFinite(
|
|
75
|
+
let s = Math.min(t / e.width, i / e.height) * 0.9;
|
|
76
|
+
return (!Number.isFinite(s) || s <= 0) && (s = 1), s;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Apply view transform (position and scale) to sprite
|
|
80
80
|
*/
|
|
81
81
|
applyViewTransform(e = {}) {
|
|
82
82
|
if (!this.app || !this.sprite || !this.originalTexture) return;
|
|
83
|
-
const t = this.fitScale * this.zoom, { w: i, h:
|
|
84
|
-
this.sprite.width = this.originalTexture.width * t, this.sprite.height = this.originalTexture.height * t, this.sprite.x =
|
|
83
|
+
const t = this.fitScale * this.zoom, { w: i, h: s } = this._getCssSize(), r = e.keepCenter ? { x: this.sprite.x + this.sprite.width / 2, y: this.sprite.y + this.sprite.height / 2 } : e.center ?? { x: i / 2, y: s / 2 };
|
|
84
|
+
this.sprite.width = this.originalTexture.width * t, this.sprite.height = this.originalTexture.height * t, this.sprite.x = r.x - this.sprite.width / 2, this.sprite.y = r.y - this.sprite.height / 2, this._syncLayerDisplayObjects(), this.render();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Set zoom level
|
|
@@ -108,12 +108,12 @@ class Te extends se {
|
|
|
108
108
|
async mount(e, t = 16777215, i = {}) {
|
|
109
109
|
if (!e) return;
|
|
110
110
|
this._destroyed = !1, this._container = e;
|
|
111
|
-
const
|
|
112
|
-
var
|
|
111
|
+
const s = ++this._mountToken, r = async () => {
|
|
112
|
+
var p;
|
|
113
113
|
const o = window.PIXI;
|
|
114
114
|
if (!o)
|
|
115
115
|
throw new Error("PIXI.js not found. Please ensure PIXI is loaded globally.");
|
|
116
|
-
(
|
|
116
|
+
(p = o.Assets) != null && p.setPreferences && o.Assets.setPreferences({ crossOrigin: "anonymous" });
|
|
117
117
|
const n = e.clientWidth || 600, a = e.clientHeight || 400, l = typeof i.backgroundAlpha == "number" ? i.backgroundAlpha : 1, h = new o.Application();
|
|
118
118
|
if (this.app = h, await h.init({
|
|
119
119
|
width: n,
|
|
@@ -123,7 +123,7 @@ class Te extends se {
|
|
|
123
123
|
antialias: !0,
|
|
124
124
|
autoDensity: !0,
|
|
125
125
|
resolution: window.devicePixelRatio || 1
|
|
126
|
-
}), this._destroyed || this._mountToken !==
|
|
126
|
+
}), this._destroyed || this._mountToken !== s || this.app !== h) {
|
|
127
127
|
try {
|
|
128
128
|
h.destroy(!0, { children: !0, texture: !0 });
|
|
129
129
|
} catch {
|
|
@@ -134,7 +134,7 @@ class Te extends se {
|
|
|
134
134
|
const c = h.canvas;
|
|
135
135
|
return c.classList.add("pixi-canvas"), c.style.width = "100%", c.style.height = "100%", c.style.transform = "translateZ(0)", c.style.willChange = "transform", c.setAttribute("role", "img"), c.setAttribute("aria-label", "Image editor canvas — use toolbar controls to edit the image"), this.emit("mounted", { width: n, height: a }), !0;
|
|
136
136
|
};
|
|
137
|
-
return this._mountPromise =
|
|
137
|
+
return this._mountPromise = r(), await this._mountPromise;
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Load an image texture
|
|
@@ -144,15 +144,15 @@ class Te extends se {
|
|
|
144
144
|
* has been superseded and must not mutate the renderer.
|
|
145
145
|
*/
|
|
146
146
|
async loadTexture(e, t = {}) {
|
|
147
|
-
var h, c,
|
|
147
|
+
var h, c, p;
|
|
148
148
|
const i = () => typeof t.isCurrent != "function" || t.isCurrent() !== !1;
|
|
149
149
|
if (this._mountPromise && await this._mountPromise, !((h = this.app) != null && h.renderer) || !i()) return !1;
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
const o =
|
|
150
|
+
const s = window.PIXI, r = await this._loadImageElement(e);
|
|
151
|
+
if (!r || !((c = this.app) != null && c.renderer) || !i() || (await this._waitForNextFrame(), !((p = this.app) != null && p.renderer) || !i())) return !1;
|
|
152
|
+
const o = s.Texture.from(r);
|
|
153
153
|
if (!o)
|
|
154
154
|
return !1;
|
|
155
|
-
this.originalTexture = o, this.baseTexture = o, this._loadedTextureUrl = typeof e == "string" ? e : null, this.sprite && (this.app.stage.removeChild(this.sprite), this.sprite.destroy()), this.sprite = new
|
|
155
|
+
this.originalTexture = o, this.baseTexture = o, this._loadedTextureUrl = typeof e == "string" ? e : null, this.sprite && (this.app.stage.removeChild(this.sprite), this.sprite.destroy()), this.sprite = new s.Sprite(o), this.app.stage.addChild(this.sprite), this.fitScale = this.getFitScaleFor(o), this.zoom = 1;
|
|
156
156
|
const { w: n, h: a } = this._getCssSize();
|
|
157
157
|
this.applyViewTransform({ center: { x: n / 2, y: a / 2 } });
|
|
158
158
|
const l = this.getFitScaleFor(o);
|
|
@@ -171,35 +171,35 @@ class Te extends se {
|
|
|
171
171
|
return !1;
|
|
172
172
|
const t = window.PIXI;
|
|
173
173
|
if (!t) return !1;
|
|
174
|
-
const i = ++this._layerRenderToken,
|
|
174
|
+
const i = ++this._layerRenderToken, s = () => i === this._layerRenderToken;
|
|
175
175
|
this._destroyLayerDisplayObjects(), this._layerDocument = JSON.parse(JSON.stringify(e)), this._renderableLayerIds = [];
|
|
176
176
|
try {
|
|
177
177
|
this.app.stage.removeChild(this.sprite);
|
|
178
178
|
} catch {
|
|
179
179
|
}
|
|
180
|
-
let
|
|
180
|
+
let r = !1;
|
|
181
181
|
for (const n of this._layerDocument.layers) {
|
|
182
182
|
if (!n || n.visible === !1) {
|
|
183
|
-
(n == null ? void 0 : n.role) === "subject" && (this.sprite.visible = !1, this.sprite.__layerId = n.id,
|
|
183
|
+
(n == null ? void 0 : n.role) === "subject" && (this.sprite.visible = !1, this.sprite.__layerId = n.id, r = !0);
|
|
184
184
|
continue;
|
|
185
185
|
}
|
|
186
186
|
if (this._isSubjectLayer(n)) {
|
|
187
187
|
const l = await this._createSubjectDisplayObjectForLayer(t, n);
|
|
188
|
-
if (!
|
|
188
|
+
if (!s())
|
|
189
189
|
return this._destroyTransientDisplayObject(l), !1;
|
|
190
190
|
if (l) {
|
|
191
|
-
this.sprite.visible = !1, l.__layerId = n.id, l.visible = !0, l.alpha = this._layerOpacity(n), this._layerDisplayObjects.set(n.id, { layer: n, displayObject: l }), this._syncLayerDisplayObject(n, l), this.app.stage.addChild(l), this._renderableLayerIds.push(n.id),
|
|
191
|
+
this.sprite.visible = !1, l.__layerId = n.id, l.visible = !0, l.alpha = this._layerOpacity(n), this._layerDisplayObjects.set(n.id, { layer: n, displayObject: l }), this._syncLayerDisplayObject(n, l), this.app.stage.addChild(l), this._renderableLayerIds.push(n.id), r = !0;
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
|
-
this.sprite.__layerId = n.id, this.sprite.visible = !0, this.sprite.alpha = this._layerOpacity(n), this._applyLayerFilterInstances(this.sprite, n), this.app.stage.addChild(this.sprite), this._renderableLayerIds.push(n.id),
|
|
194
|
+
this.sprite.__layerId = n.id, this.sprite.visible = !0, this.sprite.alpha = this._layerOpacity(n), this._applyLayerFilterInstances(this.sprite, n), this.app.stage.addChild(this.sprite), this._renderableLayerIds.push(n.id), r = !0;
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
197
|
const a = await this._createDisplayObjectForLayer(t, n);
|
|
198
|
-
if (!
|
|
198
|
+
if (!s())
|
|
199
199
|
return this._destroyTransientDisplayObject(a), !1;
|
|
200
200
|
a && (a.__layerId = n.id, a.visible = !0, a.alpha = this._layerOpacity(n), this._layerDisplayObjects.set(n.id, { layer: n, displayObject: a }), this._syncLayerDisplayObject(n, a), this.app.stage.addChild(a), this._renderableLayerIds.push(n.id));
|
|
201
201
|
}
|
|
202
|
-
return
|
|
202
|
+
return r || (this.sprite.visible = !1), s() ? (this.render(), !0) : !1;
|
|
203
203
|
}
|
|
204
204
|
getRenderableLayerIds() {
|
|
205
205
|
return [...this._renderableLayerIds];
|
|
@@ -213,10 +213,10 @@ class Te extends se {
|
|
|
213
213
|
this._layerDocument = JSON.parse(JSON.stringify(e));
|
|
214
214
|
for (const i of this._layerDocument.layers) {
|
|
215
215
|
if (!i) continue;
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
let
|
|
219
|
-
!
|
|
216
|
+
const s = this._layerDisplayObjects.get(i.id) || null;
|
|
217
|
+
s && (s.layer = i);
|
|
218
|
+
let r = (s == null ? void 0 : s.displayObject) || null;
|
|
219
|
+
!r && this._isSubjectLayer(i) && ((t = this.sprite) == null ? void 0 : t.__layerId) === i.id && (r = this.sprite), r && this._applyLayerFilterInstances(r, i);
|
|
220
220
|
}
|
|
221
221
|
return this.render(), !0;
|
|
222
222
|
}
|
|
@@ -233,10 +233,10 @@ class Te extends se {
|
|
|
233
233
|
}
|
|
234
234
|
_applyLayerFilterInstances(e, t, i = {}) {
|
|
235
235
|
if (!e || !this._layerSupportsImageFilters(t)) return;
|
|
236
|
-
let
|
|
236
|
+
let s = [];
|
|
237
237
|
if (this._layerFilterFactory)
|
|
238
238
|
try {
|
|
239
|
-
|
|
239
|
+
s = this._layerFilterFactory(t, {
|
|
240
240
|
displayObject: e,
|
|
241
241
|
forExport: i.forExport === !0,
|
|
242
242
|
previewToNativeScale: i.previewToNativeScale || 1,
|
|
@@ -244,10 +244,10 @@ class Te extends se {
|
|
|
244
244
|
sourceHeight: i.sourceHeight
|
|
245
245
|
}) || [];
|
|
246
246
|
} catch {
|
|
247
|
-
|
|
247
|
+
s = [];
|
|
248
248
|
}
|
|
249
|
-
const
|
|
250
|
-
for (const a of
|
|
249
|
+
const r = Array.isArray(s) ? s.filter(Boolean) : [];
|
|
250
|
+
for (const a of r)
|
|
251
251
|
if (!(!a || typeof a != "object" && typeof a != "function"))
|
|
252
252
|
try {
|
|
253
253
|
Object.defineProperty(a, "__mediablesLayerImageFilter", {
|
|
@@ -260,24 +260,24 @@ class Te extends se {
|
|
|
260
260
|
} catch {
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
const n = [...Array.isArray(e.filters) ? e.filters.filter((a) => (a == null ? void 0 : a.__mediablesLayerImageFilter) !== !0) : [], ...
|
|
263
|
+
const n = [...Array.isArray(e.filters) ? e.filters.filter((a) => (a == null ? void 0 : a.__mediablesLayerImageFilter) !== !0) : [], ...r];
|
|
264
264
|
e.filters = n.length > 0 ? n : null;
|
|
265
265
|
}
|
|
266
266
|
async _createDisplayObjectForLayer(e, t) {
|
|
267
267
|
var o, n;
|
|
268
268
|
const i = this._createTextDisplayObjectForLayer(e, t);
|
|
269
269
|
if (i) return i;
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
if ((
|
|
274
|
-
const a = await this._textureForLayerSource(e,
|
|
270
|
+
const s = await this._createImageDisplayObjectForLayer(e, t);
|
|
271
|
+
if (s) return s;
|
|
272
|
+
const r = this._backgroundFillForLayer(t);
|
|
273
|
+
if ((r == null ? void 0 : r.kind) === "media") {
|
|
274
|
+
const a = await this._textureForLayerSource(e, r.source);
|
|
275
275
|
if (!a) return null;
|
|
276
|
-
const l = this._createBackgroundSprite(e, a,
|
|
277
|
-
return l.__sourceWidth = Number((o =
|
|
276
|
+
const l = this._createBackgroundSprite(e, a, r.fit);
|
|
277
|
+
return l.__sourceWidth = Number((o = r.source) == null ? void 0 : o.originalWidth) || a.width || 1, l.__sourceHeight = Number((n = r.source) == null ? void 0 : n.originalHeight) || a.height || 1, this._applyLayerEffects(e, l, t), this._applyLayerFilterInstances(l, t), l;
|
|
278
278
|
}
|
|
279
|
-
if ((
|
|
280
|
-
const a = this._createGradientTexture(e,
|
|
279
|
+
if ((r == null ? void 0 : r.kind) === "gradient") {
|
|
280
|
+
const a = this._createGradientTexture(e, r, 512, 512);
|
|
281
281
|
if (!a || typeof e.Sprite != "function") return null;
|
|
282
282
|
const l = new e.Sprite(a);
|
|
283
283
|
return l.__ownsTexture = !0, l.__sourceWidth = 512, l.__sourceHeight = 512, this._applyLayerEffects(e, l, t), l;
|
|
@@ -301,9 +301,9 @@ class Te extends se {
|
|
|
301
301
|
height: this._clampNumber(t.height, 0.05, 1, 0.18)
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
|
-
_clampNumber(e, t, i,
|
|
305
|
-
const
|
|
306
|
-
return Number.isFinite(
|
|
304
|
+
_clampNumber(e, t, i, s) {
|
|
305
|
+
const r = Number(e);
|
|
306
|
+
return Number.isFinite(r) ? Math.max(t, Math.min(i, r)) : s;
|
|
307
307
|
}
|
|
308
308
|
_supportedTextFontFamily(e) {
|
|
309
309
|
const t = ["Inter", "Arial", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Verdana"], i = typeof e == "string" ? e.trim() : "";
|
|
@@ -321,25 +321,25 @@ class Te extends se {
|
|
|
321
321
|
const t = (i = e == null ? void 0 : e.text) == null ? void 0 : i.content;
|
|
322
322
|
return t == null ? "" : String(t);
|
|
323
323
|
}
|
|
324
|
-
_textStyleForLayer(e, t = 1, i = 1,
|
|
324
|
+
_textStyleForLayer(e, t = 1, i = 1, s = {}) {
|
|
325
325
|
var m;
|
|
326
|
-
const
|
|
327
|
-
fontFamily: this._supportedTextFontFamily(
|
|
326
|
+
const r = (m = e == null ? void 0 : e.text) != null && m.style && typeof e.text.style == "object" ? e.text.style : {}, o = this._textEffectsForLayer(e), n = this._clampNumber(r.fontSize, 8, 400, 64), a = this._clampNumber(r.lineHeight, 0.8, 3, 1.2), l = this._clampNumber(r.letterSpacing, -100, 100, 0), h = this._normalizeTextFontWeight(r.fontWeight), c = ["normal", "italic"].includes(r.fontStyle) ? r.fontStyle : "normal", p = ["left", "center", "right"].includes(r.align) ? r.align : "center", u = s.fill || (typeof r.fill == "string" && /^#[0-9a-f]{6}$/i.test(r.fill) ? r.fill : "#ffffff"), f = {
|
|
327
|
+
fontFamily: this._supportedTextFontFamily(r.fontFamily),
|
|
328
328
|
fontSize: n * t,
|
|
329
329
|
fontWeight: h,
|
|
330
330
|
fontStyle: c,
|
|
331
|
-
fill:
|
|
332
|
-
align:
|
|
331
|
+
fill: u,
|
|
332
|
+
align: p,
|
|
333
333
|
lineHeight: n * a * t,
|
|
334
334
|
letterSpacing: l * t,
|
|
335
335
|
wordWrap: !0,
|
|
336
336
|
wordWrapWidth: Math.max(1, i),
|
|
337
337
|
breakWords: !0
|
|
338
338
|
};
|
|
339
|
-
return
|
|
339
|
+
return s.stroke !== !1 && o.stroke.enabled && o.stroke.width > 0 && (f.stroke = {
|
|
340
340
|
color: o.stroke.color,
|
|
341
341
|
width: o.stroke.width * t
|
|
342
|
-
}),
|
|
342
|
+
}), f;
|
|
343
343
|
}
|
|
344
344
|
_normalizeTextFontWeight(e) {
|
|
345
345
|
if (e === "normal") return 400;
|
|
@@ -349,7 +349,7 @@ class Te extends se {
|
|
|
349
349
|
}
|
|
350
350
|
_textEffectsForLayer(e) {
|
|
351
351
|
var n;
|
|
352
|
-
const t = (n = e == null ? void 0 : e.text) != null && n.effects && typeof e.text.effects == "object" ? e.text.effects : {}, i = t.stroke && typeof t.stroke == "object" ? t.stroke : {},
|
|
352
|
+
const t = (n = e == null ? void 0 : e.text) != null && n.effects && typeof e.text.effects == "object" ? e.text.effects : {}, i = t.stroke && typeof t.stroke == "object" ? t.stroke : {}, s = t.shadow && typeof t.shadow == "object" ? t.shadow : {}, r = t.glow && typeof t.glow == "object" ? t.glow : {}, o = t.backdrop && typeof t.backdrop == "object" ? t.backdrop : {};
|
|
353
353
|
return {
|
|
354
354
|
stroke: {
|
|
355
355
|
enabled: i.enabled === !0,
|
|
@@ -357,18 +357,18 @@ class Te extends se {
|
|
|
357
357
|
width: this._clampNumber(i.width, 0, 80, E.stroke.width)
|
|
358
358
|
},
|
|
359
359
|
shadow: {
|
|
360
|
-
enabled:
|
|
361
|
-
color: this._supportedTextColor(
|
|
362
|
-
alpha: this._clampNumber(
|
|
363
|
-
blur: this._clampNumber(
|
|
364
|
-
distance: this._clampNumber(
|
|
365
|
-
angle: this._normalizeDegrees(
|
|
360
|
+
enabled: s.enabled === !0,
|
|
361
|
+
color: this._supportedTextColor(s.color, E.shadow.color),
|
|
362
|
+
alpha: this._clampNumber(s.alpha, 0, 1, E.shadow.alpha),
|
|
363
|
+
blur: this._clampNumber(s.blur, 0, 120, E.shadow.blur),
|
|
364
|
+
distance: this._clampNumber(s.distance, 0, 200, E.shadow.distance),
|
|
365
|
+
angle: this._normalizeDegrees(s.angle ?? E.shadow.angle)
|
|
366
366
|
},
|
|
367
367
|
glow: {
|
|
368
|
-
enabled:
|
|
369
|
-
color: this._supportedTextColor(
|
|
370
|
-
alpha: this._clampNumber(
|
|
371
|
-
blur: this._clampNumber(
|
|
368
|
+
enabled: r.enabled === !0,
|
|
369
|
+
color: this._supportedTextColor(r.color, E.glow.color),
|
|
370
|
+
alpha: this._clampNumber(r.alpha, 0, 1, E.glow.alpha),
|
|
371
|
+
blur: this._clampNumber(r.blur, 0, 120, E.glow.blur)
|
|
372
372
|
},
|
|
373
373
|
backdrop: {
|
|
374
374
|
enabled: o.enabled === !0,
|
|
@@ -395,8 +395,8 @@ class Te extends se {
|
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
_textEffectPadding(e, t) {
|
|
398
|
-
const i = e.stroke.enabled ? e.stroke.width * t : 0,
|
|
399
|
-
return Math.ceil(Math.max(i,
|
|
398
|
+
const i = e.stroke.enabled ? e.stroke.width * t : 0, s = e.shadow.enabled ? (e.shadow.distance + e.shadow.blur * 2) * t : 0, r = e.glow.enabled ? e.glow.blur * 2 * t : 0, o = e.backdrop.enabled ? (e.backdrop.padding + e.backdrop.blur * 2) * t : 0;
|
|
399
|
+
return Math.ceil(Math.max(i, s, r, o, 0));
|
|
400
400
|
}
|
|
401
401
|
_createTextDisplayObjectForLayer(e, t) {
|
|
402
402
|
if (!this._isTextLayer(t) || typeof (e == null ? void 0 : e.Text) != "function") return null;
|
|
@@ -404,8 +404,8 @@ class Te extends se {
|
|
|
404
404
|
if (!i) return null;
|
|
405
405
|
if (typeof e.Container != "function" || typeof e.Graphics != "function")
|
|
406
406
|
return i;
|
|
407
|
-
const
|
|
408
|
-
return
|
|
407
|
+
const s = new e.Container(), r = new e.Graphics(), o = new e.Graphics(), n = new e.Graphics(), a = this._createTextPrimitive(e, t), l = this._createTextPrimitive(e, t);
|
|
408
|
+
return s.__isTextLayerContainer = !0, s.__textObject = i, s.__textMask = r, s.__textEffectMask = o, s.__textBackdrop = n, s.__textShadow = a, s.__textGlow = l, n.visible = !1, a && (a.visible = !1), l && (l.visible = !1), i.mask = r, s.addChild(n), a && s.addChild(a), l && s.addChild(l), s.addChild(i), s.addChild(o), s.addChild(r), s;
|
|
409
409
|
}
|
|
410
410
|
_createTextPrimitive(e, t) {
|
|
411
411
|
try {
|
|
@@ -426,12 +426,12 @@ class Te extends se {
|
|
|
426
426
|
return !i || i === this._loadedTextureUrl ? null : this._createImageDisplayObjectForLayer(e, t);
|
|
427
427
|
}
|
|
428
428
|
async _createImageDisplayObjectForLayer(e, t) {
|
|
429
|
-
var
|
|
429
|
+
var r, o;
|
|
430
430
|
if ((t == null ? void 0 : t.type) !== "image") return null;
|
|
431
431
|
const i = await this._textureForLayerSource(e, t.source);
|
|
432
432
|
if (!i || typeof e.Sprite != "function") return null;
|
|
433
|
-
const
|
|
434
|
-
return
|
|
433
|
+
const s = new e.Sprite(i);
|
|
434
|
+
return s.__sourceWidth = Number((r = t.source) == null ? void 0 : r.originalWidth) || i.width || 1, s.__sourceHeight = Number((o = t.source) == null ? void 0 : o.originalHeight) || i.height || 1, this._applyLayerEffects(e, s, t), this._applyLayerFilterInstances(s, t), s;
|
|
435
435
|
}
|
|
436
436
|
_backgroundFillForLayer(e) {
|
|
437
437
|
const t = e == null ? void 0 : e.fill;
|
|
@@ -458,29 +458,29 @@ class Te extends se {
|
|
|
458
458
|
async _textureForLayerSource(e, t) {
|
|
459
459
|
const i = this._sourceUrlForLayerSource(t);
|
|
460
460
|
if (!i) return null;
|
|
461
|
-
const
|
|
462
|
-
return
|
|
461
|
+
const s = await this._loadImageElement(i);
|
|
462
|
+
return s ? e.Texture.from(s) : null;
|
|
463
463
|
}
|
|
464
464
|
_createBackgroundSprite(e, t, i = "cover") {
|
|
465
465
|
if (i === "tile" && typeof e.TilingSprite == "function")
|
|
466
466
|
try {
|
|
467
|
-
const
|
|
468
|
-
return
|
|
467
|
+
const s = new e.TilingSprite({ texture: t, width: 1, height: 1 });
|
|
468
|
+
return s.__isTilingBackground = !0, s;
|
|
469
469
|
} catch {
|
|
470
470
|
try {
|
|
471
|
-
const
|
|
472
|
-
return
|
|
471
|
+
const r = new e.TilingSprite(t, 1, 1);
|
|
472
|
+
return r.__isTilingBackground = !0, r;
|
|
473
473
|
} catch {
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
return new e.Sprite(t);
|
|
477
477
|
}
|
|
478
|
-
_createGradientTexture(e, t, i,
|
|
478
|
+
_createGradientTexture(e, t, i, s) {
|
|
479
479
|
var l;
|
|
480
480
|
if (typeof document > "u" || !((l = e == null ? void 0 : e.Texture) != null && l.from)) return null;
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
const o =
|
|
481
|
+
const r = document.createElement("canvas");
|
|
482
|
+
r.width = Math.max(1, Math.round(i)), r.height = Math.max(1, Math.round(s));
|
|
483
|
+
const o = r.getContext("2d");
|
|
484
484
|
if (!o) return null;
|
|
485
485
|
const n = Array.isArray(t == null ? void 0 : t.stops) && t.stops.length > 0 ? t.stops : [
|
|
486
486
|
{ offset: 0, color: "#111827" },
|
|
@@ -488,42 +488,42 @@ class Te extends se {
|
|
|
488
488
|
];
|
|
489
489
|
let a;
|
|
490
490
|
if ((t == null ? void 0 : t.gradientType) === "radial") {
|
|
491
|
-
const h = Math.max(
|
|
491
|
+
const h = Math.max(r.width, r.height) / 2;
|
|
492
492
|
a = o.createRadialGradient(
|
|
493
|
-
|
|
494
|
-
|
|
493
|
+
r.width / 2,
|
|
494
|
+
r.height / 2,
|
|
495
495
|
0,
|
|
496
|
-
|
|
497
|
-
|
|
496
|
+
r.width / 2,
|
|
497
|
+
r.height / 2,
|
|
498
498
|
h
|
|
499
499
|
);
|
|
500
500
|
} else {
|
|
501
|
-
const h = (Number(t == null ? void 0 : t.angle) || 0) * Math.PI / 180, c =
|
|
502
|
-
a = o.createLinearGradient(c -
|
|
501
|
+
const h = (Number(t == null ? void 0 : t.angle) || 0) * Math.PI / 180, c = r.width / 2, p = r.height / 2, u = Math.sqrt(r.width ** 2 + r.height ** 2) / 2, f = Math.cos(h) * u, m = Math.sin(h) * u;
|
|
502
|
+
a = o.createLinearGradient(c - f, p - m, c + f, p + m);
|
|
503
503
|
}
|
|
504
504
|
for (const h of n) {
|
|
505
505
|
if (!h || typeof h.color != "string") continue;
|
|
506
506
|
const c = Number.isFinite(Number(h.offset)) ? Math.max(0, Math.min(1, Number(h.offset))) : 0;
|
|
507
507
|
a.addColorStop(c, h.color);
|
|
508
508
|
}
|
|
509
|
-
return o.fillStyle = a, o.fillRect(0, 0,
|
|
509
|
+
return o.fillStyle = a, o.fillRect(0, 0, r.width, r.height), e.Texture.from(r);
|
|
510
510
|
}
|
|
511
511
|
_backgroundBlurAmount(e) {
|
|
512
|
-
var
|
|
513
|
-
const i = (Array.isArray(e == null ? void 0 : e.effects) ? e.effects : []).find((o) => (o == null ? void 0 : o.id) === "background-blur" || (o == null ? void 0 : o.type) === "blur"),
|
|
514
|
-
return Number.isFinite(
|
|
512
|
+
var r;
|
|
513
|
+
const i = (Array.isArray(e == null ? void 0 : e.effects) ? e.effects : []).find((o) => (o == null ? void 0 : o.id) === "background-blur" || (o == null ? void 0 : o.type) === "blur"), s = Number((r = i == null ? void 0 : i.params) == null ? void 0 : r.amount);
|
|
514
|
+
return Number.isFinite(s) ? Math.max(0, s) : 0;
|
|
515
515
|
}
|
|
516
516
|
_applyLayerEffects(e, t, i) {
|
|
517
|
-
const
|
|
518
|
-
if (!(
|
|
517
|
+
const s = this._backgroundBlurAmount(i);
|
|
518
|
+
if (!(s <= 0 || typeof (e == null ? void 0 : e.BlurFilter) != "function"))
|
|
519
519
|
try {
|
|
520
|
-
let
|
|
520
|
+
let r;
|
|
521
521
|
try {
|
|
522
|
-
|
|
522
|
+
r = new e.BlurFilter({ strength: s, quality: 4 });
|
|
523
523
|
} catch {
|
|
524
|
-
|
|
524
|
+
r = new e.BlurFilter(s);
|
|
525
525
|
}
|
|
526
|
-
typeof
|
|
526
|
+
typeof r.blur == "number" && (r.blur = s), typeof r.strength == "number" && (r.strength = s), r.padding = Math.max(Number(r.padding) || 0, Math.ceil(s * 2)), t.filters = Array.isArray(t.filters) ? [...t.filters, r] : [r];
|
|
527
527
|
} catch {
|
|
528
528
|
}
|
|
529
529
|
}
|
|
@@ -563,11 +563,11 @@ class Te extends se {
|
|
|
563
563
|
e.fill(t), e.alpha = i;
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
|
-
_syncTextEffectPrimitive(e, t, i,
|
|
566
|
+
_syncTextEffectPrimitive(e, t, i, s, r, o, n, a) {
|
|
567
567
|
if (!t) return;
|
|
568
|
-
const l = r
|
|
568
|
+
const l = s[r];
|
|
569
569
|
if (t.visible = (l == null ? void 0 : l.enabled) === !0, t.filters = null, t.mask = t.visible ? a : null, !!t.visible) {
|
|
570
|
-
if (t.text = this._textContentForLayer(i), t.rotation = 0,
|
|
570
|
+
if (t.text = this._textContentForLayer(i), t.rotation = 0, r === "shadow") {
|
|
571
571
|
const h = l.angle * Math.PI / 180;
|
|
572
572
|
t.x = Math.cos(h) * l.distance * o, t.y = Math.sin(h) * l.distance * o, t.alpha = l.alpha, t.style = this._textStyleForLayer(i, o, n, {
|
|
573
573
|
fill: l.color,
|
|
@@ -577,7 +577,7 @@ class Te extends se {
|
|
|
577
577
|
t.filters = c ? [c] : null;
|
|
578
578
|
return;
|
|
579
579
|
}
|
|
580
|
-
if (
|
|
580
|
+
if (r === "glow") {
|
|
581
581
|
t.x = 0, t.y = 0, t.alpha = l.alpha, t.style = this._textStyleForLayer(i, o, n, {
|
|
582
582
|
fill: l.color,
|
|
583
583
|
stroke: !1
|
|
@@ -587,64 +587,64 @@ class Te extends se {
|
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
|
-
_syncTextBackdrop(e, t, i,
|
|
590
|
+
_syncTextBackdrop(e, t, i, s, r, o, n) {
|
|
591
591
|
if (!t) return;
|
|
592
592
|
const a = i.backdrop;
|
|
593
593
|
if (t.visible = a.enabled === !0, t.filters = null, t.mask = t.visible ? n : null, t.alpha = 1, typeof t.clear == "function" && t.clear(), !t.visible) return;
|
|
594
|
-
const l = a.padding *
|
|
595
|
-
h > 0 && typeof t.roundRect == "function" ? t.roundRect(c,
|
|
596
|
-
const m = this._createTextBlurFilter(e, a.blur *
|
|
594
|
+
const l = a.padding * s, h = a.radius * s, c = -l, p = -l, u = r + l * 2, f = o + l * 2;
|
|
595
|
+
h > 0 && typeof t.roundRect == "function" ? t.roundRect(c, p, u, f, h) : typeof t.rect == "function" && t.rect(c, p, u, f), this._fillTextEffectGraphics(t, a.color, a.opacity);
|
|
596
|
+
const m = this._createTextBlurFilter(e, a.blur * s);
|
|
597
597
|
t.filters = m ? [m] : null;
|
|
598
598
|
}
|
|
599
599
|
_fitTextDisplayObjectToRect(e, t, i) {
|
|
600
600
|
var m, b;
|
|
601
|
-
const
|
|
602
|
-
e.x =
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
605
|
-
const
|
|
606
|
-
|
|
601
|
+
const s = this._normalizeTextBox(t), r = i.x + s.x * i.width, o = i.y + s.y * i.height, n = s.width * i.width, a = s.height * i.height, l = Number((m = this.originalTexture) == null ? void 0 : m.width) || i.width, h = l > 0 ? i.width / l : 1, c = this._textEffectsForLayer(t);
|
|
602
|
+
e.x = r, e.y = o, e.rotation = this._normalizeDegrees(Number((b = t == null ? void 0 : t.transform) == null ? void 0 : b.rotation) || 0) * Math.PI / 180, e.blendMode = this._textBlendMode(t), e.__textBox = s, e.__textLayout = { x: r, y: o, width: n, height: a, scale: h };
|
|
603
|
+
const p = e.__textObject || e, u = e.__textMask || null, f = e.__textEffectMask || null;
|
|
604
|
+
if (p.text = this._textContentForLayer(t), p.style = this._textStyleForLayer(t, h, n), p.x = 0, p.y = 0, p.rotation = 0, u && typeof u.clear == "function" && typeof u.rect == "function" && typeof u.fill == "function" && (u.clear(), u.rect(0, 0, n, a).fill(16777215), p.mask = u), f && typeof f.clear == "function" && typeof f.rect == "function" && typeof f.fill == "function") {
|
|
605
|
+
const k = this._textEffectPadding(c, h);
|
|
606
|
+
f.clear(), f.rect(-k, -k, n + k * 2, a + k * 2).fill(16777215);
|
|
607
607
|
}
|
|
608
|
-
this._syncTextBackdrop(window.PIXI, e.__textBackdrop, c, h, n, a,
|
|
608
|
+
this._syncTextBackdrop(window.PIXI, e.__textBackdrop, c, h, n, a, f), this._syncTextEffectPrimitive(window.PIXI, e.__textShadow, t, c, "shadow", h, n, f), this._syncTextEffectPrimitive(window.PIXI, e.__textGlow, t, c, "glow", h, n, f);
|
|
609
609
|
}
|
|
610
610
|
_fitDisplayObjectToRect(e, t, i) {
|
|
611
|
-
var c,
|
|
612
|
-
const
|
|
611
|
+
var c, p, u, f, m, b, k, x;
|
|
612
|
+
const s = this._backgroundFillForLayer(t), r = (s == null ? void 0 : s.fit) || "cover";
|
|
613
613
|
if (e.__isTilingBackground) {
|
|
614
|
-
e.x = i.x, e.y = i.y, e.width = i.width, e.height = i.height, (
|
|
614
|
+
e.x = i.x, e.y = i.y, e.width = i.width, e.height = i.height, (p = (c = e.tilePosition) == null ? void 0 : c.set) == null || p.call(c, 0, 0), (f = (u = e.tileScale) == null ? void 0 : u.set) == null || f.call(u, 1, 1);
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
617
|
-
if (
|
|
617
|
+
if (r === "stretch" || (s == null ? void 0 : s.kind) === "gradient" || (s == null ? void 0 : s.kind) === "color") {
|
|
618
618
|
e.x = i.x, e.y = i.y, e.width = i.width, e.height = i.height;
|
|
619
619
|
return;
|
|
620
620
|
}
|
|
621
|
-
const o = Number(e.__sourceWidth || ((m =
|
|
621
|
+
const o = Number(e.__sourceWidth || ((m = s == null ? void 0 : s.source) == null ? void 0 : m.originalWidth) || ((b = e.texture) == null ? void 0 : b.width) || i.width), n = Number(e.__sourceHeight || ((k = s == null ? void 0 : s.source) == null ? void 0 : k.originalHeight) || ((x = e.texture) == null ? void 0 : x.height) || i.height);
|
|
622
622
|
if (!Number.isFinite(o) || !Number.isFinite(n) || o <= 0 || n <= 0) {
|
|
623
623
|
e.x = i.x, e.y = i.y, e.width = i.width, e.height = i.height;
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
626
|
-
const a =
|
|
626
|
+
const a = r === "contain" ? Math.min(i.width / o, i.height / n) : Math.max(i.width / o, i.height / n), l = o * a, h = n * a;
|
|
627
627
|
e.x = i.x + (i.width - l) / 2, e.y = i.y + (i.height - h) / 2, e.width = l, e.height = h;
|
|
628
628
|
}
|
|
629
629
|
_destroyLayerDisplayObjects() {
|
|
630
|
-
var e, t, i,
|
|
630
|
+
var e, t, i, s, r;
|
|
631
631
|
if ((e = this._layerDisplayObjects) != null && e.size) {
|
|
632
632
|
for (const { displayObject: o } of this._layerDisplayObjects.values()) {
|
|
633
633
|
try {
|
|
634
|
-
(
|
|
634
|
+
(s = (i = (t = this.app) == null ? void 0 : t.stage) == null ? void 0 : i.removeChild) == null || s.call(i, o);
|
|
635
635
|
} catch {
|
|
636
636
|
}
|
|
637
637
|
const n = (o == null ? void 0 : o.__ownsTexture) === !0;
|
|
638
|
-
(
|
|
638
|
+
(r = o == null ? void 0 : o.destroy) == null || r.call(o, { children: !0, texture: n, textureSource: n });
|
|
639
639
|
}
|
|
640
640
|
this._layerDisplayObjects.clear(), this._renderableLayerIds = [];
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
643
|
_destroyTransientDisplayObject(e) {
|
|
644
|
-
var i,
|
|
644
|
+
var i, s, r, o;
|
|
645
645
|
if (!e) return;
|
|
646
646
|
try {
|
|
647
|
-
(
|
|
647
|
+
(r = (s = (i = this.app) == null ? void 0 : i.stage) == null ? void 0 : s.removeChild) == null || r.call(s, e);
|
|
648
648
|
} catch {
|
|
649
649
|
}
|
|
650
650
|
const t = (e == null ? void 0 : e.__ownsTexture) === !0;
|
|
@@ -668,13 +668,13 @@ class Te extends se {
|
|
|
668
668
|
* @returns {{ width: number, height: number }}
|
|
669
669
|
*/
|
|
670
670
|
getRotatedBounds(e, t, i) {
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
671
|
+
const s = this._normalizeDegrees(i);
|
|
672
|
+
if (s === 0)
|
|
673
673
|
return {
|
|
674
674
|
width: Math.max(1, Math.round(e)),
|
|
675
675
|
height: Math.max(1, Math.round(t))
|
|
676
676
|
};
|
|
677
|
-
const
|
|
677
|
+
const r = s * Math.PI / 180, o = Math.abs(Math.cos(r)), n = Math.abs(Math.sin(r)), a = o < 1e-10 ? 0 : o, l = n < 1e-10 ? 0 : n;
|
|
678
678
|
return {
|
|
679
679
|
width: Math.max(1, Math.ceil(e * a + t * l)),
|
|
680
680
|
height: Math.max(1, Math.ceil(e * l + t * a))
|
|
@@ -689,15 +689,15 @@ class Te extends se {
|
|
|
689
689
|
* @returns {boolean}
|
|
690
690
|
*/
|
|
691
691
|
rotateBy(e) {
|
|
692
|
-
var m, b,
|
|
692
|
+
var m, b, k;
|
|
693
693
|
const t = this._normalizeDegrees(e);
|
|
694
694
|
if (t === 0) return !0;
|
|
695
695
|
if (!((m = this.app) != null && m.renderer) || !this.originalTexture || !this.sprite)
|
|
696
696
|
return !1;
|
|
697
|
-
const i = window.PIXI,
|
|
698
|
-
if (
|
|
699
|
-
const { width: o, height: n } = this.getRotatedBounds(
|
|
700
|
-
(
|
|
697
|
+
const i = window.PIXI, s = Math.round(this.originalTexture.width), r = Math.round(this.originalTexture.height);
|
|
698
|
+
if (s <= 0 || r <= 0) return !1;
|
|
699
|
+
const { width: o, height: n } = this.getRotatedBounds(s, r, t), a = t * Math.PI / 180, l = new i.Container(), h = new i.Sprite(this.originalTexture);
|
|
700
|
+
(k = (b = h.anchor) == null ? void 0 : b.set) == null || k.call(b, 0.5), h.x = o / 2, h.y = n / 2, h.rotation = a, l.addChild(h);
|
|
701
701
|
const c = i.RenderTexture.create({ width: o, height: n, resolution: 1 });
|
|
702
702
|
try {
|
|
703
703
|
this.app.renderer.render({
|
|
@@ -711,10 +711,10 @@ class Te extends se {
|
|
|
711
711
|
} finally {
|
|
712
712
|
l.removeChildren(), h.destroy({ children: !1, texture: !1, textureSource: !1 }), l.destroy({ children: !1 });
|
|
713
713
|
}
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
return
|
|
714
|
+
const p = this.originalTexture, u = Array.isArray(this.sprite.filters) ? [...this.sprite.filters] : null;
|
|
715
|
+
p && p !== this.baseTexture && p.destroy(!0), this.originalTexture = c, this._lastExportDimensions = null, this.app.stage.removeChild(this.sprite), this.sprite.destroy({ children: !1, texture: !1, textureSource: !1 });
|
|
716
|
+
const f = new i.Sprite(c);
|
|
717
|
+
return u != null && u.length && (f.filters = u), this.app.stage.addChild(f), this.sprite = f, this.fitScale = this.getFitScaleFor(c), this.zoom = 1, this.applyViewTransform({ keepCenter: !1 }), this.render(), this.emit("textureRotated", { width: o, height: n, degrees: t }), !0;
|
|
718
718
|
}
|
|
719
719
|
/**
|
|
720
720
|
* Export the current image with filters applied.
|
|
@@ -728,9 +728,9 @@ class Te extends se {
|
|
|
728
728
|
* to keep the export under that cap while preserving aspect ratio.
|
|
729
729
|
* @returns {string|null} Data URL
|
|
730
730
|
*/
|
|
731
|
-
exportImage(e = "png", t = 0.92, i = 0,
|
|
732
|
-
var
|
|
733
|
-
if (!((
|
|
731
|
+
exportImage(e = "png", t = 0.92, i = 0, s = !0, r = 0) {
|
|
732
|
+
var S;
|
|
733
|
+
if (!((S = this.app) != null && S.renderer) || !this.originalTexture || !this.sprite)
|
|
734
734
|
return null;
|
|
735
735
|
const o = window.PIXI, n = Math.round(this.originalTexture.width), a = Math.round(this.originalTexture.height);
|
|
736
736
|
if (n <= 0 || a <= 0)
|
|
@@ -738,12 +738,12 @@ class Te extends se {
|
|
|
738
738
|
const l = this.sprite.width, h = this.sprite.height;
|
|
739
739
|
if (l <= 0 || h <= 0)
|
|
740
740
|
return null;
|
|
741
|
-
const c = l / n,
|
|
742
|
-
if (!
|
|
741
|
+
const c = l / n, p = c > 0 ? 1 / c : 1, u = this._layerDocument, f = u && Array.isArray(u.layers), m = [];
|
|
742
|
+
if (!f && Array.isArray(this.sprite.filters)) {
|
|
743
743
|
for (const y of this.sprite.filters)
|
|
744
744
|
if (y)
|
|
745
745
|
if (typeof y.createExportFilter == "function") {
|
|
746
|
-
const w = y.createExportFilter({ previewToNativeScale:
|
|
746
|
+
const w = y.createExportFilter({ previewToNativeScale: p });
|
|
747
747
|
w && m.push(w);
|
|
748
748
|
} else
|
|
749
749
|
m.push(y);
|
|
@@ -753,125 +753,125 @@ class Te extends se {
|
|
|
753
753
|
const w = typeof y.getExportPadding == "function" ? Number(y.getExportPadding()) || 0 : typeof y._exportPadding == "number" ? y._exportPadding : typeof y.padding == "number" ? y.padding : 0;
|
|
754
754
|
w > 0 && (b += w);
|
|
755
755
|
}
|
|
756
|
-
const
|
|
756
|
+
const k = Math.max(Math.ceil(b), 64), x = (y) => {
|
|
757
757
|
var Q, X, L, ee;
|
|
758
|
-
const w = Math.ceil(n + 2 * y),
|
|
758
|
+
const w = Math.ceil(n + 2 * y), R = Math.ceil(a + 2 * y), M = new o.Container(), N = [], z = (_ = null) => {
|
|
759
759
|
const v = new o.Sprite(this.originalTexture);
|
|
760
760
|
v.x = y, v.y = y, v.scale.set(1, 1), v.alpha = _ ? this._layerOpacity(_) : 1, _ && this._applyLayerFilterInstances(v, _, {
|
|
761
761
|
forExport: !0,
|
|
762
|
-
previewToNativeScale:
|
|
762
|
+
previewToNativeScale: p,
|
|
763
763
|
sourceWidth: n,
|
|
764
764
|
sourceHeight: a
|
|
765
|
-
}), m.length > 0 && (v.filters = m, v.filterArea = new o.Rectangle(0, 0, n, a)),
|
|
766
|
-
},
|
|
767
|
-
var
|
|
768
|
-
const v = (
|
|
765
|
+
}), m.length > 0 && (v.filters = m, v.filterArea = new o.Rectangle(0, 0, n, a)), M.addChild(v), N.push(v);
|
|
766
|
+
}, F = (_) => {
|
|
767
|
+
var Y, P, U;
|
|
768
|
+
const v = (Y = this._layerDisplayObjects.get(_.id)) == null ? void 0 : Y.displayObject, H = this._isSubjectLayer(_), I = (v == null ? void 0 : v.texture) || (H ? this.originalTexture : null);
|
|
769
769
|
if (!I || typeof o.Sprite != "function") return !1;
|
|
770
|
-
const
|
|
771
|
-
return
|
|
770
|
+
const C = new o.Sprite(I), te = (v == null ? void 0 : v.__sourceWidth) || (H ? null : (P = _.source) == null ? void 0 : P.originalWidth) || I.width || n, ie = (v == null ? void 0 : v.__sourceHeight) || (H ? null : (U = _.source) == null ? void 0 : U.originalHeight) || I.height || a;
|
|
771
|
+
return C.__sourceWidth = Number(te), C.__sourceHeight = Number(ie), this._fitDisplayObjectToRect(C, _, { x: y, y, width: n, height: a }), C.alpha = this._layerOpacity(_), !f && H && m.length > 0 && (C.filters = m, C.filterArea = new o.Rectangle(0, 0, n, a)), this._applyLayerEffects(o, C, _), this._applyLayerFilterInstances(C, _, {
|
|
772
772
|
forExport: !0,
|
|
773
|
-
previewToNativeScale:
|
|
773
|
+
previewToNativeScale: p,
|
|
774
774
|
sourceWidth: n,
|
|
775
775
|
sourceHeight: a
|
|
776
|
-
}),
|
|
776
|
+
}), M.addChild(C), N.push(C), !0;
|
|
777
777
|
}, T = (_) => {
|
|
778
|
-
var
|
|
779
|
-
const v = this._backgroundFillForLayer(_),
|
|
780
|
-
let
|
|
781
|
-
if (
|
|
782
|
-
|
|
778
|
+
var te, ie, Y;
|
|
779
|
+
const v = this._backgroundFillForLayer(_), H = this._backgroundColorForLayer(_), I = { x: y, y, width: n, height: a };
|
|
780
|
+
let C = null;
|
|
781
|
+
if (H && typeof o.Graphics == "function")
|
|
782
|
+
C = new o.Graphics(), C.rect(y, y, n, a).fill(H);
|
|
783
783
|
else if ((v == null ? void 0 : v.kind) === "gradient" && typeof o.Sprite == "function") {
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
786
|
-
|
|
784
|
+
const P = this._createGradientTexture(o, v, n, a);
|
|
785
|
+
if (!P) return !1;
|
|
786
|
+
C = new o.Sprite(P), C.__ownsTexture = !0, C.__sourceWidth = n, C.__sourceHeight = a, this._fitDisplayObjectToRect(C, _, I);
|
|
787
787
|
} else if ((v == null ? void 0 : v.kind) === "media") {
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
790
|
-
|
|
788
|
+
const P = (te = this._layerDisplayObjects.get(_.id)) == null ? void 0 : te.displayObject, U = P == null ? void 0 : P.texture;
|
|
789
|
+
if (!U) return !1;
|
|
790
|
+
C = this._createBackgroundSprite(o, U, v.fit), C.__sourceWidth = Number(((ie = v.source) == null ? void 0 : ie.originalWidth) || P.__sourceWidth || U.width || 1), C.__sourceHeight = Number(((Y = v.source) == null ? void 0 : Y.originalHeight) || P.__sourceHeight || U.height || 1), this._fitDisplayObjectToRect(C, _, I);
|
|
791
791
|
}
|
|
792
|
-
return
|
|
792
|
+
return C ? (C.alpha = this._layerOpacity(_), this._applyLayerEffects(o, C, _), this._applyLayerFilterInstances(C, _, {
|
|
793
793
|
forExport: !0,
|
|
794
|
-
previewToNativeScale:
|
|
794
|
+
previewToNativeScale: p,
|
|
795
795
|
sourceWidth: n,
|
|
796
796
|
sourceHeight: a
|
|
797
|
-
}),
|
|
798
|
-
},
|
|
797
|
+
}), M.addChild(C), N.push(C), !0) : !1;
|
|
798
|
+
}, O = (_) => {
|
|
799
799
|
const v = this._createTextDisplayObjectForLayer(o, _);
|
|
800
|
-
return v ? (this._fitTextDisplayObjectToRect(v, _, { x: y, y, width: n, height: a }), v.alpha = this._layerOpacity(_),
|
|
801
|
-
},
|
|
802
|
-
if (
|
|
803
|
-
for (const _ of
|
|
800
|
+
return v ? (this._fitTextDisplayObjectToRect(v, _, { x: y, y, width: n, height: a }), v.alpha = this._layerOpacity(_), M.addChild(v), N.push(v), !0) : !1;
|
|
801
|
+
}, W = u, G = f;
|
|
802
|
+
if (G) {
|
|
803
|
+
for (const _ of W.layers)
|
|
804
804
|
if (!(!_ || _.visible === !1)) {
|
|
805
805
|
if (this._isTextLayer(_)) {
|
|
806
|
-
|
|
806
|
+
O(_);
|
|
807
807
|
continue;
|
|
808
808
|
}
|
|
809
809
|
if (_.type === "image") {
|
|
810
|
-
!
|
|
810
|
+
!F(_) && this._isSubjectLayer(_) && z(_);
|
|
811
811
|
continue;
|
|
812
812
|
}
|
|
813
813
|
if (this._isSubjectLayer(_)) {
|
|
814
|
-
|
|
814
|
+
F(_) || z(_);
|
|
815
815
|
continue;
|
|
816
816
|
}
|
|
817
817
|
T(_);
|
|
818
818
|
}
|
|
819
819
|
} else
|
|
820
|
-
|
|
821
|
-
!
|
|
822
|
-
const
|
|
820
|
+
z();
|
|
821
|
+
!G && ((Q = M.children) == null ? void 0 : Q.length) === 0 && z();
|
|
822
|
+
const K = o.RenderTexture.create({
|
|
823
823
|
width: w,
|
|
824
|
-
height:
|
|
824
|
+
height: R,
|
|
825
825
|
resolution: 1
|
|
826
|
-
}),
|
|
826
|
+
}), oe = ((X = M.children) == null ? void 0 : X.length) ?? 0;
|
|
827
827
|
try {
|
|
828
828
|
this.app.renderer.render({
|
|
829
|
-
container:
|
|
830
|
-
target:
|
|
829
|
+
container: M,
|
|
830
|
+
target: K,
|
|
831
831
|
clear: !0,
|
|
832
832
|
clearColor: [0, 0, 0, 0]
|
|
833
833
|
});
|
|
834
|
-
const _ = (ee = (L = this.app.renderer.extract) == null ? void 0 : L.canvas) == null ? void 0 : ee.call(L,
|
|
835
|
-
return _ ? { canvas: _, width: w, height:
|
|
834
|
+
const _ = (ee = (L = this.app.renderer.extract) == null ? void 0 : L.canvas) == null ? void 0 : ee.call(L, K);
|
|
835
|
+
return _ ? { canvas: _, width: w, height: R, margin: y, childCount: oe } : null;
|
|
836
836
|
} finally {
|
|
837
837
|
for (const _ of N)
|
|
838
838
|
_.filters = null;
|
|
839
|
-
|
|
839
|
+
M.removeChildren();
|
|
840
840
|
for (const _ of N) {
|
|
841
841
|
const v = (_ == null ? void 0 : _.__ownsTexture) === !0;
|
|
842
842
|
_.destroy({ children: !1, texture: v, textureSource: v });
|
|
843
843
|
}
|
|
844
|
-
|
|
844
|
+
M.destroy({ children: !1 }), K.destroy(!0);
|
|
845
845
|
}
|
|
846
|
-
}, B = (y, w,
|
|
847
|
-
const
|
|
848
|
-
if (!
|
|
846
|
+
}, B = (y, w, R) => {
|
|
847
|
+
const M = typeof y.getContext == "function" ? y.getContext("2d") : null;
|
|
848
|
+
if (!M) return null;
|
|
849
849
|
let N;
|
|
850
850
|
try {
|
|
851
|
-
N =
|
|
851
|
+
N = M.getImageData(0, 0, w, R).data;
|
|
852
852
|
} catch {
|
|
853
853
|
return null;
|
|
854
854
|
}
|
|
855
|
-
const
|
|
856
|
-
let
|
|
857
|
-
const
|
|
858
|
-
for (let L = 0; L <
|
|
859
|
-
const ee = L *
|
|
855
|
+
const z = 1;
|
|
856
|
+
let F = w, T = R, O = -1, W = -1;
|
|
857
|
+
const G = 4, K = w * G;
|
|
858
|
+
for (let L = 0; L < R; L++) {
|
|
859
|
+
const ee = L * K;
|
|
860
860
|
for (let _ = 0; _ < w; _++)
|
|
861
|
-
N[ee + _ *
|
|
861
|
+
N[ee + _ * G + 3] >= z && (_ < F && (F = _), _ > O && (O = _), L < T && (T = L), L > W && (W = L));
|
|
862
862
|
}
|
|
863
|
-
if (
|
|
864
|
-
const
|
|
865
|
-
return { x:
|
|
863
|
+
if (O < 0) return null;
|
|
864
|
+
const oe = O - F + 1, Q = W - T + 1, X = F === 0 || T === 0 || O === w - 1 || W === R - 1;
|
|
865
|
+
return { x: F, y: T, width: oe, height: Q, touchesEdge: X };
|
|
866
866
|
};
|
|
867
867
|
let A = null;
|
|
868
868
|
try {
|
|
869
|
-
let y = x(
|
|
869
|
+
let y = x(k);
|
|
870
870
|
if (!y)
|
|
871
871
|
return null;
|
|
872
872
|
let w = B(y.canvas, y.width, y.height);
|
|
873
873
|
if (!w)
|
|
874
|
-
if (
|
|
874
|
+
if (f && y.childCount === 0)
|
|
875
875
|
w = {
|
|
876
876
|
x: y.margin,
|
|
877
877
|
y: y.margin,
|
|
@@ -881,27 +881,27 @@ class Te extends se {
|
|
|
881
881
|
};
|
|
882
882
|
else
|
|
883
883
|
return null;
|
|
884
|
-
if (w.touchesEdge &&
|
|
885
|
-
const
|
|
884
|
+
if (w.touchesEdge && k < n && k < a) {
|
|
885
|
+
const F = Math.max(k * 4, 256), T = x(F);
|
|
886
886
|
if (T) {
|
|
887
|
-
const
|
|
888
|
-
|
|
887
|
+
const O = B(T.canvas, T.width, T.height);
|
|
888
|
+
O && !O.touchesEdge ? (y = T, w = O) : (y = T, w = O ?? w);
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
|
-
let
|
|
891
|
+
let R = w.width, M = w.height;
|
|
892
892
|
if (i > 0) {
|
|
893
|
-
const
|
|
894
|
-
let T = i /
|
|
895
|
-
|
|
893
|
+
const F = Math.max(R, M);
|
|
894
|
+
let T = i / F;
|
|
895
|
+
s && (T = Math.min(1, T)), R = Math.max(1, Math.round(R * T)), M = Math.max(1, Math.round(M * T));
|
|
896
896
|
}
|
|
897
|
-
if (
|
|
898
|
-
const
|
|
899
|
-
|
|
897
|
+
if (r > 0 && R * M > r) {
|
|
898
|
+
const F = Math.sqrt(r / (R * M));
|
|
899
|
+
R = Math.max(1, Math.floor(R * F)), M = Math.max(1, Math.floor(M * F));
|
|
900
900
|
}
|
|
901
901
|
const N = document.createElement("canvas");
|
|
902
|
-
N.width =
|
|
903
|
-
const
|
|
904
|
-
return
|
|
902
|
+
N.width = R, N.height = M;
|
|
903
|
+
const z = N.getContext("2d");
|
|
904
|
+
return z ? (z.drawImage(
|
|
905
905
|
y.canvas,
|
|
906
906
|
w.x,
|
|
907
907
|
w.y,
|
|
@@ -909,9 +909,9 @@ class Te extends se {
|
|
|
909
909
|
w.height,
|
|
910
910
|
0,
|
|
911
911
|
0,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
), A = N.toDataURL(`image/${e}`, t), this._lastExportDimensions = { width:
|
|
912
|
+
R,
|
|
913
|
+
M
|
|
914
|
+
), A = N.toDataURL(`image/${e}`, t), this._lastExportDimensions = { width: R, height: M }, A || null) : null;
|
|
915
915
|
} catch {
|
|
916
916
|
return null;
|
|
917
917
|
}
|
|
@@ -931,17 +931,17 @@ class Te extends se {
|
|
|
931
931
|
if (this._lastExportDimensions)
|
|
932
932
|
return { ...this._lastExportDimensions };
|
|
933
933
|
const e = this.originalTexture, t = Math.round((e == null ? void 0 : e.width) || 0), i = Math.round((e == null ? void 0 : e.height) || 0);
|
|
934
|
-
let
|
|
935
|
-
const
|
|
936
|
-
if (Array.isArray(
|
|
937
|
-
for (const n of
|
|
934
|
+
let s = 0;
|
|
935
|
+
const r = (o = this.sprite) == null ? void 0 : o.filters;
|
|
936
|
+
if (Array.isArray(r))
|
|
937
|
+
for (const n of r) {
|
|
938
938
|
if (!n) continue;
|
|
939
939
|
const a = typeof n._exportPadding == "number" ? n._exportPadding : typeof n.padding == "number" ? n.padding : 0;
|
|
940
|
-
a >
|
|
940
|
+
a > s && (s = a);
|
|
941
941
|
}
|
|
942
942
|
return {
|
|
943
|
-
width: t + 2 *
|
|
944
|
-
height: i + 2 *
|
|
943
|
+
width: t + 2 * s,
|
|
944
|
+
height: i + 2 * s
|
|
945
945
|
};
|
|
946
946
|
}
|
|
947
947
|
/**
|
|
@@ -952,15 +952,15 @@ class Te extends se {
|
|
|
952
952
|
* @returns {Promise<{ blob: Blob, width: number, height: number } | null>}
|
|
953
953
|
*/
|
|
954
954
|
async exportBlob(e = "png", t = 0.92, i = {}) {
|
|
955
|
-
const
|
|
955
|
+
const s = this.exportImage(
|
|
956
956
|
e,
|
|
957
957
|
t,
|
|
958
958
|
i.maxEdge ?? 0,
|
|
959
959
|
i.dontUpscale !== !1,
|
|
960
960
|
i.maxPixels ?? 0
|
|
961
961
|
);
|
|
962
|
-
if (!
|
|
963
|
-
const o = await (await fetch(
|
|
962
|
+
if (!s) return null;
|
|
963
|
+
const o = await (await fetch(s)).blob(), n = this.getExportDimensions();
|
|
964
964
|
return { blob: o, width: n.width, height: n.height };
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
@@ -968,15 +968,15 @@ class Te extends se {
|
|
|
968
968
|
* @param {HTMLElement} container
|
|
969
969
|
*/
|
|
970
970
|
resizeTo(e) {
|
|
971
|
-
var
|
|
972
|
-
if (!((
|
|
971
|
+
var s;
|
|
972
|
+
if (!((s = this.app) != null && s.renderer) || !e) return;
|
|
973
973
|
const t = e.clientWidth, i = e.clientHeight;
|
|
974
974
|
if (!(t === Math.round(this.app.screen.width) && i === Math.round(this.app.screen.height)) && !(t <= 0 || i <= 0) && (this.app.renderer.resize(t, i), this.originalTexture && this.sprite)) {
|
|
975
|
-
const
|
|
975
|
+
const r = {
|
|
976
976
|
x: this.sprite.x + this.sprite.width / 2,
|
|
977
977
|
y: this.sprite.y + this.sprite.height / 2
|
|
978
978
|
};
|
|
979
|
-
this.fitScale = this.getFitScaleFor(this.originalTexture), this.applyViewTransform({ center:
|
|
979
|
+
this.fitScale = this.getFitScaleFor(this.originalTexture), this.applyViewTransform({ center: r });
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
982
|
/**
|
|
@@ -1015,7 +1015,7 @@ class Te extends se {
|
|
|
1015
1015
|
this.sprite = null, this.originalTexture = null, this.baseTexture = null, this._container = null, this.removeAllListeners();
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
|
-
const _e = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M328 112L184 256l144 144"/></svg>', me = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M184 112l144 144-144 144"/></svg>', gt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M256 184v74m-37-37h74"/></svg>', _t = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M184 221h74"/></svg>', mt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M432 320v112H320M80 192V80h112M320 80h112v112M192 432H80V320"/></svg>', Ae = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M262.29 192.31a64 64 0 1057.4 57.4 64.13 64.13 0 00-57.4-57.4z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416.39 256a154.34 154.34 0 01-1.53 20.79l45.21 35.46a10.81 10.81 0 012.45 13.75l-42.77 74a10.81 10.81 0 01-13.14 4.59l-44.9-18.08a16.11 16.11 0 00-15.17 1.75A164.48 164.48 0 01325 400.8a15.94 15.94 0 00-8.82 12.14l-6.73 47.89a11.08 11.08 0 01-10.68 9.17h-85.54a11.11 11.11 0 01-10.69-8.87l-6.72-47.82a16.07 16.07 0 00-9-12.22 155.3 155.3 0 01-21.46-12.57 16 16 0 00-15.11-1.71l-44.89 18.07a10.81 10.81 0 01-13.14-4.58l-42.77-74a10.8 10.8 0 012.45-13.75l38.21-30a16.05 16.05 0 006-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 00-6.07-13.94l-38.19-30A10.81 10.81 0 0149.48 186l42.77-74a10.81 10.81 0 0113.14-4.59l44.9 18.08a16.11 16.11 0 0015.17-1.75A164.48 164.48 0 01187 111.2a15.94 15.94 0 008.82-12.14l6.73-47.89A11.08 11.08 0 01213.23 42h85.54a11.11 11.11 0 0110.69 8.87l6.72 47.82a16.07 16.07 0 009 12.22 155.3 155.3 0 0121.46 12.57 16 16 0 0015.11 1.71l44.89-18.07a10.81 10.81 0 0113.14 4.58l42.77 74a10.8 10.8 0 01-2.45 13.75l-38.21 30a16.05 16.05 0 00-6.05 14.08c.33 4.14.55 8.3.55 12.47z"/></svg>', Ne = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M344 328a72 72 0 01-72 72"/></svg>', Be = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32" d="M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z"/><circle cx="144" cy="208" r="32"/><circle cx="152" cy="311" r="32"/><circle cx="224" cy="144" r="32"/><circle cx="256" cy="367" r="32"/><circle cx="328" cy="144" r="32"/></svg>', Ee = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z"/></svg>', Le = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M176 112l80-80 80 80M255.98 32l.02 448M176 400l80 80 80-80M400 176l80 80-80 80M112 176l-80 80 80 80M32 256h448"/></svg>', De = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M452.37 59.63h0a40.49 40.49 0 00-57.26 0L184 294.74c23.08 4.7 46.12 27.29 49.26 49.26l219.11-227.11a40.49 40.49 0 000-57.26z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M138 336c-29.88 0-54 24.5-54 54.86 0 23.95-20.67 36.57-34 44.78 15.08 8.08 32.23 12.36 50 12.36 48.49 0 88-38.89 88-88 0-30.36-24.12-54-50-54z"/></svg>', je = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z"/></svg>', be = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M144 48v272a48 48 0 0048 48h272"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 464V192a48 48 0 00-48-48H48"/></svg>', Oe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z"/></svg>', de = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 368L144 144M368 144L144 368"/></svg>', ye = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 146s24.36-12-64-12a160 160 0 10160 160"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 58l80 80-80 80"/></svg>', ze = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M176 112l-64 64 64 64"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M112 176h176a112 112 0 110 224H160"/></svg>', Pe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M336 112l64 64-64 64"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M400 176H224a112 112 0 100 224h128"/></svg>', He = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M80 112h352"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224"/></svg>', Ie = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M64 192v-72a40 40 0 0140-40h75.89a40 40 0 0122.19 6.72l27.84 18.56a40 40 0 0022.19 6.72H408a40 40 0 0140 40v40"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M479.9 226.55L463.68 392a40 40 0 01-39.93 40H88.25a40 40 0 01-39.93-40L32.1 226.55A32 32 0 0164 192h384.1a32 32 0 0131.8 34.55z"/></svg>', he = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg>', Ue = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 256l208 112 208-112-208-112L48 256z"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 336l208 112 208-112M48 176L256 64l208 112"/></svg>', bt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 256s80-144 208-144 208 144 208 144-80 144-208 144S48 256 48 256z"/><circle cx="256" cy="256" r="64" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>', yt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M432 448L80 64M160 160c-67.2 36.8-112 96-112 96s80 144 208 144c35.8 0 68.4-11.3 96-28.1M224.4 113.8A199.6 199.6 0 01256 112c128 0 208 144 208 144a334.2 334.2 0 01-65.1 78.6"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M213.3 213.3A64 64 0 10298.7 298.7"/></svg>', vt = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="96" y="208" width="320" height="240" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 208v-64a96 96 0 01192 0v64"/></svg>', wt = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="96" y="208" width="320" height="240" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 208v-64a96 96 0 01168-63.7"/></svg>', xt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M96 352l-32 96 96-32L421.5 154.5a45.3 45.3 0 000-64h0a45.3 45.3 0 00-64 0L96 352z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 128l64 64"/></svg>', Ct = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="144" y="144" width="288" height="288" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M80 368V112a32 32 0 0132-32h256"/></svg>', Ve = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M96 112V80h320v32M256 80v352M184 432h144"/></svg>', We = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="64" y="64" width="384" height="384" rx="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>', $e = '<svg viewBox="0 0 512 512" width="20" height="20"><circle cx="256" cy="256" r="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>', Ze = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M80 96h64l64 320h64l64-160h96"/></svg>', fe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32"/></svg>', ge = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 136c0-30.62 4.51-61.61 16-88C99.57 81.27 48 159.32 48 248c0 119.29 96.71 216 216 216 88.68 0 166.73-51.57 200-128-26.39 11.49-57.38 16-88 16-119.29 0-216-96.71-216-216z"/></svg>', qe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M436 80H76a44.05 44.05 0 00-44 44v264a44.05 44.05 0 0044 44h360a44.05 44.05 0 0044-44V124a44.05 44.05 0 00-44-44z"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M220 80v56M292 80v56M220 376v56M292 376v56M80 144h56M80 224h56M80 304h56M376 144h56M376 224h56M376 304h56"/></svg>', Ge = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z"/><path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32" d="M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z"/></svg>', ue = [
|
|
1018
|
+
const _e = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M328 112L184 256l144 144"/></svg>', me = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M184 112l144 144-144 144"/></svg>', gt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M256 184v74m-37-37h74"/></svg>', _t = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M184 221h74"/></svg>', mt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M432 320v112H320M80 192V80h112M320 80h112v112M192 432H80V320"/></svg>', Ae = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M262.29 192.31a64 64 0 1057.4 57.4 64.13 64.13 0 00-57.4-57.4z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416.39 256a154.34 154.34 0 01-1.53 20.79l45.21 35.46a10.81 10.81 0 012.45 13.75l-42.77 74a10.81 10.81 0 01-13.14 4.59l-44.9-18.08a16.11 16.11 0 00-15.17 1.75A164.48 164.48 0 01325 400.8a15.94 15.94 0 00-8.82 12.14l-6.73 47.89a11.08 11.08 0 01-10.68 9.17h-85.54a11.11 11.11 0 01-10.69-8.87l-6.72-47.82a16.07 16.07 0 00-9-12.22 155.3 155.3 0 01-21.46-12.57 16 16 0 00-15.11-1.71l-44.89 18.07a10.81 10.81 0 01-13.14-4.58l-42.77-74a10.8 10.8 0 012.45-13.75l38.21-30a16.05 16.05 0 006-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 00-6.07-13.94l-38.19-30A10.81 10.81 0 0149.48 186l42.77-74a10.81 10.81 0 0113.14-4.59l44.9 18.08a16.11 16.11 0 0015.17-1.75A164.48 164.48 0 01187 111.2a15.94 15.94 0 008.82-12.14l6.73-47.89A11.08 11.08 0 01213.23 42h85.54a11.11 11.11 0 0110.69 8.87l6.72 47.82a16.07 16.07 0 009 12.22 155.3 155.3 0 0121.46 12.57 16 16 0 0015.11 1.71l44.89-18.07a10.81 10.81 0 0113.14 4.58l42.77 74a10.8 10.8 0 01-2.45 13.75l-38.21 30a16.05 16.05 0 00-6.05 14.08c.33 4.14.55 8.3.55 12.47z"/></svg>', Ne = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M344 328a72 72 0 01-72 72"/></svg>', Be = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32" d="M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z"/><circle cx="144" cy="208" r="32"/><circle cx="152" cy="311" r="32"/><circle cx="224" cy="144" r="32"/><circle cx="256" cy="367" r="32"/><circle cx="328" cy="144" r="32"/></svg>', Ee = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z"/></svg>', Le = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M176 112l80-80 80 80M255.98 32l.02 448M176 400l80 80 80-80M400 176l80 80-80 80M112 176l-80 80 80 80M32 256h448"/></svg>', De = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M452.37 59.63h0a40.49 40.49 0 00-57.26 0L184 294.74c23.08 4.7 46.12 27.29 49.26 49.26l219.11-227.11a40.49 40.49 0 000-57.26z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M138 336c-29.88 0-54 24.5-54 54.86 0 23.95-20.67 36.57-34 44.78 15.08 8.08 32.23 12.36 50 12.36 48.49 0 88-38.89 88-88 0-30.36-24.12-54-50-54z"/></svg>', je = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z"/></svg>', be = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M144 48v272a48 48 0 0048 48h272"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 464V192a48 48 0 00-48-48H48"/></svg>', Oe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z"/></svg>', ue = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 368L144 144M368 144L144 368"/></svg>', ye = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 146s24.36-12-64-12a160 160 0 10160 160"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 58l80 80-80 80"/></svg>', ze = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M176 112l-64 64 64 64"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M112 176h176a112 112 0 110 224H160"/></svg>', Pe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M336 112l64 64-64 64"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M400 176H224a112 112 0 100 224h128"/></svg>', He = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M80 112h352"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224"/></svg>', Ie = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M64 192v-72a40 40 0 0140-40h75.89a40 40 0 0122.19 6.72l27.84 18.56a40 40 0 0022.19 6.72H408a40 40 0 0140 40v40"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M479.9 226.55L463.68 392a40 40 0 01-39.93 40H88.25a40 40 0 01-39.93-40L32.1 226.55A32 32 0 0164 192h384.1a32 32 0 0131.8 34.55z"/></svg>', ce = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg>', Ue = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 256l208 112 208-112-208-112L48 256z"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 336l208 112 208-112M48 176L256 64l208 112"/></svg>', bt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M48 256s80-144 208-144 208 144 208 144-80 144-208 144S48 256 48 256z"/><circle cx="256" cy="256" r="64" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>', yt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M432 448L80 64M160 160c-67.2 36.8-112 96-112 96s80 144 208 144c35.8 0 68.4-11.3 96-28.1M224.4 113.8A199.6 199.6 0 01256 112c128 0 208 144 208 144a334.2 334.2 0 01-65.1 78.6"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M213.3 213.3A64 64 0 10298.7 298.7"/></svg>', vt = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="96" y="208" width="320" height="240" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 208v-64a96 96 0 01192 0v64"/></svg>', wt = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="96" y="208" width="320" height="240" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 208v-64a96 96 0 01168-63.7"/></svg>', xt = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M96 352l-32 96 96-32L421.5 154.5a45.3 45.3 0 000-64h0a45.3 45.3 0 00-64 0L96 352z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 128l64 64"/></svg>', Ct = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="144" y="144" width="288" height="288" rx="32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32" d="M80 368V112a32 32 0 0132-32h256"/></svg>', Ve = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M96 112V80h320v32M256 80v352M184 432h144"/></svg>', We = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="64" y="64" width="384" height="384" rx="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>', $e = '<svg viewBox="0 0 512 512" width="20" height="20"><circle cx="256" cy="256" r="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>', Ze = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M80 96h64l64 320h64l64-160h96"/></svg>', fe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32"/></svg>', ge = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 136c0-30.62 4.51-61.61 16-88C99.57 81.27 48 159.32 48 248c0 119.29 96.71 216 216 216 88.68 0 166.73-51.57 200-128-26.39 11.49-57.38 16-88 16-119.29 0-216-96.71-216-216z"/></svg>', qe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M436 80H76a44.05 44.05 0 00-44 44v264a44.05 44.05 0 0044 44h360a44.05 44.05 0 0044-44V124a44.05 44.05 0 00-44-44z"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M220 80v56M292 80v56M220 376v56M292 376v56M80 144h56M80 224h56M80 304h56M376 144h56M376 224h56M376 304h56"/></svg>', Ge = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z"/><path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32" d="M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z"/></svg>', pe = [
|
|
1019
1019
|
{
|
|
1020
1020
|
id: "adjust",
|
|
1021
1021
|
name: "Adjust",
|
|
@@ -1080,14 +1080,14 @@ const _e = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none"
|
|
|
1080
1080
|
icon: be
|
|
1081
1081
|
}
|
|
1082
1082
|
], Ke = Object.fromEntries(
|
|
1083
|
-
|
|
1083
|
+
pe.filter((g) => Array.isArray(g.registryCategories) && g.registryCategories.length > 0).map((g) => [g.id, g.registryCategories])
|
|
1084
1084
|
), Ye = Object.fromEntries(
|
|
1085
|
-
|
|
1085
|
+
pe.filter((g) => Array.isArray(g.registryCategories)).flatMap((g) => g.registryCategories.map((e) => [e, g.id]))
|
|
1086
1086
|
);
|
|
1087
|
-
function Je(
|
|
1088
|
-
return Ke[
|
|
1087
|
+
function Je(g) {
|
|
1088
|
+
return Ke[g] || [g];
|
|
1089
1089
|
}
|
|
1090
|
-
class Qe extends
|
|
1090
|
+
class Qe extends ne {
|
|
1091
1091
|
constructor(e, t) {
|
|
1092
1092
|
super(), this.state = e, this.renderer = t, this.instances = {}, this._filterRegistry = null;
|
|
1093
1093
|
}
|
|
@@ -1097,7 +1097,7 @@ class Qe extends se {
|
|
|
1097
1097
|
*/
|
|
1098
1098
|
setRegistry(e) {
|
|
1099
1099
|
var t, i;
|
|
1100
|
-
this._filterRegistry = e, (i = (t = this.renderer) == null ? void 0 : t.setLayerFilterFactory) == null || i.call(t, (
|
|
1100
|
+
this._filterRegistry = e, (i = (t = this.renderer) == null ? void 0 : t.setLayerFilterFactory) == null || i.call(t, (s, r) => this.createFiltersForLayer(s, r));
|
|
1101
1101
|
}
|
|
1102
1102
|
/**
|
|
1103
1103
|
* Get filter definition by ID
|
|
@@ -1123,11 +1123,11 @@ class Qe extends se {
|
|
|
1123
1123
|
*/
|
|
1124
1124
|
getFiltersByCategory(e) {
|
|
1125
1125
|
if (!this._filterRegistry) return [];
|
|
1126
|
-
const t = Je(e), i = [],
|
|
1127
|
-
for (const
|
|
1128
|
-
const o = this._filterRegistry.getFiltersByCategory(
|
|
1126
|
+
const t = Je(e), i = [], s = /* @__PURE__ */ new Set();
|
|
1127
|
+
for (const r of t) {
|
|
1128
|
+
const o = this._filterRegistry.getFiltersByCategory(r) || [];
|
|
1129
1129
|
for (const n of o)
|
|
1130
|
-
|
|
1130
|
+
s.has(n.id) || (s.add(n.id), i.push(n));
|
|
1131
1131
|
}
|
|
1132
1132
|
return i;
|
|
1133
1133
|
}
|
|
@@ -1151,12 +1151,12 @@ class Qe extends se {
|
|
|
1151
1151
|
if (!t.includes(".") && !t.includes("["))
|
|
1152
1152
|
return e[t];
|
|
1153
1153
|
const i = t.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
1154
|
-
let
|
|
1155
|
-
for (const
|
|
1156
|
-
if (
|
|
1157
|
-
|
|
1154
|
+
let s = e;
|
|
1155
|
+
for (const r of i) {
|
|
1156
|
+
if (s == null) return;
|
|
1157
|
+
s = s[r];
|
|
1158
1158
|
}
|
|
1159
|
-
return
|
|
1159
|
+
return s;
|
|
1160
1160
|
}
|
|
1161
1161
|
/**
|
|
1162
1162
|
* Set a deep property on an object
|
|
@@ -1170,14 +1170,14 @@ class Qe extends se {
|
|
|
1170
1170
|
e[t] = i;
|
|
1171
1171
|
return;
|
|
1172
1172
|
}
|
|
1173
|
-
const
|
|
1174
|
-
let
|
|
1175
|
-
for (let n = 0; n <
|
|
1176
|
-
const a =
|
|
1177
|
-
if (!(a in
|
|
1173
|
+
const s = t.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
1174
|
+
let r = e;
|
|
1175
|
+
for (let n = 0; n < s.length - 1; n++) {
|
|
1176
|
+
const a = s[n];
|
|
1177
|
+
if (!(a in r) || (r = r[a], r == null)) return;
|
|
1178
1178
|
}
|
|
1179
|
-
const o =
|
|
1180
|
-
|
|
1179
|
+
const o = s[s.length - 1];
|
|
1180
|
+
r[o] = i;
|
|
1181
1181
|
}
|
|
1182
1182
|
/**
|
|
1183
1183
|
* Initialize filter values from definition defaults.
|
|
@@ -1189,12 +1189,12 @@ class Qe extends se {
|
|
|
1189
1189
|
initializeValues(e, t = void 0) {
|
|
1190
1190
|
const i = this.getFilterDef(e);
|
|
1191
1191
|
if (!i) return;
|
|
1192
|
-
const
|
|
1192
|
+
const s = this.state.getFilterValues(e), r = new Set((i.controls || []).map((o) => o.id));
|
|
1193
1193
|
if (i.defaultParams)
|
|
1194
1194
|
for (const [o, n] of Object.entries(i.defaultParams))
|
|
1195
|
-
!
|
|
1195
|
+
!r.has(o) && !(o in s) && this.state.setFilterValue(e, o, n, t);
|
|
1196
1196
|
i.controls && i.controls.forEach((o) => {
|
|
1197
|
-
o.id in
|
|
1197
|
+
o.id in s || this.state.setFilterValue(e, o.id, o.default, t);
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
1200
|
/**
|
|
@@ -1205,12 +1205,12 @@ class Qe extends se {
|
|
|
1205
1205
|
resetValues(e, t = void 0) {
|
|
1206
1206
|
const i = this.getFilterDef(e);
|
|
1207
1207
|
if (!i) return;
|
|
1208
|
-
const
|
|
1208
|
+
const s = new Set((i.controls || []).map((r) => r.id));
|
|
1209
1209
|
if (i.defaultParams)
|
|
1210
|
-
for (const [
|
|
1211
|
-
|
|
1212
|
-
i.controls && i.controls.forEach((
|
|
1213
|
-
this.state.setFilterValue(e,
|
|
1210
|
+
for (const [r, o] of Object.entries(i.defaultParams))
|
|
1211
|
+
s.has(r) || this.state.setFilterValue(e, r, o, t);
|
|
1212
|
+
i.controls && i.controls.forEach((r) => {
|
|
1213
|
+
this.state.setFilterValue(e, r.id, r.default, t);
|
|
1214
1214
|
});
|
|
1215
1215
|
}
|
|
1216
1216
|
/**
|
|
@@ -1242,25 +1242,25 @@ class Qe extends se {
|
|
|
1242
1242
|
* @param {*} value
|
|
1243
1243
|
* @returns {boolean} True if updated in-place, false if caller must recreate
|
|
1244
1244
|
*/
|
|
1245
|
-
updateValue(e, t, i,
|
|
1246
|
-
const
|
|
1247
|
-
if (!this._matchesExpectedFilterLayer(
|
|
1248
|
-
const o = this.getFilterDef(e), n = o == null ? void 0 : o.controls.find((
|
|
1249
|
-
if (!a && this.state.setFilterValue(e, t,
|
|
1245
|
+
updateValue(e, t, i, s = void 0) {
|
|
1246
|
+
const r = this._normalizeValue(i);
|
|
1247
|
+
if (!this._matchesExpectedFilterLayer(s)) return !1;
|
|
1248
|
+
const o = this.getFilterDef(e), n = o == null ? void 0 : o.controls.find((p) => p.id === t), a = !n && (t.includes("[") || t.includes("."));
|
|
1249
|
+
if (!a && this.state.setFilterValue(e, t, r, s) === !1)
|
|
1250
1250
|
return !1;
|
|
1251
1251
|
const l = this.instances[e];
|
|
1252
1252
|
if (!l) return !1;
|
|
1253
1253
|
const h = (n == null ? void 0 : n.property) || t;
|
|
1254
1254
|
if (typeof l.updateUIParam == "function") {
|
|
1255
|
-
if (l.updateUIParam(h,
|
|
1256
|
-
const
|
|
1257
|
-
for (const [
|
|
1258
|
-
this.state.setFilterValue(e,
|
|
1255
|
+
if (l.updateUIParam(h, r), a && typeof l.getSerializableParams == "function") {
|
|
1256
|
+
const p = l.getSerializableParams();
|
|
1257
|
+
for (const [u, f] of Object.entries(p))
|
|
1258
|
+
this.state.setFilterValue(e, u, f, s);
|
|
1259
1259
|
}
|
|
1260
1260
|
return !0;
|
|
1261
1261
|
}
|
|
1262
1262
|
const c = this._getDeepProp(l, h);
|
|
1263
|
-
return typeof c == "function" ? !1 : l.uniforms && h in l.uniforms ? (l.uniforms[h] =
|
|
1263
|
+
return typeof c == "function" ? !1 : l.uniforms && h in l.uniforms ? (l.uniforms[h] = r, !0) : c !== void 0 ? (this._setDeepProp(l, h, r), !0) : !1;
|
|
1264
1264
|
}
|
|
1265
1265
|
/**
|
|
1266
1266
|
* Perform a filter action (e.g. addColorStop, removeColorStop) and sync
|
|
@@ -1273,11 +1273,11 @@ class Qe extends se {
|
|
|
1273
1273
|
*/
|
|
1274
1274
|
performFilterAction(e, t, i = void 0) {
|
|
1275
1275
|
if (!this._matchesExpectedFilterLayer(i)) return !1;
|
|
1276
|
-
const
|
|
1277
|
-
if (!
|
|
1278
|
-
if (
|
|
1279
|
-
const
|
|
1280
|
-
for (const [o, n] of Object.entries(
|
|
1276
|
+
const s = this.instances[e];
|
|
1277
|
+
if (!s || typeof s.updateUIParam != "function") return !1;
|
|
1278
|
+
if (s.updateUIParam(t, !0), typeof s.getSerializableParams == "function") {
|
|
1279
|
+
const r = s.getSerializableParams();
|
|
1280
|
+
for (const [o, n] of Object.entries(r))
|
|
1281
1281
|
this.state.setFilterValue(e, o, n, i);
|
|
1282
1282
|
}
|
|
1283
1283
|
return this.applyFilters(), this.emit("filterActionPerformed", { filterId: e, action: t }), !0;
|
|
@@ -1295,27 +1295,27 @@ class Qe extends se {
|
|
|
1295
1295
|
return e && e.version === 2 && Array.isArray(e.layers) ? e : null;
|
|
1296
1296
|
}
|
|
1297
1297
|
_sourceDimensionsForLayer(e, t = {}) {
|
|
1298
|
-
var
|
|
1299
|
-
const i = (e == null ? void 0 : e.source) || ((
|
|
1298
|
+
var s, r, o, n, a, l, h, c, p;
|
|
1299
|
+
const i = (e == null ? void 0 : e.source) || ((s = e == null ? void 0 : e.fill) == null ? void 0 : s.source) || null;
|
|
1300
1300
|
return {
|
|
1301
|
-
width: Math.round(Number(t.sourceWidth || (i == null ? void 0 : i.originalWidth) || ((o = (
|
|
1302
|
-
height: Math.round(Number(t.sourceHeight || (i == null ? void 0 : i.originalHeight) || ((h = (l = this.renderer) == null ? void 0 : l.originalTexture) == null ? void 0 : h.height) || ((
|
|
1301
|
+
width: Math.round(Number(t.sourceWidth || (i == null ? void 0 : i.originalWidth) || ((o = (r = this.renderer) == null ? void 0 : r.originalTexture) == null ? void 0 : o.width) || ((a = (n = this.renderer) == null ? void 0 : n.sprite) == null ? void 0 : a.width) || 0)),
|
|
1302
|
+
height: Math.round(Number(t.sourceHeight || (i == null ? void 0 : i.originalHeight) || ((h = (l = this.renderer) == null ? void 0 : l.originalTexture) == null ? void 0 : h.height) || ((p = (c = this.renderer) == null ? void 0 : c.sprite) == null ? void 0 : p.height) || 0))
|
|
1303
1303
|
};
|
|
1304
1304
|
}
|
|
1305
1305
|
_paramsForFilterState(e, t, i) {
|
|
1306
|
-
const
|
|
1306
|
+
const s = t != null && t.values && typeof t.values == "object" ? t.values : {}, r = e.defaultParams ? { ...e.defaultParams } : {};
|
|
1307
1307
|
e.controls && Array.isArray(e.controls) && e.controls.forEach((n) => {
|
|
1308
1308
|
const a = n.property || n.id;
|
|
1309
|
-
|
|
1309
|
+
r[a] = s[n.id] ?? n.default;
|
|
1310
1310
|
});
|
|
1311
1311
|
const o = new Set((e.controls || []).map((n) => n.id));
|
|
1312
|
-
for (const [n, a] of Object.entries(
|
|
1313
|
-
o.has(n) || (
|
|
1314
|
-
return
|
|
1312
|
+
for (const [n, a] of Object.entries(s))
|
|
1313
|
+
o.has(n) || (r[n] = a);
|
|
1314
|
+
return r._sourceWidth = i.width, r._sourceHeight = i.height, r;
|
|
1315
1315
|
}
|
|
1316
1316
|
createFiltersForLayer(e, t = {}) {
|
|
1317
1317
|
if (!Array.isArray(e == null ? void 0 : e.filters) || e.filters.length === 0) return [];
|
|
1318
|
-
const i = [],
|
|
1318
|
+
const i = [], s = this.state.get("activeLayerId"), r = e.id === s && t.forExport !== !0, o = this._sourceDimensionsForLayer(e, t);
|
|
1319
1319
|
for (const n of e.filters)
|
|
1320
1320
|
if (!(!n || n.enabled === !1 || typeof n.id != "string"))
|
|
1321
1321
|
try {
|
|
@@ -1326,7 +1326,7 @@ class Qe extends se {
|
|
|
1326
1326
|
let h = l;
|
|
1327
1327
|
t.forExport === !0 && typeof l.createExportFilter == "function" && (h = l.createExportFilter({
|
|
1328
1328
|
previewToNativeScale: t.previewToNativeScale || 1
|
|
1329
|
-
}) || l), i.push(h),
|
|
1329
|
+
}) || l), i.push(h), r && (this.instances[n.id] = l);
|
|
1330
1330
|
} catch {
|
|
1331
1331
|
}
|
|
1332
1332
|
return i;
|
|
@@ -1338,56 +1338,56 @@ class Qe extends se {
|
|
|
1338
1338
|
* PIXI v8's filter pipeline correctly processes changes.
|
|
1339
1339
|
*/
|
|
1340
1340
|
applyFilters() {
|
|
1341
|
-
var o, n, a, l, h, c,
|
|
1341
|
+
var o, n, a, l, h, c, p;
|
|
1342
1342
|
const e = this._layerDocument();
|
|
1343
1343
|
if (e) {
|
|
1344
|
-
for (const
|
|
1345
|
-
delete this.instances[
|
|
1346
|
-
(n = (o = this.renderer) == null ? void 0 : o.setLayerFilterFactory) == null || n.call(o, (
|
|
1347
|
-
const
|
|
1344
|
+
for (const f in this.instances)
|
|
1345
|
+
delete this.instances[f];
|
|
1346
|
+
(n = (o = this.renderer) == null ? void 0 : o.setLayerFilterFactory) == null || n.call(o, (f, m) => this.createFiltersForLayer(f, m));
|
|
1347
|
+
const u = (l = (a = this.renderer) == null ? void 0 : a.applyLayerFilters) == null ? void 0 : l.call(a, e);
|
|
1348
1348
|
this.emit("filtersApplied", {
|
|
1349
1349
|
count: ((h = this.state.get("activeFilters")) == null ? void 0 : h.size) ?? 0,
|
|
1350
1350
|
failed: [],
|
|
1351
1351
|
scopedToLayer: !0
|
|
1352
|
-
}),
|
|
1352
|
+
}), u || (p = (c = this.renderer) == null ? void 0 : c.render) == null || p.call(c);
|
|
1353
1353
|
return;
|
|
1354
1354
|
}
|
|
1355
1355
|
const t = this.renderer.sprite;
|
|
1356
1356
|
if (!t) return;
|
|
1357
|
-
for (const
|
|
1358
|
-
delete this.instances[
|
|
1359
|
-
const i = [],
|
|
1360
|
-
this.state.get("activeFilters").forEach((
|
|
1357
|
+
for (const u in this.instances)
|
|
1358
|
+
delete this.instances[u];
|
|
1359
|
+
const i = [], s = [];
|
|
1360
|
+
this.state.get("activeFilters").forEach((u) => {
|
|
1361
1361
|
try {
|
|
1362
|
-
const
|
|
1363
|
-
if (!
|
|
1362
|
+
const f = this.getFilterDef(u);
|
|
1363
|
+
if (!f || !f.createFilter || typeof f.createFilter != "function")
|
|
1364
1364
|
return;
|
|
1365
|
-
const m = this.state.getFilterValues(
|
|
1366
|
-
|
|
1367
|
-
const J =
|
|
1368
|
-
b[J] = m[
|
|
1365
|
+
const m = this.state.getFilterValues(u), b = f.defaultParams ? { ...f.defaultParams } : {};
|
|
1366
|
+
f.controls && Array.isArray(f.controls) && f.controls.forEach((S) => {
|
|
1367
|
+
const J = S.property || S.id;
|
|
1368
|
+
b[J] = m[S.id] ?? S.default;
|
|
1369
1369
|
});
|
|
1370
|
-
const
|
|
1371
|
-
for (const [
|
|
1372
|
-
|
|
1370
|
+
const k = new Set((f.controls || []).map((S) => S.id));
|
|
1371
|
+
for (const [S, J] of Object.entries(m))
|
|
1372
|
+
k.has(S) || (b[S] = J);
|
|
1373
1373
|
const x = this.renderer.sprite, B = this.renderer.originalTexture;
|
|
1374
1374
|
b._sourceWidth = Math.round((B == null ? void 0 : B.width) || (x == null ? void 0 : x.width) || 0), b._sourceHeight = Math.round((B == null ? void 0 : B.height) || (x == null ? void 0 : x.height) || 0);
|
|
1375
|
-
const A =
|
|
1376
|
-
A && (i.push(A), this.instances[
|
|
1375
|
+
const A = f.createFilter(b);
|
|
1376
|
+
A && (i.push(A), this.instances[u] = A);
|
|
1377
1377
|
} catch {
|
|
1378
|
-
|
|
1378
|
+
s.push(u);
|
|
1379
1379
|
}
|
|
1380
1380
|
});
|
|
1381
1381
|
try {
|
|
1382
|
-
t.filters = null, t.filters = i.length ? i : null, this.renderer.render(), this.emit("filtersApplied", { count: i.length, failed:
|
|
1383
|
-
} catch (
|
|
1382
|
+
t.filters = null, t.filters = i.length ? i : null, this.renderer.render(), this.emit("filtersApplied", { count: i.length, failed: s });
|
|
1383
|
+
} catch (u) {
|
|
1384
1384
|
try {
|
|
1385
1385
|
t.filters = null, this.renderer.render();
|
|
1386
1386
|
} catch {
|
|
1387
1387
|
}
|
|
1388
|
-
this.emit("filtersError", { error:
|
|
1388
|
+
this.emit("filtersError", { error: u, failedFilters: s });
|
|
1389
1389
|
}
|
|
1390
|
-
|
|
1390
|
+
s.length > 0;
|
|
1391
1391
|
}
|
|
1392
1392
|
/**
|
|
1393
1393
|
* Reset all filters.
|
|
@@ -1396,8 +1396,8 @@ class Qe extends se {
|
|
|
1396
1396
|
* destroy any applied crop, which is a separate concern.
|
|
1397
1397
|
*/
|
|
1398
1398
|
resetAll(e = void 0) {
|
|
1399
|
-
for (const
|
|
1400
|
-
delete this.instances[
|
|
1399
|
+
for (const s in this.instances)
|
|
1400
|
+
delete this.instances[s];
|
|
1401
1401
|
return this.state.resetFilters(e) === !1 ? !1 : this._layerDocument() ? (this.applyFilters(), this.emit("filtersReset"), !0) : (this.renderer.sprite && (this.renderer.sprite.filters = null), this.renderer.render(), this.emit("filtersReset"), !0);
|
|
1402
1402
|
}
|
|
1403
1403
|
/**
|
|
@@ -1409,7 +1409,7 @@ class Qe extends se {
|
|
|
1409
1409
|
return this.instances[e] || null;
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
|
-
const
|
|
1412
|
+
const V = class V extends ne {
|
|
1413
1413
|
constructor(e, t) {
|
|
1414
1414
|
super(), this.state = e, this.renderer = t, this._overlayCanvas = null, this._isDragging = !1, this._dragStart = null, this._dragMode = null, this._startRect = null, this._hoverMode = null, this._lastAutoZoomCheck = 0, this.HANDLE_SIZE = 14, this.EDGE_HIT_PAD = 10, this._onPointerDown = this._handlePointerDown.bind(this), this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerUp = this._handlePointerUp.bind(this);
|
|
1415
1415
|
}
|
|
@@ -1437,9 +1437,9 @@ const U = class U extends se {
|
|
|
1437
1437
|
if (t[e] !== void 0) return t[e];
|
|
1438
1438
|
const i = e.split(":");
|
|
1439
1439
|
if (i.length === 2) {
|
|
1440
|
-
const
|
|
1441
|
-
if (Number.isFinite(
|
|
1442
|
-
return
|
|
1440
|
+
const s = parseFloat(i[0]), r = parseFloat(i[1]);
|
|
1441
|
+
if (Number.isFinite(s) && Number.isFinite(r) && r > 0)
|
|
1442
|
+
return s / r;
|
|
1443
1443
|
}
|
|
1444
1444
|
return null;
|
|
1445
1445
|
}
|
|
@@ -1475,8 +1475,8 @@ const U = class U extends se {
|
|
|
1475
1475
|
if (!e) return;
|
|
1476
1476
|
const t = this.renderer.sprite, i = this.renderer.app;
|
|
1477
1477
|
if (!t || !i) return;
|
|
1478
|
-
const
|
|
1479
|
-
if (e.x = Math.max(
|
|
1478
|
+
const s = this.state.get("crop.shape"), r = { x: 0, y: 0, w: i.screen.width, h: i.screen.height };
|
|
1479
|
+
if (e.x = Math.max(r.x, Math.min(e.x, r.x + r.w - e.width)), e.y = Math.max(r.y, Math.min(e.y, r.y + r.h - e.height)), e.width = Math.min(e.width, r.w), e.height = Math.min(e.height, r.h), s !== "free" || this.state.get("crop.aspect") === "1:1") {
|
|
1480
1480
|
const o = Math.min(e.width, e.height);
|
|
1481
1481
|
e.width = o, e.height = o;
|
|
1482
1482
|
}
|
|
@@ -1495,19 +1495,19 @@ const U = class U extends se {
|
|
|
1495
1495
|
* @param {number} currentZoom - Current zoom level
|
|
1496
1496
|
* @returns {number|null} Target zoom level, or null if no zoom needed
|
|
1497
1497
|
*/
|
|
1498
|
-
static calcAutoZoom(e, t, i,
|
|
1499
|
-
if (!e || !
|
|
1498
|
+
static calcAutoZoom(e, t, i, s, r, o, n) {
|
|
1499
|
+
if (!e || !s || !r || !o) return null;
|
|
1500
1500
|
const a = e.width > t, l = e.height > i;
|
|
1501
1501
|
if (!a && !l) return null;
|
|
1502
|
-
const h =
|
|
1502
|
+
const h = V.AUTO_ZOOM_PADDING;
|
|
1503
1503
|
let c = n;
|
|
1504
1504
|
if (a) {
|
|
1505
|
-
const
|
|
1506
|
-
c = Math.min(c,
|
|
1505
|
+
const p = e.width / (h * s * o);
|
|
1506
|
+
c = Math.min(c, p);
|
|
1507
1507
|
}
|
|
1508
1508
|
if (l) {
|
|
1509
|
-
const
|
|
1510
|
-
c = Math.min(c,
|
|
1509
|
+
const p = e.height / (h * r * o);
|
|
1510
|
+
c = Math.min(c, p);
|
|
1511
1511
|
}
|
|
1512
1512
|
return c = Math.max(0.1, c), c >= n - 0.01 ? null : c;
|
|
1513
1513
|
}
|
|
@@ -1518,20 +1518,20 @@ const U = class U extends se {
|
|
|
1518
1518
|
_checkAutoZoom() {
|
|
1519
1519
|
if (!this.state.get("autoZoomOnCropOverflow")) return;
|
|
1520
1520
|
const e = Date.now();
|
|
1521
|
-
if (e - this._lastAutoZoomCheck <
|
|
1521
|
+
if (e - this._lastAutoZoomCheck < V.AUTO_ZOOM_THROTTLE_MS) return;
|
|
1522
1522
|
this._lastAutoZoomCheck = e;
|
|
1523
|
-
const t = this.state.get("crop.rect"), i = this.renderer.sprite,
|
|
1524
|
-
if (!t || !i || !
|
|
1525
|
-
const
|
|
1523
|
+
const t = this.state.get("crop.rect"), i = this.renderer.sprite, s = this.renderer.originalTexture;
|
|
1524
|
+
if (!t || !i || !s) return;
|
|
1525
|
+
const r = V.calcAutoZoom(
|
|
1526
1526
|
t,
|
|
1527
1527
|
i.width,
|
|
1528
1528
|
i.height,
|
|
1529
|
-
|
|
1530
|
-
|
|
1529
|
+
s.width,
|
|
1530
|
+
s.height,
|
|
1531
1531
|
this.renderer.fitScale,
|
|
1532
1532
|
this.renderer.zoom
|
|
1533
1533
|
);
|
|
1534
|
-
|
|
1534
|
+
r !== null && this.renderer.setZoom(r, { keepCenter: !0 });
|
|
1535
1535
|
}
|
|
1536
1536
|
/**
|
|
1537
1537
|
* Draw crop overlay on canvas
|
|
@@ -1541,17 +1541,17 @@ const U = class U extends se {
|
|
|
1541
1541
|
if (!e) return;
|
|
1542
1542
|
const t = this.renderer.app;
|
|
1543
1543
|
if (!t) return;
|
|
1544
|
-
const i = t.canvas,
|
|
1545
|
-
(e.width !== Math.max(1, Math.floor(
|
|
1544
|
+
const i = t.canvas, s = i.clientWidth, r = i.clientHeight, o = window.devicePixelRatio || 1;
|
|
1545
|
+
(e.width !== Math.max(1, Math.floor(s * o)) || e.height !== Math.max(1, Math.floor(r * o))) && (e.width = Math.max(1, Math.floor(s * o)), e.height = Math.max(1, Math.floor(r * o)), e.style.width = s + "px", e.style.height = r + "px");
|
|
1546
1546
|
const n = e.getContext("2d");
|
|
1547
1547
|
if (!n) return;
|
|
1548
|
-
n.setTransform(o, 0, 0, o, 0, 0), n.clearRect(0, 0,
|
|
1548
|
+
n.setTransform(o, 0, 0, o, 0, 0), n.clearRect(0, 0, s, r), n.fillStyle = "rgba(0, 0, 0, 0.5)", n.fillRect(0, 0, s, r);
|
|
1549
1549
|
const a = this.state.get("crop.rect");
|
|
1550
1550
|
if (!a) return;
|
|
1551
1551
|
const l = this.state.get("crop.shape");
|
|
1552
1552
|
if (n.save(), l === "circle") {
|
|
1553
|
-
const b = a.x + a.width / 2,
|
|
1554
|
-
n.beginPath(), n.arc(b,
|
|
1553
|
+
const b = a.x + a.width / 2, k = a.y + a.height / 2, x = Math.min(a.width, a.height) / 2;
|
|
1554
|
+
n.beginPath(), n.arc(b, k, x, 0, Math.PI * 2), n.clip();
|
|
1555
1555
|
} else
|
|
1556
1556
|
n.beginPath(), n.rect(a.x, a.y, a.width, a.height), n.clip();
|
|
1557
1557
|
n.clearRect(a.x, a.y, a.width, a.height), n.restore(), n.strokeStyle = "#ffffff", n.lineWidth = 2, n.setLineDash([5, 5]), l === "circle" ? (n.beginPath(), n.arc(
|
|
@@ -1564,20 +1564,20 @@ const U = class U extends se {
|
|
|
1564
1564
|
const h = a.width / 3, c = a.height / 3;
|
|
1565
1565
|
for (let b = 1; b <= 2; b++)
|
|
1566
1566
|
n.beginPath(), n.moveTo(a.x + h * b, a.y), n.lineTo(a.x + h * b, a.y + a.height), n.stroke(), n.beginPath(), n.moveTo(a.x, a.y + c * b), n.lineTo(a.x + a.width, a.y + c * b), n.stroke();
|
|
1567
|
-
const
|
|
1567
|
+
const p = this.HANDLE_SIZE, u = [
|
|
1568
1568
|
{ x: a.x, y: a.y, m: "resize-nw" },
|
|
1569
1569
|
{ x: a.x + a.width, y: a.y, m: "resize-ne" },
|
|
1570
1570
|
{ x: a.x, y: a.y + a.height, m: "resize-sw" },
|
|
1571
1571
|
{ x: a.x + a.width, y: a.y + a.height, m: "resize-se" }
|
|
1572
|
-
],
|
|
1572
|
+
], f = [
|
|
1573
1573
|
{ x: a.x + a.width / 2, y: a.y, m: "n" },
|
|
1574
1574
|
{ x: a.x + a.width / 2, y: a.y + a.height, m: "s" },
|
|
1575
1575
|
{ x: a.x, y: a.y + a.height / 2, m: "w" },
|
|
1576
1576
|
{ x: a.x + a.width, y: a.y + a.height / 2, m: "e" }
|
|
1577
|
-
], m = [...
|
|
1577
|
+
], m = [...u, ...f];
|
|
1578
1578
|
for (const b of m) {
|
|
1579
|
-
const
|
|
1580
|
-
n.beginPath(), n.rect(b.x - x / 2, b.y - x / 2, x, x), n.fillStyle =
|
|
1579
|
+
const k = this._hoverMode === b.m, x = k ? p + 4 : p;
|
|
1580
|
+
n.beginPath(), n.rect(b.x - x / 2, b.y - x / 2, x, x), n.fillStyle = k ? "#4da3ff" : "#ffffff", n.strokeStyle = "rgba(0,0,0,0.6)", n.lineWidth = 1, n.fill(), n.stroke();
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
1583
1583
|
/**
|
|
@@ -1589,8 +1589,8 @@ const U = class U extends se {
|
|
|
1589
1589
|
_hitHandle(e, t) {
|
|
1590
1590
|
const i = this.state.get("crop.rect");
|
|
1591
1591
|
if (!i) return null;
|
|
1592
|
-
const
|
|
1593
|
-
return
|
|
1592
|
+
const s = (r, o, n, a, l) => Math.abs(r - n) <= l && Math.abs(o - a) <= l;
|
|
1593
|
+
return s(e, t, i.x, i.y, this.HANDLE_SIZE) ? "resize-nw" : s(e, t, i.x + i.width, i.y, this.HANDLE_SIZE) ? "resize-ne" : s(e, t, i.x, i.y + i.height, this.HANDLE_SIZE) ? "resize-sw" : s(e, t, i.x + i.width, i.y + i.height, this.HANDLE_SIZE) ? "resize-se" : Math.abs(t - i.y) <= this.EDGE_HIT_PAD && e >= i.x && e <= i.x + i.width ? "n" : Math.abs(t - (i.y + i.height)) <= this.EDGE_HIT_PAD && e >= i.x && e <= i.x + i.width ? "s" : Math.abs(e - i.x) <= this.EDGE_HIT_PAD && t >= i.y && t <= i.y + i.height ? "w" : Math.abs(e - (i.x + i.width)) <= this.EDGE_HIT_PAD && t >= i.y && t <= i.y + i.height ? "e" : e >= i.x && e <= i.x + i.width && t >= i.y && t <= i.y + i.height ? "move" : null;
|
|
1594
1594
|
}
|
|
1595
1595
|
/**
|
|
1596
1596
|
* Handle pointer down event
|
|
@@ -1605,47 +1605,67 @@ const U = class U extends se {
|
|
|
1605
1605
|
* Handle pointer move event
|
|
1606
1606
|
*/
|
|
1607
1607
|
_handlePointerMove(e) {
|
|
1608
|
-
var
|
|
1608
|
+
var l, h, c, p;
|
|
1609
1609
|
const t = this.renderer.app;
|
|
1610
1610
|
if (!t) return;
|
|
1611
1611
|
const i = e.global;
|
|
1612
1612
|
if (!this._isDragging || !this._dragStart || !this._startRect) {
|
|
1613
|
-
this._hoverMode = this._hitHandle(i.x, i.y), t.stage.cursor = this._hoverMode === "move" ? "move" : this._hoverMode === "n" || this._hoverMode === "s" ? "ns-resize" : this._hoverMode === "e" || this._hoverMode === "w" ? "ew-resize" : (
|
|
1613
|
+
this._hoverMode = this._hitHandle(i.x, i.y), t.stage.cursor = this._hoverMode === "move" ? "move" : this._hoverMode === "n" || this._hoverMode === "s" ? "ns-resize" : this._hoverMode === "e" || this._hoverMode === "w" ? "ew-resize" : (l = this._hoverMode) != null && l.endsWith("nw") || (h = this._hoverMode) != null && h.endsWith("se") ? "nwse-resize" : (c = this._hoverMode) != null && c.endsWith("ne") || (p = this._hoverMode) != null && p.endsWith("sw") ? "nesw-resize" : "crosshair", this.drawOverlay();
|
|
1614
1614
|
return;
|
|
1615
1615
|
}
|
|
1616
|
-
const
|
|
1617
|
-
if (!
|
|
1618
|
-
const
|
|
1616
|
+
const s = this.state.get("crop.rect");
|
|
1617
|
+
if (!s) return;
|
|
1618
|
+
const r = i.x - this._dragStart.x, o = i.y - this._dragStart.y, n = this._getEffectiveTargetAspect();
|
|
1619
1619
|
switch (this._dragMode) {
|
|
1620
1620
|
case "move":
|
|
1621
|
-
|
|
1621
|
+
s.x = this._startRect.x + r, s.y = this._startRect.y + o;
|
|
1622
1622
|
break;
|
|
1623
|
-
case "n":
|
|
1624
|
-
|
|
1623
|
+
case "n": {
|
|
1624
|
+
const u = this._startRect.height - o;
|
|
1625
|
+
if (s.y = this._startRect.y + o, s.height = u, n) {
|
|
1626
|
+
const f = u * n;
|
|
1627
|
+
s.x = this._startRect.x + (this._startRect.width - f) / 2, s.width = f;
|
|
1628
|
+
}
|
|
1625
1629
|
break;
|
|
1626
|
-
|
|
1627
|
-
|
|
1630
|
+
}
|
|
1631
|
+
case "s": {
|
|
1632
|
+
const u = this._startRect.height + o;
|
|
1633
|
+
if (s.height = u, n) {
|
|
1634
|
+
const f = u * n;
|
|
1635
|
+
s.x = this._startRect.x + (this._startRect.width - f) / 2, s.width = f;
|
|
1636
|
+
}
|
|
1628
1637
|
break;
|
|
1629
|
-
|
|
1630
|
-
|
|
1638
|
+
}
|
|
1639
|
+
case "w": {
|
|
1640
|
+
const u = this._startRect.width - r;
|
|
1641
|
+
if (s.x = this._startRect.x + r, s.width = u, n) {
|
|
1642
|
+
const f = u / n;
|
|
1643
|
+
s.y = this._startRect.y + (this._startRect.height - f) / 2, s.height = f;
|
|
1644
|
+
}
|
|
1631
1645
|
break;
|
|
1632
|
-
|
|
1633
|
-
|
|
1646
|
+
}
|
|
1647
|
+
case "e": {
|
|
1648
|
+
const u = this._startRect.width + r;
|
|
1649
|
+
if (s.width = u, n) {
|
|
1650
|
+
const f = u / n;
|
|
1651
|
+
s.y = this._startRect.y + (this._startRect.height - f) / 2, s.height = f;
|
|
1652
|
+
}
|
|
1634
1653
|
break;
|
|
1654
|
+
}
|
|
1635
1655
|
case "resize-nw":
|
|
1636
|
-
|
|
1656
|
+
s.x = this._startRect.x + r, s.y = this._startRect.y + o, s.width = this._startRect.width - r, s.height = this._startRect.height - o;
|
|
1637
1657
|
break;
|
|
1638
1658
|
case "resize-ne":
|
|
1639
|
-
|
|
1659
|
+
s.y = this._startRect.y + o, s.width = this._startRect.width + r, s.height = this._startRect.height - o;
|
|
1640
1660
|
break;
|
|
1641
1661
|
case "resize-sw":
|
|
1642
|
-
|
|
1662
|
+
s.x = this._startRect.x + r, s.width = this._startRect.width - r, s.height = this._startRect.height + o;
|
|
1643
1663
|
break;
|
|
1644
1664
|
case "resize-se":
|
|
1645
|
-
|
|
1665
|
+
s.width = this._startRect.width + r, s.height = this._startRect.height + o;
|
|
1646
1666
|
break;
|
|
1647
1667
|
}
|
|
1648
|
-
|
|
1668
|
+
s.width = Math.max(50, s.width), s.height = Math.max(50, s.height), this.state.set("crop.rect", s), this.state.set("crop.dirty", !0), this.state.get("crop.shape") === "circle" && this.state.get("crop.aspect") !== "1:1" && this.state.set("crop.aspect", "1:1"), this.applyAspectRatio(), this._dragMode !== "move" && this._checkAutoZoom(), this.constrainCropRect(), this.drawOverlay();
|
|
1649
1669
|
}
|
|
1650
1670
|
/**
|
|
1651
1671
|
* Handle pointer up event
|
|
@@ -1665,18 +1685,18 @@ const U = class U extends se {
|
|
|
1665
1685
|
const o = this.state.get("crop.aspect"), n = this._getAspectRatio(o);
|
|
1666
1686
|
let a, l;
|
|
1667
1687
|
if (n) {
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1688
|
+
const p = t.width * 0.9, u = t.height * 0.9;
|
|
1689
|
+
p / u > n ? (l = u, a = l * n) : (a = p, l = a / n);
|
|
1670
1690
|
} else {
|
|
1671
|
-
const
|
|
1672
|
-
a =
|
|
1691
|
+
const p = Math.min(e.screen.width, e.screen.height) * 0.7;
|
|
1692
|
+
a = p, l = p;
|
|
1673
1693
|
}
|
|
1674
1694
|
const h = t.x + (t.width - a) / 2, c = t.y + (t.height - l) / 2;
|
|
1675
1695
|
i = { x: h, y: c, width: a, height: l }, this.state.set("crop.rect", i), o !== "free" && this.constrainCropRect();
|
|
1676
1696
|
}
|
|
1677
1697
|
this.state.set("crop.dirty", !1);
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1698
|
+
const s = e.stage;
|
|
1699
|
+
s.eventMode = "static", s.hitArea = e.screen, s.cursor = "crosshair", s.on("pointerdown", this._onPointerDown), s.on("pointermove", this._onPointerMove), s.on("pointerup", this._onPointerUp), s.on("pointerupoutside", this._onPointerUp), this.state.set("mode", "crop"), this.drawOverlay(), this.emit("enabled");
|
|
1680
1700
|
}
|
|
1681
1701
|
/**
|
|
1682
1702
|
* Disable crop mode
|
|
@@ -1696,20 +1716,20 @@ const U = class U extends se {
|
|
|
1696
1716
|
* @returns {{ texture: PIXI.Texture, preservedZoom: number }|null}
|
|
1697
1717
|
*/
|
|
1698
1718
|
apply() {
|
|
1699
|
-
const e = this.renderer.app, t = this.renderer.sprite, i = this.renderer.originalTexture,
|
|
1700
|
-
if (!
|
|
1701
|
-
const
|
|
1702
|
-
let c = Math.round(Math.max(1,
|
|
1703
|
-
if (c <= 0 ||
|
|
1704
|
-
const m = new
|
|
1719
|
+
const e = this.renderer.app, t = this.renderer.sprite, i = this.renderer.originalTexture, s = this.state.get("crop.rect");
|
|
1720
|
+
if (!s || !t || !e || !i) return null;
|
|
1721
|
+
const r = window.PIXI, o = this.renderer.zoom, n = i.width / t.width, a = i.height / t.height, l = (s.x - t.x) * n, h = (s.y - t.y) * a;
|
|
1722
|
+
let c = Math.round(Math.max(1, s.width * n)), p = Math.round(Math.max(1, s.height * a)), u = Math.round(l), f = Math.round(h);
|
|
1723
|
+
if (c <= 0 || p <= 0) return null;
|
|
1724
|
+
const m = new r.Container(), b = new r.Sprite(i);
|
|
1705
1725
|
if (this.state.get("crop.shape") === "circle") {
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1708
|
-
const
|
|
1709
|
-
typeof
|
|
1726
|
+
const M = Math.round(Math.max(c, p)), N = u + c / 2, z = f + p / 2;
|
|
1727
|
+
u = Math.round(N - M / 2), f = Math.round(z - M / 2), c = p = M;
|
|
1728
|
+
const F = new r.Graphics();
|
|
1729
|
+
typeof F.circle == "function" && typeof F.fill == "function" ? F.circle(c / 2, p / 2, c / 2).fill(16777215) : (F.beginFill(16777215, 1), F.drawCircle(c / 2, p / 2, c / 2), F.endFill()), b.mask = F, m.addChild(F);
|
|
1710
1730
|
}
|
|
1711
|
-
b.x = -
|
|
1712
|
-
const x =
|
|
1731
|
+
b.x = -u, b.y = -f, m.addChild(b);
|
|
1732
|
+
const x = r.RenderTexture.create({ width: c, height: p });
|
|
1713
1733
|
e.renderer.render({
|
|
1714
1734
|
container: m,
|
|
1715
1735
|
target: x,
|
|
@@ -1717,15 +1737,15 @@ const U = class U extends se {
|
|
|
1717
1737
|
}), m.destroy({ children: !0 });
|
|
1718
1738
|
const B = this.renderer.originalTexture;
|
|
1719
1739
|
B && B !== this.renderer.baseTexture && B.destroy(!0), this.renderer.originalTexture = x, e.stage.removeChild(t), t.destroy();
|
|
1720
|
-
const A = new
|
|
1740
|
+
const A = new r.Sprite(x);
|
|
1721
1741
|
e.stage.addChild(A), this.renderer.sprite = A, this.renderer.fitScale = this.renderer.getFitScaleFor(x), this.renderer.setZoom(o, { keepCenter: !1 }), this.renderer.applyViewTransform(), this.renderer.render();
|
|
1722
|
-
const
|
|
1723
|
-
x: Math.round(
|
|
1724
|
-
y: Math.round(
|
|
1742
|
+
const S = this.state.get("crop.appliedRect"), y = S && Number.isFinite(S.x) && Number.isFinite(S.y) && Number.isFinite(S.width) && Number.isFinite(S.height) ? {
|
|
1743
|
+
x: Math.round(S.x + u),
|
|
1744
|
+
y: Math.round(S.y + f),
|
|
1725
1745
|
width: c,
|
|
1726
|
-
height:
|
|
1727
|
-
} : { x:
|
|
1728
|
-
return this.disable(), this.state.set("crop.appliedRect", y), this.state.set("crop.appliedShape", w), this.state.set("crop.appliedAspect",
|
|
1746
|
+
height: p
|
|
1747
|
+
} : { x: u, y: f, width: c, height: p }, w = this.state.get("crop.shape") || "free", R = this.state.get("crop.aspect") || "free";
|
|
1748
|
+
return this.disable(), this.state.set("crop.appliedRect", y), this.state.set("crop.appliedShape", w), this.state.set("crop.appliedAspect", R), this.state.set("crop.dirty", !1), this.emit("applied", { width: c, height: p }), { texture: x, preservedZoom: o };
|
|
1729
1749
|
}
|
|
1730
1750
|
/**
|
|
1731
1751
|
* Apply a crop from saved texture-pixel coordinates (for state rehydration).
|
|
@@ -1735,25 +1755,25 @@ const U = class U extends se {
|
|
|
1735
1755
|
* @returns {{ texture: Object, preservedZoom: number }|null}
|
|
1736
1756
|
*/
|
|
1737
1757
|
applyFromPixelRect(e, t = "free") {
|
|
1738
|
-
const i = this.renderer.app,
|
|
1739
|
-
if (!e || !
|
|
1758
|
+
const i = this.renderer.app, s = this.renderer.sprite, r = this.renderer.originalTexture;
|
|
1759
|
+
if (!e || !s || !i || !r) return null;
|
|
1740
1760
|
const o = window.PIXI, n = this.renderer.zoom;
|
|
1741
1761
|
let a = Math.round(Math.max(1, e.width)), l = Math.round(Math.max(1, e.height)), h = Math.round(e.x), c = Math.round(e.y);
|
|
1742
1762
|
if (a <= 0 || l <= 0) return null;
|
|
1743
|
-
const
|
|
1763
|
+
const p = new o.Container(), u = new o.Sprite(r);
|
|
1744
1764
|
if (t === "circle") {
|
|
1745
|
-
const
|
|
1746
|
-
h = Math.round(x -
|
|
1765
|
+
const k = Math.round(Math.max(a, l)), x = h + a / 2, B = c + l / 2;
|
|
1766
|
+
h = Math.round(x - k / 2), c = Math.round(B - k / 2), a = l = k;
|
|
1747
1767
|
const A = new o.Graphics();
|
|
1748
|
-
typeof A.circle == "function" && typeof A.fill == "function" ? A.circle(a / 2, l / 2, a / 2).fill(16777215) : (A.beginFill(16777215, 1), A.drawCircle(a / 2, l / 2, a / 2), A.endFill()),
|
|
1768
|
+
typeof A.circle == "function" && typeof A.fill == "function" ? A.circle(a / 2, l / 2, a / 2).fill(16777215) : (A.beginFill(16777215, 1), A.drawCircle(a / 2, l / 2, a / 2), A.endFill()), u.mask = A, p.addChild(A);
|
|
1749
1769
|
}
|
|
1750
|
-
|
|
1751
|
-
const
|
|
1752
|
-
i.renderer.render({ container:
|
|
1770
|
+
u.x = -h, u.y = -c, p.addChild(u);
|
|
1771
|
+
const f = o.RenderTexture.create({ width: a, height: l });
|
|
1772
|
+
i.renderer.render({ container: p, target: f, clear: !0 }), p.destroy({ children: !0 });
|
|
1753
1773
|
const m = this.renderer.originalTexture;
|
|
1754
|
-
m && m !== this.renderer.baseTexture && m.destroy(!0), this.renderer.originalTexture =
|
|
1755
|
-
const b = new o.Sprite(
|
|
1756
|
-
return i.stage.addChild(b), this.renderer.sprite = b, this.renderer.fitScale = this.renderer.getFitScaleFor(
|
|
1774
|
+
m && m !== this.renderer.baseTexture && m.destroy(!0), this.renderer.originalTexture = f, i.stage.removeChild(s), s.destroy();
|
|
1775
|
+
const b = new o.Sprite(f);
|
|
1776
|
+
return i.stage.addChild(b), this.renderer.sprite = b, this.renderer.fitScale = this.renderer.getFitScaleFor(f), this.renderer.setZoom(n, { keepCenter: !1 }), this.renderer.applyViewTransform(), this.renderer.render(), { texture: f, preservedZoom: n };
|
|
1757
1777
|
}
|
|
1758
1778
|
/**
|
|
1759
1779
|
* Cancel crop
|
|
@@ -1785,11 +1805,11 @@ const U = class U extends se {
|
|
|
1785
1805
|
* Padding factor for auto-zoom: image will be ~91% of crop size (1/1.1).
|
|
1786
1806
|
* Higher values = more aggressive zoom-out, more padding around image.
|
|
1787
1807
|
*/
|
|
1788
|
-
|
|
1808
|
+
ae(V, "AUTO_ZOOM_PADDING", 1.1), /**
|
|
1789
1809
|
* Minimum interval (ms) between auto-zoom adjustments during drag.
|
|
1790
1810
|
*/
|
|
1791
|
-
|
|
1792
|
-
let
|
|
1811
|
+
ae(V, "AUTO_ZOOM_THROTTLE_MS", 100);
|
|
1812
|
+
let de = V;
|
|
1793
1813
|
class Xe {
|
|
1794
1814
|
/**
|
|
1795
1815
|
* Create a new RemoveBgManager
|
|
@@ -1857,13 +1877,13 @@ class Xe {
|
|
|
1857
1877
|
* @returns {Promise<{dataUrl: string, model: string, processMs: string}>}
|
|
1858
1878
|
*/
|
|
1859
1879
|
async removeBackground(e, t = {}) {
|
|
1860
|
-
const i = typeof Blob < "u" && t.blob instanceof Blob ? t : await this.preparePreviewRequest(e, t),
|
|
1861
|
-
a.append("image_file",
|
|
1880
|
+
const i = typeof Blob < "u" && t.blob instanceof Blob ? t : await this.preparePreviewRequest(e, t), s = i.blob, r = i.operationId, o = i.sessionKey, n = i.sourceHash, a = new FormData();
|
|
1881
|
+
a.append("image_file", s, "image.png"), a.append("operation_id", r), a.append("session_key", o), a.append("source_hash", n), a.append("tier", i.tier || "balanced"), i.targetRef && a.append("target_ref", i.targetRef), i.model && a.append("model", i.model), i.alpha_matting && (a.append("alpha_matting", "true"), a.append("alpha_f", String(i.alpha_f ?? 10)), a.append("alpha_fr", String(i.alpha_fr ?? 15)), a.append("alpha_erode_size", String(i.alpha_erode_size ?? 10))), i.max_megapixels !== void 0 && a.append("max_megapixels", String(i.max_megapixels));
|
|
1862
1882
|
let l, h;
|
|
1863
|
-
const c = this._createAbortController(),
|
|
1883
|
+
const c = this._createAbortController(), p = (u) => c ? { ...u, signal: c.signal } : u;
|
|
1864
1884
|
try {
|
|
1865
1885
|
try {
|
|
1866
|
-
l = await fetch(this._endpoint,
|
|
1886
|
+
l = await fetch(this._endpoint, p({
|
|
1867
1887
|
method: "POST",
|
|
1868
1888
|
body: a,
|
|
1869
1889
|
credentials: "include"
|
|
@@ -1876,7 +1896,7 @@ class Xe {
|
|
|
1876
1896
|
}
|
|
1877
1897
|
if ((!l || !l.ok) && this._fallbackEndpoint)
|
|
1878
1898
|
try {
|
|
1879
|
-
l = await fetch(this._fallbackEndpoint,
|
|
1899
|
+
l = await fetch(this._fallbackEndpoint, p({
|
|
1880
1900
|
method: "POST",
|
|
1881
1901
|
body: a
|
|
1882
1902
|
}));
|
|
@@ -1896,12 +1916,12 @@ class Xe {
|
|
|
1896
1916
|
}
|
|
1897
1917
|
throw new Error(m);
|
|
1898
1918
|
}
|
|
1899
|
-
const
|
|
1919
|
+
const u = await l.blob();
|
|
1900
1920
|
return {
|
|
1901
|
-
dataUrl: await this._blobToDataUrl(
|
|
1921
|
+
dataUrl: await this._blobToDataUrl(u),
|
|
1902
1922
|
model: l.headers.get("X-Model-Used") || "unknown",
|
|
1903
1923
|
processMs: l.headers.get("X-Process-Ms") || "0",
|
|
1904
|
-
operationId: l.headers.get("X-Operation-Id") ||
|
|
1924
|
+
operationId: l.headers.get("X-Operation-Id") || r,
|
|
1905
1925
|
sessionKey: l.headers.get("X-Session-Key") || o,
|
|
1906
1926
|
sourceHash: l.headers.get("X-Source-Hash") || n,
|
|
1907
1927
|
targetRef: l.headers.get("X-Target-Ref") || i.targetRef || null
|
|
@@ -1932,10 +1952,10 @@ class Xe {
|
|
|
1932
1952
|
tier: e.tier || "balanced"
|
|
1933
1953
|
};
|
|
1934
1954
|
e.model && (i.model = e.model), e.alpha_matting !== void 0 && (i.alpha_matting = !!e.alpha_matting), e.max_megapixels !== void 0 && (i.max_megapixels = Number(e.max_megapixels));
|
|
1935
|
-
const
|
|
1936
|
-
let
|
|
1955
|
+
const s = this._createAbortController();
|
|
1956
|
+
let r;
|
|
1937
1957
|
try {
|
|
1938
|
-
if (
|
|
1958
|
+
if (r = await fetch(t, {
|
|
1939
1959
|
method: "POST",
|
|
1940
1960
|
body: JSON.stringify(i),
|
|
1941
1961
|
credentials: "include",
|
|
@@ -1943,19 +1963,19 @@ class Xe {
|
|
|
1943
1963
|
Accept: "application/json",
|
|
1944
1964
|
"Content-Type": "application/json"
|
|
1945
1965
|
},
|
|
1946
|
-
...
|
|
1947
|
-
}), !
|
|
1948
|
-
let o = `Background removal failed (HTTP ${
|
|
1966
|
+
...s ? { signal: s.signal } : {}
|
|
1967
|
+
}), !r.ok) {
|
|
1968
|
+
let o = `Background removal failed (HTTP ${r.status})`;
|
|
1949
1969
|
try {
|
|
1950
|
-
const n = await
|
|
1970
|
+
const n = await r.json();
|
|
1951
1971
|
n != null && n.message && (o += `: ${n.message}`);
|
|
1952
1972
|
} catch {
|
|
1953
1973
|
}
|
|
1954
1974
|
throw new Error(o);
|
|
1955
1975
|
}
|
|
1956
|
-
return await
|
|
1976
|
+
return await r.json();
|
|
1957
1977
|
} finally {
|
|
1958
|
-
this._releaseAbortController(
|
|
1978
|
+
this._releaseAbortController(s);
|
|
1959
1979
|
}
|
|
1960
1980
|
}
|
|
1961
1981
|
/**
|
|
@@ -1965,7 +1985,7 @@ class Xe {
|
|
|
1965
1985
|
*/
|
|
1966
1986
|
async _dataUrlToBlob(e) {
|
|
1967
1987
|
if (e.startsWith("data:")) {
|
|
1968
|
-
const [i,
|
|
1988
|
+
const [i, s] = e.split(","), r = i.match(/:(.*?);/), o = r ? r[1] : "image/png", n = atob(s), a = new Uint8Array(n.length);
|
|
1969
1989
|
for (let l = 0; l < n.length; l++)
|
|
1970
1990
|
a[l] = n.charCodeAt(l);
|
|
1971
1991
|
return new Blob([a], { type: o });
|
|
@@ -1979,8 +1999,8 @@ class Xe {
|
|
|
1979
1999
|
*/
|
|
1980
2000
|
_blobToDataUrl(e) {
|
|
1981
2001
|
return new Promise((t, i) => {
|
|
1982
|
-
const
|
|
1983
|
-
|
|
2002
|
+
const s = new FileReader();
|
|
2003
|
+
s.onload = () => t(s.result), s.onerror = () => i(new Error("Failed to read blob as data URL")), s.readAsDataURL(e);
|
|
1984
2004
|
});
|
|
1985
2005
|
}
|
|
1986
2006
|
/**
|
|
@@ -2029,61 +2049,61 @@ class Xe {
|
|
|
2029
2049
|
}
|
|
2030
2050
|
async _sha256Hex(e) {
|
|
2031
2051
|
const t = await e.arrayBuffer(), i = await globalThis.crypto.subtle.digest("SHA-256", t);
|
|
2032
|
-
return [...new Uint8Array(i)].map((
|
|
2052
|
+
return [...new Uint8Array(i)].map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
2033
2053
|
}
|
|
2034
2054
|
}
|
|
2035
|
-
function d(
|
|
2036
|
-
const i = document.createElement(
|
|
2037
|
-
for (const [
|
|
2038
|
-
if (
|
|
2039
|
-
if (
|
|
2040
|
-
i.className =
|
|
2041
|
-
else if (
|
|
2042
|
-
Object.assign(i.style,
|
|
2043
|
-
else if (
|
|
2044
|
-
const o =
|
|
2045
|
-
i.addEventListener(o,
|
|
2046
|
-
} else
|
|
2047
|
-
for (const
|
|
2048
|
-
typeof
|
|
2055
|
+
function d(g, e = {}, ...t) {
|
|
2056
|
+
const i = document.createElement(g);
|
|
2057
|
+
for (const [s, r] of Object.entries(e))
|
|
2058
|
+
if (r != null)
|
|
2059
|
+
if (s === "className")
|
|
2060
|
+
i.className = r;
|
|
2061
|
+
else if (s === "style" && typeof r == "object")
|
|
2062
|
+
Object.assign(i.style, r);
|
|
2063
|
+
else if (s.startsWith("on") && typeof r == "function") {
|
|
2064
|
+
const o = s.slice(2).toLowerCase();
|
|
2065
|
+
i.addEventListener(o, r);
|
|
2066
|
+
} else s === "dataset" && typeof r == "object" ? Object.assign(i.dataset, r) : i.setAttribute(s, r);
|
|
2067
|
+
for (const s of t)
|
|
2068
|
+
typeof s == "string" ? i.appendChild(document.createTextNode(s)) : s instanceof HTMLElement && i.appendChild(s);
|
|
2049
2069
|
return i;
|
|
2050
2070
|
}
|
|
2051
|
-
function ve({ id:
|
|
2052
|
-
const n =
|
|
2071
|
+
function ve({ id: g, label: e, min: t = 0, max: i = 1, step: s = 0.01, value: r = 0.5, onChange: o }) {
|
|
2072
|
+
const n = g.includes("-") ? g.split("-").slice(1).join("-") : g, a = d("div", {
|
|
2053
2073
|
className: "slider-control slider-wrapper",
|
|
2054
2074
|
"data-control": n,
|
|
2055
2075
|
"data-testid": `slider-${n}`
|
|
2056
2076
|
}), l = d(
|
|
2057
2077
|
"div",
|
|
2058
2078
|
{ className: "slider-header" },
|
|
2059
|
-
d("label", { for:
|
|
2060
|
-
d("span", { className: "slider-value", id: `${
|
|
2079
|
+
d("label", { for: g, className: "slider-label" }, e),
|
|
2080
|
+
d("span", { className: "slider-value", id: `${g}-value` }, le(r))
|
|
2061
2081
|
), h = d("input", {
|
|
2062
2082
|
type: "range",
|
|
2063
|
-
id:
|
|
2083
|
+
id: g,
|
|
2064
2084
|
className: "slider-input",
|
|
2065
2085
|
min: String(t),
|
|
2066
2086
|
max: String(i),
|
|
2067
|
-
step: String(
|
|
2068
|
-
value: String(
|
|
2087
|
+
step: String(s),
|
|
2088
|
+
value: String(r),
|
|
2069
2089
|
onInput: (c) => {
|
|
2070
|
-
const
|
|
2071
|
-
|
|
2090
|
+
const p = parseFloat(c.target.value), u = a.querySelector(".slider-value");
|
|
2091
|
+
u && (u.textContent = le(p)), o == null || o(p);
|
|
2072
2092
|
}
|
|
2073
2093
|
});
|
|
2074
2094
|
return a.appendChild(l), a.appendChild(h), a.setValue = (c) => {
|
|
2075
2095
|
h.value = String(c);
|
|
2076
|
-
const
|
|
2077
|
-
|
|
2096
|
+
const p = a.querySelector(".slider-value");
|
|
2097
|
+
p && (p.textContent = le(c));
|
|
2078
2098
|
}, a;
|
|
2079
2099
|
}
|
|
2080
|
-
function
|
|
2081
|
-
return Number.isInteger(
|
|
2100
|
+
function le(g) {
|
|
2101
|
+
return Number.isInteger(g) ? String(g) : g.toFixed(2);
|
|
2082
2102
|
}
|
|
2083
|
-
function we({ id:
|
|
2084
|
-
const
|
|
2103
|
+
function we({ id: g, label: e, checked: t = !1, onChange: i }) {
|
|
2104
|
+
const s = d("div", { className: "toggle-control" }), r = d("label", { className: "toggle-label", for: g }, e), o = d("input", {
|
|
2085
2105
|
type: "checkbox",
|
|
2086
|
-
id:
|
|
2106
|
+
id: g,
|
|
2087
2107
|
className: "toggle-input",
|
|
2088
2108
|
checked: t ? "checked" : void 0,
|
|
2089
2109
|
onChange: (l) => i == null ? void 0 : i(l.target.checked)
|
|
@@ -2093,32 +2113,32 @@ function we({ id: f, label: e, checked: t = !1, onChange: i }) {
|
|
|
2093
2113
|
l.target !== o && (o.checked = !o.checked, i == null || i(o.checked));
|
|
2094
2114
|
}
|
|
2095
2115
|
}), a = d("span", { className: "toggle-slider" });
|
|
2096
|
-
return n.appendChild(o), n.appendChild(a),
|
|
2116
|
+
return n.appendChild(o), n.appendChild(a), s.appendChild(r), s.appendChild(n), s.setChecked = (l) => {
|
|
2097
2117
|
o.checked = l;
|
|
2098
|
-
},
|
|
2118
|
+
}, s;
|
|
2099
2119
|
}
|
|
2100
|
-
function xe({ id:
|
|
2101
|
-
const
|
|
2120
|
+
function xe({ id: g, label: e, value: t = "#000000", onChange: i }) {
|
|
2121
|
+
const s = d("div", { className: "color-control" }), r = d("label", { className: "color-label", for: g }, e), o = d("input", {
|
|
2102
2122
|
type: "color",
|
|
2103
|
-
id:
|
|
2123
|
+
id: g,
|
|
2104
2124
|
className: "color-input",
|
|
2105
2125
|
value: t,
|
|
2106
2126
|
onInput: (n) => i == null ? void 0 : i(n.target.value)
|
|
2107
2127
|
});
|
|
2108
|
-
return
|
|
2128
|
+
return s.appendChild(r), s.appendChild(o), s.setValue = (n) => {
|
|
2109
2129
|
o.value = n;
|
|
2110
|
-
},
|
|
2130
|
+
}, s;
|
|
2111
2131
|
}
|
|
2112
|
-
function Ce({ id:
|
|
2113
|
-
const
|
|
2132
|
+
function Ce({ id: g, label: e, value: t = "", placeholder: i = "", onCommit: s }) {
|
|
2133
|
+
const r = d("div", {
|
|
2114
2134
|
className: "text-control",
|
|
2115
|
-
"data-control":
|
|
2116
|
-
"data-testid": `text-${
|
|
2117
|
-
}), o = d("label", { className: "text-label", for:
|
|
2135
|
+
"data-control": g,
|
|
2136
|
+
"data-testid": `text-${g}`
|
|
2137
|
+
}), o = d("label", { className: "text-label", for: g }, e);
|
|
2118
2138
|
let n = t;
|
|
2119
2139
|
const a = d("input", {
|
|
2120
2140
|
type: "text",
|
|
2121
|
-
id:
|
|
2141
|
+
id: g,
|
|
2122
2142
|
className: "text-input",
|
|
2123
2143
|
value: t,
|
|
2124
2144
|
placeholder: i,
|
|
@@ -2129,72 +2149,72 @@ function Ce({ id: f, label: e, value: t = "", placeholder: i = "", onCommit: r }
|
|
|
2129
2149
|
});
|
|
2130
2150
|
function l() {
|
|
2131
2151
|
const h = a.value;
|
|
2132
|
-
h !== n && (n = h,
|
|
2152
|
+
h !== n && (n = h, s == null || s(h));
|
|
2133
2153
|
}
|
|
2134
|
-
return
|
|
2154
|
+
return r.appendChild(o), r.appendChild(a), r.setValue = (h) => {
|
|
2135
2155
|
const c = h == null ? "" : String(h);
|
|
2136
2156
|
a.value = c, n = c;
|
|
2137
|
-
},
|
|
2157
|
+
}, r;
|
|
2138
2158
|
}
|
|
2139
|
-
function ke({ id:
|
|
2140
|
-
const
|
|
2141
|
-
id:
|
|
2159
|
+
function ke({ id: g, label: e, options: t = [], value: i, onChange: s }) {
|
|
2160
|
+
const r = d("div", { className: "select-control" }), o = d("label", { className: "select-label", for: g }, e), n = d("select", {
|
|
2161
|
+
id: g,
|
|
2142
2162
|
className: "select-input",
|
|
2143
|
-
onChange: (a) =>
|
|
2163
|
+
onChange: (a) => s == null ? void 0 : s(a.target.value)
|
|
2144
2164
|
});
|
|
2145
2165
|
for (const a of t) {
|
|
2146
2166
|
const l = d("option", { value: a.value }, a.label);
|
|
2147
2167
|
a.value === i && (l.selected = !0), n.appendChild(l);
|
|
2148
2168
|
}
|
|
2149
|
-
return
|
|
2169
|
+
return r.appendChild(o), r.appendChild(n), r.setValue = (a) => {
|
|
2150
2170
|
n.value = a;
|
|
2151
|
-
},
|
|
2171
|
+
}, r;
|
|
2152
2172
|
}
|
|
2153
|
-
function
|
|
2154
|
-
const
|
|
2173
|
+
function D({ label: g, className: e = "", onClick: t, icon: i = null, disabled: s = !1 }) {
|
|
2174
|
+
const r = d("button", {
|
|
2155
2175
|
type: "button",
|
|
2156
2176
|
className: `btn ${e}`.trim(),
|
|
2157
2177
|
onClick: t,
|
|
2158
|
-
disabled:
|
|
2178
|
+
disabled: s ? "disabled" : void 0
|
|
2159
2179
|
});
|
|
2160
2180
|
if (i) {
|
|
2161
2181
|
const o = d("span", { className: "btn-icon" });
|
|
2162
2182
|
o.innerHTML = i;
|
|
2163
2183
|
const n = o.querySelector("svg");
|
|
2164
|
-
n && n.setAttribute("aria-hidden", "true"),
|
|
2184
|
+
n && n.setAttribute("aria-hidden", "true"), r.appendChild(o);
|
|
2165
2185
|
}
|
|
2166
|
-
return
|
|
2186
|
+
return g && r.appendChild(document.createTextNode(g)), r;
|
|
2167
2187
|
}
|
|
2168
|
-
function
|
|
2188
|
+
function j({ icon: g, title: e, className: t = "", onClick: i, disabled: s = !1, testId: r = null, ariaLabel: o = null }) {
|
|
2169
2189
|
const n = {
|
|
2170
2190
|
type: "button",
|
|
2171
2191
|
className: `icon-btn ${t}`.trim(),
|
|
2172
2192
|
title: e,
|
|
2173
2193
|
"aria-label": o || e,
|
|
2174
2194
|
onClick: i,
|
|
2175
|
-
disabled:
|
|
2195
|
+
disabled: s ? "disabled" : void 0
|
|
2176
2196
|
};
|
|
2177
|
-
|
|
2197
|
+
r && (n.dataset = { testid: r });
|
|
2178
2198
|
const a = d("button", n);
|
|
2179
|
-
a.innerHTML =
|
|
2199
|
+
a.innerHTML = g;
|
|
2180
2200
|
const l = a.querySelector("svg");
|
|
2181
2201
|
return l && l.setAttribute("aria-hidden", "true"), a;
|
|
2182
2202
|
}
|
|
2183
|
-
function re({ label:
|
|
2184
|
-
const
|
|
2203
|
+
function re({ label: g, icon: e, active: t = !1, onClick: i }) {
|
|
2204
|
+
const s = d("button", {
|
|
2185
2205
|
type: "button",
|
|
2186
2206
|
className: `chip ${t ? "active" : ""}`.trim(),
|
|
2187
2207
|
onClick: i
|
|
2188
2208
|
});
|
|
2189
2209
|
if (e) {
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
const o =
|
|
2193
|
-
o && o.setAttribute("aria-hidden", "true"),
|
|
2210
|
+
const r = d("span", { className: "chip-icon" });
|
|
2211
|
+
r.innerHTML = e;
|
|
2212
|
+
const o = r.querySelector("svg");
|
|
2213
|
+
o && o.setAttribute("aria-hidden", "true"), s.appendChild(r);
|
|
2194
2214
|
}
|
|
2195
|
-
return
|
|
2196
|
-
|
|
2197
|
-
},
|
|
2215
|
+
return s.appendChild(d("span", { className: "chip-label" }, g)), s.setActive = (r) => {
|
|
2216
|
+
s.classList.toggle("active", r);
|
|
2217
|
+
}, s;
|
|
2198
2218
|
}
|
|
2199
2219
|
class et {
|
|
2200
2220
|
constructor(e, t) {
|
|
@@ -2206,7 +2226,7 @@ class et {
|
|
|
2206
2226
|
*/
|
|
2207
2227
|
render() {
|
|
2208
2228
|
this.element = d("div", { className: "editor-toolbar" });
|
|
2209
|
-
const e = d("div", { className: "toolbar-section toolbar-left" }), t =
|
|
2229
|
+
const e = d("div", { className: "toolbar-section toolbar-left" }), t = j({
|
|
2210
2230
|
icon: Ie,
|
|
2211
2231
|
title: "Open Image",
|
|
2212
2232
|
className: "toolbar-btn",
|
|
@@ -2216,14 +2236,14 @@ class et {
|
|
|
2216
2236
|
});
|
|
2217
2237
|
e.appendChild(t);
|
|
2218
2238
|
const i = d("div", { className: "toolbar-section toolbar-right" });
|
|
2219
|
-
this._themeBtn =
|
|
2239
|
+
this._themeBtn = j({
|
|
2220
2240
|
icon: this.state.get("isDarkMode") ? fe : ge,
|
|
2221
2241
|
title: "Toggle Theme",
|
|
2222
2242
|
className: "toolbar-btn toolbar-btn-theme",
|
|
2223
2243
|
testId: "btn-toggle-theme",
|
|
2224
2244
|
ariaLabel: "Toggle theme",
|
|
2225
2245
|
onClick: () => this.editor.toggleTheme()
|
|
2226
|
-
}), this._cropBtn =
|
|
2246
|
+
}), this._cropBtn = j({
|
|
2227
2247
|
icon: be,
|
|
2228
2248
|
title: "Crop",
|
|
2229
2249
|
className: "toolbar-btn toolbar-btn-crop",
|
|
@@ -2233,7 +2253,7 @@ class et {
|
|
|
2233
2253
|
this.state.get("mode") === "crop" ? this.editor.setMode("filters") : this.editor.setMode("crop");
|
|
2234
2254
|
}
|
|
2235
2255
|
});
|
|
2236
|
-
const
|
|
2256
|
+
const s = d("div", { className: "remove-bg-control" });
|
|
2237
2257
|
this._removeBgTierSelect = d("select", {
|
|
2238
2258
|
className: "remove-bg-tier-select",
|
|
2239
2259
|
title: "Background removal quality",
|
|
@@ -2251,7 +2271,7 @@ class et {
|
|
|
2251
2271
|
const c = d("option", { value: h[0] }, h[1]);
|
|
2252
2272
|
h[0] === this._removeBgTier && (c.selected = !0), this._removeBgTierSelect.appendChild(c);
|
|
2253
2273
|
}
|
|
2254
|
-
this._removeBgBtn =
|
|
2274
|
+
this._removeBgBtn = j({
|
|
2255
2275
|
icon: Ge,
|
|
2256
2276
|
title: "Remove Background",
|
|
2257
2277
|
className: "toolbar-btn toolbar-btn-remove-bg",
|
|
@@ -2275,8 +2295,8 @@ class et {
|
|
|
2275
2295
|
role: "status",
|
|
2276
2296
|
"aria-live": "polite",
|
|
2277
2297
|
"aria-atomic": "true"
|
|
2278
|
-
}),
|
|
2279
|
-
const
|
|
2298
|
+
}), s.appendChild(this._removeBgTierSelect), s.appendChild(this._removeBgBtn), s.appendChild(this._removeBgStatus);
|
|
2299
|
+
const r = j({
|
|
2280
2300
|
icon: ye,
|
|
2281
2301
|
title: "Reset All",
|
|
2282
2302
|
className: "toolbar-btn",
|
|
@@ -2294,15 +2314,15 @@ class et {
|
|
|
2294
2314
|
n.innerHTML = Oe;
|
|
2295
2315
|
const a = n.querySelector("svg");
|
|
2296
2316
|
a && a.setAttribute("aria-hidden", "true"), o.appendChild(n), o.appendChild(d("span", { className: "toolbar-save-label" }, "Save"));
|
|
2297
|
-
const l =
|
|
2298
|
-
icon:
|
|
2317
|
+
const l = j({
|
|
2318
|
+
icon: ue,
|
|
2299
2319
|
title: "Close",
|
|
2300
2320
|
className: "toolbar-btn",
|
|
2301
2321
|
testId: "btn-cancel-edit",
|
|
2302
2322
|
ariaLabel: "Close editor",
|
|
2303
2323
|
onClick: () => this.editor.close()
|
|
2304
2324
|
});
|
|
2305
|
-
return i.appendChild(this._themeBtn), i.appendChild(this._cropBtn), i.appendChild(
|
|
2325
|
+
return i.appendChild(this._themeBtn), i.appendChild(this._cropBtn), i.appendChild(s), i.appendChild(r), i.appendChild(o), i.appendChild(l), this.element.appendChild(e), this.element.appendChild(i), this._subscribeToState(), this.element;
|
|
2306
2326
|
}
|
|
2307
2327
|
/**
|
|
2308
2328
|
* Subscribe to state changes
|
|
@@ -2318,10 +2338,10 @@ class et {
|
|
|
2318
2338
|
this._unsubscribers.push(t);
|
|
2319
2339
|
const i = this.state.on("change:hasImage", () => this._updateRemoveBgButton());
|
|
2320
2340
|
this._unsubscribers.push(i);
|
|
2321
|
-
const
|
|
2322
|
-
this._unsubscribers.push(r);
|
|
2323
|
-
const s = this.state.on("change:backgroundRemovalAvailable", () => this._updateRemoveBgButton());
|
|
2341
|
+
const s = this.state.on("change:isProcessing", () => this._updateRemoveBgButton());
|
|
2324
2342
|
this._unsubscribers.push(s);
|
|
2343
|
+
const r = this.state.on("change:backgroundRemovalAvailable", () => this._updateRemoveBgButton());
|
|
2344
|
+
this._unsubscribers.push(r);
|
|
2325
2345
|
const o = this.state.on("change:editorDocument", () => this._updateRemoveBgButton());
|
|
2326
2346
|
this._unsubscribers.push(o);
|
|
2327
2347
|
const n = this.state.on("change:layers", () => this._updateRemoveBgButton());
|
|
@@ -2348,7 +2368,7 @@ class et {
|
|
|
2348
2368
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], (e = this.element) == null || e.remove(), this.element = null;
|
|
2349
2369
|
}
|
|
2350
2370
|
}
|
|
2351
|
-
const
|
|
2371
|
+
const se = pe;
|
|
2352
2372
|
class tt {
|
|
2353
2373
|
constructor(e, t) {
|
|
2354
2374
|
this.state = e, this.editor = t, this.element = null, this._chips = /* @__PURE__ */ new Map(), this._scrollIndex = 0, this._unsubscribers = [];
|
|
@@ -2362,20 +2382,20 @@ class tt {
|
|
|
2362
2382
|
this._onSelect = e, this.element = d("div", {
|
|
2363
2383
|
className: "category-carousel-container",
|
|
2364
2384
|
"data-testid": "category-carousel"
|
|
2365
|
-
}), this._leftBtn =
|
|
2385
|
+
}), this._leftBtn = j({
|
|
2366
2386
|
icon: _e,
|
|
2367
2387
|
title: "Previous categories",
|
|
2368
2388
|
className: "carousel-nav carousel-nav-left",
|
|
2369
2389
|
onClick: () => this._scrollLeft()
|
|
2370
|
-
}), this._carousel = d("div", { className: "category-carousel" }),
|
|
2371
|
-
const
|
|
2390
|
+
}), this._carousel = d("div", { className: "category-carousel" }), se.forEach((i) => {
|
|
2391
|
+
const s = re({
|
|
2372
2392
|
label: i.name,
|
|
2373
2393
|
icon: i.icon,
|
|
2374
2394
|
active: this.state.get("selectedCategory") === i.id,
|
|
2375
2395
|
onClick: () => this._selectCategory(i.id)
|
|
2376
2396
|
});
|
|
2377
|
-
|
|
2378
|
-
}), this._rightBtn =
|
|
2397
|
+
s.dataset.categoryId = i.id, s.dataset.category = i.id, s.dataset.testid = `category-${i.id}`, this._chips.set(i.id, s), this._carousel.appendChild(s);
|
|
2398
|
+
}), this._rightBtn = j({
|
|
2379
2399
|
icon: me,
|
|
2380
2400
|
title: "Next categories",
|
|
2381
2401
|
className: "carousel-nav carousel-nav-right",
|
|
@@ -2385,9 +2405,9 @@ class tt {
|
|
|
2385
2405
|
role: "tablist",
|
|
2386
2406
|
"aria-label": "Category pages"
|
|
2387
2407
|
});
|
|
2388
|
-
const t = Math.ceil(
|
|
2408
|
+
const t = Math.ceil(se.length / 3);
|
|
2389
2409
|
for (let i = 0; i < t; i++) {
|
|
2390
|
-
const
|
|
2410
|
+
const s = d("button", {
|
|
2391
2411
|
type: "button",
|
|
2392
2412
|
className: `pagination-dot ${i === 0 ? "active" : ""}`,
|
|
2393
2413
|
role: "tab",
|
|
@@ -2395,7 +2415,7 @@ class tt {
|
|
|
2395
2415
|
"aria-selected": i === 0 ? "true" : "false",
|
|
2396
2416
|
onClick: () => this._scrollToPage(i)
|
|
2397
2417
|
});
|
|
2398
|
-
this._pagination.appendChild(
|
|
2418
|
+
this._pagination.appendChild(s);
|
|
2399
2419
|
}
|
|
2400
2420
|
return this.element.appendChild(this._leftBtn), this.element.appendChild(this._carousel), this.element.appendChild(this._rightBtn), this.element.appendChild(this._pagination), this._subscribeToState(), this._updateNavButtons(), this.element;
|
|
2401
2421
|
}
|
|
@@ -2404,8 +2424,8 @@ class tt {
|
|
|
2404
2424
|
*/
|
|
2405
2425
|
_subscribeToState() {
|
|
2406
2426
|
const e = this.state.on("change:selectedCategory", ({ value: t }) => {
|
|
2407
|
-
this._chips.forEach((i,
|
|
2408
|
-
i.setActive(
|
|
2427
|
+
this._chips.forEach((i, s) => {
|
|
2428
|
+
i.setActive(s === t);
|
|
2409
2429
|
});
|
|
2410
2430
|
});
|
|
2411
2431
|
this._unsubscribers.push(e);
|
|
@@ -2415,12 +2435,12 @@ class tt {
|
|
|
2415
2435
|
* @param {string} categoryId
|
|
2416
2436
|
*/
|
|
2417
2437
|
_selectCategory(e) {
|
|
2418
|
-
var
|
|
2438
|
+
var s;
|
|
2419
2439
|
this.state.set("selectedCategory", e);
|
|
2420
2440
|
const t = this.state.get("mode");
|
|
2421
2441
|
e === "crop" ? t !== "crop" && this.editor.setMode("crop") : t !== "filters" && this.editor.setMode("filters");
|
|
2422
2442
|
const i = this._chips.get(e);
|
|
2423
|
-
i && this._carousel && i.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }), (
|
|
2443
|
+
i && this._carousel && i.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }), (s = this._onSelect) == null || s.call(this, e);
|
|
2424
2444
|
}
|
|
2425
2445
|
/**
|
|
2426
2446
|
* Scroll carousel left
|
|
@@ -2432,7 +2452,7 @@ class tt {
|
|
|
2432
2452
|
* Scroll carousel right
|
|
2433
2453
|
*/
|
|
2434
2454
|
_scrollRight() {
|
|
2435
|
-
this._scrollIndex <
|
|
2455
|
+
this._scrollIndex < se.length - 3 && (this._scrollIndex++, this._scrollCarousel());
|
|
2436
2456
|
}
|
|
2437
2457
|
/**
|
|
2438
2458
|
* Scroll to a specific page
|
|
@@ -2459,7 +2479,7 @@ class tt {
|
|
|
2459
2479
|
* Update navigation button states
|
|
2460
2480
|
*/
|
|
2461
2481
|
_updateNavButtons() {
|
|
2462
|
-
this._leftBtn && (this._leftBtn.disabled = this._scrollIndex === 0), this._rightBtn && (this._rightBtn.disabled = this._scrollIndex >=
|
|
2482
|
+
this._leftBtn && (this._leftBtn.disabled = this._scrollIndex === 0), this._rightBtn && (this._rightBtn.disabled = this._scrollIndex >= se.length - 3);
|
|
2463
2483
|
}
|
|
2464
2484
|
/**
|
|
2465
2485
|
* Update pagination dot states
|
|
@@ -2467,9 +2487,9 @@ class tt {
|
|
|
2467
2487
|
_updatePagination() {
|
|
2468
2488
|
if (this._pagination) {
|
|
2469
2489
|
const e = this._pagination.querySelectorAll(".pagination-dot"), t = Math.floor(this._scrollIndex / 3);
|
|
2470
|
-
e.forEach((i,
|
|
2471
|
-
const
|
|
2472
|
-
i.classList.toggle("active",
|
|
2490
|
+
e.forEach((i, s) => {
|
|
2491
|
+
const r = s === t;
|
|
2492
|
+
i.classList.toggle("active", r), i.setAttribute("aria-selected", r ? "true" : "false");
|
|
2473
2493
|
});
|
|
2474
2494
|
}
|
|
2475
2495
|
}
|
|
@@ -2498,12 +2518,12 @@ class it {
|
|
|
2498
2518
|
* @returns {HTMLElement}
|
|
2499
2519
|
*/
|
|
2500
2520
|
render({ onToggle: e, onSelect: t }) {
|
|
2501
|
-
return this._onToggle = e, this._onSelect = t, this.element = d("div", { className: "filter-carousel-container" }), this._leftBtn =
|
|
2521
|
+
return this._onToggle = e, this._onSelect = t, this.element = d("div", { className: "filter-carousel-container" }), this._leftBtn = j({
|
|
2502
2522
|
icon: _e,
|
|
2503
2523
|
title: "Previous filters",
|
|
2504
2524
|
className: "carousel-nav carousel-nav-left",
|
|
2505
2525
|
onClick: () => this._scrollLeft()
|
|
2506
|
-
}), this._carousel = d("div", { className: "filter-carousel" }), this._rightBtn =
|
|
2526
|
+
}), this._carousel = d("div", { className: "filter-carousel" }), this._rightBtn = j({
|
|
2507
2527
|
icon: me,
|
|
2508
2528
|
title: "Next filters",
|
|
2509
2529
|
className: "carousel-nav carousel-nav-right",
|
|
@@ -2534,13 +2554,13 @@ class it {
|
|
|
2534
2554
|
this._carousel.innerHTML = "", this._filterCards.clear(), this._scrollIndex = 0;
|
|
2535
2555
|
const e = this.state.get("selectedCategory");
|
|
2536
2556
|
if (e === "crop") return;
|
|
2537
|
-
const t = this.filterManager.getFiltersByCategory(e), i = this.state.get("activeFilters"),
|
|
2538
|
-
t.forEach((
|
|
2539
|
-
const o = this._createFilterCard(
|
|
2540
|
-
isActive: i.has(
|
|
2541
|
-
isSelected:
|
|
2557
|
+
const t = this.filterManager.getFiltersByCategory(e), i = this.state.get("activeFilters"), s = this.state.get("selectedFilter");
|
|
2558
|
+
t.forEach((r) => {
|
|
2559
|
+
const o = this._createFilterCard(r, {
|
|
2560
|
+
isActive: i.has(r.id),
|
|
2561
|
+
isSelected: s === r.id
|
|
2542
2562
|
});
|
|
2543
|
-
this._filterCards.set(
|
|
2563
|
+
this._filterCards.set(r.id, o), this._carousel.appendChild(o);
|
|
2544
2564
|
}), this._updateNavButtons();
|
|
2545
2565
|
}
|
|
2546
2566
|
/**
|
|
@@ -2550,23 +2570,23 @@ class it {
|
|
|
2550
2570
|
* @returns {HTMLElement}
|
|
2551
2571
|
*/
|
|
2552
2572
|
_createFilterCard(e, { isActive: t, isSelected: i }) {
|
|
2553
|
-
const
|
|
2573
|
+
const s = d("div", {
|
|
2554
2574
|
className: `filter-card ${t ? "active" : ""} ${i ? "selected" : ""}`,
|
|
2555
2575
|
"data-filter": e.id,
|
|
2556
2576
|
"data-testid": `filter-${e.id}`,
|
|
2557
2577
|
onClick: () => this._handleCardClick(e.id)
|
|
2558
|
-
}),
|
|
2559
|
-
|
|
2578
|
+
}), r = d("div", { className: "filter-preview" }), o = d("span", { className: "filter-preview-text" }, e.name.charAt(0));
|
|
2579
|
+
r.appendChild(o);
|
|
2560
2580
|
const n = d("span", { className: "filter-name", title: e.name }, e.name), a = d("button", {
|
|
2561
2581
|
className: `filter-toggle ${t ? "active" : ""}`,
|
|
2562
2582
|
onClick: (l) => {
|
|
2563
|
-
var
|
|
2583
|
+
var p;
|
|
2564
2584
|
l.stopPropagation();
|
|
2565
2585
|
const c = !this.state.get("activeFilters").has(e.id);
|
|
2566
|
-
this._handleToggle(e.id, c), c && (this.state.set("selectedFilter", e.id), (
|
|
2586
|
+
this._handleToggle(e.id, c), c && (this.state.set("selectedFilter", e.id), (p = this._onSelect) == null || p.call(this, e.id));
|
|
2567
2587
|
}
|
|
2568
2588
|
});
|
|
2569
|
-
return a.innerHTML = t ?
|
|
2589
|
+
return a.innerHTML = t ? ce : "", s.appendChild(r), s.appendChild(n), s.appendChild(a), s._toggle = a, s._isActive = t, s;
|
|
2570
2590
|
}
|
|
2571
2591
|
/**
|
|
2572
2592
|
* Handle filter card click (select)
|
|
@@ -2591,8 +2611,8 @@ class it {
|
|
|
2591
2611
|
_updateActiveStates() {
|
|
2592
2612
|
const e = this.state.get("activeFilters");
|
|
2593
2613
|
this._filterCards.forEach((t, i) => {
|
|
2594
|
-
const
|
|
2595
|
-
t.classList.toggle("active",
|
|
2614
|
+
const s = e.has(i);
|
|
2615
|
+
t.classList.toggle("active", s), t._toggle.classList.toggle("active", s), t._toggle.innerHTML = s ? ce : "", t._isActive = s;
|
|
2596
2616
|
});
|
|
2597
2617
|
}
|
|
2598
2618
|
/**
|
|
@@ -2645,7 +2665,7 @@ class it {
|
|
|
2645
2665
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._filterCards.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
2646
2666
|
}
|
|
2647
2667
|
}
|
|
2648
|
-
class
|
|
2668
|
+
class st {
|
|
2649
2669
|
constructor(e, t) {
|
|
2650
2670
|
this.state = e, this.filterManager = t, this.element = null, this._controls = /* @__PURE__ */ new Map(), this._onChange = null, this._onReset = null, this._onAction = null, this._unsubscribers = [];
|
|
2651
2671
|
}
|
|
@@ -2694,15 +2714,15 @@ class rt {
|
|
|
2694
2714
|
return;
|
|
2695
2715
|
}
|
|
2696
2716
|
const i = d("div", { className: "adjustments-header" });
|
|
2697
|
-
i.appendChild(d("span", { className: "adjustments-title" }, t.name)), i.appendChild(
|
|
2717
|
+
i.appendChild(d("span", { className: "adjustments-title" }, t.name)), i.appendChild(D({
|
|
2698
2718
|
label: "Reset",
|
|
2699
2719
|
className: "btn-text",
|
|
2700
2720
|
onClick: () => this._handleReset(e)
|
|
2701
2721
|
})), this.element.appendChild(i);
|
|
2702
|
-
const
|
|
2722
|
+
const s = d("div", { className: "adjustments-grid" }), r = this.state.getFilterValues(e);
|
|
2703
2723
|
(t.controls || []).forEach((n) => {
|
|
2704
|
-
const a =
|
|
2705
|
-
l && (this._controls.set(n.id, l),
|
|
2724
|
+
const a = r[n.id] ?? n.default, l = this._createControl(e, n, a);
|
|
2725
|
+
l && (this._controls.set(n.id, l), s.appendChild(l));
|
|
2706
2726
|
});
|
|
2707
2727
|
const o = this.filterManager.getInstance(e);
|
|
2708
2728
|
if (o && typeof o.getDynamicControls == "function") {
|
|
@@ -2712,11 +2732,11 @@ class rt {
|
|
|
2712
2732
|
} catch {
|
|
2713
2733
|
}
|
|
2714
2734
|
n.forEach((a) => {
|
|
2715
|
-
const l = a.property || a.id, h =
|
|
2716
|
-
c && (this._controls.set(a.id, c),
|
|
2735
|
+
const l = a.property || a.id, h = r[l] ?? a.default, c = this._createControl(e, a, h);
|
|
2736
|
+
c && (this._controls.set(a.id, c), s.appendChild(c));
|
|
2717
2737
|
});
|
|
2718
2738
|
}
|
|
2719
|
-
this.element.appendChild(
|
|
2739
|
+
this.element.appendChild(s);
|
|
2720
2740
|
}
|
|
2721
2741
|
/**
|
|
2722
2742
|
* Create a control element based on type.
|
|
@@ -2734,12 +2754,12 @@ class rt {
|
|
|
2734
2754
|
*/
|
|
2735
2755
|
_createControl(e, t, i) {
|
|
2736
2756
|
if (t.hidden) return null;
|
|
2737
|
-
const
|
|
2738
|
-
switch (
|
|
2757
|
+
const s = t.label || t.id, r = this._normalizeControlType(t.type), o = t.property || t.id;
|
|
2758
|
+
switch (r) {
|
|
2739
2759
|
case "slider":
|
|
2740
2760
|
return ve({
|
|
2741
2761
|
id: `${e}-${t.id}`,
|
|
2742
|
-
label:
|
|
2762
|
+
label: s,
|
|
2743
2763
|
min: t.min ?? 0,
|
|
2744
2764
|
max: t.max ?? 1,
|
|
2745
2765
|
step: t.step ?? 0.01,
|
|
@@ -2749,14 +2769,14 @@ class rt {
|
|
|
2749
2769
|
case "toggle":
|
|
2750
2770
|
return we({
|
|
2751
2771
|
id: `${e}-${t.id}`,
|
|
2752
|
-
label:
|
|
2772
|
+
label: s,
|
|
2753
2773
|
checked: !!i,
|
|
2754
2774
|
onChange: (l) => this._handleChange(e, o, l)
|
|
2755
2775
|
});
|
|
2756
2776
|
case "color":
|
|
2757
2777
|
return xe({
|
|
2758
2778
|
id: `${e}-${t.id}`,
|
|
2759
|
-
label:
|
|
2779
|
+
label: s,
|
|
2760
2780
|
value: typeof i == "string" && i.startsWith("#") ? i : t.default || "#000000",
|
|
2761
2781
|
onChange: (l) => this._handleChange(e, o, l)
|
|
2762
2782
|
});
|
|
@@ -2764,7 +2784,7 @@ class rt {
|
|
|
2764
2784
|
const n = this._normalizeOptions(t.options);
|
|
2765
2785
|
return ke({
|
|
2766
2786
|
id: `${e}-${t.id}`,
|
|
2767
|
-
label:
|
|
2787
|
+
label: s,
|
|
2768
2788
|
options: n,
|
|
2769
2789
|
value: i ?? t.default,
|
|
2770
2790
|
onChange: (l) => this._handleChange(e, o, l)
|
|
@@ -2772,15 +2792,15 @@ class rt {
|
|
|
2772
2792
|
case "text":
|
|
2773
2793
|
return Ce({
|
|
2774
2794
|
id: `${e}-${t.id}`,
|
|
2775
|
-
label:
|
|
2795
|
+
label: s,
|
|
2776
2796
|
value: typeof i == "string" ? i : t.default ?? "",
|
|
2777
2797
|
placeholder: t.placeholder || "",
|
|
2778
2798
|
onCommit: (l) => this._handleChange(e, o, l)
|
|
2779
2799
|
});
|
|
2780
2800
|
case "button":
|
|
2781
2801
|
const a = d("div", { className: "button-control" });
|
|
2782
|
-
return a.appendChild(
|
|
2783
|
-
label:
|
|
2802
|
+
return a.appendChild(D({
|
|
2803
|
+
label: s,
|
|
2784
2804
|
className: "btn-secondary",
|
|
2785
2805
|
onClick: () => this._handleAction(e, t.action || t.id)
|
|
2786
2806
|
})), a;
|
|
@@ -2821,8 +2841,8 @@ class rt {
|
|
|
2821
2841
|
* @param {*} value
|
|
2822
2842
|
*/
|
|
2823
2843
|
_handleChange(e, t, i) {
|
|
2824
|
-
var
|
|
2825
|
-
(
|
|
2844
|
+
var s;
|
|
2845
|
+
(s = this._onChange) == null || s.call(this, e, t, i);
|
|
2826
2846
|
}
|
|
2827
2847
|
/**
|
|
2828
2848
|
* Handle reset button
|
|
@@ -2851,11 +2871,11 @@ class rt {
|
|
|
2851
2871
|
const e = this.state.get("selectedFilter");
|
|
2852
2872
|
if (!e) return;
|
|
2853
2873
|
const t = this.state.getFilterValues(e), i = this.filterManager.getFilterDef(e);
|
|
2854
|
-
i && i.controls.forEach((
|
|
2855
|
-
const
|
|
2856
|
-
if (
|
|
2857
|
-
const o = t[
|
|
2858
|
-
|
|
2874
|
+
i && i.controls.forEach((s) => {
|
|
2875
|
+
const r = this._controls.get(s.id);
|
|
2876
|
+
if (r && typeof r.setValue == "function") {
|
|
2877
|
+
const o = t[s.id] ?? s.default;
|
|
2878
|
+
r.setValue(o);
|
|
2859
2879
|
}
|
|
2860
2880
|
});
|
|
2861
2881
|
}
|
|
@@ -2879,7 +2899,7 @@ class rt {
|
|
|
2879
2899
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._controls.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
2880
2900
|
}
|
|
2881
2901
|
}
|
|
2882
|
-
class
|
|
2902
|
+
class rt {
|
|
2883
2903
|
constructor(e, t) {
|
|
2884
2904
|
this.state = e, this.filterManager = t, this._drawer = null, this._body = null, this._titleEl = null, this._isOpen = !1, this._currentFilterId = null, this._controls = /* @__PURE__ */ new Map(), this._onChange = null, this._onReset = null, this._onRemove = null, this._onAction = null, this._container = null;
|
|
2885
2905
|
}
|
|
@@ -2888,26 +2908,26 @@ class st {
|
|
|
2888
2908
|
* @param {HTMLElement} container - Parent element (controls-section)
|
|
2889
2909
|
* @param {Object} callbacks - { onChange, onReset, onRemove, onAction }
|
|
2890
2910
|
*/
|
|
2891
|
-
build(e, { onChange: t, onReset: i, onRemove:
|
|
2892
|
-
this._onChange = t, this._onReset = i, this._onRemove =
|
|
2911
|
+
build(e, { onChange: t, onReset: i, onRemove: s, onAction: r }) {
|
|
2912
|
+
this._onChange = t, this._onReset = i, this._onRemove = s, this._onAction = r, this._container = e, this._drawer = d("div", { className: "mobile-filter-drawer" });
|
|
2893
2913
|
const o = d("div", { className: "drawer-header" });
|
|
2894
2914
|
this._titleEl = d("span", { className: "drawer-title" }, "Filter");
|
|
2895
|
-
const n = d("div", { className: "drawer-header-actions" }), a =
|
|
2915
|
+
const n = d("div", { className: "drawer-header-actions" }), a = D({
|
|
2896
2916
|
label: "Reset",
|
|
2897
2917
|
className: "btn-text",
|
|
2898
2918
|
onClick: () => {
|
|
2899
2919
|
var c;
|
|
2900
2920
|
this._currentFilterId && ((c = this._onReset) == null || c.call(this, this._currentFilterId), this._renderControls());
|
|
2901
2921
|
}
|
|
2902
|
-
}), l =
|
|
2922
|
+
}), l = D({
|
|
2903
2923
|
label: "Remove",
|
|
2904
2924
|
className: "btn-text btn-danger",
|
|
2905
2925
|
onClick: () => {
|
|
2906
2926
|
var c;
|
|
2907
2927
|
this._currentFilterId && ((c = this._onRemove) == null || c.call(this, this._currentFilterId), this.close());
|
|
2908
2928
|
}
|
|
2909
|
-
}), h =
|
|
2910
|
-
icon:
|
|
2929
|
+
}), h = j({
|
|
2930
|
+
icon: ue,
|
|
2911
2931
|
title: "Close",
|
|
2912
2932
|
className: "btn-icon-sm",
|
|
2913
2933
|
ariaLabel: "Close drawer",
|
|
@@ -2966,19 +2986,19 @@ class st {
|
|
|
2966
2986
|
if (!e) return;
|
|
2967
2987
|
this._titleEl.textContent = e.name;
|
|
2968
2988
|
const t = d("div", { className: "adjustments-grid" }), i = this.state.getFilterValues(this._currentFilterId);
|
|
2969
|
-
(e.controls || []).forEach((
|
|
2970
|
-
if (
|
|
2971
|
-
const o = this._createControl(this._currentFilterId,
|
|
2972
|
-
o && (this._controls.set(
|
|
2989
|
+
(e.controls || []).forEach((r) => {
|
|
2990
|
+
if (r.hidden) return;
|
|
2991
|
+
const o = this._createControl(this._currentFilterId, r, i[r.id] ?? r.default);
|
|
2992
|
+
o && (this._controls.set(r.id, o), t.appendChild(o));
|
|
2973
2993
|
});
|
|
2974
|
-
const
|
|
2975
|
-
if (
|
|
2976
|
-
let
|
|
2994
|
+
const s = this.filterManager.getInstance(this._currentFilterId);
|
|
2995
|
+
if (s && typeof s.getDynamicControls == "function") {
|
|
2996
|
+
let r = [];
|
|
2977
2997
|
try {
|
|
2978
|
-
|
|
2998
|
+
r = s.getDynamicControls() || [];
|
|
2979
2999
|
} catch {
|
|
2980
3000
|
}
|
|
2981
|
-
|
|
3001
|
+
r.forEach((o) => {
|
|
2982
3002
|
const n = o.property || o.id, a = i[n] ?? o.default, l = this._createControl(this._currentFilterId, o, a);
|
|
2983
3003
|
l && (this._controls.set(o.id, l), t.appendChild(l));
|
|
2984
3004
|
});
|
|
@@ -2995,12 +3015,12 @@ class st {
|
|
|
2995
3015
|
*/
|
|
2996
3016
|
_createControl(e, t, i) {
|
|
2997
3017
|
if (t.hidden) return null;
|
|
2998
|
-
const
|
|
2999
|
-
switch (
|
|
3018
|
+
const s = t.label || t.id, r = this._normalizeControlType(t.type), o = t.property || t.id;
|
|
3019
|
+
switch (r) {
|
|
3000
3020
|
case "slider":
|
|
3001
3021
|
return ve({
|
|
3002
3022
|
id: `drawer-${e}-${t.id}`,
|
|
3003
|
-
label:
|
|
3023
|
+
label: s,
|
|
3004
3024
|
min: t.min ?? 0,
|
|
3005
3025
|
max: t.max ?? 1,
|
|
3006
3026
|
step: t.step ?? 0.01,
|
|
@@ -3013,7 +3033,7 @@ class st {
|
|
|
3013
3033
|
case "toggle":
|
|
3014
3034
|
return we({
|
|
3015
3035
|
id: `drawer-${e}-${t.id}`,
|
|
3016
|
-
label:
|
|
3036
|
+
label: s,
|
|
3017
3037
|
checked: !!i,
|
|
3018
3038
|
onChange: (n) => {
|
|
3019
3039
|
var a;
|
|
@@ -3023,7 +3043,7 @@ class st {
|
|
|
3023
3043
|
case "color":
|
|
3024
3044
|
return xe({
|
|
3025
3045
|
id: `drawer-${e}-${t.id}`,
|
|
3026
|
-
label:
|
|
3046
|
+
label: s,
|
|
3027
3047
|
value: typeof i == "string" && i.startsWith("#") ? i : t.default || "#000000",
|
|
3028
3048
|
onChange: (n) => {
|
|
3029
3049
|
var a;
|
|
@@ -3034,7 +3054,7 @@ class st {
|
|
|
3034
3054
|
const n = this._normalizeOptions(t.options);
|
|
3035
3055
|
return ke({
|
|
3036
3056
|
id: `drawer-${e}-${t.id}`,
|
|
3037
|
-
label:
|
|
3057
|
+
label: s,
|
|
3038
3058
|
options: n,
|
|
3039
3059
|
value: i ?? t.default,
|
|
3040
3060
|
onChange: (a) => {
|
|
@@ -3046,7 +3066,7 @@ class st {
|
|
|
3046
3066
|
case "text":
|
|
3047
3067
|
return Ce({
|
|
3048
3068
|
id: `drawer-${e}-${t.id}`,
|
|
3049
|
-
label:
|
|
3069
|
+
label: s,
|
|
3050
3070
|
value: typeof i == "string" ? i : t.default ?? "",
|
|
3051
3071
|
placeholder: t.placeholder || "",
|
|
3052
3072
|
onCommit: (n) => {
|
|
@@ -3056,8 +3076,8 @@ class st {
|
|
|
3056
3076
|
});
|
|
3057
3077
|
case "button": {
|
|
3058
3078
|
const n = d("div", { className: "button-control" });
|
|
3059
|
-
return n.appendChild(
|
|
3060
|
-
label:
|
|
3079
|
+
return n.appendChild(D({
|
|
3080
|
+
label: s,
|
|
3061
3081
|
className: "btn-secondary",
|
|
3062
3082
|
onClick: () => {
|
|
3063
3083
|
var a;
|
|
@@ -3140,8 +3160,8 @@ class nt {
|
|
|
3140
3160
|
e.forEach((t) => {
|
|
3141
3161
|
const i = this.filterManager.getFilterDef(t);
|
|
3142
3162
|
if (!i) return;
|
|
3143
|
-
const
|
|
3144
|
-
this._chips.set(t,
|
|
3163
|
+
const s = this._createChip(t, i);
|
|
3164
|
+
this._chips.set(t, s), this._scrollContainer.appendChild(s);
|
|
3145
3165
|
}), this._updateSelectedState();
|
|
3146
3166
|
}
|
|
3147
3167
|
_createChip(e, t) {
|
|
@@ -3149,13 +3169,13 @@ class nt {
|
|
|
3149
3169
|
className: "active-filter-chip",
|
|
3150
3170
|
"data-filter-id": e,
|
|
3151
3171
|
"data-testid": `active-chip-${e}`
|
|
3152
|
-
}),
|
|
3172
|
+
}), s = d("span", {
|
|
3153
3173
|
className: "active-filter-chip-label",
|
|
3154
3174
|
onClick: (o) => {
|
|
3155
3175
|
var n;
|
|
3156
3176
|
o.stopPropagation(), (n = this._onSelect) == null || n.call(this, e);
|
|
3157
3177
|
}
|
|
3158
|
-
}, t.name),
|
|
3178
|
+
}, t.name), r = d("button", {
|
|
3159
3179
|
className: "active-filter-chip-check",
|
|
3160
3180
|
"aria-label": `Remove ${t.name} filter`,
|
|
3161
3181
|
onClick: (o) => {
|
|
@@ -3163,7 +3183,7 @@ class nt {
|
|
|
3163
3183
|
o.stopPropagation(), (n = this._onToggle) == null || n.call(this, e, !1);
|
|
3164
3184
|
}
|
|
3165
3185
|
});
|
|
3166
|
-
return
|
|
3186
|
+
return r.innerHTML = '<svg width="10" height="10" viewBox="0 0 12 12"><path d="M2 6l3 3 5-5" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>', i.appendChild(s), i.appendChild(r), i;
|
|
3167
3187
|
}
|
|
3168
3188
|
_updateSelectedState() {
|
|
3169
3189
|
const e = this.state.get("selectedFilter");
|
|
@@ -3193,9 +3213,9 @@ const ot = [
|
|
|
3193
3213
|
{ id: "180", label: "180°", angle: 180 },
|
|
3194
3214
|
{ id: "270", label: "270°", angle: 270 }
|
|
3195
3215
|
];
|
|
3196
|
-
function
|
|
3197
|
-
if (!Number.isFinite(Number(
|
|
3198
|
-
const e = Number(
|
|
3216
|
+
function $(g) {
|
|
3217
|
+
if (!Number.isFinite(Number(g))) return 0;
|
|
3218
|
+
const e = Number(g) % 360;
|
|
3199
3219
|
return e < 0 ? e + 360 : e;
|
|
3200
3220
|
}
|
|
3201
3221
|
class ht {
|
|
@@ -3231,26 +3251,26 @@ class ht {
|
|
|
3231
3251
|
});
|
|
3232
3252
|
h.dataset.shape = l.id, h.dataset.testid = `crop-shape-${l.id}`, this._shapeChips.set(l.id, h), t.appendChild(h);
|
|
3233
3253
|
}), e.appendChild(t), this.element.appendChild(e), this.state.get("lockCropShape") && (e.style.display = "none"), this._shapeSection = e, this._aspectSection = d("div", { className: "crop-section" }), this._aspectSection.appendChild(d("label", { className: "section-label" }, "Aspect Ratio"));
|
|
3234
|
-
const
|
|
3254
|
+
const s = d("div", { className: "chip-row aspect-row" }), r = this.state.get("crop.aspect");
|
|
3235
3255
|
at.forEach((l) => {
|
|
3236
3256
|
const h = re({
|
|
3237
3257
|
label: l.name,
|
|
3238
|
-
active:
|
|
3258
|
+
active: r === l.id,
|
|
3239
3259
|
onClick: () => this._selectAspect(l.id)
|
|
3240
3260
|
});
|
|
3241
|
-
h.dataset.ratio = l.id, h.dataset.testid = `crop-ratio-${l.id}`, this._aspectChips.set(l.id, h),
|
|
3242
|
-
}), this._aspectSection.appendChild(
|
|
3243
|
-
const o = d("div", { className: "crop-actions" }), n =
|
|
3261
|
+
h.dataset.ratio = l.id, h.dataset.testid = `crop-ratio-${l.id}`, this._aspectChips.set(l.id, h), s.appendChild(h);
|
|
3262
|
+
}), this._aspectSection.appendChild(s), this.element.appendChild(this._aspectSection), this._updateAspectVisibility();
|
|
3263
|
+
const o = d("div", { className: "crop-actions" }), n = D({
|
|
3244
3264
|
label: "Cancel",
|
|
3245
3265
|
className: "btn-secondary crop-cancel-btn",
|
|
3246
|
-
icon:
|
|
3266
|
+
icon: ue,
|
|
3247
3267
|
onClick: () => this.cropManager.cancel()
|
|
3248
3268
|
});
|
|
3249
3269
|
n.dataset.testid = "cancel-crop";
|
|
3250
|
-
const a =
|
|
3270
|
+
const a = D({
|
|
3251
3271
|
label: "Apply Crop",
|
|
3252
3272
|
className: "btn-primary crop-apply-btn",
|
|
3253
|
-
icon:
|
|
3273
|
+
icon: ce,
|
|
3254
3274
|
onClick: () => this._applyCropAndReturnToFilters()
|
|
3255
3275
|
});
|
|
3256
3276
|
return a.dataset.testid = "apply-crop", o.appendChild(n), o.appendChild(a), this.element.appendChild(o), this._subscribeToState(), this.element;
|
|
@@ -3258,40 +3278,40 @@ class ht {
|
|
|
3258
3278
|
_renderRotationSection() {
|
|
3259
3279
|
const e = d("div", { className: "crop-section rotation-section" });
|
|
3260
3280
|
e.appendChild(d("label", { className: "section-label" }, "Rotate"));
|
|
3261
|
-
const t = d("div", { className: "rotation-action-row" }), i =
|
|
3281
|
+
const t = d("div", { className: "rotation-action-row" }), i = D({
|
|
3262
3282
|
label: "Left 90°",
|
|
3263
3283
|
className: "btn-secondary rotation-action-btn",
|
|
3264
3284
|
icon: ze,
|
|
3265
3285
|
onClick: () => this._rotateBy(-90)
|
|
3266
3286
|
});
|
|
3267
3287
|
i.dataset.testid = "rotate-left-90";
|
|
3268
|
-
const
|
|
3288
|
+
const s = D({
|
|
3269
3289
|
label: "Right 90°",
|
|
3270
3290
|
className: "btn-secondary rotation-action-btn",
|
|
3271
3291
|
icon: Pe,
|
|
3272
3292
|
onClick: () => this._rotateBy(90)
|
|
3273
3293
|
});
|
|
3274
|
-
|
|
3275
|
-
const
|
|
3294
|
+
s.dataset.testid = "rotate-right-90";
|
|
3295
|
+
const r = D({
|
|
3276
3296
|
label: "Rotate 180°",
|
|
3277
3297
|
className: "btn-secondary rotation-action-btn",
|
|
3278
3298
|
onClick: () => this._rotateBy(180)
|
|
3279
3299
|
});
|
|
3280
|
-
|
|
3281
|
-
const o =
|
|
3300
|
+
r.dataset.testid = "rotate-180";
|
|
3301
|
+
const o = D({
|
|
3282
3302
|
label: "Rotate 270°",
|
|
3283
3303
|
className: "btn-secondary rotation-action-btn",
|
|
3284
3304
|
onClick: () => this._rotateBy(270)
|
|
3285
3305
|
});
|
|
3286
|
-
o.dataset.testid = "rotate-270", t.appendChild(i), t.appendChild(
|
|
3287
|
-
const n = d("div", { className: "chip-row rotation-preset-row" }), a =
|
|
3288
|
-
lt.forEach((
|
|
3289
|
-
const
|
|
3290
|
-
label:
|
|
3291
|
-
active: Math.round(a) ===
|
|
3292
|
-
onClick: () => this._setRotation(
|
|
3306
|
+
o.dataset.testid = "rotate-270", t.appendChild(i), t.appendChild(s), t.appendChild(r), t.appendChild(o), e.appendChild(t);
|
|
3307
|
+
const n = d("div", { className: "chip-row rotation-preset-row" }), a = $(this.state.get("transform.rotation") ?? 0);
|
|
3308
|
+
lt.forEach((u) => {
|
|
3309
|
+
const f = re({
|
|
3310
|
+
label: u.label,
|
|
3311
|
+
active: Math.round(a) === u.angle,
|
|
3312
|
+
onClick: () => this._setRotation(u.angle)
|
|
3293
3313
|
});
|
|
3294
|
-
|
|
3314
|
+
f.dataset.angle = u.id, f.dataset.testid = `rotation-preset-${u.id}`, this._rotationPresetChips.set(u.id, f), n.appendChild(f);
|
|
3295
3315
|
}), e.appendChild(n);
|
|
3296
3316
|
const l = d("div", { className: "rotation-arbitrary" }), h = d(
|
|
3297
3317
|
"div",
|
|
@@ -3308,8 +3328,8 @@ class ht {
|
|
|
3308
3328
|
step: "1",
|
|
3309
3329
|
value: String(Math.round(a)),
|
|
3310
3330
|
"aria-label": "Rotation angle",
|
|
3311
|
-
onInput: (
|
|
3312
|
-
onChange: (
|
|
3331
|
+
onInput: (u) => this._previewAngleValue(u.target.value),
|
|
3332
|
+
onChange: (u) => this._setRotation(Number(u.target.value))
|
|
3313
3333
|
}), this._rotationNumber = d("input", {
|
|
3314
3334
|
type: "number",
|
|
3315
3335
|
className: "text-input rotation-number-input",
|
|
@@ -3318,10 +3338,10 @@ class ht {
|
|
|
3318
3338
|
step: "1",
|
|
3319
3339
|
value: this._formatPlainAngle(a),
|
|
3320
3340
|
"aria-label": "Rotation angle in degrees",
|
|
3321
|
-
onKeyDown: (
|
|
3322
|
-
|
|
3341
|
+
onKeyDown: (u) => {
|
|
3342
|
+
u.key === "Enter" && (u.preventDefault(), this._setRotation(Number(u.target.value)), u.target.blur());
|
|
3323
3343
|
},
|
|
3324
|
-
onBlur: (
|
|
3344
|
+
onBlur: (u) => this._setRotation(Number(u.target.value))
|
|
3325
3345
|
});
|
|
3326
3346
|
const c = d(
|
|
3327
3347
|
"div",
|
|
@@ -3330,66 +3350,66 @@ class ht {
|
|
|
3330
3350
|
this._rotationNumber
|
|
3331
3351
|
);
|
|
3332
3352
|
l.appendChild(h), l.appendChild(c);
|
|
3333
|
-
const
|
|
3353
|
+
const p = D({
|
|
3334
3354
|
label: "Reset rotation",
|
|
3335
3355
|
className: "btn-text rotation-reset-btn",
|
|
3336
3356
|
onClick: () => this._setRotation(0)
|
|
3337
3357
|
});
|
|
3338
|
-
return
|
|
3358
|
+
return p.dataset.testid = "reset-rotation", l.appendChild(p), e.appendChild(l), e;
|
|
3339
3359
|
}
|
|
3340
3360
|
/**
|
|
3341
3361
|
* Subscribe to state changes
|
|
3342
3362
|
*/
|
|
3343
3363
|
_subscribeToState() {
|
|
3344
|
-
const e = this.state.on("change:crop.shape", ({ value:
|
|
3345
|
-
this._shapeChips.forEach((
|
|
3346
|
-
|
|
3364
|
+
const e = this.state.on("change:crop.shape", ({ value: s }) => {
|
|
3365
|
+
this._shapeChips.forEach((r, o) => {
|
|
3366
|
+
r.setActive(o === s);
|
|
3347
3367
|
}), this._updateAspectVisibility();
|
|
3348
3368
|
});
|
|
3349
3369
|
this._unsubscribers.push(e);
|
|
3350
|
-
const t = this.state.on("change:crop.aspect", ({ value:
|
|
3351
|
-
this._aspectChips.forEach((
|
|
3352
|
-
|
|
3370
|
+
const t = this.state.on("change:crop.aspect", ({ value: s }) => {
|
|
3371
|
+
this._aspectChips.forEach((r, o) => {
|
|
3372
|
+
r.setActive(o === s);
|
|
3353
3373
|
});
|
|
3354
3374
|
});
|
|
3355
3375
|
this._unsubscribers.push(t);
|
|
3356
|
-
const i = this.state.on("change:transform.rotation", ({ value:
|
|
3357
|
-
this._syncRotationControls(
|
|
3376
|
+
const i = this.state.on("change:transform.rotation", ({ value: s }) => {
|
|
3377
|
+
this._syncRotationControls(s);
|
|
3358
3378
|
});
|
|
3359
3379
|
this._unsubscribers.push(i);
|
|
3360
3380
|
}
|
|
3361
3381
|
_rotateBy(e) {
|
|
3362
|
-
var i,
|
|
3363
|
-
((
|
|
3382
|
+
var i, s;
|
|
3383
|
+
((s = (i = this.editor) == null ? void 0 : i.rotateBy) == null ? void 0 : s.call(i, e)) !== !1 && this._syncRotationControls(this.state.get("transform.rotation") ?? 0);
|
|
3364
3384
|
}
|
|
3365
3385
|
_setRotation(e) {
|
|
3366
|
-
var
|
|
3367
|
-
const t =
|
|
3368
|
-
if (((
|
|
3386
|
+
var s, r;
|
|
3387
|
+
const t = $(e);
|
|
3388
|
+
if (((r = (s = this.editor) == null ? void 0 : s.setRotationAngle) == null ? void 0 : r.call(s, t)) === !1) {
|
|
3369
3389
|
this._syncRotationControls(this.state.get("transform.rotation") ?? 0);
|
|
3370
3390
|
return;
|
|
3371
3391
|
}
|
|
3372
3392
|
this._syncRotationControls(t);
|
|
3373
3393
|
}
|
|
3374
3394
|
_previewAngleValue(e) {
|
|
3375
|
-
const t =
|
|
3395
|
+
const t = $(Number(e));
|
|
3376
3396
|
this._rotationValue && (this._rotationValue.textContent = this._formatAngle(t)), this._rotationNumber && (this._rotationNumber.value = this._formatPlainAngle(t)), this._refreshPresetChips(t);
|
|
3377
3397
|
}
|
|
3378
3398
|
_syncRotationControls(e) {
|
|
3379
|
-
const t =
|
|
3399
|
+
const t = $(e);
|
|
3380
3400
|
this._rotationValue && (this._rotationValue.textContent = this._formatAngle(t)), this._rotationRange && (this._rotationRange.value = String(Math.round(t))), this._rotationNumber && (this._rotationNumber.value = this._formatPlainAngle(t)), this._refreshPresetChips(t);
|
|
3381
3401
|
}
|
|
3382
3402
|
_refreshPresetChips(e) {
|
|
3383
|
-
const t = Math.round(
|
|
3384
|
-
this._rotationPresetChips.forEach((i,
|
|
3385
|
-
i.setActive(Number(
|
|
3403
|
+
const t = Math.round($(e)) % 360;
|
|
3404
|
+
this._rotationPresetChips.forEach((i, s) => {
|
|
3405
|
+
i.setActive(Number(s) === t);
|
|
3386
3406
|
});
|
|
3387
3407
|
}
|
|
3388
3408
|
_formatAngle(e) {
|
|
3389
3409
|
return `${this._formatPlainAngle(e)}°`;
|
|
3390
3410
|
}
|
|
3391
3411
|
_formatPlainAngle(e) {
|
|
3392
|
-
const t =
|
|
3412
|
+
const t = $(e);
|
|
3393
3413
|
return Number.isInteger(t) ? String(t) : t.toFixed(1);
|
|
3394
3414
|
}
|
|
3395
3415
|
/**
|
|
@@ -3442,14 +3462,14 @@ class ct {
|
|
|
3442
3462
|
* @param {Object} options - { onRemove, onReset, onClearAll, onUpdateValue, onSelect }
|
|
3443
3463
|
* @returns {HTMLElement}
|
|
3444
3464
|
*/
|
|
3445
|
-
render({ onRemove: e, onReset: t, onClearAll: i, onUpdateValue:
|
|
3446
|
-
this._onRemove = e, this._onReset = t, this._onClearAll = i, this._onUpdateValue =
|
|
3465
|
+
render({ onRemove: e, onReset: t, onClearAll: i, onUpdateValue: s, onSelect: r }) {
|
|
3466
|
+
this._onRemove = e, this._onReset = t, this._onClearAll = i, this._onUpdateValue = s, this._onSelect = r, this.element = d("div", {
|
|
3447
3467
|
className: "active-filters-panel",
|
|
3448
3468
|
"data-testid": "active-filters-panel"
|
|
3449
3469
|
});
|
|
3450
3470
|
const o = d("div", { className: "panel-header" });
|
|
3451
3471
|
o.appendChild(d("h3", { className: "panel-title" }, "Active Filters"));
|
|
3452
|
-
const n =
|
|
3472
|
+
const n = D({
|
|
3453
3473
|
label: "Clear All",
|
|
3454
3474
|
className: "btn-text btn-danger",
|
|
3455
3475
|
onClick: () => this._handleClearAll()
|
|
@@ -3497,8 +3517,8 @@ class ct {
|
|
|
3497
3517
|
e.forEach((t) => {
|
|
3498
3518
|
const i = this.filterManager.getFilterDef(t);
|
|
3499
3519
|
if (!i) return;
|
|
3500
|
-
const
|
|
3501
|
-
this._filterItems.set(t,
|
|
3520
|
+
const s = this._createFilterItem(t, i);
|
|
3521
|
+
this._filterItems.set(t, s), this._listContainer.appendChild(s);
|
|
3502
3522
|
});
|
|
3503
3523
|
}
|
|
3504
3524
|
/**
|
|
@@ -3508,27 +3528,27 @@ class ct {
|
|
|
3508
3528
|
* @returns {HTMLElement}
|
|
3509
3529
|
*/
|
|
3510
3530
|
_createFilterItem(e, t) {
|
|
3511
|
-
const
|
|
3512
|
-
className: `active-filter-item ${
|
|
3531
|
+
const s = this.state.get("selectedFilter") === e, r = d("div", {
|
|
3532
|
+
className: `active-filter-item ${s ? "selected" : ""}`,
|
|
3513
3533
|
"data-active-filter": e,
|
|
3514
3534
|
"data-testid": `active-filter-${e}`,
|
|
3515
|
-
onClick: (
|
|
3516
|
-
|
|
3535
|
+
onClick: (u) => {
|
|
3536
|
+
u.target.closest(".filter-item-actions") || this._handleSelect(e);
|
|
3517
3537
|
}
|
|
3518
|
-
}), o = d("div", { className: "filter-item-header" }), n = d("span", { className: "filter-item-name" }, t.name), a = d("div", { className: "filter-item-actions" }), l =
|
|
3538
|
+
}), o = d("div", { className: "filter-item-header" }), n = d("span", { className: "filter-item-name" }, t.name), a = d("div", { className: "filter-item-actions" }), l = j({
|
|
3519
3539
|
icon: ye,
|
|
3520
3540
|
title: "Reset filter",
|
|
3521
3541
|
className: "btn-icon-sm",
|
|
3522
3542
|
onClick: () => this._handleReset(e)
|
|
3523
|
-
}), h =
|
|
3543
|
+
}), h = j({
|
|
3524
3544
|
icon: He,
|
|
3525
3545
|
title: "Remove filter",
|
|
3526
3546
|
className: "btn-icon-sm btn-danger",
|
|
3527
3547
|
onClick: () => this._handleRemove(e)
|
|
3528
3548
|
});
|
|
3529
|
-
a.appendChild(l), a.appendChild(h), o.appendChild(n), o.appendChild(a),
|
|
3530
|
-
const c = this.state.getFilterValues(e),
|
|
3531
|
-
return
|
|
3549
|
+
a.appendChild(l), a.appendChild(h), o.appendChild(n), o.appendChild(a), r.appendChild(o);
|
|
3550
|
+
const c = this.state.getFilterValues(e), p = d("div", { className: "filter-item-summary" });
|
|
3551
|
+
return p.textContent = this._getValuesSummary(t, c), r.appendChild(p), r._summaryEl = p, r;
|
|
3532
3552
|
}
|
|
3533
3553
|
/**
|
|
3534
3554
|
* Normalize control type (handle aliases)
|
|
@@ -3557,11 +3577,11 @@ class ct {
|
|
|
3557
3577
|
if (!e.controls || !Array.isArray(e.controls))
|
|
3558
3578
|
return "Default values";
|
|
3559
3579
|
const i = [];
|
|
3560
|
-
return e.controls.forEach((
|
|
3561
|
-
const
|
|
3562
|
-
if (
|
|
3563
|
-
const o =
|
|
3564
|
-
n !==
|
|
3580
|
+
return e.controls.forEach((s) => {
|
|
3581
|
+
const r = this._normalizeControlType(s.type);
|
|
3582
|
+
if (r === "button") return;
|
|
3583
|
+
const o = s.label || s.id, n = t[s.id] ?? s.default;
|
|
3584
|
+
n !== s.default && (r === "slider" ? i.push(`${o}: ${this._formatValue(n)}`) : r === "toggle" ? n && i.push(o) : r === "color" ? i.push(`${o}: ${n}`) : r === "select" && i.push(`${o}: ${n}`));
|
|
3565
3585
|
}), i.length > 0 ? i.join(", ") : "Default values";
|
|
3566
3586
|
}
|
|
3567
3587
|
/**
|
|
@@ -3579,8 +3599,8 @@ class ct {
|
|
|
3579
3599
|
this._filterItems.forEach((e, t) => {
|
|
3580
3600
|
const i = this.filterManager.getFilterDef(t);
|
|
3581
3601
|
if (!i || !e._summaryEl) return;
|
|
3582
|
-
const
|
|
3583
|
-
e._summaryEl.textContent = this._getValuesSummary(i,
|
|
3602
|
+
const s = this.state.getFilterValues(t);
|
|
3603
|
+
e._summaryEl.textContent = this._getValuesSummary(i, s);
|
|
3584
3604
|
});
|
|
3585
3605
|
}
|
|
3586
3606
|
/**
|
|
@@ -3634,7 +3654,7 @@ class ct {
|
|
|
3634
3654
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._filterItems.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
3635
3655
|
}
|
|
3636
3656
|
}
|
|
3637
|
-
const
|
|
3657
|
+
const Z = {
|
|
3638
3658
|
name: "free",
|
|
3639
3659
|
initialMode: "filters",
|
|
3640
3660
|
cropShape: "free",
|
|
@@ -3646,12 +3666,12 @@ const $ = {
|
|
|
3646
3666
|
showCropControls: !0,
|
|
3647
3667
|
maxExportWidth: void 0,
|
|
3648
3668
|
maxExportHeight: void 0
|
|
3649
|
-
},
|
|
3669
|
+
}, he = {
|
|
3650
3670
|
free: {
|
|
3651
|
-
|
|
3671
|
+
...Z
|
|
3652
3672
|
},
|
|
3653
3673
|
avatar: {
|
|
3654
|
-
|
|
3674
|
+
...Z,
|
|
3655
3675
|
name: "avatar",
|
|
3656
3676
|
initialMode: "crop",
|
|
3657
3677
|
cropShape: "circle",
|
|
@@ -3661,7 +3681,7 @@ const $ = {
|
|
|
3661
3681
|
lockAspectRatio: !0
|
|
3662
3682
|
},
|
|
3663
3683
|
banner: {
|
|
3664
|
-
|
|
3684
|
+
...Z,
|
|
3665
3685
|
name: "banner",
|
|
3666
3686
|
initialMode: "crop",
|
|
3667
3687
|
cropShape: "square",
|
|
@@ -3671,7 +3691,7 @@ const $ = {
|
|
|
3671
3691
|
lockAspectRatio: !0
|
|
3672
3692
|
},
|
|
3673
3693
|
cover: {
|
|
3674
|
-
|
|
3694
|
+
...Z,
|
|
3675
3695
|
name: "cover",
|
|
3676
3696
|
initialMode: "crop",
|
|
3677
3697
|
cropShape: "free",
|
|
@@ -3681,7 +3701,7 @@ const $ = {
|
|
|
3681
3701
|
lockAspectRatio: !0
|
|
3682
3702
|
},
|
|
3683
3703
|
product: {
|
|
3684
|
-
|
|
3704
|
+
...Z,
|
|
3685
3705
|
name: "product",
|
|
3686
3706
|
initialMode: "filters",
|
|
3687
3707
|
cropShape: "square",
|
|
@@ -3691,35 +3711,35 @@ const $ = {
|
|
|
3691
3711
|
lockAspectRatio: !1
|
|
3692
3712
|
}
|
|
3693
3713
|
};
|
|
3694
|
-
function dt(
|
|
3695
|
-
if (!
|
|
3696
|
-
return { ...
|
|
3697
|
-
if (typeof
|
|
3698
|
-
return {
|
|
3699
|
-
const e =
|
|
3700
|
-
return e ? { ...e } : { ...
|
|
3714
|
+
function dt(g) {
|
|
3715
|
+
if (!g)
|
|
3716
|
+
return { ...he.free };
|
|
3717
|
+
if (typeof g == "object" && g !== null)
|
|
3718
|
+
return { ...Z, ...g };
|
|
3719
|
+
const e = he[g];
|
|
3720
|
+
return e ? { ...e } : { ...he.free };
|
|
3701
3721
|
}
|
|
3702
|
-
function
|
|
3703
|
-
if (!Number.isFinite(Number(
|
|
3704
|
-
const e = Number(
|
|
3722
|
+
function q(g) {
|
|
3723
|
+
if (!Number.isFinite(Number(g))) return 0;
|
|
3724
|
+
const e = Number(g) % 360;
|
|
3705
3725
|
return e < 0 ? e + 360 : e;
|
|
3706
3726
|
}
|
|
3707
|
-
function ut(
|
|
3708
|
-
const t =
|
|
3709
|
-
return (
|
|
3727
|
+
function ut(g, e) {
|
|
3728
|
+
const t = q(g);
|
|
3729
|
+
return (q(e) - t + 540) % 360 - 180;
|
|
3710
3730
|
}
|
|
3711
|
-
class kt extends
|
|
3731
|
+
class kt extends ne {
|
|
3712
3732
|
/**
|
|
3713
3733
|
* Create a new VanillaImageEditor
|
|
3714
3734
|
* @param {HTMLElement} container - Container element to mount the editor
|
|
3715
3735
|
* @param {Object} options - Configuration options
|
|
3716
3736
|
*/
|
|
3717
3737
|
constructor(e, t = {}) {
|
|
3718
|
-
var
|
|
3738
|
+
var r, o, n, a;
|
|
3719
3739
|
if (super(), !e)
|
|
3720
3740
|
throw new Error("VanillaImageEditor: container element is required");
|
|
3721
3741
|
this._container = e, this._destroyed = !1, this._loadVersion = 0, this._objectUrls = /* @__PURE__ */ new Set(), this._activeObjectUrl = null;
|
|
3722
|
-
const i = t.preset ? dt(t.preset) : null,
|
|
3742
|
+
const i = t.preset ? dt(t.preset) : null, s = i ? {
|
|
3723
3743
|
initialMode: i.initialMode === "crop" ? "crop" : "adjust",
|
|
3724
3744
|
cropShape: i.cropShape,
|
|
3725
3745
|
initialAspectRatio: i.aspectRatio
|
|
@@ -3736,9 +3756,9 @@ class kt extends se {
|
|
|
3736
3756
|
optionsEndpoint: "/api/v1/media/background-removal/options",
|
|
3737
3757
|
fallbackEndpoint: null
|
|
3738
3758
|
},
|
|
3739
|
-
...
|
|
3759
|
+
...s,
|
|
3740
3760
|
...t
|
|
3741
|
-
}, this._preset = i, this._state = Se(), this._state.set("theme", this._options.theme), this._state.set("crop.shape", this._options.cropShape), this._state.set("crop.aspect", this._options.initialAspectRatio), this._preset && (this._state.set("lockCropShape", !!this._preset.lockCropShape), this._state.set("lockAspectRatio", !!this._preset.lockAspectRatio), this._state.set("showFilters", this._preset.showFilters !== !1), this._state.set("showCropControls", this._preset.showCropControls !== !1), this._state.set("autoZoomOnCropOverflow", !!this._preset.autoZoomOnCropOverflow)), this._renderer = new Te(), this._filterManager = new Qe(this._state, this._renderer), this._cropManager = new
|
|
3761
|
+
}, this._preset = i, this._state = Se(), this._state.set("theme", this._options.theme), this._state.set("crop.shape", this._options.cropShape), this._state.set("crop.aspect", this._options.initialAspectRatio), this._preset && (this._state.set("lockCropShape", !!this._preset.lockCropShape), this._state.set("lockAspectRatio", !!this._preset.lockAspectRatio), this._state.set("showFilters", this._preset.showFilters !== !1), this._state.set("showCropControls", this._preset.showCropControls !== !1), this._state.set("autoZoomOnCropOverflow", !!this._preset.autoZoomOnCropOverflow)), this._renderer = new Te(), this._filterManager = new Qe(this._state, this._renderer), this._cropManager = new de(this._state, this._renderer), this._removeBgManager = null, this._backgroundRemovalAvailable = !1, ((r = this._options.backgroundRemoval) == null ? void 0 : r.enabled) !== !1 && (this._removeBgManager = new Xe({
|
|
3742
3762
|
endpoint: (o = this._options.backgroundRemoval) == null ? void 0 : o.endpoint,
|
|
3743
3763
|
optionsEndpoint: (n = this._options.backgroundRemoval) == null ? void 0 : n.optionsEndpoint,
|
|
3744
3764
|
fallbackEndpoint: (a = this._options.backgroundRemoval) == null ? void 0 : a.fallbackEndpoint
|
|
@@ -3770,44 +3790,44 @@ class kt extends se {
|
|
|
3770
3790
|
accept: "image/*",
|
|
3771
3791
|
className: "hidden-file-input",
|
|
3772
3792
|
"aria-label": "Choose image file to edit",
|
|
3773
|
-
onChange: (
|
|
3793
|
+
onChange: (s) => this._handleFileSelect(s)
|
|
3774
3794
|
}), this._editorEl.appendChild(this._fileInput), this._container.appendChild(this._editorEl);
|
|
3775
3795
|
}
|
|
3776
3796
|
/**
|
|
3777
3797
|
* Initialize UI components
|
|
3778
3798
|
*/
|
|
3779
3799
|
_initUI() {
|
|
3780
|
-
this._toolbar = new et(this._state, this), this._toolbarContainer.appendChild(this._toolbar.render()), this._filterControlsEl = d("div", { className: "filter-controls-container" }), this._categoryCarousel = new tt(this._state, this), this._filterControlsEl.appendChild(this._categoryCarousel.render((
|
|
3800
|
+
this._toolbar = new et(this._state, this), this._toolbarContainer.appendChild(this._toolbar.render()), this._filterControlsEl = d("div", { className: "filter-controls-container" }), this._categoryCarousel = new tt(this._state, this), this._filterControlsEl.appendChild(this._categoryCarousel.render((s) => {
|
|
3781
3801
|
}));
|
|
3782
3802
|
const e = d("div", { className: "filter-layout" }), t = d("div", { className: "filter-left-column" });
|
|
3783
3803
|
this._filterCarousel = new it(this._state, this._filterManager), t.appendChild(this._filterCarousel.render({
|
|
3784
|
-
onToggle: (
|
|
3785
|
-
onSelect: (
|
|
3786
|
-
this._handleFilterSelect(
|
|
3804
|
+
onToggle: (s, r) => this._handleFilterToggle(s, r),
|
|
3805
|
+
onSelect: (s) => {
|
|
3806
|
+
this._handleFilterSelect(s), this._isMobile && this._mobileFilterDrawer && this._mobileFilterDrawer.open(s);
|
|
3787
3807
|
}
|
|
3788
|
-
})), this._filterAdjustments = new
|
|
3789
|
-
onChange: (
|
|
3790
|
-
onReset: (
|
|
3791
|
-
onAction: (
|
|
3808
|
+
})), this._filterAdjustments = new st(this._state, this._filterManager), t.appendChild(this._filterAdjustments.render({
|
|
3809
|
+
onChange: (s, r, o) => this._handleFilterChange(s, r, o),
|
|
3810
|
+
onReset: (s) => this._handleFilterReset(s),
|
|
3811
|
+
onAction: (s, r) => this._handleFilterAction(s, r)
|
|
3792
3812
|
})), e.appendChild(t);
|
|
3793
3813
|
const i = d("div", { className: "filter-right-column" });
|
|
3794
3814
|
this._activeFiltersPanel = new ct(this._state, this._filterManager), i.appendChild(this._activeFiltersPanel.render({
|
|
3795
|
-
onRemove: (
|
|
3796
|
-
onReset: (
|
|
3815
|
+
onRemove: (s) => this._handleFilterToggle(s, !1),
|
|
3816
|
+
onReset: (s) => this._handleFilterReset(s),
|
|
3797
3817
|
onClearAll: () => this.resetAll(),
|
|
3798
|
-
onSelect: (
|
|
3818
|
+
onSelect: (s) => this._handleFilterSelect(s)
|
|
3799
3819
|
})), e.appendChild(i), this._filterControlsEl.appendChild(e), this._mobileActiveFilters = new nt(this._state, this._filterManager), this._filterControlsEl.appendChild(this._mobileActiveFilters.render({
|
|
3800
|
-
onToggle: (
|
|
3801
|
-
onSelect: (
|
|
3802
|
-
this._handleFilterSelect(
|
|
3820
|
+
onToggle: (s, r) => this._handleFilterToggle(s, r),
|
|
3821
|
+
onSelect: (s) => {
|
|
3822
|
+
this._handleFilterSelect(s), this._isMobile && this._mobileFilterDrawer && this._mobileFilterDrawer.open(s);
|
|
3803
3823
|
}
|
|
3804
|
-
})), this._cropControls = new ht(this._state, this._cropManager, this), this._cropControlsEl = this._cropControls.render(), this._cropControlsEl.style.display = "none", this._controlsSection.appendChild(this._filterControlsEl), this._controlsSection.appendChild(this._cropControlsEl), this._mobileFilterDrawer = new
|
|
3805
|
-
onChange: (
|
|
3806
|
-
onReset: (
|
|
3807
|
-
onRemove: (
|
|
3808
|
-
this._handleFilterToggle(
|
|
3824
|
+
})), this._cropControls = new ht(this._state, this._cropManager, this), this._cropControlsEl = this._cropControls.render(), this._cropControlsEl.style.display = "none", this._controlsSection.appendChild(this._filterControlsEl), this._controlsSection.appendChild(this._cropControlsEl), this._mobileFilterDrawer = new rt(this._state, this._filterManager), this._mobileFilterDrawer.build(this._controlsSection, {
|
|
3825
|
+
onChange: (s, r, o) => this._handleFilterChange(s, r, o),
|
|
3826
|
+
onReset: (s) => this._handleFilterReset(s),
|
|
3827
|
+
onRemove: (s) => {
|
|
3828
|
+
this._handleFilterToggle(s, !1), this._state.set("selectedFilter", null);
|
|
3809
3829
|
},
|
|
3810
|
-
onAction: (
|
|
3830
|
+
onAction: (s, r) => this._handleFilterAction(s, r)
|
|
3811
3831
|
});
|
|
3812
3832
|
}
|
|
3813
3833
|
/**
|
|
@@ -3936,20 +3956,20 @@ class kt extends se {
|
|
|
3936
3956
|
if (this._destroyed) return;
|
|
3937
3957
|
(a = (n = this._removeBgManager) == null ? void 0 : n.cancelActiveRequests) == null || a.call(n, "image-load");
|
|
3938
3958
|
const i = ++this._loadVersion;
|
|
3939
|
-
let
|
|
3940
|
-
this._resetEditorState(), this._state.set("hasImage", !1), this._state.set("imageUrl", null), e instanceof Blob && (
|
|
3941
|
-
const o = await this._renderer.loadTexture(
|
|
3959
|
+
let s = e, r = null;
|
|
3960
|
+
this._resetEditorState(), this._state.set("hasImage", !1), this._state.set("imageUrl", null), e instanceof Blob && (s = URL.createObjectURL(e), r = s, this._objectUrls.add(s));
|
|
3961
|
+
const o = await this._renderer.loadTexture(s, {
|
|
3942
3962
|
isCurrent: () => !this._destroyed && this._loadVersion === i
|
|
3943
3963
|
});
|
|
3944
3964
|
if (this._destroyed || this._loadVersion !== i) {
|
|
3945
|
-
this._revokeObjectUrl(
|
|
3965
|
+
this._revokeObjectUrl(r);
|
|
3946
3966
|
return;
|
|
3947
3967
|
}
|
|
3948
3968
|
if (!o) {
|
|
3949
|
-
this._revokeObjectUrl(
|
|
3969
|
+
this._revokeObjectUrl(r), this.emit("error", new Error("Failed to load image"));
|
|
3950
3970
|
return;
|
|
3951
3971
|
}
|
|
3952
|
-
|
|
3972
|
+
r ? this._replaceActiveObjectUrl(r) : this._clearActiveObjectUrl(), this._state.set("hasImage", !0), this._state.set("imageUrl", s), t.state && this._hydrateState(t.state), this._options.initialMode === "crop" && this.setMode("crop"), this.emit("imageLoaded", { url: s });
|
|
3953
3973
|
}
|
|
3954
3974
|
/**
|
|
3955
3975
|
* Reset all editor state (filters + crop) to a clean baseline.
|
|
@@ -3966,22 +3986,22 @@ class kt extends se {
|
|
|
3966
3986
|
_hydrateState(e) {
|
|
3967
3987
|
var i;
|
|
3968
3988
|
if (!e || e.version !== 1) return;
|
|
3969
|
-
const t =
|
|
3989
|
+
const t = q(((i = e.transform) == null ? void 0 : i.rotation) ?? 0);
|
|
3970
3990
|
if (t !== 0 && this._renderer.rotateBy(t) && this._state.set("transform.rotation", t), e.crop) {
|
|
3971
|
-
const
|
|
3972
|
-
e.crop.rect && (this._cropManager.applyFromPixelRect(e.crop.rect,
|
|
3991
|
+
const s = e.crop.shape || "free", r = e.crop.aspectRatio || "free";
|
|
3992
|
+
e.crop.rect && (this._cropManager.applyFromPixelRect(e.crop.rect, s), this._state.set("crop.appliedRect", { ...e.crop.rect }), this._state.set("crop.appliedShape", s), this._state.set("crop.appliedAspect", r)), this._state.set("crop.shape", s), this._state.set("crop.aspect", r);
|
|
3973
3993
|
}
|
|
3974
3994
|
if (Array.isArray(e.filters)) {
|
|
3975
|
-
let
|
|
3976
|
-
for (const
|
|
3977
|
-
if (
|
|
3978
|
-
for (const [o, n] of Object.entries(
|
|
3979
|
-
this._state.setFilterValue(
|
|
3980
|
-
if (
|
|
3981
|
-
this._state.set("selectedFilter",
|
|
3982
|
-
const
|
|
3983
|
-
if (typeof (
|
|
3984
|
-
const o = Ye[
|
|
3995
|
+
let s = null;
|
|
3996
|
+
for (const r of e.filters)
|
|
3997
|
+
if (r.enabled && (s === null && (s = r.id), this._state.toggleFilter(r.id, !0), this._filterManager.initializeValues(r.id), r.values))
|
|
3998
|
+
for (const [o, n] of Object.entries(r.values))
|
|
3999
|
+
this._state.setFilterValue(r.id, o, n);
|
|
4000
|
+
if (s !== null) {
|
|
4001
|
+
this._state.set("selectedFilter", s);
|
|
4002
|
+
const r = this._filterManager.getFilterDef(s);
|
|
4003
|
+
if (typeof (r == null ? void 0 : r.category) == "string") {
|
|
4004
|
+
const o = Ye[r.category] ?? r.category;
|
|
3985
4005
|
this._state.set("selectedCategory", o);
|
|
3986
4006
|
}
|
|
3987
4007
|
}
|
|
@@ -4067,16 +4087,16 @@ class kt extends se {
|
|
|
4067
4087
|
values: { ...n }
|
|
4068
4088
|
});
|
|
4069
4089
|
}
|
|
4070
|
-
const i = this._state.get("crop.appliedRect"),
|
|
4090
|
+
const i = this._state.get("crop.appliedRect"), s = this._state.get("crop.rect"), r = i || s;
|
|
4071
4091
|
return {
|
|
4072
4092
|
version: 1,
|
|
4073
4093
|
crop: {
|
|
4074
|
-
rect:
|
|
4094
|
+
rect: r ? { ...r } : null,
|
|
4075
4095
|
aspectRatio: this._state.get("crop.appliedAspect") || this._state.get("crop.aspect") || "free",
|
|
4076
4096
|
shape: this._state.get("crop.appliedShape") || this._state.get("crop.shape") || "free"
|
|
4077
4097
|
},
|
|
4078
4098
|
transform: {
|
|
4079
|
-
rotation:
|
|
4099
|
+
rotation: q(this._state.get("transform.rotation") ?? 0)
|
|
4080
4100
|
},
|
|
4081
4101
|
filters: t
|
|
4082
4102
|
};
|
|
@@ -4112,11 +4132,11 @@ class kt extends se {
|
|
|
4112
4132
|
}
|
|
4113
4133
|
setRotationAngle(e) {
|
|
4114
4134
|
if (!this._state.get("hasImage")) return !1;
|
|
4115
|
-
const t =
|
|
4116
|
-
if (Math.abs(
|
|
4117
|
-
if (
|
|
4118
|
-
return
|
|
4119
|
-
this._filterManager.applyFilters(), this._state.set("crop.rect", null), this._state.set("crop.dirty", !1),
|
|
4135
|
+
const t = q(this._state.get("transform.rotation") ?? 0), i = q(e), s = ut(t, i), r = this._state.get("mode") === "crop";
|
|
4136
|
+
if (Math.abs(s) > 1e-3) {
|
|
4137
|
+
if (r && this._cropManager.disable(), !this._renderer.rotateBy(s))
|
|
4138
|
+
return r && this._cropManager.enable(), !1;
|
|
4139
|
+
this._filterManager.applyFilters(), this._state.set("crop.rect", null), this._state.set("crop.dirty", !1), r && this._cropManager.enable();
|
|
4120
4140
|
}
|
|
4121
4141
|
return this._state.set("transform.rotation", i), this.emit("transformChanged", { rotation: i }), !0;
|
|
4122
4142
|
}
|
|
@@ -4170,10 +4190,10 @@ class kt extends se {
|
|
|
4170
4190
|
throw new Error("Background removal is not available for the current editor state");
|
|
4171
4191
|
this._state.set("isProcessing", !0), this._showLoadingOverlay("Removing background...");
|
|
4172
4192
|
try {
|
|
4173
|
-
const
|
|
4174
|
-
if (!
|
|
4193
|
+
const s = this.exportImage("png");
|
|
4194
|
+
if (!s)
|
|
4175
4195
|
throw new Error("Failed to export image for background removal");
|
|
4176
|
-
const
|
|
4196
|
+
const r = await this._removeBgManager.preparePreviewRequest(s, e), o = this._buildPreviewBackgroundRemovalContext(r), n = await this._removeBgManager.removeBackground(r.blob, r);
|
|
4177
4197
|
return await this._isCurrentPreviewBackgroundRemovalContext(o, n) ? (await this.loadImage(n.dataUrl), this.emit("background-removed", {
|
|
4178
4198
|
model: n.model,
|
|
4179
4199
|
processMs: n.processMs
|
|
@@ -4184,8 +4204,8 @@ class kt extends se {
|
|
|
4184
4204
|
operationId: o.operationId,
|
|
4185
4205
|
sourceHash: o.sourceHash
|
|
4186
4206
|
}), { stale: !0 });
|
|
4187
|
-
} catch (
|
|
4188
|
-
throw this.emit("error", { error:
|
|
4207
|
+
} catch (s) {
|
|
4208
|
+
throw this.emit("error", { error: s, context: "background-removal" }), s;
|
|
4189
4209
|
} finally {
|
|
4190
4210
|
(i = (t = this._state) == null ? void 0 : t.set) == null || i.call(t, "isProcessing", !1), this._hideLoadingOverlay();
|
|
4191
4211
|
}
|
|
@@ -4235,8 +4255,8 @@ class kt extends se {
|
|
|
4235
4255
|
d("div", { className: "editor-loading-text" }, e)
|
|
4236
4256
|
]);
|
|
4237
4257
|
else {
|
|
4238
|
-
const
|
|
4239
|
-
|
|
4258
|
+
const s = this._loadingOverlay.querySelector(".editor-loading-text");
|
|
4259
|
+
s && (s.textContent = e);
|
|
4240
4260
|
}
|
|
4241
4261
|
const t = (i = this._canvasContainer) == null ? void 0 : i.parentElement;
|
|
4242
4262
|
t && !this._loadingOverlay.parentElement && t.appendChild(this._loadingOverlay);
|
|
@@ -4252,36 +4272,36 @@ class kt extends se {
|
|
|
4252
4272
|
* Destroy the editor and clean up
|
|
4253
4273
|
*/
|
|
4254
4274
|
destroy() {
|
|
4255
|
-
var e, t, i,
|
|
4275
|
+
var e, t, i, s, r, o, n, a, l, h, c, p;
|
|
4256
4276
|
this._destroyed = !0, (t = (e = this._removeBgManager) == null ? void 0 : e.cancelActiveRequests) == null || t.call(e, "editor-destroy");
|
|
4257
|
-
for (const
|
|
4277
|
+
for (const u of this._objectUrls)
|
|
4258
4278
|
try {
|
|
4259
|
-
URL.revokeObjectURL(
|
|
4279
|
+
URL.revokeObjectURL(u);
|
|
4260
4280
|
} catch {
|
|
4261
4281
|
}
|
|
4262
|
-
this._objectUrls.clear(), this._activeObjectUrl = null, (i = this._resizeObserver) == null || i.disconnect(), this._renderer.destroy(), this._cropManager.disable(), this._handleWindowResize && window.removeEventListener("resize", this._handleWindowResize), (
|
|
4282
|
+
this._objectUrls.clear(), this._activeObjectUrl = null, (i = this._resizeObserver) == null || i.disconnect(), this._renderer.destroy(), this._cropManager.disable(), this._handleWindowResize && window.removeEventListener("resize", this._handleWindowResize), (s = this._toolbar) == null || s.destroy(), (r = this._categoryCarousel) == null || r.destroy(), (o = this._filterCarousel) == null || o.destroy(), (n = this._filterAdjustments) == null || n.destroy(), (a = this._mobileFilterDrawer) == null || a.destroy(), (l = this._mobileActiveFilters) == null || l.destroy(), (h = this._cropControls) == null || h.destroy(), (c = this._activeFiltersPanel) == null || c.destroy(), (p = this._editorEl) == null || p.remove(), this._container = null, this._state = null, this.emit("destroyed"), this.removeAllListeners();
|
|
4263
4283
|
}
|
|
4264
4284
|
}
|
|
4265
4285
|
export {
|
|
4266
4286
|
Ye as A,
|
|
4267
4287
|
Oe as B,
|
|
4268
|
-
|
|
4269
|
-
|
|
4288
|
+
de as C,
|
|
4289
|
+
pe as E,
|
|
4270
4290
|
Qe as F,
|
|
4271
4291
|
Te as P,
|
|
4272
4292
|
Xe as R,
|
|
4273
4293
|
et as T,
|
|
4274
4294
|
kt as V,
|
|
4275
4295
|
me as a,
|
|
4276
|
-
|
|
4277
|
-
|
|
4296
|
+
D as b,
|
|
4297
|
+
ce as c,
|
|
4278
4298
|
Ce as d,
|
|
4279
4299
|
d as e,
|
|
4280
4300
|
ke as f,
|
|
4281
4301
|
xe as g,
|
|
4282
4302
|
we as h,
|
|
4283
4303
|
ve as i,
|
|
4284
|
-
|
|
4304
|
+
ue as j,
|
|
4285
4305
|
bt as k,
|
|
4286
4306
|
yt as l,
|
|
4287
4307
|
vt as m,
|
|
@@ -4292,11 +4312,11 @@ export {
|
|
|
4292
4312
|
Ue as r,
|
|
4293
4313
|
Le as s,
|
|
4294
4314
|
He as t,
|
|
4295
|
-
|
|
4315
|
+
j as u,
|
|
4296
4316
|
gt as v,
|
|
4297
4317
|
mt as w,
|
|
4298
4318
|
dt as x,
|
|
4299
4319
|
ht as y,
|
|
4300
4320
|
_t as z
|
|
4301
4321
|
};
|
|
4302
|
-
//# sourceMappingURL=editor-
|
|
4322
|
+
//# sourceMappingURL=editor-CcfSL2dI.js.map
|