leafer-ui 2.2.8 → 2.2.10
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/README.md +1 -1
- package/dist/web.cjs +55 -26
- package/dist/web.esm.js +55 -26
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +65 -34
- 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 +66 -34
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.js
CHANGED
|
@@ -2800,7 +2800,7 @@ var LeaferUI = function(exports) {
|
|
|
2800
2800
|
toCommand(_nodes) {
|
|
2801
2801
|
return [];
|
|
2802
2802
|
},
|
|
2803
|
-
toNode(_data) {
|
|
2803
|
+
toNode(_data, _filterSamePoint) {
|
|
2804
2804
|
return [];
|
|
2805
2805
|
}
|
|
2806
2806
|
};
|
|
@@ -6626,7 +6626,7 @@ var LeaferUI = function(exports) {
|
|
|
6626
6626
|
this.levelMap = null;
|
|
6627
6627
|
}
|
|
6628
6628
|
}
|
|
6629
|
-
const version = "2.2.
|
|
6629
|
+
const version = "2.2.10";
|
|
6630
6630
|
const debug$5 = Debug.get("LeaferCanvas");
|
|
6631
6631
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6632
6632
|
set zIndex(zIndex) {
|
|
@@ -8285,7 +8285,7 @@ var LeaferUI = function(exports) {
|
|
|
8285
8285
|
getPath(curve, pathForRender) {
|
|
8286
8286
|
this.__layout.update();
|
|
8287
8287
|
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
8288
|
-
if (!path) pen.set(path = []), this.__drawPathByBox(pen, !pathForRender);
|
|
8288
|
+
if (!path) pen.set(path = []), this.__drawPathByBox(pen, "box", !pathForRender);
|
|
8289
8289
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
8290
8290
|
}
|
|
8291
8291
|
getPathString(curve, pathForRender, floatLength) {
|
|
@@ -8323,10 +8323,10 @@ var LeaferUI = function(exports) {
|
|
|
8323
8323
|
data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
|
|
8324
8324
|
}
|
|
8325
8325
|
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8326
|
-
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
8326
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, "box", ignoreCornerRadius);
|
|
8327
8327
|
}
|
|
8328
|
-
__drawPathByBox(drawer, ignoreCornerRadius) {
|
|
8329
|
-
const {x: x, y: y, width: width, height: height} = this.__layout
|
|
8328
|
+
__drawPathByBox(drawer, boundsType = "box", ignoreCornerRadius) {
|
|
8329
|
+
const {x: x, y: y, width: width, height: height} = this.__layout[boundsType + "Bounds"];
|
|
8330
8330
|
if (this.__.cornerRadius && !ignoreCornerRadius) {
|
|
8331
8331
|
const {cornerRadius: cornerRadius} = this.__;
|
|
8332
8332
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
@@ -9246,14 +9246,15 @@ var LeaferUI = function(exports) {
|
|
|
9246
9246
|
}
|
|
9247
9247
|
__updateTextDrawData() {
|
|
9248
9248
|
const data = this.__;
|
|
9249
|
-
const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9249
|
+
const {lineHeight: lineHeight, letterSpacing: letterSpacing, wordSpacing: wordSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
|
|
9250
9250
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
9251
9251
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
9252
|
+
data.__wordSpacing = UnitConvert.number(wordSpacing, fontSize);
|
|
9252
9253
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
|
|
9253
9254
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9254
9255
|
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9255
9256
|
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9256
|
-
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9257
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.__wordSpacing || data.motionText || textCase !== "none");
|
|
9257
9258
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9258
9259
|
}
|
|
9259
9260
|
__updateBoxBounds() {
|
|
@@ -9333,6 +9334,7 @@ var LeaferUI = function(exports) {
|
|
|
9333
9334
|
__decorate([ boundsType("none") ], exports.Text.prototype, "textCase", void 0);
|
|
9334
9335
|
__decorate([ boundsType("none") ], exports.Text.prototype, "textDecoration", void 0);
|
|
9335
9336
|
__decorate([ boundsType(0) ], exports.Text.prototype, "letterSpacing", void 0);
|
|
9337
|
+
__decorate([ boundsType(0) ], exports.Text.prototype, "wordSpacing", void 0);
|
|
9336
9338
|
__decorate([ boundsType({
|
|
9337
9339
|
type: "percent",
|
|
9338
9340
|
value: 1.5
|
|
@@ -11143,7 +11145,7 @@ var LeaferUI = function(exports) {
|
|
|
11143
11145
|
if (scaleX !== 1) canvas.scale(scaleX, scaleY);
|
|
11144
11146
|
}
|
|
11145
11147
|
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
11146
|
-
fillPathOrText(ui, canvas, renderOptions);
|
|
11148
|
+
fillPathOrText(ui, canvas, renderOptions, true);
|
|
11147
11149
|
canvas.restore();
|
|
11148
11150
|
} else {
|
|
11149
11151
|
if (originPaint.blendMode) {
|
|
@@ -11154,24 +11156,45 @@ var LeaferUI = function(exports) {
|
|
|
11154
11156
|
}
|
|
11155
11157
|
}
|
|
11156
11158
|
}
|
|
11157
|
-
function fillPathOrText(ui, canvas, renderOptions) {
|
|
11158
|
-
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11159
|
+
function fillPathOrText(ui, canvas, renderOptions, complexPaint) {
|
|
11160
|
+
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions, complexPaint) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11159
11161
|
}
|
|
11160
|
-
function fillText(ui, canvas, renderOptions) {
|
|
11161
|
-
|
|
11162
|
-
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11162
|
+
function fillText(ui, canvas, renderOptions, complexPaint) {
|
|
11163
|
+
const data = ui.__;
|
|
11163
11164
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11164
|
-
let
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11165
|
+
let originCanvas;
|
|
11166
|
+
if (complexPaint) {
|
|
11167
|
+
originCanvas = canvas;
|
|
11168
|
+
canvas = canvas.getSameCanvas(true, true);
|
|
11169
|
+
canvas.font = ui.__.__font;
|
|
11170
|
+
canvas.fillStyle = "#000";
|
|
11171
|
+
}
|
|
11172
|
+
if (ui.motionText) {
|
|
11173
|
+
Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11174
|
+
} else {
|
|
11175
|
+
let row;
|
|
11176
|
+
const {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11177
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
11178
|
+
row = rows[i];
|
|
11179
|
+
if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
|
|
11180
|
+
canvas.fillText(charData.char, charData.x, row.y);
|
|
11181
|
+
});
|
|
11182
|
+
}
|
|
11183
|
+
if (decorationY) {
|
|
11184
|
+
const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
|
|
11185
|
+
if (decorationColor) canvas.fillStyle = decorationColor;
|
|
11186
|
+
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
11187
|
+
}
|
|
11170
11188
|
}
|
|
11171
|
-
if (
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11189
|
+
if (complexPaint) {
|
|
11190
|
+
canvas.beginPath();
|
|
11191
|
+
ui.__drawPathByBox(canvas, "render");
|
|
11192
|
+
canvas.fillStyle = originCanvas.fillStyle;
|
|
11193
|
+
canvas.setTransform(originCanvas.getTransform());
|
|
11194
|
+
canvas.blendMode = "source-in";
|
|
11195
|
+
canvas.fill();
|
|
11196
|
+
originCanvas.copyWorldByReset(canvas, ui.__nowWorld);
|
|
11197
|
+
canvas.recycle(ui.__nowWorld);
|
|
11175
11198
|
}
|
|
11176
11199
|
}
|
|
11177
11200
|
function stroke(stroke, ui, canvas, renderOptions) {
|
|
@@ -12189,8 +12212,8 @@ var LeaferUI = function(exports) {
|
|
|
12189
12212
|
const afterChar = ">)]}%!?,.:;'\"" + langAfter;
|
|
12190
12213
|
const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
|
|
12191
12214
|
const breakChar = "- " + langBreak$1;
|
|
12192
|
-
const cjkRangeList = [ [ 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 ] ];
|
|
12193
|
-
const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
|
|
12215
|
+
const cjkRangeList = [ [ 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 ], [ 4352, 4607 ], [ 12352, 12447 ], [ 12448, 12543 ], [ 12544, 12591 ], [ 12592, 12687 ], [ 12688, 12703 ], [ 12704, 12735 ], [ 12784, 12799 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
|
|
12216
|
+
const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u{${start.toString(16)}}-\\u{${end.toString(16)}}]`).join("|"), "u");
|
|
12194
12217
|
function mapChar(str) {
|
|
12195
12218
|
const map = {};
|
|
12196
12219
|
str.split("").forEach(char => map[char] = true);
|
|
@@ -12269,11 +12292,13 @@ var LeaferUI = function(exports) {
|
|
|
12269
12292
|
rows = drawData.rows;
|
|
12270
12293
|
bounds = drawData.bounds;
|
|
12271
12294
|
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
12272
|
-
const {
|
|
12295
|
+
const {paraIndent: paraIndent, textCase: textCase} = style;
|
|
12273
12296
|
const {canvas: canvas} = Platform, {width: width} = bounds;
|
|
12274
12297
|
if (style.__isCharMode) {
|
|
12275
12298
|
const wrap = style.textWrap !== "none";
|
|
12276
12299
|
const breakAll = style.textWrap === "break";
|
|
12300
|
+
const letterSpacing = style.__letterSpacing;
|
|
12301
|
+
const wordSpacing = style.__wordSpacing;
|
|
12277
12302
|
paraStart = true;
|
|
12278
12303
|
lastCharType = null;
|
|
12279
12304
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
@@ -12294,9 +12319,9 @@ var LeaferUI = function(exports) {
|
|
|
12294
12319
|
charType = getCharType(char);
|
|
12295
12320
|
if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
|
|
12296
12321
|
charWidth = canvas.measureText(char).width;
|
|
12297
|
-
if (
|
|
12298
|
-
if (
|
|
12299
|
-
charWidth +=
|
|
12322
|
+
if (letterSpacing) {
|
|
12323
|
+
if (letterSpacing < 0) charSize = charWidth;
|
|
12324
|
+
charWidth += letterSpacing;
|
|
12300
12325
|
}
|
|
12301
12326
|
langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
|
|
12302
12327
|
afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
|
|
@@ -12317,11 +12342,11 @@ var LeaferUI = function(exports) {
|
|
|
12317
12342
|
}
|
|
12318
12343
|
if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
|
|
12319
12344
|
if (charType === Break) {
|
|
12320
|
-
if (char === " " && wordWidth) addWord();
|
|
12345
|
+
if (char === " " && wordWidth) addWord(wordSpacing);
|
|
12321
12346
|
addChar(char, charWidth);
|
|
12322
12347
|
addWord();
|
|
12323
12348
|
} else if (langBreak || afterBreak) {
|
|
12324
|
-
if (wordWidth) addWord();
|
|
12349
|
+
if (wordWidth) addWord(wordSpacing);
|
|
12325
12350
|
addChar(char, charWidth);
|
|
12326
12351
|
} else {
|
|
12327
12352
|
addChar(char, charWidth);
|
|
@@ -12355,7 +12380,11 @@ var LeaferUI = function(exports) {
|
|
|
12355
12380
|
});
|
|
12356
12381
|
wordWidth += width;
|
|
12357
12382
|
}
|
|
12358
|
-
function addWord() {
|
|
12383
|
+
function addWord(wordSpacing) {
|
|
12384
|
+
if (wordSpacing) {
|
|
12385
|
+
rowWidth += wordSpacing;
|
|
12386
|
+
word.addWidth = wordSpacing;
|
|
12387
|
+
}
|
|
12359
12388
|
rowWidth += wordWidth;
|
|
12360
12389
|
word.width = wordWidth;
|
|
12361
12390
|
row.words.push(word);
|
|
@@ -12393,6 +12422,7 @@ var LeaferUI = function(exports) {
|
|
|
12393
12422
|
const {rows: rows} = drawData;
|
|
12394
12423
|
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
12395
12424
|
const useLetter = style.__letterSpacing || style.motionText;
|
|
12425
|
+
const wordSpacing = style.__wordSpacing;
|
|
12396
12426
|
const justifyLast = width && textAlign.includes("both");
|
|
12397
12427
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
12398
12428
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -12405,7 +12435,7 @@ var LeaferUI = function(exports) {
|
|
|
12405
12435
|
remainingWidth = width - row.width - indentWidth;
|
|
12406
12436
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
12407
12437
|
}
|
|
12408
|
-
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
12438
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth || wordSpacing ? WordMode : TextMode;
|
|
12409
12439
|
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
12410
12440
|
if (mode === TextMode) {
|
|
12411
12441
|
row.x += indentWidth;
|
|
@@ -12425,6 +12455,7 @@ var LeaferUI = function(exports) {
|
|
|
12425
12455
|
} else {
|
|
12426
12456
|
charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
|
|
12427
12457
|
}
|
|
12458
|
+
if (word.addWidth) charX += word.addWidth;
|
|
12428
12459
|
if (canJustify) {
|
|
12429
12460
|
isLastWord = index === wordsLength - 1;
|
|
12430
12461
|
if (addWordWidth) {
|
package/dist/web.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t,e=require("@leafer/core"),i=require("@leafer-ui/core"),n=require("@leafer-ui/draw");function s(t,e,i,n){return new(i||(i=Promise))(function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((n=n.apply(t,e||[])).next())})}exports.PathNodeHandleType=void 0,(t=exports.PathNodeHandleType||(exports.PathNodeHandleType={}))[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror","function"==typeof SuppressedError&&SuppressedError;const o=e.Debug.get("LeaferCanvas");class r extends e.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,i=t.view||t.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none",this.view.classList.add("leafer-canvas-view")}e.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}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 i=e.isString(t)?document.getElementById(t):t;if(i)if(i instanceof HTMLCanvasElement)this.view=i;else{let t=i;if(i===window||i===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else o.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:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.unreal||(this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i))}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;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),o.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),e.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=e.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const i=this.view,{x:n,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:e.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const i={};e.DataHelper.copyAttrs(i,this,e.canvasSizeAttrs),this.resize(t),this.resizeListener&&!e.isUndefined(this.width)&&this.resizeListener(new e.ResizeEvent(t,i))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}}function a(t,i){e.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,i,n)=>{const s=e.FileHelper.mimeType(i),o=t.toDataURL(s,n);return"image/bmp"===s?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,i,n)=>new Promise(s=>t.toBlob(s,e.FileHelper.mimeType(i),n)),canvasSaveAs:(t,i,n)=>{const s=t.toDataURL(e.FileHelper.mimeType(e.FileHelper.fileType(i)),n);return e.Platform.origin.download(s,i)},download(t,e){return s(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,i,n)=>new Promise((n,s)=>{const o=new e.Platform.origin.Image;i&&(o.setAttribute("crossOrigin",i),o.crossOrigin=i),o.onload=()=>{n(o)},o.onerror=t=>{s(t)},o.src=e.Platform.image.getRealURL(t)}),loadContent(t){return s(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},e.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},e.Platform.canvas=e.Creator.canvas(),e.Platform.conicGradientSupport=!!e.Platform.canvas.context.createConicGradient}e.canvasPatch(CanvasRenderingContext2D.prototype),e.canvasPatch(Path2D.prototype),Object.assign(e.Creator,{canvas:(t,e)=>new r(t,e),image:t=>new e.LeaferImage(t)}),e.Platform.name="web",e.Platform.isMobile="ontouchstart"in window,e.Platform.requestRender=function(t){window.requestAnimationFrame(t)},e.defineKey(e.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:h}=navigator;h.indexOf("Firefox")>-1?(e.Platform.intWheelDeltaY=!0,e.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(e.Platform.os="Windows",e.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?e.Platform.os="Mac":h.indexOf("Linux")>-1&&(e.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new e.LeafList;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,i){this.totalTimes=0,this.changed=0,this.config={},this.__updatedList=new e.LeafList,this.target=t,i&&(this.config=e.DataHelper.default(i,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<100&&(this.changed++,this.running&&this.target.emit(e.RenderEvent.REQUEST))}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}addChild(t,i,n){this.config.usePartLayout&&(n===e.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(t)):(this.hasRemove=!0,this.__updatedList.add(i))),this.update()}__onChildEvent(t){this.addChild(t.child,t.parent,t.type)}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new e.WatchEvent(e.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new e.LeafList,this.totalTimes++,this.hasVisible=this.hasRemove=this.hasAdd=!1,this.changed=0}__listenEvents(){this.__eventIds=[this.target.on_([[e.PropertyEvent.CHANGE,this.__onAttrChange,this],[[e.ChildEvent.ADD,e.ChildEvent.REMOVE],this.__onChildEvent,this],[e.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:c,updateBounds:d,updateChange:u}=e.LeafHelper,{pushAllChildBranch:f,pushAllParent:p}=e.BranchHelper,g={updateMatrix(t,e){let i,n,s=0;const{list:o}=t;for(;s<o.length;)i=o[s],n=i.__layout,e.without(i)&&!n.proxyZoom&&(n.matrixChanged?(c(i,!0),i.isBranch&&f(i,e),m(i,e)):n.boundsChanged&&(i.isBranch&&(i.__tempNumber=0),m(i,e))),s++},updateBounds(t){let e,i,n,s,o=0;const{levels:r,levelMap:a}=t;for(t.sort(!0);o<r.length;){e=r[o],i=a[e];for(let t=0,e=i.length;t<e;t++){if(n=i[t],n.isBranch&&n.__tempNumber){s=n.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||d(s[t])}d(n)}o++}},updateChange(t){t.list.forEach(u)},push:m};function m(t,e){e.add(t),p(t,e)}const{worldBounds:v}=e.LeafBoundsHelper;class w{constructor(t){this.updatedBounds=new e.Bounds,this.beforeBounds=new e.Bounds,this.afterBounds=new e.Bounds,e.isArray(t)&&(t=new e.LeafList(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,v)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,v),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:y}=e.LeafHelper,x=e.Debug.get("Layouter");class P{constructor(t,i){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new e.LeafLevelList,this.target=t,i&&(this.config=e.DataHelper.default(i,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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(e.LayoutEvent.START),this.layoutOnce(),t.emitEvent(new e.LayoutEvent(e.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){x.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?x.warn("layouting"):this.times>3?x.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(e.WatchEvent.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const i=e.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=e.LayoutEvent,h=this.getBlocks(s);h.forEach(t=>t.setBefore()),n.emitEvent(new e.LayoutEvent(o,h,this.times)),this.extraBlock=null,s.sort(),g.updateMatrix(s,this.__levelList),g.updateBounds(this.__levelList),g.updateChange(s),this.extraBlock&&h.push(this.extraBlock),h.forEach(t=>t.setAfter()),n.emitEvent(new e.LayoutEvent(r,h,this.times)),n.emitEvent(new e.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,e.Run.end(i)}fullLayout(){const t=e.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=e.LayoutEvent,r=this.getBlocks(new e.LeafList(i));i.emitEvent(new e.LayoutEvent(n,r,this.times)),P.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new e.LayoutEvent(s,r,this.times)),i.emitEvent(new e.LayoutEvent(o,r,this.times)),this.addBlocks(r),e.Run.end(t)}static fullLayout(t){_(t,!0),t.isBranch?e.BranchHelper.updateBounds(t):e.LeafHelper.updateBounds(t),y(t)}addExtra(t,e){if(!this.__updatedList.has(t)){const{updatedList:i,beforeBounds:n}=this.extraBlock||(this.extraBlock=new w([]));if(i.length?n.add(t.__world):n.set(t.__world),i.add(t),e){const e=this.__levelList;g.push(t,e),e.sort(!0)}}}createBlock(t){return new w(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(){this.__eventIds=[this.target.on_([[e.LayoutEvent.REQUEST,this.layout,this],[e.LayoutEvent.AGAIN,this.layoutAgain,this],[e.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const b=e.Debug.get("Renderer");class L{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=i,n&&(this.config=e.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(e.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(e.RenderEvent.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(e.RenderEvent.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(e.RenderEvent.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new e.Bounds,b.log(i.innerName,"---\x3e");try{this.emitRender(e.RenderEvent.START),this.renderOnce(t),this.emitRender(e.RenderEvent.END,this.totalBounds),e.ImageManager.clearRecycled()}catch(t){this.rendering=!1,b.error(t)}b.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return b.warn("rendering");if(this.times>3)return b.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new e.Bounds,this.renderOptions={},t)this.emitRender(e.RenderEvent.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(e.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(e.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(e.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(t){const i=e.Run.start("PartRender"),{canvas:n}=this,s=t.getIntersect(n.bounds),o=new e.Bounds(s);n.save(),s.spread(L.clipSpread).ceil();const{ceilPartPixel:r}=this.config;n.clipWorld(s,r),n.clearWorld(s,r),this.__render(s,o),n.restore(),e.Run.end(i)}fullRender(){const t=e.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),e.Run.end(t)}__render(t,i){const{canvas:n,target:s}=this,o=t.includes(s.__world),r=o?{includes:o}:{bounds:t,includes:o};this.needFill&&n.fillWorld(t,this.config.fill),e.Debug.showRepaint&&e.Debug.drawRepaint(n,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.Platform.render(s,n,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const i=new e.Bounds;i.setList(t),t.length=0,t.push(i)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.Platform.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:i,height:n}=t.old;if(!new e.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new e.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||b.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,i,n){this.target.emitEvent(new e.RenderEvent(t,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[e.RenderEvent.REQUEST,this.update,this],[e.LayoutEvent.END,this.__onLayoutEnd,this],[e.RenderEvent.AGAIN,this.renderAgain,this],[e.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}L.clipSpread=10;const E={},{copyRadiusPoint:B}=e.PointHelper,{hitRadiusPoint:S}=e.BoundsHelper;class T{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:t.x,y:t.y,radiusX:i,radiusY:i},this.findList=new e.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o,!!n.findList),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,i,n,s){const o=this.findList=new e.LeafList;if(t.length){let i;const{x:s,y:r}=this.point,a={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=t.length;s<r;s++)if(i=t[s],(n||e.LeafHelper.worldHittable(i))&&(this.hitChild(i,i.hitThrough?this.point:a,i.mask&&i.parent&&i.parent.__onlyHitMask),o.length)){if(i.isBranchLeaf&&t.some(t=>t!==i&&e.LeafHelper.hasParent(t,i))){o.reset();break}return o.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,void 0,i[t].proxy),o.length)return o.list[0];return s?null:n?t[0]:t.find(t=>e.LeafHelper.worldHittable(t))}getPath(t){const i=new e.LeafList,n=[],{target:s}=this;for(;t&&(t.syncEventer&&n.push(t.syncEventer),i.add(t),(t=t.parent)!==s););return n.length&&n.forEach(t=>{for(;t&&(t.__.hittable&&i.add(t),(t=t.parent)!==s););}),s&&i.add(s),i}getHitablePath(t){const i=this.getPath(t&&t.hittable?t:null);let n,s=new e.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren&&(!n.isLeafer||"draw"!==n.mode));t--);return s}getThroughPath(t){const i=new e.LeafList,n=[];for(let e=t.length-1;e>-1;e--)n.push(this.getPath(t[e]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n,s;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],s=i.__,s.visible&&(!e||s.mask))if(n=S(i.__world,s.hitRadius?B(E,o,s.hitRadius):o),i.isBranch){if(n||i.__ignoreHitWorld){if(i.isBranchLeaf&&s.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o,e)}}else n&&this.hitChild(i,o,e)}hitChild(t,i,n,s){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(i,!(!n||"path"!==t.mask)||void 0)){const{parent:n,mask:o}=t;if(n&&n.__hasMask&&o&&"clipping"!==o&&"clipping-path"!==o&&!n.children.some(t=>!t.mask&&this.isHitLeaf(t,i)))return;const r=s||t,{hitThrough:a}=t,{findList:h}=this;if(a){const i=h.list.findIndex(i=>"parent"===a?e.LeafHelper.hasParent(i.parent,t.parent):i[a]===t[a]);if(i>0)return h.addAt(r,i)}h.add(r)}}isHitLeaf(t,e){if(t.isBranch){const{findList:e}=this,i=e.length;this.eachFind([t],!1);const n=e.length-i;for(let t=0;t<n;t++)e.remove(e.indexAt(e.length-1));return!!n}return t.__hitWorld(e)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class k{constructor(t,i){this.config={},i&&(this.config=e.DataHelper.default(i,this.config)),this.picker=new T(this.target=t,this),this.finder=e.Creator.finder&&e.Creator.finder(t,this.config)}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,i,n,s){return this.finder?this.finder.getBy(t,i,n,s):e.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(e.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new P(t,e),renderer:(t,e,i)=>new L(t,e,i),selector:(t,e)=>new k(t,e)}),e.Platform.layout=P.fullLayout,e.Platform.render=function(t,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new e.LeafList,t.__render(i,n),n.topList.length&&n.topList.forEach(t=>{const{parent:n}=t;n&&n.isBranchLeaf&&"show"!==n.overflow?(i.save(),e.LeafHelper.clip(n,i,s),t.__render(i,s),i.restore()):t.__render(i,s)})};const R={convert(t,e){const n=i.InteractionHelper.getBase(t),{x:s,y:o}=e,r=Object.assign(Object.assign({},n),{x:s,y:o,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===r.pointerType&&(r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist),r},convertMouse(t,e){const n=i.InteractionHelper.getBase(t),{x:s,y:o}=e;return Object.assign(Object.assign({},n),{x:s,y:o,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const n=R.getTouch(t),s=i.InteractionHelper.getBase(t),{x:o,y:r}=e;return Object.assign(Object.assign({},s),{x:o,y:r,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},C={convert(t){const e=i.InteractionHelper.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:M}=i.InteractionHelper;class O extends i.InteractionBase{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),this.windowTarget.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)this.windowTarget.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view&&(!this.config.shadowDOM||!t.composedPath||!t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(C.convert(t))}onKeyUp(t){this.keyUp(C.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(R.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(R.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=R.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(R.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(R.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(R.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(R.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=R.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&M(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(R.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=R.getTouch(t);this.pointerMove(R.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=R.getTouch(t);this.pointerUp(R.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,e);n.length>1&&(this.multiTouch(i.InteractionHelper.getBase(t),n),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})}),n}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},i.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const n=i.InteractionHelper.getBase(t);Object.assign(n,this.getLocal(t));const s=t.scale/this.lastGestureScale,o=(t.rotation-this.lastGestureRotation)/Math.PI*180*(e.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},n),{scale:s*s})),this.rotate(Object.assign(Object.assign({},n),{rotation:o})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const i=[];this.eachCursor(t,i),e.isObject(i[i.length-1])&&i.push("default"),this.canvas.view.style.cursor=i.map(t=>e.isObject(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,n,s=0){if(s++,e.isArray(t))t.forEach(t=>this.eachCursor(t,n,s));else{const o=e.isString(t)&&i.Cursor.get(t);o&&s<2?this.eachCursor(o,n,s):n.push(t)}}destroy(){this.view&&(super.destroy(),this.view=this.touches=null)}}function A(t,e,i){t.__.__font?n.Paint.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function D(t,i,s,o,r){const a=s.__;e.isObject(t)?n.Paint.drawStrokesStyle(t,i,!1,s,o,r):(o.setStroke(t,a.__strokeWidth*i,a),o.stroke()),a.__useArrow&&n.Paint.strokeArrow(t,s,o,r)}function I(t,i,s,o,r){const a=s.__;e.isObject(t)?n.Paint.drawStrokesStyle(t,i,!0,s,o,r):(o.setStroke(t,a.__strokeWidth*i,a),n.Paint.drawTextStroke(s,o,r))}function H(t,i,s,o,r){const a=o.getSameCanvas(!0,!0);a.font=s.__.__font,I(t,2,s,a,r),a.blendMode="outside"===i?"destination-out":"destination-in",n.Paint.fillText(s,a,r),a.blendMode="normal",e.LeafHelper.copyCanvasByWorld(s,o,a),a.recycle(s.__nowWorld)}const{getSpread:W,copyAndSpread:F,toOuterOf:j,getOuterOf:z,getByMove:U,move:G,getIntersectData:Y}=e.BoundsHelper,X={};let N;const{stintSet:V}=e.DataHelper,{hasTransparent:q}=n.ColorConvert;function K(t,i,s){if(!e.isObject(i)||!1===i.visible||0===i.opacity)return;let o;const{boxBounds:r}=s.__layout,{type:a}=i;switch(a){case"image":case"film":case"video":if(!i.url)return;o=n.PaintImage.image(s,t,i,r,!N||!N[i.url]),"image"!==a&&n.PaintImage[a](o);break;case"linear":o=n.PaintGradient.linearGradient(i,r);break;case"radial":o=n.PaintGradient.radialGradient(i,r);break;case"angular":o=n.PaintGradient.conicGradient(i,r);break;case"solid":const{color:h,opacity:l}=i;o={type:a,style:n.ColorConvert.string(h,l)};break;default:e.isUndefined(i.r)||(o={type:"solid",style:n.ColorConvert.string(i)})}if(o&&(o.originPaint=i,e.isString(o.style)&&q(o.style)&&(o.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;o.strokeStyle=i.style}return o}const Q={compute:function(t,i){const s=i.__,o=[];let r,a,h,l=s.__input[t];e.isArray(l)||(l=[l]),N=n.PaintImage.recycleImage(t,s);for(let e,n=0,s=l.length;n<s;n++)(e=K(t,l[n],i))&&(o.push(e),e.strokeStyle&&(h||(h=1),e.strokeStyle.strokeWidth&&(h=Math.max(h,e.strokeStyle.strokeWidth))));o.length?(s["_"+t]=o,o.every(t=>t.isTransparent)&&(o.some(t=>t.image)&&(r=!0),a=!0),"fill"===t?(V(s,"__isAlphaPixelFill",r),V(s,"__isTransparentFill",a)):(V(s,"__isAlphaPixelStroke",r),V(s,"__isTransparentStroke",a),V(s,"__hasMultiStrokeStyle",h))):(s.__removePaint(t,!1),s["_"+t]="")},fill:function(t,e,i,n){i.fillStyle=t,A(e,i,n)},fills:function(t,e,i,s){let o,r,a;for(let h=0,l=t.length;h<l;h++){if(o=t[h],r=o.originPaint,o.image){if(a?a++:a=1,n.PaintImage.checkImage(o,!e.__.__font,e,i,s))continue;if(!o.style){1===a&&o.image.isPlacehold&&e.drawImagePlaceholder(o,i,s);continue}}if(i.fillStyle=o.style,o.transform||r.scaleFixed){if(i.save(),o.transform&&i.transform(o.transform),r.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0,r.scaleFixed,!1);1!==t&&i.scale(t,n)}r.blendMode&&(i.blendMode=r.blendMode),A(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),A(e,i,s),i.restoreBlendMode()):A(e,i,s)}},fillPathOrText:A,fillText:function(t,e,i){if(t.motionText)return n.Paint.fillMotionText(t,e,i);const s=t.__,{rows:o,decorationY:r}=s.__textDrawData;let a;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=o.length;t<i;t++)a=o[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(r){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),o.forEach(t=>r.forEach(n=>e.fillRect(t.x,t.y+n,t.width,i)))}},stroke:function(t,i,s,o){const r=i.__;if(r.__strokeWidth)if(r.__font)n.Paint.strokeText(t,i,s,o);else if(r.__pathForStroke)n.Paint.fillStroke(t,i,s,o);else switch(r.strokeAlign){case"center":D(t,1,i,s,o);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),D(t,2,e,i,n),i.restore()}(t,i,s,o);break;case"outside":!function(t,i,n,s){const o=i.__;if(o.__fillAfterStroke)D(t,2,i,n,s);else{const{renderBounds:r}=i.__layout,a=n.getSameCanvas(!0,!0);i.__drawRenderPath(a),D(t,2,i,a,s),a.clipUI(o),a.clearWorld(r),e.LeafHelper.copyCanvasByWorld(i,n,a),a.recycle(i.__nowWorld)}}(t,i,s,o)}},strokes:function(t,e,i,s){n.Paint.stroke(t,e,i,s)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":I(t,1,e,i,n);break;case"inside":H(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?I(t,2,e,i,n):H(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,s=t.__.__textDrawData;const{rows:o,decorationY:r}=s;for(let t=0,i=o.length;t<i;t++)n=o[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(r){const{decorationHeight:t}=s;o.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,o,r){let a;const h=s.__,{__hasMultiStrokeStyle:l}=h;l||o.setStroke(void 0,h.__strokeWidth*e,h);for(let c=0,d=t.length;c<d;c++)if(a=t[c],(!a.image||!n.PaintImage.checkImage(a,!1,s,o,r))&&a.style){if(l){const{strokeStyle:t}=a;t?o.setStroke(a.style,h.__getRealStrokeWidth(t)*e,h,t):o.setStroke(a.style,h.__strokeWidth*e,h)}else o.strokeStyle=a.style;a.originPaint.blendMode?(o.saveBlendMode(a.originPaint.blendMode),i?n.Paint.drawTextStroke(s,o,r):o.stroke(),o.restoreBlendMode()):i?n.Paint.drawTextStroke(s,o,r):o.stroke()}},shape:function(t,i,n){const s=i.getSameCanvas(),o=i.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;j(a.strokeSpread?(F(X,a.boxBounds,a.strokeSpread),X):a.boxBounds,r,h);let{scaleX:g,scaleY:m}=t.getRenderScaleData(!0);if(o.includes(h))p=s,l=f=h,c=r;else{let s;if(e.Platform.fullImageShadow)s=h;else{const t=a.renderShapeSpread?W(o,e.FourNumberHelper.swapAndScale(a.renderShapeSpread,g,m)):o;s=Y(t,h)}u=o.getFitMatrix(s);let{a:v,d:w}=u;u.a<1&&(p=i.getSameCanvas(),t.__renderShape(p,n),g*=v,m*=w),f=z(h,u),l=U(f,-u.e,-u.f),c=z(r,u),G(c,-u.e,-u.f);const _=n.matrix;_?(d=new e.Matrix(u),d.multiply(_),v*=_.scaleX,w*=_.scaleY):d=u,d.withScale(v,w),n=Object.assign(Object.assign({},n),{matrix:d})}return t.__renderShape(s,n),{canvas:s,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:m}}};let $,Z=new e.Bounds;const{isSame:J}=e.BoundsHelper;function tt(t,i,s,o,r,a){let h=!0;const l=t.__;if("fill"!==i||l.__naturalWidth||(l.__naturalWidth=o.width/l.pixelRatio,l.__naturalHeight=o.height/l.pixelRatio,l.__autoSide&&(t.forceUpdate(),e.LeafHelper.updateBounds(t,!0),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",l.width),t.setProxyAttr("height",l.height)),h=!1)),"brush"===s.mode&&n.PaintImage.brush(t,i,r),!r.data){n.PaintImage.createData(r,o,s,a);const{transform:t}=r.data,{opacity:e}=s,i=(t&&!t.onlyScale||l.path||l.cornerRadius)&&!r.brush;(i||e&&e<1||s.blendMode)&&(r.complex=!i||2)}return s.filter&&n.PaintImage.applyFilter(r,o,s.filter,t),h}function et(t,i){st(t,e.ImageEvent.LOAD,i)}function it(t,i){st(t,e.ImageEvent.LOADED,i)}function nt(t,i,n){i.error=n,t.forceUpdate("surface"),st(t,e.ImageEvent.ERROR,i)}function st(t,i,n){t.hasEvent(i)&&t.emitEvent(new e.ImageEvent(i,n))}function ot(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:rt,translate:at}=e.MatrixHelper,ht=new e.Bounds,lt={},ct={};function dt(t,i,n,s){const o=e.isString(t)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):t;return"auto"===t&&o<0?0:o}let ut={},ft=e.getMatrixData();const{get:pt,set:gt,rotateOfOuter:mt,translate:vt,scaleOfOuter:wt,multiplyParent:_t,scale:yt,rotate:xt,skew:Pt}=e.MatrixHelper;function bt(t,e,i,n,s,o,r,a){r&&xt(t,r),a&&Pt(t,a.x,a.y),s&&yt(t,s,o),vt(t,e.x+i,e.y+n)}const{get:Lt,scale:Et,copy:Bt}=e.MatrixHelper,{getFloorScale:St}=e.MathHelper,{abs:Tt}=Math;const kt={image:function(t,i,n,s,o){let r,a;const h=e.ImageManager.get(n,n.type);return $&&n===$.paint&&J(s,$.boxBounds)?r=$.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),$=h.use>1?{leafPaint:r,paint:n,boxBounds:Z.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(tt(t,i,n,h,r,s),o&&(et(t,a),it(t,a))):h.error?o&&nt(t,a,h.error):(o&&(ot(t,!0),et(t,a)),r.loadId=h.load(()=>{ot(t,!1),t.destroyed||(tt(t,i,n,h,r,s)&&(h.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),it(t,a)),r.loadId=void 0},e=>{ot(t,!1),nt(t,a,e),r.loadId=void 0},n.lod&&h.getThumbSize(n.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{h.ready||(h.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):h.isPlacehold=!0)),r},checkImage:function(t,i,s,o,r){const{scaleX:a,scaleY:h}=n.PaintImage.getImageRenderScaleData(t,s,o,r),l=t.film?t.nowIndex:a+"-"+h,{image:c,brush:d,data:u,originPaint:f}=t,{exporting:p,snapshot:g}=r;if(!u||t.patternId===l&&!p||g){if(!d||!t.style)return!1}else if(i&&(u.repeat?i=!1:f.changeful||t.film||"miniapp"===e.Platform.name||p||(i=e.Platform.image.isLarge(c,a,h)||c.width*a>8096||c.height*h>8096)),i)s.__.__isFastShadow&&(o.fillStyle=t.style||"#000",o.fill());else if(!t.style||f.sync||p?n.PaintImage.createPattern(t,s,o,r):n.PaintImage.createPatternTask(t,s,o,r),!d||!t.style)return!1;return n.PaintImage.drawImage(t,a,h,s,o,r),!0},drawImage:function(t,e,i,n,s,o){const{data:r,image:a,brush:h,complex:l}=t;let{width:c,height:d}=a,u=h||a;if(l){const{blendMode:o,opacity:a}=t.originPaint,{transform:h}=r;s.save(),2===l&&s.clipUI(n),o&&(s.blendMode=o),a&&(s.opacity*=a),h&&s.transform(h),u.render(s,0,0,c,d,n,t,e,i),s.restore()}else r.scaleX&&(c*=r.scaleX,d*=r.scaleY),u.render(s,0,0,c,d,n,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const o=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:r}=t;if(t.brush&&n.PaintImage.addBrushScale(o,t,e),i){const{pixelRatio:t}=i;o.scaleX*=t,o.scaleY*=t}return r&&r.scaleX&&(o.scaleX*=Math.abs(r.scaleX),o.scaleY*=Math.abs(r.scaleY)),o},recycleImage:function(t,i){const s=i["_"+t];if(e.isArray(s)){let o,r,a,h,l;const c=i.__leaf;for(let d=0,u=s.length;d<u;d++)o=s[d],r=o.image,l=r&&r.url,l&&(a||(a={}),a[l]=!0,e.ImageManager.recyclePaint(o),o.brush&&n.PaintImage.recycleBrush(o,c),i.__willDestroy&&r.parent&&n.PaintImage.recycleFilter(r,c),r.loading&&(h||(h=i.__input&&i.__input[t]||[],e.isArray(h)||(h=[h])),r.unload(s[d].loadId,!h.some(t=>t.url===l))));return a}return null},createPatternTask:function(t,i,o,r){t.patternTask||(t.patternTask=e.ImageManager.patternTasker.add(()=>s(this,void 0,void 0,function*(){n.PaintImage.createPattern(t,i,o,r),i.forceUpdate("surface")}),0,()=>(t.patternTask=null,o.bounds.hit(i.__nowWorld))))},createPattern:function(t,i,s,o){let{scaleX:r,scaleY:a}=n.PaintImage.getImageRenderScaleData(t,i,s,o),h=t.film?t.nowIndex:r+"-"+a;if(t.patternId!==h&&!i.destroyed&&(!e.Platform.image.isLarge(t.image,r,a)||t.data.repeat)){const{image:l,brush:c,data:d}=t,{transform:u,gap:f}=d,p=n.PaintImage.getPatternFixScale(t,r,a);let g,m,v,{width:w,height:_}=l,{opacity:y}=t.originPaint;(c||1===y)&&(y=void 0),p&&(r*=p,a*=p),w*=r,_*=a,f&&!c&&(m=f.x*r/Tt(d.scaleX||1),v=f.y*a/Tt(d.scaleY||1)),(u||1!==r||1!==a)&&(r*=St(w+(m||0)),a*=St(_+(v||0)),g=Lt(),u&&Bt(g,u),Et(g,1/r,1/a));const x=l.getCanvas(w,_,y,void 0,m,v,i.leafer&&i.leafer.config.smooth,d.interlace);c?(t.style=x,n.PaintImage.cacheBrush(t,i,s,o)):t.style=l.getPattern(x,d.repeat||e.Platform.origin.noRepeat||"no-repeat",g,t),t.patternId=h}},getPatternFixScale:function(t,i,n){const{image:s}=t;let o,r=e.Platform.image.maxPatternSize,a=s.width*s.height;return s.isSVG?i>1&&(o=Math.ceil(i)/i):r>a&&(r=a),(a*=i*n)>r&&(o=Math.sqrt(r/a)),o},createData:function(t,e,i,s){t.data=n.PaintImage.getPatternData(i,s,e)},getPatternData:function(t,i,s){t.padding&&(i=ht.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:o,height:r}=s,{mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:m,interlace:v}=t,w=i.width===o&&i.height===r,_={mode:a},y="center"!==h&&(u||0)%180==90;let x,P;switch(e.BoundsHelper.set(ct,0,0,y?r:o,y?o:r),a&&"cover"!==a&&"fit"!==a?((c||d)&&(e.MathHelper.getScaleData(c,d,s,lt),x=lt.scaleX,P=lt.scaleY),(h||m||g)&&(x&&e.BoundsHelper.scale(ct,x,P,!0),h&&e.AlignHelper.toPoint(h,ct,i,ct,!0,!0))):w&&!u||(x=P=e.BoundsHelper.getFitScale(i,ct,"fit"!==a),e.BoundsHelper.put(i,s,h,x,!1,ct),e.BoundsHelper.scale(ct,x,P,!0)),l&&e.PointHelper.move(ct,l),a){case"stretch":w?x&&(x=P=void 0):(x=i.width/o,P=i.height/r,n.PaintImage.stretchMode(_,i,x,P));break;case"normal":case"clip":if(ct.x||ct.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),n.PaintImage.clipMode(_,i,ct.x,ct.y,x,P,u,f,t,e),t&&(x=x?x*t:t,P=P?P*e:e)}break;case"repeat":(!w||x||u||f)&&n.PaintImage.repeatMode(_,i,o,r,ct.x,ct.y,x,P,u,f,h,t.freeTransform);case"brush":g||(_.repeat="repeat");const s=e.isObject(g);(m||s)&&(_.gap=function(t,i,n,s,o){let r,a;e.isObject(t)?(r=t.x,a=t.y):r=a=t;return{x:dt(r,n,o.width,i&&i.x),y:dt(a,s,o.height,i&&i.y)}}(m,s&&g,ct.width,ct.height,i));break;default:x&&n.PaintImage.fillOrFitMode(_,i,ct.x,ct.y,x,P,u)}return _.transform||"brush"===a||(i.x||i.y)&&at(_.transform=rt(),i.x,i.y),x&&(_.scaleX=x,_.scaleY=P),g&&(_.repeat=e.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),v&&(_.interlace=e.isNumber(v)||"percent"===v.type?{type:"x",offset:v}:v),_},stretchMode:function(t,e,i,n){const s=pt(),{x:o,y:r}=e;o||r?vt(s,o,r):i>0&&n>0&&(s.onlyScale=!0),yt(s,i,n),t.transform=s},fillOrFitMode:function(t,e,i,n,s,o,r){const a=pt();vt(a,e.x+i,e.y+n),yt(a,s,o),r&&mt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,n,s,o,r,a,h,l){const c=pt();bt(c,e,i,n,s,o,r,a),h&&(r||a?(gt(ft),wt(ft,e,h,l),_t(c,ft)):wt(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,n,s,o,r,a,h,l,c,d){const u=pt();if(d)bt(u,e,s,o,r,a,h,l);else{if(h)if("center"===c)mt(u,{x:i/2,y:n/2},h);else switch(xt(u,h),h){case 90:vt(u,n,0);break;case 180:vt(u,i,n);break;case 270:vt(u,0,i)}ut.x=e.x+s,ut.y=e.y+o,vt(u,ut.x,ut.y),r&&wt(u,ut,r,a)}t.transform=u}},{toPoint:Rt}=e.AroundHelper,{hasTransparent:Ct}=n.ColorConvert,Mt={},Ot={};function At(t,i,s,o){if(s){let r,a,h,l;for(let t=0,c=s.length;t<c;t++)r=s[t],e.isString(r)?(h=t/(c-1),a=n.ColorConvert.string(r,o)):(h=r.offset,a=n.ColorConvert.string(r.color,o)),i.addColorStop(h,a),!l&&Ct(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Dt,getDistance:It}=e.PointHelper,{get:Ht,rotateOfOuter:Wt,scaleOfOuter:Ft}=e.MatrixHelper,{toPoint:jt}=e.AroundHelper,zt={},Ut={};function Gt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Dt(e,i);o=Ht(),s?(Ft(o,e,r/a*(n||1),1),Wt(o,e,t+90)):(Ft(o,e,1,r/a*(n||1)),Wt(o,e,t))}return o}const{getDistance:Yt}=e.PointHelper,{toPoint:Xt}=e.AroundHelper,Nt={},Vt={};const qt={linearGradient:function(t,i){let{from:n,to:s,type:o,opacity:r}=t;Rt(n||"top",i,Mt),Rt(s||"bottom",i,Ot);const a=e.Platform.canvas.createLinearGradient(Mt.x,Mt.y,Ot.x,Ot.y),h={type:o,style:a};return At(h,a,t.stops,r),h},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=t;jt(n||"center",i,zt),jt(s||"bottom",i,Ut);const h=e.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,It(zt,Ut)),l={type:o,style:h};At(l,h,t.stops,r);const c=Gt(i,zt,Ut,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,rotation:a,stretch:h}=t;Xt(n||"center",i,Nt),Xt(s||"bottom",i,Vt);const l=e.Platform.conicGradientSupport?e.Platform.canvas.createConicGradient(a?a*e.OneRadian:0,Nt.x,Nt.y):e.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Yt(Nt,Vt)),c={type:o,style:l};At(c,l,t.stops,r);const d=Gt(i,Nt,Vt,h||1,e.Platform.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Gt},{copy:Kt,move:Qt,toOffsetOutBounds:$t}=e.BoundsHelper,{max:Zt,abs:Jt}=Math,te={},ee=new e.Matrix,ie={};function ne(t,e){let i,n,s,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,o=1.5*(t.blur||0),s=Jt(t.spread||0),r=Zt(r,s+o-n),a=Zt(a,s+o+i),h=Zt(h,s+o+n),l=Zt(l,s+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function se(t,i,n){const{shapeBounds:s}=n;let o,r;e.Platform.fullImageShadow?(Kt(te,t.bounds),Qt(te,i.x-s.x,i.y-s.y),o=t.bounds,r=te):(o=s,r=i),t.copyWorld(n.canvas,o,r)}const{toOffsetOutBounds:oe}=e.BoundsHelper,re={};const ae=ne;const he={shadow:function(t,i,s){let o,r;const{__nowWorld:a}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=i.getSameCanvas(),m=h.length-1;$t(c,ie,d),h.forEach((h,v)=>{let w=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ie.offsetX+(h.x||0)*f*w,ie.offsetY+(h.y||0)*p*w,(h.blur||0)*f*w,n.ColorConvert.string(h.color)),r=n.Effect.getShadowTransform(t,g,s,h,ie,w),r&&g.setTransform(r),se(g,ie,s),r&&g.resetTransform(),o=d,h.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),o=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),e.LeafHelper.copyCanvasByWorld(t,i,g,o,h.blendMode),m&&v<m&&g.clearWorld(o)}),g.recycle(o)},innerShadow:function(t,i,s){let o,r;const{__nowWorld:a}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=i.getSameCanvas(),m=h.length-1;oe(c,re,d),h.forEach((h,v)=>{let w=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(re.offsetX+(h.x||0)*f*w,re.offsetY+(h.y||0)*p*w,(h.blur||0)*f*w),r=n.Effect.getShadowTransform(t,g,s,h,re,w,!0),r&&g.setTransform(r),se(g,re,s),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),o=a):(g.copyWorld(s.canvas,u,c,"source-out"),o=d),g.fillWorld(o,n.ColorConvert.string(h.color),"source-in"),e.LeafHelper.copyCanvasByWorld(t,i,g,o,h.blendMode),m&&v<m&&g.clearWorld(o)}),g.recycle(o)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ne,getShadowTransform:function(t,e,i,n,s,o,r){if(n.spread){const i=2*n.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return ee.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/a,1+i/h),ee}},isTransformShadow(t){},getInnerShadowSpread:ae},{excludeRenderBounds:le}=e.LeafBoundsHelper;let ce;function de(t,e,i,n,s,o,r,a){switch(e){case"grayscale":ce||(ce=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),o&&n.recycle(r);fe(t,e,i,1,s,o)}(t,i,n,s,r,a);break;case"opacity-path":fe(t,i,n,o,r,a);break;case"path":a&&i.restore()}}function ue(t){return t.getSameCanvas(!1,!0)}function fe(t,e,i,n,s,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),o?i.recycle(r):i.clearWorld(r)}n.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(de(this,r,t,s,n,o,void 0,!0),n=s=null),"clipping"!==a&&"clipping-path"!==a||le(i,e)||i.__render(t,e),o=i.__.opacity,ce=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",s||(s=ue(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=ue(t)),s||(s=ue(t)),i.__render(n,e));continue}const c=1===o&&i.__.__blendMode;c&&de(this,r,t,s,n,o,void 0,!1),le(i,e)||i.__render(s||t,e),c&&de(this,r,t,s,n,o,c,!1)}de(this,r,t,s,n,o,void 0,!0)};const pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ge=pe+"_#~&*+\\=|≮≯≈≠=…",me=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 ve(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const we=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),_e=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ye=ve(pe),xe=ve(ge),Pe=ve("- —/~|┆·");var be;!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"}(be||(be={}));const{Letter:Le,Single:Ee,Before:Be,After:Se,Symbol:Te,Break:ke}=be;function Re(t){return we[t]?Le:Pe[t]?ke:_e[t]?Be:ye[t]?Se:xe[t]?Te:me.test(t)?Ee:Le}const Ce={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Me(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Oe}=Ce,{Letter:Ae,Single:De,Before:Ie,After:He,Symbol:We,Break:Fe}=be;let je,ze,Ue,Ge,Ye,Xe,Ne,Ve,qe,Ke,Qe,$e,Ze,Je,ti,ei,ii,ni=[];function si(t,e){qe&&!Ve&&(Ve=qe),je.data.push({char:t,width:e}),Ue+=e}function oi(){Ge+=Ue,je.width=Ue,ze.words.push(je),je={data:[]},Ue=0}function ri(){Je&&(ti.paraNumber++,ze.paraStart=!0,Je=!1),qe&&(ze.startCharSize=Ve,ze.endCharSize=qe,Ve=0),ze.width=Ge,ei.width?Oe(ze):ii&&ai(),ni.push(ze),ze={words:[]},Ge=0}function ai(){Ge>(ti.maxWidth||0)&&(ti.maxWidth=Ge)}const{top:hi,right:li,bottom:ci,left:di}=e.Direction4;function ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const fi={getDrawData:function(t,i){e.isString(t)||(t=String(t));let s=0,o=0,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{__padding:h}=i;i.motionText&&(r=a=0),h&&(r?(s=h[di],r-=h[li]+h[di],!r&&(r=.01)):i.autoSizeAlign||(s=h[di]),a?(o=h[hi],a-=h[hi]+h[ci],!a&&(a=.01)):i.autoSizeAlign||(o=h[hi]));const l={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:e.Platform.canvas.font=i.__font};return function(t,i,n){ti=t,ni=t.rows,ei=t.bounds,ii=!ei.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=e.Platform,{width:h}=ei;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;Je=!0,Qe=null,Ve=Ne=qe=Ue=Ge=0,je={data:[]},ze={words:[]};for(let n=0,l=(i=[...i]).length;n<l;n++)Xe=i[n],"\n"===Xe?(Ue&&oi(),ze.paraEnd=!0,ri(),Je=!0):(Ke=Re(Xe),Ke===Ae&&"none"!==r&&(Xe=Me(Xe,r,!Ue)),Ne=a.measureText(Xe).width,s&&(s<0&&(qe=Ne),Ne+=s),$e=Ke===De&&(Qe===De||Qe===Ae)||Qe===De&&Ke!==He,Ze=!(Ke!==Ie&&Ke!==De||Qe!==We&&Qe!==He),Ye=Je&&o?h-o:h,t&&h&&Ge+Ue+Ne>Ye&&(e?(Ue&&oi(),Ge&&ri()):(Ze||(Ze=Ke===Ae&&Qe==He),$e||Ze||Ke===Fe||Ke===Ie||Ke===De||Ue+Ne>Ye?(Ue&&oi(),Ge&&ri()):Ge&&ri()))," "===Xe&&!0!==Je&&Ge+Ue===0||(Ke===Fe?(" "===Xe&&Ue&&oi(),si(Xe,Ne),oi()):$e||Ze?(Ue&&oi(),si(Xe,Ne)):si(Xe,Ne)),Qe=Ke);Ue&&oi(),Ge&&ri(),ni.length>0&&(ni[ni.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ti.paraNumber++,Ge=a.measureText(t).width,ni.push({x:o||0,text:t,width:Ge,paraStart:!0}),ii&&ai()})}(l,t,i),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ui(e,"x",t[di]);break;case"right":ui(e,"x",-t[li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ui(e,"y",t[hi]);break;case"bottom":ui(e,"y",-t[ci])}}(h,l,i,r,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:m}=n,v=o*s+(d?d*(t.paraNumber-1):0),w=r;if(h&&v>m)v=Math.max(e.__autoHeight?v:m,o),s>1&&(t.overflow=s);else if(m||u)switch(c){case"middle":p+=(m-v)/2;break;case"bottom":p+=m-v}w+=p;let _,y,x,P=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(_=i[r],_.x=f,_.width<g||_.width>g&&!h)switch(l){case"center":_.x+=(P-_.width)/2;break;case"right":_.x+=P-_.width}_.paraStart&&d&&r>0&&(w+=d),_.y=w,w+=o,t.overflow>r&&w>v&&(_.isOverflow=!0,t.overflow=r+1),y=_.x,x=_.width,a<0&&(_.width<0?(x=-_.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<n.x&&(n.x=y),x>n.width&&(n.width=x),h&&g&&g<x&&(_.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=v}(l,i),i.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o}=e,r=e.__letterSpacing||e.motionText,a=i&&s.includes("both"),h=a||i&&s.includes("justify"),l=h&&s.includes("letter");let c,d,u,f,p,g,m,v,w,_;n.forEach(t=>{t.words&&(p=o&&t.paraStart?o:0,v=t.words.length,h&&(_=!t.paraEnd||a,d=i-t.width-p,l?f=d/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=v>1?d/(v-1):0),g=r||t.isOverflow||l?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(m={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,m),(t.isOverflow||" "!==m.char)&&t.data.push(m)):c=function(t,e,i,n,s){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,_&&f),_&&(w=i===v-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,r),l.overflow&&function(t,i,n,s){const{rows:o,overflow:r}=t;let{textOverflow:a}=i;if(r&&o.splice(r),s&&a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?e.Platform.canvas.measureText(a).width:0,c=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],h=t.x+t.width,!(n===i&&h<c));n--){if(h<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,r),"none"!==i.textDecoration&&function(t,i){let s,o=0;const{fontSize:r,textDecoration:a}=i;switch(t.decorationHeight=r/11,e.isObject(a)?(s=a.type,a.color&&(t.decorationColor=n.ColorConvert.string(a.color)),a.offset&&(o=Math.min(.3*r,Math.max(a.offset,.15*-r)))):s=a,s){case"under":t.decorationY=[.15*r+o];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r+o,.35*-r]}}(l,i),l}};const pi={string:function(t,i){if(!t)return"#000";const s=e.isNumber(i)&&i<1;if(e.isString(t)){if(!s||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let o=e.isUndefined(t.a)?1:t.a;s&&(o*=i);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(n.TextConvert,fi),Object.assign(n.ColorConvert,pi),Object.assign(n.Paint,Q),Object.assign(n.PaintImage,kt),Object.assign(n.PaintGradient,qt),Object.assign(n.Effect,he),Object.assign(e.Creator,{interaction:(t,e,i,n)=>new O(t,e,i,n),hitCanvas:(t,e)=>new r(t,e),hitCanvasManager:()=>new i.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferFilm",{enumerable:!0,get:function(){return e.LeaferFilm}}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return e.LeaferImage}}),Object.defineProperty(exports,"LeaferVideo",{enumerable:!0,get:function(){return e.LeaferVideo}}),exports.Interaction=O,exports.Layouter=P,exports.LayouterHelper=g,exports.LeaferCanvas=r,exports.Picker=T,exports.Renderer=L,exports.Selector=k,exports.Watcher=l,exports.useCanvas=a,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]}})}),Object.keys(i).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})});
|
|
1
|
+
"use strict";var t,e=require("@leafer/core"),i=require("@leafer-ui/core"),n=require("@leafer-ui/draw");function s(t,e,i,n){return new(i||(i=Promise))(function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((n=n.apply(t,e||[])).next())})}exports.PathNodeHandleType=void 0,(t=exports.PathNodeHandleType||(exports.PathNodeHandleType={}))[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror","function"==typeof SuppressedError&&SuppressedError;const o=e.Debug.get("LeaferCanvas");class r extends e.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,i=t.view||t.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none",this.view.classList.add("leafer-canvas-view")}e.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}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 i=e.isString(t)?document.getElementById(t):t;if(i)if(i instanceof HTMLCanvasElement)this.view=i;else{let t=i;if(i===window||i===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else o.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:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.unreal||(this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i))}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;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),o.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),e.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=e.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const i=this.view,{x:n,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:e.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const i={};e.DataHelper.copyAttrs(i,this,e.canvasSizeAttrs),this.resize(t),this.resizeListener&&!e.isUndefined(this.width)&&this.resizeListener(new e.ResizeEvent(t,i))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}}function a(t,i){e.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,i,n)=>{const s=e.FileHelper.mimeType(i),o=t.toDataURL(s,n);return"image/bmp"===s?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,i,n)=>new Promise(s=>t.toBlob(s,e.FileHelper.mimeType(i),n)),canvasSaveAs:(t,i,n)=>{const s=t.toDataURL(e.FileHelper.mimeType(e.FileHelper.fileType(i)),n);return e.Platform.origin.download(s,i)},download(t,e){return s(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,i,n)=>new Promise((n,s)=>{const o=new e.Platform.origin.Image;i&&(o.setAttribute("crossOrigin",i),o.crossOrigin=i),o.onload=()=>{n(o)},o.onerror=t=>{s(t)},o.src=e.Platform.image.getRealURL(t)}),loadContent(t){return s(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},e.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},e.Platform.canvas=e.Creator.canvas(),e.Platform.conicGradientSupport=!!e.Platform.canvas.context.createConicGradient}e.canvasPatch(CanvasRenderingContext2D.prototype),e.canvasPatch(Path2D.prototype),Object.assign(e.Creator,{canvas:(t,e)=>new r(t,e),image:t=>new e.LeaferImage(t)}),e.Platform.name="web",e.Platform.isMobile="ontouchstart"in window,e.Platform.requestRender=function(t){window.requestAnimationFrame(t)},e.defineKey(e.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:h}=navigator;h.indexOf("Firefox")>-1?(e.Platform.intWheelDeltaY=!0,e.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(e.Platform.os="Windows",e.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?e.Platform.os="Mac":h.indexOf("Linux")>-1&&(e.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new e.LeafList;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,i){this.totalTimes=0,this.changed=0,this.config={},this.__updatedList=new e.LeafList,this.target=t,i&&(this.config=e.DataHelper.default(i,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<100&&(this.changed++,this.running&&this.target.emit(e.RenderEvent.REQUEST))}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}addChild(t,i,n){this.config.usePartLayout&&(n===e.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(t)):(this.hasRemove=!0,this.__updatedList.add(i))),this.update()}__onChildEvent(t){this.addChild(t.child,t.parent,t.type)}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new e.WatchEvent(e.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new e.LeafList,this.totalTimes++,this.hasVisible=this.hasRemove=this.hasAdd=!1,this.changed=0}__listenEvents(){this.__eventIds=[this.target.on_([[e.PropertyEvent.CHANGE,this.__onAttrChange,this],[[e.ChildEvent.ADD,e.ChildEvent.REMOVE],this.__onChildEvent,this],[e.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:c,updateBounds:d,updateChange:u}=e.LeafHelper,{pushAllChildBranch:f,pushAllParent:p}=e.BranchHelper,g={updateMatrix(t,e){let i,n,s=0;const{list:o}=t;for(;s<o.length;)i=o[s],n=i.__layout,e.without(i)&&!n.proxyZoom&&(n.matrixChanged?(c(i,!0),i.isBranch&&f(i,e),m(i,e)):n.boundsChanged&&(i.isBranch&&(i.__tempNumber=0),m(i,e))),s++},updateBounds(t){let e,i,n,s,o=0;const{levels:r,levelMap:a}=t;for(t.sort(!0);o<r.length;){e=r[o],i=a[e];for(let t=0,e=i.length;t<e;t++){if(n=i[t],n.isBranch&&n.__tempNumber){s=n.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||d(s[t])}d(n)}o++}},updateChange(t){t.list.forEach(u)},push:m};function m(t,e){e.add(t),p(t,e)}const{worldBounds:_}=e.LeafBoundsHelper;class w{constructor(t){this.updatedBounds=new e.Bounds,this.beforeBounds=new e.Bounds,this.afterBounds=new e.Bounds,e.isArray(t)&&(t=new e.LeafList(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,_)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,_),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:v,updateAllChange:y}=e.LeafHelper,x=e.Debug.get("Layouter");class P{constructor(t,i){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new e.LeafLevelList,this.target=t,i&&(this.config=e.DataHelper.default(i,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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(e.LayoutEvent.START),this.layoutOnce(),t.emitEvent(new e.LayoutEvent(e.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){x.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?x.warn("layouting"):this.times>3?x.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(e.WatchEvent.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const i=e.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=e.LayoutEvent,h=this.getBlocks(s);h.forEach(t=>t.setBefore()),n.emitEvent(new e.LayoutEvent(o,h,this.times)),this.extraBlock=null,s.sort(),g.updateMatrix(s,this.__levelList),g.updateBounds(this.__levelList),g.updateChange(s),this.extraBlock&&h.push(this.extraBlock),h.forEach(t=>t.setAfter()),n.emitEvent(new e.LayoutEvent(r,h,this.times)),n.emitEvent(new e.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,e.Run.end(i)}fullLayout(){const t=e.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=e.LayoutEvent,r=this.getBlocks(new e.LeafList(i));i.emitEvent(new e.LayoutEvent(n,r,this.times)),P.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new e.LayoutEvent(s,r,this.times)),i.emitEvent(new e.LayoutEvent(o,r,this.times)),this.addBlocks(r),e.Run.end(t)}static fullLayout(t){v(t,!0),t.isBranch?e.BranchHelper.updateBounds(t):e.LeafHelper.updateBounds(t),y(t)}addExtra(t,e){if(!this.__updatedList.has(t)){const{updatedList:i,beforeBounds:n}=this.extraBlock||(this.extraBlock=new w([]));if(i.length?n.add(t.__world):n.set(t.__world),i.add(t),e){const e=this.__levelList;g.push(t,e),e.sort(!0)}}}createBlock(t){return new w(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(){this.__eventIds=[this.target.on_([[e.LayoutEvent.REQUEST,this.layout,this],[e.LayoutEvent.AGAIN,this.layoutAgain,this],[e.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const b=e.Debug.get("Renderer");class L{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=i,n&&(this.config=e.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(e.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(e.RenderEvent.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(e.RenderEvent.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(e.RenderEvent.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new e.Bounds,b.log(i.innerName,"---\x3e");try{this.emitRender(e.RenderEvent.START),this.renderOnce(t),this.emitRender(e.RenderEvent.END,this.totalBounds),e.ImageManager.clearRecycled()}catch(t){this.rendering=!1,b.error(t)}b.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return b.warn("rendering");if(this.times>3)return b.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new e.Bounds,this.renderOptions={},t)this.emitRender(e.RenderEvent.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(e.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(e.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(e.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(t){const i=e.Run.start("PartRender"),{canvas:n}=this,s=t.getIntersect(n.bounds),o=new e.Bounds(s);n.save(),s.spread(L.clipSpread).ceil();const{ceilPartPixel:r}=this.config;n.clipWorld(s,r),n.clearWorld(s,r),this.__render(s,o),n.restore(),e.Run.end(i)}fullRender(){const t=e.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),e.Run.end(t)}__render(t,i){const{canvas:n,target:s}=this,o=t.includes(s.__world),r=o?{includes:o}:{bounds:t,includes:o};this.needFill&&n.fillWorld(t,this.config.fill),e.Debug.showRepaint&&e.Debug.drawRepaint(n,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.Platform.render(s,n,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const i=new e.Bounds;i.setList(t),t.length=0,t.push(i)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.Platform.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:i,height:n}=t.old;if(!new e.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new e.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||b.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,i,n){this.target.emitEvent(new e.RenderEvent(t,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[e.RenderEvent.REQUEST,this.update,this],[e.LayoutEvent.END,this.__onLayoutEnd,this],[e.RenderEvent.AGAIN,this.renderAgain,this],[e.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}L.clipSpread=10;const E={},{copyRadiusPoint:B}=e.PointHelper,{hitRadiusPoint:S}=e.BoundsHelper;class T{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:t.x,y:t.y,radiusX:i,radiusY:i},this.findList=new e.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o,!!n.findList),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,i,n,s){const o=this.findList=new e.LeafList;if(t.length){let i;const{x:s,y:r}=this.point,a={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=t.length;s<r;s++)if(i=t[s],(n||e.LeafHelper.worldHittable(i))&&(this.hitChild(i,i.hitThrough?this.point:a,i.mask&&i.parent&&i.parent.__onlyHitMask),o.length)){if(i.isBranchLeaf&&t.some(t=>t!==i&&e.LeafHelper.hasParent(t,i))){o.reset();break}return o.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,void 0,i[t].proxy),o.length)return o.list[0];return s?null:n?t[0]:t.find(t=>e.LeafHelper.worldHittable(t))}getPath(t){const i=new e.LeafList,n=[],{target:s}=this;for(;t&&(t.syncEventer&&n.push(t.syncEventer),i.add(t),(t=t.parent)!==s););return n.length&&n.forEach(t=>{for(;t&&(t.__.hittable&&i.add(t),(t=t.parent)!==s););}),s&&i.add(s),i}getHitablePath(t){const i=this.getPath(t&&t.hittable?t:null);let n,s=new e.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren&&(!n.isLeafer||"draw"!==n.mode));t--);return s}getThroughPath(t){const i=new e.LeafList,n=[];for(let e=t.length-1;e>-1;e--)n.push(this.getPath(t[e]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n,s;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],s=i.__,s.visible&&(!e||s.mask))if(n=S(i.__world,s.hitRadius?B(E,o,s.hitRadius):o),i.isBranch){if(n||i.__ignoreHitWorld){if(i.isBranchLeaf&&s.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o,e)}}else n&&this.hitChild(i,o,e)}hitChild(t,i,n,s){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(i,!(!n||"path"!==t.mask)||void 0)){const{parent:n,mask:o}=t;if(n&&n.__hasMask&&o&&"clipping"!==o&&"clipping-path"!==o&&!n.children.some(t=>!t.mask&&this.isHitLeaf(t,i)))return;const r=s||t,{hitThrough:a}=t,{findList:h}=this;if(a){const i=h.list.findIndex(i=>"parent"===a?e.LeafHelper.hasParent(i.parent,t.parent):i[a]===t[a]);if(i>0)return h.addAt(r,i)}h.add(r)}}isHitLeaf(t,e){if(t.isBranch){const{findList:e}=this,i=e.length;this.eachFind([t],!1);const n=e.length-i;for(let t=0;t<n;t++)e.remove(e.indexAt(e.length-1));return!!n}return t.__hitWorld(e)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class k{constructor(t,i){this.config={},i&&(this.config=e.DataHelper.default(i,this.config)),this.picker=new T(this.target=t,this),this.finder=e.Creator.finder&&e.Creator.finder(t,this.config)}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,i,n,s){return this.finder?this.finder.getBy(t,i,n,s):e.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(e.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new P(t,e),renderer:(t,e,i)=>new L(t,e,i),selector:(t,e)=>new k(t,e)}),e.Platform.layout=P.fullLayout,e.Platform.render=function(t,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new e.LeafList,t.__render(i,n),n.topList.length&&n.topList.forEach(t=>{const{parent:n}=t;n&&n.isBranchLeaf&&"show"!==n.overflow?(i.save(),e.LeafHelper.clip(n,i,s),t.__render(i,s),i.restore()):t.__render(i,s)})};const R={convert(t,e){const n=i.InteractionHelper.getBase(t),{x:s,y:o}=e,r=Object.assign(Object.assign({},n),{x:s,y:o,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===r.pointerType&&(r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist),r},convertMouse(t,e){const n=i.InteractionHelper.getBase(t),{x:s,y:o}=e;return Object.assign(Object.assign({},n),{x:s,y:o,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const n=R.getTouch(t),s=i.InteractionHelper.getBase(t),{x:o,y:r}=e;return Object.assign(Object.assign({},s),{x:o,y:r,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},C={convert(t){const e=i.InteractionHelper.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:M}=i.InteractionHelper;class O extends i.InteractionBase{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),this.windowTarget.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)this.windowTarget.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view&&(!this.config.shadowDOM||!t.composedPath||!t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(C.convert(t))}onKeyUp(t){this.keyUp(C.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(R.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(R.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=R.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(R.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(R.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(R.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(R.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=R.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&M(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(R.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=R.getTouch(t);this.pointerMove(R.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=R.getTouch(t);this.pointerUp(R.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,e);n.length>1&&(this.multiTouch(i.InteractionHelper.getBase(t),n),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})}),n}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},i.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const n=i.InteractionHelper.getBase(t);Object.assign(n,this.getLocal(t));const s=t.scale/this.lastGestureScale,o=(t.rotation-this.lastGestureRotation)/Math.PI*180*(e.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},n),{scale:s*s})),this.rotate(Object.assign(Object.assign({},n),{rotation:o})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const i=[];this.eachCursor(t,i),e.isObject(i[i.length-1])&&i.push("default"),this.canvas.view.style.cursor=i.map(t=>e.isObject(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,n,s=0){if(s++,e.isArray(t))t.forEach(t=>this.eachCursor(t,n,s));else{const o=e.isString(t)&&i.Cursor.get(t);o&&s<2?this.eachCursor(o,n,s):n.push(t)}}destroy(){this.view&&(super.destroy(),this.view=this.touches=null)}}function A(t,e,i,s){t.__.__font?n.Paint.fillText(t,e,i,s):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function D(t,i,s,o,r){const a=s.__;e.isObject(t)?n.Paint.drawStrokesStyle(t,i,!1,s,o,r):(o.setStroke(t,a.__strokeWidth*i,a),o.stroke()),a.__useArrow&&n.Paint.strokeArrow(t,s,o,r)}function I(t,i,s,o,r){const a=s.__;e.isObject(t)?n.Paint.drawStrokesStyle(t,i,!0,s,o,r):(o.setStroke(t,a.__strokeWidth*i,a),n.Paint.drawTextStroke(s,o,r))}function W(t,i,s,o,r){const a=o.getSameCanvas(!0,!0);a.font=s.__.__font,I(t,2,s,a,r),a.blendMode="outside"===i?"destination-out":"destination-in",n.Paint.fillText(s,a,r),a.blendMode="normal",e.LeafHelper.copyCanvasByWorld(s,o,a),a.recycle(s.__nowWorld)}const{getSpread:H,copyAndSpread:F,toOuterOf:j,getOuterOf:z,getByMove:U,move:G,getIntersectData:Y}=e.BoundsHelper,X={};let N;const{stintSet:V}=e.DataHelper,{hasTransparent:q}=n.ColorConvert;function K(t,i,s){if(!e.isObject(i)||!1===i.visible||0===i.opacity)return;let o;const{boxBounds:r}=s.__layout,{type:a}=i;switch(a){case"image":case"film":case"video":if(!i.url)return;o=n.PaintImage.image(s,t,i,r,!N||!N[i.url]),"image"!==a&&n.PaintImage[a](o);break;case"linear":o=n.PaintGradient.linearGradient(i,r);break;case"radial":o=n.PaintGradient.radialGradient(i,r);break;case"angular":o=n.PaintGradient.conicGradient(i,r);break;case"solid":const{color:h,opacity:l}=i;o={type:a,style:n.ColorConvert.string(h,l)};break;default:e.isUndefined(i.r)||(o={type:"solid",style:n.ColorConvert.string(i)})}if(o&&(o.originPaint=i,e.isString(o.style)&&q(o.style)&&(o.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;o.strokeStyle=i.style}return o}const Q={compute:function(t,i){const s=i.__,o=[];let r,a,h,l=s.__input[t];e.isArray(l)||(l=[l]),N=n.PaintImage.recycleImage(t,s);for(let e,n=0,s=l.length;n<s;n++)(e=K(t,l[n],i))&&(o.push(e),e.strokeStyle&&(h||(h=1),e.strokeStyle.strokeWidth&&(h=Math.max(h,e.strokeStyle.strokeWidth))));o.length?(s["_"+t]=o,o.every(t=>t.isTransparent)&&(o.some(t=>t.image)&&(r=!0),a=!0),"fill"===t?(V(s,"__isAlphaPixelFill",r),V(s,"__isTransparentFill",a)):(V(s,"__isAlphaPixelStroke",r),V(s,"__isTransparentStroke",a),V(s,"__hasMultiStrokeStyle",h))):(s.__removePaint(t,!1),s["_"+t]="")},fill:function(t,e,i,n){i.fillStyle=t,A(e,i,n)},fills:function(t,e,i,s){let o,r,a;for(let h=0,l=t.length;h<l;h++){if(o=t[h],r=o.originPaint,o.image){if(a?a++:a=1,n.PaintImage.checkImage(o,!e.__.__font,e,i,s))continue;if(!o.style){1===a&&o.image.isPlacehold&&e.drawImagePlaceholder(o,i,s);continue}}if(i.fillStyle=o.style,o.transform||r.scaleFixed){if(i.save(),o.transform&&i.transform(o.transform),r.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0,r.scaleFixed,!1);1!==t&&i.scale(t,n)}r.blendMode&&(i.blendMode=r.blendMode),A(e,i,s,!0),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),A(e,i,s),i.restoreBlendMode()):A(e,i,s)}},fillPathOrText:A,fillText:function(t,e,i,s){const o=t.__;let r;if(o.__isPlacehold&&o.placeholderColor&&(e.fillStyle=o.placeholderColor),s&&(r=e,(e=e.getSameCanvas(!0,!0)).font=t.__.__font,e.fillStyle="#000"),t.motionText)n.Paint.fillMotionText(t,e,i);else{let t;const{rows:i,decorationY:n}=o.__textDrawData;for(let n=0,s=i.length;n<s;n++)t=i[n],t.text?e.fillText(t.text,t.x,t.y):t.data&&t.data.forEach(i=>{e.fillText(i.char,i.x,t.y)});if(n){const{decorationColor:t,decorationHeight:s}=o.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,s)))}}s&&(e.beginPath(),t.__drawPathByBox(e,"render"),e.fillStyle=r.fillStyle,e.setTransform(r.getTransform()),e.blendMode="source-in",e.fill(),r.copyWorldByReset(e,t.__nowWorld),e.recycle(t.__nowWorld))},stroke:function(t,i,s,o){const r=i.__;if(r.__strokeWidth)if(r.__font)n.Paint.strokeText(t,i,s,o);else if(r.__pathForStroke)n.Paint.fillStroke(t,i,s,o);else switch(r.strokeAlign){case"center":D(t,1,i,s,o);break;case"inside":!function(t,e,i,n){i.save(),i.clipUI(e),D(t,2,e,i,n),i.restore()}(t,i,s,o);break;case"outside":!function(t,i,n,s){const o=i.__;if(o.__fillAfterStroke)D(t,2,i,n,s);else{const{renderBounds:r}=i.__layout,a=n.getSameCanvas(!0,!0);i.__drawRenderPath(a),D(t,2,i,a,s),a.clipUI(o),a.clearWorld(r),e.LeafHelper.copyCanvasByWorld(i,n,a),a.recycle(i.__nowWorld)}}(t,i,s,o)}},strokes:function(t,e,i,s){n.Paint.stroke(t,e,i,s)},strokeText:function(t,e,i,n){switch(e.__.strokeAlign){case"center":I(t,1,e,i,n);break;case"inside":W(t,"inside",e,i,n);break;case"outside":e.__.__fillAfterStroke?I(t,2,e,i,n):W(t,"outside",e,i,n)}},drawTextStroke:function(t,e,i){let n,s=t.__.__textDrawData;const{rows:o,decorationY:r}=s;for(let t=0,i=o.length;t<i;t++)n=o[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(r){const{decorationHeight:t}=s;o.forEach(i=>r.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,o,r){let a;const h=s.__,{__hasMultiStrokeStyle:l}=h;l||o.setStroke(void 0,h.__strokeWidth*e,h);for(let c=0,d=t.length;c<d;c++)if(a=t[c],(!a.image||!n.PaintImage.checkImage(a,!1,s,o,r))&&a.style){if(l){const{strokeStyle:t}=a;t?o.setStroke(a.style,h.__getRealStrokeWidth(t)*e,h,t):o.setStroke(a.style,h.__strokeWidth*e,h)}else o.strokeStyle=a.style;a.originPaint.blendMode?(o.saveBlendMode(a.originPaint.blendMode),i?n.Paint.drawTextStroke(s,o,r):o.stroke(),o.restoreBlendMode()):i?n.Paint.drawTextStroke(s,o,r):o.stroke()}},shape:function(t,i,n){const s=i.getSameCanvas(),o=i.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;j(a.strokeSpread?(F(X,a.boxBounds,a.strokeSpread),X):a.boxBounds,r,h);let{scaleX:g,scaleY:m}=t.getRenderScaleData(!0);if(o.includes(h))p=s,l=f=h,c=r;else{let s;if(e.Platform.fullImageShadow)s=h;else{const t=a.renderShapeSpread?H(o,e.FourNumberHelper.swapAndScale(a.renderShapeSpread,g,m)):o;s=Y(t,h)}u=o.getFitMatrix(s);let{a:_,d:w}=u;u.a<1&&(p=i.getSameCanvas(),t.__renderShape(p,n),g*=_,m*=w),f=z(h,u),l=U(f,-u.e,-u.f),c=z(r,u),G(c,-u.e,-u.f);const v=n.matrix;v?(d=new e.Matrix(u),d.multiply(v),_*=v.scaleX,w*=v.scaleY):d=u,d.withScale(_,w),n=Object.assign(Object.assign({},n),{matrix:d})}return t.__renderShape(s,n),{canvas:s,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:m}}};let $,Z=new e.Bounds;const{isSame:J}=e.BoundsHelper;function tt(t,i,s,o,r,a){let h=!0;const l=t.__;if("fill"!==i||l.__naturalWidth||(l.__naturalWidth=o.width/l.pixelRatio,l.__naturalHeight=o.height/l.pixelRatio,l.__autoSide&&(t.forceUpdate(),e.LeafHelper.updateBounds(t,!0),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",l.width),t.setProxyAttr("height",l.height)),h=!1)),"brush"===s.mode&&n.PaintImage.brush(t,i,r),!r.data){n.PaintImage.createData(r,o,s,a);const{transform:t}=r.data,{opacity:e}=s,i=(t&&!t.onlyScale||l.path||l.cornerRadius)&&!r.brush;(i||e&&e<1||s.blendMode)&&(r.complex=!i||2)}return s.filter&&n.PaintImage.applyFilter(r,o,s.filter,t),h}function et(t,i){st(t,e.ImageEvent.LOAD,i)}function it(t,i){st(t,e.ImageEvent.LOADED,i)}function nt(t,i,n){i.error=n,t.forceUpdate("surface"),st(t,e.ImageEvent.ERROR,i)}function st(t,i,n){t.hasEvent(i)&&t.emitEvent(new e.ImageEvent(i,n))}function ot(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:rt,translate:at}=e.MatrixHelper,ht=new e.Bounds,lt={},ct={};function dt(t,i,n,s){const o=e.isString(t)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):t;return"auto"===t&&o<0?0:o}let ut={},ft=e.getMatrixData();const{get:pt,set:gt,rotateOfOuter:mt,translate:_t,scaleOfOuter:wt,multiplyParent:vt,scale:yt,rotate:xt,skew:Pt}=e.MatrixHelper;function bt(t,e,i,n,s,o,r,a){r&&xt(t,r),a&&Pt(t,a.x,a.y),s&&yt(t,s,o),_t(t,e.x+i,e.y+n)}const{get:Lt,scale:Et,copy:Bt}=e.MatrixHelper,{getFloorScale:St}=e.MathHelper,{abs:Tt}=Math;const kt={image:function(t,i,n,s,o){let r,a;const h=e.ImageManager.get(n,n.type);return $&&n===$.paint&&J(s,$.boxBounds)?r=$.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),$=h.use>1?{leafPaint:r,paint:n,boxBounds:Z.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(tt(t,i,n,h,r,s),o&&(et(t,a),it(t,a))):h.error?o&&nt(t,a,h.error):(o&&(ot(t,!0),et(t,a)),r.loadId=h.load(()=>{ot(t,!1),t.destroyed||(tt(t,i,n,h,r,s)&&(h.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),it(t,a)),r.loadId=void 0},e=>{ot(t,!1),nt(t,a,e),r.loadId=void 0},n.lod&&h.getThumbSize(n.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{h.ready||(h.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):h.isPlacehold=!0)),r},checkImage:function(t,i,s,o,r){const{scaleX:a,scaleY:h}=n.PaintImage.getImageRenderScaleData(t,s,o,r),l=t.film?t.nowIndex:a+"-"+h,{image:c,brush:d,data:u,originPaint:f}=t,{exporting:p,snapshot:g}=r;if(!u||t.patternId===l&&!p||g){if(!d||!t.style)return!1}else if(i&&(u.repeat?i=!1:f.changeful||t.film||"miniapp"===e.Platform.name||p||(i=e.Platform.image.isLarge(c,a,h)||c.width*a>8096||c.height*h>8096)),i)s.__.__isFastShadow&&(o.fillStyle=t.style||"#000",o.fill());else if(!t.style||f.sync||p?n.PaintImage.createPattern(t,s,o,r):n.PaintImage.createPatternTask(t,s,o,r),!d||!t.style)return!1;return n.PaintImage.drawImage(t,a,h,s,o,r),!0},drawImage:function(t,e,i,n,s,o){const{data:r,image:a,brush:h,complex:l}=t;let{width:c,height:d}=a,u=h||a;if(l){const{blendMode:o,opacity:a}=t.originPaint,{transform:h}=r;s.save(),2===l&&s.clipUI(n),o&&(s.blendMode=o),a&&(s.opacity*=a),h&&s.transform(h),u.render(s,0,0,c,d,n,t,e,i),s.restore()}else r.scaleX&&(c*=r.scaleX,d*=r.scaleY),u.render(s,0,0,c,d,n,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const o=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:r}=t;if(t.brush&&n.PaintImage.addBrushScale(o,t,e),i){const{pixelRatio:t}=i;o.scaleX*=t,o.scaleY*=t}return r&&r.scaleX&&(o.scaleX*=Math.abs(r.scaleX),o.scaleY*=Math.abs(r.scaleY)),o},recycleImage:function(t,i){const s=i["_"+t];if(e.isArray(s)){let o,r,a,h,l;const c=i.__leaf;for(let d=0,u=s.length;d<u;d++)o=s[d],r=o.image,l=r&&r.url,l&&(a||(a={}),a[l]=!0,e.ImageManager.recyclePaint(o),o.brush&&n.PaintImage.recycleBrush(o,c),i.__willDestroy&&r.parent&&n.PaintImage.recycleFilter(r,c),r.loading&&(h||(h=i.__input&&i.__input[t]||[],e.isArray(h)||(h=[h])),r.unload(s[d].loadId,!h.some(t=>t.url===l))));return a}return null},createPatternTask:function(t,i,o,r){t.patternTask||(t.patternTask=e.ImageManager.patternTasker.add(()=>s(this,void 0,void 0,function*(){n.PaintImage.createPattern(t,i,o,r),i.forceUpdate("surface")}),0,()=>(t.patternTask=null,o.bounds.hit(i.__nowWorld))))},createPattern:function(t,i,s,o){let{scaleX:r,scaleY:a}=n.PaintImage.getImageRenderScaleData(t,i,s,o),h=t.film?t.nowIndex:r+"-"+a;if(t.patternId!==h&&!i.destroyed&&(!e.Platform.image.isLarge(t.image,r,a)||t.data.repeat)){const{image:l,brush:c,data:d}=t,{transform:u,gap:f}=d,p=n.PaintImage.getPatternFixScale(t,r,a);let g,m,_,{width:w,height:v}=l,{opacity:y}=t.originPaint;(c||1===y)&&(y=void 0),p&&(r*=p,a*=p),w*=r,v*=a,f&&!c&&(m=f.x*r/Tt(d.scaleX||1),_=f.y*a/Tt(d.scaleY||1)),(u||1!==r||1!==a)&&(r*=St(w+(m||0)),a*=St(v+(_||0)),g=Lt(),u&&Bt(g,u),Et(g,1/r,1/a));const x=l.getCanvas(w,v,y,void 0,m,_,i.leafer&&i.leafer.config.smooth,d.interlace);c?(t.style=x,n.PaintImage.cacheBrush(t,i,s,o)):t.style=l.getPattern(x,d.repeat||e.Platform.origin.noRepeat||"no-repeat",g,t),t.patternId=h}},getPatternFixScale:function(t,i,n){const{image:s}=t;let o,r=e.Platform.image.maxPatternSize,a=s.width*s.height;return s.isSVG?i>1&&(o=Math.ceil(i)/i):r>a&&(r=a),(a*=i*n)>r&&(o=Math.sqrt(r/a)),o},createData:function(t,e,i,s){t.data=n.PaintImage.getPatternData(i,s,e)},getPatternData:function(t,i,s){t.padding&&(i=ht.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:o,height:r}=s,{mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:m,interlace:_}=t,w=i.width===o&&i.height===r,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,P;switch(e.BoundsHelper.set(ct,0,0,y?r:o,y?o:r),a&&"cover"!==a&&"fit"!==a?((c||d)&&(e.MathHelper.getScaleData(c,d,s,lt),x=lt.scaleX,P=lt.scaleY),(h||m||g)&&(x&&e.BoundsHelper.scale(ct,x,P,!0),h&&e.AlignHelper.toPoint(h,ct,i,ct,!0,!0))):w&&!u||(x=P=e.BoundsHelper.getFitScale(i,ct,"fit"!==a),e.BoundsHelper.put(i,s,h,x,!1,ct),e.BoundsHelper.scale(ct,x,P,!0)),l&&e.PointHelper.move(ct,l),a){case"stretch":w?x&&(x=P=void 0):(x=i.width/o,P=i.height/r,n.PaintImage.stretchMode(v,i,x,P));break;case"normal":case"clip":if(ct.x||ct.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),n.PaintImage.clipMode(v,i,ct.x,ct.y,x,P,u,f,t,e),t&&(x=x?x*t:t,P=P?P*e:e)}break;case"repeat":(!w||x||u||f)&&n.PaintImage.repeatMode(v,i,o,r,ct.x,ct.y,x,P,u,f,h,t.freeTransform);case"brush":g||(v.repeat="repeat");const s=e.isObject(g);(m||s)&&(v.gap=function(t,i,n,s,o){let r,a;e.isObject(t)?(r=t.x,a=t.y):r=a=t;return{x:dt(r,n,o.width,i&&i.x),y:dt(a,s,o.height,i&&i.y)}}(m,s&&g,ct.width,ct.height,i));break;default:x&&n.PaintImage.fillOrFitMode(v,i,ct.x,ct.y,x,P,u)}return v.transform||"brush"===a||(i.x||i.y)&&at(v.transform=rt(),i.x,i.y),x&&(v.scaleX=x,v.scaleY=P),g&&(v.repeat=e.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),_&&(v.interlace=e.isNumber(_)||"percent"===_.type?{type:"x",offset:_}:_),v},stretchMode:function(t,e,i,n){const s=pt(),{x:o,y:r}=e;o||r?_t(s,o,r):i>0&&n>0&&(s.onlyScale=!0),yt(s,i,n),t.transform=s},fillOrFitMode:function(t,e,i,n,s,o,r){const a=pt();_t(a,e.x+i,e.y+n),yt(a,s,o),r&&mt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,n,s,o,r,a,h,l){const c=pt();bt(c,e,i,n,s,o,r,a),h&&(r||a?(gt(ft),wt(ft,e,h,l),vt(c,ft)):wt(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,n,s,o,r,a,h,l,c,d){const u=pt();if(d)bt(u,e,s,o,r,a,h,l);else{if(h)if("center"===c)mt(u,{x:i/2,y:n/2},h);else switch(xt(u,h),h){case 90:_t(u,n,0);break;case 180:_t(u,i,n);break;case 270:_t(u,0,i)}ut.x=e.x+s,ut.y=e.y+o,_t(u,ut.x,ut.y),r&&wt(u,ut,r,a)}t.transform=u}},{toPoint:Rt}=e.AroundHelper,{hasTransparent:Ct}=n.ColorConvert,Mt={},Ot={};function At(t,i,s,o){if(s){let r,a,h,l;for(let t=0,c=s.length;t<c;t++)r=s[t],e.isString(r)?(h=t/(c-1),a=n.ColorConvert.string(r,o)):(h=r.offset,a=n.ColorConvert.string(r.color,o)),i.addColorStop(h,a),!l&&Ct(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Dt,getDistance:It}=e.PointHelper,{get:Wt,rotateOfOuter:Ht,scaleOfOuter:Ft}=e.MatrixHelper,{toPoint:jt}=e.AroundHelper,zt={},Ut={};function Gt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Dt(e,i);o=Wt(),s?(Ft(o,e,r/a*(n||1),1),Ht(o,e,t+90)):(Ft(o,e,1,r/a*(n||1)),Ht(o,e,t))}return o}const{getDistance:Yt}=e.PointHelper,{toPoint:Xt}=e.AroundHelper,Nt={},Vt={};const qt={linearGradient:function(t,i){let{from:n,to:s,type:o,opacity:r}=t;Rt(n||"top",i,Mt),Rt(s||"bottom",i,Ot);const a=e.Platform.canvas.createLinearGradient(Mt.x,Mt.y,Ot.x,Ot.y),h={type:o,style:a};return At(h,a,t.stops,r),h},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=t;jt(n||"center",i,zt),jt(s||"bottom",i,Ut);const h=e.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,It(zt,Ut)),l={type:o,style:h};At(l,h,t.stops,r);const c=Gt(i,zt,Ut,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,rotation:a,stretch:h}=t;Xt(n||"center",i,Nt),Xt(s||"bottom",i,Vt);const l=e.Platform.conicGradientSupport?e.Platform.canvas.createConicGradient(a?a*e.OneRadian:0,Nt.x,Nt.y):e.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Yt(Nt,Vt)),c={type:o,style:l};At(c,l,t.stops,r);const d=Gt(i,Nt,Vt,h||1,e.Platform.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Gt},{copy:Kt,move:Qt,toOffsetOutBounds:$t}=e.BoundsHelper,{max:Zt,abs:Jt}=Math,te={},ee=new e.Matrix,ie={};function ne(t,e){let i,n,s,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,o=1.5*(t.blur||0),s=Jt(t.spread||0),r=Zt(r,s+o-n),a=Zt(a,s+o+i),h=Zt(h,s+o+n),l=Zt(l,s+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function se(t,i,n){const{shapeBounds:s}=n;let o,r;e.Platform.fullImageShadow?(Kt(te,t.bounds),Qt(te,i.x-s.x,i.y-s.y),o=t.bounds,r=te):(o=s,r=i),t.copyWorld(n.canvas,o,r)}const{toOffsetOutBounds:oe}=e.BoundsHelper,re={};const ae=ne;const he={shadow:function(t,i,s){let o,r;const{__nowWorld:a}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=i.getSameCanvas(),m=h.length-1;$t(c,ie,d),h.forEach((h,_)=>{let w=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ie.offsetX+(h.x||0)*f*w,ie.offsetY+(h.y||0)*p*w,(h.blur||0)*f*w,n.ColorConvert.string(h.color)),r=n.Effect.getShadowTransform(t,g,s,h,ie,w),r&&g.setTransform(r),se(g,ie,s),r&&g.resetTransform(),o=d,h.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),o=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),e.LeafHelper.copyCanvasByWorld(t,i,g,o,h.blendMode),m&&_<m&&g.clearWorld(o)}),g.recycle(o)},innerShadow:function(t,i,s){let o,r;const{__nowWorld:a}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=i.getSameCanvas(),m=h.length-1;oe(c,re,d),h.forEach((h,_)=>{let w=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(re.offsetX+(h.x||0)*f*w,re.offsetY+(h.y||0)*p*w,(h.blur||0)*f*w),r=n.Effect.getShadowTransform(t,g,s,h,re,w,!0),r&&g.setTransform(r),se(g,re,s),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),o=a):(g.copyWorld(s.canvas,u,c,"source-out"),o=d),g.fillWorld(o,n.ColorConvert.string(h.color),"source-in"),e.LeafHelper.copyCanvasByWorld(t,i,g,o,h.blendMode),m&&_<m&&g.clearWorld(o)}),g.recycle(o)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ne,getShadowTransform:function(t,e,i,n,s,o,r){if(n.spread){const i=2*n.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return ee.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/a,1+i/h),ee}},isTransformShadow(t){},getInnerShadowSpread:ae},{excludeRenderBounds:le}=e.LeafBoundsHelper;let ce;function de(t,e,i,n,s,o,r,a){switch(e){case"grayscale":ce||(ce=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),o&&n.recycle(r);fe(t,e,i,1,s,o)}(t,i,n,s,r,a);break;case"opacity-path":fe(t,i,n,o,r,a);break;case"path":a&&i.restore()}}function ue(t){return t.getSameCanvas(!1,!0)}function fe(t,e,i,n,s,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),o?i.recycle(r):i.clearWorld(r)}n.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(de(this,r,t,s,n,o,void 0,!0),n=s=null),"clipping"!==a&&"clipping-path"!==a||le(i,e)||i.__render(t,e),o=i.__.opacity,ce=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",s||(s=ue(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=ue(t)),s||(s=ue(t)),i.__render(n,e));continue}const c=1===o&&i.__.__blendMode;c&&de(this,r,t,s,n,o,void 0,!1),le(i,e)||i.__render(s||t,e),c&&de(this,r,t,s,n,o,c,!1)}de(this,r,t,s,n,o,void 0,!0)};const pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ge=pe+"_#~&*+\\=|≮≯≈≠=…",me=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],[4352,4607],[12352,12447],[12448,12543],[12544,12591],[12592,12687],[12688,12703],[12704,12735],[12784,12799],[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("|"),"u");function _e(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const we=_e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ve=_e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ye=_e(pe),xe=_e(ge),Pe=_e("- —/~|┆·");var be;!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"}(be||(be={}));const{Letter:Le,Single:Ee,Before:Be,After:Se,Symbol:Te,Break:ke}=be;function Re(t){return we[t]?Le:Pe[t]?ke:ve[t]?Be:ye[t]?Se:xe[t]?Te:me.test(t)?Ee:Le}const Ce={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Me(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Oe}=Ce,{Letter:Ae,Single:De,Before:Ie,After:We,Symbol:He,Break:Fe}=be;let je,ze,Ue,Ge,Ye,Xe,Ne,Ve,qe,Ke,Qe,$e,Ze,Je,ti,ei,ii,ni=[];function si(t,e){qe&&!Ve&&(Ve=qe),je.data.push({char:t,width:e}),Ue+=e}function oi(t){t&&(Ge+=t,je.addWidth=t),Ge+=Ue,je.width=Ue,ze.words.push(je),je={data:[]},Ue=0}function ri(){Je&&(ti.paraNumber++,ze.paraStart=!0,Je=!1),qe&&(ze.startCharSize=Ve,ze.endCharSize=qe,Ve=0),ze.width=Ge,ei.width?Oe(ze):ii&&ai(),ni.push(ze),ze={words:[]},Ge=0}function ai(){Ge>(ti.maxWidth||0)&&(ti.maxWidth=Ge)}const{top:hi,right:li,bottom:ci,left:di}=e.Direction4;function ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const fi={getDrawData:function(t,i){e.isString(t)||(t=String(t));let s=0,o=0,r=i.__getInput("width")||0,a=i.__getInput("height")||0;const{__padding:h}=i;i.motionText&&(r=a=0),h&&(r?(s=h[di],r-=h[li]+h[di],!r&&(r=.01)):i.autoSizeAlign||(s=h[di]),a?(o=h[hi],a-=h[hi]+h[ci],!a&&(a=.01)):i.autoSizeAlign||(o=h[hi]));const l={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:e.Platform.canvas.font=i.__font};return function(t,i,n){ti=t,ni=t.rows,ei=t.bounds,ii=!ei.width&&!n.autoSizeAlign;const{paraIndent:s,textCase:o}=n,{canvas:r}=e.Platform,{width:a}=ei;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap,h=n.__letterSpacing,l=n.__wordSpacing;Je=!0,Qe=null,Ve=Ne=qe=Ue=Ge=0,je={data:[]},ze={words:[]};for(let n=0,c=(i=[...i]).length;n<c;n++)Xe=i[n],"\n"===Xe?(Ue&&oi(),ze.paraEnd=!0,ri(),Je=!0):(Ke=Re(Xe),Ke===Ae&&"none"!==o&&(Xe=Me(Xe,o,!Ue)),Ne=r.measureText(Xe).width,h&&(h<0&&(qe=Ne),Ne+=h),$e=Ke===De&&(Qe===De||Qe===Ae)||Qe===De&&Ke!==We,Ze=!(Ke!==Ie&&Ke!==De||Qe!==He&&Qe!==We),Ye=Je&&s?a-s:a,t&&a&&Ge+Ue+Ne>Ye&&(e?(Ue&&oi(),Ge&&ri()):(Ze||(Ze=Ke===Ae&&Qe==We),$e||Ze||Ke===Fe||Ke===Ie||Ke===De||Ue+Ne>Ye?(Ue&&oi(),Ge&&ri()):Ge&&ri()))," "===Xe&&!0!==Je&&Ge+Ue===0||(Ke===Fe?(" "===Xe&&Ue&&oi(l),si(Xe,Ne),oi()):$e||Ze?(Ue&&oi(l),si(Xe,Ne)):si(Xe,Ne)),Qe=Ke);Ue&&oi(),Ge&&ri(),ni.length>0&&(ni[ni.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ti.paraNumber++,Ge=r.measureText(t).width,ni.push({x:s||0,text:t,width:Ge,paraStart:!0}),ii&&ai()})}(l,t,i),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ui(e,"x",t[di]);break;case"right":ui(e,"x",-t[li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ui(e,"y",t[hi]);break;case"bottom":ui(e,"y",-t[ci])}}(h,l,i,r,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:m}=n,_=o*s+(d?d*(t.paraNumber-1):0),w=r;if(h&&_>m)_=Math.max(e.__autoHeight?_:m,o),s>1&&(t.overflow=s);else if(m||u)switch(c){case"middle":p+=(m-_)/2;break;case"bottom":p+=m-_}w+=p;let v,y,x,P=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(P-v.width)/2;break;case"right":v.x+=P-v.width}v.paraStart&&d&&r>0&&(w+=d),v.y=w,w+=o,t.overflow>r&&w>_&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<n.x&&(n.x=y),x>n.width&&(n.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(l,i),i.__isCharMode&&function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o}=e,r=e.__letterSpacing||e.motionText,a=e.__wordSpacing,h=i&&s.includes("both"),l=h||i&&s.includes("justify"),c=l&&s.includes("letter");let d,u,f,p,g,m,_,w,v,y;n.forEach(t=>{t.words&&(g=o&&t.paraStart?o:0,w=t.words.length,l&&(y=!t.paraEnd||h,u=i-t.width-g,c?p=u/(t.words.reduce((t,e)=>t+e.data.length,0)-1):f=w>1?u/(w-1):0),m=r||t.isOverflow||c?0:f||a?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===m?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===m?(_={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):d=function(t,e,i,n,s){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,d,t.data,t.isOverflow,y&&p),e.addWidth&&(d+=e.addWidth),y&&(v=i===w-1,f?v||(d+=f,t.width+=f):p&&(t.width+=p*(e.data.length-(v?1:0))))})),t.words=null)})}(l,i,r),l.overflow&&function(t,i,n,s){const{rows:o,overflow:r}=t;let{textOverflow:a}=i;if(r&&o.splice(r),s&&a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?e.Platform.canvas.measureText(a).width:0,c=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],h=t.x+t.width,!(n===i&&h<c));n--){if(h<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,r),"none"!==i.textDecoration&&function(t,i){let s,o=0;const{fontSize:r,textDecoration:a}=i;switch(t.decorationHeight=r/11,e.isObject(a)?(s=a.type,a.color&&(t.decorationColor=n.ColorConvert.string(a.color)),a.offset&&(o=Math.min(.3*r,Math.max(a.offset,.15*-r)))):s=a,s){case"under":t.decorationY=[.15*r+o];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r+o,.35*-r]}}(l,i),l}};const pi={string:function(t,i){if(!t)return"#000";const s=e.isNumber(i)&&i<1;if(e.isString(t)){if(!s||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let o=e.isUndefined(t.a)?1:t.a;s&&(o*=i);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign(n.TextConvert,fi),Object.assign(n.ColorConvert,pi),Object.assign(n.Paint,Q),Object.assign(n.PaintImage,kt),Object.assign(n.PaintGradient,qt),Object.assign(n.Effect,he),Object.assign(e.Creator,{interaction:(t,e,i,n)=>new O(t,e,i,n),hitCanvas:(t,e)=>new r(t,e),hitCanvasManager:()=>new i.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferFilm",{enumerable:!0,get:function(){return e.LeaferFilm}}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return e.LeaferImage}}),Object.defineProperty(exports,"LeaferVideo",{enumerable:!0,get:function(){return e.LeaferVideo}}),exports.Interaction=O,exports.Layouter=P,exports.LayouterHelper=g,exports.LeaferCanvas=r,exports.Picker=T,exports.Renderer=L,exports.Selector=k,exports.Watcher=l,exports.useCanvas=a,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]}})}),Object.keys(i).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})});
|
|
2
2
|
//# sourceMappingURL=web.min.cjs.map
|