@leafer-ui/miniapp 1.0.0-rc.5 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.esm.js +158 -134
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +386 -235
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +6 -6
package/dist/miniapp.esm.js
CHANGED
|
@@ -558,7 +558,7 @@ class Renderer {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
const { hitRadiusPoint } = BoundsHelper;
|
|
561
|
-
class
|
|
561
|
+
class Pather {
|
|
562
562
|
constructor(target, selector) {
|
|
563
563
|
this.target = target;
|
|
564
564
|
this.selector = selector;
|
|
@@ -678,117 +678,108 @@ class FindPath {
|
|
|
678
678
|
class Selector {
|
|
679
679
|
constructor(target, userConfig) {
|
|
680
680
|
this.config = {};
|
|
681
|
-
this.
|
|
682
|
-
this.
|
|
683
|
-
this.
|
|
684
|
-
|
|
681
|
+
this.innerIdMap = {};
|
|
682
|
+
this.idMap = {};
|
|
683
|
+
this.methods = {
|
|
684
|
+
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
685
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
686
|
+
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
687
|
+
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
688
|
+
};
|
|
685
689
|
this.target = target;
|
|
686
690
|
if (userConfig)
|
|
687
691
|
this.config = DataHelper.default(userConfig, this.config);
|
|
688
|
-
this.
|
|
692
|
+
this.pather = new Pather(target, this);
|
|
689
693
|
this.__listenEvents();
|
|
690
694
|
}
|
|
691
695
|
getByPoint(hitPoint, hitRadius, options) {
|
|
692
696
|
if (Platform.name === 'node')
|
|
693
697
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
694
|
-
return this.
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
698
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
699
|
+
}
|
|
700
|
+
getBy(condition, branch, one, options) {
|
|
701
|
+
switch (typeof condition) {
|
|
702
|
+
case 'number':
|
|
703
|
+
const leaf = this.getByInnerId(condition, branch);
|
|
704
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
705
|
+
case 'string':
|
|
706
|
+
switch (condition[0]) {
|
|
707
|
+
case '#':
|
|
708
|
+
const leaf = this.getById(condition.substring(1), branch);
|
|
709
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
710
|
+
case '.':
|
|
711
|
+
return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
|
|
712
|
+
default:
|
|
713
|
+
return this.getByMethod(this.methods.tag, branch, one, condition);
|
|
714
|
+
}
|
|
715
|
+
case 'function':
|
|
716
|
+
return this.getByMethod(condition, branch, one, options);
|
|
708
717
|
}
|
|
709
718
|
}
|
|
710
|
-
getByInnerId(
|
|
711
|
-
|
|
719
|
+
getByInnerId(innerId, branch) {
|
|
720
|
+
const cache = this.innerIdMap[innerId];
|
|
712
721
|
if (cache)
|
|
713
722
|
return cache;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
let find;
|
|
717
|
-
this.loopFind(branch, (leaf) => {
|
|
718
|
-
if (leaf.innerId === name) {
|
|
719
|
-
find = leaf;
|
|
720
|
-
this.innerIdList[name] = find;
|
|
721
|
-
return true;
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
return find;
|
|
723
|
+
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
724
|
+
return this.findLeaf;
|
|
728
725
|
}
|
|
729
|
-
getById(
|
|
730
|
-
|
|
731
|
-
if (cache)
|
|
726
|
+
getById(id, branch) {
|
|
727
|
+
const cache = this.idMap[id];
|
|
728
|
+
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
732
729
|
return cache;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
let find;
|
|
736
|
-
this.loopFind(branch, (leaf) => {
|
|
737
|
-
if (leaf.id === name) {
|
|
738
|
-
find = leaf;
|
|
739
|
-
this.idList[name] = find;
|
|
740
|
-
return true;
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
return find;
|
|
747
|
-
}
|
|
748
|
-
getByClassName(name, branch) {
|
|
749
|
-
if (!branch)
|
|
750
|
-
branch = this.target;
|
|
751
|
-
let find = [];
|
|
752
|
-
this.loopFind(branch, (leaf) => {
|
|
753
|
-
if (leaf.className === name)
|
|
754
|
-
find.push(leaf);
|
|
755
|
-
return false;
|
|
756
|
-
});
|
|
757
|
-
return find;
|
|
758
|
-
}
|
|
759
|
-
getByTagName(name, branch) {
|
|
760
|
-
if (!branch)
|
|
761
|
-
branch = this.target;
|
|
762
|
-
let find = [];
|
|
763
|
-
this.loopFind(branch, (leaf) => {
|
|
764
|
-
if (leaf.__tag === name)
|
|
765
|
-
find.push(leaf);
|
|
766
|
-
return false;
|
|
767
|
-
});
|
|
768
|
-
return find;
|
|
730
|
+
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
731
|
+
return this.findLeaf;
|
|
769
732
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
733
|
+
getByClassName(className, branch) {
|
|
734
|
+
return this.getByMethod(this.methods.className, branch, false, className);
|
|
735
|
+
}
|
|
736
|
+
getByTag(tag, branch) {
|
|
737
|
+
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
738
|
+
}
|
|
739
|
+
getByMethod(method, branch, one, options) {
|
|
740
|
+
const list = one ? null : [];
|
|
741
|
+
this.eachFind(this.toChildren(branch), method, list, options);
|
|
742
|
+
return list || this.findLeaf;
|
|
743
|
+
}
|
|
744
|
+
eachFind(children, method, list, options) {
|
|
745
|
+
let child;
|
|
774
746
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
775
|
-
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
747
|
+
child = children[i];
|
|
748
|
+
if (method(child, options)) {
|
|
749
|
+
if (list) {
|
|
750
|
+
list.push(child);
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
this.findLeaf = child;
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (child.isBranch)
|
|
758
|
+
this.eachFind(child.children, method, list, options);
|
|
780
759
|
}
|
|
781
760
|
}
|
|
761
|
+
toChildren(branch) {
|
|
762
|
+
this.findLeaf = null;
|
|
763
|
+
return [branch || this.target];
|
|
764
|
+
}
|
|
782
765
|
__onRemoveChild(event) {
|
|
783
|
-
const
|
|
784
|
-
if (this.
|
|
785
|
-
this.
|
|
786
|
-
if (this.
|
|
787
|
-
this.
|
|
766
|
+
const { id, innerId } = event.child;
|
|
767
|
+
if (this.idMap[id])
|
|
768
|
+
delete this.idMap[id];
|
|
769
|
+
if (this.innerIdMap[innerId])
|
|
770
|
+
delete this.innerIdMap[innerId];
|
|
771
|
+
}
|
|
772
|
+
__checkIdChange(event) {
|
|
773
|
+
if (event.attrName === 'id') {
|
|
774
|
+
const id = event.oldValue;
|
|
775
|
+
if (this.idMap[id])
|
|
776
|
+
delete this.idMap[id];
|
|
777
|
+
}
|
|
788
778
|
}
|
|
789
779
|
__listenEvents() {
|
|
790
780
|
this.__eventIds = [
|
|
791
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this)
|
|
781
|
+
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
782
|
+
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
792
783
|
];
|
|
793
784
|
}
|
|
794
785
|
__removeListenEvents() {
|
|
@@ -798,11 +789,10 @@ class Selector {
|
|
|
798
789
|
destroy() {
|
|
799
790
|
if (this.__eventIds.length) {
|
|
800
791
|
this.__removeListenEvents();
|
|
801
|
-
this.
|
|
802
|
-
this.
|
|
803
|
-
this.
|
|
804
|
-
this.
|
|
805
|
-
this.tagNameList = {};
|
|
792
|
+
this.pather.destroy();
|
|
793
|
+
this.findLeaf = null;
|
|
794
|
+
this.innerIdMap = {};
|
|
795
|
+
this.idMap = {};
|
|
806
796
|
}
|
|
807
797
|
}
|
|
808
798
|
}
|
|
@@ -1410,8 +1400,9 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1410
1400
|
if (!paint.patternTask) {
|
|
1411
1401
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1412
1402
|
paint.patternTask = null;
|
|
1413
|
-
if (canvas.bounds.hit(ui.__world)
|
|
1414
|
-
ui.
|
|
1403
|
+
if (canvas.bounds.hit(ui.__world))
|
|
1404
|
+
createPattern(ui, paint, canvas.pixelRatio);
|
|
1405
|
+
ui.forceUpdate('surface');
|
|
1415
1406
|
}), 300);
|
|
1416
1407
|
}
|
|
1417
1408
|
}
|
|
@@ -2075,6 +2066,8 @@ function createRows(drawData, content, style) {
|
|
|
2075
2066
|
const { width, height } = bounds;
|
|
2076
2067
|
const charMode = width || height || __letterSpacing || (textCase !== 'none');
|
|
2077
2068
|
if (charMode) {
|
|
2069
|
+
const wrap = style.textWrap !== 'none';
|
|
2070
|
+
const breakAll = style.textWrap === 'break';
|
|
2078
2071
|
paraStart = true;
|
|
2079
2072
|
lastCharType = null;
|
|
2080
2073
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
@@ -2101,16 +2094,23 @@ function createRows(drawData, content, style) {
|
|
|
2101
2094
|
langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
|
|
2102
2095
|
afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
|
|
2103
2096
|
realWidth = paraStart && paraIndent ? width - paraIndent : width;
|
|
2104
|
-
if (width && rowWidth + wordWidth + charWidth > realWidth) {
|
|
2105
|
-
if (
|
|
2106
|
-
afterBreak = charType === Letter && lastCharType == After;
|
|
2107
|
-
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
2097
|
+
if (wrap && (width && rowWidth + wordWidth + charWidth > realWidth)) {
|
|
2098
|
+
if (breakAll) {
|
|
2108
2099
|
if (wordWidth)
|
|
2109
2100
|
addWord();
|
|
2110
2101
|
addRow();
|
|
2111
2102
|
}
|
|
2112
2103
|
else {
|
|
2113
|
-
|
|
2104
|
+
if (!afterBreak)
|
|
2105
|
+
afterBreak = charType === Letter && lastCharType == After;
|
|
2106
|
+
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
2107
|
+
if (wordWidth)
|
|
2108
|
+
addWord();
|
|
2109
|
+
addRow();
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
addRow();
|
|
2113
|
+
}
|
|
2114
2114
|
}
|
|
2115
2115
|
}
|
|
2116
2116
|
if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) ;
|
|
@@ -2180,7 +2180,7 @@ function addRow() {
|
|
|
2180
2180
|
|
|
2181
2181
|
const CharMode = 0;
|
|
2182
2182
|
const WordMode = 1;
|
|
2183
|
-
const
|
|
2183
|
+
const TextMode = 2;
|
|
2184
2184
|
function layoutChar(drawData, style, width, _height) {
|
|
2185
2185
|
const { rows } = drawData;
|
|
2186
2186
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
@@ -2189,15 +2189,12 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2189
2189
|
if (row.words) {
|
|
2190
2190
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2191
2191
|
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2192
|
-
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode :
|
|
2193
|
-
if (
|
|
2194
|
-
row.
|
|
2192
|
+
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2193
|
+
if (row.isOverflow && !letterSpacing)
|
|
2194
|
+
row.textMode = true;
|
|
2195
|
+
if (mode === TextMode) {
|
|
2195
2196
|
row.x += indentWidth;
|
|
2196
|
-
row
|
|
2197
|
-
word.data.forEach(char => {
|
|
2198
|
-
row.text += char.char;
|
|
2199
|
-
});
|
|
2200
|
-
});
|
|
2197
|
+
toTextChar$1(row);
|
|
2201
2198
|
}
|
|
2202
2199
|
else {
|
|
2203
2200
|
row.x += indentWidth;
|
|
@@ -2223,6 +2220,14 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2223
2220
|
}
|
|
2224
2221
|
});
|
|
2225
2222
|
}
|
|
2223
|
+
function toTextChar$1(row) {
|
|
2224
|
+
row.text = '';
|
|
2225
|
+
row.words.forEach(word => {
|
|
2226
|
+
word.data.forEach(char => {
|
|
2227
|
+
row.text += char.char;
|
|
2228
|
+
});
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2226
2231
|
function toWordChar(data, charX, wordChar) {
|
|
2227
2232
|
data.forEach(char => {
|
|
2228
2233
|
wordChar.char += char.char;
|
|
@@ -2243,10 +2248,10 @@ function toChar(data, charX, rowData) {
|
|
|
2243
2248
|
|
|
2244
2249
|
function layoutText(drawData, style) {
|
|
2245
2250
|
const { rows, bounds } = drawData;
|
|
2246
|
-
const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing
|
|
2251
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2247
2252
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2248
2253
|
let starY = __baseLine;
|
|
2249
|
-
if (
|
|
2254
|
+
if (__clipText && realHeight > height) {
|
|
2250
2255
|
realHeight = Math.max(height, __lineHeight);
|
|
2251
2256
|
drawData.overflow = rows.length;
|
|
2252
2257
|
}
|
|
@@ -2295,39 +2300,58 @@ function layoutText(drawData, style) {
|
|
|
2295
2300
|
bounds.x = rowX;
|
|
2296
2301
|
if (rowWidth > bounds.width)
|
|
2297
2302
|
bounds.width = rowWidth;
|
|
2303
|
+
if (__clipText && width && width < rowWidth) {
|
|
2304
|
+
row.isOverflow = true;
|
|
2305
|
+
if (!drawData.overflow)
|
|
2306
|
+
drawData.overflow = rows.length;
|
|
2307
|
+
}
|
|
2298
2308
|
}
|
|
2299
2309
|
bounds.y = y;
|
|
2300
2310
|
bounds.height = realHeight;
|
|
2301
2311
|
}
|
|
2302
2312
|
|
|
2303
|
-
function clipText(drawData,
|
|
2313
|
+
function clipText(drawData, style) {
|
|
2304
2314
|
const { rows, overflow } = drawData;
|
|
2315
|
+
let { textOverflow } = style;
|
|
2305
2316
|
rows.splice(overflow);
|
|
2306
2317
|
if (textOverflow !== 'hide') {
|
|
2307
2318
|
if (textOverflow === 'ellipsis')
|
|
2308
2319
|
textOverflow = '...';
|
|
2320
|
+
let char, charRight;
|
|
2309
2321
|
const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2322
|
+
const right = style.x + style.width - ellipsisWidth;
|
|
2323
|
+
const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
|
|
2324
|
+
list.forEach(row => {
|
|
2325
|
+
if (row.isOverflow && row.data) {
|
|
2326
|
+
let end = row.data.length - 1;
|
|
2327
|
+
for (let i = end; i > -1; i--) {
|
|
2328
|
+
char = row.data[i];
|
|
2329
|
+
charRight = char.x + char.width;
|
|
2330
|
+
if (i === end && charRight < right) {
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
else if (charRight < right && char.char !== ' ') {
|
|
2334
|
+
row.data.splice(i + 1);
|
|
2335
|
+
row.width -= char.width;
|
|
2336
|
+
break;
|
|
2337
|
+
}
|
|
2338
|
+
row.width -= char.width;
|
|
2339
|
+
}
|
|
2340
|
+
row.width += ellipsisWidth;
|
|
2341
|
+
row.data.push({ char: textOverflow, x: charRight });
|
|
2342
|
+
if (row.textMode)
|
|
2343
|
+
toTextChar(row);
|
|
2324
2344
|
}
|
|
2325
|
-
|
|
2326
|
-
}
|
|
2327
|
-
row.width += ellipsisWidth;
|
|
2328
|
-
row.data.push({ char: textOverflow, x: charRight });
|
|
2345
|
+
});
|
|
2329
2346
|
}
|
|
2330
2347
|
}
|
|
2348
|
+
function toTextChar(row) {
|
|
2349
|
+
row.text = '';
|
|
2350
|
+
row.data.forEach(char => {
|
|
2351
|
+
row.text += char.char;
|
|
2352
|
+
});
|
|
2353
|
+
row.data = null;
|
|
2354
|
+
}
|
|
2331
2355
|
|
|
2332
2356
|
function decorationText(drawData, style) {
|
|
2333
2357
|
const { fontSize } = style;
|
|
@@ -2348,7 +2372,7 @@ const TextConvert = {
|
|
|
2348
2372
|
let x = 0, y = 0;
|
|
2349
2373
|
let width = style.__getInput('width') || 0;
|
|
2350
2374
|
let height = style.__getInput('height') || 0;
|
|
2351
|
-
const { textDecoration,
|
|
2375
|
+
const { textDecoration, __font, padding } = style;
|
|
2352
2376
|
if (padding) {
|
|
2353
2377
|
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
2354
2378
|
if (width) {
|
|
@@ -2370,7 +2394,7 @@ const TextConvert = {
|
|
|
2370
2394
|
layoutText(drawData, style);
|
|
2371
2395
|
layoutChar(drawData, style, width);
|
|
2372
2396
|
if (drawData.overflow)
|
|
2373
|
-
clipText(drawData,
|
|
2397
|
+
clipText(drawData, style);
|
|
2374
2398
|
if (textDecoration !== 'none')
|
|
2375
2399
|
decorationText(drawData, style);
|
|
2376
2400
|
return drawData;
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as d,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as g,Run as f,ImageManager as _,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,canvasSizeAttrs as b,InteractionHelper as B,InteractionBase as R,LeaferImage as L,FileHelper as E,MatrixHelper as S,ImageEvent as T,PointHelper as k,MathHelper as A,TaskProcessor as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,ImageManager as O,Paint as I,Effect as W,TextConvert as P,Export as D,Platform as z}from"@leafer-ui/core";export*from"@leafer-ui/core";class F{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:V,updateAllWorldOpacity:N}=r,{pushAllChildBranch:U,pushAllParent:Y}=a;const{worldBounds:H}=d,{setByListWithHandle:j}=l;class X{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){j(this.beforeBounds,this.updatedList.list,H)}setAfter(){j(this.afterBounds,this.updatedList.list,H),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:G,updateAllChange:q}=r,{pushAllBranchStack:Q,updateWorldBoundsByBranchStack:K}=a,Z=c.get("Layouter");class ${constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.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.running)return;const{target:t}=this;this.times=0;try{t.emit(g.START),this.layoutOnce(),t.emitEvent(new g(g.END,this.layoutedBlocks,this.times))}catch(t){Z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Z.warn("layouting"):this.times>3?Z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?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 e=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=g,a=this.getBlocks(s);a.forEach((t=>{t.setBefore()})),i.emitEvent(new g(n,a,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(V(t),e.push(t),t.isBranch&&U(t,e),Y(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Y(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&N(t),t.__updateChange()}))}(s),a.forEach((t=>t.setAfter())),i.emitEvent(new g(o,a,this.times)),i.emitEvent(new g(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=g,r=this.getBlocks(new t(i));i.emitEvent(new g(s,r,this.times)),$.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new g(n,r,this.times)),i.emitEvent(new g(o,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){if(G(t),t.isBranch){const e=[t];Q(t,e),K(e)}else t.__updateWorldBounds();q(t)}createBlock(t){return new X(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.REQUEST,this.layout,this),t.on_(g.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const J=c.get("Renderer");class tt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(g.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,J.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,J.error(t)}J.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?J.warn("rendering"):this.times>3?J.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return J.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=(new h).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new h;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||J.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(g.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:et}=l;class it{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.push(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||et(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class st{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new it(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(g.CHECK_UPDATE),this.findPath.getByPoint(t,e,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new F(t,e),layouter:(t,e)=>new $(t,e),renderer:(t,e,i)=>new tt(t,e,i),selector:(t,e)=>new st(t,e)}),p.layout=$.fullLayout;class nt extends v{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=p.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&p.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:i,pixelRatio:s}=this.config,n={width:e||t.width,height:i||t.height,pixelRatio:s};this.resize(n),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),x(this.context.__proto__)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i}updateClientBounds(t){this.viewSelect&&p.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,e){this.resizeListener=e,this.checkSize=this.checkSize.bind(this),p.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:i}=this.clientBounds,{pixelRatio:s}=this,n={width:t,height:i,pixelRatio:s};if(!this.isSameSize(n)){const t={};e.copyAttrs(t,this,b),this.resize(n),void 0!==this.width&&this.resizeListener(new y(n,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,p.miniapp.offWindowResize(this.checkSize)}}const ot={convertTouch(t,e){const i=ot.getTouch(t),s=B.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class rt extends R{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){if(e&&this.canvas.updateClientBounds(),void 0!==t.x)return{x:t.x,y:t.y};{const{clientBounds:e}=this.canvas;return{x:t.clientX-e.x,y:t.clientY-e.y}}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ot.getTouch(t);this.pointerDown(ot.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ot.getTouch(t);this.pointerMove(ot.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ot.getTouch(t);this.pointerUp(ot.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,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),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(B.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}const{mineType:at,fileType:ht}=E;function dt(t,e){p.origin||(p.origin={createCanvas:(t,i,s)=>e.createOffscreenCanvas({type:"2d",width:t,height:i}),canvasToDataURL:(t,e,i)=>t.toDataURL(at(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>new Promise(((n,o)=>{let r,a=t.toDataURL(at(ht(i)),s);a=a.substring(a.indexOf("64,")+3),i.includes("/")||(i=`${e.env.USER_DATA_PATH}/`+i,r=!0);const h=e.getFileSystemManager();h.writeFile({filePath:i,data:a,encoding:"base64",success(){r&&p.miniapp.saveToAlbum(i).then((()=>{h.unlink({filePath:i})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((e,i)=>{const s=p.canvas.view.createImage();s.onload=()=>{e(s)},s.onerror=t=>{i(t)},s.src=t})),noRepeat:"repeat-x"},p.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})})),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},p.event={stopDefault(t){},stopNow(t){},stop(t){}},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient)}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new L(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new rt(t,e,i,s)}),p.name="miniapp",p.requestRender=function(t){p.canvas.view.requestAnimationFrame(t)},p.devicePixelRatio=wx.getSystemInfoSync().pixelRatio,p.realtimeLayout=!0;const{get:lt,rotateOfOuter:ct,translate:ut,scaleOfOuter:gt,scale:ft,rotate:_t}=S;const{get:pt,translate:wt}=S;function yt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:d,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=pt(),wt(g.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=lt();ut(o,e.x,e.y),i&&ut(o,i.x,i.y),s&&("number"==typeof s?ft(o,s):ft(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&_t(o,n),t.transform=o}(g,s,h,d,l);break;case"repeat":(!u||d||l)&&function(t,e,i,s,n,o){const r=lt();if(o)switch(_t(r,o),o){case 90:ut(r,s,0);break;case 180:ut(r,i,s);break;case 270:ut(r,0,i)}ut(r,e.x,e.y),n&&(gt(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,d,l);break;default:u&&!l||function(t,e,i,s,n,o){const r=lt(),a=o&&180!==o,h=i.width/(a?n:s),d=i.height/(a?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ut(r,c,u),ft(r,l),o&&ct(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=r}(g,a,s,n,o,l)}g.width=n,g.height=o,r&&(g.opacity=r)}function mt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function vt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new T(t,e))}function xt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:bt,scale:Bt,copy:Rt}=S;function Lt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{e.patternId=o,s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e,a=t.isSVG?4096:Math.min(t.width,4096),h=t.isSVG?4096:Math.min(t.height,4096);let d,l,{width:c,height:u,scaleX:g,scaleY:f,opacity:_,transform:w,mode:y}=r;g&&(l=bt(),Rt(l,w),Bt(l,1/g,1/f),s*=g,n*=f),s*=i,n*=i,c*=s,u*=n,(c>a||u>h)&&(d=Math.max(c/a,u/h)),d&&(s/=d,n/=d,c/=d,u/=d),g&&(s/=g,n/=f),(w||1!==s||1!==n)&&(l||(l=bt(),w&&Rt(l,w)),Bt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,_),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function Et(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:r}=i.data;t*=n*e.pixelRatio,r*=o*e.pixelRatio,s=t>4096||r>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?i.patternTask||(i.patternTask=_.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Lt(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300)):Lt(t,i,e.pixelRatio),!1}return!1}function St(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function Tt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function kt(t,e,i,s){const{strokeAlign:n}=e.__,o="string"!=typeof t;switch(n){case"center":i.setStroke(o?void 0:t,e.__.strokeWidth,e.__),o?Mt(t,!0,e,i):Ct(e,i);break;case"inside":At("inside",t,o,e,i,s);break;case"outside":At("outside",t,o,e,i,s)}}function At(t,e,i,s,n,o){const{strokeWidth:r,__font:a}=s.__,h=n.getSameCanvas(!0);h.setStroke(i?void 0:e,2*r,s.__),h.font=a,i?Mt(e,!0,s,h):Ct(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",Tt(s,h),h.blendMode="normal",s.__hasMirror||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function Ct(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Mt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Et(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ct(i,s):s.stroke(),s.restoreBlendMode()):e?Ct(i,s):s.stroke())}const{getSpread:Ot,getOuterOf:It,getByMove:Wt,getIntersectData:Pt}=l;const Dt={x:.5,y:0},zt={x:.5,y:1};function Ft(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Vt,getAngle:Nt,getDistance:Ut}=k,{get:Yt,rotateOfOuter:Ht,scaleOfOuter:jt}=S,Xt={x:.5,y:.5},Gt={x:.5,y:1},qt={},Qt={};const{set:Kt,getAngle:Zt,getDistance:$t}=k,{get:Jt,rotateOfOuter:te,scaleOfOuter:ee}=S,ie={x:.5,y:.5},se={x:.5,y:1},ne={},oe={};let re;function ae(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:M.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=_.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(mt(t,e,r)&&yt(o,r,i,s),n&&(vt(T.LOAD,a),vt(T.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,vt(T.ERROR,a)):(n&&vt(T.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(mt(t,e,r)&&(yt(o,r,i,s),t.forceUpdate("surface")),vt(T.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,vt(T.ERROR,a)}))),o}(i,t,e,s,!re||!re[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Dt),s||(s=zt);const a=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Ft(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=Xt),s||(s=Gt);const{x:h,y:d,width:l,height:c}=e;let u;Vt(qt,h+i.x*l,d+i.y*c),Vt(Qt,h+s.x*l,d+s.y*c),(l!==c||a)&&(u=Yt(),jt(u,qt,l/c*(a||1),1),Ht(u,qt,Nt(qt,Qt)+90));const g=p.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,Ut(qt,Qt));Ft(g,t.stops,o);const f={type:n,style:g,transform:u};return r&&(f.blendMode=r),f}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=ie),s||(s=se);const{x:h,y:d,width:l,height:c}=e;Kt(ne,h+i.x*l,d+i.y*c),Kt(oe,h+s.x*l,d+s.y*c);const u=Jt(),g=Zt(ne,oe);p.conicGradientRotate90?(ee(u,ne,l/c*(a||1),1),te(u,ne,g+90)):(ee(u,ne,1,l/c*(a||1)),te(u,ne,g));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,ne.x,ne.y):p.canvas.createRadialGradient(ne.x,ne.y,0,ne.x,ne.y,$t(ne,oe));Ft(f,t.stops,o);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var he=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,o,r=s.__input[t];r instanceof Array||(r=[r]),re=St(t,s);for(let s=0,o=r.length;s<o;s++)n=ae(t,r[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===r.length){const t=r[0];"image"===t.type&&(o=O.isPixel(t))}"fill"===t?s.__pixelFill=o:s.__pixelStroke=o},drawTextStroke:Ct,fill:function(t,e,i){i.fillStyle=t,e.__.__font?Tt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:Tt,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Et(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?Tt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Tt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Tt(e,i):n?i.fill(n):i.fill())},recycleImage:St,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=r=It(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Pt(s?Ot(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),d*=o.a,l*=o.d),r=It(h,o),n=Wt(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:d,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)kt(t,e,i,s);else switch(r){case"center":i.setStroke(t,o,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*o,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:kt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:r,__font:a}=n;if(o)if(a)kt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,o,n),Mt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),Mt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,a=i.getSameCanvas(!0);e.__drawRenderPath(a),a.setStroke(void 0,2*o,e.__),Mt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,r),a.recycle()}}});const{copy:de,toOffsetOutBounds:le}=l,ce={},ue={};function ge(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(p.fullImageShadow){if(de(ce,t.bounds),ce.x+=e.x-o.x,ce.y+=e.y-o.y,i){const{matrix:t}=s;ce.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ce.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ce.width*=i,ce.height*=i}t.copyWorld(s.canvas,t.bounds,ce)}else i&&(de(ce,e),ce.x-=e.width/2*(i-1),ce.y-=e.height/2*(i-1),ce.width*=i,ce.height*=i),t.copyWorld(s.canvas,o,i?ce:e)}const{toOffsetOutBounds:fe}=l,_e={};var pe=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;fe(l,_e),h.forEach(((h,p)=>{f.save(),f.setWorldShadow(_e.offsetX+h.x*u,_e.offsetY+h.y*g,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ge(f,_e,o,i),f.restore(),d?(f.copyWorld(f,l,r,"copy"),f.copyWorld(d,r,r,"source-out"),n=r):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,h.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(f,n,r,h.blendMode):e.copyWorldToInner(f,n,a.renderBounds,h.blendMode),_&&p<_&&f.clear()})),f.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),_=h.length-1;le(l,ue),h.forEach(((h,p)=>{f.setWorldShadow(ue.offsetX+h.x*u,ue.offsetY+h.y*g,h.blur*u,h.color),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ge(f,ue,o,i),n=l,h.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,r,"copy"),n=r),d?f.copyWorld(d,r,r,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(f,n,r,h.blendMode):e.copyWorldToInner(f,n,a.renderBounds,h.blendMode),_&&p<_&&f.clear()})),f.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ye=we+"_#~&*+\\=|≮≯≈≠=…",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 xe=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),be=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Be=ve(we),Re=ve(ye),Le=ve("- —/~|┆·");var Ee;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Ee||(Ee={}));const{Letter:Se,Single:Te,Before:ke,After:Ae,Symbol:Ce,Break:Me}=Ee;function Oe(t){return xe[t]?Se:Le[t]?Me:be[t]?ke:Be[t]?Ae:Re[t]?Ce:me.test(t)?Te:Se}const Ie={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function We(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:Pe}=Ie,{Letter:De,Single:ze,Before:Fe,After:Ve,Symbol:Ne,Break:Ue}=Ee;let Ye,He,je,Xe,Ge,qe,Qe,Ke,Ze,$e,Je,ti,ei,ii,si,ni,oi=[];function ri(t,e){Ze&&!Ke&&(Ke=Ze),Ye.data.push({char:t,width:e}),je+=e}function ai(){Xe+=je,Ye.width=je,He.words.push(Ye),Ye={data:[]},je=0}function hi(){ii&&(si.paraNumber++,He.paraStart=!0,ii=!1),Ze&&(He.startCharSize=Ke,He.endCharSize=Ze,Ke=0),He.width=Xe,ni.width&&Pe(He),oi.push(He),He={words:[]},Xe=0}const di={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:r,textOverflow:a,__font:h,padding:d}=e;if(d){const[t,e,r,a]=A.fourNumber(d);n&&(i=a,n-=e+a),o&&(s=t,o-=t+r)}const l={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:p.canvas.font=h};return function(t,e,i){si=t,oi=t.rows,ni=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=p,{width:a,height:h}=ni;if(a||h||s||"none"!==o){ii=!0,Je=null,Ke=Qe=Ze=je=Xe=0,Ye={data:[]},He={words:[]};for(let t=0,i=e.length;t<i;t++)qe=e[t],"\n"===qe?(je&&ai(),He.paraEnd=!0,hi(),ii=!0):($e=Oe(qe),$e===De&&"none"!==o&&(qe=We(qe,o,!je)),Qe=r.measureText(qe).width,s&&(s<0&&(Ze=Qe),Qe+=s),ti=$e===ze&&(Je===ze||Je===De)||Je===ze&&$e!==Ve,ei=!($e!==Fe&&$e!==ze||Je!==Ne&&Je!==Ve),Ge=ii&&n?a-n:a,a&&Xe+je+Qe>Ge&&(ei||(ei=$e===De&&Je==Ve),ti||ei||$e===Ue||$e===Fe||$e===ze||je+Qe>Ge?(je&&ai(),hi()):hi())," "===qe&&!0!==ii&&Xe+je===0||($e===Ue?(" "===qe&&je&&ai(),ri(qe,Qe),ai()):ti||ei?(je&&ai(),ri(qe,Qe)):ri(qe,Qe)),Je=$e);je&&ai(),Xe&&hi(),oi.length>0&&(oi[oi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{si.paraNumber++,oi.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,textAlign:a,verticalAlign:h,paraSpacing:d,textOverflow:l}=e;let c,u,g,{x:f,y:_,width:p,height:w}=s,y=n*i.length+(d?d*(t.paraNumber-1):0),m=o;if("show"!==l&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,h=i.length;o<h;o++){switch(c=i[o],c.x=f,a){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&d&&o>0&&(m+=d),c.y=m,m+=n,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,g=c.width,r<0&&(c.width<0?(g=-c.width+e.fontSize+r,u-=g,g+=e.fontSize):g-=r),u<s.x&&(s.x=u),g>s.width&&(s.width=g)}s.y=_,s.height=y}(l,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?0:d>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,o=i[s-1];let r,a,h=o.data.length-1;const{x:d,width:l}=t.bounds,c=d+l-n;for(let t=h;t>-1&&(r=o.data[t],a=r.x+r.width,!(t===h&&a<c));t--){if(a<c&&" "!==r.char){o.data.splice(t+1),o.width-=r.width;break}o.width-=r.width}o.width+=n,o.data.push({char:e,x:a})}}(l,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,e),l}},li={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},ci={export(t,e,i){return function(t){ui||(ui=new C);return new Promise((e=>{ui.add((()=>xt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),d&&h.recycle()})))):(s({data:!1}),n())}))))}};let ui;Object.assign(I,he),Object.assign(W,pe),Object.assign(P,di),Object.assign(M,li),Object.assign(D,ci);try{dt(0,wx)}catch(t){}nt.prototype.__createContext=function(){if(this.viewSelect){const t=z.origin.createCanvas(1,1),e=this.view.getContext("2d");this.testView=this.view,this.testContext=e,this.view=t}this.context=this.view.getContext("2d"),this.__bindContext()},nt.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,z.origin.noRepeat);this.testContext.clearRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t,this.testContext.fillRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t=null}},nt.prototype.updateViewSize=function(){const{width:t,height:e,pixelRatio:i,view:s,testView:n}=this;s.width=t*i,s.height=e*i,n&&(n.width=s.width,n.height=s.height)};export{rt as Interaction,$ as Layouter,nt as LeaferCanvas,tt as Renderer,st as Selector,F as Watcher,dt as useCanvas};
|
|
1
|
+
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as a,BranchHelper as r,Bounds as h,LeafBoundsHelper as d,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as g,ImageManager as _,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,canvasSizeAttrs as b,InteractionHelper as B,InteractionBase as R,LeaferImage as E,FileHelper as S,MatrixHelper as L,ImageEvent as k,PointHelper as T,MathHelper as M,TaskProcessor as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as A,ImageManager as O,Paint as I,Effect as W,TextConvert as P,Export as D,Platform as z}from"@leafer-ui/core";export*from"@leafer-ui/core";class F{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:V,updateAllWorldOpacity:N}=a,{pushAllChildBranch:U,pushAllParent:Y}=r;const{worldBounds:H}=d,{setByListWithHandle:j}=l;class G{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){j(this.beforeBounds,this.updatedList.list,H)}setAfter(){j(this.afterBounds,this.updatedList.list,H),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:X,updateAllChange:q}=a,{pushAllBranchStack:Q,updateWorldBoundsByBranchStack:K}=r,Z=c.get("Layouter");class ${constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.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.running)return;const{target:t}=this;this.times=0;try{t.emit(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){Z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Z.warn("layouting"):this.times>3?Z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?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 e=g.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=f,r=this.getBlocks(s);r.forEach((t=>{t.setBefore()})),i.emitEvent(new f(n,r,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(V(t),e.push(t),t.isBranch&&U(t,e),Y(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Y(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&N(t),t.__updateChange()}))}(s),r.forEach((t=>t.setAfter())),i.emitEvent(new f(o,r,this.times)),i.emitEvent(new f(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,g.end(e)}fullLayout(){const e=g.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=f,a=this.getBlocks(new t(i));i.emitEvent(new f(s,a,this.times)),$.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new f(n,a,this.times)),i.emitEvent(new f(o,a,this.times)),this.addBlocks(a),g.end(e)}static fullLayout(t){if(X(t),t.isBranch){const e=[t];Q(t,e),K(e)}else t.__updateWorldBounds();q(t)}createBlock(t){return new G(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const J=c.get("Renderer");class tt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,J.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,J.error(t)}J.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?J.warn("rendering"):this.times>3?J.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return J.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=g.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=(new h).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),g.end(e)}fullRender(){const t=g.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),g.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new h;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||J.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:et}=l;class it{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const o=this.findList,a=this.getBestMatchLeaf(),r=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:r,leaf:a,throughPath:o.length?this.getThroughPath(o):r}:{path:r,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,a;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!o||!o.has(a));t++)i.push(a)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||et(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class st{constructor(t,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?this.idMap[e]=t:0,innerId:(t,e)=>t.innerId===e?this.innerIdMap[e]=t:0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new it(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&a.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++){if(n=t[o],e(n,s)){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(o.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(m,{watcher:(t,e)=>new F(t,e),layouter:(t,e)=>new $(t,e),renderer:(t,e,i)=>new tt(t,e,i),selector:(t,e)=>new st(t,e)}),p.layout=$.fullLayout;class nt extends v{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=p.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&p.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:i,pixelRatio:s}=this.config,n={width:e||t.width,height:i||t.height,pixelRatio:s};this.resize(n),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),x(this.context.__proto__)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i}updateClientBounds(t){this.viewSelect&&p.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,e){this.resizeListener=e,this.checkSize=this.checkSize.bind(this),p.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:i}=this.clientBounds,{pixelRatio:s}=this,n={width:t,height:i,pixelRatio:s};if(!this.isSameSize(n)){const t={};e.copyAttrs(t,this,b),this.resize(n),void 0!==this.width&&this.resizeListener(new y(n,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,p.miniapp.offWindowResize(this.checkSize)}}const ot={convertTouch(t,e){const i=ot.getTouch(t),s=B.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class at extends R{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){if(e&&this.canvas.updateClientBounds(),void 0!==t.x)return{x:t.x,y:t.y};{const{clientBounds:e}=this.canvas;return{x:t.clientX-e.x,y:t.clientY-e.y}}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ot.getTouch(t);this.pointerDown(ot.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ot.getTouch(t);this.pointerMove(ot.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ot.getTouch(t);this.pointerUp(ot.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,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),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(B.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}const{mineType:rt,fileType:ht}=S;function dt(t,e){p.origin||(p.origin={createCanvas:(t,i,s)=>e.createOffscreenCanvas({type:"2d",width:t,height:i}),canvasToDataURL:(t,e,i)=>t.toDataURL(rt(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>new Promise(((n,o)=>{let a,r=t.toDataURL(rt(ht(i)),s);r=r.substring(r.indexOf("64,")+3),i.includes("/")||(i=`${e.env.USER_DATA_PATH}/`+i,a=!0);const h=e.getFileSystemManager();h.writeFile({filePath:i,data:r,encoding:"base64",success(){a&&p.miniapp.saveToAlbum(i).then((()=>{h.unlink({filePath:i})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((e,i)=>{const s=p.canvas.view.createImage();s.onload=()=>{e(s)},s.onerror=t=>{i(t)},s.src=t})),noRepeat:"repeat-x"},p.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})})),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},p.event={stopDefault(t){},stopNow(t){},stop(t){}},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient)}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new E(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new at(t,e,i,s)}),p.name="miniapp",p.requestRender=function(t){p.canvas.view.requestAnimationFrame(t)},p.devicePixelRatio=wx.getSystemInfoSync().pixelRatio,p.realtimeLayout=!0;const{get:lt,rotateOfOuter:ct,translate:ut,scaleOfOuter:ft,scale:gt,rotate:_t}=L;const{get:pt,translate:wt}=L;function yt(t,e,i,s){let{width:n,height:o}=e;const{opacity:a,mode:r,offset:h,scale:d,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const f=t.data={mode:r};switch(r){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(f.transform=pt(),wt(f.transform,s.x,s.y));break;case"clip":(h||d||l)&&function(t,e,i,s,n){const o=lt();ut(o,e.x,e.y),i&&ut(o,i.x,i.y),s&&("number"==typeof s?gt(o,s):gt(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&_t(o,n),t.transform=o}(f,s,h,d,l);break;case"repeat":(!u||d||l)&&function(t,e,i,s,n,o){const a=lt();if(o)switch(_t(a,o),o){case 90:ut(a,s,0);break;case 180:ut(a,i,s);break;case 270:ut(a,0,i)}ut(a,e.x,e.y),n&&(ft(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,s,n,o,d,l);break;default:u&&!l||function(t,e,i,s,n,o){const a=lt(),r=o&&180!==o,h=i.width/(r?n:s),d=i.height/(r?s:n),l="fit"===e?Math.min(h,d):Math.max(h,d),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ut(a,c,u),gt(a,l),o&&ct(a,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=l,t.transform=a}(f,r,s,n,o,l)}f.width=n,f.height=o,a&&(f.opacity=a)}function mt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function vt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new k(t,e))}function xt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:bt,scale:Bt,copy:Rt}=L;function Et(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{e.patternId=o,s=Math.abs(s),n=Math.abs(n);const{image:t,data:a}=e,r=t.isSVG?4096:Math.min(t.width,4096),h=t.isSVG?4096:Math.min(t.height,4096);let d,l,{width:c,height:u,scaleX:f,scaleY:g,opacity:_,transform:w,mode:y}=a;f&&(l=bt(),Rt(l,w),Bt(l,1/f,1/g),s*=f,n*=g),s*=i,n*=i,c*=s,u*=n,(c>r||u>h)&&(d=Math.max(c/r,u/h)),d&&(s/=d,n/=d,c/=d,u/=d),f&&(s/=f,n/=g),(w||1!==s||1!==n)&&(l||(l=bt(),w&&Rt(l,w)),Bt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,_),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function St(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:a}=i.data;t*=n*e.pixelRatio,a*=o*e.pixelRatio,s=t>4096||a>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?i.patternTask||(i.patternTask=_.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Et(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)):Et(t,i,e.pixelRatio),!1}return!1}function Lt(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,_.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null}function kt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Tt(t,e,i,s){const{strokeAlign:n}=e.__,o="string"!=typeof t;switch(n){case"center":i.setStroke(o?void 0:t,e.__.strokeWidth,e.__),o?At(t,!0,e,i):Ct(e,i);break;case"inside":Mt("inside",t,o,e,i,s);break;case"outside":Mt("outside",t,o,e,i,s)}}function Mt(t,e,i,s,n,o){const{strokeWidth:a,__font:r}=s.__,h=n.getSameCanvas(!0);h.setStroke(i?void 0:e,2*a,s.__),h.font=r,i?At(e,!0,s,h):Ct(s,h),h.blendMode="outside"===t?"destination-out":"destination-in",kt(s,h),h.blendMode="normal",s.__hasMirror||o.matrix?n.copyWorldByReset(h):n.copyWorldToInner(h,s.__world,s.__layout.renderBounds),h.recycle()}function Ct(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function At(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&St(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ct(i,s):s.stroke(),s.restoreBlendMode()):e?Ct(i,s):s.stroke())}const{getSpread:Ot,getOuterOf:It,getByMove:Wt,getIntersectData:Pt}=l;const Dt={x:.5,y:0},zt={x:.5,y:1};function Ft(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,A.string(s.color,i))}const{set:Vt,getAngle:Nt,getDistance:Ut}=T,{get:Yt,rotateOfOuter:Ht,scaleOfOuter:jt}=L,Gt={x:.5,y:.5},Xt={x:.5,y:1},qt={},Qt={};const{set:Kt,getAngle:Zt,getDistance:$t}=T,{get:Jt,rotateOfOuter:te,scaleOfOuter:ee}=L,ie={x:.5,y:.5},se={x:.5,y:1},ne={},oe={};let ae;function re(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:A.string(a,r)};case"image":return function(t,e,i,s,n){const o={type:i.type},a=o.image=_.get(i),r=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:i};return a.ready?(mt(t,e,a)&&yt(o,a,i,s),n&&(vt(k.LOAD,r),vt(k.LOADED,r))):a.error?n&&(t.forceUpdate("surface"),r.error=a.error,vt(k.ERROR,r)):(n&&vt(k.LOAD,r),o.loadId=a.load((()=>{t.destroyed||(mt(t,e,a)&&(yt(o,a,i,s),t.forceUpdate("surface")),vt(k.LOADED,r))}),(e=>{t.forceUpdate("surface"),r.error=e,vt(k.ERROR,r)}))),o}(i,t,e,s,!ae||!ae[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:a}=t;i||(i=Dt),s||(s=zt);const r=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Ft(r,t.stops,a);const h={type:n,style:r};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:a,stretch:r}=t;i||(i=Gt),s||(s=Xt);const{x:h,y:d,width:l,height:c}=e;let u;Vt(qt,h+i.x*l,d+i.y*c),Vt(Qt,h+s.x*l,d+s.y*c),(l!==c||r)&&(u=Yt(),jt(u,qt,l/c*(r||1),1),Ht(u,qt,Nt(qt,Qt)+90));const f=p.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,Ut(qt,Qt));Ft(f,t.stops,o);const g={type:n,style:f,transform:u};return a&&(g.blendMode=a),g}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:a,stretch:r}=t;i||(i=ie),s||(s=se);const{x:h,y:d,width:l,height:c}=e;Kt(ne,h+i.x*l,d+i.y*c),Kt(oe,h+s.x*l,d+s.y*c);const u=Jt(),f=Zt(ne,oe);p.conicGradientRotate90?(ee(u,ne,l/c*(r||1),1),te(u,ne,f+90)):(ee(u,ne,1,l/c*(r||1)),te(u,ne,f));const g=p.conicGradientSupport?p.canvas.createConicGradient(0,ne.x,ne.y):p.canvas.createRadialGradient(ne.x,ne.y,0,ne.x,ne.y,$t(ne,oe));Ft(g,t.stops,o);const _={type:n,style:g,transform:u};return a&&(_.blendMode=a),_}(e,s);default:return e.r?{type:"solid",style:A.string(e)}:void 0}}var he=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,o,a=s.__input[t];a instanceof Array||(a=[a]),ae=Lt(t,s);for(let s=0,o=a.length;s<o;s++)n=re(t,a[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===a.length){const t=a[0];"image"===t.type&&(o=O.isPixel(t))}"fill"===t?s.__pixelFill=o:s.__pixelStroke=o},drawTextStroke:Ct,fill:function(t,e,i){i.fillStyle=t,e.__.__font?kt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:kt,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&St(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?kt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?kt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?kt(e,i):n?i.fill(n):i.fill())},recycleImage:Lt,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,a,r;const{__world:h}=t;let{scaleX:d,scaleY:l}=h;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(h,i.matrix))i.matrix?(d*=i.matrix.a,l*=i.matrix.d,n=a=It(h,i.matrix)):n=a=h,r=s;else{const{renderShapeSpread:s}=t.__layout,c=Pt(s?Ot(e.bounds,s*d,s*l):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(r=e.getSameCanvas(),t.__renderShape(r,i),d*=o.a,l*=o.d),a=It(h,o),n=Wt(a,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:r,shapeBounds:a,scaleX:d,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:a,__font:r}=n;if(o)if(r)Tt(t,e,i,s);else switch(a){case"center":i.setStroke(t,o,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0);a.setStroke(t,2*o,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:Tt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:o,strokeAlign:a,__font:r}=n;if(o)if(r)Tt(t,e,i,s);else switch(a){case"center":i.setStroke(void 0,o,n),At(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*o,n),n.windingRule?i.clip(n.windingRule):i.clip(),At(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0);e.__drawRenderPath(r),r.setStroke(void 0,2*o,e.__),At(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(a),e.__hasMirror||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,a),r.recycle()}}});const{copy:de,toOffsetOutBounds:le}=l,ce={},ue={};function fe(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(p.fullImageShadow){if(de(ce,t.bounds),ce.x+=e.x-o.x,ce.y+=e.y-o.y,i){const{matrix:t}=s;ce.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ce.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ce.width*=i,ce.height*=i}t.copyWorld(s.canvas,t.bounds,ce)}else i&&(de(ce,e),ce.x-=e.width/2*(i-1),ce.y-=e.height/2*(i-1),ce.width*=i,ce.height*=i),t.copyWorld(s.canvas,o,i?ce:e)}const{toOffsetOutBounds:ge}=l,_e={};var pe=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:a,__layout:r}=t,{innerShadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,g=e.getSameCanvas(),_=h.length-1;ge(l,_e),h.forEach(((h,p)=>{g.save(),g.setWorldShadow(_e.offsetX+h.x*u,_e.offsetY+h.y*f,h.blur*u),o=h.spread?1-2*h.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,fe(g,_e,o,i),g.restore(),d?(g.copyWorld(g,l,a,"copy"),g.copyWorld(d,a,a,"source-out"),n=a):(g.copyWorld(i.canvas,c,l,"source-out"),n=l),g.fillWorld(n,h.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(g,n,a,h.blendMode):e.copyWorldToInner(g,n,r.renderBounds,h.blendMode),_&&p<_&&g.clear()})),g.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:a,__layout:r}=t,{shadow:h}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,g=e.getSameCanvas(),_=h.length-1;le(l,ue),h.forEach(((h,p)=>{g.setWorldShadow(ue.offsetX+h.x*u,ue.offsetY+h.y*f,h.blur*u,h.color),o=h.spread?1+2*h.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,fe(g,ue,o,i),n=l,h.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,l,a,"copy"),n=a),d?g.copyWorld(d,a,a,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(g,n,a,h.blendMode):e.copyWorldToInner(g,n,r.renderBounds,h.blendMode),_&&p<_&&g.clear()})),g.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ye=we+"_#~&*+\\=|≮≯≈≠=…",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 xe=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),be=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Be=ve(we),Re=ve(ye),Ee=ve("- —/~|┆·");var Se;!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"}(Se||(Se={}));const{Letter:Le,Single:ke,Before:Te,After:Me,Symbol:Ce,Break:Ae}=Se;function Oe(t){return xe[t]?Le:Ee[t]?Ae:be[t]?Te:Be[t]?Me:Re[t]?Ce:me.test(t)?ke:Le}const Ie={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function We(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:Pe}=Ie,{Letter:De,Single:ze,Before:Fe,After:Ve,Symbol:Ne,Break:Ue}=Se;let Ye,He,je,Ge,Xe,qe,Qe,Ke,Ze,$e,Je,ti,ei,ii,si,ni,oi=[];function ai(t,e){Ze&&!Ke&&(Ke=Ze),Ye.data.push({char:t,width:e}),je+=e}function ri(){Ge+=je,Ye.width=je,He.words.push(Ye),Ye={data:[]},je=0}function hi(){ii&&(si.paraNumber++,He.paraStart=!0,ii=!1),Ze&&(He.startCharSize=Ke,He.endCharSize=Ze,Ke=0),He.width=Ge,ni.width&&Pe(He),oi.push(He),He={words:[]},Ge=0}const di={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{textDecoration:a,__font:r,padding:h}=e;if(h){const[t,e,a,r]=M.fourNumber(h);n&&(i=r,n-=e+r),o&&(s=t,o-=t+a)}const d={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:p.canvas.font=r};return function(t,e,i){si=t,oi=t.rows,ni=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:a}=p,{width:r,height:h}=ni;if(r||h||s||"none"!==o){const t="none"!==i.textWrap,h="break"===i.textWrap;ii=!0,Je=null,Ke=Qe=Ze=je=Ge=0,Ye={data:[]},He={words:[]};for(let i=0,d=e.length;i<d;i++)qe=e[i],"\n"===qe?(je&&ri(),He.paraEnd=!0,hi(),ii=!0):($e=Oe(qe),$e===De&&"none"!==o&&(qe=We(qe,o,!je)),Qe=a.measureText(qe).width,s&&(s<0&&(Ze=Qe),Qe+=s),ti=$e===ze&&(Je===ze||Je===De)||Je===ze&&$e!==Ve,ei=!($e!==Fe&&$e!==ze||Je!==Ne&&Je!==Ve),Xe=ii&&n?r-n:r,t&&r&&Ge+je+Qe>Xe&&(h?(je&&ri(),hi()):(ei||(ei=$e===De&&Je==Ve),ti||ei||$e===Ue||$e===Fe||$e===ze||je+Qe>Xe?(je&&ri(),hi()):hi()))," "===qe&&!0!==ii&&Ge+je===0||($e===Ue?(" "===qe&&je&&ri(),ai(qe,Qe),ri()):ti||ei?(je&&ri(),ai(qe,Qe)):ai(qe,Qe)),Je=$e);je&&ri(),Ge&&hi(),oi.length>0&&(oi[oi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{si.paraNumber++,oi.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(d,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=g,h){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&o>0&&(m+=l),c.y=m,m+=n,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=_,s.height=y}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(d,e,n),d.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,o;"ellipsis"===n&&(n="...");const a=p.canvas.measureText(n).width,r=e.x+e.width-a;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<r));s--){if(o<r&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=a,e.data.push({char:n,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(d,e),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,e),d}},li={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},ci={export(t,e,i){return function(t){ui||(ui=new C);return new Promise((e=>{ui.add((()=>xt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let t,a,r,{canvas:h}=o,{unreal:d}=h;switch(d&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(a=!0);break;case"number":t=i;break;case"boolean":a=i}r=e.includes(".")?yield h.saveAs(e,t):a?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:r}),n(),d&&h.recycle()})))):(s({data:!1}),n())}))))}};let ui;Object.assign(I,he),Object.assign(W,pe),Object.assign(P,di),Object.assign(A,li),Object.assign(D,ci);try{dt(0,wx)}catch(t){}nt.prototype.__createContext=function(){if(this.viewSelect){const t=z.origin.createCanvas(1,1),e=this.view.getContext("2d");this.testView=this.view,this.testContext=e,this.view=t}this.context=this.view.getContext("2d"),this.__bindContext()},nt.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,z.origin.noRepeat);this.testContext.clearRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t,this.testContext.fillRect(0,0,this.view.width,this.view.height),this.testContext.fillStyle=t=null}},nt.prototype.updateViewSize=function(){const{width:t,height:e,pixelRatio:i,view:s,testView:n}=this;s.width=t*i,s.height=e*i,n&&(n.width=s.width,n.height=s.height)};export{at as Interaction,$ as Layouter,nt as LeaferCanvas,tt as Renderer,st as Selector,F as Watcher,dt as useCanvas};
|