@snowcone-app/canvas 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ERROR_CONTRACT.md +11 -0
- package/STYLING_CONTRACT.md +5 -3
- package/dist/{CanvasRenderer-hpJ05JGO.js → CanvasRenderer-1j-twIbs.js} +443 -431
- package/dist/{CanvasRenderer-hpJ05JGO.js.map → CanvasRenderer-1j-twIbs.js.map} +1 -1
- package/dist/{CanvasStateV1-jLOibojY.js → CanvasStateV1-BmC1JfPv.js} +810 -802
- package/dist/{CanvasStateV1-jLOibojY.js.map → CanvasStateV1-BmC1JfPv.js.map} +1 -1
- package/dist/ContextualToolbars-CLDFENZq.js +6532 -0
- package/dist/ContextualToolbars-CLDFENZq.js.map +1 -0
- package/dist/{EditorCanvasImpl-P2GHPNA3.js → EditorCanvasImpl-XP_t-tNl.js} +7 -7
- package/dist/{EditorCanvasImpl-P2GHPNA3.js.map → EditorCanvasImpl-XP_t-tNl.js.map} +1 -1
- package/dist/{ExportManager-Bkzzyxgw.js → ExportManager-Ci81K6xA.js} +662 -518
- package/dist/ExportManager-Ci81K6xA.js.map +1 -0
- package/dist/{FontAnalyzer-BYhwxDhe.js → FontAnalyzer-BrKY6XYn.js} +1256 -1146
- package/dist/FontAnalyzer-BrKY6XYn.js.map +1 -0
- package/dist/{ImagePanel-CEr0_FYy.js → ImagePanel-ntJBepby.js} +6 -6
- package/dist/{ImagePanel-CEr0_FYy.js.map → ImagePanel-ntJBepby.js.map} +1 -1
- package/dist/{SnowconeCanvas-Fa0isFpO.js → SnowconeCanvas-wMLBZJ9z.js} +10 -10
- package/dist/{SnowconeCanvas-Fa0isFpO.js.map → SnowconeCanvas-wMLBZJ9z.js.map} +1 -1
- package/dist/advanced.mjs +14 -14
- package/dist/components/ImageToolbar.d.ts +8 -0
- package/dist/components/ShapeToolbar.d.ts +8 -0
- package/dist/components/TextToolbar.d.ts +5 -1
- package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +6 -0
- package/dist/components/toolbars/FloatingPanels.d.ts +10 -0
- package/dist/components/toolbars/GroupElementToolbar.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +37 -1
- package/dist/components/toolbars/alignButtons.d.ts +13 -0
- package/dist/components/toolbars/index.d.ts +5 -3
- package/dist/core/BaseElement.d.ts +2 -1
- package/dist/core/shape-fill.d.ts +31 -0
- package/dist/{custom-icons-Co4rcW0S.js → custom-icons-DTWtkJ9N.js} +2 -2
- package/dist/{custom-icons-Co4rcW0S.js.map → custom-icons-DTWtkJ9N.js.map} +1 -1
- package/dist/{design-builder-CBG2hKc8.js → design-builder-BpbYUYtK.js} +55 -55
- package/dist/{design-builder-CBG2hKc8.js.map → design-builder-BpbYUYtK.js.map} +1 -1
- package/dist/{embed-D4TIzO7g.js → embed-VTcnrkRj.js} +10 -10
- package/dist/{embed-D4TIzO7g.js.map → embed-VTcnrkRj.js.map} +1 -1
- package/dist/embed.mjs +7 -7
- package/dist/errors/editorError.d.ts +7 -0
- package/dist/{guards-DgZuwVgu.js → guards-BhaQgJrE.js} +2 -2
- package/dist/{guards-DgZuwVgu.js.map → guards-BhaQgJrE.js.map} +1 -1
- package/dist/hooks/elementPatch.d.ts +8 -3
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +123 -123
- package/dist/internals.mjs.map +1 -1
- package/dist/rendering/LayerEffectsRenderer.d.ts +24 -0
- package/dist/rendering/renderer-types.d.ts +3 -1
- package/dist/state/CanvasStateV1.d.ts +17 -0
- package/dist/style.css +1 -1
- package/dist/{template-fields-CvFcr5zy.js → template-fields-D-2oLhCi.js} +5 -5
- package/dist/{template-fields-CvFcr5zy.js.map → template-fields-D-2oLhCi.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +84 -1
- package/dist/types/public.d.ts +3 -2
- package/dist/{useCommands-bPXY9rCh.js → useCommands-DwnZHUg8.js} +435 -418
- package/dist/useCommands-DwnZHUg8.js.map +1 -0
- package/dist/{usePieceGuideBundle-Bj98nPk0.js → usePieceGuideBundle-CnSmYrmM.js} +2 -2
- package/dist/{usePieceGuideBundle-Bj98nPk0.js.map → usePieceGuideBundle-CnSmYrmM.js.map} +1 -1
- package/dist/utils/featureApplied.d.ts +4 -0
- package/dist/{validation-CsTlSvJJ.js → validation-CSa86fDE.js} +11 -11
- package/dist/{validation-CsTlSvJJ.js.map → validation-CSa86fDE.js.map} +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/ContextualToolbars-DRbuUE7W.js +0 -6061
- package/dist/ContextualToolbars-DRbuUE7W.js.map +0 -1
- package/dist/ExportManager-Bkzzyxgw.js.map +0 -1
- package/dist/FontAnalyzer-BYhwxDhe.js.map +0 -1
- package/dist/useCommands-bPXY9rCh.js.map +0 -1
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function ge(o) {
|
|
2
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
3
3
|
}
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Yt = { exports: {} }, O = Yt.exports = {}, _, z;
|
|
5
|
+
function Tt() {
|
|
6
6
|
throw new Error("setTimeout has not been defined");
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function Ft() {
|
|
9
9
|
throw new Error("clearTimeout has not been defined");
|
|
10
10
|
}
|
|
11
11
|
(function() {
|
|
12
12
|
try {
|
|
13
|
-
typeof setTimeout == "function" ?
|
|
13
|
+
typeof setTimeout == "function" ? _ = setTimeout : _ = Tt;
|
|
14
14
|
} catch {
|
|
15
|
-
|
|
15
|
+
_ = Tt;
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
typeof clearTimeout == "function" ?
|
|
18
|
+
typeof clearTimeout == "function" ? z = clearTimeout : z = Ft;
|
|
19
19
|
} catch {
|
|
20
|
-
|
|
20
|
+
z = Ft;
|
|
21
21
|
}
|
|
22
22
|
})();
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
25
|
-
return setTimeout(
|
|
26
|
-
if ((
|
|
27
|
-
return
|
|
23
|
+
function Ut(o) {
|
|
24
|
+
if (_ === setTimeout)
|
|
25
|
+
return setTimeout(o, 0);
|
|
26
|
+
if ((_ === Tt || !_) && setTimeout)
|
|
27
|
+
return _ = setTimeout, setTimeout(o, 0);
|
|
28
28
|
try {
|
|
29
|
-
return
|
|
29
|
+
return _(o, 0);
|
|
30
30
|
} catch {
|
|
31
31
|
try {
|
|
32
|
-
return
|
|
32
|
+
return _.call(null, o, 0);
|
|
33
33
|
} catch {
|
|
34
|
-
return
|
|
34
|
+
return _.call(this, o, 0);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
if (
|
|
40
|
-
return clearTimeout(
|
|
41
|
-
if ((
|
|
42
|
-
return
|
|
38
|
+
function fe(o) {
|
|
39
|
+
if (z === clearTimeout)
|
|
40
|
+
return clearTimeout(o);
|
|
41
|
+
if ((z === Ft || !z) && clearTimeout)
|
|
42
|
+
return z = clearTimeout, clearTimeout(o);
|
|
43
43
|
try {
|
|
44
|
-
return
|
|
44
|
+
return z(o);
|
|
45
45
|
} catch {
|
|
46
46
|
try {
|
|
47
|
-
return
|
|
47
|
+
return z.call(null, o);
|
|
48
48
|
} catch {
|
|
49
|
-
return
|
|
49
|
+
return z.call(this, o);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
55
|
-
!
|
|
53
|
+
var X = [], Q = !1, J, ft = -1;
|
|
54
|
+
function ue() {
|
|
55
|
+
!Q || !J || (Q = !1, J.length ? X = J.concat(X) : ft = -1, X.length && Gt());
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
if (!
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
for (var t =
|
|
62
|
-
for (
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
function Gt() {
|
|
58
|
+
if (!Q) {
|
|
59
|
+
var o = Ut(ue);
|
|
60
|
+
Q = !0;
|
|
61
|
+
for (var t = X.length; t; ) {
|
|
62
|
+
for (J = X, X = []; ++ft < t; )
|
|
63
|
+
J && J[ft].run();
|
|
64
|
+
ft = -1, t = X.length;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
J = null, Q = !1, fe(o);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
O.nextTick = function(
|
|
69
|
+
O.nextTick = function(o) {
|
|
70
70
|
var t = new Array(arguments.length - 1);
|
|
71
71
|
if (arguments.length > 1)
|
|
72
72
|
for (var e = 1; e < arguments.length; e++)
|
|
73
73
|
t[e - 1] = arguments[e];
|
|
74
|
-
|
|
74
|
+
X.push(new $t(o, t)), X.length === 1 && !Q && Ut(Gt);
|
|
75
75
|
};
|
|
76
|
-
function
|
|
77
|
-
this.fun =
|
|
76
|
+
function $t(o, t) {
|
|
77
|
+
this.fun = o, this.array = t;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
$t.prototype.run = function() {
|
|
80
80
|
this.fun.apply(null, this.array);
|
|
81
81
|
};
|
|
82
82
|
O.title = "browser";
|
|
@@ -96,27 +96,27 @@ O.removeAllListeners = Y;
|
|
|
96
96
|
O.emit = Y;
|
|
97
97
|
O.prependListener = Y;
|
|
98
98
|
O.prependOnceListener = Y;
|
|
99
|
-
O.listeners = function(
|
|
99
|
+
O.listeners = function(o) {
|
|
100
100
|
return [];
|
|
101
101
|
};
|
|
102
|
-
O.binding = function(
|
|
102
|
+
O.binding = function(o) {
|
|
103
103
|
throw new Error("process.binding is not supported");
|
|
104
104
|
};
|
|
105
105
|
O.cwd = function() {
|
|
106
106
|
return "/";
|
|
107
107
|
};
|
|
108
|
-
O.chdir = function(
|
|
108
|
+
O.chdir = function(o) {
|
|
109
109
|
throw new Error("process.chdir is not supported");
|
|
110
110
|
};
|
|
111
111
|
O.umask = function() {
|
|
112
112
|
return 0;
|
|
113
113
|
};
|
|
114
|
-
var
|
|
115
|
-
const
|
|
116
|
-
let
|
|
117
|
-
class
|
|
114
|
+
var me = Yt.exports;
|
|
115
|
+
const mt = /* @__PURE__ */ ge(me);
|
|
116
|
+
let Ht = 1;
|
|
117
|
+
class at {
|
|
118
118
|
constructor(t = {}) {
|
|
119
|
-
this.transformType = "artboard", this.id = t.id || `artboard-${
|
|
119
|
+
this.transformType = "artboard", this.id = t.id || `artboard-${Ht++}`, this.name = t.name || `Artboard ${Ht}`, this.x = t.x !== void 0 ? t.x : 0, this.y = t.y !== void 0 ? t.y : 0, this.width = t.width || 1920, this.height = t.height || 1080, this.backgroundColor = t.backgroundColor || "#ffffff", t.backgroundType ? this.backgroundType = t.backgroundType : t.backgroundColor === "transparent" ? this.backgroundType = "transparent" : t.backgroundTexture ? this.backgroundType = "texture" : this.backgroundType = "color", this.backgroundTexture = t.backgroundTexture, this.exportBackground = t.exportBackground ?? !1, this.clipShape = t.clipShape, this.previewBackgroundColor = t.previewBackgroundColor, this.role = t.role, this.distressTexture = t.distressTexture ? { ...t.distressTexture } : void 0, this.imageMask = t.imageMask ? { ...t.imageMask } : void 0, this.elementIds = new Set(t.elementIds || []);
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Get bounding box of the artboard
|
|
@@ -192,14 +192,14 @@ class nt {
|
|
|
192
192
|
* Returns true if point is near the border (within tolerance)
|
|
193
193
|
*/
|
|
194
194
|
hitTestBorder(t, e, i = 5) {
|
|
195
|
-
const s = t >= this.x - i && t <= this.x + this.width + i,
|
|
196
|
-
return
|
|
195
|
+
const s = t >= this.x - i && t <= this.x + this.width + i, r = e >= this.y - i && e <= this.y + this.height + i, h = Math.abs(t - this.x) <= i && r, n = Math.abs(t - (this.x + this.width)) <= i && r, a = Math.abs(e - this.y) <= i && s, l = Math.abs(e - (this.y + this.height)) <= i && s;
|
|
196
|
+
return h || n || a || l;
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* Clone the artboard
|
|
200
200
|
*/
|
|
201
201
|
clone() {
|
|
202
|
-
return new
|
|
202
|
+
return new at({
|
|
203
203
|
id: this.id,
|
|
204
204
|
name: this.name,
|
|
205
205
|
x: this.x,
|
|
@@ -253,7 +253,7 @@ class nt {
|
|
|
253
253
|
* Create from JSON
|
|
254
254
|
*/
|
|
255
255
|
static fromJSON(t) {
|
|
256
|
-
return new
|
|
256
|
+
return new at(t);
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* Update artboard properties
|
|
@@ -274,7 +274,7 @@ class nt {
|
|
|
274
274
|
this.x = t, this.y = e;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
class
|
|
277
|
+
class ui {
|
|
278
278
|
constructor() {
|
|
279
279
|
this.artboards = /* @__PURE__ */ new Map(), this.elementToArtboard = /* @__PURE__ */ new Map(), this.activeArtboardId = null;
|
|
280
280
|
}
|
|
@@ -290,7 +290,7 @@ class ri {
|
|
|
290
290
|
* callbacks until the controlled activeArtboard prop has been synced.
|
|
291
291
|
*/
|
|
292
292
|
createArtboard(t = {}) {
|
|
293
|
-
const e = new
|
|
293
|
+
const e = new at(t);
|
|
294
294
|
return this.artboards.set(e.id, e), this.activeArtboardId = e.id, e;
|
|
295
295
|
}
|
|
296
296
|
/**
|
|
@@ -355,8 +355,8 @@ class ri {
|
|
|
355
355
|
return !1;
|
|
356
356
|
const s = this.elementToArtboard.get(t);
|
|
357
357
|
if (s) {
|
|
358
|
-
const
|
|
359
|
-
|
|
358
|
+
const r = this.artboards.get(s);
|
|
359
|
+
r == null || r.removeElementId(t);
|
|
360
360
|
}
|
|
361
361
|
return i.addElementId(t), this.elementToArtboard.set(t, e), !0;
|
|
362
362
|
}
|
|
@@ -406,9 +406,9 @@ class ri {
|
|
|
406
406
|
*/
|
|
407
407
|
findArtboardBorderAtPoint(t, e, i = 5) {
|
|
408
408
|
const s = Array.from(this.artboards.values()).reverse();
|
|
409
|
-
for (const
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
409
|
+
for (const r of s)
|
|
410
|
+
if (r.hitTestBorder(t, e, i))
|
|
411
|
+
return r;
|
|
412
412
|
return null;
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
@@ -472,7 +472,7 @@ class ri {
|
|
|
472
472
|
*/
|
|
473
473
|
fromJSON(t) {
|
|
474
474
|
this.clear(), t.artboards.forEach((e) => {
|
|
475
|
-
const i =
|
|
475
|
+
const i = at.fromJSON(e);
|
|
476
476
|
this.artboards.set(i.id, i), i.getElementIds().forEach((s) => {
|
|
477
477
|
this.elementToArtboard.set(s, i.id);
|
|
478
478
|
});
|
|
@@ -487,8 +487,8 @@ class ri {
|
|
|
487
487
|
for (const [i, s] of this.elementToArtboard.entries())
|
|
488
488
|
e.has(i) || this.removeElementFromArtboard(i);
|
|
489
489
|
for (const i of this.artboards.values()) {
|
|
490
|
-
const s = i.getElementIds().filter((
|
|
491
|
-
i.clearElementIds(), s.forEach((
|
|
490
|
+
const s = i.getElementIds().filter((r) => e.has(r));
|
|
491
|
+
i.clearElementIds(), s.forEach((r) => i.addElementId(r));
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
}
|
|
@@ -499,8 +499,8 @@ const I = {
|
|
|
499
499
|
* @param {number} degrees - Rotation in degrees (positive = clockwise in UI)
|
|
500
500
|
* @returns {number} Rotation in radians for canvas context
|
|
501
501
|
*/
|
|
502
|
-
toRadians(
|
|
503
|
-
return -
|
|
502
|
+
toRadians(o) {
|
|
503
|
+
return -o * Math.PI / 180;
|
|
504
504
|
},
|
|
505
505
|
/**
|
|
506
506
|
* Inverse transform (world → local, for hit testing)
|
|
@@ -508,21 +508,21 @@ const I = {
|
|
|
508
508
|
* @param {number} degrees - Rotation in degrees
|
|
509
509
|
* @returns {number} Rotation in radians
|
|
510
510
|
*/
|
|
511
|
-
toRadiansInverse(
|
|
512
|
-
return
|
|
511
|
+
toRadiansInverse(o) {
|
|
512
|
+
return o * Math.PI / 180;
|
|
513
513
|
},
|
|
514
514
|
/**
|
|
515
515
|
* Normalize angle to -180 to +180 range
|
|
516
516
|
* @param {number} degrees - Angle in degrees
|
|
517
517
|
* @returns {number} Normalized angle in range [-180, 180]
|
|
518
518
|
*/
|
|
519
|
-
normalize(
|
|
520
|
-
let t = (
|
|
519
|
+
normalize(o) {
|
|
520
|
+
let t = (o % 360 + 360) % 360;
|
|
521
521
|
return t > 180 && (t -= 360), t;
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
|
-
let
|
|
525
|
-
class
|
|
524
|
+
let pe = 1;
|
|
525
|
+
class tt {
|
|
526
526
|
/** Whether this element clips content below it (derived from blendMode === 'clip') */
|
|
527
527
|
get isClipping() {
|
|
528
528
|
return this.blendMode === "clip";
|
|
@@ -531,7 +531,7 @@ class Q {
|
|
|
531
531
|
t ? (this.blendMode = "clip", this.knockoutParts || (this.knockoutParts = { fill: !0, scope: "group" })) : this.blendMode === "clip" && (this.blendMode = "normal");
|
|
532
532
|
}
|
|
533
533
|
constructor(t = {}) {
|
|
534
|
-
this.id = t.id || `element-${
|
|
534
|
+
this.id = t.id || `element-${pe++}`, this.x = t.x !== void 0 ? t.x : 100, this.y = t.y !== void 0 ? t.y : 100, this.rotation = t.rotation !== void 0 ? t.rotation : 0, this.opacity = t.opacity !== void 0 ? t.opacity : 1, this.transformType = t.transformType || "custom", this.transformData = t.transformData || {}, this.blendMode = t.blendMode, this.knockoutParts = t.knockoutParts, this.stroke = t.stroke, this.masks = t.masks, this.distressEffect = t.distressEffect, this.shadow = t.shadow, t.isClipping && !t.blendMode && (this.blendMode = "clip", this.knockoutParts || (this.knockoutParts = { fill: !0, scope: "group" })), this.name = t.name, this.visible = t.visible !== void 0 ? t.visible : !0, this.locked = t.locked !== void 0 ? t.locked : !1;
|
|
535
535
|
}
|
|
536
536
|
/**
|
|
537
537
|
* Get visual bounding box (tight fit around actual rendered content)
|
|
@@ -554,7 +554,7 @@ class Q {
|
|
|
554
554
|
* Uses visual bounding box for better user experience
|
|
555
555
|
*/
|
|
556
556
|
hitTest(t, e) {
|
|
557
|
-
const i = this.getVisualBoundingBox(), s = this.getRotationAnchor(),
|
|
557
|
+
const i = this.getVisualBoundingBox(), s = this.getRotationAnchor(), r = I.toRadiansInverse(this.rotation), h = Math.cos(r), n = Math.sin(r), a = t - s.x, l = e - s.y, c = a * h - l * n, g = a * n + l * h, d = s.x + c, f = s.y + g;
|
|
558
558
|
return d >= i.x && d <= i.x + i.width && f >= i.y && f <= i.y + i.height;
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
@@ -591,6 +591,7 @@ class Q {
|
|
|
591
591
|
masks: this.masks.map((t) => ({ ...t, maskElement: structuredClone(t.maskElement) }))
|
|
592
592
|
},
|
|
593
593
|
...this.distressEffect && { distressEffect: { ...this.distressEffect } },
|
|
594
|
+
...this.shadow && { shadow: { ...this.shadow } },
|
|
594
595
|
// Layer properties (only include if defined)
|
|
595
596
|
...this.name && { name: this.name },
|
|
596
597
|
...this.visible !== void 0 && { visible: this.visible },
|
|
@@ -665,10 +666,10 @@ class P {
|
|
|
665
666
|
* @returns Point in local coordinates
|
|
666
667
|
*/
|
|
667
668
|
worldToLocal(t, e) {
|
|
668
|
-
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i),
|
|
669
|
+
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), r = Math.sin(i), h = t - this.element.x, n = e - this.element.y;
|
|
669
670
|
return {
|
|
670
|
-
x:
|
|
671
|
-
y:
|
|
671
|
+
x: h * s - n * r,
|
|
672
|
+
y: h * r + n * s
|
|
672
673
|
};
|
|
673
674
|
}
|
|
674
675
|
/**
|
|
@@ -681,9 +682,9 @@ class P {
|
|
|
681
682
|
* @returns Point in world coordinates
|
|
682
683
|
*/
|
|
683
684
|
localToWorld(t, e) {
|
|
684
|
-
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i),
|
|
685
|
+
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), r = Math.sin(i), h = t * s - e * r, n = t * r + e * s;
|
|
685
686
|
return {
|
|
686
|
-
x: this.element.x +
|
|
687
|
+
x: this.element.x + h,
|
|
687
688
|
y: this.element.y + n
|
|
688
689
|
};
|
|
689
690
|
}
|
|
@@ -697,10 +698,10 @@ class P {
|
|
|
697
698
|
* @returns Delta in local space
|
|
698
699
|
*/
|
|
699
700
|
worldDeltaToLocal(t, e) {
|
|
700
|
-
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i),
|
|
701
|
+
const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), r = Math.sin(i);
|
|
701
702
|
return {
|
|
702
|
-
dx: t * s - e *
|
|
703
|
-
dy: t *
|
|
703
|
+
dx: t * s - e * r,
|
|
704
|
+
dy: t * r + e * s
|
|
704
705
|
};
|
|
705
706
|
}
|
|
706
707
|
/**
|
|
@@ -712,10 +713,10 @@ class P {
|
|
|
712
713
|
* @returns Delta in world space
|
|
713
714
|
*/
|
|
714
715
|
localDeltaToWorld(t, e) {
|
|
715
|
-
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i),
|
|
716
|
+
const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), r = Math.sin(i);
|
|
716
717
|
return {
|
|
717
|
-
dx: t * s - e *
|
|
718
|
-
dy: t *
|
|
718
|
+
dx: t * s - e * r,
|
|
719
|
+
dy: t * r + e * s
|
|
719
720
|
};
|
|
720
721
|
}
|
|
721
722
|
/**
|
|
@@ -729,8 +730,8 @@ class P {
|
|
|
729
730
|
* @param angleDegrees - Rotation angle in degrees (positive = clockwise in UI)
|
|
730
731
|
* @returns Rotated point in world space
|
|
731
732
|
*/
|
|
732
|
-
static rotatePointAroundAnchor(t, e, i, s,
|
|
733
|
-
const
|
|
733
|
+
static rotatePointAroundAnchor(t, e, i, s, r) {
|
|
734
|
+
const h = -r * Math.PI / 180, n = Math.cos(h), a = Math.sin(h), l = t - i, c = e - s, g = l * n - c * a, d = l * a + c * n;
|
|
734
735
|
return {
|
|
735
736
|
x: i + g,
|
|
736
737
|
y: s + d
|
|
@@ -791,7 +792,7 @@ class P {
|
|
|
791
792
|
return new P(t);
|
|
792
793
|
}
|
|
793
794
|
}
|
|
794
|
-
const
|
|
795
|
+
const ye = [
|
|
795
796
|
// Bold/Display Fonts - Perfect for statements and headlines (49 fonts)
|
|
796
797
|
{
|
|
797
798
|
name: "Bebas Neue",
|
|
@@ -2267,10 +2268,10 @@ const de = [
|
|
|
2267
2268
|
description: "Humanist monospace"
|
|
2268
2269
|
}
|
|
2269
2270
|
];
|
|
2270
|
-
function
|
|
2271
|
-
return
|
|
2271
|
+
function we() {
|
|
2272
|
+
return ye.map((o) => o.name);
|
|
2272
2273
|
}
|
|
2273
|
-
const
|
|
2274
|
+
const mi = {
|
|
2274
2275
|
system: "System Fonts",
|
|
2275
2276
|
display: "Bold & Display",
|
|
2276
2277
|
"sans-serif": "Sans Serif",
|
|
@@ -2282,99 +2283,99 @@ const ni = {
|
|
|
2282
2283
|
decorative: "Decorative & Unique",
|
|
2283
2284
|
monospace: "Monospace"
|
|
2284
2285
|
};
|
|
2285
|
-
function
|
|
2286
|
+
function Vt(o) {
|
|
2286
2287
|
if (typeof window > "u" || typeof document > "u")
|
|
2287
2288
|
return "oklch(0% 0 0)";
|
|
2288
|
-
const t =
|
|
2289
|
+
const t = o || document.documentElement;
|
|
2289
2290
|
return getComputedStyle(t).getPropertyValue("--accent").trim() || "oklch(0% 0 0)";
|
|
2290
2291
|
}
|
|
2291
|
-
function
|
|
2292
|
+
function be(o) {
|
|
2292
2293
|
return typeof window > "u" || typeof document > "u" ? "light" : document.documentElement.getAttribute("data-theme") || "light";
|
|
2293
2294
|
}
|
|
2294
|
-
function
|
|
2295
|
-
return
|
|
2295
|
+
function Jt() {
|
|
2296
|
+
return be().includes("dark") ? "#60a5fa" : "#3b82f6";
|
|
2296
2297
|
}
|
|
2297
|
-
function
|
|
2298
|
+
function pi(o) {
|
|
2298
2299
|
if (typeof window > "u" || typeof document > "u")
|
|
2299
2300
|
return "#FF0000";
|
|
2300
|
-
const t =
|
|
2301
|
+
const t = o || document.documentElement;
|
|
2301
2302
|
return getComputedStyle(t).getPropertyValue("--color-spacing-indicator").trim() || "#FF0000";
|
|
2302
2303
|
}
|
|
2303
|
-
function
|
|
2304
|
-
const e =
|
|
2304
|
+
function yi(o = 0.1, t) {
|
|
2305
|
+
const e = Vt(t);
|
|
2305
2306
|
if (e.startsWith("oklch("))
|
|
2306
|
-
return `${e.slice(0, -1)} / ${
|
|
2307
|
+
return `${e.slice(0, -1)} / ${o})`;
|
|
2307
2308
|
if (e.startsWith("#")) {
|
|
2308
|
-
const i = e.replace("#", ""), s = parseInt(i.substring(0, 2), 16),
|
|
2309
|
-
return `rgba(${s}, ${
|
|
2309
|
+
const i = e.replace("#", ""), s = parseInt(i.substring(0, 2), 16), r = parseInt(i.substring(2, 4), 16), h = parseInt(i.substring(4, 6), 16);
|
|
2310
|
+
return `rgba(${s}, ${r}, ${h}, ${o})`;
|
|
2310
2311
|
}
|
|
2311
2312
|
return e;
|
|
2312
2313
|
}
|
|
2313
|
-
function
|
|
2314
|
+
function wi(o) {
|
|
2314
2315
|
if (typeof window > "u" || typeof document > "u")
|
|
2315
2316
|
return "oklch(0% 0 0 / 0.45)";
|
|
2316
|
-
const t =
|
|
2317
|
+
const t = o || document.documentElement;
|
|
2317
2318
|
return getComputedStyle(t).getPropertyValue("--color-text-selection").trim() || "oklch(0% 0 0 / 0.45)";
|
|
2318
2319
|
}
|
|
2319
|
-
function
|
|
2320
|
+
function bi(o) {
|
|
2320
2321
|
if (typeof window > "u" || typeof document > "u")
|
|
2321
2322
|
return "#b5f747";
|
|
2322
|
-
const t =
|
|
2323
|
+
const t = o || document.documentElement;
|
|
2323
2324
|
return getComputedStyle(t).getPropertyValue("--color-accent-hover").trim() || "#b5f747";
|
|
2324
2325
|
}
|
|
2325
|
-
function
|
|
2326
|
+
function xe(o) {
|
|
2326
2327
|
if (typeof window > "u" || typeof document > "u")
|
|
2327
2328
|
return "oklch(0.2103 0.0059 285.89)";
|
|
2328
|
-
const t =
|
|
2329
|
+
const t = o || document.documentElement;
|
|
2329
2330
|
return getComputedStyle(t).getPropertyValue("--foreground").trim() || "oklch(0.2103 0.0059 285.89)";
|
|
2330
2331
|
}
|
|
2331
|
-
function
|
|
2332
|
+
function xi(o) {
|
|
2332
2333
|
if (typeof window > "u" || typeof document > "u")
|
|
2333
2334
|
return "oklch(0.9607 0 0)";
|
|
2334
|
-
const t =
|
|
2335
|
+
const t = o || document.documentElement;
|
|
2335
2336
|
return getComputedStyle(t).getPropertyValue("--background").trim() || "oklch(0.9607 0 0)";
|
|
2336
2337
|
}
|
|
2337
|
-
function
|
|
2338
|
-
const t =
|
|
2338
|
+
function Si(o) {
|
|
2339
|
+
const t = xe(o);
|
|
2339
2340
|
return t.startsWith("oklch(") ? `${t.slice(0, -1)} / 0.2)` : "rgba(0,0,0,0.2)";
|
|
2340
2341
|
}
|
|
2341
|
-
function
|
|
2342
|
+
function Ci(o) {
|
|
2342
2343
|
if (typeof window > "u" || typeof document > "u")
|
|
2343
2344
|
return "oklch(0% 0 0 / 0.2)";
|
|
2344
2345
|
const t = document.documentElement;
|
|
2345
2346
|
return getComputedStyle(t).getPropertyValue("--divider").trim() || "oklch(0% 0 0 / 0.2)";
|
|
2346
2347
|
}
|
|
2347
|
-
function
|
|
2348
|
+
function vi(o) {
|
|
2348
2349
|
if (typeof window > "u" || typeof document > "u")
|
|
2349
2350
|
return "oklch(0% 0 0 / 0.5)";
|
|
2350
2351
|
const t = document.documentElement, e = getComputedStyle(t).getPropertyValue("--foreground").trim();
|
|
2351
2352
|
return e.startsWith("oklch(") ? `${e.slice(0, -1)} / 0.5)` : e || "oklch(0% 0 0 / 0.5)";
|
|
2352
2353
|
}
|
|
2353
|
-
function
|
|
2354
|
+
function Ti(o) {
|
|
2354
2355
|
if (typeof window > "u" || typeof document > "u")
|
|
2355
2356
|
return "#b5f747";
|
|
2356
2357
|
const t = document.documentElement;
|
|
2357
2358
|
return getComputedStyle(t).getPropertyValue("--color-accent-hover-border").trim() || "#b5f747";
|
|
2358
2359
|
}
|
|
2359
|
-
function
|
|
2360
|
+
function Fi(o) {
|
|
2360
2361
|
if (typeof window > "u" || typeof document > "u")
|
|
2361
2362
|
return "oklch(0.2103 0.0059 285.89)";
|
|
2362
2363
|
const t = document.documentElement;
|
|
2363
2364
|
return getComputedStyle(t).getPropertyValue("--foreground").trim() || "oklch(0.2103 0.0059 285.89)";
|
|
2364
2365
|
}
|
|
2365
|
-
function
|
|
2366
|
+
function Ai(o) {
|
|
2366
2367
|
if (typeof window > "u" || typeof document > "u")
|
|
2367
2368
|
return "oklch(1 0 0)";
|
|
2368
2369
|
const t = document.documentElement;
|
|
2369
2370
|
return getComputedStyle(t).getPropertyValue("--background").trim() || "oklch(1 0 0)";
|
|
2370
2371
|
}
|
|
2371
|
-
function
|
|
2372
|
+
function Mi(o) {
|
|
2372
2373
|
if (typeof window > "u" || typeof document > "u")
|
|
2373
2374
|
return "oklch(0.2103 0.0059 285.89 / 0.5)";
|
|
2374
2375
|
const t = document.documentElement, e = getComputedStyle(t).getPropertyValue("--foreground").trim();
|
|
2375
2376
|
return e.startsWith("oklch(") ? `${e.slice(0, -1)} / 0.5)` : e || "oklch(0.2103 0.0059 285.89 / 0.5)";
|
|
2376
2377
|
}
|
|
2377
|
-
const
|
|
2378
|
+
const Di = 1, Ii = "#ffffff", Se = 20, ki = 6, Ei = 24, Ce = 16, ve = 36, Te = 24, Oi = 4, Bi = "#FFFFFF", Ri = 2, Hi = 0.1, Pi = we(), Li = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96, 128], Z = 0, qt = 1.2, jt = 50, Fe = 8, Ae = 999, Me = /* @__PURE__ */ new Set([
|
|
2378
2379
|
"Arial",
|
|
2379
2380
|
"Arial Black",
|
|
2380
2381
|
"Verdana",
|
|
@@ -2395,12 +2396,12 @@ const bi = 1, xi = "#ffffff", me = 20, Si = 6, Ci = 24, pe = 16, ye = 36, we = 2
|
|
|
2395
2396
|
"Monaco",
|
|
2396
2397
|
"Consolas",
|
|
2397
2398
|
"Courier"
|
|
2398
|
-
]),
|
|
2399
|
-
var
|
|
2400
|
-
class
|
|
2399
|
+
]), De = 0.3;
|
|
2400
|
+
var Ie = /* @__PURE__ */ ((o) => (o[o.DEBUG = 0] = "DEBUG", o[o.INFO = 1] = "INFO", o[o.WARN = 2] = "WARN", o[o.ERROR = 3] = "ERROR", o[o.NONE = 4] = "NONE", o))(Ie || {});
|
|
2401
|
+
class ke {
|
|
2401
2402
|
constructor() {
|
|
2402
2403
|
var t;
|
|
2403
|
-
this.level = 0, this.enabled = typeof
|
|
2404
|
+
this.level = 0, this.enabled = typeof mt < "u" && ((t = mt.env) == null ? void 0 : t.NODE_ENV) !== "production";
|
|
2404
2405
|
}
|
|
2405
2406
|
// Only enabled in development by default
|
|
2406
2407
|
/**
|
|
@@ -2454,10 +2455,10 @@ class Te {
|
|
|
2454
2455
|
* Create a scoped logger with a prefix for a specific module
|
|
2455
2456
|
*/
|
|
2456
2457
|
scope(t) {
|
|
2457
|
-
return new
|
|
2458
|
+
return new Ee(this, t);
|
|
2458
2459
|
}
|
|
2459
2460
|
}
|
|
2460
|
-
class
|
|
2461
|
+
class Ee {
|
|
2461
2462
|
constructor(t, e) {
|
|
2462
2463
|
this.logger = t, this.scopeName = e;
|
|
2463
2464
|
}
|
|
@@ -2474,22 +2475,22 @@ class Fe {
|
|
|
2474
2475
|
this.logger.error(`[${this.scopeName}] ${t}`, ...e);
|
|
2475
2476
|
}
|
|
2476
2477
|
}
|
|
2477
|
-
const
|
|
2478
|
-
function
|
|
2479
|
-
return
|
|
2480
|
-
|
|
2478
|
+
const Oe = new ke(), wt = (o) => Oe.scope(o), Be = wt("ImageLoadEvents"), At = /* @__PURE__ */ new Set();
|
|
2479
|
+
function Wi(o) {
|
|
2480
|
+
return At.add(o), () => {
|
|
2481
|
+
At.delete(o);
|
|
2481
2482
|
};
|
|
2482
2483
|
}
|
|
2483
|
-
function
|
|
2484
|
-
|
|
2484
|
+
function it(o) {
|
|
2485
|
+
At.forEach((t) => {
|
|
2485
2486
|
try {
|
|
2486
|
-
t(
|
|
2487
|
+
t(o);
|
|
2487
2488
|
} catch (e) {
|
|
2488
|
-
|
|
2489
|
+
Be.error("Listener error:", e);
|
|
2489
2490
|
}
|
|
2490
2491
|
});
|
|
2491
2492
|
}
|
|
2492
|
-
class
|
|
2493
|
+
class q {
|
|
2493
2494
|
constructor() {
|
|
2494
2495
|
this.cache = /* @__PURE__ */ new Map();
|
|
2495
2496
|
}
|
|
@@ -2497,7 +2498,7 @@ class J {
|
|
|
2497
2498
|
* Get the singleton ImageCache instance.
|
|
2498
2499
|
*/
|
|
2499
2500
|
static getInstance() {
|
|
2500
|
-
return
|
|
2501
|
+
return q.instance || (q.instance = new q()), q.instance;
|
|
2501
2502
|
}
|
|
2502
2503
|
/**
|
|
2503
2504
|
* Acquire an HTMLImageElement for the given URL.
|
|
@@ -2571,61 +2572,61 @@ class J {
|
|
|
2571
2572
|
this.cache.clear();
|
|
2572
2573
|
}
|
|
2573
2574
|
}
|
|
2574
|
-
const
|
|
2575
|
+
const Ni = Object.freeze({
|
|
2575
2576
|
brightness: 1,
|
|
2576
2577
|
contrast: 1,
|
|
2577
2578
|
saturation: 1
|
|
2578
|
-
}),
|
|
2579
|
-
function
|
|
2580
|
-
return
|
|
2579
|
+
}), Ct = 1e-3;
|
|
2580
|
+
function kt(o) {
|
|
2581
|
+
return o ? Math.abs(o.brightness - 1) < Ct && Math.abs(o.contrast - 1) < Ct && Math.abs(o.saturation - 1) < Ct : !0;
|
|
2581
2582
|
}
|
|
2582
|
-
function
|
|
2583
|
-
if (
|
|
2583
|
+
function Re(o) {
|
|
2584
|
+
if (kt(o)) return;
|
|
2584
2585
|
const t = (e) => Math.round(e * 100) / 100;
|
|
2585
2586
|
return {
|
|
2586
|
-
brightness: t(
|
|
2587
|
-
contrast: t(
|
|
2588
|
-
saturation: t(
|
|
2587
|
+
brightness: t(o.brightness),
|
|
2588
|
+
contrast: t(o.contrast),
|
|
2589
|
+
saturation: t(o.saturation)
|
|
2589
2590
|
};
|
|
2590
2591
|
}
|
|
2591
|
-
function
|
|
2592
|
-
if (
|
|
2593
|
-
const t =
|
|
2592
|
+
function _i(o) {
|
|
2593
|
+
if (kt(o)) return "neutral";
|
|
2594
|
+
const t = o;
|
|
2594
2595
|
return `b${t.brightness}c${t.contrast}s${t.saturation}`;
|
|
2595
2596
|
}
|
|
2596
|
-
let
|
|
2597
|
-
function
|
|
2598
|
-
|
|
2597
|
+
let Mt = null;
|
|
2598
|
+
function zi(o) {
|
|
2599
|
+
Mt = o;
|
|
2599
2600
|
}
|
|
2600
|
-
function
|
|
2601
|
-
if (
|
|
2602
|
-
if (!
|
|
2601
|
+
function He(o, t) {
|
|
2602
|
+
if (kt(t)) return o;
|
|
2603
|
+
if (!Mt)
|
|
2603
2604
|
throw new Error(
|
|
2604
2605
|
"[image-adjustments] no adjusted-source provider registered. Painting an image with non-neutral adjustments requires the rendering engine: import 'src/rendering/image-adjustments.js' (rendering/element-painters does this for every paint driver; a direct element.render() call in a test must import it too)."
|
|
2605
2606
|
);
|
|
2606
|
-
return
|
|
2607
|
+
return Mt(o, t);
|
|
2607
2608
|
}
|
|
2608
|
-
const
|
|
2609
|
-
function x(
|
|
2610
|
-
return
|
|
2609
|
+
const st = wt("ImageElement"), Pt = 3e4, Lt = 3, Pe = 1e3;
|
|
2610
|
+
function x(o) {
|
|
2611
|
+
return o.transformData;
|
|
2611
2612
|
}
|
|
2612
|
-
class
|
|
2613
|
+
class bt extends tt {
|
|
2613
2614
|
// Track URL acquired from ImageCache for release on destroy
|
|
2614
2615
|
constructor(t = {}) {
|
|
2615
|
-
var i, s,
|
|
2616
|
+
var i, s, r, h, n, a, l, c, g, d, f;
|
|
2616
2617
|
super(t), this.svgBlobUrl = null, this.loadTimeoutId = null, this.retryAttempt = 0, this.cachedImageUrl = null, this.transformType = "image", this.transformData = {
|
|
2617
2618
|
type: "image",
|
|
2618
2619
|
width: ((i = t.transformData) == null ? void 0 : i.width) || 200,
|
|
2619
2620
|
height: ((s = t.transformData) == null ? void 0 : s.height) || 200,
|
|
2620
|
-
cropX: ((
|
|
2621
|
-
cropY: ((
|
|
2621
|
+
cropX: ((r = t.transformData) == null ? void 0 : r.cropX) ?? 0,
|
|
2622
|
+
cropY: ((h = t.transformData) == null ? void 0 : h.cropY) ?? 0,
|
|
2622
2623
|
cropWidth: ((n = t.transformData) == null ? void 0 : n.cropWidth) ?? 1,
|
|
2623
|
-
cropHeight: ((
|
|
2624
|
+
cropHeight: ((a = t.transformData) == null ? void 0 : a.cropHeight) ?? 1,
|
|
2624
2625
|
flipHorizontal: ((l = t.transformData) == null ? void 0 : l.flipHorizontal) ?? !1,
|
|
2625
2626
|
flipVertical: ((c = t.transformData) == null ? void 0 : c.flipVertical) ?? !1,
|
|
2626
2627
|
borderRadius: ((g = t.transformData) == null ? void 0 : g.borderRadius) ?? 0
|
|
2627
2628
|
};
|
|
2628
|
-
const e =
|
|
2629
|
+
const e = Re((d = t.transformData) == null ? void 0 : d.adjustments);
|
|
2629
2630
|
e && (this.transformData.adjustments = e), this.imageUrl = t.imageUrl || "", this.imageLoaded = !1, this.imageElement = null, this.imageAspectRatio = t.imageAspectRatio || 1, this.isSvg = ((f = t.imageUrl) == null ? void 0 : f.toLowerCase().endsWith(".svg")) || !1, this.preserveDimensions = t.preserveDimensions ?? !1, this.imageLoadState = t.imageUrl ? "loading" : "loaded", this.imageLoadError = null, this.isCropping = !1, this.onLoadCallback = t.onLoadCallback || null, this.imageUrl && this.loadImage(this.imageUrl);
|
|
2630
2631
|
}
|
|
2631
2632
|
/**
|
|
@@ -2651,44 +2652,44 @@ class yt extends Q {
|
|
|
2651
2652
|
* across multiple ImageElement instances.
|
|
2652
2653
|
*/
|
|
2653
2654
|
attemptLoadRegularImage(t) {
|
|
2654
|
-
var
|
|
2655
|
+
var a;
|
|
2655
2656
|
this.clearLoadTimeout(), this.releaseImageCache();
|
|
2656
|
-
const i =
|
|
2657
|
+
const i = q.getInstance().acquire(t);
|
|
2657
2658
|
this.cachedImageUrl = t;
|
|
2658
2659
|
let s = !1;
|
|
2659
|
-
const
|
|
2660
|
+
const r = () => {
|
|
2660
2661
|
s = !0, this.clearLoadTimeout();
|
|
2661
2662
|
};
|
|
2662
2663
|
if (i.complete && i.naturalWidth > 0) {
|
|
2663
|
-
|
|
2664
|
+
r(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), it(this.id);
|
|
2664
2665
|
return;
|
|
2665
2666
|
}
|
|
2666
|
-
const
|
|
2667
|
+
const h = i.onload, n = i.onerror;
|
|
2667
2668
|
i.onload = (l) => {
|
|
2668
|
-
s || (
|
|
2669
|
+
s || (r(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), it(this.id), h && h !== i.onload && h(l));
|
|
2669
2670
|
}, i.onerror = (l) => {
|
|
2670
2671
|
if (s) return;
|
|
2671
|
-
|
|
2672
|
+
r();
|
|
2672
2673
|
const c = new Error(`Failed to load image: ${t}`);
|
|
2673
2674
|
this.handleLoadFailure(t, c), n && n !== i.onerror && n(l);
|
|
2674
2675
|
}, this.loadTimeoutId = setTimeout(() => {
|
|
2675
2676
|
if (s) return;
|
|
2676
|
-
|
|
2677
|
-
const l = new Error(`Image load timed out after ${
|
|
2677
|
+
r(), i.src = "";
|
|
2678
|
+
const l = new Error(`Image load timed out after ${Pt}ms: ${t}`);
|
|
2678
2679
|
this.handleLoadFailure(t, l);
|
|
2679
|
-
},
|
|
2680
|
+
}, Pt), (!i.src || i.src !== t) && (i.src = t), !s && i.complete && i.naturalWidth > 0 && ((a = i.onload) == null || a.call(i, new Event("load")));
|
|
2680
2681
|
}
|
|
2681
2682
|
/**
|
|
2682
2683
|
* Handle a load failure - either retry with backoff or set error state.
|
|
2683
2684
|
*/
|
|
2684
2685
|
handleLoadFailure(t, e) {
|
|
2685
|
-
if (this.retryAttempt++, this.retryAttempt <
|
|
2686
|
-
const i =
|
|
2687
|
-
|
|
2686
|
+
if (this.retryAttempt++, this.retryAttempt < Lt) {
|
|
2687
|
+
const i = Pe * Math.pow(2, this.retryAttempt - 1);
|
|
2688
|
+
st.warn(`Image load attempt ${this.retryAttempt} failed, retrying in ${i}ms:`, t), this.imageLoadState = "retrying", this.imageLoadError = e, it(this.id), this.loadTimeoutId = setTimeout(() => {
|
|
2688
2689
|
this.attemptLoadRegularImage(t);
|
|
2689
2690
|
}, i);
|
|
2690
2691
|
} else
|
|
2691
|
-
|
|
2692
|
+
st.error(`Image load failed after ${Lt} attempts:`, t), this.imageLoaded = !1, this.imageLoadState = "error", this.imageLoadError = e, it(this.id);
|
|
2692
2693
|
}
|
|
2693
2694
|
/**
|
|
2694
2695
|
* Clear any pending load timeout
|
|
@@ -2701,14 +2702,14 @@ class yt extends Q {
|
|
|
2701
2702
|
* Called when switching URLs or destroying the element.
|
|
2702
2703
|
*/
|
|
2703
2704
|
releaseImageCache() {
|
|
2704
|
-
this.cachedImageUrl && (
|
|
2705
|
+
this.cachedImageUrl && (q.getInstance().release(this.cachedImageUrl), this.cachedImageUrl = null);
|
|
2705
2706
|
}
|
|
2706
2707
|
/**
|
|
2707
2708
|
* Manually retry loading the image after a failure.
|
|
2708
2709
|
* Resets retry count and starts fresh.
|
|
2709
2710
|
*/
|
|
2710
2711
|
retryImageLoad() {
|
|
2711
|
-
this.imageUrl && (
|
|
2712
|
+
this.imageUrl && (st.info("Manual retry triggered for image:", this.imageUrl), this.clearLoadTimeout(), this.imageLoaded = !1, this.imageElement = null, this.isSvg ? (this.imageLoadState = "loading", this.imageLoadError = null, this.loadSvgAsHighDpi(this.imageUrl)) : this.loadRegularImage(this.imageUrl));
|
|
2712
2713
|
}
|
|
2713
2714
|
/**
|
|
2714
2715
|
* Revoke any existing SVG blob URL to prevent memory leaks
|
|
@@ -2727,18 +2728,18 @@ class yt extends Q {
|
|
|
2727
2728
|
e.crossOrigin = "anonymous", e.onload = () => {
|
|
2728
2729
|
const s = document.createElement("canvas");
|
|
2729
2730
|
s.width = e.width * 4, s.height = e.height * 4;
|
|
2730
|
-
const
|
|
2731
|
-
|
|
2732
|
-
if (!
|
|
2733
|
-
|
|
2731
|
+
const r = s.getContext("2d");
|
|
2732
|
+
r.scale(4, 4), r.drawImage(e, 0, 0), s.toBlob((h) => {
|
|
2733
|
+
if (!h) {
|
|
2734
|
+
st.error("Failed to convert SVG to blob"), this.imageLoaded = !1;
|
|
2734
2735
|
return;
|
|
2735
2736
|
}
|
|
2736
|
-
this.svgBlobUrl = URL.createObjectURL(
|
|
2737
|
-
this.imageLoaded = !0, this.imageAspectRatio = this.imageElement.width / this.imageElement.height, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()),
|
|
2737
|
+
this.svgBlobUrl = URL.createObjectURL(h), this.imageElement = new Image(), this.imageElement.crossOrigin = "anonymous", this.imageElement.onload = () => {
|
|
2738
|
+
this.imageLoaded = !0, this.imageAspectRatio = this.imageElement.width / this.imageElement.height, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), it(this.id);
|
|
2738
2739
|
}, this.imageElement.src = this.svgBlobUrl;
|
|
2739
2740
|
}, "image/png");
|
|
2740
2741
|
}, e.onerror = () => {
|
|
2741
|
-
|
|
2742
|
+
st.error("Failed to load SVG:", t), this.imageLoaded = !1;
|
|
2742
2743
|
}, e.src = t;
|
|
2743
2744
|
}
|
|
2744
2745
|
/**
|
|
@@ -2750,9 +2751,9 @@ class yt extends Q {
|
|
|
2750
2751
|
if (this.isCropping) {
|
|
2751
2752
|
const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
|
|
2752
2753
|
let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
|
|
2753
|
-
const
|
|
2754
|
-
i *=
|
|
2755
|
-
const n = Math.cos(I.toRadians(this.rotation)),
|
|
2754
|
+
const r = this.transformData.flipHorizontal ? -1 : 1, h = this.transformData.flipVertical ? -1 : 1;
|
|
2755
|
+
i *= r, s *= h;
|
|
2756
|
+
const n = Math.cos(I.toRadians(this.rotation)), a = Math.sin(I.toRadians(this.rotation)), l = i * n - s * a, c = i * a + s * n, g = this.x + l, d = this.y + c;
|
|
2756
2757
|
return {
|
|
2757
2758
|
x: g - this.transformData.width / 2,
|
|
2758
2759
|
y: d - this.transformData.height / 2,
|
|
@@ -2791,9 +2792,9 @@ class yt extends Q {
|
|
|
2791
2792
|
if (this.isCropping) {
|
|
2792
2793
|
const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
|
|
2793
2794
|
let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
|
|
2794
|
-
const
|
|
2795
|
-
i *=
|
|
2796
|
-
const n = Math.cos(I.toRadians(this.rotation)),
|
|
2795
|
+
const r = this.transformData.flipHorizontal ? -1 : 1, h = this.transformData.flipVertical ? -1 : 1;
|
|
2796
|
+
i *= r, s *= h;
|
|
2797
|
+
const n = Math.cos(I.toRadians(this.rotation)), a = Math.sin(I.toRadians(this.rotation)), l = i * n - s * a, c = i * a + s * n;
|
|
2797
2798
|
return {
|
|
2798
2799
|
x: this.x + l,
|
|
2799
2800
|
y: this.y + c
|
|
@@ -2810,11 +2811,11 @@ class yt extends Q {
|
|
|
2810
2811
|
hitTest(t, e) {
|
|
2811
2812
|
const i = this.worldToLocal(t, e);
|
|
2812
2813
|
if (this.isCropping) {
|
|
2813
|
-
const s = this.transformData.width * this.transformData.cropWidth,
|
|
2814
|
-
return i.x >=
|
|
2814
|
+
const s = this.transformData.width * this.transformData.cropWidth, r = this.transformData.height * this.transformData.cropHeight, h = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + s / 2), n = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + r / 2), a = this.transformData.width / 2, l = this.transformData.height / 2;
|
|
2815
|
+
return i.x >= h - a && i.x <= h + a && i.y >= n - l && i.y <= n + l;
|
|
2815
2816
|
} else {
|
|
2816
|
-
const s = this.transformData.width * this.transformData.cropWidth,
|
|
2817
|
-
return i.x >= -
|
|
2817
|
+
const s = this.transformData.width * this.transformData.cropWidth, r = this.transformData.height * this.transformData.cropHeight, h = s / 2, n = r / 2;
|
|
2818
|
+
return i.x >= -h && i.x <= h && i.y >= -n && i.y <= n;
|
|
2818
2819
|
}
|
|
2819
2820
|
}
|
|
2820
2821
|
/**
|
|
@@ -2825,13 +2826,13 @@ class yt extends Q {
|
|
|
2825
2826
|
this.renderPlaceholder(t);
|
|
2826
2827
|
return;
|
|
2827
2828
|
}
|
|
2828
|
-
const s =
|
|
2829
|
+
const s = He(
|
|
2829
2830
|
this.imageElement,
|
|
2830
2831
|
this.transformData.adjustments
|
|
2831
|
-
),
|
|
2832
|
+
), r = s.width, h = s.height;
|
|
2832
2833
|
t.save(), this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
2833
|
-
const n = this.transformData.flipHorizontal ? -1 : 1,
|
|
2834
|
-
if (t.scale(n,
|
|
2834
|
+
const n = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
|
|
2835
|
+
if (t.scale(n, a), this.isCropping) {
|
|
2835
2836
|
const l = this.transformData.width * this.transformData.cropWidth, c = this.transformData.height * this.transformData.cropHeight, g = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + l / 2), d = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + c / 2), f = g - this.transformData.width / 2, u = d - this.transformData.height / 2, m = this.transformData.borderRadius || 0;
|
|
2836
2837
|
if (m > 0) {
|
|
2837
2838
|
t.save();
|
|
@@ -2846,8 +2847,8 @@ class yt extends Q {
|
|
|
2846
2847
|
s,
|
|
2847
2848
|
0,
|
|
2848
2849
|
0,
|
|
2849
|
-
|
|
2850
|
-
|
|
2850
|
+
r,
|
|
2851
|
+
h,
|
|
2851
2852
|
f,
|
|
2852
2853
|
u,
|
|
2853
2854
|
this.transformData.width,
|
|
@@ -2859,8 +2860,8 @@ class yt extends Q {
|
|
|
2859
2860
|
s,
|
|
2860
2861
|
0,
|
|
2861
2862
|
0,
|
|
2862
|
-
|
|
2863
|
-
|
|
2863
|
+
r,
|
|
2864
|
+
h,
|
|
2864
2865
|
f,
|
|
2865
2866
|
u,
|
|
2866
2867
|
this.transformData.width,
|
|
@@ -2876,8 +2877,8 @@ class yt extends Q {
|
|
|
2876
2877
|
s,
|
|
2877
2878
|
0,
|
|
2878
2879
|
0,
|
|
2879
|
-
|
|
2880
|
-
|
|
2880
|
+
r,
|
|
2881
|
+
h,
|
|
2881
2882
|
m,
|
|
2882
2883
|
p,
|
|
2883
2884
|
this.transformData.width,
|
|
@@ -2892,25 +2893,25 @@ class yt extends Q {
|
|
|
2892
2893
|
*/
|
|
2893
2894
|
renderPlaceholder(t) {
|
|
2894
2895
|
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
2895
|
-
const e = this.transformData.width * this.transformData.cropWidth, i = this.transformData.height * this.transformData.cropHeight, s = -e / 2,
|
|
2896
|
-
let
|
|
2897
|
-
this.imageLoadState === "error" ? (
|
|
2896
|
+
const e = this.transformData.width * this.transformData.cropWidth, i = this.transformData.height * this.transformData.cropHeight, s = -e / 2, r = -i / 2;
|
|
2897
|
+
let h, n, a;
|
|
2898
|
+
this.imageLoadState === "error" ? (h = "#f0e0e0", n = "#993333", a = "Image failed to load") : this.imageLoadState === "retrying" ? (h = "#e0e0e0", n = "#666", a = "Retrying...") : this.imageLoadState === "loading" ? (h = "#e0e0e0", n = "#666", a = "Loading...") : (h = "#e0e0e0", n = "#666", a = this.imageUrl ? "Loading..." : "No image"), t.fillStyle = h, t.fillRect(s, r, e, i), t.fillStyle = n, t.font = "14px system-ui, -apple-system, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText(a, 0, 0), t.restore();
|
|
2898
2899
|
}
|
|
2899
2900
|
/**
|
|
2900
2901
|
* Handle resize - maintain aspect ratio
|
|
2901
2902
|
* @returns {boolean} true if resize was applied
|
|
2902
2903
|
*/
|
|
2903
2904
|
resize(t, e, i, s) {
|
|
2904
|
-
let
|
|
2905
|
-
this.isCropping ? (
|
|
2906
|
-
const n = (
|
|
2907
|
-
let
|
|
2908
|
-
this.isCropping && (
|
|
2905
|
+
let r, h;
|
|
2906
|
+
this.isCropping ? (r = e / x(s).width, h = i / x(s).height) : (r = e / (s.width ?? 1), h = i / (s.height ?? 1));
|
|
2907
|
+
const n = (r + h) / 2;
|
|
2908
|
+
let a = t;
|
|
2909
|
+
this.isCropping && (a = this.remapAnchorForFlips(t, s));
|
|
2909
2910
|
let l = n;
|
|
2910
2911
|
if (this.isCropping) {
|
|
2911
2912
|
const B = this.transformData.width / x(s).width;
|
|
2912
2913
|
n < B && (l = this.calculateMinScaleForCropBounds(
|
|
2913
|
-
|
|
2914
|
+
a,
|
|
2914
2915
|
s,
|
|
2915
2916
|
n,
|
|
2916
2917
|
B
|
|
@@ -2919,27 +2920,27 @@ class yt extends Q {
|
|
|
2919
2920
|
this.transformData.width = x(s).width * l, this.transformData.height = this.transformData.width / this.imageAspectRatio, this.rotation = s.rotation;
|
|
2920
2921
|
let c, g;
|
|
2921
2922
|
if (this.isCropping) {
|
|
2922
|
-
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx,
|
|
2923
|
-
c = s.x - W, g = s.y -
|
|
2923
|
+
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, N = E.dy;
|
|
2924
|
+
c = s.x - W, g = s.y - N;
|
|
2924
2925
|
} else {
|
|
2925
|
-
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx,
|
|
2926
|
-
c = s.x - W, g = s.y -
|
|
2926
|
+
const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, N = E.dy;
|
|
2927
|
+
c = s.x - W, g = s.y - N;
|
|
2927
2928
|
}
|
|
2928
2929
|
let d, f, u = 0, m = 0;
|
|
2929
|
-
|
|
2930
|
+
a === "top-left" ? (u = x(s).width / 2, m = x(s).height / 2) : a === "top-right" ? (u = -x(s).width / 2, m = x(s).height / 2) : a === "bottom-left" ? (u = x(s).width / 2, m = -x(s).height / 2) : a === "bottom-right" ? (u = -x(s).width / 2, m = -x(s).height / 2) : a === "middle-left" ? (u = x(s).width / 2, m = 0) : a === "middle-right" ? (u = -x(s).width / 2, m = 0) : a === "middle-top" ? (u = 0, m = x(s).height / 2) : a === "middle-bottom" && (u = 0, m = -x(s).height / 2);
|
|
2930
2931
|
const y = P.fromSnapshot(s).localDeltaToWorld(u, m), w = y.dx, S = y.dy;
|
|
2931
2932
|
d = c + w, f = g + S;
|
|
2932
2933
|
let b = 0, v = 0;
|
|
2933
|
-
|
|
2934
|
+
a === "top-left" ? (b = this.transformData.width / 2, v = this.transformData.height / 2) : a === "top-right" ? (b = -this.transformData.width / 2, v = this.transformData.height / 2) : a === "bottom-left" ? (b = this.transformData.width / 2, v = -this.transformData.height / 2) : a === "bottom-right" ? (b = -this.transformData.width / 2, v = -this.transformData.height / 2) : a === "middle-left" ? (b = this.transformData.width / 2, v = 0) : a === "middle-right" ? (b = -this.transformData.width / 2, v = 0) : a === "middle-top" ? (b = 0, v = this.transformData.height / 2) : a === "middle-bottom" && (b = 0, v = -this.transformData.height / 2);
|
|
2934
2935
|
const M = new P(this).localDeltaToWorld(b, v), F = M.dx, T = M.dy, D = d - F, U = f - T;
|
|
2935
2936
|
if (this.isCropping) {
|
|
2936
2937
|
const B = s.x, A = s.y, k = x(s).cropWidth * x(s).width, R = x(s).cropHeight * x(s).height;
|
|
2937
2938
|
this.x = B, this.y = A;
|
|
2938
|
-
const H = k / this.transformData.width, E = R / this.transformData.height, W = B - D,
|
|
2939
|
-
this.transformData.cropX =
|
|
2939
|
+
const H = k / this.transformData.width, E = R / this.transformData.height, W = B - D, N = A - U, Rt = new P(this).worldDeltaToLocal(W, N), ne = Rt.dx, ae = Rt.dy, he = this.transformData.width / 2 + ne, le = this.transformData.height / 2 + ae, ce = he / this.transformData.width - H / 2, de = le / this.transformData.height - E / 2;
|
|
2940
|
+
this.transformData.cropX = ce, this.transformData.cropY = de, this.transformData.cropWidth = H, this.transformData.cropHeight = E;
|
|
2940
2941
|
} else {
|
|
2941
|
-
const B = (this.transformData.cropX + this.transformData.cropWidth / 2) * this.transformData.width - this.transformData.width / 2, A = (this.transformData.cropY + this.transformData.cropHeight / 2) * this.transformData.height - this.transformData.height / 2, k = B, R = A, E = new P(this).localDeltaToWorld(k, R), W = E.dx,
|
|
2942
|
-
this.x = D + W, this.y = U +
|
|
2942
|
+
const B = (this.transformData.cropX + this.transformData.cropWidth / 2) * this.transformData.width - this.transformData.width / 2, A = (this.transformData.cropY + this.transformData.cropHeight / 2) * this.transformData.height - this.transformData.height / 2, k = B, R = A, E = new P(this).localDeltaToWorld(k, R), W = E.dx, N = E.dy;
|
|
2943
|
+
this.x = D + W, this.y = U + N;
|
|
2943
2944
|
}
|
|
2944
2945
|
return !0;
|
|
2945
2946
|
}
|
|
@@ -2995,9 +2996,9 @@ class yt extends Q {
|
|
|
2995
2996
|
// bottom-left
|
|
2996
2997
|
{ x: t.x + t.width, y: t.y + t.height }
|
|
2997
2998
|
// bottom-right
|
|
2998
|
-
].map((
|
|
2999
|
-
x: this.x +
|
|
3000
|
-
y: this.y +
|
|
2999
|
+
].map((r) => ({
|
|
3000
|
+
x: this.x + r.x * e - r.y * i,
|
|
3001
|
+
y: this.y + r.x * i + r.y * e
|
|
3001
3002
|
}));
|
|
3002
3003
|
}
|
|
3003
3004
|
/**
|
|
@@ -3005,12 +3006,12 @@ class yt extends Q {
|
|
|
3005
3006
|
* Local coordinates are relative to this.x, this.y (the center of the visible area)
|
|
3006
3007
|
*/
|
|
3007
3008
|
worldToLocal(t, e) {
|
|
3008
|
-
const i = t - this.x, s = e - this.y,
|
|
3009
|
-
let n = i *
|
|
3009
|
+
const i = t - this.x, s = e - this.y, r = Math.cos(I.toRadiansInverse(this.rotation)), h = Math.sin(I.toRadiansInverse(this.rotation));
|
|
3010
|
+
let n = i * r - s * h, a = i * h + s * r;
|
|
3010
3011
|
const l = this.transformData.flipHorizontal ? -1 : 1, c = this.transformData.flipVertical ? -1 : 1;
|
|
3011
|
-
return n *= l,
|
|
3012
|
+
return n *= l, a *= c, {
|
|
3012
3013
|
x: n,
|
|
3013
|
-
y:
|
|
3014
|
+
y: a
|
|
3014
3015
|
};
|
|
3015
3016
|
}
|
|
3016
3017
|
/**
|
|
@@ -3020,8 +3021,8 @@ class yt extends Q {
|
|
|
3020
3021
|
*/
|
|
3021
3022
|
localToWorld(t, e) {
|
|
3022
3023
|
const i = this.transformData.flipHorizontal ? -1 : 1, s = this.transformData.flipVertical ? -1 : 1;
|
|
3023
|
-
let
|
|
3024
|
-
const n = Math.cos(I.toRadians(this.rotation)),
|
|
3024
|
+
let r = t * i, h = e * s;
|
|
3025
|
+
const n = Math.cos(I.toRadians(this.rotation)), a = Math.sin(I.toRadians(this.rotation)), l = r * n - h * a, c = r * a + h * n;
|
|
3025
3026
|
return {
|
|
3026
3027
|
x: this.x + l,
|
|
3027
3028
|
y: this.y + c
|
|
@@ -3038,14 +3039,14 @@ class yt extends Q {
|
|
|
3038
3039
|
if (!this.isCropping) return null;
|
|
3039
3040
|
const s = this.getCropBoxBounds();
|
|
3040
3041
|
if (!s) return null;
|
|
3041
|
-
const
|
|
3042
|
+
const r = this.worldToLocal(t, e), h = 1 / i, n = Ce * h, a = ve * h, l = Te * h, c = [
|
|
3042
3043
|
{ x: s.x, y: s.y, anchor: "top-left" },
|
|
3043
3044
|
{ x: s.x + s.width, y: s.y, anchor: "top-right" },
|
|
3044
3045
|
{ x: s.x, y: s.y + s.height, anchor: "bottom-left" },
|
|
3045
3046
|
{ x: s.x + s.width, y: s.y + s.height, anchor: "bottom-right" }
|
|
3046
3047
|
];
|
|
3047
3048
|
for (const d of c) {
|
|
3048
|
-
const f =
|
|
3049
|
+
const f = r.x - d.x, u = r.y - d.y;
|
|
3049
3050
|
if (Math.sqrt(f * f + u * u) <= n) {
|
|
3050
3051
|
const p = this.localToWorld(d.x, d.y);
|
|
3051
3052
|
return { type: "corner", anchor: d.anchor, worldX: p.x, worldY: p.y };
|
|
@@ -3058,9 +3059,9 @@ class yt extends Q {
|
|
|
3058
3059
|
{ x: s.x + s.width, y: s.y + s.height / 2, anchor: "right", orientation: "vertical" }
|
|
3059
3060
|
];
|
|
3060
3061
|
for (const d of g) {
|
|
3061
|
-
const f =
|
|
3062
|
+
const f = r.x - d.x, u = r.y - d.y;
|
|
3062
3063
|
let m, p;
|
|
3063
|
-
if (d.orientation === "horizontal" ? (m =
|
|
3064
|
+
if (d.orientation === "horizontal" ? (m = a / 2, p = l / 2) : (m = l / 2, p = a / 2), Math.abs(f) <= m && Math.abs(u) <= p) {
|
|
3064
3065
|
const y = this.localToWorld(d.x, d.y);
|
|
3065
3066
|
return { type: "edge", anchor: d.anchor, worldX: y.x, worldY: y.y };
|
|
3066
3067
|
}
|
|
@@ -3086,42 +3087,42 @@ class yt extends Q {
|
|
|
3086
3087
|
* @param {number} cropHeight - Normalized height (0-1)
|
|
3087
3088
|
* @param {boolean} adjustPosition - Whether to adjust this.x, this.y to keep visual position stable (default: false)
|
|
3088
3089
|
*/
|
|
3089
|
-
updateCrop(t, e, i, s,
|
|
3090
|
-
let n = Math.max(0.1, Math.min(1, i)),
|
|
3091
|
-
l + n > 1 && (n = 1 - l), c +
|
|
3090
|
+
updateCrop(t, e, i, s, r = !1) {
|
|
3091
|
+
let n = Math.max(0.1, Math.min(1, i)), a = Math.max(0.1, Math.min(1, s)), l = Math.max(0, Math.min(1 - n, t)), c = Math.max(0, Math.min(1 - a, e));
|
|
3092
|
+
l + n > 1 && (n = 1 - l), c + a > 1 && (a = 1 - c);
|
|
3092
3093
|
let g = 0, d = 0;
|
|
3093
|
-
if (
|
|
3094
|
-
const f = this.transformData.cropX * this.transformData.width + this.transformData.cropWidth * this.transformData.width / 2, u = this.transformData.cropY * this.transformData.height + this.transformData.cropHeight * this.transformData.height / 2, m = l * this.transformData.width + n * this.transformData.width / 2, p = c * this.transformData.height +
|
|
3094
|
+
if (r) {
|
|
3095
|
+
const f = this.transformData.cropX * this.transformData.width + this.transformData.cropWidth * this.transformData.width / 2, u = this.transformData.cropY * this.transformData.height + this.transformData.cropHeight * this.transformData.height / 2, m = l * this.transformData.width + n * this.transformData.width / 2, p = c * this.transformData.height + a * this.transformData.height / 2, y = m - f, w = p - u, S = Math.cos(I.toRadians(this.rotation)), b = Math.sin(I.toRadians(this.rotation));
|
|
3095
3096
|
g = y * S - w * b, d = y * b + w * S;
|
|
3096
3097
|
}
|
|
3097
|
-
this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight =
|
|
3098
|
+
this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight = a, r && (this.x += g, this.y += d);
|
|
3098
3099
|
}
|
|
3099
3100
|
/**
|
|
3100
3101
|
* Get the local position of the corner opposite to the given anchor
|
|
3101
3102
|
* Corners are relative to frame center
|
|
3102
3103
|
*/
|
|
3103
3104
|
getOppositeCornerLocalPosition(t, e, i) {
|
|
3104
|
-
const s = e / 2,
|
|
3105
|
+
const s = e / 2, r = i / 2;
|
|
3105
3106
|
return {
|
|
3106
|
-
"top-left": { x: s, y:
|
|
3107
|
+
"top-left": { x: s, y: r },
|
|
3107
3108
|
// Opposite is bottom-right
|
|
3108
|
-
"top-right": { x: -s, y:
|
|
3109
|
+
"top-right": { x: -s, y: r },
|
|
3109
3110
|
// Opposite is bottom-left
|
|
3110
|
-
"bottom-left": { x: s, y: -
|
|
3111
|
+
"bottom-left": { x: s, y: -r },
|
|
3111
3112
|
// Opposite is top-right
|
|
3112
|
-
"bottom-right": { x: -s, y: -
|
|
3113
|
+
"bottom-right": { x: -s, y: -r },
|
|
3113
3114
|
// Opposite is top-left
|
|
3114
|
-
top: { x: 0, y:
|
|
3115
|
+
top: { x: 0, y: r },
|
|
3115
3116
|
// Opposite is bottom edge
|
|
3116
|
-
bottom: { x: 0, y: -
|
|
3117
|
+
bottom: { x: 0, y: -r },
|
|
3117
3118
|
// Opposite is top edge
|
|
3118
3119
|
left: { x: s, y: 0 },
|
|
3119
3120
|
// Opposite is right edge
|
|
3120
3121
|
right: { x: -s, y: 0 },
|
|
3121
3122
|
// Opposite is left edge
|
|
3122
|
-
"middle-top": { x: 0, y:
|
|
3123
|
+
"middle-top": { x: 0, y: r },
|
|
3123
3124
|
// Opposite is bottom edge
|
|
3124
|
-
"middle-bottom": { x: 0, y: -
|
|
3125
|
+
"middle-bottom": { x: 0, y: -r },
|
|
3125
3126
|
// Opposite is top edge
|
|
3126
3127
|
"middle-left": { x: s, y: 0 },
|
|
3127
3128
|
// Opposite is right edge
|
|
@@ -3134,7 +3135,7 @@ class yt extends Q {
|
|
|
3134
3135
|
* In crop mode, this.x/y is the crop center, not the frame center
|
|
3135
3136
|
*/
|
|
3136
3137
|
calculateFrameCenterFromCropCenter(t) {
|
|
3137
|
-
const e = x(t).width * x(t).cropWidth, i = x(t).height * x(t).cropHeight, s = x(t).width / 2 - (x(t).cropX * x(t).width + e / 2),
|
|
3138
|
+
const e = x(t).width * x(t).cropWidth, i = x(t).height * x(t).cropHeight, s = x(t).width / 2 - (x(t).cropX * x(t).width + e / 2), r = x(t).height / 2 - (x(t).cropY * x(t).height + i / 2), n = new P(t).localDeltaToWorld(s, r);
|
|
3138
3139
|
return {
|
|
3139
3140
|
x: t.x + n.dx,
|
|
3140
3141
|
y: t.y + n.dy
|
|
@@ -3148,10 +3149,10 @@ class yt extends Q {
|
|
|
3148
3149
|
t,
|
|
3149
3150
|
x(e).width,
|
|
3150
3151
|
x(e).height
|
|
3151
|
-
), s = this.calculateFrameCenterFromCropCenter(e),
|
|
3152
|
+
), s = this.calculateFrameCenterFromCropCenter(e), h = new P(e).localDeltaToWorld(i.x, i.y);
|
|
3152
3153
|
return {
|
|
3153
|
-
x: s.x +
|
|
3154
|
-
y: s.y +
|
|
3154
|
+
x: s.x + h.dx,
|
|
3155
|
+
y: s.y + h.dy
|
|
3155
3156
|
};
|
|
3156
3157
|
}
|
|
3157
3158
|
/**
|
|
@@ -3159,7 +3160,7 @@ class yt extends Q {
|
|
|
3159
3160
|
* The opposite corner from the anchor stays fixed in world space
|
|
3160
3161
|
*/
|
|
3161
3162
|
calculateFrameCenterAfterResize(t, e, i) {
|
|
3162
|
-
const s = this.getFixedCornerWorldPosition(e, i),
|
|
3163
|
+
const s = this.getFixedCornerWorldPosition(e, i), r = x(i).width * t, h = r / this.imageAspectRatio, n = this.getOppositeCornerLocalPosition(e, r, h), l = new P({
|
|
3163
3164
|
x: 0,
|
|
3164
3165
|
// Will calculate frame center
|
|
3165
3166
|
y: 0,
|
|
@@ -3176,7 +3177,7 @@ class yt extends Q {
|
|
|
3176
3177
|
* would be positioned within the frame after resize.
|
|
3177
3178
|
*/
|
|
3178
3179
|
calculateCropStateAtScale(t, e, i) {
|
|
3179
|
-
const s = x(i).width * t,
|
|
3180
|
+
const s = x(i).width * t, r = s / this.imageAspectRatio, h = x(i).cropWidth * x(i).width, n = x(i).cropHeight * x(i).height, a = h / s, l = n / r, c = this.calculateFrameCenterAfterResize(t, e, i), g = {
|
|
3180
3181
|
x: i.x,
|
|
3181
3182
|
// In crop mode, this.x/y is the crop center
|
|
3182
3183
|
y: i.y
|
|
@@ -3184,11 +3185,11 @@ class yt extends Q {
|
|
|
3184
3185
|
x: c.x,
|
|
3185
3186
|
y: c.y,
|
|
3186
3187
|
rotation: i.rotation
|
|
3187
|
-
}).worldDeltaToLocal(d, f), p = s / 2 + m.dx, y =
|
|
3188
|
+
}).worldDeltaToLocal(d, f), p = s / 2 + m.dx, y = r / 2 + m.dy, w = p / s - a / 2, S = y / r - l / 2;
|
|
3188
3189
|
return {
|
|
3189
3190
|
cropX: w,
|
|
3190
3191
|
cropY: S,
|
|
3191
|
-
cropWidth:
|
|
3192
|
+
cropWidth: a,
|
|
3192
3193
|
cropHeight: l
|
|
3193
3194
|
};
|
|
3194
3195
|
}
|
|
@@ -3196,11 +3197,11 @@ class yt extends Q {
|
|
|
3196
3197
|
* Check if a given scale keeps crop within frame bounds
|
|
3197
3198
|
*/
|
|
3198
3199
|
isScaleValidForCropBounds(t, e, i) {
|
|
3199
|
-
const
|
|
3200
|
-
if (
|
|
3200
|
+
const r = this.calculateCropStateAtScale(t, e, i);
|
|
3201
|
+
if (r.cropWidth > 1 + 1e-4 || r.cropHeight > 1 + 1e-4)
|
|
3201
3202
|
return !1;
|
|
3202
|
-
const
|
|
3203
|
-
return
|
|
3203
|
+
const h = r.cropX, n = r.cropX + r.cropWidth, a = r.cropY, l = r.cropY + r.cropHeight;
|
|
3204
|
+
return h >= -1e-4 && a >= -1e-4 && n <= 1 + 1e-4 && l <= 1 + 1e-4;
|
|
3204
3205
|
}
|
|
3205
3206
|
/**
|
|
3206
3207
|
* Calculate minimum scale that keeps crop within frame bounds
|
|
@@ -3209,27 +3210,27 @@ class yt extends Q {
|
|
|
3209
3210
|
calculateMinScaleForCropBounds(t, e, i, s) {
|
|
3210
3211
|
if (this.isScaleValidForCropBounds(i, t, e))
|
|
3211
3212
|
return i;
|
|
3212
|
-
let n = i,
|
|
3213
|
+
let n = i, a = s;
|
|
3213
3214
|
for (let l = 0; l < 20; l++) {
|
|
3214
|
-
const c = (n +
|
|
3215
|
-
if (this.isScaleValidForCropBounds(c, t, e) ?
|
|
3215
|
+
const c = (n + a) / 2;
|
|
3216
|
+
if (this.isScaleValidForCropBounds(c, t, e) ? a = c : n = c, Math.abs(a - n) < 1e-4)
|
|
3216
3217
|
break;
|
|
3217
3218
|
}
|
|
3218
|
-
return
|
|
3219
|
+
return a;
|
|
3219
3220
|
}
|
|
3220
3221
|
/**
|
|
3221
3222
|
* Remap anchor to account for flips
|
|
3222
3223
|
*/
|
|
3223
3224
|
remapAnchorForFlips(t, e) {
|
|
3224
3225
|
let i = t;
|
|
3225
|
-
const s = x(e).flipHorizontal,
|
|
3226
|
-
return s && (i.includes("left") ? i = i.replace("left", "right") : i.includes("right") && (i = i.replace("right", "left"))),
|
|
3226
|
+
const s = x(e).flipHorizontal, r = x(e).flipVertical;
|
|
3227
|
+
return s && (i.includes("left") ? i = i.replace("left", "right") : i.includes("right") && (i = i.replace("right", "left"))), r && (i.includes("top") ? i = i.replace("top", "bottom") : i.includes("bottom") && (i = i.replace("bottom", "top"))), i;
|
|
3227
3228
|
}
|
|
3228
3229
|
/**
|
|
3229
3230
|
* Clone this element
|
|
3230
3231
|
*/
|
|
3231
3232
|
clone() {
|
|
3232
|
-
const t = this.toJSON(), { imageUrl: e, ...i } = t, s = new
|
|
3233
|
+
const t = this.toJSON(), { imageUrl: e, ...i } = t, s = new bt(i);
|
|
3233
3234
|
return s.imageUrl = this.imageUrl, s.imageElement = this.imageElement, s.imageLoaded = this.imageLoaded, s.imageAspectRatio = this.imageAspectRatio, s.isCropping = this.isCropping, s.onLoadCallback = this.onLoadCallback, s.isSvg = this.isSvg, s.imageLoadState = this.imageLoadState, s.imageLoadError = this.imageLoadError, s.preserveDimensions = this.preserveDimensions, s;
|
|
3234
3235
|
}
|
|
3235
3236
|
/**
|
|
@@ -3269,28 +3270,35 @@ class yt extends Q {
|
|
|
3269
3270
|
this.clearLoadTimeout(), this.releaseImageCache(), this.revokeSvgBlobUrl(), this.imageElement = null, this.onLoadCallback = null, this.imageLoadError = null;
|
|
3270
3271
|
}
|
|
3271
3272
|
}
|
|
3272
|
-
const
|
|
3273
|
-
let
|
|
3274
|
-
function
|
|
3273
|
+
const Zt = /* @__PURE__ */ new Map();
|
|
3274
|
+
let Dt = null;
|
|
3275
|
+
function Kt(o) {
|
|
3275
3276
|
return new Error(
|
|
3276
|
-
`[paint-registry] no painter registered for ${
|
|
3277
|
+
`[paint-registry] no painter registered for ${o}. Element painting requires the rendering engine: import 'src/rendering/element-painters.js' (every paint driver — CanvasRenderer, ExportManager, ElementPreviewRenderer — does this; a direct element.render() call in a test must import it too).`
|
|
3277
3278
|
);
|
|
3278
3279
|
}
|
|
3279
|
-
function
|
|
3280
|
-
|
|
3280
|
+
function Xi(o, t) {
|
|
3281
|
+
Zt.set(o, t);
|
|
3281
3282
|
}
|
|
3282
|
-
function
|
|
3283
|
-
const t =
|
|
3284
|
-
if (!t) throw
|
|
3283
|
+
function ut(o) {
|
|
3284
|
+
const t = Zt.get(o);
|
|
3285
|
+
if (!t) throw Kt(`text transform "${o}"`);
|
|
3285
3286
|
return t;
|
|
3286
3287
|
}
|
|
3287
|
-
function
|
|
3288
|
-
|
|
3288
|
+
function Yi(o) {
|
|
3289
|
+
Dt = o;
|
|
3289
3290
|
}
|
|
3290
|
-
function
|
|
3291
|
-
if (!
|
|
3292
|
-
return
|
|
3291
|
+
function Le() {
|
|
3292
|
+
if (!Dt) throw Kt("group clipping");
|
|
3293
|
+
return Dt;
|
|
3293
3294
|
}
|
|
3295
|
+
const We = [
|
|
3296
|
+
"multiply",
|
|
3297
|
+
"screen",
|
|
3298
|
+
"overlay",
|
|
3299
|
+
"darken",
|
|
3300
|
+
"lighten"
|
|
3301
|
+
];
|
|
3294
3302
|
class L {
|
|
3295
3303
|
constructor(t = []) {
|
|
3296
3304
|
this.spans = t.length > 0 ? t.map((e) => ({ ...e, style: { ...e.style } })) : [{ text: "", style: {} }], this.normalize();
|
|
@@ -3339,28 +3347,28 @@ class L {
|
|
|
3339
3347
|
if (t >= e || t < 0 || e > this.getLength())
|
|
3340
3348
|
return;
|
|
3341
3349
|
const s = [];
|
|
3342
|
-
let
|
|
3343
|
-
for (const
|
|
3344
|
-
const n =
|
|
3345
|
-
if (
|
|
3346
|
-
s.push(
|
|
3350
|
+
let r = 0;
|
|
3351
|
+
for (const h of this.spans) {
|
|
3352
|
+
const n = r, a = r + h.text.length;
|
|
3353
|
+
if (a <= t) {
|
|
3354
|
+
s.push(h), r = a;
|
|
3347
3355
|
continue;
|
|
3348
3356
|
}
|
|
3349
3357
|
if (n >= e) {
|
|
3350
|
-
s.push(
|
|
3358
|
+
s.push(h), r = a;
|
|
3351
3359
|
continue;
|
|
3352
3360
|
}
|
|
3353
|
-
const l = Math.max(t, n), c = Math.min(e,
|
|
3361
|
+
const l = Math.max(t, n), c = Math.min(e, a);
|
|
3354
3362
|
l > n && s.push({
|
|
3355
|
-
text:
|
|
3356
|
-
style:
|
|
3363
|
+
text: h.text.substring(0, l - n),
|
|
3364
|
+
style: h.style
|
|
3357
3365
|
}), s.push({
|
|
3358
|
-
text:
|
|
3359
|
-
style: { ...
|
|
3360
|
-
}), c <
|
|
3361
|
-
text:
|
|
3362
|
-
style:
|
|
3363
|
-
}),
|
|
3366
|
+
text: h.text.substring(l - n, c - n),
|
|
3367
|
+
style: { ...h.style, ...i }
|
|
3368
|
+
}), c < a && s.push({
|
|
3369
|
+
text: h.text.substring(c - n),
|
|
3370
|
+
style: h.style
|
|
3371
|
+
}), r = a;
|
|
3364
3372
|
}
|
|
3365
3373
|
this.spans = s, this.normalize();
|
|
3366
3374
|
}
|
|
@@ -3373,23 +3381,23 @@ class L {
|
|
|
3373
3381
|
insert(t, e, i) {
|
|
3374
3382
|
if (e.length === 0) return;
|
|
3375
3383
|
const s = [];
|
|
3376
|
-
let
|
|
3377
|
-
for (const
|
|
3378
|
-
const n =
|
|
3379
|
-
if (t <= n && s.length === 0 && s.push({ text: e, style: i }), t > n && t <=
|
|
3384
|
+
let r = 0;
|
|
3385
|
+
for (const h of this.spans) {
|
|
3386
|
+
const n = r, a = r + h.text.length;
|
|
3387
|
+
if (t <= n && s.length === 0 && s.push({ text: e, style: i }), t > n && t <= a) {
|
|
3380
3388
|
const l = t - n;
|
|
3381
3389
|
s.push({
|
|
3382
|
-
text:
|
|
3383
|
-
style:
|
|
3390
|
+
text: h.text.substring(0, l),
|
|
3391
|
+
style: h.style
|
|
3384
3392
|
}), s.push({ text: e, style: i }), s.push({
|
|
3385
|
-
text:
|
|
3386
|
-
style:
|
|
3387
|
-
}),
|
|
3393
|
+
text: h.text.substring(l),
|
|
3394
|
+
style: h.style
|
|
3395
|
+
}), r = a;
|
|
3388
3396
|
continue;
|
|
3389
3397
|
}
|
|
3390
|
-
s.push(
|
|
3398
|
+
s.push(h), r = a;
|
|
3391
3399
|
}
|
|
3392
|
-
t >= this.getLength() && !s.some((
|
|
3400
|
+
t >= this.getLength() && !s.some((h) => h.text === e) && s.push({ text: e, style: i }), this.spans = s, this.normalize();
|
|
3393
3401
|
}
|
|
3394
3402
|
/**
|
|
3395
3403
|
* Delete text in a character range
|
|
@@ -3401,25 +3409,25 @@ class L {
|
|
|
3401
3409
|
if (t = Math.max(0, Math.min(t, i)), e = Math.max(0, Math.min(e, i)), t >= e)
|
|
3402
3410
|
return;
|
|
3403
3411
|
const s = [];
|
|
3404
|
-
let
|
|
3405
|
-
for (const
|
|
3406
|
-
const n =
|
|
3407
|
-
if (
|
|
3408
|
-
s.push(
|
|
3412
|
+
let r = 0;
|
|
3413
|
+
for (const h of this.spans) {
|
|
3414
|
+
const n = r, a = r + h.text.length;
|
|
3415
|
+
if (a <= t) {
|
|
3416
|
+
s.push(h), r = a;
|
|
3409
3417
|
continue;
|
|
3410
3418
|
}
|
|
3411
3419
|
if (n >= e) {
|
|
3412
|
-
s.push(
|
|
3420
|
+
s.push(h), r = a;
|
|
3413
3421
|
continue;
|
|
3414
3422
|
}
|
|
3415
|
-
const l = Math.max(t, n), c = Math.min(e,
|
|
3423
|
+
const l = Math.max(t, n), c = Math.min(e, a);
|
|
3416
3424
|
l > n && s.push({
|
|
3417
|
-
text:
|
|
3418
|
-
style:
|
|
3419
|
-
}), c <
|
|
3420
|
-
text:
|
|
3421
|
-
style:
|
|
3422
|
-
}),
|
|
3425
|
+
text: h.text.substring(0, l - n),
|
|
3426
|
+
style: h.style
|
|
3427
|
+
}), c < a && s.push({
|
|
3428
|
+
text: h.text.substring(c - n),
|
|
3429
|
+
style: h.style
|
|
3430
|
+
}), r = a;
|
|
3423
3431
|
}
|
|
3424
3432
|
this.spans = s.length > 0 ? s : [{ text: "", style: {} }], this.normalize();
|
|
3425
3433
|
}
|
|
@@ -3487,69 +3495,72 @@ class L {
|
|
|
3487
3495
|
return new L(t.spans);
|
|
3488
3496
|
}
|
|
3489
3497
|
}
|
|
3490
|
-
function
|
|
3491
|
-
return
|
|
3498
|
+
function Ui(o) {
|
|
3499
|
+
return o.type === "custom";
|
|
3492
3500
|
}
|
|
3493
|
-
function
|
|
3494
|
-
return
|
|
3501
|
+
function Gi(o) {
|
|
3502
|
+
return o.type === "circle";
|
|
3495
3503
|
}
|
|
3496
|
-
function
|
|
3497
|
-
return
|
|
3504
|
+
function $i(o) {
|
|
3505
|
+
return o.type === "arch";
|
|
3498
3506
|
}
|
|
3499
|
-
function
|
|
3500
|
-
return
|
|
3507
|
+
function Vi(o) {
|
|
3508
|
+
return o.type === "wave";
|
|
3501
3509
|
}
|
|
3502
|
-
function
|
|
3503
|
-
return
|
|
3510
|
+
function Ji(o) {
|
|
3511
|
+
return o.type === "flag";
|
|
3504
3512
|
}
|
|
3505
|
-
function
|
|
3506
|
-
return
|
|
3513
|
+
function qi(o) {
|
|
3514
|
+
return o.type === "image";
|
|
3507
3515
|
}
|
|
3508
|
-
function
|
|
3509
|
-
return
|
|
3516
|
+
function ji(o) {
|
|
3517
|
+
return o.type === "group";
|
|
3510
3518
|
}
|
|
3511
|
-
function
|
|
3512
|
-
return
|
|
3519
|
+
function Zi(o) {
|
|
3520
|
+
return o.transformType !== "image" && o.transformType !== "group";
|
|
3513
3521
|
}
|
|
3514
|
-
function
|
|
3515
|
-
return
|
|
3522
|
+
function Ki(o) {
|
|
3523
|
+
return o.transformType === "image";
|
|
3516
3524
|
}
|
|
3517
|
-
function
|
|
3518
|
-
return
|
|
3525
|
+
function Qi(o) {
|
|
3526
|
+
return o.transformType === "custom";
|
|
3519
3527
|
}
|
|
3520
|
-
function
|
|
3521
|
-
return
|
|
3528
|
+
function ts(o) {
|
|
3529
|
+
return o.transformType === "circle";
|
|
3522
3530
|
}
|
|
3523
|
-
function
|
|
3524
|
-
return
|
|
3531
|
+
function es(o) {
|
|
3532
|
+
return o.transformType === "group";
|
|
3525
3533
|
}
|
|
3526
|
-
function
|
|
3527
|
-
return
|
|
3534
|
+
function is(o) {
|
|
3535
|
+
return o.transformType === "shape";
|
|
3528
3536
|
}
|
|
3529
|
-
function
|
|
3530
|
-
return
|
|
3537
|
+
function ss(o) {
|
|
3538
|
+
return o.transformType === "path";
|
|
3531
3539
|
}
|
|
3532
|
-
function
|
|
3533
|
-
return
|
|
3540
|
+
function os(o) {
|
|
3541
|
+
return o.type === "shape";
|
|
3534
3542
|
}
|
|
3535
|
-
function
|
|
3536
|
-
return
|
|
3543
|
+
function rs(o) {
|
|
3544
|
+
return o.type === "path";
|
|
3537
3545
|
}
|
|
3538
|
-
function
|
|
3546
|
+
function ns(o) {
|
|
3539
3547
|
var t;
|
|
3540
|
-
return ((t =
|
|
3548
|
+
return ((t = o.stroke) == null ? void 0 : t.enabled) === !0;
|
|
3549
|
+
}
|
|
3550
|
+
function as(o) {
|
|
3551
|
+
return Array.isArray(o.masks) && o.masks.length > 0;
|
|
3541
3552
|
}
|
|
3542
|
-
function
|
|
3543
|
-
return
|
|
3553
|
+
function hs(o) {
|
|
3554
|
+
return o.blendMode === "knockout" || o.blendMode === "clip";
|
|
3544
3555
|
}
|
|
3545
|
-
function
|
|
3546
|
-
return
|
|
3556
|
+
function ls(o) {
|
|
3557
|
+
return We.includes(o);
|
|
3547
3558
|
}
|
|
3548
|
-
function
|
|
3559
|
+
function cs(o) {
|
|
3549
3560
|
var t;
|
|
3550
|
-
return ((t =
|
|
3561
|
+
return ((t = o.distressEffect) == null ? void 0 : t.enabled) === !0;
|
|
3551
3562
|
}
|
|
3552
|
-
class
|
|
3563
|
+
class j extends tt {
|
|
3553
3564
|
constructor(t = {}) {
|
|
3554
3565
|
super(t), this.transformType = t.transformType || "custom", this.fontSize = t.fontSize || 72, this.fontFamily = t.fontFamily || "Arial", this.color = t.color || "#333333", this.bold = t.bold !== void 0 ? t.bold : !1, this.italic = t.italic !== void 0 ? t.italic : !1, this.underline = t.underline !== void 0 ? t.underline : !1, this.strikethrough = t.strikethrough !== void 0 ? t.strikethrough : !1, this.textAlign = t.textAlign || "center", this.letterSpacing = t.letterSpacing, this.lineHeight = t.lineHeight, t.richText ? (t.richText instanceof L ? this.richText = t.richText : this.richText = L.fromJSON(t.richText), this.text = this.richText.getText()) : t.text !== void 0 ? (this.text = t.text, this.richText = L.fromPlainText(t.text, {})) : (this.text = "Text", this.richText = L.fromPlainText("Text", {})), this.glyphOverrides = t.glyphOverrides, this.openTypeFeatures = t.openTypeFeatures;
|
|
3555
3566
|
}
|
|
@@ -3571,7 +3582,7 @@ class q extends Q {
|
|
|
3571
3582
|
*/
|
|
3572
3583
|
render(t, e = !1, i = !1) {
|
|
3573
3584
|
const s = t.globalAlpha;
|
|
3574
|
-
this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity),
|
|
3585
|
+
this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), ut(this.transformType)(t, this.toJSON()), t.globalAlpha = s;
|
|
3575
3586
|
}
|
|
3576
3587
|
/**
|
|
3577
3588
|
* Serialize to JSON
|
|
@@ -3657,7 +3668,7 @@ class q extends Q {
|
|
|
3657
3668
|
* Update font size
|
|
3658
3669
|
*/
|
|
3659
3670
|
setFontSize(t) {
|
|
3660
|
-
this.fontSize = Math.max(
|
|
3671
|
+
this.fontSize = Math.max(Fe, Math.min(Ae, t));
|
|
3661
3672
|
}
|
|
3662
3673
|
/**
|
|
3663
3674
|
* Update color
|
|
@@ -3691,21 +3702,21 @@ class q extends Q {
|
|
|
3691
3702
|
};
|
|
3692
3703
|
}
|
|
3693
3704
|
}
|
|
3694
|
-
function
|
|
3695
|
-
return Array.from(
|
|
3705
|
+
function Ne(o) {
|
|
3706
|
+
return Array.from(o).length;
|
|
3696
3707
|
}
|
|
3697
|
-
function
|
|
3698
|
-
return e ?
|
|
3708
|
+
function xt(o, t, e) {
|
|
3709
|
+
return e ? o + e * Ne(t) : o;
|
|
3699
3710
|
}
|
|
3700
|
-
function
|
|
3711
|
+
function _e(o, t, e) {
|
|
3701
3712
|
const i = Array.from(t), s = [0];
|
|
3702
|
-
let
|
|
3703
|
-
for (let
|
|
3704
|
-
|
|
3713
|
+
let r = "";
|
|
3714
|
+
for (let h = 0; h < i.length; h++)
|
|
3715
|
+
r += i[h], s.push(o.measureText(r).width + e * (h + 1));
|
|
3705
3716
|
return s;
|
|
3706
3717
|
}
|
|
3707
|
-
function
|
|
3708
|
-
switch (
|
|
3718
|
+
function ze(o, t, e) {
|
|
3719
|
+
switch (o.textAlign) {
|
|
3709
3720
|
case "center":
|
|
3710
3721
|
return t - e / 2;
|
|
3711
3722
|
case "right":
|
|
@@ -3715,60 +3726,60 @@ function Re(r, t, e) {
|
|
|
3715
3726
|
return t;
|
|
3716
3727
|
}
|
|
3717
3728
|
}
|
|
3718
|
-
function
|
|
3719
|
-
if (!
|
|
3720
|
-
t[
|
|
3729
|
+
function Qt(o, t, e, i, s, r) {
|
|
3730
|
+
if (!r || e.length === 0) {
|
|
3731
|
+
t[o](e, i, s);
|
|
3721
3732
|
return;
|
|
3722
3733
|
}
|
|
3723
|
-
const
|
|
3734
|
+
const h = _e(t, e, r), n = h[h.length - 1], a = ze(t, i, n), l = t.textAlign;
|
|
3724
3735
|
t.textAlign = "left";
|
|
3725
3736
|
const c = Array.from(e);
|
|
3726
3737
|
for (let g = 0; g < c.length; g++)
|
|
3727
|
-
t[
|
|
3738
|
+
t[o](c[g], a + h[g], s);
|
|
3728
3739
|
t.textAlign = l;
|
|
3729
3740
|
}
|
|
3730
|
-
function
|
|
3731
|
-
|
|
3741
|
+
function ds(o, t, e, i, s) {
|
|
3742
|
+
Qt("fillText", o, t, e, i, s);
|
|
3732
3743
|
}
|
|
3733
|
-
function
|
|
3734
|
-
|
|
3744
|
+
function gs(o, t, e, i, s) {
|
|
3745
|
+
Qt("strokeText", o, t, e, i, s);
|
|
3735
3746
|
}
|
|
3736
|
-
let
|
|
3737
|
-
function
|
|
3738
|
-
if (!
|
|
3747
|
+
let lt = null;
|
|
3748
|
+
function St() {
|
|
3749
|
+
if (!lt)
|
|
3739
3750
|
if (typeof document < "u")
|
|
3740
|
-
|
|
3751
|
+
lt = document.createElement("canvas");
|
|
3741
3752
|
else if (typeof OffscreenCanvas < "u")
|
|
3742
|
-
|
|
3753
|
+
lt = new OffscreenCanvas(1, 1);
|
|
3743
3754
|
else
|
|
3744
3755
|
throw new Error("No canvas available for text measurement");
|
|
3745
|
-
return
|
|
3756
|
+
return lt;
|
|
3746
3757
|
}
|
|
3747
|
-
function
|
|
3758
|
+
function ht(o, t, e = !1, i = !1) {
|
|
3748
3759
|
const s = [];
|
|
3749
|
-
return i && s.push("italic"), e && s.push("bold"), s.push(`${
|
|
3750
|
-
}
|
|
3751
|
-
function
|
|
3752
|
-
const c =
|
|
3753
|
-
c.font =
|
|
3754
|
-
const g = (
|
|
3755
|
-
if (
|
|
3756
|
-
return [
|
|
3757
|
-
if (
|
|
3760
|
+
return i && s.push("italic"), e && s.push("bold"), s.push(`${o}px`), s.push(t), s.join(" ");
|
|
3761
|
+
}
|
|
3762
|
+
function Et(o, t, e, i, s = !1, r = !1, h, n = !1, a) {
|
|
3763
|
+
const c = St().getContext("2d");
|
|
3764
|
+
c.font = ht(e, i, s, r);
|
|
3765
|
+
const g = (a == null ? void 0 : a.letterSpacing) ?? 0, d = (A) => xt(c.measureText(A).width, A, g);
|
|
3766
|
+
if (o.trim().length === 0)
|
|
3767
|
+
return [o];
|
|
3768
|
+
if (o.includes(`
|
|
3758
3769
|
`)) {
|
|
3759
|
-
const A =
|
|
3770
|
+
const A = o.split(`
|
|
3760
3771
|
`), k = [];
|
|
3761
3772
|
for (let R = 0; R < A.length; R++) {
|
|
3762
|
-
const H = A[R], E =
|
|
3773
|
+
const H = A[R], E = Et(H, t, e, i, s, r, void 0, n, a);
|
|
3763
3774
|
k.push(...E);
|
|
3764
3775
|
}
|
|
3765
3776
|
return k;
|
|
3766
3777
|
}
|
|
3767
|
-
const f =
|
|
3768
|
-
if (
|
|
3769
|
-
if (
|
|
3778
|
+
const f = o.match(/^\s*/), u = o.match(/\s*$/), m = f ? f[0] : "", p = u ? u[0] : "", w = o.substring(m.length, o.length - p.length).split(" ");
|
|
3779
|
+
if (h !== void 0 && h > 0) {
|
|
3780
|
+
if (h === 1)
|
|
3770
3781
|
return [m + w.join(" ") + p];
|
|
3771
|
-
const A = [], k = Math.ceil(w.length /
|
|
3782
|
+
const A = [], k = Math.ceil(w.length / h);
|
|
3772
3783
|
for (let R = 0; R < w.length; R += k) {
|
|
3773
3784
|
const H = w.slice(R, R + k);
|
|
3774
3785
|
A.push(H.join(" "));
|
|
@@ -3788,8 +3799,8 @@ function It(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
|
3788
3799
|
const H = Array.from(k);
|
|
3789
3800
|
let E = "";
|
|
3790
3801
|
for (const W of H) {
|
|
3791
|
-
const
|
|
3792
|
-
d(
|
|
3802
|
+
const N = E + W;
|
|
3803
|
+
d(N) > t + B && E.length > 0 ? (T.push(E), E = W) : E = N;
|
|
3793
3804
|
}
|
|
3794
3805
|
D = E;
|
|
3795
3806
|
} else {
|
|
@@ -3809,25 +3820,25 @@ function It(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
|
3809
3820
|
}
|
|
3810
3821
|
return T;
|
|
3811
3822
|
}
|
|
3812
|
-
function
|
|
3813
|
-
const n =
|
|
3814
|
-
return n.font =
|
|
3823
|
+
function Wt(o, t, e, i = !1, s = !1, r = 0) {
|
|
3824
|
+
const n = St().getContext("2d");
|
|
3825
|
+
return n.font = ht(t, e, i, s), xt(n.measureText(o).width, o, r);
|
|
3815
3826
|
}
|
|
3816
|
-
function
|
|
3817
|
-
const
|
|
3818
|
-
|
|
3819
|
-
const n =
|
|
3820
|
-
return { ascent:
|
|
3827
|
+
function It(o, t, e = !1, i = !1) {
|
|
3828
|
+
const r = St().getContext("2d");
|
|
3829
|
+
r.font = ht(o, t, e, i);
|
|
3830
|
+
const n = r.measureText("ÁÉÍgjpqy"), a = n.actualBoundingBoxAscent || o * 0.8, l = n.actualBoundingBoxDescent || o * 0.2, c = a + l;
|
|
3831
|
+
return { ascent: a, descent: l, height: c };
|
|
3821
3832
|
}
|
|
3822
|
-
function
|
|
3823
|
-
const l = (
|
|
3833
|
+
function Nt(o, t, e, i, s = !1, r = !1, h, n = !1, a) {
|
|
3834
|
+
const l = (a == null ? void 0 : a.letterSpacing) ?? 0, c = Et(o, t, e, i, s, r, h, n, a), g = o.includes(`
|
|
3824
3835
|
`), d = c.map((b, v) => ({
|
|
3825
3836
|
isParagraphStart: !g && v === 0,
|
|
3826
3837
|
isParagraphEnd: !g && v === c.length - 1
|
|
3827
|
-
})), u =
|
|
3828
|
-
u.font =
|
|
3838
|
+
})), u = St().getContext("2d");
|
|
3839
|
+
u.font = ht(e, i, s, r);
|
|
3829
3840
|
let m = 0;
|
|
3830
|
-
const p =
|
|
3841
|
+
const p = It(e, i, s, r);
|
|
3831
3842
|
let y = 0;
|
|
3832
3843
|
c.forEach((b, v) => {
|
|
3833
3844
|
const C = d[v].isParagraphStart, M = d[v].isParagraphEnd;
|
|
@@ -3841,12 +3852,12 @@ function Lt(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
|
3841
3852
|
D > 0 && (F = F.substring(0, F.length - D));
|
|
3842
3853
|
}
|
|
3843
3854
|
if (y++, F.length > 0) {
|
|
3844
|
-
const T =
|
|
3855
|
+
const T = xt(u.measureText(F).width, F, l);
|
|
3845
3856
|
m = Math.max(m, T);
|
|
3846
3857
|
}
|
|
3847
3858
|
});
|
|
3848
3859
|
let w;
|
|
3849
|
-
const S = (
|
|
3860
|
+
const S = (a == null ? void 0 : a.lineHeight) ?? qt;
|
|
3850
3861
|
if (y === 1)
|
|
3851
3862
|
w = p.height;
|
|
3852
3863
|
else if (y === 0)
|
|
@@ -3861,38 +3872,38 @@ function Lt(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
|
|
|
3861
3872
|
lines: c
|
|
3862
3873
|
};
|
|
3863
3874
|
}
|
|
3864
|
-
let
|
|
3865
|
-
function
|
|
3866
|
-
if (!
|
|
3875
|
+
let ct = null;
|
|
3876
|
+
function Xe() {
|
|
3877
|
+
if (!ct)
|
|
3867
3878
|
if (typeof OffscreenCanvas < "u")
|
|
3868
|
-
|
|
3879
|
+
ct = new OffscreenCanvas(1, 1).getContext("2d");
|
|
3869
3880
|
else if (typeof document < "u")
|
|
3870
|
-
|
|
3881
|
+
ct = document.createElement("canvas").getContext("2d");
|
|
3871
3882
|
else
|
|
3872
3883
|
throw new Error("No canvas context available");
|
|
3873
|
-
return
|
|
3884
|
+
return ct;
|
|
3874
3885
|
}
|
|
3875
|
-
function
|
|
3876
|
-
const i =
|
|
3886
|
+
function Ye(o, t, e) {
|
|
3887
|
+
const i = Xe(), s = [], r = (p, y) => {
|
|
3877
3888
|
const w = y.fontSize || e.fontSize, S = y.fontFamily || e.fontFamily, b = y.bold !== void 0 ? y.bold : e.bold || !1, v = y.italic !== void 0 ? y.italic : e.italic || !1, C = y.letterSpacing !== void 0 ? y.letterSpacing : e.letterSpacing ?? 0;
|
|
3878
|
-
return i.font =
|
|
3879
|
-
},
|
|
3880
|
-
|
|
3881
|
-
n.length > 0 &&
|
|
3889
|
+
return i.font = ht(w, S, b, v), xt(i.measureText(p).width, p, C);
|
|
3890
|
+
}, h = (p, y) => p.fontSize === y.fontSize && p.fontFamily === y.fontFamily && p.color === y.color && p.bold === y.bold && p.italic === y.italic && p.underline === y.underline && p.strikethrough === y.strikethrough && p.letterSpacing === y.letterSpacing, n = [];
|
|
3891
|
+
o.forEach((p) => {
|
|
3892
|
+
n.length > 0 && h(n[n.length - 1].style, p.style) ? n[n.length - 1].text += p.text : n.push({ text: p.text, style: p.style });
|
|
3882
3893
|
});
|
|
3883
|
-
let
|
|
3894
|
+
let a = "";
|
|
3884
3895
|
const l = [];
|
|
3885
3896
|
n.forEach((p, y) => {
|
|
3886
3897
|
for (let w = 0; w < p.text.length; w++)
|
|
3887
|
-
|
|
3898
|
+
a += p.text[w], l.push(y);
|
|
3888
3899
|
});
|
|
3889
3900
|
const c = [];
|
|
3890
3901
|
let g = "", d = 0;
|
|
3891
|
-
for (let p = 0; p <
|
|
3892
|
-
const y =
|
|
3902
|
+
for (let p = 0; p < a.length; p++) {
|
|
3903
|
+
const y = a[p];
|
|
3893
3904
|
y === " " ? (g.length > 0 && (c.push({ text: g, startIdx: d, endIdx: p - 1 }), g = ""), c.push({ text: " ", startIdx: p, endIdx: p })) : (g.length === 0 && (d = p), g += y);
|
|
3894
3905
|
}
|
|
3895
|
-
g.length > 0 && c.push({ text: g, startIdx: d, endIdx:
|
|
3906
|
+
g.length > 0 && c.push({ text: g, startIdx: d, endIdx: a.length - 1 });
|
|
3896
3907
|
let f = [], u = 0;
|
|
3897
3908
|
const m = () => {
|
|
3898
3909
|
f.length > 0 && (s.push(f), f = [], u = 0);
|
|
@@ -3902,14 +3913,14 @@ function Pe(r, t, e) {
|
|
|
3902
3913
|
let S = l[p.startIdx], b = "";
|
|
3903
3914
|
for (let C = p.startIdx; C <= p.endIdx; C++) {
|
|
3904
3915
|
const M = l[C];
|
|
3905
|
-
M !== S ? (w.push({ text: b, style: n[S].style }), b =
|
|
3916
|
+
M !== S ? (w.push({ text: b, style: n[S].style }), b = a[C], S = M) : b += a[C];
|
|
3906
3917
|
}
|
|
3907
3918
|
b.length > 0 && w.push({ text: b, style: n[S].style });
|
|
3908
|
-
const v = w.reduce((C, M) => C +
|
|
3919
|
+
const v = w.reduce((C, M) => C + r(M.text, M.style), 0);
|
|
3909
3920
|
if (p.text === " ") {
|
|
3910
3921
|
if (f.length > 0) {
|
|
3911
3922
|
const C = f[f.length - 1];
|
|
3912
|
-
|
|
3923
|
+
h(C.style, w[0].style) ? C.text += " " : f.push({ text: " ", style: w[0].style });
|
|
3913
3924
|
} else
|
|
3914
3925
|
f.push({ text: " ", style: w[0].style });
|
|
3915
3926
|
u += v;
|
|
@@ -3919,12 +3930,12 @@ function Pe(r, t, e) {
|
|
|
3919
3930
|
const M = Array.from(C.text);
|
|
3920
3931
|
let F = "";
|
|
3921
3932
|
for (const T of M) {
|
|
3922
|
-
const D =
|
|
3933
|
+
const D = r(T, C.style);
|
|
3923
3934
|
if (u + D > t && u > 0) {
|
|
3924
3935
|
if (F.length > 0) {
|
|
3925
3936
|
if (f.length > 0) {
|
|
3926
3937
|
const U = f[f.length - 1];
|
|
3927
|
-
|
|
3938
|
+
h(U.style, C.style) ? U.text += F : f.push({ text: F, style: C.style });
|
|
3928
3939
|
} else
|
|
3929
3940
|
f.push({ text: F, style: C.style });
|
|
3930
3941
|
F = "";
|
|
@@ -3936,7 +3947,7 @@ function Pe(r, t, e) {
|
|
|
3936
3947
|
if (F.length > 0)
|
|
3937
3948
|
if (f.length > 0) {
|
|
3938
3949
|
const T = f[f.length - 1];
|
|
3939
|
-
|
|
3950
|
+
h(T.style, C.style) ? T.text += F : f.push({ text: F, style: C.style });
|
|
3940
3951
|
} else
|
|
3941
3952
|
f.push({ text: F, style: C.style });
|
|
3942
3953
|
}
|
|
@@ -3944,69 +3955,69 @@ function Pe(r, t, e) {
|
|
|
3944
3955
|
u + v > t && f.length > 0 && m(), w.forEach((C) => {
|
|
3945
3956
|
if (f.length > 0) {
|
|
3946
3957
|
const M = f[f.length - 1];
|
|
3947
|
-
|
|
3958
|
+
h(M.style, C.style) ? M.text += C.text : f.push({ ...C });
|
|
3948
3959
|
} else
|
|
3949
3960
|
f.push({ ...C });
|
|
3950
3961
|
}), u += v;
|
|
3951
3962
|
}), m(), s.length === 0 && s.push([]), s;
|
|
3952
3963
|
}
|
|
3953
|
-
function
|
|
3964
|
+
function Ue(o) {
|
|
3954
3965
|
const t = [];
|
|
3955
3966
|
let e = [];
|
|
3956
|
-
return
|
|
3967
|
+
return o.spans.forEach((i) => {
|
|
3957
3968
|
const s = i.text.split(`
|
|
3958
3969
|
`);
|
|
3959
|
-
s.forEach((
|
|
3960
|
-
|
|
3970
|
+
s.forEach((r, h) => {
|
|
3971
|
+
r.length > 0 && e.push({ text: r, style: i.style }), h < s.length - 1 && (t.push(e), e = []);
|
|
3961
3972
|
});
|
|
3962
3973
|
}), e.length > 0 && t.push(e), t.length === 0 && t.push([]), t;
|
|
3963
3974
|
}
|
|
3964
|
-
function
|
|
3965
|
-
return typeof
|
|
3975
|
+
function ot(o) {
|
|
3976
|
+
return typeof o.width == "number" ? o.width : void 0;
|
|
3966
3977
|
}
|
|
3967
|
-
function
|
|
3968
|
-
|
|
3978
|
+
function te(o, t) {
|
|
3979
|
+
o.width = t;
|
|
3969
3980
|
}
|
|
3970
|
-
function
|
|
3971
|
-
const i = e.transformData, s =
|
|
3981
|
+
function Ge(o, t, e) {
|
|
3982
|
+
const i = e.transformData, s = ot(i), r = s !== void 0 ? s : e.width ?? 0, h = t / r, n = e.fontSize ?? o.fontSize, a = n * h;
|
|
3972
3983
|
let l;
|
|
3973
|
-
if (
|
|
3984
|
+
if (a < 16 ? l = Math.round(a) : l = Math.round(a * 2) / 2, o.setFontSize(l), e.richText && e.richText instanceof L && typeof o.setRichText == "function") {
|
|
3974
3985
|
const f = e.richText.clone();
|
|
3975
3986
|
for (const u of f.spans)
|
|
3976
3987
|
if (u.style.fontSize !== void 0) {
|
|
3977
|
-
const m = u.style.fontSize *
|
|
3988
|
+
const m = u.style.fontSize * h;
|
|
3978
3989
|
m < 16 ? u.style.fontSize = Math.round(m) : u.style.fontSize = Math.round(m * 2) / 2;
|
|
3979
3990
|
}
|
|
3980
|
-
|
|
3991
|
+
o.setRichText(f);
|
|
3981
3992
|
}
|
|
3982
|
-
const c =
|
|
3983
|
-
if (
|
|
3984
|
-
const d = n > 0 ? l / n :
|
|
3985
|
-
|
|
3993
|
+
const c = o.transformData;
|
|
3994
|
+
if (ot(c) !== void 0 && s !== void 0) {
|
|
3995
|
+
const d = n > 0 ? l / n : h, f = s * d;
|
|
3996
|
+
te(c, Math.max(20, Math.ceil(f)));
|
|
3986
3997
|
}
|
|
3987
3998
|
}
|
|
3988
|
-
function
|
|
3999
|
+
function $e(o, t, e, i) {
|
|
3989
4000
|
if (t !== "middle-left" && t !== "middle-right")
|
|
3990
4001
|
return;
|
|
3991
|
-
|
|
3992
|
-
const s =
|
|
3993
|
-
if (
|
|
3994
|
-
|
|
3995
|
-
const
|
|
3996
|
-
t === "middle-left" ? (
|
|
4002
|
+
o.fontSize = i.fontSize ?? o.fontSize;
|
|
4003
|
+
const s = o.transformData;
|
|
4004
|
+
if (ot(s) !== void 0) {
|
|
4005
|
+
te(s, Math.max(jt, e));
|
|
4006
|
+
const h = I.toRadiansInverse(o.rotation), n = Math.cos(h), a = Math.sin(h), l = i.transformData, g = ot(l) ?? i.width ?? 0, f = (ot(s) ?? 0) - g;
|
|
4007
|
+
t === "middle-left" ? (o.x = i.x - f / 2 * n, o.y = i.y - f / 2 * a) : t === "middle-right" && (o.x = i.x + f / 2 * n, o.y = i.y + f / 2 * a);
|
|
3997
4008
|
}
|
|
3998
4009
|
}
|
|
3999
|
-
function
|
|
4000
|
-
const
|
|
4001
|
-
|
|
4010
|
+
function ee(o, t, e, i, s) {
|
|
4011
|
+
const r = t.includes("top") || t.includes("bottom"), h = t.includes("middle");
|
|
4012
|
+
r ? Ge(o, e, s) : h && $e(o, t, e, s);
|
|
4002
4013
|
}
|
|
4003
|
-
class
|
|
4014
|
+
class Ve extends j {
|
|
4004
4015
|
// Temporary property used during resize operations only
|
|
4005
4016
|
constructor(t = {}) {
|
|
4006
4017
|
super(t), this.transformType = "custom";
|
|
4007
4018
|
const e = t.transformData, i = (e == null ? void 0 : e.width) !== void 0 ? e.width : Math.max(
|
|
4008
|
-
|
|
4009
|
-
|
|
4019
|
+
jt,
|
|
4020
|
+
Wt(this.text, this.fontSize, this.fontFamily, this.bold, this.italic, this.letterSpacing ?? 0) + Z * 2
|
|
4010
4021
|
);
|
|
4011
4022
|
this.transformData = {
|
|
4012
4023
|
type: "custom",
|
|
@@ -4019,9 +4030,9 @@ class Xe extends q {
|
|
|
4019
4030
|
* Returns the total height based on the tallest font in each line
|
|
4020
4031
|
*/
|
|
4021
4032
|
calculateRichTextHeight() {
|
|
4022
|
-
const t = this.getRichText(), e = this.transformData.width -
|
|
4023
|
-
if (i.forEach((
|
|
4024
|
-
|
|
4033
|
+
const t = this.getRichText(), e = this.transformData.width - Z * 2, i = Ue(t), s = [];
|
|
4034
|
+
if (i.forEach((a) => {
|
|
4035
|
+
Ye(a, e, {
|
|
4025
4036
|
fontSize: this.fontSize,
|
|
4026
4037
|
fontFamily: this.fontFamily,
|
|
4027
4038
|
bold: this.bold,
|
|
@@ -4032,18 +4043,18 @@ class Xe extends q {
|
|
|
4032
4043
|
});
|
|
4033
4044
|
}), s.length === 0)
|
|
4034
4045
|
return 0;
|
|
4035
|
-
let
|
|
4036
|
-
s.forEach((
|
|
4037
|
-
|
|
4038
|
-
const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u =
|
|
4039
|
-
|
|
4046
|
+
let r = 0, h = 0;
|
|
4047
|
+
s.forEach((a) => {
|
|
4048
|
+
a.forEach((l) => {
|
|
4049
|
+
const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u = It(c, g, d, f);
|
|
4050
|
+
r = Math.max(r, u.height), h = Math.max(h, u.ascent);
|
|
4040
4051
|
});
|
|
4041
4052
|
});
|
|
4042
|
-
const n = this.fontSize * (this.lineHeight ??
|
|
4053
|
+
const n = this.fontSize * (this.lineHeight ?? qt);
|
|
4043
4054
|
if (s.length === 1)
|
|
4044
|
-
return
|
|
4055
|
+
return r;
|
|
4045
4056
|
{
|
|
4046
|
-
const
|
|
4057
|
+
const a = It(this.fontSize, this.fontFamily, this.bold, this.italic), l = (s.length - 1) * n + a.height, c = Math.max(0, h - a.ascent), g = Math.max(0, r - h - (a.height - a.ascent));
|
|
4047
4058
|
return l + c + g;
|
|
4048
4059
|
}
|
|
4049
4060
|
}
|
|
@@ -4063,9 +4074,9 @@ class Xe extends q {
|
|
|
4063
4074
|
* This should match the actual text bounds including wrapping
|
|
4064
4075
|
*/
|
|
4065
4076
|
getBoundingBox() {
|
|
4066
|
-
const t = this.transformData.width -
|
|
4077
|
+
const t = this.transformData.width - Z * 2;
|
|
4067
4078
|
let e;
|
|
4068
|
-
return this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e =
|
|
4079
|
+
return this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e = Nt(
|
|
4069
4080
|
this.text,
|
|
4070
4081
|
t,
|
|
4071
4082
|
this.fontSize,
|
|
@@ -4090,9 +4101,9 @@ class Xe extends q {
|
|
|
4090
4101
|
* (x, y) is the center of the element
|
|
4091
4102
|
*/
|
|
4092
4103
|
getVisualBoundingBox() {
|
|
4093
|
-
const t = this.transformData.width -
|
|
4104
|
+
const t = this.transformData.width - Z * 2;
|
|
4094
4105
|
let e;
|
|
4095
|
-
this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e =
|
|
4106
|
+
this.hasPerCharacterFormatting() ? e = this.calculateRichTextHeight() : e = Nt(
|
|
4096
4107
|
this.text,
|
|
4097
4108
|
t,
|
|
4098
4109
|
this.fontSize,
|
|
@@ -4130,13 +4141,13 @@ class Xe extends q {
|
|
|
4130
4141
|
*/
|
|
4131
4142
|
render(t, e = !1, i = !1) {
|
|
4132
4143
|
var n;
|
|
4133
|
-
const s = this.opacity ?? 1,
|
|
4134
|
-
if (s < 1 &&
|
|
4144
|
+
const s = this.opacity ?? 1, r = !!((n = this.stroke) != null && n.enabled);
|
|
4145
|
+
if (s < 1 && r) {
|
|
4135
4146
|
this.renderWithOffscreen(t, s);
|
|
4136
4147
|
return;
|
|
4137
4148
|
}
|
|
4138
|
-
const
|
|
4139
|
-
s !== 1 && (t.globalAlpha = s),
|
|
4149
|
+
const h = t.globalAlpha;
|
|
4150
|
+
s !== 1 && (t.globalAlpha = s), ut("custom")(t, this.toJSON()), t.globalAlpha = h;
|
|
4140
4151
|
}
|
|
4141
4152
|
/**
|
|
4142
4153
|
* Render stroke+fill to an offscreen canvas at full opacity, then composite
|
|
@@ -4144,22 +4155,22 @@ class Xe extends q {
|
|
|
4144
4155
|
*/
|
|
4145
4156
|
renderWithOffscreen(t, e) {
|
|
4146
4157
|
var d;
|
|
4147
|
-
const s = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20,
|
|
4148
|
-
|
|
4149
|
-
const l =
|
|
4158
|
+
const s = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20, r = this.getVisualBoundingBox(), h = Math.ceil(r.width + s * 2), n = Math.ceil(r.height + s * 2), a = document.createElement("canvas");
|
|
4159
|
+
a.width = h, a.height = n;
|
|
4160
|
+
const l = a.getContext("2d");
|
|
4150
4161
|
if (!l) {
|
|
4151
4162
|
const f = t.globalAlpha;
|
|
4152
|
-
t.globalAlpha = e,
|
|
4163
|
+
t.globalAlpha = e, ut("custom")(t, this.toJSON()), t.globalAlpha = f;
|
|
4153
4164
|
return;
|
|
4154
4165
|
}
|
|
4155
|
-
const c =
|
|
4156
|
-
l.translate(
|
|
4166
|
+
const c = r.x + r.width / 2, g = r.y + r.height / 2;
|
|
4167
|
+
l.translate(h / 2 - c, n / 2 - g), ut("custom")(l, this.toJSON()), t.save(), t.globalAlpha = e, t.drawImage(a, c - h / 2, g - n / 2), t.restore();
|
|
4157
4168
|
}
|
|
4158
4169
|
/**
|
|
4159
4170
|
* Override getTransformStartData to capture initial line count
|
|
4160
4171
|
*/
|
|
4161
4172
|
getTransformStartData() {
|
|
4162
|
-
const t = super.getTransformStartData(), e = this.transformData.width -
|
|
4173
|
+
const t = super.getTransformStartData(), e = this.transformData.width - Z * 2, i = Et(this.text, e, this.fontSize, this.fontFamily, this.bold, this.italic, void 0, !1, {
|
|
4163
4174
|
letterSpacing: this.letterSpacing
|
|
4164
4175
|
});
|
|
4165
4176
|
return t.lineCount = i.length, t;
|
|
@@ -4170,15 +4181,15 @@ class Xe extends q {
|
|
|
4170
4181
|
* Side handles: only width changes - text re-wraps naturally
|
|
4171
4182
|
*/
|
|
4172
4183
|
resize(t, e, i, s) {
|
|
4173
|
-
if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0),
|
|
4174
|
-
const n =
|
|
4184
|
+
if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0), ee(this, t, e, i, s), this._lockedLineCount !== void 0 && this._lockedLineCount > 0) {
|
|
4185
|
+
const n = Wt(
|
|
4175
4186
|
this.text,
|
|
4176
4187
|
this.fontSize,
|
|
4177
4188
|
this.fontFamily,
|
|
4178
4189
|
this.bold,
|
|
4179
4190
|
this.italic,
|
|
4180
4191
|
this.letterSpacing ?? 0
|
|
4181
|
-
) / this._lockedLineCount +
|
|
4192
|
+
) / this._lockedLineCount + Z * 2;
|
|
4182
4193
|
this.transformData.width < n && (this.transformData.width = Math.ceil(n));
|
|
4183
4194
|
}
|
|
4184
4195
|
}
|
|
@@ -4223,32 +4234,32 @@ class Xe extends q {
|
|
|
4223
4234
|
};
|
|
4224
4235
|
}
|
|
4225
4236
|
}
|
|
4226
|
-
function
|
|
4227
|
-
const s = I.toRadians(i),
|
|
4228
|
-
let n = 0,
|
|
4229
|
-
e === "top-left" ? (n =
|
|
4230
|
-
const l =
|
|
4237
|
+
function Je(o, t, e, i) {
|
|
4238
|
+
const s = I.toRadians(i), r = Math.cos(s), h = Math.sin(s);
|
|
4239
|
+
let n = 0, a = 0;
|
|
4240
|
+
e === "top-left" ? (n = o.width, a = o.height) : e === "top-right" ? (n = 0, a = o.height) : e === "bottom-left" ? (n = o.width, a = 0) : e === "bottom-right" && (n = 0, a = 0);
|
|
4241
|
+
const l = o.x + (n * r - a * h), c = o.y + (n * h + a * r);
|
|
4231
4242
|
let g = 0, d = 0;
|
|
4232
4243
|
e === "top-left" ? (g = t.width, d = t.height) : e === "top-right" ? (g = 0, d = t.height) : e === "bottom-left" ? (g = t.width, d = 0) : e === "bottom-right" && (g = 0, d = 0);
|
|
4233
|
-
const f = l - (g *
|
|
4244
|
+
const f = l - (g * r - d * h), u = c - (g * h + d * r);
|
|
4234
4245
|
return { x: f, y: u };
|
|
4235
4246
|
}
|
|
4236
|
-
function
|
|
4237
|
-
const s =
|
|
4247
|
+
function fs(o, t, e, i = 1) {
|
|
4248
|
+
const s = o.width / 2, r = o.height + Se / i, h = o.x + s, n = o.y + r, a = I.toRadians(t), l = Math.cos(a), c = Math.sin(a), g = h - e.x, d = n - e.y, f = g * l - d * c, u = g * c + d * l;
|
|
4238
4249
|
return {
|
|
4239
4250
|
x: e.x + f,
|
|
4240
4251
|
y: e.y + u
|
|
4241
4252
|
};
|
|
4242
4253
|
}
|
|
4243
|
-
function
|
|
4244
|
-
const i = I.toRadians(t), s = Math.cos(i),
|
|
4245
|
-
const d =
|
|
4254
|
+
function us(o, t, e) {
|
|
4255
|
+
const i = I.toRadians(t), s = Math.cos(i), r = Math.sin(i), h = (c, g) => {
|
|
4256
|
+
const d = o.x + c, f = o.y + g, u = d - e.x, m = f - e.y, p = u * s - m * r, y = u * r + m * s;
|
|
4246
4257
|
return {
|
|
4247
4258
|
x: e.x + p,
|
|
4248
4259
|
y: e.y + y
|
|
4249
4260
|
};
|
|
4250
|
-
}, { width: n, height:
|
|
4251
|
-
const u =
|
|
4261
|
+
}, { width: n, height: a } = o, l = (c, g, d, f) => {
|
|
4262
|
+
const u = h(d, f), m = qe(
|
|
4252
4263
|
u.x,
|
|
4253
4264
|
u.y,
|
|
4254
4265
|
e.x,
|
|
@@ -4268,47 +4279,47 @@ function os(r, t, e) {
|
|
|
4268
4279
|
// Corner handles
|
|
4269
4280
|
l("corner", "top-left", 0, 0),
|
|
4270
4281
|
l("corner", "top-right", n, 0),
|
|
4271
|
-
l("corner", "bottom-left", 0,
|
|
4272
|
-
l("corner", "bottom-right", n,
|
|
4282
|
+
l("corner", "bottom-left", 0, a),
|
|
4283
|
+
l("corner", "bottom-right", n, a),
|
|
4273
4284
|
// Side handles
|
|
4274
|
-
l("edge", "middle-left", 0,
|
|
4275
|
-
l("edge", "middle-right", n,
|
|
4285
|
+
l("edge", "middle-left", 0, a / 2),
|
|
4286
|
+
l("edge", "middle-right", n, a / 2),
|
|
4276
4287
|
l("edge", "middle-top", n / 2, 0),
|
|
4277
|
-
l("edge", "middle-bottom", n / 2,
|
|
4288
|
+
l("edge", "middle-bottom", n / 2, a)
|
|
4278
4289
|
];
|
|
4279
4290
|
}
|
|
4280
|
-
function
|
|
4281
|
-
const
|
|
4282
|
-
return
|
|
4291
|
+
function ms(o, t, e, i, s) {
|
|
4292
|
+
const r = o - e, h = t - i;
|
|
4293
|
+
return r * r + h * h <= s * s;
|
|
4283
4294
|
}
|
|
4284
|
-
function
|
|
4285
|
-
const s = I.toRadiansInverse(i),
|
|
4295
|
+
function ps(o, t, e, i) {
|
|
4296
|
+
const s = I.toRadiansInverse(i), r = Math.cos(s), h = Math.sin(s), n = o - e.x, a = t - e.y, l = n * r - a * h, c = n * h + a * r;
|
|
4286
4297
|
return l >= 0 && l <= e.width && c >= 0 && c <= e.height;
|
|
4287
4298
|
}
|
|
4288
|
-
function
|
|
4289
|
-
const
|
|
4290
|
-
return
|
|
4299
|
+
function et(o, t, e = "Arial", i = !1, s = !1) {
|
|
4300
|
+
const h = document.createElement("canvas").getContext("2d"), n = i ? "bold" : "normal", a = s ? "italic" : "normal";
|
|
4301
|
+
return h.font = `${a} ${n} ${t}px ${e}`, h.measureText(o).width;
|
|
4291
4302
|
}
|
|
4292
|
-
function
|
|
4303
|
+
function ys(o) {
|
|
4293
4304
|
return {
|
|
4294
|
-
x:
|
|
4295
|
-
y:
|
|
4305
|
+
x: o.x + o.width / 2,
|
|
4306
|
+
y: o.y + o.height / 2
|
|
4296
4307
|
};
|
|
4297
4308
|
}
|
|
4298
|
-
function
|
|
4299
|
-
return Math.atan2(i - t, e -
|
|
4309
|
+
function ws(o, t, e, i) {
|
|
4310
|
+
return Math.atan2(i - t, e - o);
|
|
4300
4311
|
}
|
|
4301
|
-
function
|
|
4302
|
-
return Math.abs(
|
|
4312
|
+
function bs(o, t, e) {
|
|
4313
|
+
return Math.abs(o - t) <= e;
|
|
4303
4314
|
}
|
|
4304
|
-
function
|
|
4305
|
-
const n =
|
|
4306
|
-
let l = Math.atan2(
|
|
4315
|
+
function qe(o, t, e, i, s, r = 0, h = "") {
|
|
4316
|
+
const n = o - e, a = t - i;
|
|
4317
|
+
let l = Math.atan2(a, n) * (180 / Math.PI);
|
|
4307
4318
|
if (l = (l % 360 + 360) % 360, s === "corner") {
|
|
4308
|
-
if (Math.abs(
|
|
4309
|
-
if (
|
|
4319
|
+
if (Math.abs(r) < 0.1) {
|
|
4320
|
+
if (h === "top-left" || h === "bottom-right")
|
|
4310
4321
|
return "nwse-resize";
|
|
4311
|
-
if (
|
|
4322
|
+
if (h === "top-right" || h === "bottom-left")
|
|
4312
4323
|
return "nesw-resize";
|
|
4313
4324
|
}
|
|
4314
4325
|
const g = l % 180;
|
|
@@ -4318,17 +4329,17 @@ function _e(r, t, e, i, s, o = 0, a = "") {
|
|
|
4318
4329
|
return c >= 45 && c < 135 ? "ns-resize" : "ew-resize";
|
|
4319
4330
|
}
|
|
4320
4331
|
}
|
|
4321
|
-
function
|
|
4322
|
-
if (!
|
|
4332
|
+
function je(o) {
|
|
4333
|
+
if (!o.getTransform)
|
|
4323
4334
|
return 1;
|
|
4324
|
-
const t =
|
|
4335
|
+
const t = o.getTransform();
|
|
4325
4336
|
return Math.sqrt(t.a * t.a + t.b * t.b);
|
|
4326
4337
|
}
|
|
4327
|
-
function
|
|
4328
|
-
const i =
|
|
4329
|
-
|
|
4338
|
+
function xs(o, t, e = []) {
|
|
4339
|
+
const i = je(o);
|
|
4340
|
+
o.lineWidth = i > 0 ? t / i : t, e.length > 0 && o.setLineDash(i > 0 ? e.map((s) => s / i) : e);
|
|
4330
4341
|
}
|
|
4331
|
-
class
|
|
4342
|
+
class Ze extends j {
|
|
4332
4343
|
constructor(t = {}) {
|
|
4333
4344
|
super(t), this.transformType = "circle";
|
|
4334
4345
|
const e = t.transformData;
|
|
@@ -4358,11 +4369,11 @@ class Ue extends q {
|
|
|
4358
4369
|
* For circular text, calculate the arc bounds where text actually appears
|
|
4359
4370
|
*/
|
|
4360
4371
|
getVisualBoundingBox() {
|
|
4361
|
-
const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, s =
|
|
4372
|
+
const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, s = et(this.text, e, this.fontFamily, this.bold, this.italic) / t, r = -Math.PI / 2 - s / 2, h = -Math.PI / 2 + s / 2, n = t > e / 2 ? t - e / 2 : t * 0.1, a = t + e / 2;
|
|
4362
4373
|
let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0;
|
|
4363
4374
|
const f = 10;
|
|
4364
4375
|
for (let u = 0; u <= f; u++) {
|
|
4365
|
-
const m =
|
|
4376
|
+
const m = r + (h - r) * (u / f), p = this.x + Math.cos(m) * n, y = this.y + Math.sin(m) * n, w = this.x + Math.cos(m) * a, S = this.y + Math.sin(m) * a;
|
|
4366
4377
|
l = Math.min(l, p, w), c = Math.max(c, p, w), g = Math.min(g, y, S), d = Math.max(d, y, S);
|
|
4367
4378
|
}
|
|
4368
4379
|
return {
|
|
@@ -4382,14 +4393,14 @@ class Ue extends q {
|
|
|
4382
4393
|
* For circle, we maintain uniform scale and keep scale on the transform
|
|
4383
4394
|
*/
|
|
4384
4395
|
resize(t, e, i, s) {
|
|
4385
|
-
const
|
|
4396
|
+
const r = s.transformData, h = (e + i) / 2, n = (s.width + s.height) / 2, a = h / n, l = r.scale * a, c = Math.max(0.1, Math.min(10, l));
|
|
4386
4397
|
this.transformData.scale = c;
|
|
4387
|
-
const g = this.getBoundingBox(), d =
|
|
4398
|
+
const g = this.getBoundingBox(), d = Je(
|
|
4388
4399
|
{
|
|
4389
|
-
x: s.x -
|
|
4390
|
-
y: s.y -
|
|
4391
|
-
width:
|
|
4392
|
-
height:
|
|
4400
|
+
x: s.x - r.radius * r.scale,
|
|
4401
|
+
y: s.y - r.radius * r.scale,
|
|
4402
|
+
width: r.radius * 2 * r.scale,
|
|
4403
|
+
height: r.radius * 2 * r.scale
|
|
4393
4404
|
},
|
|
4394
4405
|
{ width: g.width, height: g.height },
|
|
4395
4406
|
t,
|
|
@@ -4458,7 +4469,7 @@ class Ue extends q {
|
|
|
4458
4469
|
};
|
|
4459
4470
|
}
|
|
4460
4471
|
}
|
|
4461
|
-
class
|
|
4472
|
+
class Ke extends j {
|
|
4462
4473
|
constructor(t = {}) {
|
|
4463
4474
|
super(t), this.transformType = "arch";
|
|
4464
4475
|
const e = t.transformData;
|
|
@@ -4478,8 +4489,8 @@ class Ge extends q {
|
|
|
4478
4489
|
};
|
|
4479
4490
|
}
|
|
4480
4491
|
getVisualBoundingBox() {
|
|
4481
|
-
const t = this.text.split(""), e = t.map((u) =>
|
|
4482
|
-
let
|
|
4492
|
+
const t = this.text.split(""), e = t.map((u) => et(u, this.fontSize, this.fontFamily)), i = e.reduce((u, m) => u + m, 0), s = this.transformData.width / 2, r = 0.3, n = this.fontSize / 2;
|
|
4493
|
+
let a = 1 / 0, l = -1 / 0, c = 1 / 0, g = -1 / 0, d = -i / 2;
|
|
4483
4494
|
t.forEach((u, m) => {
|
|
4484
4495
|
const p = e[m], y = d + p / 2, w = y / s, S = (Math.pow(w, 2) - 1) * this.transformData.archHeight * this.fontSize, b = 2 * w * this.transformData.archHeight;
|
|
4485
4496
|
[
|
|
@@ -4492,33 +4503,33 @@ class Ge extends q {
|
|
|
4492
4503
|
{ x: p / 2, y: n }
|
|
4493
4504
|
// bottom-right
|
|
4494
4505
|
].forEach((C) => {
|
|
4495
|
-
const M = C.x, F = C.y + b *
|
|
4496
|
-
|
|
4506
|
+
const M = C.x, F = C.y + b * r * C.x, T = y + M, D = S + F;
|
|
4507
|
+
a = Math.min(a, T), l = Math.max(l, T), c = Math.min(c, D), g = Math.max(g, D);
|
|
4497
4508
|
}), d += p;
|
|
4498
4509
|
});
|
|
4499
4510
|
const f = 2;
|
|
4500
|
-
return
|
|
4501
|
-
x: this.x +
|
|
4511
|
+
return a -= f, l += f, c -= f, g += f, {
|
|
4512
|
+
x: this.x + a,
|
|
4502
4513
|
y: this.y + c,
|
|
4503
|
-
width: l -
|
|
4514
|
+
width: l - a,
|
|
4504
4515
|
height: g - c
|
|
4505
4516
|
};
|
|
4506
4517
|
}
|
|
4507
4518
|
resize(t, e, i, s) {
|
|
4508
|
-
const
|
|
4509
|
-
if (
|
|
4510
|
-
const
|
|
4519
|
+
const r = t.includes("top") || t.includes("bottom"), h = t.includes("middle"), n = s.transformData;
|
|
4520
|
+
if (r) {
|
|
4521
|
+
const a = e / s.width, l = s.fontSize * a;
|
|
4511
4522
|
this.setFontSize(l);
|
|
4512
|
-
const c = n.width *
|
|
4523
|
+
const c = n.width * a;
|
|
4513
4524
|
this.transformData.width = Math.max(50, c);
|
|
4514
|
-
} else if (
|
|
4525
|
+
} else if (h && (t === "middle-left" || t === "middle-right")) {
|
|
4515
4526
|
this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
|
|
4516
|
-
const
|
|
4527
|
+
const a = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
|
|
4517
4528
|
if (t === "middle-left") {
|
|
4518
|
-
const d = -
|
|
4529
|
+
const d = -a / 2;
|
|
4519
4530
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4520
4531
|
} else if (t === "middle-right") {
|
|
4521
|
-
const d =
|
|
4532
|
+
const d = a / 2;
|
|
4522
4533
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4523
4534
|
}
|
|
4524
4535
|
}
|
|
@@ -4551,34 +4562,34 @@ class Ge extends q {
|
|
|
4551
4562
|
};
|
|
4552
4563
|
}
|
|
4553
4564
|
}
|
|
4554
|
-
const
|
|
4565
|
+
const rt = {
|
|
4555
4566
|
amplitude: 0.2,
|
|
4556
4567
|
// 20% - subtle wave effect
|
|
4557
4568
|
frequency: 1.2,
|
|
4558
4569
|
// Smooth curve
|
|
4559
4570
|
width: 200
|
|
4560
|
-
},
|
|
4571
|
+
}, nt = {
|
|
4561
4572
|
amplitude: 0.2,
|
|
4562
4573
|
// 20% - subtle flag wave
|
|
4563
4574
|
frequency: 2,
|
|
4564
4575
|
// Standard flag frequency
|
|
4565
4576
|
width: 200
|
|
4566
|
-
},
|
|
4577
|
+
}, Qe = {
|
|
4567
4578
|
archHeight: 0.5
|
|
4568
|
-
},
|
|
4579
|
+
}, ti = {
|
|
4569
4580
|
leanAmount: 0
|
|
4570
|
-
},
|
|
4581
|
+
}, ei = {
|
|
4571
4582
|
ascendAngle: -15
|
|
4572
4583
|
};
|
|
4573
|
-
class
|
|
4584
|
+
class ii extends j {
|
|
4574
4585
|
constructor(t = {}) {
|
|
4575
4586
|
super(t), this.transformType = "wave";
|
|
4576
4587
|
const e = t.transformData;
|
|
4577
4588
|
this.transformData = {
|
|
4578
4589
|
type: "wave",
|
|
4579
|
-
amplitude: (e == null ? void 0 : e.amplitude) ??
|
|
4580
|
-
frequency: (e == null ? void 0 : e.frequency) ??
|
|
4581
|
-
width: (e == null ? void 0 : e.width) ??
|
|
4590
|
+
amplitude: (e == null ? void 0 : e.amplitude) ?? rt.amplitude,
|
|
4591
|
+
frequency: (e == null ? void 0 : e.frequency) ?? rt.frequency,
|
|
4592
|
+
width: (e == null ? void 0 : e.width) ?? rt.width
|
|
4582
4593
|
};
|
|
4583
4594
|
}
|
|
4584
4595
|
getBoundingBox() {
|
|
@@ -4591,34 +4602,34 @@ class qe extends q {
|
|
|
4591
4602
|
};
|
|
4592
4603
|
}
|
|
4593
4604
|
getVisualBoundingBox() {
|
|
4594
|
-
const t = this.text.split(""), e = t.map((d) =>
|
|
4595
|
-
let
|
|
4605
|
+
const t = this.text.split(""), e = t.map((d) => et(d, this.fontSize, this.fontFamily)), i = e.reduce((d, f) => d + f, 0), r = this.fontSize / 2;
|
|
4606
|
+
let h = 1 / 0, n = -1 / 0, a = 1 / 0, l = -1 / 0, c = -i / 2;
|
|
4596
4607
|
t.forEach((d, f) => {
|
|
4597
4608
|
const u = e[f], m = c + u / 2, p = m / (this.transformData.width / 2), y = this.transformData.amplitude * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * p), w = this.transformData.amplitude * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * p);
|
|
4598
4609
|
[
|
|
4599
|
-
{ x: -u / 2, y: -
|
|
4610
|
+
{ x: -u / 2, y: -r },
|
|
4600
4611
|
// top-left
|
|
4601
|
-
{ x: u / 2, y: -
|
|
4612
|
+
{ x: u / 2, y: -r },
|
|
4602
4613
|
// top-right
|
|
4603
|
-
{ x: -u / 2, y:
|
|
4614
|
+
{ x: -u / 2, y: r },
|
|
4604
4615
|
// bottom-left
|
|
4605
|
-
{ x: u / 2, y:
|
|
4616
|
+
{ x: u / 2, y: r }
|
|
4606
4617
|
// bottom-right
|
|
4607
4618
|
].forEach((b) => {
|
|
4608
|
-
const v = b.x, C = b.y + w *
|
|
4609
|
-
|
|
4619
|
+
const v = b.x, C = b.y + w * De * b.x, M = m + v, F = y + C;
|
|
4620
|
+
h = Math.min(h, M), n = Math.max(n, M), a = Math.min(a, F), l = Math.max(l, F);
|
|
4610
4621
|
}), c += u;
|
|
4611
4622
|
});
|
|
4612
4623
|
const g = 2;
|
|
4613
|
-
return
|
|
4614
|
-
x: this.x +
|
|
4615
|
-
y: this.y +
|
|
4616
|
-
width: n -
|
|
4617
|
-
height: l -
|
|
4624
|
+
return h -= g, n += g, a -= g, l += g, {
|
|
4625
|
+
x: this.x + h,
|
|
4626
|
+
y: this.y + a,
|
|
4627
|
+
width: n - h,
|
|
4628
|
+
height: l - a
|
|
4618
4629
|
};
|
|
4619
4630
|
}
|
|
4620
4631
|
resize(t, e, i, s) {
|
|
4621
|
-
|
|
4632
|
+
ee(this, t, e, i, s);
|
|
4622
4633
|
}
|
|
4623
4634
|
getEnabledAnchors() {
|
|
4624
4635
|
return ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
@@ -4639,15 +4650,15 @@ class qe extends q {
|
|
|
4639
4650
|
};
|
|
4640
4651
|
}
|
|
4641
4652
|
}
|
|
4642
|
-
class
|
|
4653
|
+
class si extends j {
|
|
4643
4654
|
constructor(t = {}) {
|
|
4644
4655
|
super(t), this.transformType = "flag";
|
|
4645
4656
|
const e = t.transformData;
|
|
4646
4657
|
this.transformData = {
|
|
4647
4658
|
type: "flag",
|
|
4648
|
-
amplitude: (e == null ? void 0 : e.amplitude) ??
|
|
4649
|
-
frequency: (e == null ? void 0 : e.frequency) ??
|
|
4650
|
-
width: (e == null ? void 0 : e.width) ??
|
|
4659
|
+
amplitude: (e == null ? void 0 : e.amplitude) ?? nt.amplitude,
|
|
4660
|
+
frequency: (e == null ? void 0 : e.frequency) ?? nt.frequency,
|
|
4661
|
+
width: (e == null ? void 0 : e.width) ?? nt.width
|
|
4651
4662
|
};
|
|
4652
4663
|
}
|
|
4653
4664
|
getBoundingBox() {
|
|
@@ -4660,47 +4671,47 @@ class je extends q {
|
|
|
4660
4671
|
};
|
|
4661
4672
|
}
|
|
4662
4673
|
getVisualBoundingBox() {
|
|
4663
|
-
const t = this.text.split(""), e = t.map((f) =>
|
|
4664
|
-
let n = 1 / 0,
|
|
4674
|
+
const t = this.text.split(""), e = t.map((f) => et(f, this.fontSize, this.fontFamily)), i = e.reduce((f, u) => f + u, 0), s = 0.3, h = this.fontSize / 2;
|
|
4675
|
+
let n = 1 / 0, a = -1 / 0, l = 1 / 0, c = -1 / 0, g = -i / 2;
|
|
4665
4676
|
t.forEach((f, u) => {
|
|
4666
4677
|
const m = e[u], p = g + m / 2, y = p / (this.transformData.width / 2), w = Math.abs(y), S = this.transformData.amplitude * w, b = S * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * y), v = S * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * y), C = this.transformData.amplitude * Math.sign(y) * Math.sin(this.transformData.frequency * Math.PI * y), M = v + C;
|
|
4667
4678
|
[
|
|
4668
|
-
{ x: -m / 2, y: -
|
|
4679
|
+
{ x: -m / 2, y: -h },
|
|
4669
4680
|
// top-left
|
|
4670
|
-
{ x: m / 2, y: -
|
|
4681
|
+
{ x: m / 2, y: -h },
|
|
4671
4682
|
// top-right
|
|
4672
|
-
{ x: -m / 2, y:
|
|
4683
|
+
{ x: -m / 2, y: h },
|
|
4673
4684
|
// bottom-left
|
|
4674
|
-
{ x: m / 2, y:
|
|
4685
|
+
{ x: m / 2, y: h }
|
|
4675
4686
|
// bottom-right
|
|
4676
4687
|
].forEach((T) => {
|
|
4677
4688
|
const D = T.x, U = T.y + M * s * T.x, B = p + D, A = b + U;
|
|
4678
|
-
n = Math.min(n, B),
|
|
4689
|
+
n = Math.min(n, B), a = Math.max(a, B), l = Math.min(l, A), c = Math.max(c, A);
|
|
4679
4690
|
}), g += m;
|
|
4680
4691
|
});
|
|
4681
4692
|
const d = 2;
|
|
4682
|
-
return n -= d,
|
|
4693
|
+
return n -= d, a += d, l -= d, c += d, {
|
|
4683
4694
|
x: this.x + n,
|
|
4684
4695
|
y: this.y + l,
|
|
4685
|
-
width:
|
|
4696
|
+
width: a - n,
|
|
4686
4697
|
height: c - l
|
|
4687
4698
|
};
|
|
4688
4699
|
}
|
|
4689
4700
|
resize(t, e, i, s) {
|
|
4690
|
-
const
|
|
4691
|
-
if (
|
|
4692
|
-
const
|
|
4701
|
+
const r = t.includes("top") || t.includes("bottom"), h = t.includes("middle"), n = s.transformData;
|
|
4702
|
+
if (r) {
|
|
4703
|
+
const a = e / s.width, l = s.fontSize * a;
|
|
4693
4704
|
this.setFontSize(l);
|
|
4694
|
-
const c = n.width *
|
|
4705
|
+
const c = n.width * a;
|
|
4695
4706
|
this.transformData.width = Math.max(50, c);
|
|
4696
|
-
} else if (
|
|
4707
|
+
} else if (h && (t === "middle-left" || t === "middle-right")) {
|
|
4697
4708
|
this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
|
|
4698
|
-
const
|
|
4709
|
+
const a = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
|
|
4699
4710
|
if (t === "middle-left") {
|
|
4700
|
-
const d = -
|
|
4711
|
+
const d = -a / 2;
|
|
4701
4712
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4702
4713
|
} else if (t === "middle-right") {
|
|
4703
|
-
const d =
|
|
4714
|
+
const d = a / 2;
|
|
4704
4715
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4705
4716
|
}
|
|
4706
4717
|
}
|
|
@@ -4735,7 +4746,7 @@ class je extends q {
|
|
|
4735
4746
|
};
|
|
4736
4747
|
}
|
|
4737
4748
|
}
|
|
4738
|
-
class
|
|
4749
|
+
class oi extends j {
|
|
4739
4750
|
constructor(t = {}) {
|
|
4740
4751
|
super(t), this.transformType = "lean";
|
|
4741
4752
|
const e = t.transformData;
|
|
@@ -4755,7 +4766,7 @@ class Ze extends q {
|
|
|
4755
4766
|
};
|
|
4756
4767
|
}
|
|
4757
4768
|
getVisualBoundingBox() {
|
|
4758
|
-
const e =
|
|
4769
|
+
const e = et(this.text, this.fontSize, this.fontFamily), i = this.fontSize * 1.2, s = -this.transformData.leanAmount * Math.PI / 4, r = Math.tan(s), h = [
|
|
4759
4770
|
{ x: -e / 2, y: -i / 2 },
|
|
4760
4771
|
// top-left
|
|
4761
4772
|
{ x: e / 2, y: -i / 2 },
|
|
@@ -4765,34 +4776,34 @@ class Ze extends q {
|
|
|
4765
4776
|
{ x: e / 2, y: i / 2 }
|
|
4766
4777
|
// bottom-right
|
|
4767
4778
|
];
|
|
4768
|
-
let n = 1 / 0,
|
|
4769
|
-
|
|
4770
|
-
const f = d.x +
|
|
4771
|
-
n = Math.min(n, f),
|
|
4779
|
+
let n = 1 / 0, a = -1 / 0, l = 1 / 0, c = -1 / 0;
|
|
4780
|
+
h.forEach((d) => {
|
|
4781
|
+
const f = d.x + r * d.y, u = d.y;
|
|
4782
|
+
n = Math.min(n, f), a = Math.max(a, f), l = Math.min(l, u), c = Math.max(c, u);
|
|
4772
4783
|
});
|
|
4773
4784
|
const g = 2;
|
|
4774
|
-
return n -= g,
|
|
4785
|
+
return n -= g, a += g, l -= g, c += g, {
|
|
4775
4786
|
x: this.x + n,
|
|
4776
4787
|
y: this.y + l,
|
|
4777
|
-
width:
|
|
4788
|
+
width: a - n,
|
|
4778
4789
|
height: c - l
|
|
4779
4790
|
};
|
|
4780
4791
|
}
|
|
4781
4792
|
resize(t, e, i, s) {
|
|
4782
|
-
const
|
|
4783
|
-
if (
|
|
4784
|
-
const
|
|
4793
|
+
const r = t.includes("top") || t.includes("bottom"), h = t.includes("middle"), n = s.transformData;
|
|
4794
|
+
if (r) {
|
|
4795
|
+
const a = e / s.width, l = s.fontSize * a;
|
|
4785
4796
|
this.setFontSize(l);
|
|
4786
|
-
const c = n.width *
|
|
4797
|
+
const c = n.width * a;
|
|
4787
4798
|
this.transformData.width = Math.max(50, c);
|
|
4788
|
-
} else if (
|
|
4799
|
+
} else if (h && (t === "middle-left" || t === "middle-right")) {
|
|
4789
4800
|
this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
|
|
4790
|
-
const
|
|
4801
|
+
const a = e - n.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
|
|
4791
4802
|
if (t === "middle-left") {
|
|
4792
|
-
const d = -
|
|
4803
|
+
const d = -a / 2;
|
|
4793
4804
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4794
4805
|
} else if (t === "middle-right") {
|
|
4795
|
-
const d =
|
|
4806
|
+
const d = a / 2;
|
|
4796
4807
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4797
4808
|
}
|
|
4798
4809
|
}
|
|
@@ -4825,7 +4836,7 @@ class Ze extends q {
|
|
|
4825
4836
|
};
|
|
4826
4837
|
}
|
|
4827
4838
|
}
|
|
4828
|
-
class
|
|
4839
|
+
class ri extends j {
|
|
4829
4840
|
constructor(t = {}) {
|
|
4830
4841
|
super(t), this.transformType = "ascend";
|
|
4831
4842
|
const e = t.transformData;
|
|
@@ -4836,30 +4847,30 @@ class Ke extends q {
|
|
|
4836
4847
|
};
|
|
4837
4848
|
}
|
|
4838
4849
|
getBoundingBox() {
|
|
4839
|
-
const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width, i = e * Math.tan(t), s = Math.abs(i) + this.fontSize * 1.2,
|
|
4850
|
+
const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width, i = e * Math.tan(t), s = Math.abs(i) + this.fontSize * 1.2, r = i > 0 ? -s : 0;
|
|
4840
4851
|
return {
|
|
4841
4852
|
x: this.x - e / 2,
|
|
4842
|
-
y: this.y +
|
|
4853
|
+
y: this.y + r,
|
|
4843
4854
|
width: e,
|
|
4844
4855
|
height: s
|
|
4845
4856
|
};
|
|
4846
4857
|
}
|
|
4847
4858
|
getVisualBoundingBox() {
|
|
4848
|
-
const t = this.text.split(""), e = t.map((m) =>
|
|
4859
|
+
const t = this.text.split(""), e = t.map((m) => et(m, this.fontSize, this.fontFamily)), i = e.reduce((m, p) => m + p, 0), s = this.transformData.ascendAngle * Math.PI / 180, r = Math.tan(s), h = 1, a = this.fontSize / 2;
|
|
4849
4860
|
let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0, f = -i / 2;
|
|
4850
4861
|
t.forEach((m, p) => {
|
|
4851
|
-
const y = e[p], w = f + y / 2, S = w *
|
|
4862
|
+
const y = e[p], w = f + y / 2, S = w * r;
|
|
4852
4863
|
[
|
|
4853
|
-
{ x: -y / 2, y: -
|
|
4864
|
+
{ x: -y / 2, y: -a },
|
|
4854
4865
|
// top-left
|
|
4855
|
-
{ x: y / 2, y: -
|
|
4866
|
+
{ x: y / 2, y: -a },
|
|
4856
4867
|
// top-right
|
|
4857
|
-
{ x: -y / 2, y:
|
|
4868
|
+
{ x: -y / 2, y: a },
|
|
4858
4869
|
// bottom-left
|
|
4859
|
-
{ x: y / 2, y:
|
|
4870
|
+
{ x: y / 2, y: a }
|
|
4860
4871
|
// bottom-right
|
|
4861
4872
|
].forEach((v) => {
|
|
4862
|
-
const C = v.x, M = v.y +
|
|
4873
|
+
const C = v.x, M = v.y + r * h * v.x, F = w + C, T = S + M;
|
|
4863
4874
|
l = Math.min(l, F), c = Math.max(c, F), g = Math.min(g, T), d = Math.max(d, T);
|
|
4864
4875
|
}), f += y;
|
|
4865
4876
|
});
|
|
@@ -4872,20 +4883,20 @@ class Ke extends q {
|
|
|
4872
4883
|
};
|
|
4873
4884
|
}
|
|
4874
4885
|
resize(t, e, i, s) {
|
|
4875
|
-
const
|
|
4876
|
-
if (
|
|
4877
|
-
const
|
|
4886
|
+
const r = t.includes("top") || t.includes("bottom"), h = t.includes("middle"), n = s.transformData;
|
|
4887
|
+
if (r) {
|
|
4888
|
+
const a = e / s.width, l = s.fontSize * a;
|
|
4878
4889
|
this.setFontSize(l);
|
|
4879
|
-
const c = n.width *
|
|
4890
|
+
const c = n.width * a;
|
|
4880
4891
|
this.transformData.width = Math.max(50, c);
|
|
4881
|
-
} else if (
|
|
4892
|
+
} else if (h && (t === "middle-left" || t === "middle-right")) {
|
|
4882
4893
|
this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
|
|
4883
|
-
const
|
|
4894
|
+
const a = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
|
|
4884
4895
|
if (t === "middle-left") {
|
|
4885
|
-
const d = -
|
|
4896
|
+
const d = -a / 2;
|
|
4886
4897
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4887
4898
|
} else if (t === "middle-right") {
|
|
4888
|
-
const d =
|
|
4899
|
+
const d = a / 2;
|
|
4889
4900
|
this.x = s.x + d * c, this.y = s.y + d * g;
|
|
4890
4901
|
}
|
|
4891
4902
|
}
|
|
@@ -4918,25 +4929,125 @@ class Ke extends q {
|
|
|
4918
4929
|
};
|
|
4919
4930
|
}
|
|
4920
4931
|
}
|
|
4921
|
-
class
|
|
4932
|
+
class ni extends Error {
|
|
4933
|
+
constructor(t, e, i = {}) {
|
|
4934
|
+
super(`[Editor] ${t}: ${e}`), this.name = "EditorError", this.code = t, this.data = { code: t, ...i };
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
function Ss(o) {
|
|
4938
|
+
return o instanceof Error && o.name === "EditorError" && "code" in o;
|
|
4939
|
+
}
|
|
4940
|
+
function Cs() {
|
|
4941
|
+
var o;
|
|
4942
|
+
return typeof mt < "u" && ((o = mt.env) == null ? void 0 : o.NODE_ENV) !== "production";
|
|
4943
|
+
}
|
|
4944
|
+
const ie = "#3b82f6", _t = ["solid", "linear", "radial"];
|
|
4945
|
+
function V(o, t) {
|
|
4946
|
+
return new ni("E_INVALID_FILL", o, t);
|
|
4947
|
+
}
|
|
4948
|
+
function ai(o) {
|
|
4949
|
+
if (typeof o != "object" || o === null)
|
|
4950
|
+
throw V(
|
|
4951
|
+
`shape fill must be an object ({ type: "solid" | "linear" | "radial", ... }), got ${JSON.stringify(o)}.`,
|
|
4952
|
+
{ fill: o }
|
|
4953
|
+
);
|
|
4954
|
+
const t = o;
|
|
4955
|
+
if (t.type === "solid") {
|
|
4956
|
+
if (typeof t.color != "string")
|
|
4957
|
+
throw V(`solid fill "color" must be a string, got ${JSON.stringify(t.color)}.`, { fill: o });
|
|
4958
|
+
return;
|
|
4959
|
+
}
|
|
4960
|
+
if (t.type === "linear" || t.type === "radial") {
|
|
4961
|
+
if (t.type === "linear" && (typeof t.angle != "number" || !Number.isFinite(t.angle)))
|
|
4962
|
+
throw V(
|
|
4963
|
+
`linear fill "angle" must be a finite number of degrees (0 = up, 90 = right), got ${JSON.stringify(t.angle)}.`,
|
|
4964
|
+
{ fill: o }
|
|
4965
|
+
);
|
|
4966
|
+
if (!Array.isArray(t.stops) || t.stops.length < 2)
|
|
4967
|
+
throw V(
|
|
4968
|
+
`${t.type} fill needs at least 2 stops, got ${Array.isArray(t.stops) ? t.stops.length : JSON.stringify(t.stops)}.`,
|
|
4969
|
+
{ fill: o }
|
|
4970
|
+
);
|
|
4971
|
+
for (const e of t.stops) {
|
|
4972
|
+
if (typeof e != "object" || e === null || typeof e.offset != "number" || !Number.isFinite(e.offset) || e.offset < 0 || e.offset > 1)
|
|
4973
|
+
throw V(
|
|
4974
|
+
`gradient stop "offset" must be a finite number in 0..1, got ${JSON.stringify(e)}.`,
|
|
4975
|
+
{ fill: o, stop: e }
|
|
4976
|
+
);
|
|
4977
|
+
if (typeof e.color != "string")
|
|
4978
|
+
throw V(`gradient stop "color" must be a string, got ${JSON.stringify(e)}.`, { fill: o, stop: e });
|
|
4979
|
+
}
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
throw V(
|
|
4983
|
+
`unknown shape fill type ${JSON.stringify(t.type)}. Valid types: ${JSON.stringify(_t)}.`,
|
|
4984
|
+
{ fill: o, validNames: _t }
|
|
4985
|
+
);
|
|
4986
|
+
}
|
|
4987
|
+
function zt(o) {
|
|
4988
|
+
switch (o.type) {
|
|
4989
|
+
case "solid":
|
|
4990
|
+
return { type: "solid", color: o.color };
|
|
4991
|
+
case "linear":
|
|
4992
|
+
return { type: "linear", angle: o.angle, stops: o.stops.map((t) => ({ ...t })) };
|
|
4993
|
+
case "radial":
|
|
4994
|
+
return { type: "radial", stops: o.stops.map((t) => ({ ...t })) };
|
|
4995
|
+
}
|
|
4996
|
+
}
|
|
4997
|
+
function Xt(o, t) {
|
|
4998
|
+
for (const e of t)
|
|
4999
|
+
o.addColorStop(Math.min(1, Math.max(0, e.offset)), e.color);
|
|
5000
|
+
return o;
|
|
5001
|
+
}
|
|
5002
|
+
function dt(o, t) {
|
|
5003
|
+
const { fill: e } = t;
|
|
5004
|
+
if (!e) return t.fillColor || ie;
|
|
5005
|
+
if (e.type === "solid") return e.color;
|
|
5006
|
+
const i = t.width ?? 100, s = t.height ?? 100;
|
|
5007
|
+
if (e.type === "linear") {
|
|
5008
|
+
const h = e.angle * Math.PI / 180, n = Math.sin(h), a = -Math.cos(h), l = (Math.abs(i * n) + Math.abs(s * a)) / 2;
|
|
5009
|
+
return Xt(
|
|
5010
|
+
o.createLinearGradient(-n * l, -a * l, n * l, a * l),
|
|
5011
|
+
e.stops
|
|
5012
|
+
);
|
|
5013
|
+
}
|
|
5014
|
+
const r = Math.sqrt(i * i + s * s) / 2;
|
|
5015
|
+
return Xt(o.createRadialGradient(0, 0, 0, 0, 0, r), e.stops);
|
|
5016
|
+
}
|
|
5017
|
+
function vs(o, t) {
|
|
5018
|
+
if (!o) return t || ie;
|
|
5019
|
+
switch (o.type) {
|
|
5020
|
+
case "solid":
|
|
5021
|
+
return o.color;
|
|
5022
|
+
case "linear":
|
|
5023
|
+
return `linear-gradient(${o.angle}deg, ${o.stops.map((e) => `${e.color} ${e.offset * 100}%`).join(", ")})`;
|
|
5024
|
+
case "radial":
|
|
5025
|
+
return `radial-gradient(circle, ${o.stops.map((e) => `${e.color} ${e.offset * 100}%`).join(", ")})`;
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
class Ot extends tt {
|
|
4922
5029
|
constructor(t = {}) {
|
|
4923
|
-
var
|
|
5030
|
+
var s, r, h, n, a, l, c, g, d, f, u, m;
|
|
4924
5031
|
super(t), this.transformType = "shape";
|
|
4925
|
-
const e =
|
|
5032
|
+
const e = (s = t.transformData) == null ? void 0 : s.fill;
|
|
5033
|
+
e !== void 0 && ai(e);
|
|
5034
|
+
const i = "rectangle";
|
|
4926
5035
|
this.transformData = {
|
|
4927
5036
|
type: "shape",
|
|
4928
|
-
shapeType: ((
|
|
4929
|
-
width: ((
|
|
4930
|
-
height: ((
|
|
5037
|
+
shapeType: ((r = t.transformData) == null ? void 0 : r.shapeType) || i,
|
|
5038
|
+
width: ((h = t.transformData) == null ? void 0 : h.width) || 200,
|
|
5039
|
+
height: ((n = t.transformData) == null ? void 0 : n.height) || 200,
|
|
4931
5040
|
borderRadius: ((a = t.transformData) == null ? void 0 : a.borderRadius) ?? 3,
|
|
4932
5041
|
// Default 3% radius (~6px on 200x200 shape, matches hover border)
|
|
4933
|
-
radiusX: (
|
|
4934
|
-
radiusY: (
|
|
4935
|
-
sides: ((
|
|
4936
|
-
points: ((
|
|
4937
|
-
innerRadius: ((
|
|
4938
|
-
fillColor: ((
|
|
4939
|
-
fillOpacity: ((
|
|
5042
|
+
radiusX: (l = t.transformData) == null ? void 0 : l.radiusX,
|
|
5043
|
+
radiusY: (c = t.transformData) == null ? void 0 : c.radiusY,
|
|
5044
|
+
sides: ((g = t.transformData) == null ? void 0 : g.sides) ?? 5,
|
|
5045
|
+
points: ((d = t.transformData) == null ? void 0 : d.points) ?? 5,
|
|
5046
|
+
innerRadius: ((f = t.transformData) == null ? void 0 : f.innerRadius) ?? 0.4,
|
|
5047
|
+
fillColor: ((u = t.transformData) == null ? void 0 : u.fillColor) || Jt(),
|
|
5048
|
+
fillOpacity: ((m = t.transformData) == null ? void 0 : m.fillOpacity) ?? 1,
|
|
5049
|
+
// Deep-copy so a config's stops array is never aliased by the element
|
|
5050
|
+
...e !== void 0 && { fill: zt(e) }
|
|
4940
5051
|
};
|
|
4941
5052
|
}
|
|
4942
5053
|
/**
|
|
@@ -4980,25 +5091,25 @@ class kt extends Q {
|
|
|
4980
5091
|
}
|
|
4981
5092
|
if (t === "polygon" || t === "star") {
|
|
4982
5093
|
const s = Math.min(e, i) / 2;
|
|
4983
|
-
let
|
|
5094
|
+
let r = 1 / 0, h = 1 / 0, n = -1 / 0, a = -1 / 0;
|
|
4984
5095
|
if (t === "polygon") {
|
|
4985
5096
|
const l = this.transformData.sides || 5;
|
|
4986
5097
|
for (let c = 0; c < l; c++) {
|
|
4987
5098
|
const g = c * 2 * Math.PI / l - Math.PI / 2, d = s * Math.cos(g), f = s * Math.sin(g);
|
|
4988
|
-
d <
|
|
5099
|
+
d < r && (r = d), d > n && (n = d), f < h && (h = f), f > a && (a = f);
|
|
4989
5100
|
}
|
|
4990
5101
|
} else {
|
|
4991
5102
|
const l = this.transformData.points || 5, c = s, g = c * (this.transformData.innerRadius ?? 0.4);
|
|
4992
5103
|
for (let d = 0; d < l * 2; d++) {
|
|
4993
5104
|
const f = d * Math.PI / l - Math.PI / 2, u = d % 2 === 0 ? c : g, m = u * Math.cos(f), p = u * Math.sin(f);
|
|
4994
|
-
m <
|
|
5105
|
+
m < r && (r = m), m > n && (n = m), p < h && (h = p), p > a && (a = p);
|
|
4995
5106
|
}
|
|
4996
5107
|
}
|
|
4997
5108
|
return {
|
|
4998
|
-
x: this.x +
|
|
4999
|
-
y: this.y +
|
|
5000
|
-
width: n -
|
|
5001
|
-
height:
|
|
5109
|
+
x: this.x + r,
|
|
5110
|
+
y: this.y + h,
|
|
5111
|
+
width: n - r,
|
|
5112
|
+
height: a - h
|
|
5002
5113
|
};
|
|
5003
5114
|
}
|
|
5004
5115
|
return this.getBoundingBox();
|
|
@@ -5014,14 +5125,14 @@ class kt extends Q {
|
|
|
5014
5125
|
*/
|
|
5015
5126
|
render(t, e = !1, i = !1) {
|
|
5016
5127
|
var n;
|
|
5017
|
-
const s = this.opacity ?? 1,
|
|
5018
|
-
if (s < 1 &&
|
|
5128
|
+
const s = this.opacity ?? 1, r = !!((n = this.stroke) != null && n.enabled);
|
|
5129
|
+
if (s < 1 && r) {
|
|
5019
5130
|
this.renderWithOffscreen(t, s);
|
|
5020
5131
|
return;
|
|
5021
5132
|
}
|
|
5022
|
-
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = this.transformData
|
|
5023
|
-
const
|
|
5024
|
-
t.globalAlpha = s *
|
|
5133
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = dt(t, this.transformData);
|
|
5134
|
+
const h = this.transformData.fillOpacity ?? 1;
|
|
5135
|
+
t.globalAlpha = s * h, this.renderShape(t), t.restore(), r && this.renderStroke(t, s);
|
|
5025
5136
|
}
|
|
5026
5137
|
/**
|
|
5027
5138
|
* Render fill+stroke to a temporary canvas at full opacity, then composite
|
|
@@ -5029,25 +5140,25 @@ class kt extends Q {
|
|
|
5029
5140
|
*/
|
|
5030
5141
|
renderWithOffscreen(t, e) {
|
|
5031
5142
|
var f;
|
|
5032
|
-
const { width: i, height: s } = this.transformData,
|
|
5033
|
-
l.width = n, l.height =
|
|
5143
|
+
const { width: i, height: s } = this.transformData, h = (((f = this.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(i + h * 2), a = Math.ceil(s + h * 2), l = document.createElement("canvas");
|
|
5144
|
+
l.width = n, l.height = a;
|
|
5034
5145
|
const c = l.getContext("2d");
|
|
5035
5146
|
if (!c) {
|
|
5036
5147
|
this.renderDirect(t, e);
|
|
5037
5148
|
return;
|
|
5038
5149
|
}
|
|
5039
|
-
c.save(), c.translate(n / 2,
|
|
5150
|
+
c.save(), c.translate(n / 2, a / 2), c.fillStyle = dt(c, this.transformData);
|
|
5040
5151
|
const g = this.transformData.fillOpacity ?? 1;
|
|
5041
|
-
c.globalAlpha = g, c.beginPath(), this.traceShapePath(c), c.fill(), c.restore(), c.save(), c.translate(n / 2,
|
|
5152
|
+
c.globalAlpha = g, c.beginPath(), this.traceShapePath(c), c.fill(), c.restore(), c.save(), c.translate(n / 2, a / 2);
|
|
5042
5153
|
const d = this.stroke;
|
|
5043
|
-
c.strokeStyle = d.color || "#000000", c.lineWidth = d.width || 2, c.lineCap = d.lineCap || "round", c.lineJoin = d.lineJoin || "round", c.globalAlpha = d.opacity ?? 1, d.dashArray && d.dashArray.length > 0 && c.setLineDash(d.dashArray), c.beginPath(), this.traceShapePath(c), c.stroke(), c.restore(), t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.globalAlpha = e, t.drawImage(l, -n / 2, -
|
|
5154
|
+
c.strokeStyle = d.color || "#000000", c.lineWidth = d.width || 2, c.lineCap = d.lineCap || "round", c.lineJoin = d.lineJoin || "round", c.globalAlpha = d.opacity ?? 1, d.dashArray && d.dashArray.length > 0 && c.setLineDash(d.dashArray), c.beginPath(), this.traceShapePath(c), c.stroke(), c.restore(), t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.globalAlpha = e, t.drawImage(l, -n / 2, -a / 2), t.restore();
|
|
5044
5155
|
}
|
|
5045
5156
|
/**
|
|
5046
5157
|
* Direct render (no offscreen) — used as fallback
|
|
5047
5158
|
*/
|
|
5048
5159
|
renderDirect(t, e) {
|
|
5049
5160
|
var i;
|
|
5050
|
-
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = this.transformData
|
|
5161
|
+
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = dt(t, this.transformData), t.globalAlpha = e * (this.transformData.fillOpacity ?? 1), this.renderShape(t), t.restore(), (i = this.stroke) != null && i.enabled && this.renderStroke(t, e);
|
|
5051
5162
|
}
|
|
5052
5163
|
/**
|
|
5053
5164
|
* Trace the shape path without filling or stroking — used by offscreen render
|
|
@@ -5056,48 +5167,48 @@ class kt extends Q {
|
|
|
5056
5167
|
const { shapeType: e, width: i, height: s } = this.transformData;
|
|
5057
5168
|
switch (e) {
|
|
5058
5169
|
case "rectangle": {
|
|
5059
|
-
const
|
|
5060
|
-
if (
|
|
5061
|
-
const
|
|
5062
|
-
t.roundRect(
|
|
5170
|
+
const r = this.transformData.borderRadius || 0, h = -i / 2, n = -s / 2;
|
|
5171
|
+
if (r > 0) {
|
|
5172
|
+
const a = Math.min(r / 100 * Math.min(i, s), i / 2, s / 2);
|
|
5173
|
+
t.roundRect(h, n, i, s, a);
|
|
5063
5174
|
} else
|
|
5064
|
-
t.rect(
|
|
5175
|
+
t.rect(h, n, i, s);
|
|
5065
5176
|
break;
|
|
5066
5177
|
}
|
|
5067
5178
|
case "circle": {
|
|
5068
|
-
const
|
|
5069
|
-
t.arc(0, 0,
|
|
5179
|
+
const r = Math.min(i, s) / 2;
|
|
5180
|
+
t.arc(0, 0, r, 0, Math.PI * 2);
|
|
5070
5181
|
break;
|
|
5071
5182
|
}
|
|
5072
5183
|
case "ellipse":
|
|
5073
5184
|
t.ellipse(0, 0, i / 2, s / 2, 0, 0, Math.PI * 2);
|
|
5074
5185
|
break;
|
|
5075
5186
|
case "triangle": {
|
|
5076
|
-
const
|
|
5077
|
-
t.moveTo(0, -
|
|
5187
|
+
const r = i / 2, h = s / 2;
|
|
5188
|
+
t.moveTo(0, -h), t.lineTo(r, h), t.lineTo(-r, h), t.closePath();
|
|
5078
5189
|
break;
|
|
5079
5190
|
}
|
|
5080
5191
|
case "polygon": {
|
|
5081
|
-
const
|
|
5082
|
-
for (let n = 0; n <
|
|
5083
|
-
const
|
|
5192
|
+
const r = this.transformData.sides || 5, h = Math.min(i, s) / 2;
|
|
5193
|
+
for (let n = 0; n < r; n++) {
|
|
5194
|
+
const a = n * 2 * Math.PI / r - Math.PI / 2, l = h * Math.cos(a), c = h * Math.sin(a);
|
|
5084
5195
|
n === 0 ? t.moveTo(l, c) : t.lineTo(l, c);
|
|
5085
5196
|
}
|
|
5086
5197
|
t.closePath();
|
|
5087
5198
|
break;
|
|
5088
5199
|
}
|
|
5089
5200
|
case "star": {
|
|
5090
|
-
const
|
|
5091
|
-
for (let
|
|
5092
|
-
const l =
|
|
5093
|
-
|
|
5201
|
+
const r = this.transformData.points || 5, h = Math.min(i, s) / 2, n = h * (this.transformData.innerRadius || 0.4);
|
|
5202
|
+
for (let a = 0; a < r * 2; a++) {
|
|
5203
|
+
const l = a * Math.PI / r - Math.PI / 2, c = a % 2 === 0 ? h : n, g = c * Math.cos(l), d = c * Math.sin(l);
|
|
5204
|
+
a === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
5094
5205
|
}
|
|
5095
5206
|
t.closePath();
|
|
5096
5207
|
break;
|
|
5097
5208
|
}
|
|
5098
5209
|
case "line": {
|
|
5099
|
-
const
|
|
5100
|
-
t.rect(-
|
|
5210
|
+
const r = i / 2, h = s / 2;
|
|
5211
|
+
t.rect(-r, -h, i, s);
|
|
5101
5212
|
break;
|
|
5102
5213
|
}
|
|
5103
5214
|
default:
|
|
@@ -5111,55 +5222,55 @@ class kt extends Q {
|
|
|
5111
5222
|
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
5112
5223
|
const i = this.stroke;
|
|
5113
5224
|
t.strokeStyle = i.color || "#000000", t.lineWidth = i.width || 2, t.lineCap = i.lineCap || "round", t.lineJoin = i.lineJoin || "round", t.globalAlpha = e * (i.opacity ?? 1), i.dashArray && i.dashArray.length > 0 && t.setLineDash(i.dashArray);
|
|
5114
|
-
const { shapeType: s, width:
|
|
5225
|
+
const { shapeType: s, width: r, height: h } = this.transformData;
|
|
5115
5226
|
switch (t.beginPath(), s) {
|
|
5116
5227
|
case "rectangle": {
|
|
5117
|
-
const n = this.transformData.borderRadius || 0,
|
|
5228
|
+
const n = this.transformData.borderRadius || 0, a = -r / 2, l = -h / 2;
|
|
5118
5229
|
if (n > 0) {
|
|
5119
|
-
const c = Math.min(n / 100 * Math.min(
|
|
5120
|
-
t.roundRect(
|
|
5230
|
+
const c = Math.min(n / 100 * Math.min(r, h), r / 2, h / 2);
|
|
5231
|
+
t.roundRect(a, l, r, h, c);
|
|
5121
5232
|
} else
|
|
5122
|
-
t.rect(
|
|
5233
|
+
t.rect(a, l, r, h);
|
|
5123
5234
|
break;
|
|
5124
5235
|
}
|
|
5125
5236
|
case "circle": {
|
|
5126
|
-
const n = Math.min(
|
|
5237
|
+
const n = Math.min(r, h) / 2;
|
|
5127
5238
|
t.arc(0, 0, n, 0, Math.PI * 2);
|
|
5128
5239
|
break;
|
|
5129
5240
|
}
|
|
5130
5241
|
case "ellipse":
|
|
5131
|
-
t.ellipse(0, 0,
|
|
5242
|
+
t.ellipse(0, 0, r / 2, h / 2, 0, 0, Math.PI * 2);
|
|
5132
5243
|
break;
|
|
5133
5244
|
case "triangle": {
|
|
5134
|
-
const n =
|
|
5135
|
-
t.moveTo(0, -
|
|
5245
|
+
const n = r / 2, a = h / 2;
|
|
5246
|
+
t.moveTo(0, -a), t.lineTo(n, a), t.lineTo(-n, a), t.closePath();
|
|
5136
5247
|
break;
|
|
5137
5248
|
}
|
|
5138
5249
|
case "polygon": {
|
|
5139
|
-
const n = this.transformData.sides || 5,
|
|
5250
|
+
const n = this.transformData.sides || 5, a = Math.min(r, h) / 2;
|
|
5140
5251
|
for (let l = 0; l < n; l++) {
|
|
5141
|
-
const c = l * 2 * Math.PI / n - Math.PI / 2, g =
|
|
5252
|
+
const c = l * 2 * Math.PI / n - Math.PI / 2, g = a * Math.cos(c), d = a * Math.sin(c);
|
|
5142
5253
|
l === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
5143
5254
|
}
|
|
5144
5255
|
t.closePath();
|
|
5145
5256
|
break;
|
|
5146
5257
|
}
|
|
5147
5258
|
case "star": {
|
|
5148
|
-
const n = this.transformData.points || 5,
|
|
5259
|
+
const n = this.transformData.points || 5, a = Math.min(r, h) / 2, l = a * (this.transformData.innerRadius || 0.4);
|
|
5149
5260
|
for (let c = 0; c < n * 2; c++) {
|
|
5150
|
-
const g = c * Math.PI / n - Math.PI / 2, d = c % 2 === 0 ?
|
|
5261
|
+
const g = c * Math.PI / n - Math.PI / 2, d = c % 2 === 0 ? a : l, f = d * Math.cos(g), u = d * Math.sin(g);
|
|
5151
5262
|
c === 0 ? t.moveTo(f, u) : t.lineTo(f, u);
|
|
5152
5263
|
}
|
|
5153
5264
|
t.closePath();
|
|
5154
5265
|
break;
|
|
5155
5266
|
}
|
|
5156
5267
|
case "line": {
|
|
5157
|
-
const n =
|
|
5158
|
-
t.rect(-n, -
|
|
5268
|
+
const n = r / 2, a = h / 2;
|
|
5269
|
+
t.rect(-n, -a, r, h);
|
|
5159
5270
|
break;
|
|
5160
5271
|
}
|
|
5161
5272
|
default:
|
|
5162
|
-
t.rect(-
|
|
5273
|
+
t.rect(-r / 2, -h / 2, r, h);
|
|
5163
5274
|
}
|
|
5164
5275
|
t.stroke(), t.restore();
|
|
5165
5276
|
}
|
|
@@ -5200,12 +5311,12 @@ class kt extends Q {
|
|
|
5200
5311
|
* Render a rectangle (with optional border radius)
|
|
5201
5312
|
*/
|
|
5202
5313
|
renderRectangle(t, e, i) {
|
|
5203
|
-
const s = this.transformData.borderRadius || 0,
|
|
5314
|
+
const s = this.transformData.borderRadius || 0, r = -e / 2, h = -i / 2;
|
|
5204
5315
|
if (s > 0) {
|
|
5205
5316
|
const n = Math.min(s / 100 * Math.min(e, i), e / 2, i / 2);
|
|
5206
|
-
t.roundRect(
|
|
5317
|
+
t.roundRect(r, h, e, i, n);
|
|
5207
5318
|
} else
|
|
5208
|
-
t.rect(
|
|
5319
|
+
t.rect(r, h, e, i);
|
|
5209
5320
|
}
|
|
5210
5321
|
/**
|
|
5211
5322
|
* Render a circle
|
|
@@ -5223,17 +5334,17 @@ class kt extends Q {
|
|
|
5223
5334
|
* Render a triangle (isosceles, pointing up)
|
|
5224
5335
|
*/
|
|
5225
5336
|
renderTriangle(t, e, i) {
|
|
5226
|
-
const s = e / 2,
|
|
5227
|
-
t.moveTo(0, -
|
|
5337
|
+
const s = e / 2, r = i / 2;
|
|
5338
|
+
t.moveTo(0, -r), t.lineTo(s, r), t.lineTo(-s, r), t.closePath();
|
|
5228
5339
|
}
|
|
5229
5340
|
/**
|
|
5230
5341
|
* Render a regular polygon
|
|
5231
5342
|
*/
|
|
5232
5343
|
renderPolygon(t, e) {
|
|
5233
|
-
const i = Math.max(3, Math.min(20, this.transformData.sides || 5)), s = Math.PI * 2 / i,
|
|
5234
|
-
for (let
|
|
5235
|
-
const n =
|
|
5236
|
-
|
|
5344
|
+
const i = Math.max(3, Math.min(20, this.transformData.sides || 5)), s = Math.PI * 2 / i, r = -Math.PI / 2;
|
|
5345
|
+
for (let h = 0; h <= i; h++) {
|
|
5346
|
+
const n = r + s * h, a = Math.cos(n) * e, l = Math.sin(n) * e;
|
|
5347
|
+
h === 0 ? t.moveTo(a, l) : t.lineTo(a, l);
|
|
5237
5348
|
}
|
|
5238
5349
|
t.closePath();
|
|
5239
5350
|
}
|
|
@@ -5241,10 +5352,10 @@ class kt extends Q {
|
|
|
5241
5352
|
* Render a star
|
|
5242
5353
|
*/
|
|
5243
5354
|
renderStar(t, e) {
|
|
5244
|
-
const i = Math.max(3, Math.min(20, this.transformData.points || 5)), s = Math.max(0.1, Math.min(0.9, this.transformData.innerRadius || 0.4)),
|
|
5245
|
-
for (let
|
|
5246
|
-
const l = n +
|
|
5247
|
-
|
|
5355
|
+
const i = Math.max(3, Math.min(20, this.transformData.points || 5)), s = Math.max(0.1, Math.min(0.9, this.transformData.innerRadius || 0.4)), r = e * s, h = Math.PI / i, n = -Math.PI / 2;
|
|
5356
|
+
for (let a = 0; a < i * 2; a++) {
|
|
5357
|
+
const l = n + h * a, c = a % 2 === 0 ? e : r, g = Math.cos(l) * c, d = Math.sin(l) * c;
|
|
5358
|
+
a === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
|
|
5248
5359
|
}
|
|
5249
5360
|
t.closePath();
|
|
5250
5361
|
}
|
|
@@ -5252,21 +5363,21 @@ class kt extends Q {
|
|
|
5252
5363
|
* Render a line
|
|
5253
5364
|
*/
|
|
5254
5365
|
renderLine(t, e, i) {
|
|
5255
|
-
const s = e / 2,
|
|
5256
|
-
t.moveTo(-s, 0), t.lineTo(s, 0), t.strokeStyle = this.transformData
|
|
5366
|
+
const s = e / 2, r = i;
|
|
5367
|
+
t.moveTo(-s, 0), t.lineTo(s, 0), t.strokeStyle = dt(t, this.transformData), t.lineWidth = r, t.lineCap = "round", t.stroke();
|
|
5257
5368
|
}
|
|
5258
5369
|
/**
|
|
5259
5370
|
* Handle resize - maintain aspect ratio for circles, free resize for others
|
|
5260
5371
|
*/
|
|
5261
5372
|
resize(t, e, i, s) {
|
|
5262
|
-
const { shapeType:
|
|
5263
|
-
if (
|
|
5373
|
+
const { shapeType: r } = this.transformData;
|
|
5374
|
+
if (r === "circle" || r === "polygon" || r === "star") {
|
|
5264
5375
|
const c = Math.max(e / s.transformData.width, i / s.transformData.height);
|
|
5265
5376
|
this.transformData.width = s.transformData.width * c, this.transformData.height = s.transformData.height * c;
|
|
5266
|
-
} else
|
|
5377
|
+
} else r === "line" ? (this.transformData.width = e, this.transformData.height = s.transformData.height) : (this.transformData.width = e, this.transformData.height = i);
|
|
5267
5378
|
this.rotation = s.rotation;
|
|
5268
|
-
const
|
|
5269
|
-
return this.x =
|
|
5379
|
+
const h = this.getFixedCorner(t, s), n = this.getOppositeAnchor(t), a = this.getBoundingBox(), l = this.getCornerOffset(n, a);
|
|
5380
|
+
return this.x = h.x - l.x, this.y = h.y - l.y, !0;
|
|
5270
5381
|
}
|
|
5271
5382
|
/**
|
|
5272
5383
|
* Get the opposite anchor (the one that should stay fixed during resize)
|
|
@@ -5297,36 +5408,36 @@ class kt extends Q {
|
|
|
5297
5408
|
width: e.transformData.width,
|
|
5298
5409
|
height: e.transformData.height
|
|
5299
5410
|
};
|
|
5300
|
-
let s,
|
|
5411
|
+
let s, r;
|
|
5301
5412
|
switch (t) {
|
|
5302
5413
|
case "top-left":
|
|
5303
|
-
s = i.x + i.width,
|
|
5414
|
+
s = i.x + i.width, r = i.y + i.height;
|
|
5304
5415
|
break;
|
|
5305
5416
|
case "top-right":
|
|
5306
|
-
s = i.x,
|
|
5417
|
+
s = i.x, r = i.y + i.height;
|
|
5307
5418
|
break;
|
|
5308
5419
|
case "bottom-left":
|
|
5309
|
-
s = i.x + i.width,
|
|
5420
|
+
s = i.x + i.width, r = i.y;
|
|
5310
5421
|
break;
|
|
5311
5422
|
case "bottom-right":
|
|
5312
|
-
s = i.x,
|
|
5423
|
+
s = i.x, r = i.y;
|
|
5313
5424
|
break;
|
|
5314
5425
|
case "middle-left":
|
|
5315
|
-
s = i.x + i.width,
|
|
5426
|
+
s = i.x + i.width, r = i.y + i.height / 2;
|
|
5316
5427
|
break;
|
|
5317
5428
|
case "middle-right":
|
|
5318
|
-
s = i.x,
|
|
5429
|
+
s = i.x, r = i.y + i.height / 2;
|
|
5319
5430
|
break;
|
|
5320
5431
|
case "middle-top":
|
|
5321
|
-
s = i.x + i.width / 2,
|
|
5432
|
+
s = i.x + i.width / 2, r = i.y + i.height;
|
|
5322
5433
|
break;
|
|
5323
5434
|
case "middle-bottom":
|
|
5324
|
-
s = i.x + i.width / 2,
|
|
5435
|
+
s = i.x + i.width / 2, r = i.y;
|
|
5325
5436
|
break;
|
|
5326
5437
|
default:
|
|
5327
|
-
s = i.x + i.width / 2,
|
|
5438
|
+
s = i.x + i.width / 2, r = i.y + i.height / 2;
|
|
5328
5439
|
}
|
|
5329
|
-
return { x: s, y:
|
|
5440
|
+
return { x: s, y: r };
|
|
5330
5441
|
}
|
|
5331
5442
|
/**
|
|
5332
5443
|
* Get the offset of a corner from the center
|
|
@@ -5383,7 +5494,7 @@ class kt extends Q {
|
|
|
5383
5494
|
* Clone this element
|
|
5384
5495
|
*/
|
|
5385
5496
|
clone() {
|
|
5386
|
-
return new
|
|
5497
|
+
return new Ot(this.toJSON());
|
|
5387
5498
|
}
|
|
5388
5499
|
/**
|
|
5389
5500
|
* Serialize to JSON
|
|
@@ -5401,22 +5512,27 @@ class kt extends Q {
|
|
|
5401
5512
|
// Explicitly include to ensure number type
|
|
5402
5513
|
rotation: this.rotation,
|
|
5403
5514
|
// Explicitly include to ensure number type
|
|
5404
|
-
transformData: {
|
|
5515
|
+
transformData: {
|
|
5516
|
+
...this.transformData,
|
|
5517
|
+
// Deep-copy gradient stops — a spread would alias the stops array
|
|
5518
|
+
// between the element and its serialized config (fidelity sweep pin)
|
|
5519
|
+
...this.transformData.fill && { fill: zt(this.transformData.fill) }
|
|
5520
|
+
}
|
|
5405
5521
|
};
|
|
5406
5522
|
}
|
|
5407
5523
|
}
|
|
5408
|
-
class
|
|
5524
|
+
class Bt extends tt {
|
|
5409
5525
|
constructor(t = {}) {
|
|
5410
|
-
var e, i, s,
|
|
5526
|
+
var e, i, s, r, h, n, a, l, c, g;
|
|
5411
5527
|
super(t), this.transformType = "path", this.transformData = {
|
|
5412
5528
|
type: "path",
|
|
5413
5529
|
points: ((e = t.transformData) == null ? void 0 : e.points) || [],
|
|
5414
5530
|
closed: ((i = t.transformData) == null ? void 0 : i.closed) ?? !1,
|
|
5415
5531
|
width: ((s = t.transformData) == null ? void 0 : s.width) || 200,
|
|
5416
|
-
height: ((
|
|
5417
|
-
fillEnabled: ((
|
|
5418
|
-
fillColor: ((n = t.transformData) == null ? void 0 : n.fillColor) ||
|
|
5419
|
-
fillOpacity: ((
|
|
5532
|
+
height: ((r = t.transformData) == null ? void 0 : r.height) || 200,
|
|
5533
|
+
fillEnabled: ((h = t.transformData) == null ? void 0 : h.fillEnabled) ?? !1,
|
|
5534
|
+
fillColor: ((n = t.transformData) == null ? void 0 : n.fillColor) || Jt(),
|
|
5535
|
+
fillOpacity: ((a = t.transformData) == null ? void 0 : a.fillOpacity) ?? 1,
|
|
5420
5536
|
strokeEnabled: ((l = t.transformData) == null ? void 0 : l.strokeEnabled) ?? !0,
|
|
5421
5537
|
strokeColor: ((c = t.transformData) == null ? void 0 : c.strokeColor) || "#000000",
|
|
5422
5538
|
strokeWidth: ((g = t.transformData) == null ? void 0 : g.strokeWidth) || 2
|
|
@@ -5461,11 +5577,11 @@ class Et extends Q {
|
|
|
5461
5577
|
* @param p3 End point
|
|
5462
5578
|
* @param t Parameter from 0 to 1
|
|
5463
5579
|
*/
|
|
5464
|
-
bezierPoint(t, e, i, s,
|
|
5465
|
-
const
|
|
5580
|
+
bezierPoint(t, e, i, s, r) {
|
|
5581
|
+
const h = 1 - r, n = h * h, a = n * h, l = r * r, c = l * r;
|
|
5466
5582
|
return {
|
|
5467
|
-
x:
|
|
5468
|
-
y:
|
|
5583
|
+
x: a * t.x + 3 * n * r * e.x + 3 * h * l * i.x + c * s.x,
|
|
5584
|
+
y: a * t.y + 3 * n * r * e.y + 3 * h * l * i.y + c * s.y
|
|
5469
5585
|
};
|
|
5470
5586
|
}
|
|
5471
5587
|
/**
|
|
@@ -5473,20 +5589,20 @@ class Et extends Q {
|
|
|
5473
5589
|
* Returns bbox in local coordinates (relative to element position)
|
|
5474
5590
|
*/
|
|
5475
5591
|
calculatePathBounds() {
|
|
5476
|
-
var
|
|
5592
|
+
var a, l, c, g;
|
|
5477
5593
|
const { points: t } = this.transformData;
|
|
5478
5594
|
if (t.length === 0)
|
|
5479
5595
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
5480
|
-
let e = 1 / 0, i = 1 / 0, s = -1 / 0,
|
|
5596
|
+
let e = 1 / 0, i = 1 / 0, s = -1 / 0, r = -1 / 0;
|
|
5481
5597
|
for (let d = 0; d < t.length; d++) {
|
|
5482
5598
|
const f = t[d], u = t[(d + 1) % t.length];
|
|
5483
5599
|
if (d === t.length - 1 && !this.transformData.closed) {
|
|
5484
|
-
e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x),
|
|
5600
|
+
e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), r = Math.max(r, f.y);
|
|
5485
5601
|
break;
|
|
5486
5602
|
}
|
|
5487
|
-
if (e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x),
|
|
5603
|
+
if (e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), r = Math.max(r, f.y), f.handleOut || u.handleIn) {
|
|
5488
5604
|
const p = { x: f.x, y: f.y }, y = {
|
|
5489
|
-
x: f.x + (((
|
|
5605
|
+
x: f.x + (((a = f.handleOut) == null ? void 0 : a.x) || 0),
|
|
5490
5606
|
y: f.y + (((l = f.handleOut) == null ? void 0 : l.y) || 0)
|
|
5491
5607
|
}, w = {
|
|
5492
5608
|
x: u.x + (((c = u.handleIn) == null ? void 0 : c.x) || 0),
|
|
@@ -5494,16 +5610,16 @@ class Et extends Q {
|
|
|
5494
5610
|
}, S = { x: u.x, y: u.y }, b = 20;
|
|
5495
5611
|
for (let v = 0; v <= b; v++) {
|
|
5496
5612
|
const C = v / b, M = this.bezierPoint(p, y, w, S, C);
|
|
5497
|
-
e = Math.min(e, M.x), i = Math.min(i, M.y), s = Math.max(s, M.x),
|
|
5613
|
+
e = Math.min(e, M.x), i = Math.min(i, M.y), s = Math.max(s, M.x), r = Math.max(r, M.y);
|
|
5498
5614
|
}
|
|
5499
5615
|
}
|
|
5500
5616
|
}
|
|
5501
|
-
const
|
|
5617
|
+
const h = this.transformData.strokeEnabled ? this.transformData.strokeWidth || 2 : 0, n = h / 2;
|
|
5502
5618
|
return {
|
|
5503
5619
|
x: e - n,
|
|
5504
5620
|
y: i - n,
|
|
5505
|
-
width: s - e +
|
|
5506
|
-
height:
|
|
5621
|
+
width: s - e + h,
|
|
5622
|
+
height: r - i + h
|
|
5507
5623
|
};
|
|
5508
5624
|
}
|
|
5509
5625
|
/**
|
|
@@ -5517,18 +5633,18 @@ class Et extends Q {
|
|
|
5517
5633
|
* Render the path
|
|
5518
5634
|
*/
|
|
5519
5635
|
render(t, e = !1, i = !1) {
|
|
5520
|
-
const { points: s, closed:
|
|
5636
|
+
const { points: s, closed: r, fillEnabled: h, fillColor: n, fillOpacity: a, strokeEnabled: l, strokeColor: c, strokeWidth: g } = this.transformData;
|
|
5521
5637
|
if (s.length === 0)
|
|
5522
5638
|
return;
|
|
5523
5639
|
t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
|
|
5524
5640
|
const d = this.calculatePathBounds(), f = d.x + d.width / 2, u = d.y + d.height / 2;
|
|
5525
|
-
t.translate(-f, -u), t.beginPath(), this.renderPath(t),
|
|
5641
|
+
t.translate(-f, -u), t.beginPath(), this.renderPath(t), h && r && n && (t.fillStyle = n, t.globalAlpha = a ?? 1, t.fill()), l && c && g && (t.strokeStyle = c, t.lineWidth = g, t.lineCap = "round", t.lineJoin = "round", t.globalAlpha = 1, t.stroke()), t.restore();
|
|
5526
5642
|
}
|
|
5527
5643
|
/**
|
|
5528
5644
|
* Render the path using Canvas API bezier curves
|
|
5529
5645
|
*/
|
|
5530
5646
|
renderPath(t) {
|
|
5531
|
-
var
|
|
5647
|
+
var r, h, n, a;
|
|
5532
5648
|
const { points: e, closed: i } = this.transformData;
|
|
5533
5649
|
if (e.length === 0) return;
|
|
5534
5650
|
const s = e[0];
|
|
@@ -5538,7 +5654,7 @@ class Et extends Q {
|
|
|
5538
5654
|
if (l === e.length - 1 && !i)
|
|
5539
5655
|
break;
|
|
5540
5656
|
if (c.handleOut || g.handleIn) {
|
|
5541
|
-
const f = c.x + (((
|
|
5657
|
+
const f = c.x + (((r = c.handleOut) == null ? void 0 : r.x) || 0), u = c.y + (((h = c.handleOut) == null ? void 0 : h.y) || 0), m = g.x + (((n = g.handleIn) == null ? void 0 : n.x) || 0), p = g.y + (((a = g.handleIn) == null ? void 0 : a.y) || 0);
|
|
5542
5658
|
t.bezierCurveTo(f, u, m, p, g.x, g.y);
|
|
5543
5659
|
} else
|
|
5544
5660
|
t.lineTo(g.x, g.y);
|
|
@@ -5549,10 +5665,10 @@ class Et extends Q {
|
|
|
5549
5665
|
* Handle resize - scale all points relative to center
|
|
5550
5666
|
*/
|
|
5551
5667
|
resize(t, e, i, s) {
|
|
5552
|
-
const
|
|
5553
|
-
if (
|
|
5668
|
+
const r = s.transformData.width, h = s.transformData.height;
|
|
5669
|
+
if (r === 0 || h === 0)
|
|
5554
5670
|
return !1;
|
|
5555
|
-
const n = e /
|
|
5671
|
+
const n = e / r, a = i / h, l = s.transformData.points;
|
|
5556
5672
|
let c = 1 / 0, g = 1 / 0, d = -1 / 0, f = -1 / 0;
|
|
5557
5673
|
for (const b of l)
|
|
5558
5674
|
c = Math.min(c, b.x), g = Math.min(g, b.y), d = Math.max(d, b.x), f = Math.max(f, b.y);
|
|
@@ -5560,9 +5676,9 @@ class Et extends Q {
|
|
|
5560
5676
|
this.transformData.points = l.map((b) => ({
|
|
5561
5677
|
...b,
|
|
5562
5678
|
x: u + (b.x - u) * n,
|
|
5563
|
-
y: m + (b.y - m) *
|
|
5564
|
-
handleIn: b.handleIn ? { x: b.handleIn.x * n, y: b.handleIn.y *
|
|
5565
|
-
handleOut: b.handleOut ? { x: b.handleOut.x * n, y: b.handleOut.y *
|
|
5679
|
+
y: m + (b.y - m) * a,
|
|
5680
|
+
handleIn: b.handleIn ? { x: b.handleIn.x * n, y: b.handleIn.y * a } : void 0,
|
|
5681
|
+
handleOut: b.handleOut ? { x: b.handleOut.x * n, y: b.handleOut.y * a } : void 0
|
|
5566
5682
|
})), this.transformData.width = e, this.transformData.height = i, this.rotation = s.rotation;
|
|
5567
5683
|
const p = this.getFixedCorner(t, s), y = this.getOppositeAnchor(t), w = this.getBoundingBox(), S = this.getCornerOffset(y, w);
|
|
5568
5684
|
return this.x = p.x - S.x, this.y = p.y - S.y, !0;
|
|
@@ -5596,36 +5712,36 @@ class Et extends Q {
|
|
|
5596
5712
|
width: e.transformData.width,
|
|
5597
5713
|
height: e.transformData.height
|
|
5598
5714
|
};
|
|
5599
|
-
let s,
|
|
5715
|
+
let s, r;
|
|
5600
5716
|
switch (t) {
|
|
5601
5717
|
case "top-left":
|
|
5602
|
-
s = i.x + i.width,
|
|
5718
|
+
s = i.x + i.width, r = i.y + i.height;
|
|
5603
5719
|
break;
|
|
5604
5720
|
case "top-right":
|
|
5605
|
-
s = i.x,
|
|
5721
|
+
s = i.x, r = i.y + i.height;
|
|
5606
5722
|
break;
|
|
5607
5723
|
case "bottom-left":
|
|
5608
|
-
s = i.x + i.width,
|
|
5724
|
+
s = i.x + i.width, r = i.y;
|
|
5609
5725
|
break;
|
|
5610
5726
|
case "bottom-right":
|
|
5611
|
-
s = i.x,
|
|
5727
|
+
s = i.x, r = i.y;
|
|
5612
5728
|
break;
|
|
5613
5729
|
case "middle-left":
|
|
5614
|
-
s = i.x + i.width,
|
|
5730
|
+
s = i.x + i.width, r = i.y + i.height / 2;
|
|
5615
5731
|
break;
|
|
5616
5732
|
case "middle-right":
|
|
5617
|
-
s = i.x,
|
|
5733
|
+
s = i.x, r = i.y + i.height / 2;
|
|
5618
5734
|
break;
|
|
5619
5735
|
case "middle-top":
|
|
5620
|
-
s = i.x + i.width / 2,
|
|
5736
|
+
s = i.x + i.width / 2, r = i.y + i.height;
|
|
5621
5737
|
break;
|
|
5622
5738
|
case "middle-bottom":
|
|
5623
|
-
s = i.x + i.width / 2,
|
|
5739
|
+
s = i.x + i.width / 2, r = i.y;
|
|
5624
5740
|
break;
|
|
5625
5741
|
default:
|
|
5626
|
-
s = i.x + i.width / 2,
|
|
5742
|
+
s = i.x + i.width / 2, r = i.y + i.height / 2;
|
|
5627
5743
|
}
|
|
5628
|
-
return { x: s, y:
|
|
5744
|
+
return { x: s, y: r };
|
|
5629
5745
|
}
|
|
5630
5746
|
/**
|
|
5631
5747
|
* Get the offset of a corner from the center
|
|
@@ -5681,7 +5797,7 @@ class Et extends Q {
|
|
|
5681
5797
|
* Clone this element
|
|
5682
5798
|
*/
|
|
5683
5799
|
clone() {
|
|
5684
|
-
return new
|
|
5800
|
+
return new Bt(this.toJSON());
|
|
5685
5801
|
}
|
|
5686
5802
|
/**
|
|
5687
5803
|
* Serialize to JSON
|
|
@@ -5711,7 +5827,7 @@ class Et extends Q {
|
|
|
5711
5827
|
};
|
|
5712
5828
|
}
|
|
5713
5829
|
}
|
|
5714
|
-
const
|
|
5830
|
+
const hi = {
|
|
5715
5831
|
circle: [
|
|
5716
5832
|
{
|
|
5717
5833
|
key: "reverse",
|
|
@@ -5724,77 +5840,77 @@ const Qe = {
|
|
|
5724
5840
|
{
|
|
5725
5841
|
key: "archHeight",
|
|
5726
5842
|
label: "Arch Height",
|
|
5727
|
-
defaultInternalValue:
|
|
5843
|
+
defaultInternalValue: Qe.archHeight,
|
|
5728
5844
|
// Slider 0-100 maps to internal -1 to 1
|
|
5729
|
-
toSlider: (
|
|
5730
|
-
fromSlider: (
|
|
5731
|
-
toDisplay: (
|
|
5845
|
+
toSlider: (o) => (o + 1) / 2 * 100,
|
|
5846
|
+
fromSlider: (o) => o / 100 * 2 - 1,
|
|
5847
|
+
toDisplay: (o) => `${(o * 100).toFixed(0)}%`
|
|
5732
5848
|
}
|
|
5733
5849
|
],
|
|
5734
5850
|
wave: [
|
|
5735
5851
|
{
|
|
5736
5852
|
key: "amplitude",
|
|
5737
5853
|
label: "Wave Amplitude",
|
|
5738
|
-
defaultInternalValue:
|
|
5854
|
+
defaultInternalValue: rt.amplitude,
|
|
5739
5855
|
// Slider 0-100 maps to internal -0.5 to 0.5 (-50% to +50%)
|
|
5740
|
-
toSlider: (
|
|
5741
|
-
fromSlider: (
|
|
5742
|
-
toDisplay: (
|
|
5856
|
+
toSlider: (o) => (o + 0.5) * 100,
|
|
5857
|
+
fromSlider: (o) => o / 100 - 0.5,
|
|
5858
|
+
toDisplay: (o) => `${(o * 100).toFixed(0)}%`
|
|
5743
5859
|
},
|
|
5744
5860
|
{
|
|
5745
5861
|
key: "frequency",
|
|
5746
5862
|
label: "Wave Frequency",
|
|
5747
|
-
defaultInternalValue:
|
|
5863
|
+
defaultInternalValue: rt.frequency,
|
|
5748
5864
|
step: 5,
|
|
5749
5865
|
// 5% steps for smoother control
|
|
5750
5866
|
// Slider 0-100 maps to internal 1 to 5
|
|
5751
|
-
toSlider: (
|
|
5752
|
-
fromSlider: (
|
|
5753
|
-
toDisplay: (
|
|
5867
|
+
toSlider: (o) => (o - 1) / 4 * 100,
|
|
5868
|
+
fromSlider: (o) => 1 + o / 100 * 4,
|
|
5869
|
+
toDisplay: (o) => o.toFixed(1)
|
|
5754
5870
|
}
|
|
5755
5871
|
],
|
|
5756
5872
|
flag: [
|
|
5757
5873
|
{
|
|
5758
5874
|
key: "amplitude",
|
|
5759
5875
|
label: "Flag Amplitude",
|
|
5760
|
-
defaultInternalValue:
|
|
5876
|
+
defaultInternalValue: nt.amplitude,
|
|
5761
5877
|
// Slider 0-100 maps to internal -0.5 to 0.5 (-50% to +50%)
|
|
5762
|
-
toSlider: (
|
|
5763
|
-
fromSlider: (
|
|
5764
|
-
toDisplay: (
|
|
5878
|
+
toSlider: (o) => (o + 0.5) * 100,
|
|
5879
|
+
fromSlider: (o) => o / 100 - 0.5,
|
|
5880
|
+
toDisplay: (o) => `${(o * 100).toFixed(0)}%`
|
|
5765
5881
|
},
|
|
5766
5882
|
{
|
|
5767
5883
|
key: "frequency",
|
|
5768
5884
|
label: "Flag Frequency",
|
|
5769
|
-
defaultInternalValue:
|
|
5885
|
+
defaultInternalValue: nt.frequency,
|
|
5770
5886
|
step: 5,
|
|
5771
|
-
toSlider: (
|
|
5772
|
-
fromSlider: (
|
|
5773
|
-
toDisplay: (
|
|
5887
|
+
toSlider: (o) => (o - 1) / 4 * 100,
|
|
5888
|
+
fromSlider: (o) => 1 + o / 100 * 4,
|
|
5889
|
+
toDisplay: (o) => o.toFixed(1)
|
|
5774
5890
|
}
|
|
5775
5891
|
],
|
|
5776
5892
|
lean: [
|
|
5777
5893
|
{
|
|
5778
5894
|
key: "leanAmount",
|
|
5779
5895
|
label: "Lean Amount",
|
|
5780
|
-
defaultInternalValue:
|
|
5896
|
+
defaultInternalValue: ti.leanAmount,
|
|
5781
5897
|
// Slider 0-100 maps to internal -0.5 to 0.5
|
|
5782
5898
|
// Display as -100% to 100%
|
|
5783
|
-
toSlider: (
|
|
5784
|
-
fromSlider: (
|
|
5785
|
-
toDisplay: (
|
|
5899
|
+
toSlider: (o) => (o + 0.5) * 100,
|
|
5900
|
+
fromSlider: (o) => o / 100 - 0.5,
|
|
5901
|
+
toDisplay: (o) => `${(o * 200).toFixed(0)}%`
|
|
5786
5902
|
}
|
|
5787
5903
|
],
|
|
5788
5904
|
ascend: [
|
|
5789
5905
|
{
|
|
5790
5906
|
key: "ascendAngle",
|
|
5791
5907
|
label: "Ascend Amount",
|
|
5792
|
-
defaultInternalValue:
|
|
5908
|
+
defaultInternalValue: ei.ascendAngle,
|
|
5793
5909
|
// Slider 0-100 maps to internal angle +30° to -30°
|
|
5794
5910
|
// Display: slider 0 = -100% (down), slider 50 = 0%, slider 100 = +100% (up)
|
|
5795
|
-
toSlider: (
|
|
5796
|
-
fromSlider: (
|
|
5797
|
-
toDisplay: (
|
|
5911
|
+
toSlider: (o) => (30 - o) / 60 * 100,
|
|
5912
|
+
fromSlider: (o) => 30 - o / 100 * 60,
|
|
5913
|
+
toDisplay: (o) => `${(-o / 30 * 100).toFixed(0)}%`
|
|
5798
5914
|
}
|
|
5799
5915
|
],
|
|
5800
5916
|
shape: [
|
|
@@ -5818,10 +5934,10 @@ const Qe = {
|
|
|
5818
5934
|
label: "Border Radius",
|
|
5819
5935
|
defaultInternalValue: 0,
|
|
5820
5936
|
// Slider 0-100 maps to internal 0 to 50
|
|
5821
|
-
toSlider: (
|
|
5822
|
-
fromSlider: (
|
|
5823
|
-
toDisplay: (
|
|
5824
|
-
visibleWhen: (
|
|
5937
|
+
toSlider: (o) => o / 50 * 100,
|
|
5938
|
+
fromSlider: (o) => o / 100 * 50,
|
|
5939
|
+
toDisplay: (o) => `${o.toFixed(0)}%`,
|
|
5940
|
+
visibleWhen: (o) => o.shapeType === "rectangle"
|
|
5825
5941
|
},
|
|
5826
5942
|
{
|
|
5827
5943
|
key: "sides",
|
|
@@ -5829,10 +5945,10 @@ const Qe = {
|
|
|
5829
5945
|
defaultInternalValue: 5,
|
|
5830
5946
|
step: 1,
|
|
5831
5947
|
// Slider 0-100 maps to internal 3 to 20
|
|
5832
|
-
toSlider: (
|
|
5833
|
-
fromSlider: (
|
|
5834
|
-
toDisplay: (
|
|
5835
|
-
visibleWhen: (
|
|
5948
|
+
toSlider: (o) => (o - 3) / 17 * 100,
|
|
5949
|
+
fromSlider: (o) => Math.round(3 + o / 100 * 17),
|
|
5950
|
+
toDisplay: (o) => o.toFixed(0),
|
|
5951
|
+
visibleWhen: (o) => o.shapeType === "polygon"
|
|
5836
5952
|
},
|
|
5837
5953
|
{
|
|
5838
5954
|
key: "points",
|
|
@@ -5840,82 +5956,82 @@ const Qe = {
|
|
|
5840
5956
|
defaultInternalValue: 5,
|
|
5841
5957
|
step: 1,
|
|
5842
5958
|
// Slider 0-100 maps to internal 3 to 20
|
|
5843
|
-
toSlider: (
|
|
5844
|
-
fromSlider: (
|
|
5845
|
-
toDisplay: (
|
|
5846
|
-
visibleWhen: (
|
|
5959
|
+
toSlider: (o) => (o - 3) / 17 * 100,
|
|
5960
|
+
fromSlider: (o) => Math.round(3 + o / 100 * 17),
|
|
5961
|
+
toDisplay: (o) => o.toFixed(0),
|
|
5962
|
+
visibleWhen: (o) => o.shapeType === "star"
|
|
5847
5963
|
},
|
|
5848
5964
|
{
|
|
5849
5965
|
key: "innerRadius",
|
|
5850
5966
|
label: "Inner Radius",
|
|
5851
5967
|
defaultInternalValue: 0.4,
|
|
5852
5968
|
// Slider 0-100 maps to internal 0.1 to 0.9
|
|
5853
|
-
toSlider: (
|
|
5854
|
-
fromSlider: (
|
|
5855
|
-
toDisplay: (
|
|
5856
|
-
visibleWhen: (
|
|
5969
|
+
toSlider: (o) => (o - 0.1) / 0.8 * 100,
|
|
5970
|
+
fromSlider: (o) => 0.1 + o / 100 * 0.8,
|
|
5971
|
+
toDisplay: (o) => `${(o * 100).toFixed(0)}%`,
|
|
5972
|
+
visibleWhen: (o) => o.shapeType === "star"
|
|
5857
5973
|
},
|
|
5858
5974
|
{
|
|
5859
5975
|
key: "fillOpacity",
|
|
5860
5976
|
label: "Fill Opacity",
|
|
5861
5977
|
defaultInternalValue: 1,
|
|
5862
5978
|
// Slider 0-100 maps to internal 0 to 1
|
|
5863
|
-
toSlider: (
|
|
5864
|
-
fromSlider: (
|
|
5865
|
-
toDisplay: (
|
|
5979
|
+
toSlider: (o) => o * 100,
|
|
5980
|
+
fromSlider: (o) => o / 100,
|
|
5981
|
+
toDisplay: (o) => `${(o * 100).toFixed(0)}%`
|
|
5866
5982
|
}
|
|
5867
5983
|
]
|
|
5868
|
-
},
|
|
5869
|
-
{ id: "custom", label: "CUSTOM", Component:
|
|
5984
|
+
}, se = [
|
|
5985
|
+
{ id: "custom", label: "CUSTOM", Component: Ve },
|
|
5870
5986
|
// NOTE: distort transform is not yet implemented. Removed from registry
|
|
5871
5987
|
// to prevent it from appearing in UI that iterates over registered transforms.
|
|
5872
5988
|
// Re-add with a valid Component when implementation is ready.
|
|
5873
|
-
{ id: "circle", label: "CIRCLE", Component:
|
|
5874
|
-
{ id: "lean", label: "LEAN", Component:
|
|
5875
|
-
{ id: "arch", label: "ARCH", Component:
|
|
5876
|
-
{ id: "ascend", label: "ASCEND", Component:
|
|
5877
|
-
{ id: "wave", label: "WAVE", Component:
|
|
5878
|
-
{ id: "flag", label: "FLAG", Component:
|
|
5879
|
-
{ id: "shape", label: "SHAPE", Component:
|
|
5880
|
-
{ id: "path", label: "PATH", Component:
|
|
5881
|
-
{ id: "image", label: "IMAGE", Component:
|
|
5989
|
+
{ id: "circle", label: "CIRCLE", Component: Ze },
|
|
5990
|
+
{ id: "lean", label: "LEAN", Component: oi },
|
|
5991
|
+
{ id: "arch", label: "ARCH", Component: Ke },
|
|
5992
|
+
{ id: "ascend", label: "ASCEND", Component: ri },
|
|
5993
|
+
{ id: "wave", label: "WAVE", Component: ii },
|
|
5994
|
+
{ id: "flag", label: "FLAG", Component: si },
|
|
5995
|
+
{ id: "shape", label: "SHAPE", Component: Ot },
|
|
5996
|
+
{ id: "path", label: "PATH", Component: Bt },
|
|
5997
|
+
{ id: "image", label: "IMAGE", Component: bt },
|
|
5882
5998
|
// Use a getter to break circular dependency: GroupElement imports getTransformById
|
|
5883
5999
|
// from this module, so GroupElement may be in the TDZ during module evaluation.
|
|
5884
6000
|
// The getter defers access until runtime when both modules are fully initialized.
|
|
5885
6001
|
{ id: "group", label: "GROUP", get Component() {
|
|
5886
|
-
return
|
|
6002
|
+
return yt;
|
|
5887
6003
|
} }
|
|
5888
|
-
],
|
|
5889
|
-
function
|
|
5890
|
-
if (
|
|
6004
|
+
], oe = new Set(se.map((o) => o.id)), pt = /* @__PURE__ */ new Map();
|
|
6005
|
+
function Ts(o, t) {
|
|
6006
|
+
if (oe.has(o))
|
|
5891
6007
|
throw new Error(
|
|
5892
|
-
`Cannot register transform type "${
|
|
6008
|
+
`Cannot register transform type "${o}": conflicts with built-in type`
|
|
5893
6009
|
);
|
|
5894
|
-
if (
|
|
6010
|
+
if (pt.has(o))
|
|
5895
6011
|
throw new Error(
|
|
5896
|
-
`Cannot register transform type "${
|
|
6012
|
+
`Cannot register transform type "${o}": already registered as a custom type`
|
|
5897
6013
|
);
|
|
5898
|
-
|
|
6014
|
+
pt.set(o, t);
|
|
5899
6015
|
}
|
|
5900
|
-
function
|
|
5901
|
-
if (
|
|
6016
|
+
function Fs(o) {
|
|
6017
|
+
if (oe.has(o))
|
|
5902
6018
|
throw new Error(
|
|
5903
|
-
`Cannot unregister transform type "${
|
|
6019
|
+
`Cannot unregister transform type "${o}": built-in types cannot be removed`
|
|
5904
6020
|
);
|
|
5905
|
-
return
|
|
6021
|
+
return pt.delete(o);
|
|
5906
6022
|
}
|
|
5907
|
-
function
|
|
5908
|
-
const t =
|
|
5909
|
-
return t ||
|
|
6023
|
+
function li(o) {
|
|
6024
|
+
const t = se.find((e) => e.id === o);
|
|
6025
|
+
return t || pt.get(o);
|
|
5910
6026
|
}
|
|
5911
|
-
function
|
|
5912
|
-
return
|
|
6027
|
+
function As(o) {
|
|
6028
|
+
return hi[o] || [];
|
|
5913
6029
|
}
|
|
5914
|
-
class
|
|
6030
|
+
class yt extends tt {
|
|
5915
6031
|
constructor(t = {}) {
|
|
5916
6032
|
super(t), this.isGroup = !0, this._baseBBoxWidth = 0, this._baseBBoxHeight = 0, this._rotationCenterX = 0, this._rotationCenterY = 0, this.transformType = "group";
|
|
5917
6033
|
const e = t.children || [];
|
|
5918
|
-
this.children = e.map((i) => i instanceof
|
|
6034
|
+
this.children = e.map((i) => i instanceof tt ? i : this._reconstructChildFromJSON(i)), this.transformData = {
|
|
5919
6035
|
type: "group"
|
|
5920
6036
|
}, this.children.length > 0 && this.updateBoundsFromChildren(!0);
|
|
5921
6037
|
}
|
|
@@ -5926,7 +6042,7 @@ class mt extends Q {
|
|
|
5926
6042
|
*/
|
|
5927
6043
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- JSON deserialization: config comes from toJSON() and constructors accept Partial<Config> with varying signatures
|
|
5928
6044
|
_reconstructChildFromJSON(t) {
|
|
5929
|
-
const e = t.transformType || t.type, i =
|
|
6045
|
+
const e = t.transformType || t.type, i = li(e);
|
|
5930
6046
|
if (!i || !i.Component)
|
|
5931
6047
|
throw new Error(`Unknown transform type: ${e}`);
|
|
5932
6048
|
return new i.Component(t);
|
|
@@ -5939,10 +6055,10 @@ class mt extends Q {
|
|
|
5939
6055
|
if (this.children.length === 0)
|
|
5940
6056
|
return { x: this.x - 50, y: this.y - 50, width: 100, height: 100 };
|
|
5941
6057
|
let t = 1 / 0, e = 1 / 0, i = -1 / 0, s = -1 / 0;
|
|
5942
|
-
return this.children.forEach((
|
|
5943
|
-
const
|
|
5944
|
-
this._getRotatedCorners(
|
|
5945
|
-
t = Math.min(t,
|
|
6058
|
+
return this.children.forEach((r) => {
|
|
6059
|
+
const h = r.getVisualBoundingBox();
|
|
6060
|
+
this._getRotatedCorners(r, h).forEach((a) => {
|
|
6061
|
+
t = Math.min(t, a.x), e = Math.min(e, a.y), i = Math.max(i, a.x), s = Math.max(s, a.y);
|
|
5946
6062
|
});
|
|
5947
6063
|
}), {
|
|
5948
6064
|
x: t,
|
|
@@ -5972,12 +6088,12 @@ class mt extends Q {
|
|
|
5972
6088
|
* Get the four corners of an element's bounding box in world space
|
|
5973
6089
|
*/
|
|
5974
6090
|
_getRotatedCorners(t, e) {
|
|
5975
|
-
const i = new P(t), s = e.x + e.width / 2,
|
|
6091
|
+
const i = new P(t), s = e.x + e.width / 2, r = e.y + e.height / 2, h = s - t.x, n = r - t.y;
|
|
5976
6092
|
return [
|
|
5977
|
-
{ localX:
|
|
5978
|
-
{ localX:
|
|
5979
|
-
{ localX:
|
|
5980
|
-
{ localX:
|
|
6093
|
+
{ localX: h - e.width / 2, localY: n - e.height / 2 },
|
|
6094
|
+
{ localX: h + e.width / 2, localY: n - e.height / 2 },
|
|
6095
|
+
{ localX: h - e.width / 2, localY: n + e.height / 2 },
|
|
6096
|
+
{ localX: h + e.width / 2, localY: n + e.height / 2 }
|
|
5981
6097
|
].map((l) => i.localToWorld(l.localX, l.localY));
|
|
5982
6098
|
}
|
|
5983
6099
|
/**
|
|
@@ -6012,9 +6128,9 @@ class mt extends Q {
|
|
|
6012
6128
|
* Elements with isClipping=true clip all elements below them in the group
|
|
6013
6129
|
*/
|
|
6014
6130
|
render(t, e = !1, i = !1) {
|
|
6015
|
-
const s = this.children.filter((
|
|
6016
|
-
s.some((
|
|
6017
|
-
|
|
6131
|
+
const s = this.children.filter((h) => h.visible !== !1);
|
|
6132
|
+
s.some((h) => h.isClipping) ? Le()(t, s) : s.forEach((h) => {
|
|
6133
|
+
h.render(t, !1);
|
|
6018
6134
|
}), e ? this._renderGroupOutline(t, 1) : i && this._renderGroupOutline(t, 0.3);
|
|
6019
6135
|
}
|
|
6020
6136
|
/**
|
|
@@ -6023,9 +6139,9 @@ class mt extends Q {
|
|
|
6023
6139
|
*/
|
|
6024
6140
|
_renderGroupOutline(t, e = 1) {
|
|
6025
6141
|
const i = this.getOrientedBoundingBox();
|
|
6026
|
-
t.save(), t.globalAlpha = e, t.strokeStyle =
|
|
6027
|
-
const s = this._rotationCenterX || this.x,
|
|
6028
|
-
this.rotation !== 0 && (t.translate(s,
|
|
6142
|
+
t.save(), t.globalAlpha = e, t.strokeStyle = Vt(), t.lineWidth = 2, t.setLineDash([5, 5]);
|
|
6143
|
+
const s = this._rotationCenterX || this.x, r = this._rotationCenterY || this.y;
|
|
6144
|
+
this.rotation !== 0 && (t.translate(s, r), t.rotate(-this.rotation * Math.PI / 180), t.translate(-s, -r)), t.strokeRect(i.x, i.y, i.width, i.height), t.setLineDash([]), t.restore();
|
|
6029
6145
|
}
|
|
6030
6146
|
/**
|
|
6031
6147
|
* Get oriented bounding box (uses cached base dimensions for stability during rotation)
|
|
@@ -6042,8 +6158,8 @@ class mt extends Q {
|
|
|
6042
6158
|
if (this._baseBBoxWidth > 0 && this._baseBBoxHeight > 0)
|
|
6043
6159
|
t = this._baseBBoxWidth, e = this._baseBBoxHeight;
|
|
6044
6160
|
else {
|
|
6045
|
-
const
|
|
6046
|
-
t =
|
|
6161
|
+
const r = this.getBoundingBox();
|
|
6162
|
+
t = r.width, e = r.height, this._baseBBoxWidth = t, this._baseBBoxHeight = e;
|
|
6047
6163
|
}
|
|
6048
6164
|
const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
|
|
6049
6165
|
return {
|
|
@@ -6068,9 +6184,9 @@ class mt extends Q {
|
|
|
6068
6184
|
const e = t - this.rotation;
|
|
6069
6185
|
this.rotation = t;
|
|
6070
6186
|
const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
|
|
6071
|
-
this.children.forEach((
|
|
6072
|
-
const
|
|
6073
|
-
|
|
6187
|
+
this.children.forEach((r) => {
|
|
6188
|
+
const h = P.rotatePointAroundAnchor(r.x, r.y, i, s, e);
|
|
6189
|
+
r.x = h.x, r.y = h.y, r.setRotation(r.rotation + e);
|
|
6074
6190
|
}), this.x = i, this.y = s;
|
|
6075
6191
|
}
|
|
6076
6192
|
/**
|
|
@@ -6080,31 +6196,31 @@ class mt extends Q {
|
|
|
6080
6196
|
resize(t, e, i, s) {
|
|
6081
6197
|
if (!s.childrenStartData || !s.width || !s.height)
|
|
6082
6198
|
return;
|
|
6083
|
-
const
|
|
6084
|
-
let
|
|
6199
|
+
const r = e / s.width, h = i / s.height, n = (r + h) / 2;
|
|
6200
|
+
let a, l;
|
|
6085
6201
|
switch (t) {
|
|
6086
6202
|
case "top-left":
|
|
6087
|
-
|
|
6203
|
+
a = s.width / 2, l = s.height / 2;
|
|
6088
6204
|
break;
|
|
6089
6205
|
case "top-right":
|
|
6090
|
-
|
|
6206
|
+
a = -s.width / 2, l = s.height / 2;
|
|
6091
6207
|
break;
|
|
6092
6208
|
case "bottom-left":
|
|
6093
|
-
|
|
6209
|
+
a = s.width / 2, l = -s.height / 2;
|
|
6094
6210
|
break;
|
|
6095
6211
|
case "bottom-right":
|
|
6096
|
-
|
|
6212
|
+
a = -s.width / 2, l = -s.height / 2;
|
|
6097
6213
|
break;
|
|
6098
6214
|
default:
|
|
6099
|
-
|
|
6215
|
+
a = 0, l = 0;
|
|
6100
6216
|
}
|
|
6101
|
-
const c = -s.rotation * Math.PI / 180, g = Math.cos(c), d = Math.sin(c), f = s.x + (
|
|
6217
|
+
const c = -s.rotation * Math.PI / 180, g = Math.cos(c), d = Math.sin(c), f = s.x + (a * g - l * d), u = s.y + (a * d + l * g);
|
|
6102
6218
|
this.children.forEach((y, w) => {
|
|
6103
6219
|
const S = s.childrenStartData[w], b = S.x - f, v = S.y - u, C = f + b * n, M = u + v * n;
|
|
6104
|
-
if (y.x = C, y.y = M, y instanceof
|
|
6220
|
+
if (y.x = C, y.y = M, y instanceof bt) {
|
|
6105
6221
|
const F = S.transformData, T = F.width * n, D = F.height * n;
|
|
6106
6222
|
y.transformData.width = T, y.transformData.height = D;
|
|
6107
|
-
} else if (y instanceof
|
|
6223
|
+
} else if (y instanceof yt) {
|
|
6108
6224
|
const F = (S.width ?? 0) * n, T = (S.height ?? 0) * n;
|
|
6109
6225
|
y.resize(t, F, T, S);
|
|
6110
6226
|
} else {
|
|
@@ -6129,7 +6245,7 @@ class mt extends Q {
|
|
|
6129
6245
|
height: e,
|
|
6130
6246
|
rotation: this.rotation,
|
|
6131
6247
|
transformData: this.transformData,
|
|
6132
|
-
childrenStartData: this.children.map((
|
|
6248
|
+
childrenStartData: this.children.map((r) => r.getTransformStartData())
|
|
6133
6249
|
};
|
|
6134
6250
|
}
|
|
6135
6251
|
/**
|
|
@@ -6137,10 +6253,10 @@ class mt extends Q {
|
|
|
6137
6253
|
* This allows clicking anywhere within the selection border to drag the group
|
|
6138
6254
|
*/
|
|
6139
6255
|
hitTest(t, e) {
|
|
6140
|
-
const i = this.getOrientedBoundingBox(), s = this._rotationCenterX || this.x,
|
|
6256
|
+
const i = this.getOrientedBoundingBox(), s = this._rotationCenterX || this.x, r = this._rotationCenterY || this.y;
|
|
6141
6257
|
if (this.rotation === 0)
|
|
6142
6258
|
return t >= i.x && t <= i.x + i.width && e >= i.y && e <= i.y + i.height;
|
|
6143
|
-
const
|
|
6259
|
+
const h = this.rotation * Math.PI / 180, n = Math.cos(h), a = Math.sin(h), l = t - s, c = e - r, g = s + (l * n - c * a), d = r + (l * a + c * n);
|
|
6144
6260
|
return g >= i.x && g <= i.x + i.width && d >= i.y && d <= i.y + i.height;
|
|
6145
6261
|
}
|
|
6146
6262
|
/**
|
|
@@ -6166,7 +6282,7 @@ class mt extends Q {
|
|
|
6166
6282
|
* Clone the group (deep copy with children)
|
|
6167
6283
|
*/
|
|
6168
6284
|
clone() {
|
|
6169
|
-
const t = this.children.map((i) => i.clone()), e = new
|
|
6285
|
+
const t = this.children.map((i) => i.clone()), e = new yt({
|
|
6170
6286
|
id: this.id,
|
|
6171
6287
|
x: this.x,
|
|
6172
6288
|
y: this.y,
|
|
@@ -6180,7 +6296,7 @@ class mt extends Q {
|
|
|
6180
6296
|
}), this.masks && (e.masks = this.masks.map((i) => ({
|
|
6181
6297
|
...i,
|
|
6182
6298
|
maskElement: structuredClone(i.maskElement)
|
|
6183
|
-
}))), this.distressEffect && (e.distressEffect = { ...this.distressEffect }), e;
|
|
6299
|
+
}))), this.distressEffect && (e.distressEffect = { ...this.distressEffect }), this.shadow && (e.shadow = { ...this.shadow }), e;
|
|
6184
6300
|
}
|
|
6185
6301
|
/**
|
|
6186
6302
|
* Add a child to the group
|
|
@@ -6214,7 +6330,7 @@ class mt extends Q {
|
|
|
6214
6330
|
return null;
|
|
6215
6331
|
}
|
|
6216
6332
|
}
|
|
6217
|
-
class
|
|
6333
|
+
class K {
|
|
6218
6334
|
constructor(t) {
|
|
6219
6335
|
if (this._cachedArray = null, this.byId = /* @__PURE__ */ new Map(), this.order = [], t)
|
|
6220
6336
|
for (const e of t)
|
|
@@ -6310,7 +6426,7 @@ class Z {
|
|
|
6310
6426
|
* (e.g., reordering by an ID array from undo/redo).
|
|
6311
6427
|
*/
|
|
6312
6428
|
replaceAll(t) {
|
|
6313
|
-
return new
|
|
6429
|
+
return new K(t);
|
|
6314
6430
|
}
|
|
6315
6431
|
/**
|
|
6316
6432
|
* Filter elements by predicate while preserving order.
|
|
@@ -6318,7 +6434,7 @@ class Z {
|
|
|
6318
6434
|
*/
|
|
6319
6435
|
filter(t) {
|
|
6320
6436
|
const e = this.getAll().filter(t);
|
|
6321
|
-
return new
|
|
6437
|
+
return new K(e);
|
|
6322
6438
|
}
|
|
6323
6439
|
/**
|
|
6324
6440
|
* Map over elements in render order, returning a new store.
|
|
@@ -6326,7 +6442,7 @@ class Z {
|
|
|
6326
6442
|
*/
|
|
6327
6443
|
map(t) {
|
|
6328
6444
|
const e = this.getAll().map(t);
|
|
6329
|
-
return new
|
|
6445
|
+
return new K(e);
|
|
6330
6446
|
}
|
|
6331
6447
|
/**
|
|
6332
6448
|
* Set a completely new ordering for all elements.
|
|
@@ -6345,29 +6461,17 @@ class Z {
|
|
|
6345
6461
|
}
|
|
6346
6462
|
/** Create from a plain array. */
|
|
6347
6463
|
static fromArray(t) {
|
|
6348
|
-
return new
|
|
6464
|
+
return new K(t);
|
|
6349
6465
|
}
|
|
6350
6466
|
// ---------------------------------------------------------------------------
|
|
6351
6467
|
// Internal
|
|
6352
6468
|
// ---------------------------------------------------------------------------
|
|
6353
6469
|
/** Create a shallow clone (new Map/Array, same element references). */
|
|
6354
6470
|
clone() {
|
|
6355
|
-
const t = new
|
|
6471
|
+
const t = new K();
|
|
6356
6472
|
return t.byId = new Map(this.byId), t.order = [...this.order], t;
|
|
6357
6473
|
}
|
|
6358
6474
|
}
|
|
6359
|
-
class us extends Error {
|
|
6360
|
-
constructor(t, e, i = {}) {
|
|
6361
|
-
super(`[Editor] ${t}: ${e}`), this.name = "EditorError", this.code = t, this.data = { code: t, ...i };
|
|
6362
|
-
}
|
|
6363
|
-
}
|
|
6364
|
-
function ms(r) {
|
|
6365
|
-
return r instanceof Error && r.name === "EditorError" && "code" in r;
|
|
6366
|
-
}
|
|
6367
|
-
function ps() {
|
|
6368
|
-
var r;
|
|
6369
|
-
return typeof ft < "u" && ((r = ft.env) == null ? void 0 : r.NODE_ENV) !== "production";
|
|
6370
|
-
}
|
|
6371
6475
|
class $ {
|
|
6372
6476
|
/**
|
|
6373
6477
|
* Execute the command
|
|
@@ -6382,7 +6486,7 @@ class $ {
|
|
|
6382
6486
|
throw new Error("Command.undo() must be implemented");
|
|
6383
6487
|
}
|
|
6384
6488
|
}
|
|
6385
|
-
class
|
|
6489
|
+
class Ms extends $ {
|
|
6386
6490
|
constructor(t, e, i, s) {
|
|
6387
6491
|
super(), this.elementId = t, this.oldElement = e ? e.clone() : null, this.newElement = i ? i.clone() : null, this.onUpdate = s;
|
|
6388
6492
|
}
|
|
@@ -6393,7 +6497,7 @@ class ys extends $ {
|
|
|
6393
6497
|
this.oldElement && this.onUpdate(this.oldElement);
|
|
6394
6498
|
}
|
|
6395
6499
|
}
|
|
6396
|
-
class
|
|
6500
|
+
class Ds extends $ {
|
|
6397
6501
|
constructor(t, e, i) {
|
|
6398
6502
|
super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
|
|
6399
6503
|
}
|
|
@@ -6404,7 +6508,7 @@ class ws extends $ {
|
|
|
6404
6508
|
this.onRemove(this.element.id);
|
|
6405
6509
|
}
|
|
6406
6510
|
}
|
|
6407
|
-
class
|
|
6511
|
+
class Is extends $ {
|
|
6408
6512
|
constructor(t, e, i) {
|
|
6409
6513
|
super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
|
|
6410
6514
|
}
|
|
@@ -6415,7 +6519,7 @@ class bs extends $ {
|
|
|
6415
6519
|
this.onAdd(this.element);
|
|
6416
6520
|
}
|
|
6417
6521
|
}
|
|
6418
|
-
class
|
|
6522
|
+
class ci extends $ {
|
|
6419
6523
|
constructor(t) {
|
|
6420
6524
|
super(), this.commands = t;
|
|
6421
6525
|
}
|
|
@@ -6427,7 +6531,7 @@ class ei extends $ {
|
|
|
6427
6531
|
this.commands[t].undo();
|
|
6428
6532
|
}
|
|
6429
6533
|
}
|
|
6430
|
-
class
|
|
6534
|
+
class gt {
|
|
6431
6535
|
constructor(t = 50) {
|
|
6432
6536
|
this.history = [], this.currentIndex = -1, this.maxSize = t;
|
|
6433
6537
|
}
|
|
@@ -6447,7 +6551,7 @@ class ct {
|
|
|
6447
6551
|
executeBatch(t) {
|
|
6448
6552
|
if (t.length === 0)
|
|
6449
6553
|
return;
|
|
6450
|
-
const e = new
|
|
6554
|
+
const e = new ci(t);
|
|
6451
6555
|
this.execute(e);
|
|
6452
6556
|
}
|
|
6453
6557
|
/**
|
|
@@ -6492,7 +6596,7 @@ class ct {
|
|
|
6492
6596
|
};
|
|
6493
6597
|
}
|
|
6494
6598
|
}
|
|
6495
|
-
class
|
|
6599
|
+
class ks extends $ {
|
|
6496
6600
|
constructor(t, e) {
|
|
6497
6601
|
super(), this.artboard = t.clone(), this.artboardManager = e;
|
|
6498
6602
|
}
|
|
@@ -6512,7 +6616,7 @@ class xs extends $ {
|
|
|
6512
6616
|
this.artboardManager.deleteArtboard(this.artboard.id);
|
|
6513
6617
|
}
|
|
6514
6618
|
}
|
|
6515
|
-
class
|
|
6619
|
+
class Es extends $ {
|
|
6516
6620
|
constructor(t, e) {
|
|
6517
6621
|
super(), this.artboard = t.clone(), this.artboardManager = e, this.elementsOnArtboard = t.getElementIds();
|
|
6518
6622
|
}
|
|
@@ -6535,7 +6639,7 @@ class Ss extends $ {
|
|
|
6535
6639
|
});
|
|
6536
6640
|
}
|
|
6537
6641
|
}
|
|
6538
|
-
class
|
|
6642
|
+
class Os extends $ {
|
|
6539
6643
|
constructor(t, e, i, s) {
|
|
6540
6644
|
super(), this.artboardId = t, this.oldProperties = { ...e }, this.newProperties = { ...i }, this.artboardManager = s;
|
|
6541
6645
|
}
|
|
@@ -6546,9 +6650,9 @@ class Cs extends $ {
|
|
|
6546
6650
|
this.artboardManager.updateArtboard(this.artboardId, this.oldProperties);
|
|
6547
6651
|
}
|
|
6548
6652
|
}
|
|
6549
|
-
class
|
|
6550
|
-
constructor(t, e, i, s,
|
|
6551
|
-
super(), this.draggedId = t, this.targetId = e, this.position = i, this.oldOrder = [...s], this.onReorder =
|
|
6653
|
+
class Bs extends $ {
|
|
6654
|
+
constructor(t, e, i, s, r) {
|
|
6655
|
+
super(), this.draggedId = t, this.targetId = e, this.position = i, this.oldOrder = [...s], this.onReorder = r, this.newOrder = this.calculateNewOrder();
|
|
6552
6656
|
}
|
|
6553
6657
|
calculateNewOrder() {
|
|
6554
6658
|
const t = [...this.oldOrder], e = t.indexOf(this.draggedId);
|
|
@@ -6566,10 +6670,10 @@ class vs extends $ {
|
|
|
6566
6670
|
this.onReorder(this.oldOrder);
|
|
6567
6671
|
}
|
|
6568
6672
|
}
|
|
6569
|
-
const
|
|
6570
|
-
class
|
|
6673
|
+
const di = wt("HybridHistoryManager");
|
|
6674
|
+
class Rs {
|
|
6571
6675
|
constructor(t, e = 50) {
|
|
6572
|
-
this.commandExecutedCallbacks = [], this.globalHistory = new
|
|
6676
|
+
this.commandExecutedCallbacks = [], this.globalHistory = new gt(e), this.artboardHistories = /* @__PURE__ */ new Map(), this.lastOperation = null, this.artboardManager = t, this.maxHistorySize = e;
|
|
6573
6677
|
}
|
|
6574
6678
|
/**
|
|
6575
6679
|
* Register a callback to be called whenever a command is executed
|
|
@@ -6588,8 +6692,8 @@ class Ts {
|
|
|
6588
6692
|
for (const s of this.commandExecutedCallbacks)
|
|
6589
6693
|
try {
|
|
6590
6694
|
s(t, e, i);
|
|
6591
|
-
} catch (
|
|
6592
|
-
|
|
6695
|
+
} catch (r) {
|
|
6696
|
+
di.error("Error in command executed callback:", r);
|
|
6593
6697
|
}
|
|
6594
6698
|
}
|
|
6595
6699
|
/**
|
|
@@ -6623,7 +6727,7 @@ class Ts {
|
|
|
6623
6727
|
if (e.length === 0)
|
|
6624
6728
|
return;
|
|
6625
6729
|
let i = this.artboardHistories.get(t);
|
|
6626
|
-
i || (i = new
|
|
6730
|
+
i || (i = new gt(this.maxHistorySize), this.artboardHistories.set(t, i)), i.executeBatch(e), this.lastOperation = {
|
|
6627
6731
|
type: "artboard",
|
|
6628
6732
|
artboardId: t,
|
|
6629
6733
|
timestamp: Date.now()
|
|
@@ -6636,7 +6740,7 @@ class Ts {
|
|
|
6636
6740
|
*/
|
|
6637
6741
|
executeOnArtboard(t, e) {
|
|
6638
6742
|
let i = this.artboardHistories.get(t);
|
|
6639
|
-
i || (i = new
|
|
6743
|
+
i || (i = new gt(this.maxHistorySize), this.artboardHistories.set(t, i)), i.execute(e), this.lastOperation = {
|
|
6640
6744
|
type: "artboard",
|
|
6641
6745
|
artboardId: t,
|
|
6642
6746
|
timestamp: Date.now()
|
|
@@ -6782,7 +6886,7 @@ class Ts {
|
|
|
6782
6886
|
*/
|
|
6783
6887
|
getArtboardHistory(t) {
|
|
6784
6888
|
let e = this.artboardHistories.get(t);
|
|
6785
|
-
return e || (e = new
|
|
6889
|
+
return e || (e = new gt(this.maxHistorySize), this.artboardHistories.set(t, e)), e;
|
|
6786
6890
|
}
|
|
6787
6891
|
/**
|
|
6788
6892
|
* Get global history
|
|
@@ -6796,11 +6900,11 @@ class Ts {
|
|
|
6796
6900
|
getState() {
|
|
6797
6901
|
const t = this.globalHistory.getState(), e = /* @__PURE__ */ new Map();
|
|
6798
6902
|
return this.artboardHistories.forEach((i, s) => {
|
|
6799
|
-
const
|
|
6903
|
+
const r = i.getState();
|
|
6800
6904
|
e.set(s, {
|
|
6801
|
-
canUndo:
|
|
6802
|
-
canRedo:
|
|
6803
|
-
historySize:
|
|
6905
|
+
canUndo: r.canUndo,
|
|
6906
|
+
canRedo: r.canRedo,
|
|
6907
|
+
historySize: r.historySize
|
|
6804
6908
|
});
|
|
6805
6909
|
}), {
|
|
6806
6910
|
global: {
|
|
@@ -6861,12 +6965,12 @@ class Ts {
|
|
|
6861
6965
|
return this.canRedoGlobal() ? "Redo artboard operation" : "Nothing to redo";
|
|
6862
6966
|
}
|
|
6863
6967
|
}
|
|
6864
|
-
const G =
|
|
6865
|
-
let
|
|
6866
|
-
async function
|
|
6867
|
-
return
|
|
6968
|
+
const G = wt("FontAnalyzer");
|
|
6969
|
+
let vt = null;
|
|
6970
|
+
async function gi() {
|
|
6971
|
+
return vt || (vt = await import("./browser-module-DFvKXBUE.js")), vt;
|
|
6868
6972
|
}
|
|
6869
|
-
class
|
|
6973
|
+
class fi {
|
|
6870
6974
|
constructor() {
|
|
6871
6975
|
this.fontCache = /* @__PURE__ */ new Map(), this.failedFonts = /* @__PURE__ */ new Set(), this.CACHE_DURATION = 1e3 * 60 * 30, this.MAX_CACHE_SIZE = 5;
|
|
6872
6976
|
}
|
|
@@ -6886,7 +6990,7 @@ class oi {
|
|
|
6886
6990
|
* Check if a font is a system font
|
|
6887
6991
|
*/
|
|
6888
6992
|
isSystemFont(t) {
|
|
6889
|
-
return
|
|
6993
|
+
return Me.has(t);
|
|
6890
6994
|
}
|
|
6891
6995
|
/**
|
|
6892
6996
|
* Get Google Fonts API URL for a specific font family
|
|
@@ -6899,18 +7003,18 @@ class oi {
|
|
|
6899
7003
|
*/
|
|
6900
7004
|
async extractFontFileUrl(t, e = 400) {
|
|
6901
7005
|
try {
|
|
6902
|
-
const i = this.getGoogleFontUrl(t, e),
|
|
7006
|
+
const i = this.getGoogleFontUrl(t, e), r = await (await fetch(i)).text(), h = /@font-face\s*{([^}]*)}/g, n = Array.from(r.matchAll(h));
|
|
6903
7007
|
if (n.length === 0)
|
|
6904
7008
|
return G.warn("No @font-face found in CSS"), null;
|
|
6905
|
-
let
|
|
7009
|
+
let a = null, l = -1;
|
|
6906
7010
|
for (let c = 0; c < n.length; c++) {
|
|
6907
7011
|
const g = n[c][1], d = g.match(/url\((https:\/\/fonts\.gstatic\.com\/[^)]+)\)/), f = g.includes("unicode-range"), u = g.match(/unicode-range:\s*([^;]+);/);
|
|
6908
7012
|
if (!d) continue;
|
|
6909
7013
|
const m = d[1];
|
|
6910
7014
|
let p = 0;
|
|
6911
|
-
f ? u && (p = (u[1].match(/U\+/g) || []).length) : p = 1e3, p > l && (l = p,
|
|
7015
|
+
f ? u && (p = (u[1].match(/U\+/g) || []).length) : p = 1e3, p > l && (l = p, a = m);
|
|
6912
7016
|
}
|
|
6913
|
-
return
|
|
7017
|
+
return a || (G.warn("No font URL found in CSS for", t), null);
|
|
6914
7018
|
} catch (i) {
|
|
6915
7019
|
return G.error("Error extracting font file URL:", i), null;
|
|
6916
7020
|
}
|
|
@@ -6928,20 +7032,20 @@ class oi {
|
|
|
6928
7032
|
if (s && Date.now() - s.timestamp < this.CACHE_DURATION)
|
|
6929
7033
|
return s.timestamp = Date.now(), s.font;
|
|
6930
7034
|
try {
|
|
6931
|
-
const
|
|
6932
|
-
if (!
|
|
7035
|
+
const r = await this.extractFontFileUrl(t, e);
|
|
7036
|
+
if (!r)
|
|
6933
7037
|
return this.failedFonts.add(i), null;
|
|
6934
|
-
const
|
|
6935
|
-
if (!
|
|
6936
|
-
return G.error(`Font fetch failed: ${
|
|
6937
|
-
const n = await
|
|
7038
|
+
const h = await fetch(r);
|
|
7039
|
+
if (!h.ok)
|
|
7040
|
+
return G.error(`Font fetch failed: ${h.status} ${h.statusText}`), this.failedFonts.add(i), null;
|
|
7041
|
+
const n = await h.arrayBuffer(), a = new Uint8Array(n), c = (await gi()).create(a), g = "fonts" in c ? c.fonts[0] : c;
|
|
6938
7042
|
return this.fontCache.set(i, {
|
|
6939
7043
|
font: g,
|
|
6940
|
-
url:
|
|
7044
|
+
url: r,
|
|
6941
7045
|
timestamp: Date.now()
|
|
6942
7046
|
}), this.evictOldestFont(), g;
|
|
6943
|
-
} catch (
|
|
6944
|
-
return G.error(`Error loading font ${t}:`,
|
|
7047
|
+
} catch (r) {
|
|
7048
|
+
return G.error(`Error loading font ${t}:`, r), this.failedFonts.add(i), null;
|
|
6945
7049
|
}
|
|
6946
7050
|
}
|
|
6947
7051
|
/**
|
|
@@ -6967,14 +7071,14 @@ class oi {
|
|
|
6967
7071
|
* Get all glyphs in a font (for browsing)
|
|
6968
7072
|
*/
|
|
6969
7073
|
async getAllGlyphs(t, e = 400, i = 1500) {
|
|
6970
|
-
var n,
|
|
7074
|
+
var n, a;
|
|
6971
7075
|
if (this.isSystemFont(t))
|
|
6972
7076
|
return [];
|
|
6973
7077
|
const s = await this.loadFont(t, e);
|
|
6974
7078
|
if (!s)
|
|
6975
7079
|
return [];
|
|
6976
|
-
const
|
|
6977
|
-
for (let l = 0; l <
|
|
7080
|
+
const r = [], h = Math.min(s.numGlyphs, i);
|
|
7081
|
+
for (let l = 0; l < h; l++)
|
|
6978
7082
|
try {
|
|
6979
7083
|
const c = s.getGlyph(l);
|
|
6980
7084
|
if (!c || !c.name || c.name === ".notdef" || c.name.startsWith(".null"))
|
|
@@ -6993,7 +7097,7 @@ class oi {
|
|
|
6993
7097
|
const p = ((n = c.name.match(/\.alt(\d+)/)) == null ? void 0 : n[1]) || "";
|
|
6994
7098
|
f = `${d} Alternate${p ? " " + p : ""}`;
|
|
6995
7099
|
} else if (c.name.match(/\.ss(\d+)/)) {
|
|
6996
|
-
const p = (
|
|
7100
|
+
const p = (a = c.name.match(/\.ss(\d+)/)) == null ? void 0 : a[1];
|
|
6997
7101
|
f = `${d} Stylistic Set ${p}`;
|
|
6998
7102
|
} else
|
|
6999
7103
|
f = `${d} - ${c.name}`;
|
|
@@ -7001,7 +7105,7 @@ class oi {
|
|
|
7001
7105
|
const m = c.name.toLowerCase();
|
|
7002
7106
|
if (m.includes("swash") || m.includes("cswh") ? u = "swash" : c.name.match(/\.(alt|ss\d+|cv\d+|salt|ornament)/) || c.name.match(/_\d+$/) ? u = "stylistic" : m.match(/liga|dlig/) && (u = "ligature"), u === "default")
|
|
7003
7107
|
continue;
|
|
7004
|
-
d && d.length > 0 &&
|
|
7108
|
+
d && d.length > 0 && r.push({
|
|
7005
7109
|
glyphIndex: c.id,
|
|
7006
7110
|
unicode: d,
|
|
7007
7111
|
name: f,
|
|
@@ -7010,7 +7114,7 @@ class oi {
|
|
|
7010
7114
|
});
|
|
7011
7115
|
} catch {
|
|
7012
7116
|
}
|
|
7013
|
-
return
|
|
7117
|
+
return r;
|
|
7014
7118
|
}
|
|
7015
7119
|
/**
|
|
7016
7120
|
* Get glyph alternates for a specific character
|
|
@@ -7020,28 +7124,28 @@ class oi {
|
|
|
7020
7124
|
const s = await this.loadFont(t, i);
|
|
7021
7125
|
if (!s)
|
|
7022
7126
|
return [];
|
|
7023
|
-
const
|
|
7024
|
-
if (
|
|
7127
|
+
const r = [], h = e.codePointAt(0);
|
|
7128
|
+
if (h === void 0)
|
|
7025
7129
|
return [];
|
|
7026
|
-
const n = s.glyphForCodePoint(
|
|
7027
|
-
n &&
|
|
7130
|
+
const n = s.glyphForCodePoint(h);
|
|
7131
|
+
n && r.push({
|
|
7028
7132
|
glyphIndex: n.id,
|
|
7029
7133
|
unicode: e,
|
|
7030
7134
|
name: n.name || "Default",
|
|
7031
7135
|
category: "default",
|
|
7032
7136
|
previewDataUrl: this.generateGlyphPreview(s, n.id, 80)
|
|
7033
7137
|
});
|
|
7034
|
-
const
|
|
7035
|
-
if (
|
|
7138
|
+
const a = n == null ? void 0 : n.name;
|
|
7139
|
+
if (a) {
|
|
7036
7140
|
let f = 0;
|
|
7037
7141
|
for (let u = 0; u < s.numGlyphs; u++)
|
|
7038
7142
|
try {
|
|
7039
7143
|
const m = s.getGlyph(u);
|
|
7040
7144
|
if (!m || !m.name) continue;
|
|
7041
7145
|
if ([
|
|
7042
|
-
new RegExp(`^${
|
|
7043
|
-
new RegExp(`^${
|
|
7044
|
-
new RegExp(`^${
|
|
7146
|
+
new RegExp(`^${a}\\.(swash|alt|ss\\d+|salt|ornament)`, "i"),
|
|
7147
|
+
new RegExp(`^${a}_\\d+$`, "i"),
|
|
7148
|
+
new RegExp(`^${a}\\.\\d+$`, "i")
|
|
7045
7149
|
].some((w) => w.test(m.name)) && m.id !== n.id) {
|
|
7046
7150
|
f++;
|
|
7047
7151
|
let w = m.name;
|
|
@@ -7054,7 +7158,7 @@ class oi {
|
|
|
7054
7158
|
const S = (c = m.name.match(/\.ss(\d+)/)) == null ? void 0 : c[1];
|
|
7055
7159
|
w = `${e} Stylistic Set ${S}`;
|
|
7056
7160
|
}
|
|
7057
|
-
|
|
7161
|
+
r.push({
|
|
7058
7162
|
glyphIndex: m.id,
|
|
7059
7163
|
unicode: e,
|
|
7060
7164
|
name: w,
|
|
@@ -7080,7 +7184,7 @@ class oi {
|
|
|
7080
7184
|
if (!S) continue;
|
|
7081
7185
|
if (this.getCoverageIndex(S, n.id) !== -1) {
|
|
7082
7186
|
const v = this.getSubstituteGlyph(w, n.id);
|
|
7083
|
-
v !== null &&
|
|
7187
|
+
v !== null && r.push({
|
|
7084
7188
|
glyphIndex: v,
|
|
7085
7189
|
unicode: e,
|
|
7086
7190
|
name: `${e} (${m})`,
|
|
@@ -7098,7 +7202,7 @@ class oi {
|
|
|
7098
7202
|
const C = v.alternateSets[b];
|
|
7099
7203
|
if (C)
|
|
7100
7204
|
for (const M of C)
|
|
7101
|
-
|
|
7205
|
+
r.push({
|
|
7102
7206
|
glyphIndex: M,
|
|
7103
7207
|
unicode: e,
|
|
7104
7208
|
name: `${e} (${m} alt)`,
|
|
@@ -7111,7 +7215,7 @@ class oi {
|
|
|
7111
7215
|
}
|
|
7112
7216
|
}
|
|
7113
7217
|
}
|
|
7114
|
-
return
|
|
7218
|
+
return r;
|
|
7115
7219
|
}
|
|
7116
7220
|
/**
|
|
7117
7221
|
* Get available OpenType features for a font
|
|
@@ -7123,16 +7227,16 @@ class oi {
|
|
|
7123
7227
|
try {
|
|
7124
7228
|
const s = [];
|
|
7125
7229
|
if (i.GSUB && i.GSUB.featureList) {
|
|
7126
|
-
const
|
|
7127
|
-
for (const
|
|
7128
|
-
|
|
7129
|
-
s.push(...Array.from(
|
|
7230
|
+
const r = /* @__PURE__ */ new Set();
|
|
7231
|
+
for (const h of i.GSUB.featureList)
|
|
7232
|
+
h.tag && r.add(h.tag);
|
|
7233
|
+
s.push(...Array.from(r));
|
|
7130
7234
|
}
|
|
7131
7235
|
if (i.GPOS && i.GPOS.featureList) {
|
|
7132
|
-
const
|
|
7133
|
-
for (const
|
|
7134
|
-
|
|
7135
|
-
s.push(...Array.from(
|
|
7236
|
+
const r = /* @__PURE__ */ new Set();
|
|
7237
|
+
for (const h of i.GPOS.featureList)
|
|
7238
|
+
h.tag && r.add(h.tag);
|
|
7239
|
+
s.push(...Array.from(r));
|
|
7136
7240
|
}
|
|
7137
7241
|
return s;
|
|
7138
7242
|
} catch (s) {
|
|
@@ -7145,27 +7249,27 @@ class oi {
|
|
|
7145
7249
|
generateGlyphPreview(t, e, i = 80) {
|
|
7146
7250
|
const s = document.createElement("canvas");
|
|
7147
7251
|
s.width = i, s.height = i;
|
|
7148
|
-
const
|
|
7149
|
-
if (!
|
|
7252
|
+
const r = s.getContext("2d");
|
|
7253
|
+
if (!r)
|
|
7150
7254
|
return "";
|
|
7151
7255
|
try {
|
|
7152
|
-
const
|
|
7153
|
-
if (!
|
|
7256
|
+
const h = t.getGlyph(e);
|
|
7257
|
+
if (!h)
|
|
7154
7258
|
return "";
|
|
7155
|
-
|
|
7156
|
-
const n =
|
|
7259
|
+
r.clearRect(0, 0, i, i);
|
|
7260
|
+
const n = h.bbox;
|
|
7157
7261
|
if (!n)
|
|
7158
7262
|
return "";
|
|
7159
|
-
const
|
|
7160
|
-
if (
|
|
7263
|
+
const a = n.maxX - n.minX, l = n.maxY - n.minY;
|
|
7264
|
+
if (a === 0 || l === 0)
|
|
7161
7265
|
return "";
|
|
7162
|
-
const g = Math.min(i /
|
|
7266
|
+
const g = Math.min(i / a, i / l) * 0.6, d = (n.minX + n.maxX) / 2, f = (n.minY + n.maxY) / 2, u = i / 2, m = i / 2, p = h.path.toSVG();
|
|
7163
7267
|
if (!p)
|
|
7164
7268
|
return "";
|
|
7165
7269
|
const y = new Path2D(p);
|
|
7166
|
-
return
|
|
7167
|
-
} catch (
|
|
7168
|
-
return G.error("Error generating glyph preview:",
|
|
7270
|
+
return r.save(), r.translate(u, m), r.scale(g, -g), r.translate(-d, -f), r.fillStyle = "#000000", r.fill(y), r.restore(), s.toDataURL("image/png");
|
|
7271
|
+
} catch (h) {
|
|
7272
|
+
return G.error("Error generating glyph preview:", h), "";
|
|
7169
7273
|
}
|
|
7170
7274
|
}
|
|
7171
7275
|
/**
|
|
@@ -7227,9 +7331,9 @@ class oi {
|
|
|
7227
7331
|
if (t.format === 2 && t.ranges) {
|
|
7228
7332
|
const i = t.ranges;
|
|
7229
7333
|
for (let s = 0; s < i.length; s++) {
|
|
7230
|
-
const
|
|
7231
|
-
if (e >=
|
|
7232
|
-
return
|
|
7334
|
+
const r = i[s];
|
|
7335
|
+
if (e >= r.start && e <= r.end)
|
|
7336
|
+
return r.index + (e - r.start);
|
|
7233
7337
|
}
|
|
7234
7338
|
}
|
|
7235
7339
|
return -1;
|
|
@@ -7256,14 +7360,14 @@ class oi {
|
|
|
7256
7360
|
if (!i)
|
|
7257
7361
|
return 0;
|
|
7258
7362
|
let s = 0;
|
|
7259
|
-
const
|
|
7260
|
-
for (let
|
|
7363
|
+
const r = Math.min(i.numGlyphs, 1500);
|
|
7364
|
+
for (let h = 0; h < r; h++)
|
|
7261
7365
|
try {
|
|
7262
|
-
const n = i.getGlyph(
|
|
7366
|
+
const n = i.getGlyph(h);
|
|
7263
7367
|
if (!n || !n.name || n.name === ".notdef" || n.name.startsWith(".null"))
|
|
7264
7368
|
continue;
|
|
7265
|
-
const
|
|
7266
|
-
let l =
|
|
7369
|
+
const a = n.codePoints || [];
|
|
7370
|
+
let l = a.length > 0 ? String.fromCodePoint(a[0]) : "";
|
|
7267
7371
|
if (!l || l.length === 0) {
|
|
7268
7372
|
const d = n.name.match(/^([A-Za-z0-9])[._]/);
|
|
7269
7373
|
d && (l = d[1]);
|
|
@@ -7285,134 +7389,140 @@ class oi {
|
|
|
7285
7389
|
};
|
|
7286
7390
|
}
|
|
7287
7391
|
}
|
|
7288
|
-
const
|
|
7392
|
+
const Hs = new fi();
|
|
7289
7393
|
export {
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7394
|
+
si as $,
|
|
7395
|
+
at as A,
|
|
7396
|
+
tt as B,
|
|
7397
|
+
Hs as C,
|
|
7398
|
+
Cs as D,
|
|
7399
|
+
ni as E,
|
|
7400
|
+
Li as F,
|
|
7401
|
+
yt as G,
|
|
7402
|
+
ye as H,
|
|
7403
|
+
bt as I,
|
|
7404
|
+
ai as J,
|
|
7405
|
+
zt as K,
|
|
7406
|
+
Re as L,
|
|
7407
|
+
kt as M,
|
|
7408
|
+
_i as N,
|
|
7409
|
+
zi as O,
|
|
7410
|
+
Bt as P,
|
|
7411
|
+
dt as Q,
|
|
7308
7412
|
L as R,
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7413
|
+
Ot as S,
|
|
7414
|
+
j as T,
|
|
7415
|
+
Ms as U,
|
|
7416
|
+
Ke as V,
|
|
7417
|
+
ui as W,
|
|
7418
|
+
ri as X,
|
|
7419
|
+
Ze as Y,
|
|
7420
|
+
Ve as Z,
|
|
7421
|
+
K as _,
|
|
7422
|
+
as as a,
|
|
7423
|
+
pi as a$,
|
|
7424
|
+
Rs as a0,
|
|
7425
|
+
oi as a1,
|
|
7426
|
+
Ie as a2,
|
|
7427
|
+
ii as a3,
|
|
7428
|
+
Je as a4,
|
|
7429
|
+
us as a5,
|
|
7430
|
+
fs as a6,
|
|
7431
|
+
ms as a7,
|
|
7432
|
+
ps as a8,
|
|
7433
|
+
Oe as a9,
|
|
7434
|
+
rt as aA,
|
|
7435
|
+
Wi as aB,
|
|
7436
|
+
Et as aC,
|
|
7437
|
+
Jt as aD,
|
|
7438
|
+
Fi as aE,
|
|
7439
|
+
Vt as aF,
|
|
7336
7440
|
Ai as aG,
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
Ji as
|
|
7408
|
-
|
|
7409
|
-
ji as
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7441
|
+
Mi as aH,
|
|
7442
|
+
I as aI,
|
|
7443
|
+
P as aJ,
|
|
7444
|
+
Hi as aK,
|
|
7445
|
+
xs as aL,
|
|
7446
|
+
Se as aM,
|
|
7447
|
+
yi as aN,
|
|
7448
|
+
Ti as aO,
|
|
7449
|
+
ws as aP,
|
|
7450
|
+
Ce as aQ,
|
|
7451
|
+
ys as aR,
|
|
7452
|
+
qe as aS,
|
|
7453
|
+
bs as aT,
|
|
7454
|
+
Oi as aU,
|
|
7455
|
+
Ci as aV,
|
|
7456
|
+
vi as aW,
|
|
7457
|
+
Si as aX,
|
|
7458
|
+
xe as aY,
|
|
7459
|
+
xi as aZ,
|
|
7460
|
+
bi as a_,
|
|
7461
|
+
Ue as aa,
|
|
7462
|
+
Ye as ab,
|
|
7463
|
+
ht as ac,
|
|
7464
|
+
Wt as ad,
|
|
7465
|
+
It as ae,
|
|
7466
|
+
Nt as af,
|
|
7467
|
+
qt as ag,
|
|
7468
|
+
gs as ah,
|
|
7469
|
+
Z as ai,
|
|
7470
|
+
xt as aj,
|
|
7471
|
+
ds as ak,
|
|
7472
|
+
De as al,
|
|
7473
|
+
Xi as am,
|
|
7474
|
+
Yi as an,
|
|
7475
|
+
q as ao,
|
|
7476
|
+
ls as ap,
|
|
7477
|
+
Ds as aq,
|
|
7478
|
+
Is as ar,
|
|
7479
|
+
ks as as,
|
|
7480
|
+
Es as at,
|
|
7481
|
+
Os as au,
|
|
7482
|
+
Bs as av,
|
|
7483
|
+
Fe as aw,
|
|
7484
|
+
Ae as ax,
|
|
7485
|
+
Ii as ay,
|
|
7486
|
+
Qe as az,
|
|
7487
|
+
ns as b,
|
|
7488
|
+
Ri as b0,
|
|
7489
|
+
Bi as b1,
|
|
7490
|
+
wi as b2,
|
|
7491
|
+
ki as b3,
|
|
7492
|
+
Ei as b4,
|
|
7493
|
+
Di as b5,
|
|
7494
|
+
vs as b6,
|
|
7495
|
+
mi as b7,
|
|
7496
|
+
se as b8,
|
|
7497
|
+
As as b9,
|
|
7498
|
+
Pi as ba,
|
|
7499
|
+
ti as bb,
|
|
7500
|
+
nt as bc,
|
|
7501
|
+
Ni as bd,
|
|
7502
|
+
We as be,
|
|
7503
|
+
wt as c,
|
|
7504
|
+
ts as d,
|
|
7505
|
+
Gi as e,
|
|
7506
|
+
Qi as f,
|
|
7507
|
+
li as g,
|
|
7508
|
+
cs as h,
|
|
7509
|
+
$i as i,
|
|
7510
|
+
Ui as j,
|
|
7511
|
+
Ji as k,
|
|
7512
|
+
es as l,
|
|
7513
|
+
ji as m,
|
|
7514
|
+
Ki as n,
|
|
7515
|
+
qi as o,
|
|
7516
|
+
hs as p,
|
|
7517
|
+
ss as q,
|
|
7518
|
+
Ts as r,
|
|
7519
|
+
rs as s,
|
|
7520
|
+
is as t,
|
|
7521
|
+
Fs as u,
|
|
7522
|
+
os as v,
|
|
7523
|
+
Zi as w,
|
|
7524
|
+
Vi as x,
|
|
7525
|
+
Ss as y,
|
|
7526
|
+
mt as z
|
|
7417
7527
|
};
|
|
7418
|
-
//# sourceMappingURL=FontAnalyzer-
|
|
7528
|
+
//# sourceMappingURL=FontAnalyzer-BrKY6XYn.js.map
|