@leafer-draw/worker 1.0.9 → 1.1.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/dist/worker.cjs +25 -13
- package/dist/worker.esm.js +25 -13
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +105 -67
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +105 -67
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.js
CHANGED
|
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
|
|
|
111
111
|
return rotation - oldRotation;
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
|
|
|
1414
1414
|
list: {},
|
|
1415
1415
|
register(UI) {
|
|
1416
1416
|
const { __tag: tag } = UI.prototype;
|
|
1417
|
-
if (list$1[tag])
|
|
1417
|
+
if (list$1[tag])
|
|
1418
1418
|
debug$c.repeat(tag);
|
|
1419
|
-
|
|
1420
|
-
else {
|
|
1421
|
-
list$1[tag] = UI;
|
|
1422
|
-
}
|
|
1419
|
+
list$1[tag] = UI;
|
|
1423
1420
|
},
|
|
1424
1421
|
get(tag, data, x, y, width, height) {
|
|
1422
|
+
if (!list$1[tag])
|
|
1423
|
+
debug$c.error('not register ' + tag);
|
|
1425
1424
|
const ui = new list$1[tag](data);
|
|
1426
1425
|
if (x !== undefined) {
|
|
1427
1426
|
ui.x = x;
|
|
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
|
|
|
1445
1444
|
Object.keys(Event).forEach(key => {
|
|
1446
1445
|
name = Event[key];
|
|
1447
1446
|
if (typeof name === 'string')
|
|
1448
|
-
nameList[name]
|
|
1447
|
+
nameList[name] && debug$b.repeat(name), nameList[name] = Event;
|
|
1449
1448
|
});
|
|
1450
1449
|
},
|
|
1451
1450
|
changeName(oldName, newName) {
|
|
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
|
|
|
1647
1646
|
const t = this;
|
|
1648
1647
|
if (t.blendMode === 'pass-through') {
|
|
1649
1648
|
const leaf = this.__leaf;
|
|
1650
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1649
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1651
1650
|
t.__single = true;
|
|
1652
1651
|
}
|
|
1653
1652
|
else if (t.__single) {
|
|
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
|
|
|
2045
2044
|
takeCanvas = this.getSameCanvas();
|
|
2046
2045
|
takeCanvas.copyWorld(this);
|
|
2047
2046
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2047
|
+
const s = this.size;
|
|
2048
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2049
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2050
2050
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2051
2051
|
if (this.context && !this.unreal) {
|
|
2052
2052
|
this.updateViewSize();
|
|
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
|
|
|
2160
2160
|
if (!onlyResetTransform)
|
|
2161
2161
|
this.useWorldTransform();
|
|
2162
2162
|
}
|
|
2163
|
+
useGrayscaleAlpha(bounds) {
|
|
2164
|
+
this.setTempBounds(bounds, true, true);
|
|
2165
|
+
let alpha, pixel;
|
|
2166
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2167
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2168
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2169
|
+
if (alpha = data[i + 3])
|
|
2170
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2171
|
+
}
|
|
2172
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2173
|
+
}
|
|
2163
2174
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2164
2175
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2165
2176
|
}
|
|
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
|
|
|
2170
2181
|
if (blendMode)
|
|
2171
2182
|
this.blendMode = blendMode;
|
|
2172
2183
|
this.fillStyle = color;
|
|
2173
|
-
|
|
2184
|
+
this.setTempBounds(bounds);
|
|
2174
2185
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2175
2186
|
if (blendMode)
|
|
2176
2187
|
this.blendMode = 'source-over';
|
|
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
|
|
|
2179
2190
|
if (blendMode)
|
|
2180
2191
|
this.blendMode = blendMode;
|
|
2181
2192
|
this.strokeStyle = color;
|
|
2182
|
-
|
|
2193
|
+
this.setTempBounds(bounds);
|
|
2183
2194
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2184
2195
|
if (blendMode)
|
|
2185
2196
|
this.blendMode = 'source-over';
|
|
2186
2197
|
}
|
|
2187
2198
|
clearWorld(bounds, ceilPixel) {
|
|
2188
|
-
|
|
2189
|
-
if (ceilPixel)
|
|
2190
|
-
tempBounds$1.ceil();
|
|
2199
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2191
2200
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2192
2201
|
}
|
|
2193
2202
|
clipWorld(bounds, ceilPixel) {
|
|
2194
2203
|
this.beginPath();
|
|
2195
|
-
|
|
2196
|
-
if (ceilPixel)
|
|
2197
|
-
tempBounds$1.ceil();
|
|
2204
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2198
2205
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2199
2206
|
this.clip();
|
|
2200
2207
|
}
|
|
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
|
|
|
2202
2209
|
const { pixelRatio } = this;
|
|
2203
2210
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2204
2211
|
}
|
|
2212
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2213
|
+
tempBounds$1.set(bounds);
|
|
2214
|
+
if (intersect)
|
|
2215
|
+
tempBounds$1.intersect(this.bounds);
|
|
2216
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2217
|
+
if (ceil)
|
|
2218
|
+
tempBounds$1.ceil();
|
|
2219
|
+
}
|
|
2205
2220
|
isSameSize(size) {
|
|
2206
2221
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2207
2222
|
}
|
|
@@ -4153,20 +4168,17 @@ var LeaferUI = (function (exports) {
|
|
|
4153
4168
|
}
|
|
4154
4169
|
return true;
|
|
4155
4170
|
},
|
|
4156
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4171
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4157
4172
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4158
4173
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4159
|
-
L.moveLocal(t, local.x, local.y);
|
|
4174
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4160
4175
|
},
|
|
4161
|
-
moveLocal(t, x, y = 0) {
|
|
4162
|
-
if (typeof x === 'object')
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
t.x += x;
|
|
4168
|
-
t.y += y;
|
|
4169
|
-
}
|
|
4176
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4177
|
+
if (typeof x === 'object')
|
|
4178
|
+
y = x.y, x = x.x;
|
|
4179
|
+
x += t.x;
|
|
4180
|
+
y += t.y;
|
|
4181
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4170
4182
|
},
|
|
4171
4183
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4172
4184
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5215,13 +5227,14 @@ var LeaferUI = (function (exports) {
|
|
|
5215
5227
|
this.__.__checkSingle();
|
|
5216
5228
|
},
|
|
5217
5229
|
__render(canvas, options) {
|
|
5230
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5218
5231
|
if (this.__worldOpacity) {
|
|
5219
5232
|
if (this.__.__single) {
|
|
5220
5233
|
if (this.__.eraser === 'path')
|
|
5221
5234
|
return this.__renderEraser(canvas, options);
|
|
5222
5235
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5223
5236
|
this.__renderBranch(tempCanvas, options);
|
|
5224
|
-
const nowWorld = this.
|
|
5237
|
+
const nowWorld = this.__nowWorld;
|
|
5225
5238
|
canvas.opacity = this.__.opacity;
|
|
5226
5239
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5227
5240
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5545,11 +5558,11 @@ var LeaferUI = (function (exports) {
|
|
|
5545
5558
|
transform(matrix, resize) {
|
|
5546
5559
|
transform(this, matrix, resize);
|
|
5547
5560
|
}
|
|
5548
|
-
move(x, y) {
|
|
5549
|
-
moveLocal(this, x, y);
|
|
5561
|
+
move(x, y, transition) {
|
|
5562
|
+
moveLocal(this, x, y, transition);
|
|
5550
5563
|
}
|
|
5551
|
-
moveInner(x, y) {
|
|
5552
|
-
moveWorld(this, x, y, true);
|
|
5564
|
+
moveInner(x, y, transition) {
|
|
5565
|
+
moveWorld(this, x, y, true, transition);
|
|
5553
5566
|
}
|
|
5554
5567
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5555
5568
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5563,8 +5576,8 @@ var LeaferUI = (function (exports) {
|
|
|
5563
5576
|
transformWorld(worldTransform, resize) {
|
|
5564
5577
|
transformWorld(this, worldTransform, resize);
|
|
5565
5578
|
}
|
|
5566
|
-
moveWorld(x, y) {
|
|
5567
|
-
moveWorld(this, x, y);
|
|
5579
|
+
moveWorld(x, y, transition) {
|
|
5580
|
+
moveWorld(this, x, y, false, transition);
|
|
5568
5581
|
}
|
|
5569
5582
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5570
5583
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5962,7 +5975,7 @@ var LeaferUI = (function (exports) {
|
|
|
5962
5975
|
}
|
|
5963
5976
|
}
|
|
5964
5977
|
|
|
5965
|
-
const version = "1.0
|
|
5978
|
+
const version = "1.1.0";
|
|
5966
5979
|
|
|
5967
5980
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5968
5981
|
get allowBackgroundColor() { return true; }
|
|
@@ -6431,7 +6444,8 @@ var LeaferUI = (function (exports) {
|
|
|
6431
6444
|
this.totalBounds = new Bounds();
|
|
6432
6445
|
debug$3.log(target.innerName, '--->');
|
|
6433
6446
|
try {
|
|
6434
|
-
target.
|
|
6447
|
+
if (!target.isApp)
|
|
6448
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6435
6449
|
this.emitRender(RenderEvent.START);
|
|
6436
6450
|
this.renderOnce(callback);
|
|
6437
6451
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6712,6 +6726,12 @@ var LeaferUI = (function (exports) {
|
|
|
6712
6726
|
return strokeWidth;
|
|
6713
6727
|
}
|
|
6714
6728
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
6729
|
+
get __hasMultiPaint() {
|
|
6730
|
+
const t = this;
|
|
6731
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
6732
|
+
return true;
|
|
6733
|
+
return t.fill && this.__hasStroke;
|
|
6734
|
+
}
|
|
6715
6735
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
6716
6736
|
get __autoWidth() { return !this._width; }
|
|
6717
6737
|
get __autoHeight() { return !this._height; }
|
|
@@ -7081,9 +7101,8 @@ var LeaferUI = (function (exports) {
|
|
|
7081
7101
|
canvas.strokeRect(half, half, width, height);
|
|
7082
7102
|
canvas.restore();
|
|
7083
7103
|
}
|
|
7084
|
-
else
|
|
7104
|
+
else
|
|
7085
7105
|
canvas.strokeRect(half, half, width, height);
|
|
7086
|
-
}
|
|
7087
7106
|
break;
|
|
7088
7107
|
case 'outside':
|
|
7089
7108
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7113,11 +7132,15 @@ var LeaferUI = (function (exports) {
|
|
|
7113
7132
|
super(data);
|
|
7114
7133
|
}
|
|
7115
7134
|
reset(_data) { }
|
|
7116
|
-
set(data,
|
|
7117
|
-
if (
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7135
|
+
set(data, transition) {
|
|
7136
|
+
if (transition) {
|
|
7137
|
+
if (transition === 'temp') {
|
|
7138
|
+
this.lockNormalStyle = true;
|
|
7139
|
+
Object.assign(this, data);
|
|
7140
|
+
this.lockNormalStyle = false;
|
|
7141
|
+
}
|
|
7142
|
+
else
|
|
7143
|
+
this.animate(data, transition);
|
|
7121
7144
|
}
|
|
7122
7145
|
else
|
|
7123
7146
|
Object.assign(this, data);
|
|
@@ -7308,6 +7331,15 @@ var LeaferUI = (function (exports) {
|
|
|
7308
7331
|
__decorate([
|
|
7309
7332
|
boundsType(0)
|
|
7310
7333
|
], exports.UI.prototype, "padding", void 0);
|
|
7334
|
+
__decorate([
|
|
7335
|
+
boundsType(false)
|
|
7336
|
+
], exports.UI.prototype, "lockRatio", void 0);
|
|
7337
|
+
__decorate([
|
|
7338
|
+
boundsType()
|
|
7339
|
+
], exports.UI.prototype, "widthRange", void 0);
|
|
7340
|
+
__decorate([
|
|
7341
|
+
boundsType()
|
|
7342
|
+
], exports.UI.prototype, "heightRange", void 0);
|
|
7311
7343
|
__decorate([
|
|
7312
7344
|
dataType(false)
|
|
7313
7345
|
], exports.UI.prototype, "draggable", void 0);
|
|
@@ -7418,17 +7450,17 @@ var LeaferUI = (function (exports) {
|
|
|
7418
7450
|
if (!this.children)
|
|
7419
7451
|
this.children = [];
|
|
7420
7452
|
}
|
|
7421
|
-
set(data,
|
|
7453
|
+
set(data, transition) {
|
|
7422
7454
|
if (data.children) {
|
|
7423
7455
|
const { children } = data;
|
|
7424
7456
|
delete data.children;
|
|
7425
7457
|
this.children ? this.clear() : this.__setBranch();
|
|
7426
|
-
super.set(data,
|
|
7458
|
+
super.set(data, transition);
|
|
7427
7459
|
children.forEach(child => this.add(child));
|
|
7428
7460
|
data.children = children;
|
|
7429
7461
|
}
|
|
7430
7462
|
else
|
|
7431
|
-
super.set(data,
|
|
7463
|
+
super.set(data, transition);
|
|
7432
7464
|
}
|
|
7433
7465
|
toJSON(options) {
|
|
7434
7466
|
const data = super.toJSON(options);
|
|
@@ -7541,8 +7573,8 @@ var LeaferUI = (function (exports) {
|
|
|
7541
7573
|
}
|
|
7542
7574
|
onInit() { }
|
|
7543
7575
|
initType(_type) { }
|
|
7544
|
-
set(data) {
|
|
7545
|
-
this.waitInit(() => { super.set(data); });
|
|
7576
|
+
set(data, transition) {
|
|
7577
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7546
7578
|
}
|
|
7547
7579
|
start() {
|
|
7548
7580
|
clearTimeout(this.__startTimer);
|
|
@@ -7599,8 +7631,6 @@ var LeaferUI = (function (exports) {
|
|
|
7599
7631
|
__onResize(event) {
|
|
7600
7632
|
this.emitEvent(event);
|
|
7601
7633
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
7602
|
-
if (!event.width || !event.height)
|
|
7603
|
-
debug$1.warn('w = 0 or h = 0');
|
|
7604
7634
|
setTimeout(() => { if (this.canvasManager)
|
|
7605
7635
|
this.canvasManager.clearRecycled(); }, 0);
|
|
7606
7636
|
}
|
|
@@ -7925,9 +7955,6 @@ var LeaferUI = (function (exports) {
|
|
|
7925
7955
|
__decorate([
|
|
7926
7956
|
dataType(false)
|
|
7927
7957
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
7928
|
-
__decorate([
|
|
7929
|
-
dataType(false)
|
|
7930
|
-
], exports.Box.prototype, "textBox", void 0);
|
|
7931
7958
|
__decorate([
|
|
7932
7959
|
affectRenderBoundsType('show')
|
|
7933
7960
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -8642,6 +8669,8 @@ var LeaferUI = (function (exports) {
|
|
|
8642
8669
|
case 'center':
|
|
8643
8670
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
8644
8671
|
canvas.stroke();
|
|
8672
|
+
if (options.__useArrow)
|
|
8673
|
+
strokeArrow(ui, canvas);
|
|
8645
8674
|
break;
|
|
8646
8675
|
case 'inside':
|
|
8647
8676
|
canvas.save();
|
|
@@ -8679,6 +8708,8 @@ var LeaferUI = (function (exports) {
|
|
|
8679
8708
|
case 'center':
|
|
8680
8709
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
8681
8710
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
8711
|
+
if (options.__useArrow)
|
|
8712
|
+
strokeArrow(ui, canvas);
|
|
8682
8713
|
break;
|
|
8683
8714
|
case 'inside':
|
|
8684
8715
|
canvas.save();
|
|
@@ -8704,6 +8735,14 @@ var LeaferUI = (function (exports) {
|
|
|
8704
8735
|
}
|
|
8705
8736
|
}
|
|
8706
8737
|
}
|
|
8738
|
+
function strokeArrow(ui, canvas) {
|
|
8739
|
+
if (ui.__.dashPattern) {
|
|
8740
|
+
canvas.beginPath();
|
|
8741
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
8742
|
+
canvas.dashPattern = null;
|
|
8743
|
+
canvas.stroke();
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8707
8746
|
|
|
8708
8747
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
8709
8748
|
function shape(ui, current, options) {
|
|
@@ -9389,16 +9428,16 @@ var LeaferUI = (function (exports) {
|
|
|
9389
9428
|
|
|
9390
9429
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
9391
9430
|
exports.Group.prototype.__renderMask = function (canvas, options) {
|
|
9392
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
9431
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
9393
9432
|
const { children } = this;
|
|
9394
9433
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
9395
|
-
child = children[i];
|
|
9396
|
-
if (
|
|
9434
|
+
child = children[i], mask = child.__.mask;
|
|
9435
|
+
if (mask) {
|
|
9397
9436
|
if (currentMask) {
|
|
9398
9437
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
9399
9438
|
maskCanvas = contentCanvas = null;
|
|
9400
9439
|
}
|
|
9401
|
-
if (
|
|
9440
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
9402
9441
|
if (child.opacity < 1) {
|
|
9403
9442
|
currentMask = 'opacity-path';
|
|
9404
9443
|
maskOpacity = child.opacity;
|
|
@@ -9412,14 +9451,14 @@ var LeaferUI = (function (exports) {
|
|
|
9412
9451
|
child.__clip(contentCanvas || canvas, options);
|
|
9413
9452
|
}
|
|
9414
9453
|
else {
|
|
9415
|
-
currentMask = 'alpha';
|
|
9454
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
9416
9455
|
if (!maskCanvas)
|
|
9417
9456
|
maskCanvas = getCanvas(canvas);
|
|
9418
9457
|
if (!contentCanvas)
|
|
9419
9458
|
contentCanvas = getCanvas(canvas);
|
|
9420
9459
|
child.__render(maskCanvas, options);
|
|
9421
9460
|
}
|
|
9422
|
-
if (
|
|
9461
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
9423
9462
|
continue;
|
|
9424
9463
|
}
|
|
9425
9464
|
if (excludeRenderBounds(child, options))
|
|
@@ -9430,6 +9469,8 @@ var LeaferUI = (function (exports) {
|
|
|
9430
9469
|
};
|
|
9431
9470
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
9432
9471
|
switch (maskMode) {
|
|
9472
|
+
case 'grayscale':
|
|
9473
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
9433
9474
|
case 'alpha':
|
|
9434
9475
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
9435
9476
|
break;
|
|
@@ -10134,15 +10175,12 @@ var LeaferUI = (function (exports) {
|
|
|
10134
10175
|
const debug = Debug.get('@leafer-ui/export');
|
|
10135
10176
|
canvas.export = function (filename, options) {
|
|
10136
10177
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
10137
|
-
if (filename.includes('.'))
|
|
10178
|
+
if (filename.includes('.'))
|
|
10138
10179
|
return this.saveAs(filename, quality);
|
|
10139
|
-
|
|
10140
|
-
else if (blob) {
|
|
10180
|
+
else if (blob)
|
|
10141
10181
|
return this.toBlob(filename, quality);
|
|
10142
|
-
|
|
10143
|
-
else {
|
|
10182
|
+
else
|
|
10144
10183
|
return this.toDataURL(filename, quality);
|
|
10145
|
-
}
|
|
10146
10184
|
};
|
|
10147
10185
|
canvas.toBlob = function (type, quality) {
|
|
10148
10186
|
return new Promise((resolve) => {
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:i}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((a,o)=>{t.convertToBlob({type:i(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:i(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return y.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,a,e,n);break;case"outside":B("outside",t,a,e,n)}}function B(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,o)}function R(t,n,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),n?E(i,a):a.stroke(),a.restoreBlendMode()):n?E(i,a):a.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:L,getOuterOf:k,getByMove:S,getIntersectData:P}=t.BoundsHelper;let C;function O(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:a}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:l}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,a,!C||!C[n.url]);case"linear":return e.PaintGradient.linearGradient(n,a);case"radial":return e.PaintGradient.radialGradient(n,a);case"angular":return e.PaintGradient.conicGradient(n,a);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const A={compute:function(t,n){const i=n.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),C=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=s.length;i<o;i++)e=O(t,s[i],n),e&&a.push(e);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let a;const{windingRule:o,__font:s}=n.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&e.PaintImage.checkImage(n,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),R(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),R(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=P(i?L(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=k(a,s),o=S(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let W={};const{get:M,rotateOfOuter:T,translate:I,scaleOfOuter:D,scale:H,rotate:F}=t.MatrixHelper;function Y(t,e,n,i,a,o,s){const r=M();I(r,e.x+n,e.y+i),H(r,a,o),s&&T(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function G(t,e,n,i,a,o,s){const r=M();I(r,e.x+n,e.y+i),a&&H(r,a,o),s&&F(r,s),t.transform=r}function j(t,e,n,i,a,o,s,r,l,d){const c=M();if(l)if("center"===d)T(c,{x:n/2,y:i/2},l);else switch(F(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}W.x=e.x+a,W.y=e.y+o,I(c,W.x,W.y),s&&D(c,W,s,r),t.transform=c}const{get:X,translate:U}=t.MatrixHelper,z=new t.Bounds,N={},q={};function V(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:a,height:o}=i;e.padding&&(n=z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,q),y=q.scaleX,v=q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*y)/2,b+=(n.height-o*v)/2}if(l){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,N,!0),x+=N.x,b+=N.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&G(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&j(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&Y(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=X(),U(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:K}=t.BoundsHelper;function $(t,e,n,i,a,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||V(a,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:st,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=dt(a),o=dt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),rt(d,g),st(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=ot(),g&&rt(d,g)),st(d,1/a,1/o));const y=e.getCanvas(lt(c)||1,lt(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return J&&i===J.paint&&K(a,J.boxBounds)?s=J.leafPaint:(s={type:i.type,image:l},J=l.use>1?{leafPaint:s,paint:i,boxBounds:Z.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?($(e,n,i,l,s,a),o&&(tt(e,r),et(e,r))):l.error?o&&nt(e,r,l.error):(o&&(at(e,!0),tt(e,r)),s.loadId=l.load((()=>{at(e,!1),e.destroyed||($(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),s.loadId=null}),(t=>{at(e,!1),nt(e,r,t),s.loadId=null}))),s},checkImage:function(n,i,a,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!a.data||a.patternId===s+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=a;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ut(s)*l,i*=ut(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),a.blendMode&&(i.blendMode=a.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(a.image.view,0,0,d.width,d.height),i.restore(),!0):(!a.style||a.sync||e.Export.running?ct(n,a,l):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,a,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:V,getPatternData:Q,fillOrFitMode:Y,clipMode:G,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){if(n){let a;for(let o=0,s=n.length;o<s;o++)a=n[o],"string"==typeof a?t.addColorStop(o/(s-1),e.ColorConvert.string(a,i)):t.addColorStop(a.offset,e.ColorConvert.string(a.color,i))}}const{getAngle:mt,getDistance:yt}=t.PointHelper,{get:vt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Bt}=t.AroundHelper,Et={},Rt={};function Lt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=mt(e,n);o=vt(),a?(bt(o,e,s/r*(i||1),1),xt(o,e,t+90)):(bt(o,e,1,s/r*(i||1)),xt(o,e,t))}return o}const{getDistance:kt}=t.PointHelper,{toPoint:St}=t.AroundHelper,Pt={},Ct={};const Ot={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;pt(i||"top",n,gt),pt(a||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Bt(i||"center",n,Et),Bt(a||"bottom",n,Rt);const d=t.Platform.canvas.createRadialGradient(Et.x,Et.y,0,Et.x,Et.y,yt(Et,Rt));wt(d,e.stops,s);const c={type:o,style:d},h=Lt(n,Et,Rt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;St(i||"center",n,Pt),St(a||"bottom",n,Ct);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Pt.x,Pt.y):t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,kt(Pt,Ct));wt(d,e.stops,s);const c={type:o,style:d},h=Lt(n,Pt,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Lt},{copy:At,toOffsetOutBounds:Wt}=t.BoundsHelper,Mt={},Tt={};function It(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(At(Mt,e.bounds),Mt.x+=n.x-s.x,Mt.y+=n.y-s.y,i){const{matrix:t}=a;Mt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Mt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(a.canvas,e.bounds,Mt)}else i&&(At(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(a.canvas,s,i?Mt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,Ht={};const Ft={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Wt(d,Tt),r.forEach(((r,g)=>{f.setWorldShadow(Tt.offsetX+r.x*h,Tt.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,It(f,Tt,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,Ht),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ht.offsetX+r.x*h,Ht.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,It(f,Ht,a,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Yt}=t.LeafBoundsHelper;function Gt(t,e,n,i,a,o){switch(e){case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Xt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Xt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}e.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(s&&(Gt(this,s,t,a,i,o),i=a=null),"path"===n.__.mask?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=jt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="alpha",i||(i=jt(t)),a||(a=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Yt(n,e)||n.__render(a||t,e);Gt(this,s,t,a,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",zt=Ut+"_#~&*+\\=|≮≯≈≠=…",Nt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Vt=qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=qt(Ut),Zt=qt(zt),Kt=qt("- —/~|┆·");var $t;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}($t||($t={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:ae,Break:oe}=$t;function se(t){return Vt[t]?te:Kt[t]?oe:Qt[t]?ne:Jt[t]?ie:Zt[t]?ae:Nt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=$t;let _e,we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ce,Oe,Ae,We=[];function Me(t,e){Ee&&!Be&&(Be=Ee),_e.data.push({char:t,width:e}),me+=e}function Te(){ye+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Ie(){Pe&&(Ce.paraNumber++,we.paraStart=!0,Pe=!1),Ee&&(we.startCharSize=Be,we.endCharSize=Ee,Be=0),we.width=ye,Oe.width?de(we):Ae&&De(),We.push(we),we={words:[]},ye=0}function De(){ye>(Ce.maxWidth||0)&&(Ce.maxWidth=ye)}const He=0,Fe=1,Ye=2;const{top:Ge,right:je,bottom:Xe,left:Ue}=t.Direction4;function ze(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ne={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ue],o-=d[je]+d[Ue]):n.autoSizeAlign||(i=d[Ue]),s?(a=d[Ge],s-=d[Ge]+d[Xe]):n.autoSizeAlign||(a=d[Ge]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,We=e.rows,Oe=e.bounds,Ae=!Oe.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=Oe;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Pe=!0,Le=null,Be=be=Ee=me=ye=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Te(),we.paraEnd=!0,Ie(),Pe=!0):(Re=se(xe),Re===ce&&"none"!==s&&(xe=le(xe,s,!me)),be=r.measureText(xe).width,a&&(a<0&&(Ee=be),be+=a),ke=Re===he&&(Le===he||Le===ce)||Le===he&&Re!==fe,Se=!(Re!==ue&&Re!==he||Le!==pe&&Le!==fe),ve=Pe&&o?l-o:l,t&&l&&ye+me+be>ve&&(e?(me&&Te(),ye&&Ie()):(Se||(Se=Re===ce&&Le==fe),ke||Se||Re===ge||Re===ue||Re===he||me+be>ve?(me&&Te(),ye&&Ie()):ye&&Ie()))," "===xe&&!0!==Pe&&ye+me===0||(Re===ge?(" "===xe&&me&&Te(),Me(xe,be),Te()):ke||Se?(me&&Te(),Me(xe,be)):Me(xe,be)),Le=Re);me&&Te(),ye&&Ie(),We.length>0&&(We[We.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ye=r.measureText(t).width,We.push({x:o||0,text:t,width:ye,paraStart:!0}),Ae&&De()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":ze(e,"x",t[Ue]);break;case"right":ze(e,"x",-t[je])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":ze(e,"y",t[Ge]);break;case"bottom":ze(e,"y",-t[Xe])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?He:d>.01?Fe:Ye,t.isOverflow&&!r&&(t.textMode=!0),h===Ye?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Fe?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const qe={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=n);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}},{setPoint:Ve,addPoint:Qe,toBounds:Je}=t.TwoPointBoundsHelper;const Ze={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){Ke||(Ke=new t.TaskProcessor);return new Promise((t=>{Ke.add((()=>ht(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((r=>{const l=t=>{s(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?($e(e),h.waitViewCompleted((()=>ht(this,void 0,void 0,(function*(){let a,o,s=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,y=c&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)a=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(s=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}a=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,a,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(a).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,C=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,S.bounds=C.bounds),C.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(C,S),e.fill=t}else e.__render(C,S);if(C.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Qe(r,o,s):Ve(r={},o,s)),l++;const d=new t.Bounds;return Je(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};C=t.Creator.canvas(a),C.copyWorld(e,o,a)}v&&C.fillWorld(C.bounds,y||"#FFFFFF","destination-over"),g&&g(C);const O="canvas"===n?C:yield C.export(n,i);l({data:O,width:C.pixelWidth,height:C.pixelHeight,renderBounds:a,trimBounds:o})}))))):l({data:!1})}))))}};let Ke;function $e(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>$e(t)))}const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,qe),Object.assign(e.Paint,A),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Ot),Object.assign(e.Effect,Ft),Object.assign(e.Export,Ze),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:i}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((a,o)=>{t.convertToBlob({type:i(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:i(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return y.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,a,e,n);break;case"outside":B("outside",t,a,e,n)}}function B(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,o)}function R(t,n,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),n?E(i,a):a.stroke(),a.restoreBlendMode()):n?E(i,a):a.stroke())}function L(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let C;function O(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:a}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:l}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,a,!C||!C[n.url]);case"linear":return e.PaintGradient.linearGradient(n,a);case"radial":return e.PaintGradient.radialGradient(n,a);case"angular":return e.PaintGradient.conicGradient(n,a);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),C=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=s.length;i<o;i++)e=O(t,s[i],n),e&&a.push(e);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let a;const{windingRule:o,__font:s}=n.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&e.PaintImage.checkImage(n,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),R(t,!1,e,n),i.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),R(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=A(i?k(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),F(r,a,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function j(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),a&&F(r,a,o),s&&Y(r,s),t.transform=r}function X(t,e,n,i,a,o,s,r,l,d){const c=T();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}M.x=e.x+a,M.y=e.y+o,D(c,M.x,M.y),s&&H(c,M,s,r),t.transform=c}const{get:U,translate:z}=t.MatrixHelper,N=new t.Bounds,q={},V={};function Q(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=J(n,i,e)}function J(e,n,i){let{width:a,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,V),y=V.scaleX,v=V.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*y)/2,b+=(n.height-o*v)/2}if(l){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,q,!0),x+=q.x,b+=q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&j(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&X(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&G(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),z(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let Z,K=new t.Bounds;const{isSame:$}=t.BoundsHelper;function tt(t,e,n,i,a,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||Q(a,i,n,o),!0}function et(e,n){at(e,t.ImageEvent.LOAD,n)}function nt(e,n){at(e,t.ImageEvent.LOADED,n)}function it(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ot(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:st,scale:rt,copy:lt}=t.MatrixHelper,{ceil:dt,abs:ct}=Math;function ht(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=ct(a),o=ct(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=st(),lt(d,g),rt(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=st(),g&<(d,g)),rt(d,1/a,1/o));const y=e.getCanvas(dt(c)||1,dt(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}function ut(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return Z&&i===Z.paint&&$(a,Z.boxBounds)?s=Z.leafPaint:(s={type:i.type,image:l},Z=l.use>1?{leafPaint:s,paint:i,boxBounds:K.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(tt(e,n,i,l,s,a),o&&(et(e,r),nt(e,r))):l.error?o&&it(e,r,l.error):(o&&(ot(e,!0),et(e,r)),s.loadId=l.load((()=>{ot(e,!1),e.destroyed||(tt(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),s.loadId=null}),(t=>{ot(e,!1),it(e,r,t),s.loadId=null}))),s},checkImage:function(n,i,a,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!a.data||a.patternId===s+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=a;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ft(s)*l,i*=ft(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),a.blendMode&&(i.blendMode=a.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(a.image.view,0,0,d.width,d.height),i.restore(),!0):(!a.style||a.sync||e.Export.running?ht(n,a,l):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(n.__nowWorld)&&ht(n,a,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:Q,getPatternData:J,fillOrFitMode:G,clipMode:j,repeatMode:X},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,n,i){if(n){let a;for(let o=0,s=n.length;o<s;o++)a=n[o],"string"==typeof a?t.addColorStop(o/(s-1),e.ColorConvert.string(a,i)):t.addColorStop(a.offset,e.ColorConvert.string(a.color,i))}}const{getAngle:yt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=yt(e,n);o=xt(),a?(Bt(o,e,s/r*(i||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(i||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Ct={};const Ot={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;gt(i||"top",n,_t),gt(a||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(a||"bottom",n,Lt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,Rt,Lt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ct);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Ct));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Wt,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-s.x,Tt.y+=n.y-s.y,i){const{matrix:t}=a;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(a.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(a.canvas,s,i?Tt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Yt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(d,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,It,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,Ft,a,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,a,o){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Ut(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Xt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}e.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(jt(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Xt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Xt(t)),a||(a=Xt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(a||t,e);jt(this,s,t,a,i,o)};const zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=zt+"_#~&*+\\=|≮≯≈≠=…",qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Vt(zt),Kt=Vt(Nt),$t=Vt("- —/~|┆·");var te;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:ae,Symbol:oe,Break:se}=te;function re(t){return Qt[t]?ee:$t[t]?se:Jt[t]?ie:Zt[t]?ae:Kt[t]?oe:qt.test(t)?ne:ee}const le={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function de(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ce}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce,Oe,We,Me=[];function Te(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),ye+=e}function Ie(){ve+=ye,we.width=ye,me.words.push(we),we={data:[]},ye=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Re&&(me.startCharSize=Ee,me.endCharSize=Re,Ee=0),me.width=ve,Oe.width?ce(me):We&&He(),Me.push(me),me={words:[]},ve=0}function He(){ve>(Ce.maxWidth||0)&&(Ce.maxWidth=ve)}const Fe=0,Ye=1,Ge=2;const{top:je,right:Xe,bottom:Ue,left:ze}=t.Direction4;function Ne(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[ze],o-=d[Xe]+d[ze]):n.autoSizeAlign||(i=d[ze]),s?(a=d[je],s-=d[je]+d[Ue]):n.autoSizeAlign||(a=d[je]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Me=e.rows,Oe=e.bounds,We=!Oe.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=Oe;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=ye=ve=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ye&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=de(be,s,!ye)),Be=r.measureText(be).width,a&&(a<0&&(Re=Be),Be+=a),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&o?l-o:l,t&&l&&ve+ye+Be>xe&&(e?(ye&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||ye+Be>xe?(ye&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+ye===0||(Le===_e?(" "===be&&ye&&Ie(),Te(be,Be),Ie()):Se||Pe?(ye&&Ie(),Te(be,Be)):Te(be,Be)),ke=Le);ye&&Ie(),ve&&De(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ve=r.measureText(t).width,Me.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&He()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[je]);break;case"bottom":Ne(e,"y",-t[Ue])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ve={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=n);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}},{setPoint:Qe,addPoint:Je,toBounds:Ze}=t.TwoPointBoundsHelper;const Ke={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ut(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((r=>{const l=t=>{s(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(tn(e),h.waitViewCompleted((()=>ut(this,void 0,void 0,(function*(){let a,o,s=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,y=c&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)a=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(s=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}a=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,a,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(a).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,S.bounds=A.bounds),A.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(A,S),e.fill=t}else e.__render(A,S);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new t.Bounds;return Ze(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(a),A.copyWorld(e,o,a)}v&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=t.LeaferCanvasBase.prototype,nn=t.Debug.get("@leafer-ui/export");en.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},en.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},en.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,qe),Object.assign(e.ColorConvert,Ve),Object.assign(e.Paint,W),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Ot),Object.assign(e.Effect,Yt),Object.assign(e.Export,Ke),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|