leafer-draw 1.6.0 → 1.6.2
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/web.cjs +59 -51
- package/dist/web.esm.js +59 -51
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +106 -69
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +102 -69
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/web.cjs.map +0 -1
- package/dist/web.esm.js.map +0 -1
- package/dist/web.js.map +0 -1
- package/dist/web.module.js.map +0 -1
package/dist/web.js
CHANGED
|
@@ -2592,7 +2592,11 @@ var LeaferUI = (function (exports) {
|
|
|
2592
2592
|
const point = {};
|
|
2593
2593
|
getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
|
|
2594
2594
|
return point;
|
|
2595
|
-
}
|
|
2595
|
+
},
|
|
2596
|
+
getDerivative(t, fromV, v1, v2, toV) {
|
|
2597
|
+
const o = 1 - t;
|
|
2598
|
+
return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
|
|
2599
|
+
},
|
|
2596
2600
|
};
|
|
2597
2601
|
const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
|
|
2598
2602
|
|
|
@@ -3773,8 +3777,11 @@ var LeaferUI = (function (exports) {
|
|
|
3773
3777
|
load(onSuccess, onError) {
|
|
3774
3778
|
if (!this.loading) {
|
|
3775
3779
|
this.loading = true;
|
|
3780
|
+
let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
|
|
3781
|
+
if (onProgress)
|
|
3782
|
+
loadImage = loadImageWithProgress;
|
|
3776
3783
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
3777
|
-
return yield
|
|
3784
|
+
return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
|
|
3778
3785
|
this.error = e;
|
|
3779
3786
|
this.onComplete(false);
|
|
3780
3787
|
});
|
|
@@ -3799,6 +3806,9 @@ var LeaferUI = (function (exports) {
|
|
|
3799
3806
|
this.view = img;
|
|
3800
3807
|
this.onComplete(true);
|
|
3801
3808
|
}
|
|
3809
|
+
onProgress(progress) {
|
|
3810
|
+
this.progress = progress;
|
|
3811
|
+
}
|
|
3802
3812
|
onComplete(isSuccess) {
|
|
3803
3813
|
let odd;
|
|
3804
3814
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -4264,13 +4274,20 @@ var LeaferUI = (function (exports) {
|
|
|
4264
4274
|
if (leaf.isBranch) {
|
|
4265
4275
|
const { children } = leaf;
|
|
4266
4276
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
4267
|
-
updateAllWorldOpacity
|
|
4277
|
+
updateAllWorldOpacity(children[i]);
|
|
4268
4278
|
}
|
|
4269
4279
|
}
|
|
4270
4280
|
},
|
|
4271
|
-
|
|
4272
|
-
|
|
4281
|
+
updateChange(leaf) {
|
|
4282
|
+
const layout = leaf.__layout;
|
|
4283
|
+
if (layout.stateStyleChanged)
|
|
4284
|
+
leaf.updateState();
|
|
4285
|
+
if (layout.opacityChanged)
|
|
4286
|
+
updateAllWorldOpacity(leaf);
|
|
4273
4287
|
leaf.__updateChange();
|
|
4288
|
+
},
|
|
4289
|
+
updateAllChange(leaf) {
|
|
4290
|
+
updateChange$1(leaf);
|
|
4274
4291
|
if (leaf.isBranch) {
|
|
4275
4292
|
const { children } = leaf;
|
|
4276
4293
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
@@ -4406,7 +4423,7 @@ var LeaferUI = (function (exports) {
|
|
|
4406
4423
|
}
|
|
4407
4424
|
};
|
|
4408
4425
|
const L = LeafHelper;
|
|
4409
|
-
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity:
|
|
4426
|
+
const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1 } = L;
|
|
4410
4427
|
function getTempLocal(t, world) {
|
|
4411
4428
|
t.__layout.update();
|
|
4412
4429
|
return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
|
|
@@ -6128,7 +6145,7 @@ var LeaferUI = (function (exports) {
|
|
|
6128
6145
|
}
|
|
6129
6146
|
}
|
|
6130
6147
|
|
|
6131
|
-
const version = "1.6.
|
|
6148
|
+
const version = "1.6.2";
|
|
6132
6149
|
|
|
6133
6150
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6134
6151
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6494,7 +6511,7 @@ var LeaferUI = (function (exports) {
|
|
|
6494
6511
|
}
|
|
6495
6512
|
}
|
|
6496
6513
|
|
|
6497
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
6514
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
|
|
6498
6515
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
6499
6516
|
function updateMatrix(updateList, levelList) {
|
|
6500
6517
|
let layout;
|
|
@@ -6537,15 +6554,7 @@ var LeaferUI = (function (exports) {
|
|
|
6537
6554
|
});
|
|
6538
6555
|
}
|
|
6539
6556
|
function updateChange(updateList) {
|
|
6540
|
-
|
|
6541
|
-
updateList.list.forEach(leaf => {
|
|
6542
|
-
layout = leaf.__layout;
|
|
6543
|
-
if (layout.opacityChanged)
|
|
6544
|
-
updateAllWorldOpacity(leaf);
|
|
6545
|
-
if (layout.stateStyleChanged)
|
|
6546
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
6547
|
-
leaf.__updateChange();
|
|
6548
|
-
});
|
|
6557
|
+
updateList.list.forEach(updateOneChange);
|
|
6549
6558
|
}
|
|
6550
6559
|
|
|
6551
6560
|
const { worldBounds } = LeafBoundsHelper;
|
|
@@ -6766,6 +6775,15 @@ var LeaferUI = (function (exports) {
|
|
|
6766
6775
|
}
|
|
6767
6776
|
checkRender() {
|
|
6768
6777
|
if (this.running) {
|
|
6778
|
+
const { target } = this;
|
|
6779
|
+
if (target.isApp) {
|
|
6780
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
6781
|
+
target.children.forEach(leafer => {
|
|
6782
|
+
leafer.renderer.FPS = this.FPS;
|
|
6783
|
+
leafer.renderer.checkRender();
|
|
6784
|
+
});
|
|
6785
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
6786
|
+
}
|
|
6769
6787
|
if (this.changed && this.canvas.view)
|
|
6770
6788
|
this.render();
|
|
6771
6789
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -6851,7 +6869,7 @@ var LeaferUI = (function (exports) {
|
|
|
6851
6869
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
6852
6870
|
canvas.clearWorld(bounds, true);
|
|
6853
6871
|
canvas.clipWorld(bounds, true);
|
|
6854
|
-
this.__render(bounds,
|
|
6872
|
+
this.__render(bounds, realBounds);
|
|
6855
6873
|
canvas.restore();
|
|
6856
6874
|
Run.end(t);
|
|
6857
6875
|
}
|
|
@@ -6860,12 +6878,12 @@ var LeaferUI = (function (exports) {
|
|
|
6860
6878
|
const { canvas } = this;
|
|
6861
6879
|
canvas.save();
|
|
6862
6880
|
canvas.clear();
|
|
6863
|
-
this.__render(canvas.bounds
|
|
6881
|
+
this.__render(canvas.bounds);
|
|
6864
6882
|
canvas.restore();
|
|
6865
6883
|
Run.end(t);
|
|
6866
6884
|
}
|
|
6867
|
-
__render(bounds,
|
|
6868
|
-
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
6885
|
+
__render(bounds, realBounds) {
|
|
6886
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
6869
6887
|
if (this.needFill)
|
|
6870
6888
|
canvas.fillWorld(bounds, this.config.fill);
|
|
6871
6889
|
if (Debug.showRepaint)
|
|
@@ -6892,22 +6910,14 @@ var LeaferUI = (function (exports) {
|
|
|
6892
6910
|
}
|
|
6893
6911
|
__requestRender() {
|
|
6894
6912
|
const target = this.target;
|
|
6895
|
-
if (target
|
|
6896
|
-
return target.parentApp.renderer.update(false);
|
|
6897
|
-
if (this.requestTime)
|
|
6913
|
+
if (this.requestTime || !target)
|
|
6898
6914
|
return;
|
|
6915
|
+
if (target.parentApp)
|
|
6916
|
+
return target.parentApp.requestRender(false);
|
|
6899
6917
|
const requestTime = this.requestTime = Date.now();
|
|
6900
6918
|
Platform.requestRender(() => {
|
|
6901
6919
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6902
6920
|
this.requestTime = 0;
|
|
6903
|
-
if (target.isApp) {
|
|
6904
|
-
target.emit(RenderEvent.CHILD_START, target);
|
|
6905
|
-
target.children.forEach(leafer => {
|
|
6906
|
-
leafer.renderer.FPS = this.FPS;
|
|
6907
|
-
leafer.renderer.checkRender();
|
|
6908
|
-
});
|
|
6909
|
-
target.emit(RenderEvent.CHILD_END, target);
|
|
6910
|
-
}
|
|
6911
6921
|
this.checkRender();
|
|
6912
6922
|
});
|
|
6913
6923
|
}
|
|
@@ -7232,13 +7242,11 @@ var LeaferUI = (function (exports) {
|
|
|
7232
7242
|
setFontWeight(value) {
|
|
7233
7243
|
if (typeof value === 'string') {
|
|
7234
7244
|
this.__setInput('fontWeight', value);
|
|
7235
|
-
|
|
7236
|
-
}
|
|
7237
|
-
else {
|
|
7238
|
-
if (this.__input)
|
|
7239
|
-
this.__removeInput('fontWeight');
|
|
7240
|
-
this._fontWeight = value;
|
|
7245
|
+
value = fontWeightMap[value] || 400;
|
|
7241
7246
|
}
|
|
7247
|
+
else if (this.__input)
|
|
7248
|
+
this.__removeInput('fontWeight');
|
|
7249
|
+
this._fontWeight = value;
|
|
7242
7250
|
}
|
|
7243
7251
|
setBoxStyle(value) {
|
|
7244
7252
|
let t = this.__leaf, box = t.__box;
|
|
@@ -7565,6 +7573,9 @@ var LeaferUI = (function (exports) {
|
|
|
7565
7573
|
else
|
|
7566
7574
|
drawer.rect(x, y, width, height);
|
|
7567
7575
|
}
|
|
7576
|
+
drawImagePlaceholder(canvas, _image) {
|
|
7577
|
+
Paint.fill(this.__.placeholderColor, this, canvas);
|
|
7578
|
+
}
|
|
7568
7579
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7569
7580
|
return Plugin.need('animate');
|
|
7570
7581
|
}
|
|
@@ -7801,6 +7812,9 @@ var LeaferUI = (function (exports) {
|
|
|
7801
7812
|
__decorate([
|
|
7802
7813
|
effectType()
|
|
7803
7814
|
], exports.UI.prototype, "filter", void 0);
|
|
7815
|
+
__decorate([
|
|
7816
|
+
surfaceType()
|
|
7817
|
+
], exports.UI.prototype, "placeholderColor", void 0);
|
|
7804
7818
|
__decorate([
|
|
7805
7819
|
dataType({})
|
|
7806
7820
|
], exports.UI.prototype, "data", void 0);
|
|
@@ -8631,10 +8645,11 @@ var LeaferUI = (function (exports) {
|
|
|
8631
8645
|
get ready() { return this.image ? this.image.ready : false; }
|
|
8632
8646
|
constructor(data) {
|
|
8633
8647
|
super(data);
|
|
8634
|
-
this.
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8648
|
+
this.on_(ImageEvent.LOADED, this.__onLoaded, this);
|
|
8649
|
+
}
|
|
8650
|
+
__onLoaded(e) {
|
|
8651
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
8652
|
+
this.image = e.image;
|
|
8638
8653
|
}
|
|
8639
8654
|
destroy() {
|
|
8640
8655
|
this.image = null;
|
|
@@ -8748,7 +8763,7 @@ var LeaferUI = (function (exports) {
|
|
|
8748
8763
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8749
8764
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8750
8765
|
data.__clipText = textOverflow !== 'show' && !data.__autoSize;
|
|
8751
|
-
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8766
|
+
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
|
|
8752
8767
|
}
|
|
8753
8768
|
__updateBoxBounds() {
|
|
8754
8769
|
const data = this.__;
|
|
@@ -8846,6 +8861,9 @@ var LeaferUI = (function (exports) {
|
|
|
8846
8861
|
__decorate([
|
|
8847
8862
|
boundsType('')
|
|
8848
8863
|
], exports.Text.prototype, "text", void 0);
|
|
8864
|
+
__decorate([
|
|
8865
|
+
boundsType('')
|
|
8866
|
+
], exports.Text.prototype, "placeholder", void 0);
|
|
8849
8867
|
__decorate([
|
|
8850
8868
|
boundsType('caption')
|
|
8851
8869
|
], exports.Text.prototype, "fontFamily", void 0);
|
|
@@ -8965,8 +8983,10 @@ var LeaferUI = (function (exports) {
|
|
|
8965
8983
|
}
|
|
8966
8984
|
|
|
8967
8985
|
function fillText(ui, canvas) {
|
|
8968
|
-
|
|
8969
|
-
|
|
8986
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
8987
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
8988
|
+
canvas.fillStyle = data.placeholderColor;
|
|
8989
|
+
let row;
|
|
8970
8990
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
8971
8991
|
row = rows[i];
|
|
8972
8992
|
if (row.text)
|
|
@@ -8975,7 +8995,7 @@ var LeaferUI = (function (exports) {
|
|
|
8975
8995
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
8976
8996
|
}
|
|
8977
8997
|
if (decorationY) {
|
|
8978
|
-
const { decorationColor, decorationHeight } = data;
|
|
8998
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
8979
8999
|
if (decorationColor)
|
|
8980
9000
|
canvas.fillStyle = decorationColor;
|
|
8981
9001
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -8984,38 +9004,44 @@ var LeaferUI = (function (exports) {
|
|
|
8984
9004
|
|
|
8985
9005
|
function fill(fill, ui, canvas) {
|
|
8986
9006
|
canvas.fillStyle = fill;
|
|
8987
|
-
|
|
9007
|
+
fillPathOrText(ui, canvas);
|
|
8988
9008
|
}
|
|
8989
9009
|
function fills(fills, ui, canvas) {
|
|
8990
9010
|
let item;
|
|
8991
|
-
const { windingRule, __font } = ui.__;
|
|
8992
9011
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
8993
9012
|
item = fills[i];
|
|
8994
|
-
if (item.image
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
if (item.blendMode)
|
|
9002
|
-
canvas.blendMode = item.blendMode;
|
|
9003
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
9004
|
-
canvas.restore();
|
|
9013
|
+
if (item.image) {
|
|
9014
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
9015
|
+
continue;
|
|
9016
|
+
if (!item.style) {
|
|
9017
|
+
if (!i && item.image.isPlacehold)
|
|
9018
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
9019
|
+
continue;
|
|
9005
9020
|
}
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9021
|
+
}
|
|
9022
|
+
canvas.fillStyle = item.style;
|
|
9023
|
+
if (item.transform) {
|
|
9024
|
+
canvas.save();
|
|
9025
|
+
canvas.transform(item.transform);
|
|
9026
|
+
if (item.blendMode)
|
|
9027
|
+
canvas.blendMode = item.blendMode;
|
|
9028
|
+
fillPathOrText(ui, canvas);
|
|
9029
|
+
canvas.restore();
|
|
9030
|
+
}
|
|
9031
|
+
else {
|
|
9032
|
+
if (item.blendMode) {
|
|
9033
|
+
canvas.saveBlendMode(item.blendMode);
|
|
9034
|
+
fillPathOrText(ui, canvas);
|
|
9035
|
+
canvas.restoreBlendMode();
|
|
9015
9036
|
}
|
|
9037
|
+
else
|
|
9038
|
+
fillPathOrText(ui, canvas);
|
|
9016
9039
|
}
|
|
9017
9040
|
}
|
|
9018
9041
|
}
|
|
9042
|
+
function fillPathOrText(ui, canvas) {
|
|
9043
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
9044
|
+
}
|
|
9019
9045
|
|
|
9020
9046
|
function strokeText(stroke, ui, canvas) {
|
|
9021
9047
|
const { strokeAlign } = ui.__;
|
|
@@ -9255,6 +9281,7 @@ var LeaferUI = (function (exports) {
|
|
|
9255
9281
|
compute,
|
|
9256
9282
|
fill,
|
|
9257
9283
|
fills,
|
|
9284
|
+
fillPathOrText,
|
|
9258
9285
|
fillText,
|
|
9259
9286
|
stroke,
|
|
9260
9287
|
strokes,
|
|
@@ -9447,6 +9474,13 @@ var LeaferUI = (function (exports) {
|
|
|
9447
9474
|
onLoadError(ui, event, error);
|
|
9448
9475
|
leafPaint.loadId = null;
|
|
9449
9476
|
});
|
|
9477
|
+
if (ui.placeholderColor)
|
|
9478
|
+
setTimeout(() => {
|
|
9479
|
+
if (!(image.ready || image.isPlacehold)) {
|
|
9480
|
+
image.isPlacehold = true;
|
|
9481
|
+
ui.forceUpdate('surface');
|
|
9482
|
+
}
|
|
9483
|
+
}, 100);
|
|
9450
9484
|
}
|
|
9451
9485
|
return leafPaint;
|
|
9452
9486
|
}
|
|
@@ -10640,4 +10674,7 @@ var LeaferUI = (function (exports) {
|
|
|
10640
10674
|
return exports;
|
|
10641
10675
|
|
|
10642
10676
|
})({});
|
|
10643
|
-
|
|
10677
|
+
|
|
10678
|
+
function Leafer(opt) { return new LeaferUI.Leafer(opt); }
|
|
10679
|
+
Object.setPrototypeOf(Leafer, LeaferUI);
|
|
10680
|
+
Leafer.prototype = LeaferUI.Leafer.prototype;
|
package/dist/web.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function r(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const r=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(r,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:a}=navigator;a.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):a.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),a.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):a.indexOf("Mac")>-1?t.Platform.os="Mac":a.indexOf("Linux")>-1&&(t.Platform.os="Linux");class d{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:l,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{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,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;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||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),y.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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;e&&(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,s=e.getIntersect(i.bounds),o=new t.Bounds(s);i.save(),s.spread(x.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,e.includes(this.target.__world),o),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{canvas:s}=this,o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}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=this.target;if(e.parentApp)return e.parentApp.renderer.update(!1);if(this.requestTime)return;const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.checkRender()}))}__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.update()}}__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||v.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 b(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[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)}));if(o){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?L(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:o,__font:r}=i.__,a=s.getSameCanvas(!0,!0);a.setStroke(n?void 0:e,2*o,i.__),a.font=r,n?L(e,!0,i,a):R(i,a),a.blendMode="outside"===t?"destination-out":"destination-in",b(i,a),a.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(a,i.__nowWorld):s.copyWorldToInner(a,i.__nowWorld,i.__layout.renderBounds),a.recycle(i.__nowWorld)}function R(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[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)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function L(t,n,i,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}function k(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:P,getOuterOf:S,getByMove:C,getIntersectData:A}=t.BoundsHelper;let O;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:r,color:a,opacity:d}=n;return{type:o,blendMode:r,style:e.ColorConvert.string(a,d)};case"image":return e.PaintImage.image(i,t,n,s,!O||!O[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const M={compute:function(t,n){const i=n.__,s=[];let o,r=i.__input[t];r instanceof Array||(r=[r]),O=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)e=W(t,r[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:r}=n.__;for(let a=0,d=t.length;a<d;a++)s=t[a],s.image&&e.PaintImage.checkImage(n,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?b(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?b(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):r?b(n,i):o?i.fill(o):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=i;if(s)if(r)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&k(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,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*s,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:s,strokeAlign:o,__font:r}=i;if(s)if(r)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),L(t,!1,e,n),i.__useArrow&&k(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),L(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=a=s;else{const{renderShapeSpread:i}=t.__layout,h=A(i?P(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);r=e.bounds.getFitMatrix(h);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),a=S(s,r),o=C(a,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:o,worldCanvas:d,shapeBounds:a,scaleX:l,scaleY:c}}};let I={};const{get:T,rotateOfOuter:D,translate:z,scaleOfOuter:F,scale:H,rotate:G}=t.MatrixHelper;function j(t,e,n,i,s,o,r){const a=T();z(a,e.x+n,e.y+i),H(a,s,o),r&&D(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function V(t,e,n,i,s,o,r){const a=T();z(a,e.x+n,e.y+i),s&&H(a,s,o),r&&G(a,r),t.transform=a}function Y(t,e,n,i,s,o,r,a,d,l){const c=T();if(d)if("center"===l)D(c,{x:n/2,y:i/2},d);else switch(G(c,d),d){case 90:z(c,i,0);break;case 180:z(c,n,i);break;case 270:z(c,0,n)}I.x=e.x+s,I.y=e.y+o,z(c,I.x,I.y),r&&F(c,I,r,a),t.transform=c}const{get:N,translate:U}=t.MatrixHelper,q=new t.Bounds,X={},Q={};function K(t,e,n,i){const{blendMode:s,changeful:o,sync:r}=n;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=Z(n,i,e)}function Z(e,n,i){let{width:s,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:a,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:a},w="center"!==d&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(a&&"cover"!==a&&"fit"!==a)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),v=Q.scaleX,x=Q.scaleY);else if(!g||u){const t=n.width/m,e=n.height/y;v=x="fit"===a?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,E+=(n.height-o*x)/2}if(d){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(d,e,n,X,!0),b+=X.x,E+=X.y}switch(l&&(b+=l.x,E+=l.y),a){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(b||E||v||u)&&V(_,n,b,E,v,x,u);break;case"repeat":(!g||v||u)&&Y(_,n,s,o,b,E,v,x,u,d),f||(_.repeat="repeat");break;default:v&&j(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=N(),U(_.transform,n.x,n.y)),v&&"stretch"!==a&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,r&&(_.opacity=r),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let $,J=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(t,e,n,i,s,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 s.data||K(s,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function st(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:at,scale:dt,copy:lt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=ht(s),o=ht(o);const{image:e,data:a}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=a;u&&(l=at(),lt(l,p),dt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(d=Math.sqrt(_/w)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=at(),p&<(l,p)),dt(l,1/s,1/o));const m=e.getCanvas(ct(c)||1,ct(h)||1,a.opacity,a.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=y,n.patternId=r,!0}}function ft(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{d(i.next(t))}catch(t){o(t)}}function a(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pt}=Math;const gt={image:function(e,n,i,s,o){let r,a;const d=t.ImageManager.get(i);return $&&i===$.paint&&tt(s,$.boxBounds)?r=$.leafPaint:(r={type:i.type,image:d},$=d.use>1?{leafPaint:r,paint:i,boxBounds:J.set(s)}:null),(o||d.loading)&&(a={image:d,attrName:n,attrValue:i}),d.ready?(et(e,n,i,d,r,s),o&&(nt(e,a),it(e,a))):d.error?o&&st(e,a,d.error):(o&&(rt(e,!0),nt(e,a)),r.loadId=d.load((()=>{rt(e,!1),e.destroyed||(et(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,a)),r.loadId=null}),(t=>{rt(e,!1),st(e,a,t),r.loadId=null}))),r},checkImage:function(n,i,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:d}=i,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+d&&!e.Export.running)return!1;if(o)if(l.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=l;e*=pt(r)*d,n*=pt(a)*d,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,l),!0):(!s.style||s.sync||e.Export.running?ut(n,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ut(n,s,d),n.forceUpdate("surface")}))),300)),!1)},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,r,a,d;for(let l=0,c=i.length;l<c;l++)s=i[l],o=s.image,d=o&&o.url,d&&(r||(r={}),r[d]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),o.unload(i[l].loadId,!a.some((t=>t.url===d)))));return r}return null},createData:K,getPatternData:Z,fillOrFitMode:j,clipMode:V,repeatMode:Y},{toPoint:_t}=t.AroundHelper,wt={},mt={};function yt(t,n,i){if(n){let s;for(let o=0,r=n.length;o<r;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(r-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:vt,getDistance:xt}=t.PointHelper,{get:bt,rotateOfOuter:Et,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Lt={},kt={};function Pt(t,e,n,i,s){let o;const{width:r,height:a}=t;if(r!==a||i){const t=vt(e,n);o=bt(),s?(Bt(o,e,r/a*(i||1),1),Et(o,e,t+90)):(Bt(o,e,1,r/a*(i||1)),Et(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,At={},Ot={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:r,opacity:a}=e;_t(i||"top",n,wt),_t(s||"bottom",n,mt);const d=t.Platform.canvas.createLinearGradient(wt.x,wt.y,mt.x,mt.y);yt(d,e.stops,a);const l={type:o,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:d}=e;Rt(i||"center",n,Lt),Rt(s||"bottom",n,kt);const l=t.Platform.canvas.createRadialGradient(Lt.x,Lt.y,0,Lt.x,Lt.y,xt(Lt,kt));yt(l,e.stops,r);const c={type:o,style:l},h=Pt(n,Lt,kt,d,!0);return h&&(c.transform=h),a&&(c.blendMode=a),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:d}=e;Ct(i||"center",n,At),Ct(s||"bottom",n,Ot);const l=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,Ot));yt(l,e.stops,r);const c={type:o,style:l},h=Pt(n,At,Ot,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),a&&(c.blendMode=a),c},getTransform:Pt},{copy:Mt,toOffsetOutBounds:It}=t.BoundsHelper,Tt={},Dt={};function zt(e,n,i,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Mt(Tt,e.bounds),Tt.x+=n.x-r.x,Tt.y+=n.y-r.y,i){const{matrix:t}=s;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(s.canvas,e.bounds,Tt)}else i&&(Mt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,r,i?Tt:n)}const{toOffsetOutBounds:Ft}=t.BoundsHelper,Ht={};const Gt={shadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;It(c,Dt),d.forEach(((d,_)=>{p.setWorldShadow(Dt.offsetX+d.x*u,Dt.offsetY+d.y*f,d.blur*u,e.ColorConvert.string(d.color)),o=d.spread?1+2*d.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,zt(p,Dt,o,i),s=c,d.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,c,r,"copy"),s=r),l?p.copyWorld(l,r,r,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,r,d.blendMode):n.copyWorldToInner(p,s,a.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=d.length-1;Ft(c,Ht),d.forEach(((d,_)=>{p.save(),p.setWorldShadow(Ht.offsetX+d.x*u,Ht.offsetY+d.y*f,d.blur*u),o=d.spread?1-2*d.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,zt(p,Ht,o,i),p.restore(),l?(p.copyWorld(p,c,r,"copy"),p.copyWorld(l,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,r,d.blendMode):n.copyWorldToInner(p,s,a.renderBounds,d.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},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:jt}=t.LeafBoundsHelper;function Vt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,o);break;case"path":n.restore()}}function Yt(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,r,a;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],a=n.__.mask,a&&(r&&(Vt(this,r,t,s,i,o),i=s=null),"path"===a||"clipping-path"===a?(n.opacity<1?(r="opacity-path",o=n.opacity,s||(s=Yt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",i||(i=Yt(t)),s||(s=Yt(t)),n.__render(i,e)),"clipping"!==a&&"clipping-path"!==a)||jt(n,e)||n.__render(s||t,e);Vt(this,r,t,s,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Kt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=Qt(Ut),Jt=Qt(qt),te=Qt("- —/~|┆·");var ee;!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"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:oe,Symbol:re,Break:ae}=ee;function de(t){return Kt[t]?ne:te[t]?ae:Zt[t]?se:$t[t]?oe:Jt[t]?re:Xt.test(t)?ie:ne}const le={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ce(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:he}=le,{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:we}=ee;let me,ye,ve,xe,be,Ee,Be,Re,Le,ke,Pe,Se,Ce,Ae,Oe,We,Me,Ie=[];function Te(t,e){Le&&!Re&&(Re=Le),me.data.push({char:t,width:e}),ve+=e}function De(){xe+=ve,me.width=ve,ye.words.push(me),me={data:[]},ve=0}function ze(){Ae&&(Oe.paraNumber++,ye.paraStart=!0,Ae=!1),Le&&(ye.startCharSize=Re,ye.endCharSize=Le,Re=0),ye.width=xe,We.width?he(ye):Me&&Fe(),Ie.push(ye),ye={words:[]},xe=0}function Fe(){xe>(Oe.maxWidth||0)&&(Oe.maxWidth=xe)}const{top:He,right:Ge,bottom:je,left:Ve}=t.Direction4;function Ye(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ne={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:d,__font:l,__padding:c}=i;c&&(r?(s=c[Ve],r-=c[Ge]+c[Ve]):i.autoSizeAlign||(s=c[Ve]),a?(o=c[He],a-=c[He]+c[je]):i.autoSizeAlign||(o=c[He]));const h={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Oe=e,Ie=e.rows,We=e.bounds,Me=!We.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=i,{canvas:a}=t.Platform,{width:d,height:l}=We;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,Pe=null,Re=Be=Le=ve=xe=0,me={data:[]},ye={words:[]};for(let i=0,l=n.length;i<l;i++)Ee=n[i],"\n"===Ee?(ve&&De(),ye.paraEnd=!0,ze(),Ae=!0):(ke=de(Ee),ke===ue&&"none"!==r&&(Ee=ce(Ee,r,!ve)),Be=a.measureText(Ee).width,s&&(s<0&&(Le=Be),Be+=s),Se=ke===fe&&(Pe===fe||Pe===ue)||Pe===fe&&ke!==ge,Ce=!(ke!==pe&&ke!==fe||Pe!==_e&&Pe!==ge),be=Ae&&o?d-o:d,t&&d&&xe+ve+Be>be&&(e?(ve&&De(),xe&&ze()):(Ce||(Ce=ke===ue&&Pe==ge),Se||Ce||ke===we||ke===pe||ke===fe||ve+Be>be?(ve&&De(),xe&&ze()):xe&&ze()))," "===Ee&&!0!==Ae&&xe+ve===0||(ke===we?(" "===Ee&&ve&&De(),Te(Ee,Be),De()):Se||Ce?(ve&&De(),Te(Ee,Be)):Te(Ee,Be)),Pe=ke);ve&&De(),xe&&ze(),Ie.length>0&&(Ie[Ie.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,xe=a.measureText(t).width,Ie.push({x:o||0,text:t,width:xe,paraStart:!0}),Me&&Fe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ye(e,"x",t[Ve]);break;case"right":Ye(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ye(e,"y",t[He]);break;case"bottom":Ye(e,"y",-t[je])}}(c,h,i,r,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:d,textAlign:l,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=o*s+(h?h*(t.paraNumber-1):0),m=r;if(d&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=n[r],y.x=f,y.width<g||y.width>g&&!d)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=o,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,a<0&&(y.width<0?(x=-y.width+e.fontSize+a,v-=x,x+=e.fontSize):x-=a),v<i.x&&(i.x=v),x>i.width&&(i.width=x),d&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,d,l,c,h,u;i.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-l)/(u-1):0,c=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:a},a=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,a,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):a=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||n===u-1||(a+=d,t.width+=d)}))),t.words=null)}))}(h,i,r),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=n;if(o.splice(r),a&&"show"!==a){let e,d;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,c=i+s-l;("none"===n.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<c));i--){if(d<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,r),"none"!==d&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Ue={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 s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,Ue),Object.assign(e.Paint,M),Object.assign(e.PaintImage,gt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Gt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=d,exports.useCanvas=r,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");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function r(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const r=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(r,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:a}=navigator;a.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):a.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),a.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):a.indexOf("Mac")>-1?t.Platform.os="Mac":a.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{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:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{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,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;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||c(i[t])}c(n)}}))}(this.__levelList),function(t){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,l,this.times)),i.emitEvent(new t.LayoutEvent(a,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),y.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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;e&&(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,s=e.getIntersect(i.bounds),o=new t.Bounds(s);i.save(),s.spread(x.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}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=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__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.update()}}__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||v.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 b(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:r}=i.__,a=s.getSameCanvas(!0,!0);a.setStroke(n?void 0:e,2*o,i.__),a.font=r,n?k(e,!0,i,a):L(i,a),a.blendMode="outside"===t?"destination-out":"destination-in",b(i,a),a.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(a,i.__nowWorld):s.copyWorldToInner(a,i.__nowWorld,i.__layout.renderBounds),a.recycle(i.__nowWorld)}function L(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[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)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function k(t,n,i,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:C,getByMove:A,getIntersectData:O}=t.BoundsHelper;let W;function M(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:r,color:a,opacity:l}=n;return{type:o,blendMode:r,style:e.ColorConvert.string(a,l)};case"image":return e.PaintImage.image(i,t,n,s,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const I={compute:function(t,n){const i=n.__,s=[];let o,r=i.__input[t];r instanceof Array||(r=[r]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)e=M(t,r[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,E(e,n)},fills:function(t,n,i){let s;for(let o=0,r=t.length;o<r;o++){if(s=t[o],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),E(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),E(n,i),i.restoreBlendMode()):E(n,i)}},fillPathOrText:E,fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=i;if(s)if(r)B(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,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*s,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:s,strokeAlign:o,__font:r}=i;if(s)if(r)B(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),k(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=a=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);r=e.bounds.getFitMatrix(h);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),a=C(s,r),o=A(a,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:o,worldCanvas:l,shapeBounds:a,scaleX:d,scaleY:c}}};let T={};const{get:D,rotateOfOuter:z,translate:F,scaleOfOuter:H,scale:G,rotate:j}=t.MatrixHelper;function V(t,e,n,i,s,o,r){const a=D();F(a,e.x+n,e.y+i),G(a,s,o),r&&z(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Y(t,e,n,i,s,o,r){const a=D();F(a,e.x+n,e.y+i),s&&G(a,s,o),r&&j(a,r),t.transform=a}function U(t,e,n,i,s,o,r,a,l,d){const c=D();if(l)if("center"===d)z(c,{x:n/2,y:i/2},l);else switch(j(c,l),l){case 90:F(c,i,0);break;case 180:F(c,n,i);break;case 270:F(c,0,n)}T.x=e.x+s,T.y=e.y+o,F(c,T.x,T.y),r&&H(c,T,r,a),t.transform=c}const{get:N,translate:q}=t.MatrixHelper,X=new t.Bounds,Q={},K={};function Z(t,e,n,i){const{blendMode:s,changeful:o,sync:r}=n;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=$(n,i,e)}function $(e,n,i){let{width:s,height:o}=i;e.padding&&(n=X.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:a,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:a},w="center"!==l&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(a&&"cover"!==a&&"fit"!==a)(c||h)&&(t.MathHelper.getScaleData(c,h,i,K),v=K.scaleX,x=K.scaleY);else if(!g||u){const t=n.width/m,e=n.height/y;v=x="fit"===a?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,E+=(n.height-o*x)/2}if(l){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,n,Q,!0),b+=Q.x,E+=Q.y}switch(d&&(b+=d.x,E+=d.y),a){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(b||E||v||u)&&Y(_,n,b,E,v,x,u);break;case"repeat":(!g||v||u)&&U(_,n,s,o,b,E,v,x,u,l),f||(_.repeat="repeat");break;default:v&&V(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=N(),q(_.transform,n.x,n.y)),v&&"stretch"!==a&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,r&&(_.opacity=r),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let J,tt=new t.Bounds;const{isSame:et}=t.BoundsHelper;function nt(t,e,n,i,s,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 s.data||Z(s,i,n,o),!0}function it(e,n){rt(e,t.ImageEvent.LOAD,n)}function st(e,n){rt(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),rt(e,t.ImageEvent.ERROR,n)}function rt(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:lt,scale:dt,copy:ct}=t.MatrixHelper,{ceil:ht,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:a}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=a;u&&(d=lt(),ct(d,p),dt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(d||(d=lt(),p&&ct(d,p)),dt(d,1/s,1/o));const m=e.getCanvas(ht(c)||1,ht(h)||1,a.opacity,a.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=r,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let r,a;const l=t.ImageManager.get(i);return J&&i===J.paint&&et(s,J.boxBounds)?r=J.leafPaint:(r={type:i.type,image:l},J=l.use>1?{leafPaint:r,paint:i,boxBounds:tt.set(s)}:null),(o||l.loading)&&(a={image:l,attrName:n,attrValue:i}),l.ready?(nt(e,n,i,l,r,s),o&&(it(e,a),st(e,a))):l.error?o&&ot(e,a,l.error):(o&&(at(e,!0),it(e,a)),r.loadId=l.load((()=>{at(e,!1),e.destroyed||(nt(e,n,i,l,r,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,a)),r.loadId=null}),(t=>{at(e,!1),ot(e,a,t),r.loadId=null})),e.placeholderColor&&setTimeout((()=>{l.ready||l.isPlacehold||(l.isPlacehold=!0,e.forceUpdate("surface"))}),100)),r},checkImage:function(n,i,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===r+"-"+a+"-"+l&&!e.Export.running)return!1;if(o)if(d.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=gt(r)*l,n*=gt(a)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,d),!0):(!s.style||s.sync||e.Export.running?ft(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ft(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,r,a,l;for(let d=0,c=i.length;d<c;d++)s=i[d],o=s.image,l=o&&o.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),o.unload(i[d].loadId,!a.some((t=>t.url===l)))));return r}return null},createData:Z,getPatternData:$,fillOrFitMode:V,clipMode:Y,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},yt={};function vt(t,n,i){if(n){let s;for(let o=0,r=n.length;o<r;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(r-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:xt,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Bt,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:r,height:a}=t;if(r!==a||i){const t=xt(e,n);o=Et(),s?(Rt(o,e,r/a*(i||1),1),Bt(o,e,t+90)):(Rt(o,e,1,r/a*(i||1)),Bt(o,e,t))}return o}const{getDistance:Ct}=t.PointHelper,{toPoint:At}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:r,opacity:a}=e;wt(i||"top",n,mt),wt(s||"bottom",n,yt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,yt.x,yt.y);vt(l,e.stops,a);const d={type:o,style:l};return r&&(d.blendMode=r),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:l}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const d=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));vt(d,e.stops,r);const c={type:o,style:d},h=St(n,kt,Pt,l,!0);return h&&(c.transform=h),a&&(c.blendMode=a),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:r,blendMode:a,stretch:l}=e;At(i||"center",n,Ot),At(s||"bottom",n,Wt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Ct(Ot,Wt));vt(d,e.stops,r);const c={type:o,style:d},h=St(n,Ot,Wt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),a&&(c.blendMode=a),c},getTransform:St},{copy:It,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},zt={};function Ft(e,n,i,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(It(Dt,e.bounds),Dt.x+=n.x-r.x,Dt.y+=n.y-r.y,i){const{matrix:t}=s;Dt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Dt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(s.canvas,e.bounds,Dt)}else i&&(It(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(s.canvas,r,i?Dt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Gt={};const jt={shadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Tt(c,zt),l.forEach(((l,_)=>{p.setWorldShadow(zt.offsetX+l.x*u,zt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(p,zt,o,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,r,"copy"),s=r),d?p.copyWorld(d,r,r,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,r,l.blendMode):n.copyWorldToInner(p,s,a.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:r,__layout:a}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Ht(c,Gt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(p,Gt,o,i),p.restore(),d?(p.copyWorld(p,c,r,"copy"),p.copyWorld(d,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,r,l.blendMode):n.copyWorldToInner(p,s,a.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},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:Vt}=t.LeafBoundsHelper;function Yt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,r,a;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],a=n.__.mask,a&&(r&&(Yt(this,r,t,s,i,o),i=s=null),"path"===a||"clipping-path"===a?(n.opacity<1?(r="opacity-path",o=n.opacity,s||(s=Ut(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==a&&"clipping-path"!==a)||Vt(n,e)||n.__render(s||t,e);Yt(this,r,t,s,i,o)};const qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xt=qt+"_#~&*+\\=|≮≯≈≠=…",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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Kt(qt),te=Kt(Xt),ee=Kt("- —/~|┆·");var ne;!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"}(ne||(ne={}));const{Letter:ie,Single:se,Before:oe,After:re,Symbol:ae,Break:le}=ne;function de(t){return Zt[t]?ie:ee[t]?le:$t[t]?oe:Jt[t]?re:te[t]?ae:Qt.test(t)?se:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function he(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:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ye,ve,xe,be,Ee,Be,Re,Le,ke,Pe,Se,Ce,Ae,Oe,We,Me,Ie,Te=[];function De(t,e){ke&&!Le&&(Le=ke),ye.data.push({char:t,width:e}),xe+=e}function ze(){be+=xe,ye.width=xe,ve.words.push(ye),ye={data:[]},xe=0}function Fe(){Oe&&(We.paraNumber++,ve.paraStart=!0,Oe=!1),ke&&(ve.startCharSize=Le,ve.endCharSize=ke,Le=0),ve.width=be,Me.width?ue(ve):Ie&&He(),Te.push(ve),ve={words:[]},be=0}function He(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const{top:Ge,right:je,bottom:Ve,left:Ye}=t.Direction4;function Ue(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ne={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(r?(s=c[Ye],r-=c[je]+c[Ye]):i.autoSizeAlign||(s=c[Ye]),a?(o=c[Ge],a-=c[Ge]+c[Ve]):i.autoSizeAlign||(o=c[Ge]));const h={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){We=e,Te=e.rows,Me=e.bounds,Ie=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=i,{canvas:a}=t.Platform,{width:l,height:d}=Me;if(l||d||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Le=Re=ke=xe=be=0,ye={data:[]},ve={words:[]};for(let i=0,d=n.length;i<d;i++)Be=n[i],"\n"===Be?(xe&&ze(),ve.paraEnd=!0,Fe(),Oe=!0):(Pe=de(Be),Pe===fe&&"none"!==r&&(Be=he(Be,r,!xe)),Re=a.measureText(Be).width,s&&(s<0&&(ke=Re),Re+=s),Ce=Pe===pe&&(Se===pe||Se===fe)||Se===pe&&Pe!==_e,Ae=!(Pe!==ge&&Pe!==pe||Se!==we&&Se!==_e),Ee=Oe&&o?l-o:l,t&&l&&be+xe+Re>Ee&&(e?(xe&&ze(),be&&Fe()):(Ae||(Ae=Pe===fe&&Se==_e),Ce||Ae||Pe===me||Pe===ge||Pe===pe||xe+Re>Ee?(xe&&ze(),be&&Fe()):be&&Fe()))," "===Be&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Be&&xe&&ze(),De(Be,Re),ze()):Ce||Ae?(xe&&ze(),De(Be,Re)):De(Be,Re)),Se=Pe);xe&&ze(),be&&Fe(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=a.measureText(t).width,Te.push({x:o||0,text:t,width:be,paraStart:!0}),Ie&&He()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ue(e,"x",t[Ye]);break;case"right":Ue(e,"x",-t[je])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ue(e,"y",t[Ge]);break;case"bottom":Ue(e,"y",-t[Ve])}}(c,h,i,r,a),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=o*s+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=n[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=o,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,a<0&&(y.width<0?(x=-y.width+e.fontSize+a,v-=x,x+=e.fontSize):x-=a),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,a=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:a},a=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,a,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):a=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||n===u-1||(a+=l,t.width+=l)}))),t.words=null)}))}(h,i,r),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=n;if(o.splice(r),a&&"show"!==a){let e,l;"hide"===a?a="":"ellipsis"===a&&(a="...");const d=a?t.Platform.canvas.measureText(a).width:0,c=i+s-d;("none"===n.textWrap?o:[o[r-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||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:a,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,r),"none"!==l&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};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 s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,qe),Object.assign(e.Paint,I),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,jt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,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]}})}));
|
|
2
2
|
//# sourceMappingURL=web.min.cjs.map
|