@leafer-ui/miniapp 1.0.0-rc.21 → 1.0.0-rc.22
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 +88 -62
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +215 -123
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +10 -10
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MatrixHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MatrixHelper, AroundHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { InteractionHelper, InteractionBase, HitCanvasManager, Platform as Platform$1 } from '@leafer-ui/core';
|
|
@@ -797,32 +797,38 @@ class Picker {
|
|
|
797
797
|
const target = options.target || this.target;
|
|
798
798
|
this.exclude = options.exclude || null;
|
|
799
799
|
this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
|
|
800
|
-
this.findList = options.findList
|
|
800
|
+
this.findList = new LeafList(options.findList);
|
|
801
801
|
if (!options.findList)
|
|
802
|
-
this.
|
|
803
|
-
const list = this.findList;
|
|
804
|
-
const leaf = this.getBestMatchLeaf();
|
|
802
|
+
this.hitBranch(target);
|
|
803
|
+
const { list } = this.findList;
|
|
804
|
+
const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
|
|
805
805
|
const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
|
|
806
806
|
this.clear();
|
|
807
807
|
return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
|
|
808
808
|
}
|
|
809
|
-
getBestMatchLeaf() {
|
|
810
|
-
|
|
811
|
-
if (targets.length > 1) {
|
|
809
|
+
getBestMatchLeaf(list, bottomList, ignoreHittable) {
|
|
810
|
+
if (list.length) {
|
|
812
811
|
let find;
|
|
813
|
-
this.findList =
|
|
812
|
+
this.findList = new LeafList();
|
|
814
813
|
const { x, y } = this.point;
|
|
815
814
|
const point = { x, y, radiusX: 0, radiusY: 0 };
|
|
816
|
-
for (let i = 0, len =
|
|
817
|
-
find =
|
|
818
|
-
if (LeafHelper.worldHittable(find)) {
|
|
815
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
816
|
+
find = list[i];
|
|
817
|
+
if (ignoreHittable || LeafHelper.worldHittable(find)) {
|
|
819
818
|
this.hitChild(find, point);
|
|
820
819
|
if (this.findList.length)
|
|
821
|
-
return this.findList[0];
|
|
820
|
+
return this.findList.list[0];
|
|
822
821
|
}
|
|
823
822
|
}
|
|
824
823
|
}
|
|
825
|
-
|
|
824
|
+
if (bottomList) {
|
|
825
|
+
for (let i = 0, len = bottomList.length; i < len; i++) {
|
|
826
|
+
this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
|
|
827
|
+
if (this.findList.length)
|
|
828
|
+
return this.findList.list[0];
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return list[0];
|
|
826
832
|
}
|
|
827
833
|
getPath(leaf) {
|
|
828
834
|
const path = new LeafList();
|
|
@@ -864,6 +870,9 @@ class Picker {
|
|
|
864
870
|
}
|
|
865
871
|
return throughPath;
|
|
866
872
|
}
|
|
873
|
+
hitBranch(branch) {
|
|
874
|
+
this.eachFind(branch.children, branch.__onlyHitMask);
|
|
875
|
+
}
|
|
867
876
|
eachFind(children, hitMask) {
|
|
868
877
|
let child, hit;
|
|
869
878
|
const { point } = this, len = children.length;
|
|
@@ -885,11 +894,11 @@ class Picker {
|
|
|
885
894
|
}
|
|
886
895
|
}
|
|
887
896
|
}
|
|
888
|
-
hitChild(child, point) {
|
|
897
|
+
hitChild(child, point, proxy) {
|
|
889
898
|
if (this.exclude && this.exclude.has(child))
|
|
890
899
|
return;
|
|
891
900
|
if (child.__hitWorld(point))
|
|
892
|
-
this.findList.
|
|
901
|
+
this.findList.add(proxy || child);
|
|
893
902
|
}
|
|
894
903
|
clear() {
|
|
895
904
|
this.point = null;
|
|
@@ -1443,79 +1452,75 @@ const PaintModule = {
|
|
|
1443
1452
|
|
|
1444
1453
|
let origin = {};
|
|
1445
1454
|
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1446
|
-
function fillOrFitMode(data,
|
|
1455
|
+
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1447
1456
|
const transform = get$4();
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
const sh = box.height / (swap ? width : height);
|
|
1451
|
-
const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
1452
|
-
const x = box.x + (box.width - width * scale) / 2;
|
|
1453
|
-
const y = box.y + (box.height - height * scale) / 2;
|
|
1454
|
-
translate$1(transform, x, y);
|
|
1455
|
-
scaleHelper(transform, scale);
|
|
1457
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1458
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
1456
1459
|
if (rotation)
|
|
1457
1460
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1458
|
-
data.scaleX = data.scaleY = scale;
|
|
1459
1461
|
data.transform = transform;
|
|
1460
1462
|
}
|
|
1461
1463
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1462
1464
|
const transform = get$4();
|
|
1463
|
-
translate$1(transform, box.x, box.y);
|
|
1464
|
-
if (
|
|
1465
|
-
translate$1(transform, x, y);
|
|
1466
|
-
if (scaleX) {
|
|
1465
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
1466
|
+
if (scaleX)
|
|
1467
1467
|
scaleHelper(transform, scaleX, scaleY);
|
|
1468
|
-
data.scaleX = transform.a;
|
|
1469
|
-
data.scaleY = transform.d;
|
|
1470
|
-
}
|
|
1471
1468
|
if (rotation)
|
|
1472
1469
|
rotate(transform, rotation);
|
|
1473
1470
|
data.transform = transform;
|
|
1474
1471
|
}
|
|
1475
|
-
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
|
|
1472
|
+
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
|
|
1476
1473
|
const transform = get$4();
|
|
1477
1474
|
if (rotation) {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1475
|
+
if (around === 'center') {
|
|
1476
|
+
rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
1477
|
+
}
|
|
1478
|
+
else {
|
|
1479
|
+
rotate(transform, rotation);
|
|
1480
|
+
switch (rotation) {
|
|
1481
|
+
case 90:
|
|
1482
|
+
translate$1(transform, height, 0);
|
|
1483
|
+
break;
|
|
1484
|
+
case 180:
|
|
1485
|
+
translate$1(transform, width, height);
|
|
1486
|
+
break;
|
|
1487
|
+
case 270:
|
|
1488
|
+
translate$1(transform, 0, width);
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1489
1491
|
}
|
|
1490
1492
|
}
|
|
1491
|
-
origin.x = box.x;
|
|
1492
|
-
origin.y = box.y;
|
|
1493
|
-
if (x || y)
|
|
1494
|
-
origin.x += x, origin.y += y;
|
|
1493
|
+
origin.x = box.x + x;
|
|
1494
|
+
origin.y = box.y + y;
|
|
1495
1495
|
translate$1(transform, origin.x, origin.y);
|
|
1496
|
-
if (scaleX)
|
|
1496
|
+
if (scaleX)
|
|
1497
1497
|
scaleOfOuter$2(transform, origin, scaleX, scaleY);
|
|
1498
|
-
data.scaleX = scaleX;
|
|
1499
|
-
data.scaleY = scaleY;
|
|
1500
|
-
}
|
|
1501
1498
|
data.transform = transform;
|
|
1502
1499
|
}
|
|
1503
1500
|
|
|
1504
1501
|
const { get: get$3, translate } = MatrixHelper;
|
|
1505
1502
|
const tempBox = new Bounds();
|
|
1503
|
+
const tempPoint = {};
|
|
1506
1504
|
function createData(leafPaint, image, paint, box) {
|
|
1507
1505
|
let { width, height } = image;
|
|
1508
1506
|
if (paint.padding)
|
|
1509
1507
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1510
|
-
const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
1508
|
+
const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
|
|
1511
1509
|
const sameBox = box.width === width && box.height === height;
|
|
1512
1510
|
if (blendMode)
|
|
1513
1511
|
leafPaint.blendMode = blendMode;
|
|
1514
1512
|
const data = leafPaint.data = { mode };
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
if (
|
|
1513
|
+
const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
|
|
1514
|
+
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
1515
|
+
let x = 0, y = 0, scaleX, scaleY;
|
|
1516
|
+
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
1517
|
+
if (!sameBox || rotation) {
|
|
1518
|
+
const sw = box.width / swapWidth, sh = box.height / swapHeight;
|
|
1519
|
+
scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
|
|
1520
|
+
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
else if (size) {
|
|
1519
1524
|
scaleX = (typeof size === 'number' ? size : size.width) / width;
|
|
1520
1525
|
scaleY = (typeof size === 'number' ? size : size.height) / height;
|
|
1521
1526
|
}
|
|
@@ -1523,26 +1528,36 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1523
1528
|
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
1524
1529
|
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
1525
1530
|
}
|
|
1531
|
+
if (around) {
|
|
1532
|
+
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
1533
|
+
if (scaleX)
|
|
1534
|
+
imageBounds.width *= scaleX, imageBounds.height *= scaleY;
|
|
1535
|
+
AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
|
|
1536
|
+
x += tempPoint.x, y += tempPoint.y;
|
|
1537
|
+
}
|
|
1538
|
+
if (offset)
|
|
1539
|
+
x += offset.x, y += offset.y;
|
|
1526
1540
|
switch (mode) {
|
|
1527
1541
|
case 'strench':
|
|
1528
1542
|
if (!sameBox)
|
|
1529
1543
|
width = box.width, height = box.height;
|
|
1530
1544
|
break;
|
|
1545
|
+
case 'normal':
|
|
1531
1546
|
case 'clip':
|
|
1532
|
-
if (
|
|
1547
|
+
if (x || y || scaleX || rotation)
|
|
1533
1548
|
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1534
1549
|
break;
|
|
1535
1550
|
case 'repeat':
|
|
1536
1551
|
if (!sameBox || scaleX || rotation)
|
|
1537
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
|
|
1552
|
+
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
|
|
1538
1553
|
if (!repeat)
|
|
1539
1554
|
data.repeat = 'repeat';
|
|
1540
1555
|
break;
|
|
1541
1556
|
case 'fit':
|
|
1542
1557
|
case 'cover':
|
|
1543
1558
|
default:
|
|
1544
|
-
if (
|
|
1545
|
-
fillOrFitMode(data,
|
|
1559
|
+
if (scaleX)
|
|
1560
|
+
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1546
1561
|
}
|
|
1547
1562
|
if (!data.transform) {
|
|
1548
1563
|
if (box.x || box.y) {
|
|
@@ -1550,6 +1565,10 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1550
1565
|
translate(data.transform, box.x, box.y);
|
|
1551
1566
|
}
|
|
1552
1567
|
}
|
|
1568
|
+
if (scaleX && mode !== 'strench') {
|
|
1569
|
+
data.scaleX = scaleX;
|
|
1570
|
+
data.scaleY = scaleY;
|
|
1571
|
+
}
|
|
1553
1572
|
data.width = width;
|
|
1554
1573
|
data.height = height;
|
|
1555
1574
|
if (opacity)
|
|
@@ -2637,6 +2656,13 @@ const ExportModule = {
|
|
|
2637
2656
|
resolve();
|
|
2638
2657
|
this.running = false;
|
|
2639
2658
|
};
|
|
2659
|
+
if (filename === 'json') {
|
|
2660
|
+
return over({ data: leaf.toJSON() });
|
|
2661
|
+
}
|
|
2662
|
+
else if (FileHelper.fileType(filename) === 'json') {
|
|
2663
|
+
Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
|
|
2664
|
+
return over({ data: true });
|
|
2665
|
+
}
|
|
2640
2666
|
const { leafer } = leaf;
|
|
2641
2667
|
if (leafer) {
|
|
2642
2668
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as h,LeafList as d,RenderEvent as l,ChildEvent as c,WatchEvent as u,PropertyEvent as f,LeafHelper as g,BranchHelper as p,Bounds as _,LeafBoundsHelper as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,Answer as k,MatrixHelper as E,ImageEvent as L,PointHelper as S,Direction4 as T,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as W,InteractionBase as O,HitCanvasManager as I,Platform as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as F,ColorConvert as D,PaintGradient as z,Export as Y,Group as V,TextConvert as N,Paint as U,Effect as X}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.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:s,pixelRatio:n}=this.config,o={width:e||t.width,height:s||t.height,pixelRatio:n};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};s.copyAttrs(t,this,n),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:G,fileType:j}=h;function q(t,i){e.origin||(e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(G(j(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a&&e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=t})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.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((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new H(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new d,this.target=t,e&&(this.config=s.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(u.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:Z,updateAllWorldOpacity:$}=g,{pushAllChildBranch:J,pushAllParent:tt}=p;const{worldBounds:et}=w,it={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:nt,updateAllChange:ot}=g,at=y.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new v(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&J(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&$(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,o=this.getBlocks(new d(e));e.emitEvent(new v(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(s,o,this.times)),e.emitEvent(new v(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?p.updateBounds(t):g.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(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_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=y.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,ht.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ht.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new _(s);i.save(),n&&!y.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(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.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),y.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),y.showHitView&&this.renderHitView(s),y.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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||ht.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:lt}=R;class ct{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=i.findList||[],i.findList||this.eachFind(o.children,o.__onlyHitMask);const a=this.findList,r=this.getBestMatchLeaf(),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target: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],g.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}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.__.mask||(s=!!i.__.hitRadius||lt(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()}}const{Yes:ut,NoAndSkip:ft,YesAndSkip:gt}=k;class pt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ct(t,this),this.__listenEvents()}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)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(v.CHECK_UPDATE),this.picker.getByPoint(t,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&&g.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,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===ut||o===gt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<ft&&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_(c.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new pt(t,e)}),e.layout=rt.fullLayout;const _t={convertTouch(t,e){const i=_t.getTouch(t),s=W.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 wt extends O{__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=_t.getTouch(t);this.pointerDown(_t.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=_t.getTouch(t);this.pointerMove(_t.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=_t.getTouch(t);this.pointerUp(_t.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(W.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}}function yt(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 mt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?bt(t,!0,e,i):xt(e,i);break;case"inside":vt("inside",t,n,e,i);break;case"outside":vt("outside",t,n,e,i)}}function vt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?bt(e,!0,s,r):xt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function xt(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 bt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&F.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?xt(i,s):s.stroke(),s.restoreBlendMode()):e?xt(i,s):s.stroke())}const{getSpread:Bt,getOuterOf:Rt,getByMove:kt,getIntersectData:Et}=R;let Lt;function St(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:D.string(a,r)};case"image":return F.image(i,t,e,s,!Lt||!Lt[e.url]);case"linear":return z.linearGradient(e,s);case"radial":return z.radialGradient(e,s);case"angular":return z.conicGradient(e,s);default:return e.r?{type:"solid",style:D.string(e)}:void 0}}const Tt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Lt=F.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=St(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},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&&F.checkImage(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?yt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yt(e,i):n?i.fill(n):i.fill())},fillText:yt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)mt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),bt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Et(s?Bt(e.bounds,s*d,s*l):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=f),r=Rt(n,a),o=kt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Mt={};const{get:At,rotateOfOuter:Ct,translate:Wt,scaleOfOuter:Ot,scale:It,rotate:Pt}=E;function Ft(t,e,i,s,n,o){const a=At(),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;Wt(a,c,u),It(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}function Dt(t,e,i,s,n,o,a){const r=At();Wt(r,e.x,e.y),(i||s)&&Wt(r,i,s),n&&(It(r,n,o),t.scaleX=r.a,t.scaleY=r.d),a&&Pt(r,a),t.transform=r}function zt(t,e,i,s,n,o,a,r,h){const d=At();if(h)switch(Pt(d,h),h){case 90:Wt(d,s,0);break;case 180:Wt(d,i,s);break;case 270:Wt(d,0,i)}Mt.x=e.x,Mt.y=e.y,(n||o)&&(Mt.x+=n,Mt.y+=o),Wt(d,Mt.x,Mt.y),a&&(Ot(d,Mt,a,r),t.scaleX=a,t.scaleY=r),t.transform=d}const{get:Yt,translate:Vt}=E,Nt=new _;function Ut(t,e,i,s){let{width:n,height:o}=e;i.padding&&(s=Nt.set(s).shrink(i.padding));const{opacity:a,mode:r,offset:h,scale:d,size:l,rotation:c,blendMode:u,repeat:f}=i,g=s.width===n&&s.height===o;u&&(t.blendMode=u);const p=t.data={mode:r};let _,w,y,m;switch(h&&(_=h.x,w=h.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/o):d&&(y="number"==typeof d?d:d.x,m="number"==typeof d?d:d.y),r){case"strench":g||(n=s.width,o=s.height);break;case"clip":(h||y||c)&&Dt(p,s,_,w,y,m,c);break;case"repeat":(!g||y||c)&&zt(p,s,n,o,_,w,y,m,c),f||(p.repeat="repeat");break;default:g&&!c||Ft(p,r,s,n,o,c)}p.transform||(s.x||s.y)&&(p.transform=Yt(),Vt(p.transform,s.x,s.y)),p.width=n,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Xt,Ht=new _;const{isSame:Gt}=R;function jt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ut(n,s,i,o),!0}function qt(t,e){Zt(t,L.LOAD,e)}function Qt(t,e){Zt(t,L.LOADED,e)}function Kt(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,L.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Jt,scale:te,copy:ee}=E,{ceil:ie,abs:se}=Math;function ne(t,i,s){let{scaleX:n,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o;if(i.patternId===a||t.destroyed)return!1;{n=se(n),o=se(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=Jt(),ee(d,p),te(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=Jt(),p&&ee(d,p)),te(d,1/n,1/o));const m=t.getCanvas(ie(l)||1,ie(c)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function oe(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{abs:ae}=Math;const re={image:function(t,e,i,s,n){let o,a;const r=b.get(i);return Xt&&i===Xt.paint&&Gt(s,Xt.boxBounds)?o=Xt.leafPaint:(o={type:i.type,image:r},Xt=r.use>1?{leafPaint:o,paint:i,boxBounds:Ht.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(jt(t,e,i,r,o,s),n&&(qt(t,a),Qt(t,a))):r.error?n&&Kt(t,a,r.error):($t(t,!0),n&&qt(t,a),o.loadId=r.load((()=>{$t(t,!1),t.destroyed||(jt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,a)),o.loadId=null}),(e=>{$t(t,!1),Kt(t,a,e),o.loadId=null}))),o},createData:Ut,fillOrFitMode:Ft,clipMode:Dt,repeatMode:zt,createPattern:ne,checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==o+"-"+a){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=ae(o)*i.pixelRatio,s*=ae(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||Y.running?ne(t,s,i.pixelRatio):s.patternTask||(s.patternTask=b.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ne(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];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,b.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}},he={x:.5,y:0},de={x:.5,y:1};function le(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,D.string(s.color,i))}const{set:ce,getAngle:ue,getDistance:fe}=S,{get:ge,rotateOfOuter:pe,scaleOfOuter:_e}=E,we={x:.5,y:.5},ye={x:.5,y:1},me={},ve={};const{set:xe,getAngle:be,getDistance:Be}=S,{get:Re,rotateOfOuter:ke,scaleOfOuter:Ee}=E,Le={x:.5,y:.5},Se={x:.5,y:1},Te={},Me={};const Ae={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;s||(s=he),n||(n=de);const h=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);le(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=we),n||(n=ye);const{x:d,y:l,width:c,height:u}=i;let f;ce(me,d+s.x*c,l+s.y*u),ce(ve,d+n.x*c,l+n.y*u),(c!==u||h)&&(f=ge(),_e(f,me,c/u*(h||1),1),pe(f,me,ue(me,ve)+90));const g=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,fe(me,ve));le(g,t.stops,a);const p={type:o,style:g,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=Le),n||(n=Se);const{x:d,y:l,width:c,height:u}=i;xe(Te,d+s.x*c,l+s.y*u),xe(Me,d+n.x*c,l+n.y*u);const f=Re(),g=be(Te,Me);e.conicGradientRotate90?(Ee(f,Te,c/u*(h||1),1),ke(f,Te,g+90)):(Ee(f,Te,1,c/u*(h||1)),ke(f,Te,g));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,Te.x,Te.y):e.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Be(Te,Me));le(p,t.stops,a);const _={type:o,style:p,transform:f};return r&&(_.blendMode=r),_}},{copy:Ce,toOffsetOutBounds:We}=R,Oe={},Ie={};function Pe(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ce(Oe,t.bounds),Oe.x+=i.x-a.x,Oe.y+=i.y-a.y,s){const{matrix:t}=n;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ce(Oe,i),Oe.x-=i.width/2*(s-1),Oe.y-=i.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,a,s?Oe:i)}const{toOffsetOutBounds:Fe}=R,De={};const ze={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(d,Ie),r.forEach(((r,p)=>{f.setWorldShadow(Ie.offsetX+r.x*c,Ie.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Pe(f,Ie,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Fe(d,De),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*c,De.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Pe(f,De,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ye}=w;function Ve(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,o);break;case"path":i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}V.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(Ve(this,a,t,n,s,o),s=n=null),"path"===i.__.maskType?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ne(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=Ne(t)),n||(n=Ne(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ye(i,e)||i.__render(n||t,e);Ve(this,a,t,n,s,o)};const Xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=Xe+"_#~&*+\\=|≮≯≈≠=…",Ge=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 je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qe=je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=je(Xe),Ze=je(He),$e=je("- —/~|┆·");var Je;!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"}(Je||(Je={}));const{Letter:ti,Single:ei,Before:ii,After:si,Symbol:ni,Break:oi}=Je;function ai(t){return qe[t]?ti:$e[t]?oi:Qe[t]?ii:Ke[t]?si:Ze[t]?ni:Ge.test(t)?ei:ti}const ri={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 hi(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:di}=ri,{Letter:li,Single:ci,Before:ui,After:fi,Symbol:gi,Break:pi}=Je;let _i,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li,Si,Ti,Mi,Ai,Ci=[];function Wi(t,e){Ri&&!Bi&&(Bi=Ri),_i.data.push({char:t,width:e}),yi+=e}function Oi(){mi+=yi,_i.width=yi,wi.words.push(_i),_i={data:[]},yi=0}function Ii(){Ti&&(Mi.paraNumber++,wi.paraStart=!0,Ti=!1),Ri&&(wi.startCharSize=Bi,wi.endCharSize=Ri,Bi=0),wi.width=mi,Ai.width&&di(wi),Ci.push(wi),wi={words:[]},mi=0}const Pi=0,Fi=1,Di=2;const{top:zi,right:Yi,bottom:Vi,left:Ni}=T;function Ui(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Xi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[Ni],o-=d[Yi]+d[Ni]),a&&(n=d[zi],a-=d[zi]+d[Vi]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Mi=t,Ci=t.rows,Ai=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Ai;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ti=!0,Ei=null,Bi=bi=Ri=yi=mi=0,_i={data:[]},wi={words:[]};for(let s=0,d=i.length;s<d;s++)xi=i[s],"\n"===xi?(yi&&Oi(),wi.paraEnd=!0,Ii(),Ti=!0):(ki=ai(xi),ki===li&&"none"!==a&&(xi=hi(xi,a,!yi)),bi=r.measureText(xi).width,n&&(n<0&&(Ri=bi),bi+=n),Li=ki===ci&&(Ei===ci||Ei===li)||Ei===ci&&ki!==fi,Si=!(ki!==ui&&ki!==ci||Ei!==gi&&Ei!==fi),vi=Ti&&o?h-o:h,t&&h&&mi+yi+bi>vi&&(e?(yi&&Oi(),Ii()):(Si||(Si=ki===li&&Ei==fi),Li||Si||ki===pi||ki===ui||ki===ci||yi+bi>vi?(yi&&Oi(),Ii()):Ii()))," "===xi&&!0!==Ti&&mi+yi===0||(ki===pi?(" "===xi&&yi&&Oi(),Wi(xi,bi),Oi()):Li||Si?(yi&&Oi(),Wi(xi,bi)):Wi(xi,bi)),Ei=ki);yi&&Oi(),mi&&Ii(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,Ci.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Ui(e,"x",t[Ni]);break;case"right":Ui(e,"x",-t[Yi])}if(!n)switch(i.verticalAlign){case"top":Ui(e,"y",t[zi]);break;case"bottom":Ui(e,"y",-t[Vi])}}(d,l,i,o,a),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:p,width:_,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":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=g,h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-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&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(l,i),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?Pi:d>.01?Fi:Di,t.isOverflow&&!r&&(t.textMode=!0),c===Di?(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=>{c===Fi?(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,i,o),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:o}=i;if(s.splice(n),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,h=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<h));s--){if(a<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"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,i),l}};const Hi={string:function(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+")"}},{setPoint:Gi,addPoint:ji,toBounds:qi}=M;const Qi={export(t,e,i){return this.running=!0,function(t){Ki||(Ki=new A);return new Promise((e=>{Ki.add((()=>oe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const o=t=>{s(t),n(),this.running=!1},{leafer:r}=t;r?r.waitViewCompleted((()=>oe(this,void 0,void 0,(function*(){i=h.getExportOptions(i);let s,n,d=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=i,y=i.scale||1,m=i.pixelRatio||1,v=i.screenshot||t.isApp,x=u&&v&&void 0===i.fill?t.fill:i.fill,b=h.isOpaqueImage(e)||x,B=new C;if(v)s=!0===v?u?r.canvas.bounds:t.worldRenderBounds:v;else{let e=i.relative||(u?"inner":"local");switch(d=c.scaleX,l=c.scaleY,e){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),d/=t.scaleX,l/=t.scaleY;break;case"world":d=1,l=1;break;case"page":e=t.leafer;default:B.set(c).divide(t.getTransform(e));const i=e.worldTransform;d/=d/i.scaleX,l/=l/i.scaleY}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:L}=new _(s).scale(y);let S=a.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const T={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/d*y,1/l*y)};if(g&&(t=r,T.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,T),t.fill=e}else t.__render(S,T);if(S.restore(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?ji(a,n,o):Gi(a={},n,o)),r++;const h=new _;return qi(a,h),h.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=a.canvas(s),S.copyWorld(t,n,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const M="canvas"===e?S:yield S.export(e,i);o({data:M,width:S.pixelWidth,height:S.pixelHeight,renderBounds:s,trimBounds:n})})))):o({data:!1})}))))}};let Ki;const Zi=t.prototype,$i=y.get("@leafer-ui/export");Zi.export=function(t,e){const{quality:i,blob:s}=h.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Zi.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{$i.error(t),s(null)}))}))},Zi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Zi.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{$i.error(t),s(!1)}))}))},Object.assign(N,Xi),Object.assign(D,Hi),Object.assign(U,Tt),Object.assign(F,re),Object.assign(z,Ae),Object.assign(X,ze),Object.assign(Y,Qi),Object.assign(a,{interaction:(t,e,i,s)=>new wt(t,e,i,s),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new I});try{q(0,wx)}catch(t){}H.prototype.__createContext=function(){if(this.viewSelect){const t=P.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()},H.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,P.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}},H.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{wt as Interaction,rt as Layouter,H as LeaferCanvas,dt as Renderer,pt as Selector,Q as Watcher,q as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as h,LeafList as d,RenderEvent as l,ChildEvent as c,WatchEvent as u,PropertyEvent as f,LeafHelper as g,BranchHelper as p,Bounds as _,LeafBoundsHelper as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,Answer as k,MatrixHelper as S,AroundHelper as L,ImageEvent as E,PointHelper as T,Direction4 as M,TwoPointBoundsHelper as C,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as I,HitCanvasManager as P,Platform as F}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as z,PaintGradient as N,Export as V,Group as Y,TextConvert as U,Paint as H,Effect as X}from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.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:s,pixelRatio:n}=this.config,o={width:e||t.width,height:s||t.height,pixelRatio:n};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};s.copyAttrs(t,this,n),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:G,fileType:q}=h;function Q(t,i){e.origin||(e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(G(q(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a&&e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s})})),n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=t})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.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((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new j(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new d,this.target=t,e&&(this.config=s.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(u.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:Z,updateAllWorldOpacity:$}=g,{pushAllChildBranch:tt,pushAllParent:et}=p;const{worldBounds:it}=w,st={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(st):this.afterBounds.setListWithFn(t,it),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:at}=g,rt=y.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new v(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&$(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,o=this.getBlocks(new d(e));e.emitEvent(new v(i,o,this.times)),ht.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(s,o,this.times)),e.emitEvent(new v(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?p.updateBounds(t):g.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=y.get("Renderer");class lt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new _(s);i.save(),n&&!y.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(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.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),y.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),y.showHitView&&this.renderHitView(s),y.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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ct}=R;class ut{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new d(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||g.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}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.__.mask||(s=!!i.__.hitRadius||ct(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,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ft,NoAndSkip:gt,YesAndSkip:pt}=k;class _t{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ut(t,this),this.__listenEvents()}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)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(v.CHECK_UPDATE),this.picker.getByPoint(t,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&&g.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,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===ft||o===pt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<gt&&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_(c.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ht.fullLayout;const wt={convertTouch(t,e){const i=wt.getTouch(t),s=O.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 yt extends I{__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=wt.getTouch(t);this.pointerDown(wt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=wt.getTouch(t);this.pointerMove(wt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=wt.getTouch(t);this.pointerUp(wt.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(O.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}}function mt(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 vt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,n,e,i);break;case"outside":xt("outside",t,n,e,i)}}function xt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Bt(e,!0,s,r):bt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",mt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function bt(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 Bt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&D.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?bt(i,s):s.stroke(),s.restoreBlendMode()):e?bt(i,s):s.stroke())}const{getSpread:Rt,getOuterOf:kt,getByMove:St,getIntersectData:Lt}=R;let Et;function Tt(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:z.string(a,r)};case"image":return D.image(i,t,e,s,!Et||!Et[e.url]);case"linear":return N.linearGradient(e,s);case"radial":return N.radialGradient(e,s);case"angular":return N.conicGradient(e,s);default:return e.r?{type:"solid",style:z.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Et=D.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Tt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?mt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},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&&D.checkImage(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?mt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?mt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?mt(e,i):n?i.fill(n):i.fill())},fillText:mt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)vt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),Bt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:vt,drawTextStroke:bt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Lt(s?Rt(e.bounds,s*d,s*l):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=f),r=kt(n,a),o=St(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Ct={};const{get:At,rotateOfOuter:Wt,translate:Ot,scaleOfOuter:It,scale:Pt,rotate:Ft}=S;function Dt(t,e,i,s,n,o,a){const r=At();Ot(r,e.x+i,e.y+s),Pt(r,n,o),a&&Wt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function zt(t,e,i,s,n,o,a){const r=At();Ot(r,e.x+i,e.y+s),n&&Pt(r,n,o),a&&Ft(r,a),t.transform=r}function Nt(t,e,i,s,n,o,a,r,h,d){const l=At();if(h)if("center"===d)Wt(l,{x:i/2,y:s/2},h);else switch(Ft(l,h),h){case 90:Ot(l,s,0);break;case 180:Ot(l,i,s);break;case 270:Ot(l,0,i)}Ct.x=e.x+n,Ct.y=e.y+o,Ot(l,Ct.x,Ct.y),a&&It(l,Ct,a,r),t.transform=l}const{get:Vt,translate:Yt}=S,Ut=new _,Ht={};function Xt(t,e,i,s){let{width:n,height:o}=e;i.padding&&(s=Ut.set(s).shrink(i.padding));const{opacity:a,mode:r,around:h,offset:d,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,p=s.width===n&&s.height===o;f&&(t.blendMode=f);const _=t.data={mode:r},w="center"!==h&&(u||0)%180==90,y=w?o:n,m=w?n:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/n,x=("number"==typeof c?c:c.height)/o):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!p||u){const t=s.width/y,e=s.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(s.width-n*v)/2,B+=(s.height-o*x)/2}if(h){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),L.toPoint(h,s,Ht,!0,t),b+=Ht.x,B+=Ht.y}switch(d&&(b+=d.x,B+=d.y),r){case"strench":p||(n=s.width,o=s.height);break;case"normal":case"clip":(b||B||v||u)&&zt(_,s,b,B,v,x,u);break;case"repeat":(!p||v||u)&&Nt(_,s,n,o,b,B,v,x,u,h),g||(_.repeat="repeat");break;default:v&&Dt(_,s,b,B,v,x,u)}_.transform||(s.x||s.y)&&(_.transform=Vt(),Yt(_.transform,s.x,s.y)),v&&"strench"!==r&&(_.scaleX=v,_.scaleY=x),_.width=n,_.height=o,a&&(_.opacity=a),g&&(_.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let jt,Gt=new _;const{isSame:qt}=R;function Qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Xt(n,s,i,o),!0}function Jt(t,e){$t(t,E.LOAD,e)}function Kt(t,e){$t(t,E.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,E.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function te(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ee,scale:ie,copy:se}=S,{ceil:ne,abs:oe}=Math;function ae(t,i,s){let{scaleX:n,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o;if(i.patternId===a||t.destroyed)return!1;{n=oe(n),o=oe(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=ee(),se(d,p),ie(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=ee(),p&&se(d,p)),ie(d,1/n,1/o));const m=t.getCanvas(ne(l)||1,ne(c)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function re(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{abs:he}=Math;const de={image:function(t,e,i,s,n){let o,a;const r=b.get(i);return jt&&i===jt.paint&&qt(s,jt.boxBounds)?o=jt.leafPaint:(o={type:i.type,image:r},jt=r.use>1?{leafPaint:o,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Qt(t,e,i,r,o,s),n&&(Jt(t,a),Kt(t,a))):r.error?n&&Zt(t,a,r.error):(te(t,!0),n&&Jt(t,a),o.loadId=r.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{te(t,!1),Zt(t,a,e),o.loadId=null}))),o},createData:Xt,fillOrFitMode:Dt,clipMode:zt,repeatMode:Nt,createPattern:ae,checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==o+"-"+a){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=he(o)*i.pixelRatio,s*=he(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||V.running?ae(t,s,i.pixelRatio):s.patternTask||(s.patternTask=b.patternTasker.add((()=>re(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ae(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];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,b.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}},le={x:.5,y:0},ce={x:.5,y:1};function ue(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,z.string(s.color,i))}const{set:fe,getAngle:ge,getDistance:pe}=T,{get:_e,rotateOfOuter:we,scaleOfOuter:ye}=S,me={x:.5,y:.5},ve={x:.5,y:1},xe={},be={};const{set:Be,getAngle:Re,getDistance:ke}=T,{get:Se,rotateOfOuter:Le,scaleOfOuter:Ee}=S,Te={x:.5,y:.5},Me={x:.5,y:1},Ce={},Ae={};const We={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;s||(s=le),n||(n=ce);const h=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);ue(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=me),n||(n=ve);const{x:d,y:l,width:c,height:u}=i;let f;fe(xe,d+s.x*c,l+s.y*u),fe(be,d+n.x*c,l+n.y*u),(c!==u||h)&&(f=_e(),ye(f,xe,c/u*(h||1),1),we(f,xe,ge(xe,be)+90));const g=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,pe(xe,be));ue(g,t.stops,a);const p={type:o,style:g,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;s||(s=Te),n||(n=Me);const{x:d,y:l,width:c,height:u}=i;Be(Ce,d+s.x*c,l+s.y*u),Be(Ae,d+n.x*c,l+n.y*u);const f=Se(),g=Re(Ce,Ae);e.conicGradientRotate90?(Ee(f,Ce,c/u*(h||1),1),Le(f,Ce,g+90)):(Ee(f,Ce,1,c/u*(h||1)),Le(f,Ce,g));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,Ce.x,Ce.y):e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,ke(Ce,Ae));ue(p,t.stops,a);const _={type:o,style:p,transform:f};return r&&(_.blendMode=r),_}},{copy:Oe,toOffsetOutBounds:Ie}=R,Pe={},Fe={};function De(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Oe(Pe,t.bounds),Pe.x+=i.x-a.x,Pe.y+=i.y-a.y,s){const{matrix:t}=n;Pe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Pe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Pe.width*=s,Pe.height*=s}t.copyWorld(n.canvas,t.bounds,Pe)}else s&&(Oe(Pe,i),Pe.x-=i.width/2*(s-1),Pe.y-=i.height/2*(s-1),Pe.width*=s,Pe.height*=s),t.copyWorld(n.canvas,a,s?Pe:i)}const{toOffsetOutBounds:ze}=R,Ne={};const Ve={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(d,Fe),r.forEach(((r,p)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,De(f,Fe,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;ze(d,Ne),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ne.offsetX+r.x*c,Ne.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,De(f,Ne,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ye}=w;function Ue(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Xe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Xe(t,i,s,o);break;case"path":i.restore()}}function He(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(Ue(this,a,t,n,s,o),s=n=null),"path"===i.__.maskType?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=He(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=He(t)),n||(n=He(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ye(i,e)||i.__render(n||t,e);Ue(this,a,t,n,s,o)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=je+"_#~&*+\\=|≮≯≈≠=…",qe=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 Qe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Je=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ze=Qe(je),$e=Qe(Ge),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ni,After:oi,Symbol:ai,Break:ri}=ei;function hi(t){return Je[t]?ii:ti[t]?ri:Ke[t]?ni:Ze[t]?oi:$e[t]?ai:qe.test(t)?si:ii}const di={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 li(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:ci}=di,{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:wi}=ei;let yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ti,Mi,Ci,Ai,Wi,Oi=[];function Ii(t,e){Si&&!ki&&(ki=Si),yi.data.push({char:t,width:e}),vi+=e}function Pi(){xi+=vi,yi.width=vi,mi.words.push(yi),yi={data:[]},vi=0}function Fi(){Ci&&(Ai.paraNumber++,mi.paraStart=!0,Ci=!1),Si&&(mi.startCharSize=ki,mi.endCharSize=Si,ki=0),mi.width=xi,Wi.width&&ci(mi),Oi.push(mi),mi={words:[]},xi=0}const Di=0,zi=1,Ni=2;const{top:Vi,right:Yi,bottom:Ui,left:Hi}=M;function Xi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[Hi],o-=d[Yi]+d[Hi]),a&&(n=d[Vi],a-=d[Vi]+d[Ui]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Ai=t,Oi=t.rows,Wi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Wi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ci=!0,Ei=null,ki=Ri=Si=vi=xi=0,yi={data:[]},mi={words:[]};for(let s=0,d=i.length;s<d;s++)Bi=i[s],"\n"===Bi?(vi&&Pi(),mi.paraEnd=!0,Fi(),Ci=!0):(Li=hi(Bi),Li===ui&&"none"!==a&&(Bi=li(Bi,a,!vi)),Ri=r.measureText(Bi).width,n&&(n<0&&(Si=Ri),Ri+=n),Ti=Li===fi&&(Ei===fi||Ei===ui)||Ei===fi&&Li!==pi,Mi=!(Li!==gi&&Li!==fi||Ei!==_i&&Ei!==pi),bi=Ci&&o?h-o:h,t&&h&&xi+vi+Ri>bi&&(e?(vi&&Pi(),Fi()):(Mi||(Mi=Li===ui&&Ei==pi),Ti||Mi||Li===wi||Li===gi||Li===fi||vi+Ri>bi?(vi&&Pi(),Fi()):Fi()))," "===Bi&&!0!==Ci&&xi+vi===0||(Li===wi?(" "===Bi&&vi&&Pi(),Ii(Bi,Ri),Pi()):Ti||Mi?(vi&&Pi(),Ii(Bi,Ri)):Ii(Bi,Ri)),Ei=Li);vi&&Pi(),xi&&Fi(),Oi.length>0&&(Oi[Oi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ai.paraNumber++,Oi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Xi(e,"x",t[Hi]);break;case"right":Xi(e,"x",-t[Yi])}if(!n)switch(i.verticalAlign){case"top":Xi(e,"y",t[Vi]);break;case"bottom":Xi(e,"y",-t[Ui])}}(d,l,i,o,a),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:p,width:_,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":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,d=i.length;o<d;o++){switch(c=i[o],c.x=g,h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-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&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(l,i),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?Di:d>.01?zi:Ni,t.isOverflow&&!r&&(t.textMode=!0),c===Ni?(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=>{c===zi?(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,i,o),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:o}=i;if(s.splice(n),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,h=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<h));s--){if(a<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"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,i),l}};const Gi={string:function(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+")"}},{setPoint:qi,addPoint:Qi,toBounds:Ji}=C;const Ki={export(t,i,s){return this.running=!0,function(t){Zi||(Zi=new A);return new Promise((e=>{Zi.add((()=>re(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1};if("json"===i)return r({data:t.toJSON()});if("json"===h.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),r({data:!0});const{leafer:d}=t;d?d.waitViewCompleted((()=>re(this,void 0,void 0,(function*(){s=h.getExportOptions(s);let e,n,o=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=s,y=s.scale||1,m=s.pixelRatio||1,v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=h.isOpaqueImage(i)||x,B=new W;if(v)e=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(o=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:S,height:L}=new _(e).scale(y);let E=a.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:m});const T={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/o*y,1/l*y)};if(g&&(t=d,T.bounds=E.bounds),E.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(E,T),t.fill=e}else t.__render(E,T);if(E.restore(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Qi(a,n,o):qi(a={},n,o)),r++;const h=new _;return Ji(a,h),h.scale(1/t.pixelRatio).ceil()}(E);const t=E,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};E=a.canvas(s),E.copyWorld(t,n,s)}b&&E.fillWorld(E.bounds,x||"#FFFFFF","destination-over"),w&&w(E);const M="canvas"===i?E:yield E.export(i,s);r({data:M,width:E.pixelWidth,height:E.pixelHeight,renderBounds:e,trimBounds:n})})))):r({data:!1})}))))}};let Zi;const $i=t.prototype,ts=y.get("@leafer-ui/export");$i.export=function(t,e){const{quality:i,blob:s}=h.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},$i.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{ts.error(t),s(null)}))}))},$i.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},$i.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{ts.error(t),s(!1)}))}))},Object.assign(U,ji),Object.assign(z,Gi),Object.assign(H,Mt),Object.assign(D,de),Object.assign(N,We),Object.assign(X,Ve),Object.assign(V,Ki),Object.assign(a,{interaction:(t,e,i,s)=>new yt(t,e,i,s),hitCanvas:(t,e)=>new j(t,e),hitCanvasManager:()=>new P});try{Q(0,wx)}catch(t){}j.prototype.__createContext=function(){if(this.viewSelect){const t=F.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()},j.prototype.updateRender=function(){if(this.testView){let t=this.context.createPattern(this.view,F.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}},j.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{yt as Interaction,ht as Layouter,j as LeaferCanvas,lt as Renderer,_t as Selector,J as Watcher,Q as useCanvas};
|