leafer-draw 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +34 -21
- package/dist/web.esm.js +35 -22
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +390 -352
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +387 -349
- package/dist/web.module.min.js +1 -1
- package/package.json +2 -2
package/dist/web.cjs
CHANGED
|
@@ -401,9 +401,13 @@ function updateBounds(boundsList) {
|
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
function updateChange(updateList) {
|
|
404
|
+
let layout;
|
|
404
405
|
updateList.list.forEach(leaf => {
|
|
405
|
-
|
|
406
|
+
layout = leaf.__layout;
|
|
407
|
+
if (layout.opacityChanged)
|
|
406
408
|
updateAllWorldOpacity(leaf);
|
|
409
|
+
if (layout.stateStyleChanged)
|
|
410
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
407
411
|
leaf.__updateChange();
|
|
408
412
|
});
|
|
409
413
|
}
|
|
@@ -769,7 +773,6 @@ class Renderer {
|
|
|
769
773
|
core.Platform.requestRender(() => {
|
|
770
774
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
771
775
|
if (this.running) {
|
|
772
|
-
this.target.emit(core.AnimateEvent.FRAME);
|
|
773
776
|
if (this.changed && this.canvas.view)
|
|
774
777
|
this.render();
|
|
775
778
|
this.target.emit(core.RenderEvent.NEXT);
|
|
@@ -1207,6 +1210,8 @@ function getPatternData(paint, box, image) {
|
|
|
1207
1210
|
let { width, height } = image;
|
|
1208
1211
|
if (paint.padding)
|
|
1209
1212
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1213
|
+
if (paint.mode === 'strench')
|
|
1214
|
+
paint.mode = 'stretch';
|
|
1210
1215
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1211
1216
|
const sameBox = box.width === width && box.height === height;
|
|
1212
1217
|
const data = { mode };
|
|
@@ -1235,7 +1240,7 @@ function getPatternData(paint, box, image) {
|
|
|
1235
1240
|
if (offset)
|
|
1236
1241
|
x += offset.x, y += offset.y;
|
|
1237
1242
|
switch (mode) {
|
|
1238
|
-
case '
|
|
1243
|
+
case 'stretch':
|
|
1239
1244
|
if (!sameBox)
|
|
1240
1245
|
width = box.width, height = box.height;
|
|
1241
1246
|
break;
|
|
@@ -1262,7 +1267,7 @@ function getPatternData(paint, box, image) {
|
|
|
1262
1267
|
translate(data.transform, box.x, box.y);
|
|
1263
1268
|
}
|
|
1264
1269
|
}
|
|
1265
|
-
if (scaleX && mode !== '
|
|
1270
|
+
if (scaleX && mode !== 'stretch') {
|
|
1266
1271
|
data.scaleX = scaleX;
|
|
1267
1272
|
data.scaleY = scaleY;
|
|
1268
1273
|
}
|
|
@@ -1366,7 +1371,7 @@ const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
|
1366
1371
|
const { ceil, abs: abs$1 } = Math;
|
|
1367
1372
|
function createPattern(ui, paint, pixelRatio) {
|
|
1368
1373
|
let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1369
|
-
const id = scaleX + '-' + scaleY;
|
|
1374
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1370
1375
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1371
1376
|
scaleX = abs$1(scaleX);
|
|
1372
1377
|
scaleY = abs$1(scaleY);
|
|
@@ -1460,7 +1465,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1460
1465
|
const { abs } = Math;
|
|
1461
1466
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1462
1467
|
const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1463
|
-
|
|
1468
|
+
const { pixelRatio } = canvas;
|
|
1469
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1464
1470
|
return false;
|
|
1465
1471
|
}
|
|
1466
1472
|
else {
|
|
@@ -1468,8 +1474,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1468
1474
|
if (allowPaint) {
|
|
1469
1475
|
if (!data.repeat) {
|
|
1470
1476
|
let { width, height } = data;
|
|
1471
|
-
width *= abs(scaleX) *
|
|
1472
|
-
height *= abs(scaleY) *
|
|
1477
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1478
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1473
1479
|
if (data.scaleX) {
|
|
1474
1480
|
width *= data.scaleX;
|
|
1475
1481
|
height *= data.scaleY;
|
|
@@ -1495,14 +1501,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1495
1501
|
}
|
|
1496
1502
|
else {
|
|
1497
1503
|
if (!paint.style || paint.sync || draw.Export.running) {
|
|
1498
|
-
createPattern(ui, paint,
|
|
1504
|
+
createPattern(ui, paint, pixelRatio);
|
|
1499
1505
|
}
|
|
1500
1506
|
else {
|
|
1501
1507
|
if (!paint.patternTask) {
|
|
1502
1508
|
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1503
1509
|
paint.patternTask = null;
|
|
1504
1510
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1505
|
-
createPattern(ui, paint,
|
|
1511
|
+
createPattern(ui, paint, pixelRatio);
|
|
1506
1512
|
ui.forceUpdate('surface');
|
|
1507
1513
|
}), 300);
|
|
1508
1514
|
}
|
|
@@ -1566,14 +1572,16 @@ function linearGradient(paint, box) {
|
|
|
1566
1572
|
return data;
|
|
1567
1573
|
}
|
|
1568
1574
|
function applyStops(gradient, stops, opacity) {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1575
|
+
if (stops) {
|
|
1576
|
+
let stop;
|
|
1577
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1578
|
+
stop = stops[i];
|
|
1579
|
+
if (typeof stop === 'string') {
|
|
1580
|
+
gradient.addColorStop(i / (len - 1), draw.ColorConvert.string(stop, opacity));
|
|
1581
|
+
}
|
|
1582
|
+
else {
|
|
1583
|
+
gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
|
|
1584
|
+
}
|
|
1577
1585
|
}
|
|
1578
1586
|
}
|
|
1579
1587
|
}
|
|
@@ -2329,10 +2337,15 @@ const TextConvertModule = {
|
|
|
2329
2337
|
};
|
|
2330
2338
|
|
|
2331
2339
|
function string(color, opacity) {
|
|
2332
|
-
|
|
2333
|
-
|
|
2340
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
2341
|
+
if (typeof color === 'string') {
|
|
2342
|
+
if (doOpacity && draw.ColorConvert.object)
|
|
2343
|
+
color = draw.ColorConvert.object(color);
|
|
2344
|
+
else
|
|
2345
|
+
return color;
|
|
2346
|
+
}
|
|
2334
2347
|
let a = color.a === undefined ? 1 : color.a;
|
|
2335
|
-
if (
|
|
2348
|
+
if (doOpacity)
|
|
2336
2349
|
a *= opacity;
|
|
2337
2350
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
2338
2351
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
package/dist/web.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, LeafLevelList, LayoutEvent, Run, ImageManager,
|
|
1
|
+
import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
|
|
@@ -402,9 +402,13 @@ function updateBounds(boundsList) {
|
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
function updateChange(updateList) {
|
|
405
|
+
let layout;
|
|
405
406
|
updateList.list.forEach(leaf => {
|
|
406
|
-
|
|
407
|
+
layout = leaf.__layout;
|
|
408
|
+
if (layout.opacityChanged)
|
|
407
409
|
updateAllWorldOpacity(leaf);
|
|
410
|
+
if (layout.stateStyleChanged)
|
|
411
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
408
412
|
leaf.__updateChange();
|
|
409
413
|
});
|
|
410
414
|
}
|
|
@@ -770,7 +774,6 @@ class Renderer {
|
|
|
770
774
|
Platform.requestRender(() => {
|
|
771
775
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
772
776
|
if (this.running) {
|
|
773
|
-
this.target.emit(AnimateEvent.FRAME);
|
|
774
777
|
if (this.changed && this.canvas.view)
|
|
775
778
|
this.render();
|
|
776
779
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -1208,6 +1211,8 @@ function getPatternData(paint, box, image) {
|
|
|
1208
1211
|
let { width, height } = image;
|
|
1209
1212
|
if (paint.padding)
|
|
1210
1213
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1214
|
+
if (paint.mode === 'strench')
|
|
1215
|
+
paint.mode = 'stretch';
|
|
1211
1216
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1212
1217
|
const sameBox = box.width === width && box.height === height;
|
|
1213
1218
|
const data = { mode };
|
|
@@ -1236,7 +1241,7 @@ function getPatternData(paint, box, image) {
|
|
|
1236
1241
|
if (offset)
|
|
1237
1242
|
x += offset.x, y += offset.y;
|
|
1238
1243
|
switch (mode) {
|
|
1239
|
-
case '
|
|
1244
|
+
case 'stretch':
|
|
1240
1245
|
if (!sameBox)
|
|
1241
1246
|
width = box.width, height = box.height;
|
|
1242
1247
|
break;
|
|
@@ -1263,7 +1268,7 @@ function getPatternData(paint, box, image) {
|
|
|
1263
1268
|
translate(data.transform, box.x, box.y);
|
|
1264
1269
|
}
|
|
1265
1270
|
}
|
|
1266
|
-
if (scaleX && mode !== '
|
|
1271
|
+
if (scaleX && mode !== 'stretch') {
|
|
1267
1272
|
data.scaleX = scaleX;
|
|
1268
1273
|
data.scaleY = scaleY;
|
|
1269
1274
|
}
|
|
@@ -1367,7 +1372,7 @@ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
|
1367
1372
|
const { ceil, abs: abs$1 } = Math;
|
|
1368
1373
|
function createPattern(ui, paint, pixelRatio) {
|
|
1369
1374
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1370
|
-
const id = scaleX + '-' + scaleY;
|
|
1375
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1371
1376
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1372
1377
|
scaleX = abs$1(scaleX);
|
|
1373
1378
|
scaleY = abs$1(scaleY);
|
|
@@ -1461,7 +1466,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1461
1466
|
const { abs } = Math;
|
|
1462
1467
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1463
1468
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1464
|
-
|
|
1469
|
+
const { pixelRatio } = canvas;
|
|
1470
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1465
1471
|
return false;
|
|
1466
1472
|
}
|
|
1467
1473
|
else {
|
|
@@ -1469,8 +1475,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1469
1475
|
if (allowPaint) {
|
|
1470
1476
|
if (!data.repeat) {
|
|
1471
1477
|
let { width, height } = data;
|
|
1472
|
-
width *= abs(scaleX) *
|
|
1473
|
-
height *= abs(scaleY) *
|
|
1478
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1479
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1474
1480
|
if (data.scaleX) {
|
|
1475
1481
|
width *= data.scaleX;
|
|
1476
1482
|
height *= data.scaleY;
|
|
@@ -1496,14 +1502,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1496
1502
|
}
|
|
1497
1503
|
else {
|
|
1498
1504
|
if (!paint.style || paint.sync || Export.running) {
|
|
1499
|
-
createPattern(ui, paint,
|
|
1505
|
+
createPattern(ui, paint, pixelRatio);
|
|
1500
1506
|
}
|
|
1501
1507
|
else {
|
|
1502
1508
|
if (!paint.patternTask) {
|
|
1503
1509
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1504
1510
|
paint.patternTask = null;
|
|
1505
1511
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1506
|
-
createPattern(ui, paint,
|
|
1512
|
+
createPattern(ui, paint, pixelRatio);
|
|
1507
1513
|
ui.forceUpdate('surface');
|
|
1508
1514
|
}), 300);
|
|
1509
1515
|
}
|
|
@@ -1567,14 +1573,16 @@ function linearGradient(paint, box) {
|
|
|
1567
1573
|
return data;
|
|
1568
1574
|
}
|
|
1569
1575
|
function applyStops(gradient, stops, opacity) {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1576
|
+
if (stops) {
|
|
1577
|
+
let stop;
|
|
1578
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1579
|
+
stop = stops[i];
|
|
1580
|
+
if (typeof stop === 'string') {
|
|
1581
|
+
gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
|
|
1582
|
+
}
|
|
1583
|
+
else {
|
|
1584
|
+
gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
|
|
1585
|
+
}
|
|
1578
1586
|
}
|
|
1579
1587
|
}
|
|
1580
1588
|
}
|
|
@@ -2330,10 +2338,15 @@ const TextConvertModule = {
|
|
|
2330
2338
|
};
|
|
2331
2339
|
|
|
2332
2340
|
function string(color, opacity) {
|
|
2333
|
-
|
|
2334
|
-
|
|
2341
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
2342
|
+
if (typeof color === 'string') {
|
|
2343
|
+
if (doOpacity && ColorConvert.object)
|
|
2344
|
+
color = ColorConvert.object(color);
|
|
2345
|
+
else
|
|
2346
|
+
return color;
|
|
2347
|
+
}
|
|
2335
2348
|
let a = color.a === undefined ? 1 : color.a;
|
|
2336
|
-
if (
|
|
2349
|
+
if (doOpacity)
|
|
2337
2350
|
a *= opacity;
|
|
2338
2351
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
2339
2352
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
package/dist/web.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,defineKey as l,FileHelper as c,LeafList as h,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as y,LeafBoundsHelper as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,AnimateEvent as R,BoundsHelper as k,MatrixHelper as E,MathHelper as S,AlignHelper as L,ImageEvent as A,AroundHelper as O,PointHelper as W,Direction4 as C,TwoPointBoundsHelper as T,TaskProcessor as M,Matrix as D}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as I,ColorConvert as P,PaintGradient as F,Export as z,Group as V,TextConvert as Y,Paint as U,Effect as X}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const N=t.get("LeaferCanvas");class G extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(n.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else N.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),N.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:n,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:j,fileType:q}=c;function H(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(j(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,j(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(j(q(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new G(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Q.indexOf("Safari")>-1&&-1===Q.indexOf("Chrome")&&(i.fullImageShadow=!0),Q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?i.os="Mac":Q.indexOf("Linux")>-1&&(i.os="Linux");class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,this.target=t,e&&(this.config=n.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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([f.ADD,f.REMOVE],this.__onChildEvent,this),t.on_(p.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:Z,updateBounds:$,updateAllWorldOpacity:K}=_,{pushAllChildBranch:tt,pushAllParent:et}=w;const{worldBounds:it}=m,nt={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,it),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:at}=_,rt=t.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=n.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(p.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=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(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?(Z(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(t,e)))}))}(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||$(n[t])}$(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&K(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new h(e));e.emitEvent(new x(i,o,this.times)),dt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(p.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=t.get("Renderer");class ct{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=n.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new y,lt.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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 lt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new y(s);n.save(),o&&!t.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.showHitView&&this.renderHitView(s),t.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(R.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.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 y(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 y(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||lt.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 u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function ut(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?gt(t,!0,e,i):pt(e,i);break;case"inside":ft("inside",t,s,e,i);break;case"outside":ft("outside",t,s,e,i)}}function ft(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?gt(e,!0,n,r):pt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ht(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 pt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function gt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&I.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?pt(i,n):n.stroke(),n.restoreBlendMode()):e?pt(i,n):n.stroke())}Object.assign(r,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=dt.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=k;let vt;function xt(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:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:P.string(a,r)};case"image":return I.image(i,t,e,n,!vt||!vt[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:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),vt=I.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=xt(t,o[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?ht(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&I.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?ht(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?ht(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?ht(e,i):s?i.fill(s):i.fill())},fillText:ht,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ut(t,e,i);else switch(o){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 o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ut(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),gt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),gt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),gt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ut,drawTextStroke:pt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=mt(n?_t(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=wt(s,a),o=yt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let Bt={};const{get:Rt,rotateOfOuter:kt,translate:Et,scaleOfOuter:St,scale:Lt,rotate:At}=E;function Ot(t,e,i,n,s,o,a){const r=Rt();Et(r,e.x+i,e.y+n),Lt(r,s,o),a&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,n,s,o,a){const r=Rt();Et(r,e.x+i,e.y+n),s&&Lt(r,s,o),a&&At(r,a),t.transform=r}function Ct(t,e,i,n,s,o,a,r,d,l){const c=Rt();if(d)if("center"===l)kt(c,{x:i/2,y:n/2},d);else switch(At(c,d),d){case 90:Et(c,n,0);break;case 180:Et(c,i,n);break;case 270:Et(c,0,i)}Bt.x=e.x+s,Bt.y=e.y+o,Et(c,Bt.x,Bt.y),a&&St(c,Bt,a,r),t.transform=c}const{get:Tt,translate:Mt}=E,Dt=new y,It={},Pt={};function Ft(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=zt(i,n,e)}function zt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Dt.set(e).shrink(t.padding));const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,i,Pt),y=Pt.scaleX,m=Pt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;y=m="fit"===a?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:_,height:w};y&&(t.width*=y,t.height*=m),L.toPoint(r,t,e,It,!0),v+=It.x,x+=It.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Wt(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Ct(p,e,n,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&Ot(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=Tt(),Mt(p.transform,e.x,e.y)),y&&"strench"!==a&&(p.scaleX=y,p.scaleY=m),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Vt,Yt=new y;const{isSame:Ut}=k;function Xt(t,e,i,n,s,o){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||Ft(s,n,i,o),!0}function Nt(t,e){qt(t,A.LOAD,e)}function Gt(t,e){qt(t,A.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,A.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Ht(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Jt,copy:Zt}=E,{ceil:$t,abs:Kt}=Math;function te(t,e,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(e.patternId===a||t.destroyed)return!1;{s=Kt(s),o=Kt(o);const{image:t,data:r}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=Qt(),Zt(l,g),Jt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.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,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=Qt(),g&&Zt(l,g)),Jt(l,1/s,1/o));const m=t.getCanvas($t(c)||1,$t(h)||1,p),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(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(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return Vt&&i===Vt.paint&&Ut(n,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:r},Vt=r.use>1?{leafPaint:o,paint:i,boxBounds:Yt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Xt(t,e,i,r,o,n),s&&(Nt(t,a),Gt(t,a))):r.error?s&&jt(t,a,r.error):(Ht(t,!0),s&&Nt(t,a),o.loadId=r.load((()=>{Ht(t,!1),t.destroyed||(Xt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Ht(t,!1),jt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld;if(!n.data||n.patternId===o+"-"+a&&!z.running)return!1;{const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=ie(o)*e.pixelRatio,n*=ie(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>i.image.maxCacheSize||z.running}return s?(e.save(),e.clip(),n.blendMode&&(e.blendMode=n.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(n.image.view,0,0,r.width,r.height),e.restore(),!0):(!n.style||n.sync||z.running?te(t,n,e.pixelRatio):n.patternTask||(n.patternTask=B.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&te(t,n,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Ft,getPatternData:zt,fillOrFitMode:Ot,clipMode:Wt,repeatMode:Ct},{toPoint:se}=O,oe={},ae={};function re(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}const{getAngle:de,getDistance:le}=W,{get:ce,rotateOfOuter:he,scaleOfOuter:ue}=E,{toPoint:fe}=O,pe={},ge={};function _e(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=de(e,i);o=ce(),s?(ue(o,e,a/r*(n||1),1),he(o,e,t+90)):(ue(o,e,1,a/r*(n||1)),he(o,e,t))}return o}const{getDistance:we}=W,{toPoint:ye}=O,me={},ve={};const xe={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;se(n||"top",e,oe),se(s||"bottom",e,ae);const d=i.canvas.createLinearGradient(oe.x,oe.y,ae.x,ae.y);re(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;fe(n||"center",e,pe),fe(s||"bottom",e,ge);const l=i.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,le(pe,ge));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,pe,ge,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ye(n||"center",e,me),ye(s||"bottom",e,ve);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,me.x,me.y):i.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,ve));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,me,ve,d||1,i.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:_e},{copy:be,toOffsetOutBounds:Be}=k,Re={},ke={};function Ee(t,e,n,s){const{bounds:o,shapeBounds:a}=s;if(i.fullImageShadow){if(be(Re,t.bounds),Re.x+=e.x-a.x,Re.y+=e.y-a.y,n){const{matrix:t}=s;Re.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Re.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Re.width*=n,Re.height*=n}t.copyWorld(s.canvas,t.bounds,Re)}else n&&(be(Re,e),Re.x-=e.width/2*(n-1),Re.y-=e.height/2*(n-1),Re.width*=n,Re.height*=n),t.copyWorld(s.canvas,a,n?Re:e)}const{toOffsetOutBounds:Se}=k,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Be(l,ke),r.forEach(((r,g)=>{f.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ee(f,ke,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Se(l,Le),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Le.offsetX+r.x*h,Le.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ee(f,Le,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&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:Oe}=m;function We(t,e,i,n,s,o){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),Te(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Te(t,i,n,o);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function Te(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}V.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(We(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ce(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ce(t)),s||(s=Ce(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Oe(i,e)||i.__render(s||t,e);We(this,a,t,s,n,o)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",De=Me+"_#~&*+\\=|≮≯≈≠=…",Ie=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 Pe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Fe=Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ze=Pe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Pe(Me),Ye=Pe(De),Ue=Pe("- —/~|┆·");var Xe;!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"}(Xe||(Xe={}));const{Letter:Ne,Single:Ge,Before:je,After:qe,Symbol:He,Break:Qe}=Xe;function Je(t){return Fe[t]?Ne:Ue[t]?Qe:ze[t]?je:Ve[t]?qe:Ye[t]?He:Ie.test(t)?Ge:Ne}const Ze={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function $e(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:Ke}=Ze,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:oi}=Xe;let ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi,bi=[];function Bi(t,e){pi&&!fi&&(fi=pi),ai.data.push({char:t,width:e}),di+=e}function Ri(){li+=di,ai.width=di,ri.words.push(ai),ai={data:[]},di=0}function ki(){mi&&(vi.paraNumber++,ri.paraStart=!0,mi=!1),pi&&(ri.startCharSize=fi,ri.endCharSize=pi,fi=0),ri.width=li,xi.width&&Ke(ri),bi.push(ri),ri={words:[]},li=0}const Ei=0,Si=1,Li=2;const{top:Ai,right:Oi,bottom:Wi,left:Ci}=C;function Ti(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 Mi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o&&(n=l[Ci],o-=l[Oi]+l[Ci]),a&&(s=l[Ai],a-=l[Ai]+l[Wi]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){vi=t,bi=t.rows,xi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=i,{width:d,height:l}=xi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,i="break"===n.textWrap;mi=!0,_i=null,fi=ui=pi=di=li=0,ai={data:[]},ri={words:[]};for(let n=0,l=e.length;n<l;n++)hi=e[n],"\n"===hi?(di&&Ri(),ri.paraEnd=!0,ki(),mi=!0):(gi=Je(hi),gi===ti&&"none"!==a&&(hi=$e(hi,a,!di)),ui=r.measureText(hi).width,s&&(s<0&&(pi=ui),ui+=s),wi=gi===ei&&(_i===ei||_i===ti)||_i===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||_i!==si&&_i!==ni),ci=mi&&o?d-o:d,t&&d&&li+di+ui>ci&&(i?(di&&Ri(),li&&ki()):(yi||(yi=gi===ti&&_i==ni),wi||yi||gi===oi||gi===ii||gi===ei||di+ui>ci?(di&&Ri(),li&&ki()):li&&ki()))," "===hi&&!0!==mi&&li+di===0||(gi===oi?(" "===hi&&di&&Ri(),Bi(hi,ui),Ri()):wi||yi?(di&&Ri(),Bi(hi,ui)):Bi(hi,ui)),_i=gi);di&&Ri(),li&&ki(),bi.length>0&&(bi[bi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{vi.paraNumber++,bi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,e),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ti(e,"x",t[Ci]);break;case"right":Ti(e,"x",-t[Oi])}if(!s)switch(i.verticalAlign){case"top":Ti(e,"y",t[Ai]);break;case"bottom":Ti(e,"y",-t[Wi])}}(l,c,e,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=n,y=s*i.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=i.length;o<l;o++){if(h=i[o],h.x=p,h.width<_||h.width>_&&!r)switch(d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(c,e),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Ei:l>.01?Si:Li,t.isOverflow&&!r&&(t.textMode=!0),h===Li?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Si?(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&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,c=n+s-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,n,o),"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}}(c,e),c}};const Di={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:Ii,addPoint:Pi,toBounds:Fi}=T;const zi={export(t,e,n){this.running=!0;const s=c.fileType(e),o=e.includes(".");return n=c.getExportOptions(n),function(t){Vi||(Vi=new M);return new Promise((e=>{Vi.add((()=>ee(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((d=>{const l=t=>{a(t),d(),this.running=!1},{toURL:h}=i,{download:u}=i.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),e),l({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),e),l({data:!!o||t.toSVG()});const{leafer:f}=t;f?(Yi(t),f.waitViewCompleted((()=>ee(this,void 0,void 0,(function*(){let i,s,o=1,a=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,w=void 0===n.smooth?f.config.smooth:n.smooth,m=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=c.isOpaqueImage(e)||x,B=new D;if(v)i=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(h?"inner":"local");switch(o=d.scaleX,a=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,a/=t.scaleY;break;case"world":o=1,a=1;break;case"page":e=t.leafer;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,a/=a/i.scaleY}i=t.getBounds("render",e)}const R={scaleX:1,scaleY:1};S.getScaleData(n.scale,n.size,i,R);let k=n.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:O}=new y(i).scale(R.scaleX,R.scaleY),W={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/o*R.scaleX,1/a*R.scaleY)};let C,T=r.canvas({width:Math.round(A),height:Math.round(O),pixelRatio:k,smooth:w,contextSettings:m});if(p&&(C=t,C.__worldOpacity=0,t=f,W.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,W),t.fill=e}else t.__render(T,W);if(T.restore(),C&&C.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Pi(a,s,o):Ii(a={},s,o)),r++;const d=new y;return Fi(a,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:k};T=r.canvas(n),T.copyWorld(t,s,n)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),_&&_(T);const M="canvas"===e?T:yield T.export(e,n);l({data:M,width:T.pixelWidth,height:T.pixelHeight,renderBounds:i,trimBounds:s})}))))):l({data:!1})}))))}};let Vi;function Yi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Yi(t)))}const Ui=e.prototype,Xi=t.get("@leafer-ui/export");Ui.export=function(t,e){const{quality:i,blob:n}=c.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ui.toBlob=function(t,e){return new Promise((n=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{Xi.error(t),n(null)}))}))},Ui.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Ui.saveAs=function(t,e){return new Promise((n=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{Xi.error(t),n(!1)}))}))},Object.assign(Y,Mi),Object.assign(P,Di),Object.assign(U,bt),Object.assign(I,ne),Object.assign(F,xe),Object.assign(X,Ae),Object.assign(z,zi),H();export{dt as Layouter,G as LeaferCanvas,ct as Renderer,J as Watcher,H as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,defineKey as l,FileHelper as c,LeafList as h,RenderEvent as u,ChildEvent as f,WatchEvent as p,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as y,LeafBoundsHelper as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as k,MathHelper as E,AlignHelper as S,ImageEvent as L,AroundHelper as A,PointHelper as O,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as T,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as D,ColorConvert as I,PaintGradient as P,Export as F,Group as z,TextConvert as V,Paint as Y,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else X.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:G,fileType:j}=c;function q(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,G(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(G(j(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new N(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:H}=navigator;H.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):H.indexOf("Safari")>-1&&-1===H.indexOf("Chrome")&&(i.fullImageShadow=!0),H.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):H.indexOf("Mac")>-1?i.os="Mac":H.indexOf("Linux")>-1&&(i.os="Linux");class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===f.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 p(p.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([f.ADD,f.REMOVE],this.__onChildEvent,this),t.on_(p.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:J,updateBounds:Z,updateAllWorldOpacity:$}=_,{pushAllChildBranch:K,pushAllParent:tt}=w;const{worldBounds:et}=m,it={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:nt,updateAllChange:ot}=_,at=t.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.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(p.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&K(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new h(e));e.emitEvent(new x(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(p.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=t.get("Renderer");class lt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new y,dt.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=e.includes(this.target.__world),a=new y(n);s.save(),o&&!t.showRepaint?s.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0)),this.__render(n,o,a),s.restore(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(e,i,s){const n=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.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 y(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 y(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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ct(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function ht(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?pt(t,!0,e,i):ft(e,i);break;case"inside":ut("inside",t,n,e,i);break;case"outside":ut("outside",t,n,e,i)}}function ut(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?pt(e,!0,s,r):ft(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",ct(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function ft(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function pt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&D.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?ft(i,s):s.stroke(),s.restoreBlendMode()):e?ft(i,s):s.stroke())}Object.assign(r,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=rt.fullLayout;const{getSpread:gt,getOuterOf:_t,getByMove:wt,getIntersectData:yt}=R;let mt;function vt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:I.string(a,r)};case"image":return D.image(i,t,e,s,!mt||!mt[e.url]);case"linear":return P.linearGradient(e,s);case"radial":return P.radialGradient(e,s);case"angular":return P.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:I.string(e)}:void 0}}const xt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),mt=D.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=vt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ct(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&D.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?ct(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?ct(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?ct(e,i):n?i.fill(n):i.fill())},fillText:ct,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),pt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),pt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),pt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:ft,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))d=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,h=yt(s?gt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=_t(n,a),o=wt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let bt={};const{get:Bt,rotateOfOuter:Rt,translate:kt,scaleOfOuter:Et,scale:St,rotate:Lt}=k;function At(t,e,i,s,n,o,a){const r=Bt();kt(r,e.x+i,e.y+s),St(r,n,o),a&&Rt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ot(t,e,i,s,n,o,a){const r=Bt();kt(r,e.x+i,e.y+s),n&&St(r,n,o),a&&Lt(r,a),t.transform=r}function Ct(t,e,i,s,n,o,a,r,d,l){const c=Bt();if(d)if("center"===l)Rt(c,{x:i/2,y:s/2},d);else switch(Lt(c,d),d){case 90:kt(c,s,0);break;case 180:kt(c,i,s);break;case 270:kt(c,0,i)}bt.x=e.x+n,bt.y=e.y+o,kt(c,bt.x,bt.y),a&&Et(c,bt,a,r),t.transform=c}const{get:Wt,translate:Tt}=k,Mt=new y,Dt={},It={};function Pt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=Ft(i,s,e)}function Ft(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Mt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===s&&e.height===n,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?n:s,w=g?s:n;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(E.getScaleData(l,c,i,It),y=It.scaleX,m=It.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),S.toPoint(r,t,e,Dt,!0),v+=Dt.x,x+=Dt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||y||h)&&Ot(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Ct(p,e,s,n,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&At(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),y&&"stretch"!==a&&(p.scaleX=y,p.scaleY=m),p.width=s,p.height=n,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let zt,Vt=new y;const{isSame:Yt}=R;function Ut(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Pt(n,s,i,o),!0}function Xt(t,e){jt(t,L.LOAD,e)}function Nt(t,e){jt(t,L.LOADED,e)}function Gt(t,e,i){e.error=i,t.forceUpdate("surface"),jt(t,L.ERROR,e)}function jt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function qt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ht,scale:Qt,copy:Jt}=k,{ceil:Zt,abs:$t}=Math;function Kt(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(e.patternId===a||t.destroyed)return!1;{n=$t(n),o=$t(o);const{image:t,data:r}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=Ht(),Jt(l,g),Qt(l,1/u,1/f),n*=u,o*=f),n*=s,o*=s,c*=n,h*=o;const w=c*h;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(n/=d,o/=d,c/=d,h/=d),u&&(n/=u,o/=f),(g||1!==n||1!==o)&&(l||(l=Ht(),g&&Jt(l,g)),Qt(l,1/n,1/o));const m=t.getCanvas(Zt(c)||1,Zt(h)||1,p),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function te(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{d(s.next(t))}catch(t){o(t)}}function r(t){try{d(s.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ee}=Math;const ie={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return zt&&i===zt.paint&&Yt(s,zt.boxBounds)?o=zt.leafPaint:(o={type:i.type,image:r},zt=r.use>1?{leafPaint:o,paint:i,boxBounds:Vt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ut(t,e,i,r,o,s),n&&(Xt(t,a),Nt(t,a))):r.error?n&&Gt(t,a,r.error):(qt(t,!0),n&&Xt(t,a),o.loadId=r.load((()=>{qt(t,!1),t.destroyed||(Ut(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,a)),o.loadId=null}),(e=>{qt(t,!1),Gt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=e;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:d}=s;if(n)if(d.repeat)n=!1;else{let{width:t,height:e}=d;t*=ee(o)*r,e*=ee(a)*r,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),n=t*e>i.image.maxCacheSize||F.running}return n?(e.save(),e.clip(),s.blendMode&&(e.blendMode=s.blendMode),d.opacity&&(e.opacity*=d.opacity),d.transform&&e.transform(d.transform),e.drawImage(s.image.view,0,0,d.width,d.height),e.restore(),!0):(!s.style||s.sync||F.running?Kt(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>te(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Kt(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Kt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,d=i.length;r<d;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Pt,getPatternData:Ft,fillOrFitMode:At,clipMode:Ot,repeatMode:Ct},{toPoint:se}=A,ne={},oe={};function ae(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),I.string(s,i)):t.addColorStop(s.offset,I.string(s.color,i))}}const{getAngle:re,getDistance:de}=O,{get:le,rotateOfOuter:ce,scaleOfOuter:he}=k,{toPoint:ue}=A,fe={},pe={};function ge(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=re(e,i);o=le(),n?(he(o,e,a/r*(s||1),1),ce(o,e,t+90)):(he(o,e,1,a/r*(s||1)),ce(o,e,t))}return o}const{getDistance:_e}=O,{toPoint:we}=A,ye={},me={};const ve={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;se(s||"top",e,ne),se(n||"bottom",e,oe);const d=i.canvas.createLinearGradient(ne.x,ne.y,oe.x,oe.y);ae(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(s||"center",e,fe),ue(n||"bottom",e,pe);const l=i.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,de(fe,pe));ae(l,t.stops,a);const c={type:o,style:l},h=ge(e,fe,pe,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:d}=t;we(s||"center",e,ye),we(n||"bottom",e,me);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ye.x,ye.y):i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,_e(ye,me));ae(l,t.stops,a);const c={type:o,style:l},h=ge(e,ye,me,d||1,i.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ge},{copy:xe,toOffsetOutBounds:be}=R,Be={},Re={};function ke(t,e,s,n){const{bounds:o,shapeBounds:a}=n;if(i.fullImageShadow){if(xe(Be,t.bounds),Be.x+=e.x-a.x,Be.y+=e.y-a.y,s){const{matrix:t}=n;Be.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Be.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Be.width*=s,Be.height*=s}t.copyWorld(n.canvas,t.bounds,Be)}else s&&(xe(Be,e),Be.x-=e.width/2*(s-1),Be.y-=e.height/2*(s-1),Be.width*=s,Be.height*=s),t.copyWorld(n.canvas,a,s?Be:e)}const{toOffsetOutBounds:Ee}=R,Se={};const Le={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;be(l,Re),r.forEach(((r,g)=>{f.setWorldShadow(Re.offsetX+r.x*h,Re.offsetY+r.y*u,r.blur*h,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ke(f,Re,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),s=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ee(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ke(f,Se,n,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ae}=m;function Oe(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),We(t,e,i,1)}(t,i,s,n);break;case"opacity-path":We(t,i,s,o);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}z.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Oe(this,a,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ce(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=Ce(t)),n||(n=Ce(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ae(i,e)||i.__render(n||t,e);Oe(this,a,t,n,s,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Me=Te+"_#~&*+\\=|≮≯≈≠=…",De=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 Ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Pe=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Fe=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ze=Ie(Te),Ve=Ie(Me),Ye=Ie("- —/~|┆·");var Ue;!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"}(Ue||(Ue={}));const{Letter:Xe,Single:Ne,Before:Ge,After:je,Symbol:qe,Break:He}=Ue;function Qe(t){return Pe[t]?Xe:Ye[t]?He:Fe[t]?Ge:ze[t]?je:Ve[t]?qe:De.test(t)?Ne:Xe}const Je={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ze(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:$e}=Je,{Letter:Ke,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ue;let oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,yi,mi,vi,xi=[];function bi(t,e){fi&&!ui&&(ui=fi),oi.data.push({char:t,width:e}),ri+=e}function Bi(){di+=ri,oi.width=ri,ai.words.push(oi),oi={data:[]},ri=0}function Ri(){yi&&(mi.paraNumber++,ai.paraStart=!0,yi=!1),fi&&(ai.startCharSize=ui,ai.endCharSize=fi,ui=0),ai.width=di,vi.width&&$e(ai),xi.push(ai),ai={words:[]},di=0}const ki=0,Ei=1,Si=2;const{top:Li,right:Ai,bottom:Oi,left:Ci}=C;function Wi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Ti={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o&&(s=l[Ci],o-=l[Ai]+l[Ci]),a&&(n=l[Li],a-=l[Li]+l[Oi]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,s){mi=t,xi=t.rows,vi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=i,{width:d,height:l}=vi;if(d||l||n||"none"!==a){const t="none"!==s.textWrap,i="break"===s.textWrap;yi=!0,gi=null,ui=hi=fi=ri=di=0,oi={data:[]},ai={words:[]};for(let s=0,l=e.length;s<l;s++)ci=e[s],"\n"===ci?(ri&&Bi(),ai.paraEnd=!0,Ri(),yi=!0):(pi=Qe(ci),pi===Ke&&"none"!==a&&(ci=Ze(ci,a,!ri)),hi=r.measureText(ci).width,n&&(n<0&&(fi=hi),hi+=n),_i=pi===ti&&(gi===ti||gi===Ke)||gi===ti&&pi!==ii,wi=!(pi!==ei&&pi!==ti||gi!==si&&gi!==ii),li=yi&&o?d-o:d,t&&d&&di+ri+hi>li&&(i?(ri&&Bi(),di&&Ri()):(wi||(wi=pi===Ke&&gi==ii),_i||wi||pi===ni||pi===ei||pi===ti||ri+hi>li?(ri&&Bi(),di&&Ri()):di&&Ri()))," "===ci&&!0!==yi&&di+ri===0||(pi===ni?(" "===ci&&ri&&Bi(),bi(ci,hi),Bi()):_i||wi?(ri&&Bi(),bi(ci,hi)):bi(ci,hi)),gi=pi);ri&&Bi(),di&&Ri(),xi.length>0&&(xi[xi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{mi.paraNumber++,xi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,e),l&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Wi(e,"x",t[Ci]);break;case"right":Wi(e,"x",-t[Ai])}if(!n)switch(i.verticalAlign){case"top":Wi(e,"y",t[Li]);break;case"bottom":Wi(e,"y",-t[Oi])}}(l,c,e,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=s,y=n*i.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=i.length;o<l;o++){if(h=i[o],h.x=p,h.width<_||h.width>_&&!r)switch(d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=n,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(c,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;n.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?ki:l>.01?Ei:Si,t.isOverflow&&!r&&(t.textMode=!0),h===Si?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ei?(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,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,c=s+n-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<c));s--){if(d<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,s,o),"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}}(c,e),c}};const Mi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:Di,addPoint:Ii,toBounds:Pi}=W;const Fi={export(t,e,s){this.running=!0;const n=c.fileType(e),o=e.includes(".");return s=c.getExportOptions(s),function(t){zi||(zi=new T);return new Promise((e=>{zi.add((()=>te(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((d=>{const l=t=>{a(t),d(),this.running=!1},{toURL:h}=i,{download:u}=i.origin;if("json"===n)return o&&u(h(JSON.stringify(t.toJSON(s.json)),"text"),e),l({data:!!o||t.toJSON(s.json)});if("svg"===n)return o&&u(h(t.toSVG(),"svg"),e),l({data:!!o||t.toSVG()});const{leafer:f}=t;f?(Vi(t),f.waitViewCompleted((()=>te(this,void 0,void 0,(function*(){let i,n,o=1,a=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=s,w=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=h&&v&&void 0===s.fill?t.fill:s.fill,b=c.isOpaqueImage(e)||x,B=new M;if(v)i=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let e=s.relative||(h?"inner":"local");switch(o=d.scaleX,a=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,a/=t.scaleY;break;case"world":o=1,a=1;break;case"page":e=t.leafer;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,a/=a/i.scaleY}i=t.getBounds("render",e)}const R={scaleX:1,scaleY:1};E.getScaleData(s.scale,s.size,i,R);let k=s.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:S,y:L,width:A,height:O}=new y(i).scale(R.scaleX,R.scaleY),C={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-S,-L).withScale(1/o*R.scaleX,1/a*R.scaleY)};let W,T=r.canvas({width:Math.round(A),height:Math.round(O),pixelRatio:k,smooth:w,contextSettings:m});if(p&&(W=t,W.__worldOpacity=0,t=f,C.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,C),t.fill=e}else t.__render(T,C);if(T.restore(),W&&W.__updateWorldOpacity(),g){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Ii(a,n,o):Di(a={},n,o)),r++;const d=new y;return Pi(a,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:k};T=r.canvas(s),T.copyWorld(t,n,s)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),_&&_(T);const D="canvas"===e?T:yield T.export(e,s);l({data:D,width:T.pixelWidth,height:T.pixelHeight,renderBounds:i,trimBounds:n})}))))):l({data:!1})}))))}};let zi;function Vi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Vi(t)))}const Yi=e.prototype,Ui=t.get("@leafer-ui/export");Yi.export=function(t,e){const{quality:i,blob:s}=c.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Yi.toBlob=function(t,e){return new Promise((s=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{s(t)})).catch((t=>{Ui.error(t),s(null)}))}))},Yi.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Yi.saveAs=function(t,e){return new Promise((s=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{s(!0)})).catch((t=>{Ui.error(t),s(!1)}))}))},Object.assign(V,Ti),Object.assign(I,Mi),Object.assign(Y,xt),Object.assign(D,ie),Object.assign(P,ve),Object.assign(U,Le),Object.assign(F,Fi),q();export{rt as Layouter,N as LeaferCanvas,lt as Renderer,Q as Watcher,q as useCanvas};
|