@leafer-draw/miniapp 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/miniapp.cjs +34 -21
- package/dist/miniapp.esm.js +35 -22
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +387 -349
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +7 -7
- package/src/index.ts +2 -0
- package/types/index.d.ts +1 -0
package/dist/miniapp.cjs
CHANGED
|
@@ -365,9 +365,13 @@ function updateBounds(boundsList) {
|
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
367
|
function updateChange(updateList) {
|
|
368
|
+
let layout;
|
|
368
369
|
updateList.list.forEach(leaf => {
|
|
369
|
-
|
|
370
|
+
layout = leaf.__layout;
|
|
371
|
+
if (layout.opacityChanged)
|
|
370
372
|
updateAllWorldOpacity(leaf);
|
|
373
|
+
if (layout.stateStyleChanged)
|
|
374
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
371
375
|
leaf.__updateChange();
|
|
372
376
|
});
|
|
373
377
|
}
|
|
@@ -733,7 +737,6 @@ class Renderer {
|
|
|
733
737
|
core.Platform.requestRender(() => {
|
|
734
738
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
735
739
|
if (this.running) {
|
|
736
|
-
this.target.emit(core.AnimateEvent.FRAME);
|
|
737
740
|
if (this.changed && this.canvas.view)
|
|
738
741
|
this.render();
|
|
739
742
|
this.target.emit(core.RenderEvent.NEXT);
|
|
@@ -1171,6 +1174,8 @@ function getPatternData(paint, box, image) {
|
|
|
1171
1174
|
let { width, height } = image;
|
|
1172
1175
|
if (paint.padding)
|
|
1173
1176
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1177
|
+
if (paint.mode === 'strench')
|
|
1178
|
+
paint.mode = 'stretch';
|
|
1174
1179
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1175
1180
|
const sameBox = box.width === width && box.height === height;
|
|
1176
1181
|
const data = { mode };
|
|
@@ -1199,7 +1204,7 @@ function getPatternData(paint, box, image) {
|
|
|
1199
1204
|
if (offset)
|
|
1200
1205
|
x += offset.x, y += offset.y;
|
|
1201
1206
|
switch (mode) {
|
|
1202
|
-
case '
|
|
1207
|
+
case 'stretch':
|
|
1203
1208
|
if (!sameBox)
|
|
1204
1209
|
width = box.width, height = box.height;
|
|
1205
1210
|
break;
|
|
@@ -1226,7 +1231,7 @@ function getPatternData(paint, box, image) {
|
|
|
1226
1231
|
translate(data.transform, box.x, box.y);
|
|
1227
1232
|
}
|
|
1228
1233
|
}
|
|
1229
|
-
if (scaleX && mode !== '
|
|
1234
|
+
if (scaleX && mode !== 'stretch') {
|
|
1230
1235
|
data.scaleX = scaleX;
|
|
1231
1236
|
data.scaleY = scaleY;
|
|
1232
1237
|
}
|
|
@@ -1330,7 +1335,7 @@ const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
|
1330
1335
|
const { ceil, abs: abs$1 } = Math;
|
|
1331
1336
|
function createPattern(ui, paint, pixelRatio) {
|
|
1332
1337
|
let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1333
|
-
const id = scaleX + '-' + scaleY;
|
|
1338
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1334
1339
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1335
1340
|
scaleX = abs$1(scaleX);
|
|
1336
1341
|
scaleY = abs$1(scaleY);
|
|
@@ -1424,7 +1429,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1424
1429
|
const { abs } = Math;
|
|
1425
1430
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1426
1431
|
const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1427
|
-
|
|
1432
|
+
const { pixelRatio } = canvas;
|
|
1433
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1428
1434
|
return false;
|
|
1429
1435
|
}
|
|
1430
1436
|
else {
|
|
@@ -1432,8 +1438,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1432
1438
|
if (allowPaint) {
|
|
1433
1439
|
if (!data.repeat) {
|
|
1434
1440
|
let { width, height } = data;
|
|
1435
|
-
width *= abs(scaleX) *
|
|
1436
|
-
height *= abs(scaleY) *
|
|
1441
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1442
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1437
1443
|
if (data.scaleX) {
|
|
1438
1444
|
width *= data.scaleX;
|
|
1439
1445
|
height *= data.scaleY;
|
|
@@ -1459,14 +1465,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1459
1465
|
}
|
|
1460
1466
|
else {
|
|
1461
1467
|
if (!paint.style || paint.sync || draw.Export.running) {
|
|
1462
|
-
createPattern(ui, paint,
|
|
1468
|
+
createPattern(ui, paint, pixelRatio);
|
|
1463
1469
|
}
|
|
1464
1470
|
else {
|
|
1465
1471
|
if (!paint.patternTask) {
|
|
1466
1472
|
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1467
1473
|
paint.patternTask = null;
|
|
1468
1474
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1469
|
-
createPattern(ui, paint,
|
|
1475
|
+
createPattern(ui, paint, pixelRatio);
|
|
1470
1476
|
ui.forceUpdate('surface');
|
|
1471
1477
|
}), 300);
|
|
1472
1478
|
}
|
|
@@ -1530,14 +1536,16 @@ function linearGradient(paint, box) {
|
|
|
1530
1536
|
return data;
|
|
1531
1537
|
}
|
|
1532
1538
|
function applyStops(gradient, stops, opacity) {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1539
|
+
if (stops) {
|
|
1540
|
+
let stop;
|
|
1541
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1542
|
+
stop = stops[i];
|
|
1543
|
+
if (typeof stop === 'string') {
|
|
1544
|
+
gradient.addColorStop(i / (len - 1), draw.ColorConvert.string(stop, opacity));
|
|
1545
|
+
}
|
|
1546
|
+
else {
|
|
1547
|
+
gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
|
|
1548
|
+
}
|
|
1541
1549
|
}
|
|
1542
1550
|
}
|
|
1543
1551
|
}
|
|
@@ -2293,10 +2301,15 @@ const TextConvertModule = {
|
|
|
2293
2301
|
};
|
|
2294
2302
|
|
|
2295
2303
|
function string(color, opacity) {
|
|
2296
|
-
|
|
2297
|
-
|
|
2304
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
2305
|
+
if (typeof color === 'string') {
|
|
2306
|
+
if (doOpacity && draw.ColorConvert.object)
|
|
2307
|
+
color = draw.ColorConvert.object(color);
|
|
2308
|
+
else
|
|
2309
|
+
return color;
|
|
2310
|
+
}
|
|
2298
2311
|
let a = color.a === undefined ? 1 : color.a;
|
|
2299
|
-
if (
|
|
2312
|
+
if (doOpacity)
|
|
2300
2313
|
a *= opacity;
|
|
2301
2314
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
2302
2315
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager,
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, 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';
|
|
@@ -366,9 +366,13 @@ function updateBounds(boundsList) {
|
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
368
|
function updateChange(updateList) {
|
|
369
|
+
let layout;
|
|
369
370
|
updateList.list.forEach(leaf => {
|
|
370
|
-
|
|
371
|
+
layout = leaf.__layout;
|
|
372
|
+
if (layout.opacityChanged)
|
|
371
373
|
updateAllWorldOpacity(leaf);
|
|
374
|
+
if (layout.stateStyleChanged)
|
|
375
|
+
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
372
376
|
leaf.__updateChange();
|
|
373
377
|
});
|
|
374
378
|
}
|
|
@@ -734,7 +738,6 @@ class Renderer {
|
|
|
734
738
|
Platform.requestRender(() => {
|
|
735
739
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
|
|
736
740
|
if (this.running) {
|
|
737
|
-
this.target.emit(AnimateEvent.FRAME);
|
|
738
741
|
if (this.changed && this.canvas.view)
|
|
739
742
|
this.render();
|
|
740
743
|
this.target.emit(RenderEvent.NEXT);
|
|
@@ -1172,6 +1175,8 @@ function getPatternData(paint, box, image) {
|
|
|
1172
1175
|
let { width, height } = image;
|
|
1173
1176
|
if (paint.padding)
|
|
1174
1177
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1178
|
+
if (paint.mode === 'strench')
|
|
1179
|
+
paint.mode = 'stretch';
|
|
1175
1180
|
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1176
1181
|
const sameBox = box.width === width && box.height === height;
|
|
1177
1182
|
const data = { mode };
|
|
@@ -1200,7 +1205,7 @@ function getPatternData(paint, box, image) {
|
|
|
1200
1205
|
if (offset)
|
|
1201
1206
|
x += offset.x, y += offset.y;
|
|
1202
1207
|
switch (mode) {
|
|
1203
|
-
case '
|
|
1208
|
+
case 'stretch':
|
|
1204
1209
|
if (!sameBox)
|
|
1205
1210
|
width = box.width, height = box.height;
|
|
1206
1211
|
break;
|
|
@@ -1227,7 +1232,7 @@ function getPatternData(paint, box, image) {
|
|
|
1227
1232
|
translate(data.transform, box.x, box.y);
|
|
1228
1233
|
}
|
|
1229
1234
|
}
|
|
1230
|
-
if (scaleX && mode !== '
|
|
1235
|
+
if (scaleX && mode !== 'stretch') {
|
|
1231
1236
|
data.scaleX = scaleX;
|
|
1232
1237
|
data.scaleY = scaleY;
|
|
1233
1238
|
}
|
|
@@ -1331,7 +1336,7 @@ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
|
1331
1336
|
const { ceil, abs: abs$1 } = Math;
|
|
1332
1337
|
function createPattern(ui, paint, pixelRatio) {
|
|
1333
1338
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1334
|
-
const id = scaleX + '-' + scaleY;
|
|
1339
|
+
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
1335
1340
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1336
1341
|
scaleX = abs$1(scaleX);
|
|
1337
1342
|
scaleY = abs$1(scaleY);
|
|
@@ -1425,7 +1430,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1425
1430
|
const { abs } = Math;
|
|
1426
1431
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1427
1432
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1428
|
-
|
|
1433
|
+
const { pixelRatio } = canvas;
|
|
1434
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1429
1435
|
return false;
|
|
1430
1436
|
}
|
|
1431
1437
|
else {
|
|
@@ -1433,8 +1439,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1433
1439
|
if (allowPaint) {
|
|
1434
1440
|
if (!data.repeat) {
|
|
1435
1441
|
let { width, height } = data;
|
|
1436
|
-
width *= abs(scaleX) *
|
|
1437
|
-
height *= abs(scaleY) *
|
|
1442
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1443
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1438
1444
|
if (data.scaleX) {
|
|
1439
1445
|
width *= data.scaleX;
|
|
1440
1446
|
height *= data.scaleY;
|
|
@@ -1460,14 +1466,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1460
1466
|
}
|
|
1461
1467
|
else {
|
|
1462
1468
|
if (!paint.style || paint.sync || Export.running) {
|
|
1463
|
-
createPattern(ui, paint,
|
|
1469
|
+
createPattern(ui, paint, pixelRatio);
|
|
1464
1470
|
}
|
|
1465
1471
|
else {
|
|
1466
1472
|
if (!paint.patternTask) {
|
|
1467
1473
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1468
1474
|
paint.patternTask = null;
|
|
1469
1475
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1470
|
-
createPattern(ui, paint,
|
|
1476
|
+
createPattern(ui, paint, pixelRatio);
|
|
1471
1477
|
ui.forceUpdate('surface');
|
|
1472
1478
|
}), 300);
|
|
1473
1479
|
}
|
|
@@ -1531,14 +1537,16 @@ function linearGradient(paint, box) {
|
|
|
1531
1537
|
return data;
|
|
1532
1538
|
}
|
|
1533
1539
|
function applyStops(gradient, stops, opacity) {
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1540
|
+
if (stops) {
|
|
1541
|
+
let stop;
|
|
1542
|
+
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1543
|
+
stop = stops[i];
|
|
1544
|
+
if (typeof stop === 'string') {
|
|
1545
|
+
gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
|
|
1546
|
+
}
|
|
1547
|
+
else {
|
|
1548
|
+
gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
|
|
1549
|
+
}
|
|
1542
1550
|
}
|
|
1543
1551
|
}
|
|
1544
1552
|
}
|
|
@@ -2294,10 +2302,15 @@ const TextConvertModule = {
|
|
|
2294
2302
|
};
|
|
2295
2303
|
|
|
2296
2304
|
function string(color, opacity) {
|
|
2297
|
-
|
|
2298
|
-
|
|
2305
|
+
const doOpacity = typeof opacity === 'number' && opacity !== 1;
|
|
2306
|
+
if (typeof color === 'string') {
|
|
2307
|
+
if (doOpacity && ColorConvert.object)
|
|
2308
|
+
color = ColorConvert.object(color);
|
|
2309
|
+
else
|
|
2310
|
+
return color;
|
|
2311
|
+
}
|
|
2299
2312
|
let a = color.a === undefined ? 1 : color.a;
|
|
2300
|
-
if (
|
|
2313
|
+
if (doOpacity)
|
|
2301
2314
|
a *= opacity;
|
|
2302
2315
|
const rgb = color.r + ',' + color.g + ',' + color.b;
|
|
2303
2316
|
return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,AnimateEvent as R,BoundsHelper as S,MatrixHelper as k,MathHelper as E,AlignHelper as L,ImageEvent as A,AroundHelper as W,PointHelper as O,Direction4 as T,TwoPointBoundsHelper as C,TaskProcessor as M,Matrix as P}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as D,ColorConvert as I,PaintGradient as F,Export as z,Group as Y,TextConvert as U,Paint as V,Effect as X}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class N extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:G,fileType:j}=l;function q(t,i){e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(G(j(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class H{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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}=g,{pushAllChildBranch:$,pushAllParent:K}=_;const{worldBounds:tt}=m,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(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}=g,ot=y.get("Layouter");class at{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){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(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 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 c(e));e.emitEvent(new x(i,o,this.times)),at.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){nt(t,!0),t.isBranch?_.updateBounds(t):g.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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=y.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=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 w,rt.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.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 w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.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=b.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.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),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;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(R.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.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 w(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 w(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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.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 lt(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 ct(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?ft(t,!0,e,i):ut(e,i);break;case"inside":ht("inside",t,s,e,i);break;case"outside":ht("outside",t,s,e,i)}}function ht(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?ft(e,!0,n,r):ut(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",lt(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 ut(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 ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ut(i,n):n.stroke(),n.restoreBlendMode()):e?ut(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=at.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:_t,getIntersectData:wt}=S;let mt;function yt(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:I.string(a,r)};case"image":return D.image(i,t,e,n,!mt||!mt[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:I.string(e)}:void 0}}const vt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),mt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=yt(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?lt(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&&D.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?lt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?lt(e,i):s?i.fill(s):i.fill())},fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ct(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)ct(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(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),ft(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:ct,drawTextStroke:ut,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=wt(n?pt(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=gt(s,a),o=_t(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 xt={};const{get:bt,rotateOfOuter:Bt,translate:Rt,scaleOfOuter:St,scale:kt,rotate:Et}=k;function Lt(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),kt(r,s,o),a&&Bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function At(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),s&&kt(r,s,o),a&&Et(r,a),t.transform=r}function Wt(t,e,i,n,s,o,a,r,d,l){const c=bt();if(d)if("center"===l)Bt(c,{x:i/2,y:n/2},d);else switch(Et(c,d),d){case 90:Rt(c,n,0);break;case 180:Rt(c,i,n);break;case 270:Rt(c,0,i)}xt.x=e.x+s,xt.y=e.y+o,Rt(c,xt.x,xt.y),a&&St(c,xt,a,r),t.transform=c}const{get:Ot,translate:Tt}=k,Ct=new w,Mt={},Pt={};function Dt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=It(i,n,e)}function It(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ct.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 m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(E.getScaleData(l,c,i,Pt),m=Pt.scaleX,y=Pt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),L.toPoint(r,t,e,Mt,!0),v+=Mt.x,x+=Mt.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||m||h)&&At(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&Wt(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Lt(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Ot(),Tt(p.transform,e.x,e.y)),m&&"strench"!==a&&(p.scaleX=m,p.scaleY=y),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 Ft,zt=new w;const{isSame:Yt}=S;function Ut(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||Dt(s,n,i,o),!0}function Vt(t,e){Gt(t,A.LOAD,e)}function Xt(t,e){Gt(t,A.LOADED,e)}function Nt(t,e,i){e.error=i,t.forceUpdate("surface"),Gt(t,A.ERROR,e)}function Gt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:qt,scale:Ht,copy:Qt}=k,{ceil:Jt,abs:Zt}=Math;function $t(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Zt(s),o=Zt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=qt(),Qt(l,g),Ht(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=qt(),g&&Qt(l,g)),Ht(l,1/s,1/o));const y=t.getCanvas(Jt(c)||1,Jt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function Kt(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:te}=Math;const ee={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return Ft&&i===Ft.paint&&Yt(n,Ft.boxBounds)?o=Ft.leafPaint:(o={type:i.type,image:r},Ft=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ut(t,e,i,r,o,n),s&&(Vt(t,a),Xt(t,a))):r.error?s&&Nt(t,a,r.error):(jt(t,!0),s&&Vt(t,a),o.loadId=r.load((()=>{jt(t,!1),t.destroyed||(Ut(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Xt(t,a)),o.loadId=null}),(e=>{jt(t,!1),Nt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,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*=te(o)*i.pixelRatio,n*=te(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize||z.running}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.sync||z.running?$t(t,n,i.pixelRatio):n.patternTask||(n.patternTask=B.patternTasker.add((()=>Kt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&$t(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}},createPattern:$t,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:Dt,getPatternData:It,fillOrFitMode:Lt,clipMode:At,repeatMode:Wt},{toPoint:ie}=W,ne={},se={};function oe(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),I.string(n,i)):t.addColorStop(n.offset,I.string(n.color,i))}const{getAngle:ae,getDistance:re}=O,{get:de,rotateOfOuter:le,scaleOfOuter:ce}=k,{toPoint:he}=W,ue={},fe={};function pe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ae(e,i);o=de(),s?(ce(o,e,a/r*(n||1),1),le(o,e,t+90)):(ce(o,e,1,a/r*(n||1)),le(o,e,t))}return o}const{getDistance:ge}=O,{toPoint:_e}=W,we={},me={};const ye={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ie(n||"top",i,ne),ie(s||"bottom",i,se);const d=e.canvas.createLinearGradient(ne.x,ne.y,se.x,se.y);oe(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;he(n||"center",i,ue),he(s||"bottom",i,fe);const l=e.canvas.createRadialGradient(ue.x,ue.y,0,ue.x,ue.y,re(ue,fe));oe(l,t.stops,a);const c={type:o,style:l},h=pe(i,ue,fe,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;_e(n||"center",i,we),_e(s||"bottom",i,me);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,we.x,we.y):e.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,ge(we,me));oe(l,t.stops,a);const c={type:o,style:l},h=pe(i,we,me,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:pe},{copy:ve,toOffsetOutBounds:xe}=S,be={},Be={};function Re(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ve(be,t.bounds),be.x+=i.x-a.x,be.y+=i.y-a.y,n){const{matrix:t}=s;be.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),be.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),be.width*=n,be.height*=n}t.copyWorld(s.canvas,t.bounds,be)}else n&&(ve(be,i),be.x-=i.width/2*(n-1),be.y-=i.height/2*(n-1),be.width*=n,be.height*=n),t.copyWorld(s.canvas,a,n?be:i)}const{toOffsetOutBounds:Se}=S,ke={};const Ee={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;xe(l,Be),r.forEach(((r,g)=>{f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(f,Be,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,ke),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(f,ke,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:Le}=m;function Ae(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),Oe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Oe(t,i,n,o);break;case"path":i.restore()}}function We(t){return t.getSameCanvas(!1,!0)}function Oe(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,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Ae(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=We(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=We(t)),s||(s=We(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Le(i,e)||i.__render(s||t,e);Ae(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=Te+"_#~&*+\\=|≮≯≈≠=…",Me=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Pe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const De=Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ie=Pe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Fe=Pe(Te),ze=Pe(Ce),Ye=Pe("- —/~|┆·");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:Ve,Single:Xe,Before:Ne,After:Ge,Symbol:je,Break:qe}=Ue;function He(t){return De[t]?Ve:Ye[t]?qe:Ie[t]?Ne:Fe[t]?Ge:ze[t]?je:Me.test(t)?Xe:Ve}const Qe={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 Je(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:Ze}=Qe,{Letter:$e,Single:Ke,Before:ti,After:ei,Symbol:ii,Break:ni}=Ue;let si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi,vi=[];function xi(t,e){ui&&!hi&&(hi=ui),si.data.push({char:t,width:e}),ai+=e}function bi(){ri+=ai,si.width=ai,oi.words.push(si),si={data:[]},ai=0}function Bi(){wi&&(mi.paraNumber++,oi.paraStart=!0,wi=!1),ui&&(oi.startCharSize=hi,oi.endCharSize=ui,hi=0),oi.width=ri,yi.width&&Ze(oi),vi.push(oi),oi={words:[]},ri=0}const Ri=0,Si=1,ki=2;const{top:Ei,right:Li,bottom:Ai,left:Wi}=T;function Oi(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 Ti={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Wi],o-=l[Li]+l[Wi]),a&&(s=l[Ei],a-=l[Ei]+l[Ai]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){mi=t,vi=t.rows,yi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=yi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;wi=!0,pi=null,hi=ci=ui=ai=ri=0,si={data:[]},oi={words:[]};for(let n=0,l=i.length;n<l;n++)li=i[n],"\n"===li?(ai&&bi(),oi.paraEnd=!0,Bi(),wi=!0):(fi=He(li),fi===$e&&"none"!==a&&(li=Je(li,a,!ai)),ci=r.measureText(li).width,s&&(s<0&&(ui=ci),ci+=s),gi=fi===Ke&&(pi===Ke||pi===$e)||pi===Ke&&fi!==ei,_i=!(fi!==ti&&fi!==Ke||pi!==ii&&pi!==ei),di=wi&&o?d-o:d,t&&d&&ri+ai+ci>di&&(e?(ai&&bi(),ri&&Bi()):(_i||(_i=fi===$e&&pi==ei),gi||_i||fi===ni||fi===ti||fi===Ke||ai+ci>di?(ai&&bi(),ri&&Bi()):ri&&Bi()))," "===li&&!0!==wi&&ri+ai===0||(fi===ni?(" "===li&&ai&&bi(),xi(li,ci),bi()):gi||_i?(ai&&bi(),xi(li,ci)):xi(li,ci)),pi=fi);ai&&bi(),ri&&Bi(),vi.length>0&&(vi[vi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{mi.paraNumber++,vi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Oi(e,"x",t[Wi]);break;case"right":Oi(e,"x",-t[Li])}if(!s)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ei]);break;case"bottom":Oi(e,"y",-t[Ai])}}(l,c,i,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,m=s*i.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}y+=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&&(y+=c),h.y=y,y+=s,t.overflow>o&&y>m&&(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=m}(c,i),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?Ri:l>.01?Si:ki,t.isOverflow&&!r&&(t.textMode=!0),h===ki?(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,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.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,i,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,i),c}};const Ci={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:Mi,addPoint:Pi,toBounds:Di}=C;const Ii={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Fi||(Fi=new M);return new Promise((e=>{Fi.add((()=>Kt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(zi(t),f.waitViewCompleted((()=>Kt(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new P;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};E.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:k,y:L,width:A,height:W}=new w(e).scale(R.scaleX,R.scaleY),O={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-k,-L).withScale(1/o*R.scaleX,1/r*R.scaleY)};let T,C=a.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(T=t,T.__worldOpacity=0,t=f,O.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,O),t.fill=e}else t.__render(C,O);if(C.restore(),T&&T.__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):Mi(a={},s,o)),r++;const d=new w;return Di(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const M="canvas"===i?C:yield C.export(i,n);c({data:M,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Fi;function zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>zi(t)))}const Yi=t.prototype,Ui=y.get("@leafer-ui/export");Yi.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Yi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Ui.error(t),n(null)}))}))},Yi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Yi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Ui.error(t),n(!1)}))}))},Object.assign(U,Ti),Object.assign(I,Ci),Object.assign(V,vt),Object.assign(D,ee),Object.assign(F,ye),Object.assign(X,Ee),Object.assign(z,Ii);try{wx&&q(0,wx)}catch(t){}export{at as Layouter,N as LeaferCanvas,dt as Renderer,H as Watcher,q as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as d,FileHelper as l,LeafList as c,RenderEvent as h,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as S,MathHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as T,TwoPointBoundsHelper as O,TaskProcessor as C,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as z,Group as F,TextConvert as Y,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:s,pixelRatio:o}=this.config,a={width:n||t.width,height:s||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:G}=l;function j(t,i){e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(N(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new X(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},d(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,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(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:H,updateBounds:Q,updateAllWorldOpacity:J}=g,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:K}=m,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,K)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,K),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:it,updateAllChange:nt}=g,st=y.get("Layouter");class ot{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){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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?(H(t,!0),e.add(t),t.isBranch&&Z(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||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&J(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),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 c(e));e.emitEvent(new x(i,o,this.times)),ot.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){it(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(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_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=y.get("Renderer");class rt{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 w,at.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.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 at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new w(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.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),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;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.changed&&this.canvas.view&&this.render(),this.target.emit(h.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 w(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 w(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||at.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 h(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(h.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 dt(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 lt(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?ut(t,!0,e,i):ht(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(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?ut(e,!0,n,r):ht(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(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 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.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 ut(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ht(i,n):n.stroke(),n.restoreBlendMode()):e?ht(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:gt,getIntersectData:_t}=R;let wt;function mt(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:D.string(a,r)};case"image":return P.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const yt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),wt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=mt(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?dt(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&&P.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?dt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?dt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?dt(e,i):s?i.fill(s):i.fill())},fillText:dt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)lt(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)lt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ut(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ut(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),ut(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:lt,drawTextStroke:ht,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=_t(n?ft(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=pt(s,a),o=gt(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 vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:St,rotate:kt}=S;function Et(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),St(r,s,o),a&&bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Lt(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&St(r,s,o),a&&kt(r,a),t.transform=r}function At(t,e,i,n,s,o,a,r,d,l){const c=xt();if(d)if("center"===l)bt(c,{x:i/2,y:n/2},d);else switch(kt(c,d),d){case 90:Bt(c,n,0);break;case 180:Bt(c,i,n);break;case 270:Bt(c,0,i)}vt.x=e.x+s,vt.y=e.y+o,Bt(c,vt.x,vt.y),a&&Rt(c,vt,a,r),t.transform=c}const{get:Wt,translate:Tt}=S,Ot=new w,Ct={},Mt={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(i,n,e)}function Dt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ot.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===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,i,Mt),m=Mt.scaleX,y=Mt.scaleY);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Ct,!0),v+=Ct.x,x+=Ct.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||m||h)&&Lt(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&At(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&Et(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Tt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=y),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 It,zt=new w;const{isSame:Ft}=R;function Yt(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||Pt(s,n,i,o),!0}function Ut(t,e){Nt(t,L.LOAD,e)}function Vt(t,e){Nt(t,L.LOADED,e)}function Xt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,L.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Gt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=S,{ceil:Qt,abs:Jt}=Math;function Zt(t,i,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const y=t.getCanvas(Qt(c)||1,Qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function $t(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:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return It&&i===It.paint&&Ft(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Yt(t,e,i,r,o,n),s&&(Ut(t,a),Vt(t,a))):r.error?s&&Xt(t,a,r.error):(Gt(t,!0),s&&Ut(t,a),o.loadId=r.load((()=>{Gt(t,!1),t.destroyed||(Yt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,a)),o.loadId=null}),(e=>{Gt(t,!1),Xt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=Kt(o)*r,i*=Kt(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||z.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||z.running?Zt(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Zt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Zt,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:Pt,getPatternData:Dt,fillOrFitMode:Et,clipMode:Lt,repeatMode:At},{toPoint:ee}=A,ie={},ne={};function se(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:oe,getDistance:ae}=W,{get:re,rotateOfOuter:de,scaleOfOuter:le}=S,{toPoint:ce}=A,he={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=W,{toPoint:ge}=A,_e={},we={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",i,ie),ee(s||"bottom",i,ne);const d=e.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ce(n||"center",i,he),ce(s||"bottom",i,ue);const l=e.canvas.createRadialGradient(he.x,he.y,0,he.x,he.y,ae(he,ue));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,he,ue,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,_e),ge(s||"bottom",i,we);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const c={type:o,style:l},h=fe(i,_e,we,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:fe},{copy:ye,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(xe,t.bounds),xe.x+=i.x-a.x,xe.y+=i.y-a.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(ye(xe,i),xe.x-=i.width/2*(n-1),xe.y-=i.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:i)}const{toOffsetOutBounds:Re}=R,Se={};const ke={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;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,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;Re(l,Se),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Se.offsetX+r.x*h,Se.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,Se,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:Ee}=m;function Le(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),We(t,e,i,1)}(t,i,n,s);break;case"opacity-path":We(t,i,n,o);break;case"path":i.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function We(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.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&&(Le(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ae(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ae(t)),s||(s=Ae(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ee(i,e)||i.__render(s||t,e);Le(this,a,t,s,n,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Ce=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Pe=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Me(Te),ze=Me(Oe),Fe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Ve,Before:Xe,After:Ne,Symbol:Ge,Break:je}=Ye;function qe(t){return Pe[t]?Ue:Fe[t]?je:De[t]?Xe:Ie[t]?Ne:ze[t]?Ge:Ce.test(t)?Ve:Ue}const He={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 Qe(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:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=Ye;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi,mi,yi=[];function vi(t,e){hi&&!ci&&(ci=hi),ni.data.push({char:t,width:e}),oi+=e}function xi(){ai+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),hi&&(si.startCharSize=ci,si.endCharSize=hi,ci=0),si.width=ai,mi.width&&Je(si),yi.push(si),si={words:[]},ai=0}const Bi=0,Ri=1,Si=2;const{top:ki,right:Ei,bottom:Li,left:Ai}=T;function Wi(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 Ti={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Ai],o-=l[Ei]+l[Ai]),a&&(s=l[ki],a-=l[ki]+l[Li]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){wi=t,yi=t.rows,mi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;_i=!0,fi=null,ci=li=hi=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=i.length;n<l;n++)di=i[n],"\n"===di?(oi&&xi(),si.paraEnd=!0,bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(hi=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&xi(),ai&&bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&xi(),ai&&bi()):ai&&bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&xi(),vi(di,li),xi()):pi||gi?(oi&&xi(),vi(di,li)):vi(di,li)),fi=ui);oi&&xi(),ai&&bi(),yi.length>0&&(yi[yi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,yi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Wi(e,"x",t[Ai]);break;case"right":Wi(e,"x",-t[Ei])}if(!s)switch(i.verticalAlign){case"top":Wi(e,"y",t[ki]);break;case"bottom":Wi(e,"y",-t[Li])}}(l,c,i,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,m=s*i.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}y+=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&&(y+=c),h.y=y,y+=s,t.overflow>o&&y>m&&(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=m}(c,i),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?Bi:l>.01?Ri: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===Ri?(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,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.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,i,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,i),c}};const Oi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:Ci,addPoint:Mi,toBounds:Pi}=O;const Di={export(t,i,n){this.running=!0;const s=l.fileType(i),o=i.includes(".");return n=l.getExportOptions(n),function(t){Ii||(Ii=new C);return new Promise((e=>{Ii.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const c=t=>{r(t),d(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),i),c({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(zi(t),f.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let e,s,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:_}=n,m=void 0===n.smooth?f.config.smooth:n.smooth,y=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,i){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(d).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};k.getScaleData(n.scale,n.size,e,R);let S=n.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:L,width:A,height:W}=new w(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/o*R.scaleX,1/r*R.scaleY)};let O,C=a.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:S,smooth:m,contextSettings:y});if(p&&(O=t,O.__worldOpacity=0,t=f,T.bounds=C.bounds),C.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(C,T),t.fill=e}else t.__render(C,T);if(C.restore(),O&&O.__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?Mi(a,s,o):Ci(a={},s,o)),r++;const d=new w;return Pi(a,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:S};C=a.canvas(n),C.copyWorld(t,s,n)}b&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),_&&_(C);const P="canvas"===i?C:yield C.export(i,n);c({data:P,width:C.pixelWidth,height:C.pixelHeight,renderBounds:e,trimBounds:s})}))))):c({data:!1})}))))}};let Ii;function zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>zi(t)))}const Fi=t.prototype,Yi=y.get("@leafer-ui/export");Fi.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Fi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Yi.error(t),n(null)}))}))},Fi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Fi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Yi.error(t),n(!1)}))}))},Object.assign(Y,Ti),Object.assign(D,Oi),Object.assign(U,yt),Object.assign(P,te),Object.assign(I,me),Object.assign(V,ke),Object.assign(z,Di);try{wx&&j(0,wx)}catch(t){}export{ot as Layouter,X as LeaferCanvas,rt as Renderer,q as Watcher,j as useCanvas};
|