@leafer-ui/worker 1.0.0-rc.24 → 1.0.0-rc.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.esm.js +74 -49
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +163 -74
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +163 -74
- package/dist/worker.module.min.js +1 -1
- package/package.json +9 -9
package/dist/worker.esm.js
CHANGED
|
@@ -781,8 +781,12 @@ class Picker {
|
|
|
781
781
|
hitChild(child, point, proxy) {
|
|
782
782
|
if (this.exclude && this.exclude.has(child))
|
|
783
783
|
return;
|
|
784
|
-
if (child.__hitWorld(point))
|
|
784
|
+
if (child.__hitWorld(point)) {
|
|
785
|
+
const { parent } = child;
|
|
786
|
+
if (parent && parent.__hasMask && !child.__.mask && !parent.children.some(item => item.__.mask && item.__hitWorld(point)))
|
|
787
|
+
return;
|
|
785
788
|
this.findList.add(proxy || child);
|
|
789
|
+
}
|
|
786
790
|
}
|
|
787
791
|
clear() {
|
|
788
792
|
this.point = null;
|
|
@@ -1225,7 +1229,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1225
1229
|
case 'angular':
|
|
1226
1230
|
return PaintGradient.conicGradient(paint, boxBounds);
|
|
1227
1231
|
default:
|
|
1228
|
-
return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
1232
|
+
return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
1229
1233
|
}
|
|
1230
1234
|
}
|
|
1231
1235
|
|
|
@@ -1242,17 +1246,17 @@ const PaintModule = {
|
|
|
1242
1246
|
};
|
|
1243
1247
|
|
|
1244
1248
|
let origin = {};
|
|
1245
|
-
const { get: get$
|
|
1249
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1246
1250
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1247
|
-
const transform = get$
|
|
1251
|
+
const transform = get$3();
|
|
1248
1252
|
translate$1(transform, box.x + x, box.y + y);
|
|
1249
1253
|
scaleHelper(transform, scaleX, scaleY);
|
|
1250
1254
|
if (rotation)
|
|
1251
|
-
rotateOfOuter$
|
|
1255
|
+
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1252
1256
|
data.transform = transform;
|
|
1253
1257
|
}
|
|
1254
1258
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
1255
|
-
const transform = get$
|
|
1259
|
+
const transform = get$3();
|
|
1256
1260
|
translate$1(transform, box.x + x, box.y + y);
|
|
1257
1261
|
if (scaleX)
|
|
1258
1262
|
scaleHelper(transform, scaleX, scaleY);
|
|
@@ -1261,10 +1265,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1261
1265
|
data.transform = transform;
|
|
1262
1266
|
}
|
|
1263
1267
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
1264
|
-
const transform = get$
|
|
1268
|
+
const transform = get$3();
|
|
1265
1269
|
if (rotation) {
|
|
1266
1270
|
if (align === 'center') {
|
|
1267
|
-
rotateOfOuter$
|
|
1271
|
+
rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
1268
1272
|
}
|
|
1269
1273
|
else {
|
|
1270
1274
|
rotate(transform, rotation);
|
|
@@ -1285,22 +1289,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1285
1289
|
origin.y = box.y + y;
|
|
1286
1290
|
translate$1(transform, origin.x, origin.y);
|
|
1287
1291
|
if (scaleX)
|
|
1288
|
-
scaleOfOuter$
|
|
1292
|
+
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
1289
1293
|
data.transform = transform;
|
|
1290
1294
|
}
|
|
1291
1295
|
|
|
1292
|
-
const { get: get$
|
|
1296
|
+
const { get: get$2, translate } = MatrixHelper;
|
|
1293
1297
|
const tempBox = new Bounds();
|
|
1294
1298
|
const tempPoint = {};
|
|
1295
1299
|
function createData(leafPaint, image, paint, box) {
|
|
1300
|
+
const { blendMode } = paint;
|
|
1301
|
+
if (blendMode)
|
|
1302
|
+
leafPaint.blendMode = blendMode;
|
|
1303
|
+
leafPaint.data = getPatternData(paint, box, image);
|
|
1304
|
+
}
|
|
1305
|
+
function getPatternData(paint, box, image) {
|
|
1296
1306
|
let { width, height } = image;
|
|
1297
1307
|
if (paint.padding)
|
|
1298
1308
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1299
|
-
const { opacity, mode, align, offset, scale, size, rotation,
|
|
1309
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1300
1310
|
const sameBox = box.width === width && box.height === height;
|
|
1301
|
-
|
|
1302
|
-
leafPaint.blendMode = blendMode;
|
|
1303
|
-
const data = leafPaint.data = { mode };
|
|
1311
|
+
const data = { mode };
|
|
1304
1312
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1305
1313
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
1306
1314
|
let x = 0, y = 0, scaleX, scaleY;
|
|
@@ -1352,7 +1360,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1352
1360
|
}
|
|
1353
1361
|
if (!data.transform) {
|
|
1354
1362
|
if (box.x || box.y) {
|
|
1355
|
-
data.transform = get$
|
|
1363
|
+
data.transform = get$2();
|
|
1356
1364
|
translate(data.transform, box.x, box.y);
|
|
1357
1365
|
}
|
|
1358
1366
|
}
|
|
@@ -1366,6 +1374,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1366
1374
|
data.opacity = opacity;
|
|
1367
1375
|
if (repeat)
|
|
1368
1376
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1377
|
+
return data;
|
|
1369
1378
|
}
|
|
1370
1379
|
|
|
1371
1380
|
let cache, box = new Bounds();
|
|
@@ -1455,7 +1464,7 @@ function ignoreRender(ui, value) {
|
|
|
1455
1464
|
leafer.renderer.ignore = value;
|
|
1456
1465
|
}
|
|
1457
1466
|
|
|
1458
|
-
const { get: get$
|
|
1467
|
+
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1459
1468
|
const { ceil, abs: abs$1 } = Math;
|
|
1460
1469
|
function createPattern(ui, paint, pixelRatio) {
|
|
1461
1470
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
@@ -1466,7 +1475,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1466
1475
|
const { image, data } = paint;
|
|
1467
1476
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
1468
1477
|
if (sx) {
|
|
1469
|
-
imageMatrix = get$
|
|
1478
|
+
imageMatrix = get$1();
|
|
1470
1479
|
copy$1(imageMatrix, transform);
|
|
1471
1480
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
1472
1481
|
scaleX *= sx;
|
|
@@ -1501,7 +1510,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1501
1510
|
}
|
|
1502
1511
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1503
1512
|
if (!imageMatrix) {
|
|
1504
|
-
imageMatrix = get$
|
|
1513
|
+
imageMatrix = get$1();
|
|
1505
1514
|
if (transform)
|
|
1506
1515
|
copy$1(imageMatrix, transform);
|
|
1507
1516
|
}
|
|
@@ -1634,13 +1643,14 @@ function recycleImage(attrName, data) {
|
|
|
1634
1643
|
|
|
1635
1644
|
const PaintImageModule = {
|
|
1636
1645
|
image,
|
|
1646
|
+
checkImage,
|
|
1647
|
+
createPattern,
|
|
1648
|
+
recycleImage,
|
|
1637
1649
|
createData,
|
|
1650
|
+
getPatternData,
|
|
1638
1651
|
fillOrFitMode,
|
|
1639
1652
|
clipMode,
|
|
1640
|
-
repeatMode
|
|
1641
|
-
createPattern,
|
|
1642
|
-
checkImage,
|
|
1643
|
-
recycleImage
|
|
1653
|
+
repeatMode
|
|
1644
1654
|
};
|
|
1645
1655
|
|
|
1646
1656
|
const { toPoint: toPoint$2 } = AroundHelper;
|
|
@@ -1670,8 +1680,8 @@ function applyStops(gradient, stops, opacity) {
|
|
|
1670
1680
|
}
|
|
1671
1681
|
}
|
|
1672
1682
|
|
|
1673
|
-
const { getAngle
|
|
1674
|
-
const { get
|
|
1683
|
+
const { getAngle, getDistance: getDistance$1 } = PointHelper;
|
|
1684
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
1675
1685
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
1676
1686
|
const realFrom$1 = {};
|
|
1677
1687
|
const realTo$1 = {};
|
|
@@ -1679,23 +1689,35 @@ function radialGradient(paint, box) {
|
|
|
1679
1689
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1680
1690
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1681
1691
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1682
|
-
const { width, height } = box;
|
|
1683
|
-
let transform;
|
|
1684
|
-
if (width !== height || stretch) {
|
|
1685
|
-
transform = get$1();
|
|
1686
|
-
scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
|
|
1687
|
-
rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
|
|
1688
|
-
}
|
|
1689
1692
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
1690
1693
|
applyStops(style, paint.stops, opacity);
|
|
1691
|
-
const data = { type, style
|
|
1694
|
+
const data = { type, style };
|
|
1695
|
+
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1696
|
+
if (transform)
|
|
1697
|
+
data.transform = transform;
|
|
1692
1698
|
if (blendMode)
|
|
1693
1699
|
data.blendMode = blendMode;
|
|
1694
1700
|
return data;
|
|
1695
1701
|
}
|
|
1702
|
+
function getTransform(box, from, to, stretch, rotate90) {
|
|
1703
|
+
let transform;
|
|
1704
|
+
const { width, height } = box;
|
|
1705
|
+
if (width !== height || stretch) {
|
|
1706
|
+
const angle = getAngle(from, to);
|
|
1707
|
+
transform = get();
|
|
1708
|
+
if (rotate90) {
|
|
1709
|
+
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
1710
|
+
rotateOfOuter(transform, from, angle + 90);
|
|
1711
|
+
}
|
|
1712
|
+
else {
|
|
1713
|
+
scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
|
|
1714
|
+
rotateOfOuter(transform, from, angle);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return transform;
|
|
1718
|
+
}
|
|
1696
1719
|
|
|
1697
|
-
const {
|
|
1698
|
-
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
1720
|
+
const { getDistance } = PointHelper;
|
|
1699
1721
|
const { toPoint } = AroundHelper;
|
|
1700
1722
|
const realFrom = {};
|
|
1701
1723
|
const realTo = {};
|
|
@@ -1703,20 +1725,12 @@ function conicGradient(paint, box) {
|
|
|
1703
1725
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1704
1726
|
toPoint(from || 'center', box, realFrom);
|
|
1705
1727
|
toPoint(to || 'bottom', box, realTo);
|
|
1706
|
-
const { width, height } = box;
|
|
1707
|
-
const transform = get();
|
|
1708
|
-
const angle = getAngle(realFrom, realTo);
|
|
1709
|
-
if (Platform.conicGradientRotate90) {
|
|
1710
|
-
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
|
|
1711
|
-
rotateOfOuter(transform, realFrom, angle + 90);
|
|
1712
|
-
}
|
|
1713
|
-
else {
|
|
1714
|
-
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
|
|
1715
|
-
rotateOfOuter(transform, realFrom, angle);
|
|
1716
|
-
}
|
|
1717
1728
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
1718
1729
|
applyStops(style, paint.stops, opacity);
|
|
1719
|
-
const data = { type, style
|
|
1730
|
+
const data = { type, style };
|
|
1731
|
+
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
1732
|
+
if (transform)
|
|
1733
|
+
data.transform = transform;
|
|
1720
1734
|
if (blendMode)
|
|
1721
1735
|
data.blendMode = blendMode;
|
|
1722
1736
|
return data;
|
|
@@ -1725,7 +1739,8 @@ function conicGradient(paint, box) {
|
|
|
1725
1739
|
const PaintGradientModule = {
|
|
1726
1740
|
linearGradient,
|
|
1727
1741
|
radialGradient,
|
|
1728
|
-
conicGradient
|
|
1742
|
+
conicGradient,
|
|
1743
|
+
getTransform
|
|
1729
1744
|
};
|
|
1730
1745
|
|
|
1731
1746
|
const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
|
|
@@ -2451,11 +2466,21 @@ const ExportModule = {
|
|
|
2451
2466
|
resolve();
|
|
2452
2467
|
this.running = false;
|
|
2453
2468
|
};
|
|
2469
|
+
const { toURL } = Platform;
|
|
2470
|
+
const { download } = Platform.origin;
|
|
2471
|
+
const fileType = FileHelper.fileType(filename);
|
|
2454
2472
|
if (filename === 'json') {
|
|
2455
2473
|
return over({ data: leaf.toJSON() });
|
|
2456
2474
|
}
|
|
2457
|
-
else if (
|
|
2458
|
-
|
|
2475
|
+
else if (fileType === 'json') {
|
|
2476
|
+
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
2477
|
+
return over({ data: true });
|
|
2478
|
+
}
|
|
2479
|
+
if (filename === 'svg') {
|
|
2480
|
+
return over({ data: leaf.toSVG() });
|
|
2481
|
+
}
|
|
2482
|
+
else if (fileType === 'svg') {
|
|
2483
|
+
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
2459
2484
|
return over({ data: true });
|
|
2460
2485
|
}
|
|
2461
2486
|
const { leafer } = leaf;
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as S,PointHelper as M,Direction4 as A,TwoPointBoundsHelper as O,TaskProcessor as W,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as T,HitCanvasManager as I}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as F,PaintGradient as D,Export as N,Group as Y,TextConvert as U,Paint as G,Effect as H}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:j}=a;function V(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:j(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:j(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new X(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.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(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:Q,updateBounds:J,updateAllWorldOpacity:Z}=u,{pushAllChildBranch:K,pushAllParent:$}=f;const{worldBounds:tt}=_,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),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:st}=u,at=p.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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(y.START),this.layoutOnce(),t.emitEvent(new y(y.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(l.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=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&K(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||J(n[t])}J(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Z(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),ot.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),st(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=p.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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new g,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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 rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.showBoundsView&&this.renderBoundsView(n),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 g;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(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.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:ht}=B;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,a),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 o;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,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ht(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}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:ct,NoAndSkip:ut,YesAndSkip:ft}=R,gt={},_t={},pt={};class wt{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,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new lt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":gt.id=t.substring(1),t=gt;break;case".":_t.className=t.substring(1),t=_t;break;default:pt.tag=t,t=pt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?r.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}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&&u.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,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===ct||a===ft){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ut&&this.eachFind(s.children,e,i,n)}}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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.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={})}}function yt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function mt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?bt(t,!0,e,i):xt(e,i);break;case"inside":vt("inside",t,s,e,i);break;case"outside":vt("outside",t,s,e,i)}}function vt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?bt(e,!0,n,r):xt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function xt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function bt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?xt(i,n):n.stroke(),n.restoreBlendMode()):e?xt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new wt(t,e)}),e.layout=ot.fullLayout;const{getSpread:Bt,getOuterOf:Rt,getByMove:kt,getIntersectData:Et}=B;let Lt;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:F.string(o,r)};case"image":return P.image(i,t,e,n,!Lt||!Lt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return e.r?{type:"solid",style:F.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Lt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=St(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},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 n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?yt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?yt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?yt(e,i):s?i.fill(s):i.fill())},fillText:yt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)mt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)mt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),bt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Et(n?Bt(e.bounds,h===l?n*h:[n*l,n*h]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=Rt(s,o),a=kt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let At={};const{get:Ot,rotateOfOuter:Wt,translate:Ct,scaleOfOuter:Tt,scale:It,rotate:Pt}=k;function Ft(t,e,i,n,s,a,o){const r=Ot();Ct(r,e.x+i,e.y+n),It(r,s,a),o&&Wt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Dt(t,e,i,n,s,a,o){const r=Ot();Ct(r,e.x+i,e.y+n),s&&It(r,s,a),o&&Pt(r,o),t.transform=r}function Nt(t,e,i,n,s,a,o,r,d,h){const l=Ot();if(d)if("center"===h)Wt(l,{x:i/2,y:n/2},d);else switch(Pt(l,d),d){case 90:Ct(l,n,0);break;case 180:Ct(l,i,n);break;case 270:Ct(l,0,i)}At.x=e.x+s,At.y=e.y+a,Ct(l,At.x,At.y),o&&Tt(l,At,o,r),t.transform=l}const{get:Yt,translate:Ut}=k,Gt=new g,Ht={};function Xt(t,e,i,n){let{width:s,height:a}=e;i.padding&&(n=Gt.set(n).shrink(i.padding));const{opacity:o,mode:r,align:d,offset:h,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,_=n.width===s&&n.height===a;f&&(t.blendMode=f);const p=t.data={mode:r},w="center"!==d&&(u||0)%180==90,y=w?a:s,m=w?s:a;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/s,x=("number"==typeof c?c:c.height)/a):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!_||u){const t=n.width/y,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,B+=(n.height-a*x)/2}if(d){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),E.toPoint(d,t,n,Ht,!0),b+=Ht.x,B+=Ht.y}switch(h&&(b+=h.x,B+=h.y),r){case"strench":_||(s=n.width,a=n.height);break;case"normal":case"clip":(b||B||v||u)&&Dt(p,n,b,B,v,x,u);break;case"repeat":(!_||v||u)&&Nt(p,n,s,a,b,B,v,x,u,d),g||(p.repeat="repeat");break;default:v&&Ft(p,n,b,B,v,x,u)}p.transform||(n.x||n.y)&&(p.transform=Yt(),Ut(p.transform,n.x,n.y)),v&&"strench"!==r&&(p.scaleX=v,p.scaleY=x),p.width=s,p.height=a,o&&(p.opacity=o),g&&(p.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let jt,Vt=new g;const{isSame:qt}=B;function zt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Xt(s,n,i,a),!0}function Qt(t,e){Kt(t,L.LOAD,e)}function Jt(t,e){Kt(t,L.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),Kt(t,L.ERROR,e)}function Kt(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:te,scale:ee,copy:ie}=k,{ceil:ne,abs:se}=Math;function ae(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=se(s),a=se(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=te(),ie(h,_),ee(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&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&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(h||(h=te(),_&&ie(h,_)),ee(h,1/s,1/a));const m=t.getCanvas(ne(l)||1,ne(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}function oe(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:re}=Math;const de={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return jt&&i===jt.paint&&qt(n,jt.boxBounds)?a=jt.leafPaint:(a={type:i.type,image:r},jt=r.use>1?{leafPaint:a,paint:i,boxBounds:Vt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(zt(t,e,i,r,a,n),s&&(Qt(t,o),Jt(t,o))):r.error?s&&Zt(t,o,r.error):($t(t,!0),s&&Qt(t,o),a.loadId=r.load((()=>{$t(t,!1),t.destroyed||(zt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Jt(t,o)),a.loadId=null}),(e=>{$t(t,!1),Zt(t,o,e),a.loadId=null}))),a},createData:Xt,fillOrFitMode:Ft,clipMode:Dt,repeatMode:Nt,createPattern:ae,checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=re(a)*i.pixelRatio,n*=re(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||N.running?ae(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ae(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},{toPoint:he}=S,le={},ce={};function ue(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),F.string(n,i)):t.addColorStop(n.offset,F.string(n.color,i))}const{getAngle:fe,getDistance:ge}=M,{get:_e,rotateOfOuter:pe,scaleOfOuter:we}=k,{toPoint:ye}=S,me={},ve={};const{getAngle:xe,getDistance:be}=M,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Ee}=S,Le={},Se={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;he(n||"top",i,le),he(s||"bottom",i,ce);const d=e.canvas.createLinearGradient(le.x,le.y,ce.x,ce.y);ue(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;ye(n||"center",i,me),ye(s||"bottom",i,ve);const{width:h,height:l}=i;let c;(h!==l||d)&&(c=_e(),we(c,me,h/l*(d||1),1),pe(c,me,fe(me,ve)+90));const u=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,ge(me,ve));ue(u,t.stops,o);const f={type:a,style:u,transform:c};return r&&(f.blendMode=r),f},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Ee(n||"center",i,Le),Ee(s||"bottom",i,Se);const{width:h,height:l}=i,c=Be(),u=xe(Le,Se);e.conicGradientRotate90?(ke(c,Le,h/l*(d||1),1),Re(c,Le,u+90)):(ke(c,Le,1,h/l*(d||1)),Re(c,Le,u));const f=e.conicGradientSupport?e.canvas.createConicGradient(0,Le.x,Le.y):e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Se));ue(f,t.stops,o);const g={type:a,style:f,transform:c};return r&&(g.blendMode=r),g}},{copy:Ae,toOffsetOutBounds:Oe}=B,We={},Ce={};function Te(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ae(We,t.bounds),We.x+=i.x-o.x,We.y+=i.y-o.y,n){const{matrix:t}=s;We.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),We.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),We.width*=n,We.height*=n}t.copyWorld(s.canvas,t.bounds,We)}else n&&(Ae(We,i),We.x-=i.width/2*(n-1),We.y-=i.height/2*(n-1),We.width*=n,We.height*=n),t.copyWorld(s.canvas,o,n?We:i)}const{toOffsetOutBounds:Ie}=B,Pe={};const Fe={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Oe(h,Ce),r.forEach(((r,_)=>{f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Ce,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(h,Pe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Pe.offsetX+r.x*c,Pe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Pe,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:De}=_;function Ne(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ue(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ue(t,i,n,a);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Ne(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ye(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ye(t)),s||(s=Ye(t)),i.__render(n,e)),"clipping"!==i.__.mask)||De(i,e)||i.__render(s||t,e);Ne(this,o,t,s,n,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=Ge+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ve=je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ze=je(Ge),Qe=je(He),Je=je("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Ke,Single:$e,Before:ti,After:ei,Symbol:ii,Break:ni}=Ze;function si(t){return Ve[t]?Ke:Je[t]?ni:qe[t]?ti:ze[t]?ei:Qe[t]?ii:Xe.test(t)?$e:Ke}const ai={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function oi(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:ri}=ai,{Letter:di,Single:hi,Before:li,After:ci,Symbol:ui,Break:fi}=Ze;let gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li,Si,Mi,Ai=[];function Oi(t,e){bi&&!xi&&(xi=bi),gi.data.push({char:t,width:e}),pi+=e}function Wi(){wi+=pi,gi.width=pi,_i.words.push(gi),gi={data:[]},pi=0}function Ci(){Li&&(Si.paraNumber++,_i.paraStart=!0,Li=!1),bi&&(_i.startCharSize=xi,_i.endCharSize=bi,xi=0),_i.width=wi,Mi.width&&ri(_i),Ai.push(_i),_i={words:[]},wi=0}const Ti=0,Ii=1,Pi=2;const{top:Fi,right:Di,bottom:Ni,left:Yi}=A;function Ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Gi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Yi],a-=h[Di]+h[Yi]),o&&(s=h[Fi],o-=h[Fi]+h[Ni]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Si=t,Ai=t.rows,Mi=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Mi;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Li=!0,Ri=null,xi=vi=bi=pi=wi=0,gi={data:[]},_i={words:[]};for(let n=0,h=i.length;n<h;n++)mi=i[n],"\n"===mi?(pi&&Wi(),_i.paraEnd=!0,Ci(),Li=!0):(Bi=si(mi),Bi===di&&"none"!==o&&(mi=oi(mi,o,!pi)),vi=r.measureText(mi).width,s&&(s<0&&(bi=vi),vi+=s),ki=Bi===hi&&(Ri===hi||Ri===di)||Ri===hi&&Bi!==ci,Ei=!(Bi!==li&&Bi!==hi||Ri!==ui&&Ri!==ci),yi=Li&&a?d-a:d,t&&d&&wi+pi+vi>yi&&(e?(pi&&Wi(),Ci()):(Ei||(Ei=Bi===di&&Ri==ci),ki||Ei||Bi===fi||Bi===li||Bi===hi||pi+vi>yi?(pi&&Wi(),Ci()):Ci()))," "===mi&&!0!==Li&&wi+pi===0||(Bi===fi?(" "===mi&&pi&&Wi(),Oi(mi,vi),Wi()):ki||Ei?(pi&&Wi(),Oi(mi,vi)):Oi(mi,vi)),Ri=Bi);pi&&Wi(),wi&&Ci(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,Ai.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ui(e,"x",t[Yi]);break;case"right":Ui(e,"x",-t[Di])}if(!s)switch(i.verticalAlign){case"top":Ui(e,"y",t[Fi]);break;case"bottom":Ui(e,"y",-t[Ni])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,h=i.length;a<h;a++){if(c=i[a],c.x=g,c.width<p||c.width>p&&!r)switch(d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ti:h>.01?Ii:Pi,t.isOverflow&&!r&&(t.textMode=!0),c===Pi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ii?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),a&&"show"!==a){let t,o;"hide"===a?a="":"ellipsis"===a&&(a="...");const r=a?e.canvas.measureText(a).width:0,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),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 n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Xi,addPoint:ji,toBounds:Vi}=O;const qi={export(t,i,s){return this.running=!0,function(t){zi||(zi=new W);return new Promise((e=>{zi.add((()=>oe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1};if("json"===i)return d({data:t.toJSON()});if("json"===a.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),d({data:!0});const{leafer:h}=t;h?h.waitViewCompleted((()=>oe(this,void 0,void 0,(function*(){s=a.getExportOptions(s);let e,o,r=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(i)||x,B=new C;if(v)e=!0===v?u?h.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(r=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:E,height:L}=new g(e).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/l*y)};if(_&&(t=h,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?ji(o,s,a):Xi(o={},s,a)),r++;const d=new g;return Vi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===i?S:yield S.export(i,s);d({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:e,trimBounds:o})})))):d({data:!1})}))))}};let zi;const Qi=t.prototype,Ji=p.get("@leafer-ui/export");Qi.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Qi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Ji.error(t),n(null)}))}))},Qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Qi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Ji.error(t),n(!1)}))}))},Object.assign(U,Gi),Object.assign(F,Hi),Object.assign(G,Mt),Object.assign(P,de),Object.assign(D,Me),Object.assign(H,Fe),Object.assign(N,qi),Object.assign(n,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new I}),V();export{ot as Layouter,X as LeaferCanvas,dt as Renderer,wt as Selector,z as Watcher,V as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as k,MatrixHelper as R,AlignHelper as E,ImageEvent as L,AroundHelper as S,PointHelper as M,Direction4 as A,TwoPointBoundsHelper as W,TaskProcessor as O,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as T,HitCanvasManager as I}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as F,Export as N,Group as Y,TextConvert as G,Paint as U,Effect as H}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:V}=a;function j(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:V(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:V(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new X(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.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(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:Q,updateBounds:J,updateAllWorldOpacity:Z}=u,{pushAllChildBranch:K,pushAllParent:$}=f;const{worldBounds:tt}=_,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),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:st}=u,at=p.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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(y.START),this.layoutOnce(),t.emitEvent(new y(y.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(l.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=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&K(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||J(n[t])}J(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Z(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),ot.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),st(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=p.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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new g,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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 rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.showBoundsView&&this.renderBoundsView(n),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 g;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(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.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:ht}=B;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,a),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 o;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,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ht(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ct,NoAndSkip:ut,YesAndSkip:ft}=k,gt={},_t={},pt={};class wt{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,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new lt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":gt.id=t.substring(1),t=gt;break;case".":_t.className=t.substring(1),t=_t;break;default:pt.tag=t,t=pt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?r.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}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&&u.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,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===ct||a===ft){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ut&&this.eachFind(s.children,e,i,n)}}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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.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={})}}function yt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function mt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?bt(t,!0,e,i):xt(e,i);break;case"inside":vt("inside",t,s,e,i);break;case"outside":vt("outside",t,s,e,i)}}function vt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?bt(e,!0,n,r):xt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function xt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function bt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?xt(i,n):n.stroke(),n.restoreBlendMode()):e?xt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new wt(t,e)}),e.layout=ot.fullLayout;const{getSpread:Bt,getOuterOf:kt,getByMove:Rt,getIntersectData:Et}=B;let Lt;function St(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:D.string(o,r)};case"image":return P.image(i,t,e,n,!Lt||!Lt[e.url]);case"linear":return F.linearGradient(e,n);case"radial":return F.radialGradient(e,n);case"angular":return F.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Mt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Lt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=St(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},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 n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?yt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?yt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?yt(e,i):s?i.fill(s):i.fill())},fillText:yt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)mt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)mt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),bt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Et(n?Bt(e.bounds,h===l?n*h:[n*l,n*h]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=kt(s,o),a=Rt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let At={};const{get:Wt,rotateOfOuter:Ot,translate:Ct,scaleOfOuter:Tt,scale:It,rotate:Pt}=R;function Dt(t,e,i,n,s,a,o){const r=Wt();Ct(r,e.x+i,e.y+n),It(r,s,a),o&&Ot(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ft(t,e,i,n,s,a,o){const r=Wt();Ct(r,e.x+i,e.y+n),s&&It(r,s,a),o&&Pt(r,o),t.transform=r}function Nt(t,e,i,n,s,a,o,r,d,h){const l=Wt();if(d)if("center"===h)Ot(l,{x:i/2,y:n/2},d);else switch(Pt(l,d),d){case 90:Ct(l,n,0);break;case 180:Ct(l,i,n);break;case 270:Ct(l,0,i)}At.x=e.x+s,At.y=e.y+a,Ct(l,At.x,At.y),o&&Tt(l,At,o,r),t.transform=l}const{get:Yt,translate:Gt}=R,Ut=new g,Ht={};function Xt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=Vt(i,n,e)}function Vt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ut.set(e).shrink(t.padding));const{opacity:a,mode:o,align:r,offset:d,scale:h,size:l,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/s):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Ht,!0),v+=Ht.x,x+=Ht.y}switch(d&&(v+=d.x,x+=d.y),o){case"strench":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ft(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Nt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Dt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=Yt(),Gt(g.transform,e.x,e.y)),y&&"strench"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let jt,qt=new g;const{isSame:zt}=B;function Qt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Xt(s,n,i,a),!0}function Jt(t,e){$t(t,L.LOAD,e)}function Zt(t,e){$t(t,L.LOADED,e)}function Kt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,L.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function te(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ee,scale:ie,copy:ne}=R,{ceil:se,abs:ae}=Math;function oe(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=ae(s),a=ae(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=ee(),ne(h,_),ie(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&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&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(h||(h=ee(),_&&ne(h,_)),ie(h,1/s,1/a));const m=t.getCanvas(se(l)||1,se(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}function re(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const he={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return jt&&i===jt.paint&&zt(n,jt.boxBounds)?a=jt.leafPaint:(a={type:i.type,image:r},jt=r.use>1?{leafPaint:a,paint:i,boxBounds:qt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Qt(t,e,i,r,a,n),s&&(Jt(t,o),Zt(t,o))):r.error?s&&Kt(t,o,r.error):(te(t,!0),s&&Jt(t,o),a.loadId=r.load((()=>{te(t,!1),t.destroyed||(Qt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Zt(t,o)),a.loadId=null}),(e=>{te(t,!1),Kt(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=de(a)*i.pixelRatio,n*=de(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||N.running?oe(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>re(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&oe(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:oe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:Xt,getPatternData:Vt,fillOrFitMode:Dt,clipMode:Ft,repeatMode:Nt},{toPoint:le}=S,ce={},ue={};function fe(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}const{getAngle:ge,getDistance:_e}=M,{get:pe,rotateOfOuter:we,scaleOfOuter:ye}=R,{toPoint:me}=S,ve={},xe={};function be(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=ge(e,i);a=pe(),s?(ye(a,e,o/r*(n||1),1),we(a,e,t+90)):(ye(a,e,1,o/r*(n||1)),we(a,e,t))}return a}const{getDistance:Be}=M,{toPoint:ke}=S,Re={},Ee={};const Le={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;le(n||"top",i,ce),le(s||"bottom",i,ue);const d=e.canvas.createLinearGradient(ce.x,ce.y,ue.x,ue.y);fe(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;me(n||"center",i,ve),me(s||"bottom",i,xe);const h=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,xe));fe(h,t.stops,o);const l={type:a,style:h},c=be(i,ve,xe,d,!0);return c&&(l.transform=c),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;ke(n||"center",i,Re),ke(s||"bottom",i,Ee);const h=e.conicGradientSupport?e.canvas.createConicGradient(0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,Be(Re,Ee));fe(h,t.stops,o);const l={type:a,style:h},c=be(i,Re,Ee,d||1,e.conicGradientRotate90);return c&&(l.transform=c),r&&(l.blendMode=r),l},getTransform:be},{copy:Se,toOffsetOutBounds:Me}=B,Ae={},We={};function Oe(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Se(Ae,t.bounds),Ae.x+=i.x-o.x,Ae.y+=i.y-o.y,n){const{matrix:t}=s;Ae.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ae.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ae.width*=n,Ae.height*=n}t.copyWorld(s.canvas,t.bounds,Ae)}else n&&(Se(Ae,i),Ae.x-=i.width/2*(n-1),Ae.y-=i.height/2*(n-1),Ae.width*=n,Ae.height*=n),t.copyWorld(s.canvas,o,n?Ae:i)}const{toOffsetOutBounds:Ce}=B,Te={};const Ie={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Me(h,We),r.forEach(((r,_)=>{f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,We,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ce(h,Te),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Te.offsetX+r.x*c,Te.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,Te,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Pe}=_;function De(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ne(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ne(t,i,n,a);break;case"path":i.restore()}}function Fe(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(De(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Fe(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Fe(t)),s||(s=Fe(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Pe(i,e)||i.__render(s||t,e);De(this,o,t,s,n,a)};const Ye=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=Ye+"_#~&*+\\=|≮≯≈≠=…",Ue=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 He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Xe=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),je=He(Ye),qe=He(Ge),ze=He("- —/~|┆·");var Qe;!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"}(Qe||(Qe={}));const{Letter:Je,Single:Ze,Before:Ke,After:$e,Symbol:ti,Break:ei}=Qe;function ii(t){return Xe[t]?Je:ze[t]?ei:Ve[t]?Ke:je[t]?$e:qe[t]?ti:Ue.test(t)?Ze:Je}const ni={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function si(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:ai}=ni,{Letter:oi,Single:ri,Before:di,After:hi,Symbol:li,Break:ci}=Qe;let ui,fi,gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,ki,Ri,Ei,Li,Si=[];function Mi(t,e){vi&&!mi&&(mi=vi),ui.data.push({char:t,width:e}),gi+=e}function Ai(){_i+=gi,ui.width=gi,fi.words.push(ui),ui={data:[]},gi=0}function Wi(){Ri&&(Ei.paraNumber++,fi.paraStart=!0,Ri=!1),vi&&(fi.startCharSize=mi,fi.endCharSize=vi,mi=0),fi.width=_i,Li.width&&ai(fi),Si.push(fi),fi={words:[]},_i=0}const Oi=0,Ci=1,Ti=2;const{top:Ii,right:Pi,bottom:Di,left:Fi}=A;function Ni(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Fi],a-=h[Pi]+h[Fi]),o&&(s=h[Ii],o-=h[Ii]+h[Di]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ei=t,Si=t.rows,Li=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Li;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ri=!0,bi=null,mi=yi=vi=gi=_i=0,ui={data:[]},fi={words:[]};for(let n=0,h=i.length;n<h;n++)wi=i[n],"\n"===wi?(gi&&Ai(),fi.paraEnd=!0,Wi(),Ri=!0):(xi=ii(wi),xi===oi&&"none"!==o&&(wi=si(wi,o,!gi)),yi=r.measureText(wi).width,s&&(s<0&&(vi=yi),yi+=s),Bi=xi===ri&&(bi===ri||bi===oi)||bi===ri&&xi!==hi,ki=!(xi!==di&&xi!==ri||bi!==li&&bi!==hi),pi=Ri&&a?d-a:d,t&&d&&_i+gi+yi>pi&&(e?(gi&&Ai(),Wi()):(ki||(ki=xi===oi&&bi==hi),Bi||ki||xi===ci||xi===di||xi===ri||gi+yi>pi?(gi&&Ai(),Wi()):Wi()))," "===wi&&!0!==Ri&&_i+gi===0||(xi===ci?(" "===wi&&gi&&Ai(),Mi(wi,yi),Ai()):Bi||ki?(gi&&Ai(),Mi(wi,yi)):Mi(wi,yi)),bi=xi);gi&&Ai(),_i&&Wi(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ei.paraNumber++,Si.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ni(e,"x",t[Fi]);break;case"right":Ni(e,"x",-t[Pi])}if(!s)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ii]);break;case"bottom":Ni(e,"y",-t[Di])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,h=i.length;a<h;a++){if(c=i[a],c.x=g,c.width<p||c.width>p&&!r)switch(d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Oi:h>.01?Ci:Ti,t.isOverflow&&!r&&(t.textMode=!0),c===Ti?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ci?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),a&&"show"!==a){let t,o;"hide"===a?a="":"ellipsis"===a&&(a="...");const r=a?e.canvas.measureText(a).width:0,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),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 n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Ui,addPoint:Hi,toBounds:Xi}=W;const Vi={export(t,i,s){return this.running=!0,function(t){ji||(ji=new O);return new Promise((e=>{ji.add((()=>re(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1},{toURL:h}=e,{download:l}=e.origin,c=a.fileType(i);if("json"===i)return d({data:t.toJSON()});if("json"===c)return l(h(JSON.stringify(t.toJSON()),"text"),i),d({data:!0});if("svg"===i)return d({data:t.toSVG()});if("svg"===c)return l(h(t.toSVG(),"svg"),i),d({data:!0});const{leafer:u}=t;u?u.waitViewCompleted((()=>re(this,void 0,void 0,(function*(){s=a.getExportOptions(s);let e,o,r=1,h=1;const{worldTransform:l,isLeafer:c,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(i)||x,B=new C;if(v)e=!0===v?c?u.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(r=l.scaleX,h=l.scaleY,i){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,h/=t.scaleY;break;case"world":r=1,h=1;break;case"page":i=t.leafer;default:B.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,h/=h/e.scaleY}e=t.getBounds("render",i)}const{x:k,y:R,width:E,height:L}=new g(e).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:B.scale(1/y).invert().translate(-k,-R).withScale(1/r*y,1/h*y)};if(_&&(t=u,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Hi(o,s,a):Ui(o={},s,a)),r++;const d=new g;return Xi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===i?S:yield S.export(i,s);d({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:e,trimBounds:o})})))):d({data:!1})}))))}};let ji;const qi=t.prototype,zi=p.get("@leafer-ui/export");qi.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},qi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{zi.error(t),n(null)}))}))},qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},qi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{zi.error(t),n(!1)}))}))},Object.assign(G,Yi),Object.assign(D,Gi),Object.assign(U,Mt),Object.assign(P,he),Object.assign(F,Le),Object.assign(H,Ie),Object.assign(N,Vi),Object.assign(n,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new I}),j();export{ot as Layouter,X as LeaferCanvas,dt as Renderer,wt as Selector,z as Watcher,j as useCanvas};
|