@leafer-draw/node 1.0.0-rc.25 → 1.0.0-rc.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node.cjs +69 -48
- package/dist/node.esm.js +69 -48
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +6 -6
package/dist/node.cjs
CHANGED
|
@@ -967,7 +967,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
967
967
|
case 'angular':
|
|
968
968
|
return draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
969
969
|
default:
|
|
970
|
-
return paint.r ? { type: 'solid', style: draw.ColorConvert.string(paint) } : undefined;
|
|
970
|
+
return paint.r !== undefined ? { type: 'solid', style: draw.ColorConvert.string(paint) } : undefined;
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
|
|
@@ -984,17 +984,17 @@ const PaintModule = {
|
|
|
984
984
|
};
|
|
985
985
|
|
|
986
986
|
let origin = {};
|
|
987
|
-
const { get: get$
|
|
987
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = core.MatrixHelper;
|
|
988
988
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
989
|
-
const transform = get$
|
|
989
|
+
const transform = get$3();
|
|
990
990
|
translate$1(transform, box.x + x, box.y + y);
|
|
991
991
|
scaleHelper(transform, scaleX, scaleY);
|
|
992
992
|
if (rotation)
|
|
993
|
-
rotateOfOuter$
|
|
993
|
+
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
994
994
|
data.transform = transform;
|
|
995
995
|
}
|
|
996
996
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
997
|
-
const transform = get$
|
|
997
|
+
const transform = get$3();
|
|
998
998
|
translate$1(transform, box.x + x, box.y + y);
|
|
999
999
|
if (scaleX)
|
|
1000
1000
|
scaleHelper(transform, scaleX, scaleY);
|
|
@@ -1003,10 +1003,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1003
1003
|
data.transform = transform;
|
|
1004
1004
|
}
|
|
1005
1005
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
1006
|
-
const transform = get$
|
|
1006
|
+
const transform = get$3();
|
|
1007
1007
|
if (rotation) {
|
|
1008
1008
|
if (align === 'center') {
|
|
1009
|
-
rotateOfOuter$
|
|
1009
|
+
rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
1010
1010
|
}
|
|
1011
1011
|
else {
|
|
1012
1012
|
rotate(transform, rotation);
|
|
@@ -1027,22 +1027,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1027
1027
|
origin.y = box.y + y;
|
|
1028
1028
|
translate$1(transform, origin.x, origin.y);
|
|
1029
1029
|
if (scaleX)
|
|
1030
|
-
scaleOfOuter$
|
|
1030
|
+
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
1031
1031
|
data.transform = transform;
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
|
-
const { get: get$
|
|
1034
|
+
const { get: get$2, translate } = core.MatrixHelper;
|
|
1035
1035
|
const tempBox = new core.Bounds();
|
|
1036
1036
|
const tempPoint = {};
|
|
1037
1037
|
function createData(leafPaint, image, paint, box) {
|
|
1038
|
+
const { blendMode } = paint;
|
|
1039
|
+
if (blendMode)
|
|
1040
|
+
leafPaint.blendMode = blendMode;
|
|
1041
|
+
leafPaint.data = getPatternData(paint, box, image);
|
|
1042
|
+
}
|
|
1043
|
+
function getPatternData(paint, box, image) {
|
|
1038
1044
|
let { width, height } = image;
|
|
1039
1045
|
if (paint.padding)
|
|
1040
1046
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1041
|
-
const { opacity, mode, align, offset, scale, size, rotation,
|
|
1047
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1042
1048
|
const sameBox = box.width === width && box.height === height;
|
|
1043
|
-
|
|
1044
|
-
leafPaint.blendMode = blendMode;
|
|
1045
|
-
const data = leafPaint.data = { mode };
|
|
1049
|
+
const data = { mode };
|
|
1046
1050
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1047
1051
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
1048
1052
|
let x = 0, y = 0, scaleX, scaleY;
|
|
@@ -1094,7 +1098,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1094
1098
|
}
|
|
1095
1099
|
if (!data.transform) {
|
|
1096
1100
|
if (box.x || box.y) {
|
|
1097
|
-
data.transform = get$
|
|
1101
|
+
data.transform = get$2();
|
|
1098
1102
|
translate(data.transform, box.x, box.y);
|
|
1099
1103
|
}
|
|
1100
1104
|
}
|
|
@@ -1108,6 +1112,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1108
1112
|
data.opacity = opacity;
|
|
1109
1113
|
if (repeat)
|
|
1110
1114
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1115
|
+
return data;
|
|
1111
1116
|
}
|
|
1112
1117
|
|
|
1113
1118
|
let cache, box = new core.Bounds();
|
|
@@ -1197,7 +1202,7 @@ function ignoreRender(ui, value) {
|
|
|
1197
1202
|
leafer.renderer.ignore = value;
|
|
1198
1203
|
}
|
|
1199
1204
|
|
|
1200
|
-
const { get: get$
|
|
1205
|
+
const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
|
|
1201
1206
|
const { ceil, abs: abs$1 } = Math;
|
|
1202
1207
|
function createPattern(ui, paint, pixelRatio) {
|
|
1203
1208
|
let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
@@ -1208,7 +1213,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1208
1213
|
const { image, data } = paint;
|
|
1209
1214
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
1210
1215
|
if (sx) {
|
|
1211
|
-
imageMatrix = get$
|
|
1216
|
+
imageMatrix = get$1();
|
|
1212
1217
|
copy$1(imageMatrix, transform);
|
|
1213
1218
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
1214
1219
|
scaleX *= sx;
|
|
@@ -1243,7 +1248,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1243
1248
|
}
|
|
1244
1249
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1245
1250
|
if (!imageMatrix) {
|
|
1246
|
-
imageMatrix = get$
|
|
1251
|
+
imageMatrix = get$1();
|
|
1247
1252
|
if (transform)
|
|
1248
1253
|
copy$1(imageMatrix, transform);
|
|
1249
1254
|
}
|
|
@@ -1344,13 +1349,14 @@ function recycleImage(attrName, data) {
|
|
|
1344
1349
|
|
|
1345
1350
|
const PaintImageModule = {
|
|
1346
1351
|
image,
|
|
1352
|
+
checkImage,
|
|
1353
|
+
createPattern,
|
|
1354
|
+
recycleImage,
|
|
1347
1355
|
createData,
|
|
1356
|
+
getPatternData,
|
|
1348
1357
|
fillOrFitMode,
|
|
1349
1358
|
clipMode,
|
|
1350
|
-
repeatMode
|
|
1351
|
-
createPattern,
|
|
1352
|
-
checkImage,
|
|
1353
|
-
recycleImage
|
|
1359
|
+
repeatMode
|
|
1354
1360
|
};
|
|
1355
1361
|
|
|
1356
1362
|
const { toPoint: toPoint$2 } = core.AroundHelper;
|
|
@@ -1380,8 +1386,8 @@ function applyStops(gradient, stops, opacity) {
|
|
|
1380
1386
|
}
|
|
1381
1387
|
}
|
|
1382
1388
|
|
|
1383
|
-
const { getAngle
|
|
1384
|
-
const { get
|
|
1389
|
+
const { getAngle, getDistance: getDistance$1 } = core.PointHelper;
|
|
1390
|
+
const { get, rotateOfOuter, scaleOfOuter } = core.MatrixHelper;
|
|
1385
1391
|
const { toPoint: toPoint$1 } = core.AroundHelper;
|
|
1386
1392
|
const realFrom$1 = {};
|
|
1387
1393
|
const realTo$1 = {};
|
|
@@ -1389,23 +1395,35 @@ function radialGradient(paint, box) {
|
|
|
1389
1395
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1390
1396
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1391
1397
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1392
|
-
const { width, height } = box;
|
|
1393
|
-
let transform;
|
|
1394
|
-
if (width !== height || stretch) {
|
|
1395
|
-
transform = get$1();
|
|
1396
|
-
scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
|
|
1397
|
-
rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
|
|
1398
|
-
}
|
|
1399
1398
|
const style = core.Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
1400
1399
|
applyStops(style, paint.stops, opacity);
|
|
1401
|
-
const data = { type, style
|
|
1400
|
+
const data = { type, style };
|
|
1401
|
+
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1402
|
+
if (transform)
|
|
1403
|
+
data.transform = transform;
|
|
1402
1404
|
if (blendMode)
|
|
1403
1405
|
data.blendMode = blendMode;
|
|
1404
1406
|
return data;
|
|
1405
1407
|
}
|
|
1408
|
+
function getTransform(box, from, to, stretch, rotate90) {
|
|
1409
|
+
let transform;
|
|
1410
|
+
const { width, height } = box;
|
|
1411
|
+
if (width !== height || stretch) {
|
|
1412
|
+
const angle = getAngle(from, to);
|
|
1413
|
+
transform = get();
|
|
1414
|
+
if (rotate90) {
|
|
1415
|
+
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
1416
|
+
rotateOfOuter(transform, from, angle + 90);
|
|
1417
|
+
}
|
|
1418
|
+
else {
|
|
1419
|
+
scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
|
|
1420
|
+
rotateOfOuter(transform, from, angle);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return transform;
|
|
1424
|
+
}
|
|
1406
1425
|
|
|
1407
|
-
const {
|
|
1408
|
-
const { get, rotateOfOuter, scaleOfOuter } = core.MatrixHelper;
|
|
1426
|
+
const { getDistance } = core.PointHelper;
|
|
1409
1427
|
const { toPoint } = core.AroundHelper;
|
|
1410
1428
|
const realFrom = {};
|
|
1411
1429
|
const realTo = {};
|
|
@@ -1413,20 +1431,12 @@ function conicGradient(paint, box) {
|
|
|
1413
1431
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1414
1432
|
toPoint(from || 'center', box, realFrom);
|
|
1415
1433
|
toPoint(to || 'bottom', box, realTo);
|
|
1416
|
-
const { width, height } = box;
|
|
1417
|
-
const transform = get();
|
|
1418
|
-
const angle = getAngle(realFrom, realTo);
|
|
1419
|
-
if (core.Platform.conicGradientRotate90) {
|
|
1420
|
-
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
|
|
1421
|
-
rotateOfOuter(transform, realFrom, angle + 90);
|
|
1422
|
-
}
|
|
1423
|
-
else {
|
|
1424
|
-
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
|
|
1425
|
-
rotateOfOuter(transform, realFrom, angle);
|
|
1426
|
-
}
|
|
1427
1434
|
const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
1428
1435
|
applyStops(style, paint.stops, opacity);
|
|
1429
|
-
const data = { type, style
|
|
1436
|
+
const data = { type, style };
|
|
1437
|
+
const transform = getTransform(box, realFrom, realTo, stretch || 1, core.Platform.conicGradientRotate90);
|
|
1438
|
+
if (transform)
|
|
1439
|
+
data.transform = transform;
|
|
1430
1440
|
if (blendMode)
|
|
1431
1441
|
data.blendMode = blendMode;
|
|
1432
1442
|
return data;
|
|
@@ -1435,7 +1445,8 @@ function conicGradient(paint, box) {
|
|
|
1435
1445
|
const PaintGradientModule = {
|
|
1436
1446
|
linearGradient,
|
|
1437
1447
|
radialGradient,
|
|
1438
|
-
conicGradient
|
|
1448
|
+
conicGradient,
|
|
1449
|
+
getTransform
|
|
1439
1450
|
};
|
|
1440
1451
|
|
|
1441
1452
|
const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = core.BoundsHelper;
|
|
@@ -2161,11 +2172,21 @@ const ExportModule = {
|
|
|
2161
2172
|
resolve();
|
|
2162
2173
|
this.running = false;
|
|
2163
2174
|
};
|
|
2175
|
+
const { toURL } = core.Platform;
|
|
2176
|
+
const { download } = core.Platform.origin;
|
|
2177
|
+
const fileType = core.FileHelper.fileType(filename);
|
|
2164
2178
|
if (filename === 'json') {
|
|
2165
2179
|
return over({ data: leaf.toJSON() });
|
|
2166
2180
|
}
|
|
2167
|
-
else if (
|
|
2168
|
-
|
|
2181
|
+
else if (fileType === 'json') {
|
|
2182
|
+
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
2183
|
+
return over({ data: true });
|
|
2184
|
+
}
|
|
2185
|
+
if (filename === 'svg') {
|
|
2186
|
+
return over({ data: leaf.toSVG() });
|
|
2187
|
+
}
|
|
2188
|
+
else if (fileType === 'svg') {
|
|
2189
|
+
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
2169
2190
|
return over({ data: true });
|
|
2170
2191
|
}
|
|
2171
2192
|
const { leafer } = leaf;
|
package/dist/node.esm.js
CHANGED
|
@@ -968,7 +968,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
968
968
|
case 'angular':
|
|
969
969
|
return PaintGradient.conicGradient(paint, boxBounds);
|
|
970
970
|
default:
|
|
971
|
-
return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
971
|
+
return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
|
|
@@ -985,17 +985,17 @@ const PaintModule = {
|
|
|
985
985
|
};
|
|
986
986
|
|
|
987
987
|
let origin = {};
|
|
988
|
-
const { get: get$
|
|
988
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
989
989
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
990
|
-
const transform = get$
|
|
990
|
+
const transform = get$3();
|
|
991
991
|
translate$1(transform, box.x + x, box.y + y);
|
|
992
992
|
scaleHelper(transform, scaleX, scaleY);
|
|
993
993
|
if (rotation)
|
|
994
|
-
rotateOfOuter$
|
|
994
|
+
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
995
995
|
data.transform = transform;
|
|
996
996
|
}
|
|
997
997
|
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
998
|
-
const transform = get$
|
|
998
|
+
const transform = get$3();
|
|
999
999
|
translate$1(transform, box.x + x, box.y + y);
|
|
1000
1000
|
if (scaleX)
|
|
1001
1001
|
scaleHelper(transform, scaleX, scaleY);
|
|
@@ -1004,10 +1004,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1004
1004
|
data.transform = transform;
|
|
1005
1005
|
}
|
|
1006
1006
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
1007
|
-
const transform = get$
|
|
1007
|
+
const transform = get$3();
|
|
1008
1008
|
if (rotation) {
|
|
1009
1009
|
if (align === 'center') {
|
|
1010
|
-
rotateOfOuter$
|
|
1010
|
+
rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
|
|
1011
1011
|
}
|
|
1012
1012
|
else {
|
|
1013
1013
|
rotate(transform, rotation);
|
|
@@ -1028,22 +1028,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1028
1028
|
origin.y = box.y + y;
|
|
1029
1029
|
translate$1(transform, origin.x, origin.y);
|
|
1030
1030
|
if (scaleX)
|
|
1031
|
-
scaleOfOuter$
|
|
1031
|
+
scaleOfOuter$1(transform, origin, scaleX, scaleY);
|
|
1032
1032
|
data.transform = transform;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
|
-
const { get: get$
|
|
1035
|
+
const { get: get$2, translate } = MatrixHelper;
|
|
1036
1036
|
const tempBox = new Bounds();
|
|
1037
1037
|
const tempPoint = {};
|
|
1038
1038
|
function createData(leafPaint, image, paint, box) {
|
|
1039
|
+
const { blendMode } = paint;
|
|
1040
|
+
if (blendMode)
|
|
1041
|
+
leafPaint.blendMode = blendMode;
|
|
1042
|
+
leafPaint.data = getPatternData(paint, box, image);
|
|
1043
|
+
}
|
|
1044
|
+
function getPatternData(paint, box, image) {
|
|
1039
1045
|
let { width, height } = image;
|
|
1040
1046
|
if (paint.padding)
|
|
1041
1047
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1042
|
-
const { opacity, mode, align, offset, scale, size, rotation,
|
|
1048
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1043
1049
|
const sameBox = box.width === width && box.height === height;
|
|
1044
|
-
|
|
1045
|
-
leafPaint.blendMode = blendMode;
|
|
1046
|
-
const data = leafPaint.data = { mode };
|
|
1050
|
+
const data = { mode };
|
|
1047
1051
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1048
1052
|
const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
|
|
1049
1053
|
let x = 0, y = 0, scaleX, scaleY;
|
|
@@ -1095,7 +1099,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1095
1099
|
}
|
|
1096
1100
|
if (!data.transform) {
|
|
1097
1101
|
if (box.x || box.y) {
|
|
1098
|
-
data.transform = get$
|
|
1102
|
+
data.transform = get$2();
|
|
1099
1103
|
translate(data.transform, box.x, box.y);
|
|
1100
1104
|
}
|
|
1101
1105
|
}
|
|
@@ -1109,6 +1113,7 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1109
1113
|
data.opacity = opacity;
|
|
1110
1114
|
if (repeat)
|
|
1111
1115
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1116
|
+
return data;
|
|
1112
1117
|
}
|
|
1113
1118
|
|
|
1114
1119
|
let cache, box = new Bounds();
|
|
@@ -1198,7 +1203,7 @@ function ignoreRender(ui, value) {
|
|
|
1198
1203
|
leafer.renderer.ignore = value;
|
|
1199
1204
|
}
|
|
1200
1205
|
|
|
1201
|
-
const { get: get$
|
|
1206
|
+
const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
|
|
1202
1207
|
const { ceil, abs: abs$1 } = Math;
|
|
1203
1208
|
function createPattern(ui, paint, pixelRatio) {
|
|
1204
1209
|
let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
@@ -1209,7 +1214,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1209
1214
|
const { image, data } = paint;
|
|
1210
1215
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
|
|
1211
1216
|
if (sx) {
|
|
1212
|
-
imageMatrix = get$
|
|
1217
|
+
imageMatrix = get$1();
|
|
1213
1218
|
copy$1(imageMatrix, transform);
|
|
1214
1219
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
1215
1220
|
scaleX *= sx;
|
|
@@ -1244,7 +1249,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1244
1249
|
}
|
|
1245
1250
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1246
1251
|
if (!imageMatrix) {
|
|
1247
|
-
imageMatrix = get$
|
|
1252
|
+
imageMatrix = get$1();
|
|
1248
1253
|
if (transform)
|
|
1249
1254
|
copy$1(imageMatrix, transform);
|
|
1250
1255
|
}
|
|
@@ -1345,13 +1350,14 @@ function recycleImage(attrName, data) {
|
|
|
1345
1350
|
|
|
1346
1351
|
const PaintImageModule = {
|
|
1347
1352
|
image,
|
|
1353
|
+
checkImage,
|
|
1354
|
+
createPattern,
|
|
1355
|
+
recycleImage,
|
|
1348
1356
|
createData,
|
|
1357
|
+
getPatternData,
|
|
1349
1358
|
fillOrFitMode,
|
|
1350
1359
|
clipMode,
|
|
1351
|
-
repeatMode
|
|
1352
|
-
createPattern,
|
|
1353
|
-
checkImage,
|
|
1354
|
-
recycleImage
|
|
1360
|
+
repeatMode
|
|
1355
1361
|
};
|
|
1356
1362
|
|
|
1357
1363
|
const { toPoint: toPoint$2 } = AroundHelper;
|
|
@@ -1381,8 +1387,8 @@ function applyStops(gradient, stops, opacity) {
|
|
|
1381
1387
|
}
|
|
1382
1388
|
}
|
|
1383
1389
|
|
|
1384
|
-
const { getAngle
|
|
1385
|
-
const { get
|
|
1390
|
+
const { getAngle, getDistance: getDistance$1 } = PointHelper;
|
|
1391
|
+
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
1386
1392
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
1387
1393
|
const realFrom$1 = {};
|
|
1388
1394
|
const realTo$1 = {};
|
|
@@ -1390,23 +1396,35 @@ function radialGradient(paint, box) {
|
|
|
1390
1396
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1391
1397
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1392
1398
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1393
|
-
const { width, height } = box;
|
|
1394
|
-
let transform;
|
|
1395
|
-
if (width !== height || stretch) {
|
|
1396
|
-
transform = get$1();
|
|
1397
|
-
scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
|
|
1398
|
-
rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
|
|
1399
|
-
}
|
|
1400
1399
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
1401
1400
|
applyStops(style, paint.stops, opacity);
|
|
1402
|
-
const data = { type, style
|
|
1401
|
+
const data = { type, style };
|
|
1402
|
+
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1403
|
+
if (transform)
|
|
1404
|
+
data.transform = transform;
|
|
1403
1405
|
if (blendMode)
|
|
1404
1406
|
data.blendMode = blendMode;
|
|
1405
1407
|
return data;
|
|
1406
1408
|
}
|
|
1409
|
+
function getTransform(box, from, to, stretch, rotate90) {
|
|
1410
|
+
let transform;
|
|
1411
|
+
const { width, height } = box;
|
|
1412
|
+
if (width !== height || stretch) {
|
|
1413
|
+
const angle = getAngle(from, to);
|
|
1414
|
+
transform = get();
|
|
1415
|
+
if (rotate90) {
|
|
1416
|
+
scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
|
|
1417
|
+
rotateOfOuter(transform, from, angle + 90);
|
|
1418
|
+
}
|
|
1419
|
+
else {
|
|
1420
|
+
scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
|
|
1421
|
+
rotateOfOuter(transform, from, angle);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return transform;
|
|
1425
|
+
}
|
|
1407
1426
|
|
|
1408
|
-
const {
|
|
1409
|
-
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
1427
|
+
const { getDistance } = PointHelper;
|
|
1410
1428
|
const { toPoint } = AroundHelper;
|
|
1411
1429
|
const realFrom = {};
|
|
1412
1430
|
const realTo = {};
|
|
@@ -1414,20 +1432,12 @@ function conicGradient(paint, box) {
|
|
|
1414
1432
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
1415
1433
|
toPoint(from || 'center', box, realFrom);
|
|
1416
1434
|
toPoint(to || 'bottom', box, realTo);
|
|
1417
|
-
const { width, height } = box;
|
|
1418
|
-
const transform = get();
|
|
1419
|
-
const angle = getAngle(realFrom, realTo);
|
|
1420
|
-
if (Platform.conicGradientRotate90) {
|
|
1421
|
-
scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
|
|
1422
|
-
rotateOfOuter(transform, realFrom, angle + 90);
|
|
1423
|
-
}
|
|
1424
|
-
else {
|
|
1425
|
-
scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
|
|
1426
|
-
rotateOfOuter(transform, realFrom, angle);
|
|
1427
|
-
}
|
|
1428
1435
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
1429
1436
|
applyStops(style, paint.stops, opacity);
|
|
1430
|
-
const data = { type, style
|
|
1437
|
+
const data = { type, style };
|
|
1438
|
+
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
1439
|
+
if (transform)
|
|
1440
|
+
data.transform = transform;
|
|
1431
1441
|
if (blendMode)
|
|
1432
1442
|
data.blendMode = blendMode;
|
|
1433
1443
|
return data;
|
|
@@ -1436,7 +1446,8 @@ function conicGradient(paint, box) {
|
|
|
1436
1446
|
const PaintGradientModule = {
|
|
1437
1447
|
linearGradient,
|
|
1438
1448
|
radialGradient,
|
|
1439
|
-
conicGradient
|
|
1449
|
+
conicGradient,
|
|
1450
|
+
getTransform
|
|
1440
1451
|
};
|
|
1441
1452
|
|
|
1442
1453
|
const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
|
|
@@ -2162,11 +2173,21 @@ const ExportModule = {
|
|
|
2162
2173
|
resolve();
|
|
2163
2174
|
this.running = false;
|
|
2164
2175
|
};
|
|
2176
|
+
const { toURL } = Platform;
|
|
2177
|
+
const { download } = Platform.origin;
|
|
2178
|
+
const fileType = FileHelper.fileType(filename);
|
|
2165
2179
|
if (filename === 'json') {
|
|
2166
2180
|
return over({ data: leaf.toJSON() });
|
|
2167
2181
|
}
|
|
2168
|
-
else if (
|
|
2169
|
-
|
|
2182
|
+
else if (fileType === 'json') {
|
|
2183
|
+
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
2184
|
+
return over({ data: true });
|
|
2185
|
+
}
|
|
2186
|
+
if (filename === 'svg') {
|
|
2187
|
+
return over({ data: leaf.toSVG() });
|
|
2188
|
+
}
|
|
2189
|
+
else if (fileType === 'svg') {
|
|
2190
|
+
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
2170
2191
|
return over({ data: true });
|
|
2171
2192
|
}
|
|
2172
2193
|
const { leafer } = leaf;
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as p,LeafBoundsHelper as _,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,AlignHelper as k,ImageEvent as E,AroundHelper as S,PointHelper as L,Direction4 as A,TwoPointBoundsHelper as O,TaskProcessor as W,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as M}from"fs";import{PaintImage as C,ColorConvert as I,PaintGradient as D,Export as P,Group as F,TextConvert as U,Paint as N,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function G(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;class X extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,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),this.clientBounds=this.bounds}}const{mineType:j,fileType:q}=o;function V(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:n},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(j(e),i),canvasToBolb:(t,e,i)=>G(this,void 0,void 0,(function*(){return t.toBuffer(j(e),i)})),canvasSaveAs:(t,e,i)=>G(this,void 0,void 0,(function*(){return M(e,t.toBuffer(j(q(e)),i))})),download(t,e){},loadImage:n}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new X(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new a;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 a,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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}=u,{pushAllChildBranch:Z,pushAllParent:$}=f;const{worldBounds:K}=_,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new a(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}=u,st=g.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){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(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(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){t.list.forEach((t=>{t.__layout.opacityChanged&&J(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(o,r,this.times)),i.emitEvent(new y(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(i,o,this.times)),ot.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){it(t,!0),t.isBranch?f.updateBounds(t):u.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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=g.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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new p,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,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 p,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new p(n);i.save(),s&&!g.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(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(n),g.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new p(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 p(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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}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&&C.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(n,{watcher:(t,e)=>new z(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:_t,getIntersectData:gt}=B;let wt;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 C.image(i,t,e,n,!wt||!wt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return e.r?{type:"solid",style:I.string(e)}:void 0}}const mt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),wt=C.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?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&&C.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=gt(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=_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 vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:kt,rotate:Et}=R;function St(t,e,i,n,s,o,a){const r=xt();Bt(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 Lt(t,e,i,n,s,o,a){const r=xt();Bt(r,e.x+i,e.y+n),s&&kt(r,s,o),a&&Et(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(Et(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:Ot,translate:Wt}=R,Tt=new p,Mt={};function Ct(t,e,i,n){let{width:s,height:o}=e;i.padding&&(n=Tt.set(n).shrink(i.padding));const{opacity:a,mode:r,align:d,offset:l,scale:c,size:h,rotation:u,blendMode:f,repeat:p}=i,_=n.width===s&&n.height===o;f&&(t.blendMode=f);const g=t.data={mode:r},w="center"!==d&&(u||0)%180==90,y=w?o:s,m=w?s:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)h?(v=("number"==typeof h?h:h.width)/s,x=("number"==typeof h?h:h.height)/o):c&&(v="number"==typeof c?c:c.x,x="number"==typeof c?c:c.y);else if(!_||u){const t=n.width/y,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,B+=(n.height-o*x)/2}if(d){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),k.toPoint(d,t,n,Mt,!0),b+=Mt.x,B+=Mt.y}switch(l&&(b+=l.x,B+=l.y),r){case"strench":_||(s=n.width,o=n.height);break;case"normal":case"clip":(b||B||v||u)&&Lt(g,n,b,B,v,x,u);break;case"repeat":(!_||v||u)&&At(g,n,s,o,b,B,v,x,u,d),p||(g.repeat="repeat");break;default:v&&St(g,n,b,B,v,x,u)}g.transform||(n.x||n.y)&&(g.transform=Ot(),Wt(g.transform,n.x,n.y)),v&&"strench"!==r&&(g.scaleX=v,g.scaleY=x),g.width=s,g.height=o,a&&(g.opacity=a),p&&(g.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat")}let It,Dt=new p;const{isSame:Pt}=B;function Ft(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||Ct(s,n,i,o),!0}function Ut(t,e){Gt(t,E.LOAD,e)}function Nt(t,e){Gt(t,E.LOADED,e)}function Yt(t,e,i){e.error=i,t.forceUpdate("surface"),Gt(t,E.ERROR,e)}function Gt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Vt}=R,{ceil:zt,abs:Ht}=Math;function Qt(t,i,n){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Ht(s),o=Ht(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=jt(),Vt(l,_),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=jt(),_&&Vt(l,_)),qt(l,1/s,1/o));const m=t.getCanvas(zt(c)||1,zt(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}const{abs:Jt}=Math;const Zt={image:function(t,e,i,n,s){let o,a;const r=v.get(i);return It&&i===It.paint&&Pt(n,It.boxBounds)?o=It.leafPaint:(o={type:i.type,image:r},It=r.use>1?{leafPaint:o,paint:i,boxBounds:Dt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ft(t,e,i,r,o,n),s&&(Ut(t,a),Nt(t,a))):r.error?s&&Yt(t,a,r.error):(Xt(t,!0),s&&Ut(t,a),o.loadId=r.load((()=>{Xt(t,!1),t.destroyed||(Ft(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,a)),o.loadId=null}),(e=>{Xt(t,!1),Yt(t,a,e),o.loadId=null}))),o},createData:Ct,fillOrFitMode:St,clipMode:Lt,repeatMode:At,createPattern:Qt,checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=Jt(o)*i.pixelRatio,n*=Jt(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||P.running?Qt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>G(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Qt(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,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,v.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}},{toPoint:$t}=S,Kt={},te={};function ee(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:ie,getDistance:ne}=L,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=S,de={},le={};const{getAngle:ce,getDistance:he}=L,{get:ue,rotateOfOuter:fe,scaleOfOuter:pe}=R,{toPoint:_e}=S,ge={},we={};const ye={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;$t(n||"top",i,Kt),$t(s||"bottom",i,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(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;re(n||"center",i,de),re(s||"bottom",i,le);const{width:l,height:c}=i;let h;(l!==c||d)&&(h=se(),ae(h,de,l/c*(d||1),1),oe(h,de,ie(de,le)+90));const u=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ne(de,le));ee(u,t.stops,a);const f={type:o,style:u,transform:h};return r&&(f.blendMode=r),f},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;_e(n||"center",i,ge),_e(s||"bottom",i,we);const{width:l,height:c}=i,h=ue(),u=ce(ge,we);e.conicGradientRotate90?(pe(h,ge,l/c*(d||1),1),fe(h,ge,u+90)):(pe(h,ge,1,l/c*(d||1)),fe(h,ge,u));const f=e.conicGradientSupport?e.canvas.createConicGradient(0,ge.x,ge.y):e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,he(ge,we));ee(f,t.stops,a);const p={type:o,style:f,transform:h};return r&&(p.blendMode=r),p}},{copy:me,toOffsetOutBounds:ve}=B,xe={},be={};function Be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(me(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&&(me(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}=B,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;ve(l,be),r.forEach(((r,_)=>{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&&_<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,ke),r.forEach(((r,_)=>{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,Be(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&&_<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:Se}=_;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),Oe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Oe(t,i,n,o);break;case"path":i.restore()}}function Ae(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)}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)||Se(i,e)||i.__render(s||t,e);Le(this,a,t,s,n,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Te=We+"_#~&*+\\=|≮≯≈≠=…",Me=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ce(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ie=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Ce(We),Fe=Ce(Te),Ue=Ce("- —/~|┆·");var Ne;!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"}(Ne||(Ne={}));const{Letter:Ye,Single:Ge,Before:Xe,After:je,Symbol:qe,Break:Ve}=Ne;function ze(t){return Ie[t]?Ye:Ue[t]?Ve:De[t]?Xe:Pe[t]?je:Fe[t]?qe:Me.test(t)?Ge:Ye}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}=Ne;let ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,_i,gi,wi,yi,mi=[];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(){gi&&(wi.paraNumber++,si.paraStart=!0,gi=!1),hi&&(si.startCharSize=ci,si.endCharSize=hi,ci=0),si.width=ai,yi.width&&Je(si),mi.push(si),si={words:[]},ai=0}const Bi=0,Ri=1,ki=2;const{top:Ei,right:Si,bottom:Li,left:Ai}=A;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 Wi={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[Si]+l[Ai]),a&&(s=l[Ei],a-=l[Ei]+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,mi=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;gi=!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(),gi=!0):(ui=ze(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,_i=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=gi&&o?d-o:d,t&&d&&ai+oi+li>ri&&(e?(oi&&xi(),bi()):(_i||(_i=ui===Ze&&fi==ti),pi||_i||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&xi(),bi()):bi()))," "===di&&!0!==gi&&ai+oi===0||(ui===ii?(" "===di&&oi&&xi(),vi(di,li),xi()):pi||_i?(oi&&xi(),vi(di,li)):vi(di,li)),fi=ui);oi&&xi(),ai&&bi(),mi.length>0&&(mi[mi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{wi.paraNumber++,mi.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[Ai]);break;case"right":Oi(e,"x",-t[Si])}if(!s)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ei]);break;case"bottom":Oi(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:_,width:g,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":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,l=i.length;o<l;o++){if(h=i[o],h.x=p,h.width<g||h.width>g&&!r)switch(d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-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&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(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: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===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){const{rows:n,overflow:s}=t;let{textOverflow:o}=i;if(n.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?e.canvas.measureText(o).width:0,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],a=t.x+t.width,!(n===i&&a<d));n--){if(a<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Ti={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:Ci,toBounds:Ii}=O;const Di={export(t,i,s){return this.running=!0,function(t){Pi||(Pi=new W);return new Promise((e=>{Pi.add((()=>G(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((r=>{const d=t=>{a(t),r(),this.running=!1};if("json"===i)return d({data:t.toJSON()});if("json"===o.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),d({data:!0});const{leafer:l}=t;l?l.waitViewCompleted((()=>G(this,void 0,void 0,(function*(){s=o.getExportOptions(s);let e,a,r=1,c=1;const{worldTransform:h,isLeafer:u,isFrame:f}=t,{slice:_,trim:g,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=o.isOpaqueImage(i)||x,B=new T;if(v)e=!0===v?u?l.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(r=h.scaleX,c=h.scaleY,i){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),r/=t.scaleX,c/=t.scaleY;break;case"world":r=1,c=1;break;case"page":i=t.leafer;default:B.set(h).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,c/=c/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:E,height:S}=new p(e).scale(y);let L=n.canvas({width:Math.round(E),height:Math.round(S),pixelRatio:m});const A={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/c*y)};if(_&&(t=l,A.bounds=L.bounds),L.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.restore(),g){a=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?Ci(a,s,o):Mi(a={},s,o)),r++;const d=new p;return Ii(a,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:m};L=n.canvas(s),L.copyWorld(t,a,s)}b&&L.fillWorld(L.bounds,x||"#FFFFFF","destination-over"),w&&w(L);const O="canvas"===i?L:yield L.export(i,s);d({data:O,width:L.pixelWidth,height:L.pixelHeight,renderBounds:e,trimBounds:a})})))):d({data:!1})}))))}};let Pi;const Fi=t.prototype,Ui=g.get("@leafer-ui/export");Fi.export=function(t,e){const{quality:i,blob:n}=o.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=>{Ui.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=>{Ui.error(t),n(!1)}))}))},Object.assign(U,Wi),Object.assign(I,Ti),Object.assign(N,mt),Object.assign(C,Zt),Object.assign(D,ye),Object.assign(Y,Ee),Object.assign(P,Di);export{ot as Layouter,X as LeaferCanvas,rt as Renderer,z as Watcher,V as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as p,LeafBoundsHelper as _,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,AlignHelper as k,ImageEvent as E,AroundHelper as S,PointHelper as L,Direction4 as A,TwoPointBoundsHelper as W,TaskProcessor as T,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as M}from"fs";import{PaintImage as C,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as U,Paint as N,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function G(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class V extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,n(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:X,fileType:j}=o;function q(t,n){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:i},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,n,i),canvasToDataURL:(t,e,n)=>t.toDataURL(X(e),n),canvasToBolb:(t,e,n)=>G(this,void 0,void 0,(function*(){return t.toBuffer(X(e),n)})),canvasSaveAs:(t,e,n)=>G(this,void 0,void 0,(function*(){return M(e,t.toBuffer(X(j(e)),n))})),download(t,e){},loadImage:i}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new V(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new a;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 a,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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}=u,{pushAllChildBranch:Z,pushAllParent:$}=f;const{worldBounds:K}=_,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new a(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:nt,updateAllChange:it}=u,st=g.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){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(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new y(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(H(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||Q(i[t])}Q(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&J(t),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new y(o,r,this.times)),n.emitEvent(new y(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(n,o,this.times)),ot.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(i,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new et([]));e.length?n.add(t.__world):n.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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=g.get("Renderer");class rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=r.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new p,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,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 p,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!g.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(i),g.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(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,n){this.target.emitEvent(new d(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function dt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function lt(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ut(t,!0,e,n):ht(e,n);break;case"inside":ct("inside",t,s,e,n);break;case"outside":ct("outside",t,s,e,n)}}function ct(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?ut(e,!0,i,r):ht(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",dt(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function ht(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function ut(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&C.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?ht(n,i):i.stroke(),i.restoreBlendMode()):e?ht(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,n)=>new rt(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=ot.fullLayout;const{getSpread:ft,getOuterOf:pt,getByMove:_t,getIntersectData:gt}=B;let wt;function yt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__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 C.image(n,t,e,i,!wt||!wt[e.url]);case"linear":return I.linearGradient(e,i);case"radial":return I.radialGradient(e,i);case"angular":return I.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const mt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),wt=C.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=yt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?dt(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&C.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?dt(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?dt(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?dt(e,n):s?n.fill(s):n.fill())},fillText:dt,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)lt(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)lt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ut(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ut(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),ut(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:lt,drawTextStroke:ht,shape:function(t,e,n){const i=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=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=gt(i?ft(e.bounds,l===c?i*l:[i*c,i*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,n),l*=u,c*=f),r=pt(s,a),o=_t(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let vt={};const{get:xt,rotateOfOuter:bt,translate:Bt,scaleOfOuter:Rt,scale:kt,rotate:Et}=R;function St(t,e,n,i,s,o,a){const r=xt();Bt(r,e.x+n,e.y+i),kt(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,n,i,s,o,a){const r=xt();Bt(r,e.x+n,e.y+i),s&&kt(r,s,o),a&&Et(r,a),t.transform=r}function At(t,e,n,i,s,o,a,r,d,l){const c=xt();if(d)if("center"===l)bt(c,{x:n/2,y:i/2},d);else switch(Et(c,d),d){case 90:Bt(c,i,0);break;case 180:Bt(c,n,i);break;case 270:Bt(c,0,n)}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}=R,Ot=new p,Mt={};function Ct(t,e,n,i){const{blendMode:s}=n;s&&(t.blendMode=s),t.data=Dt(n,i,e)}function Dt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=Ot.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===i&&e.height===s,p={mode:a},_="center"!==r&&(h||0)%180==90,g=_?s:i,w=_?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)c?(y=("number"==typeof c?c:c.width)/i,m=("number"==typeof c?c:c.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),k.toPoint(r,t,e,Mt,!0),v+=Mt.x,x+=Mt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Lt(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&At(p,e,i,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&St(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&&"strench"!==a&&(p.scaleX=y,p.scaleY=m),p.width=i,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,Pt=new p;const{isSame:Ft}=B;function Ut(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||Ct(s,i,n,o),!0}function Nt(t,e){Vt(t,E.LOAD,e)}function Yt(t,e){Vt(t,E.LOADED,e)}function Gt(t,e,n){e.error=n,t.forceUpdate("surface"),Vt(t,E.ERROR,e)}function Vt(t,e,n){t.hasEvent(e)&&t.emitEvent(new E(e,n))}function Xt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:jt,scale:qt,copy:zt}=R,{ceil:Ht,abs:Qt}=Math;function Jt(t,n,i){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(n.patternId===a||t.destroyed)return!1;{s=Qt(s),o=Qt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=jt(),zt(l,_),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=jt(),_&&zt(l,_)),qt(l,1/s,1/o));const m=t.getCanvas(Ht(c)||1,Ht(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=v.get(n);return It&&n===It.paint&&Ft(i,It.boxBounds)?o=It.leafPaint:(o={type:n.type,image:r},It=r.use>1?{leafPaint:o,paint:n,boxBounds:Pt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Ut(t,e,n,r,o,i),s&&(Nt(t,a),Yt(t,a))):r.error?s&&Gt(t,a,r.error):(Xt(t,!0),s&&Nt(t,a),o.loadId=r.load((()=>{Xt(t,!1),t.destroyed||(Ut(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,a)),o.loadId=null}),(e=>{Xt(t,!1),Gt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;if(i.data&&i.patternId!==o+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Zt(o)*n.pixelRatio,i*=Zt(a)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||P.running?Jt(t,i,n.pixelRatio):i.patternTask||(i.patternTask=v.patternTasker.add((()=>G(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Jt(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Jt,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,v.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Ct,getPatternData:Dt,fillOrFitMode:St,clipMode:Lt,repeatMode:At},{toPoint:Kt}=S,te={},ee={};function ne(t,e,n){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),D.string(i,n)):t.addColorStop(i.offset,D.string(i.color,n))}const{getAngle:ie,getDistance:se}=L,{get:oe,rotateOfOuter:ae,scaleOfOuter:re}=R,{toPoint:de}=S,le={},ce={};function he(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ie(e,n);o=oe(),s?(re(o,e,a/r*(i||1),1),ae(o,e,t+90)):(re(o,e,1,a/r*(i||1)),ae(o,e,t))}return o}const{getDistance:ue}=L,{toPoint:fe}=S,pe={},_e={};const ge={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Kt(i||"top",n,te),Kt(s||"bottom",n,ee);const d=e.canvas.createLinearGradient(te.x,te.y,ee.x,ee.y);ne(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;de(i||"center",n,le),de(s||"bottom",n,ce);const l=e.canvas.createRadialGradient(le.x,le.y,0,le.x,le.y,se(le,ce));ne(l,t.stops,a);const c={type:o,style:l},h=he(n,le,ce,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;fe(i||"center",n,pe),fe(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,ue(pe,_e));ne(l,t.stops,a);const c={type:o,style:l},h=he(n,pe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:he},{copy:we,toOffsetOutBounds:ye}=B,me={},ve={};function xe(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=n.x-a.x,me.y+=n.y-a.y,i){const{matrix:t}=s;me.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),me.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),me.width*=i,me.height*=i}t.copyWorld(s.canvas,t.bounds,me)}else i&&(we(me,n),me.x-=n.width/2*(i-1),me.y-=n.height/2*(i-1),me.width*=i,me.height*=i),t.copyWorld(s.canvas,a,i?me:n)}const{toOffsetOutBounds:be}=B,Be={};const Re={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;ye(l,ve),r.forEach(((r,_)=>{f.setWorldShadow(ve.offsetX+r.x*h,ve.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,ve,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;be(l,Be),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,Be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:ke}=_;function Ee(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Le(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Le(t,n,i,o);break;case"path":n.restore()}}function Se(t){return t.getSameCanvas(!1,!0)}function Le(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}F.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(a&&(Ee(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Se(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Se(t)),s||(s=Se(t)),n.__render(i,e)),"clipping"!==n.__.mask)||ke(n,e)||n.__render(s||t,e);Ee(this,a,t,s,i,o)};const Ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Ae+"_#~&*+\\=|≮≯≈≠=…",Te=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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),De=Oe(Ae),Ie=Oe(We),Pe=Oe("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:Ue,Single:Ne,Before:Ye,After:Ge,Symbol:Ve,Break:Xe}=Fe;function je(t){return Me[t]?Ue:Pe[t]?Xe:Ce[t]?Ye:De[t]?Ge:Ie[t]?Ve:Te.test(t)?Ne:Ue}const qe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ze(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:He}=qe,{Letter:Qe,Single:Je,Before:Ze,After:$e,Symbol:Ke,Break:tn}=Fe;let en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn=[];function mn(t,e){cn&&!ln&&(ln=cn),en.data.push({char:t,width:e}),sn+=e}function vn(){on+=sn,en.width=sn,nn.words.push(en),en={data:[]},sn=0}function xn(){_n&&(gn.paraNumber++,nn.paraStart=!0,_n=!1),cn&&(nn.startCharSize=ln,nn.endCharSize=cn,ln=0),nn.width=on,wn.width&&He(nn),yn.push(nn),nn={words:[]},on=0}const bn=0,Bn=1,Rn=2;const{top:kn,right:En,bottom:Sn,left:Ln}=A;function An(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Wn={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o&&(i=l[Ln],o-=l[En]+l[Ln]),a&&(s=l[kn],a-=l[kn]+l[Sn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){gn=t,yn=t.rows,wn=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=wn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,un=null,ln=dn=cn=sn=on=0,en={data:[]},nn={words:[]};for(let i=0,l=n.length;i<l;i++)rn=n[i],"\n"===rn?(sn&&vn(),nn.paraEnd=!0,xn(),_n=!0):(hn=je(rn),hn===Qe&&"none"!==a&&(rn=ze(rn,a,!sn)),dn=r.measureText(rn).width,s&&(s<0&&(cn=dn),dn+=s),fn=hn===Je&&(un===Je||un===Qe)||un===Je&&hn!==$e,pn=!(hn!==Ze&&hn!==Je||un!==Ke&&un!==$e),an=_n&&o?d-o:d,t&&d&&on+sn+dn>an&&(e?(sn&&vn(),xn()):(pn||(pn=hn===Qe&&un==$e),fn||pn||hn===tn||hn===Ze||hn===Je||sn+dn>an?(sn&&vn(),xn()):xn()))," "===rn&&!0!==_n&&on+sn===0||(hn===tn?(" "===rn&&sn&&vn(),mn(rn,dn),vn()):fn||pn?(sn&&vn(),mn(rn,dn)):mn(rn,dn)),un=hn);sn&&vn(),on&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{gn.paraNumber++,yn.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":An(e,"x",t[Ln]);break;case"right":An(e,"x",-t[En])}if(!s)switch(n.verticalAlign){case"top":An(e,"y",t[kn]);break;case"bottom":An(e,"y",-t[Sn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,l=n.length;o<l;o++){if(h=n[o],h.x=p,h.width<g||h.width>g&&!r)switch(d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-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<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(c,n),function(t,e,n,i){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=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?bn:l>.01?Bn:Rn,t.isOverflow&&!r&&(t.textMode=!0),h===Rn?(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===Bn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.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,n,o),c.overflow&&function(t,n){const{rows:i,overflow:s}=t;let{textOverflow:o}=n;if(i.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?e.canvas.measureText(o).width:0,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],a=t.x+t.width,!(i===n&&a<d));i--){if(a<d&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Tn={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:On,addPoint:Mn,toBounds:Cn}=W;const Dn={export(t,n,s){return this.running=!0,function(t){In||(In=new T);return new Promise((e=>{In.add((()=>G(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((r=>{const d=t=>{a(t),r(),this.running=!1},{toURL:l}=e,{download:c}=e.origin,h=o.fileType(n);if("json"===n)return d({data:t.toJSON()});if("json"===h)return c(l(JSON.stringify(t.toJSON()),"text"),n),d({data:!0});if("svg"===n)return d({data:t.toSVG()});if("svg"===h)return c(l(t.toSVG(),"svg"),n),d({data:!0});const{leafer:u}=t;u?u.waitViewCompleted((()=>G(this,void 0,void 0,(function*(){s=o.getExportOptions(s);let e,a,r=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:f}=t,{slice:_,trim:g,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=h&&v&&void 0===s.fill?t.fill:s.fill,b=o.isOpaqueImage(n)||x,B=new O;if(v)e=!0===v?h?u.canvas.bounds:t.worldRenderBounds:v;else{let n=s.relative||(h?"inner":"local");switch(r=c.scaleX,l=c.scaleY,n){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":n=t.leafer;default:B.set(c).divide(t.getTransform(n));const e=n.worldTransform;r/=r/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",n)}const{x:R,y:k,width:E,height:S}=new p(e).scale(y);let L=i.canvas({width:Math.round(E),height:Math.round(S),pixelRatio:m});const A={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/l*y)};if(_&&(t=u,A.bounds=L.bounds),L.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.restore(),g){a=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,o,a,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,o=(r-s)/e,a?Mn(a,s,o):On(a={},s,o)),r++;const d=new p;return Cn(a,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:n}=a,s={x:0,y:0,width:e,height:n,pixelRatio:m};L=i.canvas(s),L.copyWorld(t,a,s)}b&&L.fillWorld(L.bounds,x||"#FFFFFF","destination-over"),w&&w(L);const W="canvas"===n?L:yield L.export(n,s);d({data:W,width:L.pixelWidth,height:L.pixelHeight,renderBounds:e,trimBounds:a})})))):d({data:!1})}))))}};let In;const Pn=t.prototype,Fn=g.get("@leafer-ui/export");Pn.export=function(t,e){const{quality:n,blob:i}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},Pn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Fn.error(t),i(null)}))}))},Pn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Pn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Fn.error(t),i(!1)}))}))},Object.assign(U,Wn),Object.assign(D,Tn),Object.assign(N,mt),Object.assign(C,$t),Object.assign(I,ge),Object.assign(Y,Re),Object.assign(P,Dn);export{ot as Layouter,V as LeaferCanvas,rt as Renderer,z as Watcher,q as useCanvas};
|
package/dist/node.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/draw");function i(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:s}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),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:_,updateAllChange:w}=t.LeafHelper,y=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:s,AFTER:r}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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 v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.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 b(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,o)}function B(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?L(t,!0,e,n):R(e,n);break;case"inside":E("inside",t,a,e,n);break;case"outside":E("outside",t,a,e,n)}}function E(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?L(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",b(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,o)}function L(t,e,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&n.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),e?R(i,a):a.stroke(),a.restoreBlendMode()):e?R(i,a):a.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let O;function C(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=i.__layout;switch(e.type){case"solid":let{type:o,blendMode:s,color:r,opacity:d}=e;return{type:o,blendMode:s,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,a,!O||!O[e.url]);case"linear":return n.PaintGradient.linearGradient(e,a);case"radial":return n.PaintGradient.radialGradient(e,a);case"angular":return n.PaintGradient.conicGradient(e,a);default:return e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const W={compute:function(t,e){const i=e.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),O=n.PaintImage.recycleImage(t,i);for(let n,i=0,o=s.length;i<o;i++)n=C(t,s[i],e),n&&a.push(n);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let a;const{windingRule:o,__font:s}=e.__;for(let r=0,d=t.length;r<d;r++)a=t[r],a.image&&n.PaintImage.checkImage(e,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?b(e,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?b(e,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?b(e,i):o?i.fill(o):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)B(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)B(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),L(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),L(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,d,{scaleX:l,scaleY:c}=a;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(a))d=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=A(i?k(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:j}=t.MatrixHelper;function U(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),F(r,a,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function G(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),a&&F(r,a,o),s&&j(r,s),t.transform=r}function N(t,e,n,i,a,o,s,r,d,l){const c=T();if(d)if("center"===l)I(c,{x:n/2,y:i/2},d);else switch(j(c,d),d){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}M.x=e.x+a,M.y=e.y+o,D(c,M.x,M.y),s&&H(c,M,s,r),t.transform=c}const{get:Y,translate:q}=t.MatrixHelper,X=new t.Bounds,V={};function z(e,n,i,a){let{width:o,height:s}=n;i.padding&&(a=X.set(a).shrink(i.padding));const{opacity:r,mode:d,align:l,offset:c,scale:h,size:u,rotation:f,blendMode:p,repeat:g}=i,_=a.width===o&&a.height===s;p&&(e.blendMode=p);const w=e.data={mode:d},y="center"!==l&&(f||0)%180==90,m=y?s:o,v=y?o:s;let x,b,B=0,E=0;if(d&&"cover"!==d&&"fit"!==d)u?(x=("number"==typeof u?u:u.width)/o,b=("number"==typeof u?u:u.height)/s):h&&(x="number"==typeof h?h:h.x,b="number"==typeof h?h:h.y);else if(!_||f){const t=a.width/m,e=a.height/v;x=b="fit"===d?Math.min(t,e):Math.max(t,e),B+=(a.width-o*x)/2,E+=(a.height-s*b)/2}if(l){const e={x:B,y:E,width:m,height:v};x&&(e.width*=x,e.height*=b),t.AlignHelper.toPoint(l,e,a,V,!0),B+=V.x,E+=V.y}switch(c&&(B+=c.x,E+=c.y),d){case"strench":_||(o=a.width,s=a.height);break;case"normal":case"clip":(B||E||x||f)&&G(w,a,B,E,x,b,f);break;case"repeat":(!_||x||f)&&N(w,a,o,s,B,E,x,b,f,l),g||(w.repeat="repeat");break;default:x&&U(w,a,B,E,x,b,f)}w.transform||(a.x||a.y)&&(w.transform=Y(),q(w.transform,a.x,a.y)),x&&"strench"!==d&&(w.scaleX=x,w.scaleY=b),w.width=o,w.height=s,r&&(w.opacity=r),g&&(w.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let Q,J=new t.Bounds;const{isSame:Z}=t.BoundsHelper;function $(t,e,n,i,a,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||z(a,i,n,o),!0}function K(e,n){nt(e,t.ImageEvent.LOAD,n)}function tt(e,n){nt(e,t.ImageEvent.LOADED,n)}function et(e,n,i){n.error=i,e.forceUpdate("surface"),nt(e,t.ImageEvent.ERROR,n)}function nt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function it(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:at,scale:ot,copy:st}=t.MatrixHelper,{ceil:rt,abs:dt}=Math;function lt(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o;if(n.patternId===s||e.destroyed)return!1;{a=dt(a),o=dt(o);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=at(),st(l,g),ot(l,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(a/=d,o/=d,c/=d,h/=d),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(l||(l=at(),g&&st(l,g)),ot(l,1/a,1/o));const m=e.getCanvas(rt(c)||1,rt(h)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=s,!0}}const{abs:ct}=Math;const ht={image:function(e,n,i,a,o){let s,r;const d=t.ImageManager.get(i);return Q&&i===Q.paint&&Z(a,Q.boxBounds)?s=Q.leafPaint:(s={type:i.type,image:d},Q=d.use>1?{leafPaint:s,paint:i,boxBounds:J.set(a)}:null),(o||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?($(e,n,i,d,s,a),o&&(K(e,r),tt(e,r))):d.error?o&&et(e,r,d.error):(it(e,!0),o&&K(e,r),s.loadId=d.load((()=>{it(e,!1),e.destroyed||($(e,n,i,d,s,a)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),tt(e,r)),s.loadId=null}),(t=>{it(e,!1),et(e,r,t),s.loadId=null}))),s},createData:z,fillOrFitMode:U,clipMode:G,repeatMode:N,createPattern:lt,checkImage:function(e,a,o,s){const{scaleX:r,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(o.data&&o.patternId!==r+"-"+d){const{data:l}=o;if(s)if(l.repeat)s=!1;else{let{width:e,height:n}=l;e*=ct(r)*a.pixelRatio,n*=ct(d)*a.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(a.save(),a.clip(),o.blendMode&&(a.blendMode=o.blendMode),l.opacity&&(a.opacity*=l.opacity),l.transform&&a.transform(l.transform),a.drawImage(o.image.view,0,0,l.width,l.height),a.restore(),!0):(!o.style||n.Export.running?lt(e,o,a.pixelRatio):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){o.patternTask=null,a.bounds.hit(e.__nowWorld)&<(e,o,a.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let d=0,l=i.length;d<l;d++)a=i[d].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[d].loadId,!s.some((t=>t.url===r)))));return o}return null}},{toPoint:ut}=t.AroundHelper,ft={},pt={};function gt(t,e,i){let a;for(let o=0,s=e.length;o<s;o++)a=e[o],"string"==typeof a?t.addColorStop(o/(s-1),n.ColorConvert.string(a,i)):t.addColorStop(a.offset,n.ColorConvert.string(a.color,i))}const{getAngle:_t,getDistance:wt}=t.PointHelper,{get:yt,rotateOfOuter:mt,scaleOfOuter:vt}=t.MatrixHelper,{toPoint:xt}=t.AroundHelper,bt={},Bt={};const{getAngle:Et,getDistance:Rt}=t.PointHelper,{get:Lt,rotateOfOuter:kt,scaleOfOuter:St}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,At={},Ot={};const Ct={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;ut(i||"top",n,ft),ut(a||"bottom",n,pt);const d=t.Platform.canvas.createLinearGradient(ft.x,ft.y,pt.x,pt.y);gt(d,e.stops,r);const l={type:o,style:d};return s&&(l.blendMode=s),l},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:d}=e;xt(i||"center",n,bt),xt(a||"bottom",n,Bt);const{width:l,height:c}=n;let h;(l!==c||d)&&(h=yt(),vt(h,bt,l/c*(d||1),1),mt(h,bt,_t(bt,Bt)+90));const u=t.Platform.canvas.createRadialGradient(bt.x,bt.y,0,bt.x,bt.y,wt(bt,Bt));gt(u,e.stops,s);const f={type:o,style:u,transform:h};return r&&(f.blendMode=r),f},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:d}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ot);const{width:l,height:c}=n,h=Lt(),u=Et(At,Ot);t.Platform.conicGradientRotate90?(St(h,At,l/c*(d||1),1),kt(h,At,u+90)):(St(h,At,1,l/c*(d||1)),kt(h,At,u));const f=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,Rt(At,Ot));gt(f,e.stops,s);const p={type:o,style:f,transform:h};return r&&(p.blendMode=r),p}},{copy:Wt,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-s.x,Tt.y+=n.y-s.y,i){const{matrix:t}=a;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(a.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(a.canvas,s,i?Tt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const jt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(l,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,It,a,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(l,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,Ft,a,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ut}=t.LeafBoundsHelper;function Gt(t,e,n,i,a,o){switch(e){case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Yt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Yt(t,n,i,o);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Yt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}n.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(s&&(Gt(this,s,t,a,i,o),i=a=null),"path"===n.__.mask?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Nt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Ut(n,e)||n.__render(a||t,e);Gt(this,s,t,a,i,o)};const qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xt=qt+"_#~&*+\\=|≮≯≈≠=…",Vt=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 zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=zt(qt),$t=zt(Xt),Kt=zt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:ae,Symbol:oe,Break:se}=te;function re(t){return Qt[t]?ee:Kt[t]?se:Jt[t]?ie:Zt[t]?ae:$t[t]?oe:Vt.test(t)?ne:ee}const de={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ce}=de,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,ye,me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Oe,Ce,We=[];function Me(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),me+=e}function Te(){ve+=me,we.width=me,ye.words.push(we),we={data:[]},me=0}function Ie(){Ae&&(Oe.paraNumber++,ye.paraStart=!0,Ae=!1),Re&&(ye.startCharSize=Ee,ye.endCharSize=Re,Ee=0),ye.width=ve,Ce.width&&ce(ye),We.push(ye),ye={words:[]},ve=0}const De=0,He=1,Fe=2;const{top:je,right:Ue,bottom:Ge,left:Ne}=t.Direction4;function Ye(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o&&(i=l[Ne],o-=l[Ue]+l[Ne]),s&&(a=l[je],s-=l[je]+l[Ge]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Oe=e,We=e.rows,Ce=e.bounds;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ce;if(d||l||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=me=ve=0,we={data:[]},ye={words:[]};for(let i=0,l=n.length;i<l;i++)be=n[i],"\n"===be?(me&&Te(),ye.paraEnd=!0,Ie(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=le(be,s,!me)),Be=r.measureText(be).width,a&&(a<0&&(Re=Be),Be+=a),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&o?d-o:d,t&&d&&ve+me+Be>xe&&(e?(me&&Te(),Ie()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||me+Be>xe?(me&&Te(),Ie()):Ie()))," "===be&&!0!==Ae&&ve+me===0||(Le===_e?(" "===be&&me&&Te(),Me(be,Be),Te()):Se||Pe?(me&&Te(),Me(be,Be)):Me(be,Be)),ke=Le);me&&Te(),ve&&Ie(),We.length>0&&(We[We.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,We.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,i,a){if(!i)switch(n.textAlign){case"left":Ye(e,"x",t[Ne]);break;case"right":Ye(e,"x",-t[Ue])}if(!a)switch(n.verticalAlign){case"top":Ye(e,"y",t[je]);break;case"bottom":Ye(e,"y",-t[Ge])}}(l,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=i,y=a*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,a),t.overflow=n.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=n.length;o<l;o++){if(h=n[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+=a,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,s<0&&(h.width<0?(f=-h.width+e.fontSize+s,u-=f,f+=e.fontSize):f-=s),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=y}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let d,l,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?De:l>.01?He:Fe,t.isOverflow&&!r&&(t.textMode=!0),h===Fe?(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===He?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.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,n,o),c.overflow&&function(e,n){const{rows:i,overflow:a}=e;let{textOverflow:o}=n;if(i.splice(a),o&&"show"!==o){let e,s;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?t.Platform.canvas.measureText(o).width:0,d=n.x+n.width-r;("none"===n.textWrap?i:[i[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],s=e.x+e.width,!(i===n&&s<d));i--){if(s<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:o,x:s}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Xe={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:Ve,addPoint:ze,toBounds:Qe}=t.TwoPointBoundsHelper;const Je={export(e,n,a){return this.running=!0,function(e){Ze||(Ze=new t.TaskProcessor);return new Promise((t=>{Ze.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((s=>{const r=t=>{o(t),s(),this.running=!1};if("json"===n)return r({data:e.toJSON()});if("json"===t.FileHelper.fileType(n))return t.Platform.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(e.toJSON())),n),r({data:!0});const{leafer:d}=e;d?d.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){a=t.FileHelper.getExportOptions(a);let i,o,s=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=a;let _=a.scale||1,w=a.pixelRatio||1;e.isApp&&(_*=w,w=e.app.pixelRatio);const y=a.screenshot||e.isApp,m=h&&y&&void 0===a.fill?e.fill:a.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(y)i=!0===y?h?d.canvas.bounds:e.worldRenderBounds:y;else{let t=a.relative||(h?"inner":"local");switch(s=c.scaleX,l=c.scaleY,t){case"inner":x.set(c);break;case"local":x.set(c).divide(e.localTransform),s/=e.scaleX,l/=e.scaleY;break;case"world":s=1,l=1;break;case"page":t=e.leafer;default:x.set(c).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,l/=l/n.scaleY}i=e.getBounds("render",t)}const{x:b,y:B,width:E,height:R}=new t.Bounds(i).scale(_);let L=t.Creator.canvas({width:Math.round(E),height:Math.round(R),pixelRatio:w});const k={matrix:x.scale(1/_).invert().translate(-b,-B).withScale(1/s*_,1/l*_)};if(f&&(e=d,k.bounds=L.bounds),L.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(L,k),e.fill=t}else e.__render(L,k);if(L.restore(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,d=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=d%n,s=(d-o)/n,r?ze(r,o,s):Ve(r={},o,s)),d++;const l=new t.Bounds;return Qe(r,l),l.scale(1/e.pixelRatio).ceil()}(L);const e=L,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:w};L=t.Creator.canvas(a),L.copyWorld(e,o,a)}v&&L.fillWorld(L.bounds,m||"#FFFFFF","destination-over"),g&&g(L);const S="canvas"===n?L:yield L.export(n,a);r({data:S,width:L.pixelWidth,height:L.pixelHeight,renderBounds:i,trimBounds:o})})))):r({data:!1})}))))}};let Ze;const $e=t.LeaferCanvasBase.prototype,Ke=t.Debug.get("@leafer-ui/export");$e.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},$e.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{Ke.error(t),i(null)}))}))},$e.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},$e.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{Ke.error(t),i(!1)}))}))},Object.assign(n.TextConvert,qe),Object.assign(n.ColorConvert,Xe),Object.assign(n.Paint,W),Object.assign(n.PaintImage,ht),Object.assign(n.PaintGradient,Ct),Object.assign(n.Effect,jt),Object.assign(n.Export,Je),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=a,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,a){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=a;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:r}=a;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>i(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,a)=>i(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(s(n)),a))})),download(t,e){},loadImage:r}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/draw");function i(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:s}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),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:_,updateAllChange:w}=t.LeafHelper,y=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:s,AFTER:r}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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 v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.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 b(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,o)}function B(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?L(t,!0,e,n):R(e,n);break;case"inside":E("inside",t,a,e,n);break;case"outside":E("outside",t,a,e,n)}}function E(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?L(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",b(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,o)}function L(t,e,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&n.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),e?R(i,a):a.stroke(),a.restoreBlendMode()):e?R(i,a):a.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let C;function O(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=i.__layout;switch(e.type){case"solid":let{type:o,blendMode:s,color:r,opacity:d}=e;return{type:o,blendMode:s,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,a,!C||!C[e.url]);case"linear":return n.PaintGradient.linearGradient(e,a);case"radial":return n.PaintGradient.radialGradient(e,a);case"angular":return n.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const W={compute:function(t,e){const i=e.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),C=n.PaintImage.recycleImage(t,i);for(let n,i=0,o=s.length;i<o;i++)n=O(t,s[i],e),n&&a.push(n);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let a;const{windingRule:o,__font:s}=e.__;for(let r=0,d=t.length;r<d;r++)a=t[r],a.image&&n.PaintImage.checkImage(e,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?b(e,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?b(e,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?b(e,i):o?i.fill(o):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)B(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)B(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),L(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),L(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,d,{scaleX:l,scaleY:c}=a;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(a))d=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=A(i?k(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let T={};const{get:M,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:G}=t.MatrixHelper;function j(t,e,n,i,a,o,s){const r=M();D(r,e.x+n,e.y+i),F(r,a,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function U(t,e,n,i,a,o,s){const r=M();D(r,e.x+n,e.y+i),a&&F(r,a,o),s&&G(r,s),t.transform=r}function N(t,e,n,i,a,o,s,r,d,l){const c=M();if(d)if("center"===l)I(c,{x:n/2,y:i/2},d);else switch(G(c,d),d){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}T.x=e.x+a,T.y=e.y+o,D(c,T.x,T.y),s&&H(c,T,s,r),t.transform=c}const{get:Y,translate:q}=t.MatrixHelper,V=new t.Bounds,X={};function z(t,e,n,i){const{blendMode:a}=n;a&&(t.blendMode=a),t.data=Q(n,i,e)}function Q(e,n,i){let{width:a,height:o}=i;e.padding&&(n=V.set(n).shrink(e.padding));const{opacity:s,mode:r,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==d&&(u||0)%180==90,w=_?o:a,y=_?a:o;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)h?(m=("number"==typeof h?h:h.width)/a,v=("number"==typeof h?h:h.height)/o):c&&(m="number"==typeof c?c:c.x,v="number"==typeof c?c:c.y);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-o*v)/2}if(d){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(d,e,n,X,!0),x+=X.x,b+=X.y}switch(l&&(x+=l.x,b+=l.y),r){case"strench":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||m||u)&&U(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&N(g,n,a,o,x,b,m,v,u,d),f||(g.repeat="repeat");break;default:m&&j(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Y(),q(g.transform,n.x,n.y)),m&&"strench"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:$}=t.BoundsHelper;function K(t,e,n,i,a,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||z(a,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:st,copy:rt}=t.MatrixHelper,{ceil:dt,abs:lt}=Math;function ct(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o;if(n.patternId===s||e.destroyed)return!1;{a=lt(a),o=lt(o);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=ot(),rt(l,g),st(l,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(a/=d,o/=d,c/=d,h/=d),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(l||(l=ot(),g&&rt(l,g)),st(l,1/a,1/o));const m=e.getCanvas(dt(c)||1,dt(h)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=s,!0}}const{abs:ht}=Math;const ut={image:function(e,n,i,a,o){let s,r;const d=t.ImageManager.get(i);return J&&i===J.paint&&$(a,J.boxBounds)?s=J.leafPaint:(s={type:i.type,image:d},J=d.use>1?{leafPaint:s,paint:i,boxBounds:Z.set(a)}:null),(o||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(K(e,n,i,d,s,a),o&&(tt(e,r),et(e,r))):d.error?o&&nt(e,r,d.error):(at(e,!0),o&&tt(e,r),s.loadId=d.load((()=>{at(e,!1),e.destroyed||(K(e,n,i,d,s,a)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),s.loadId=null}),(t=>{at(e,!1),nt(e,r,t),s.loadId=null}))),s},checkImage:function(e,a,o,s){const{scaleX:r,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(o.data&&o.patternId!==r+"-"+d){const{data:l}=o;if(s)if(l.repeat)s=!1;else{let{width:e,height:n}=l;e*=ht(r)*a.pixelRatio,n*=ht(d)*a.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(a.save(),a.clip(),o.blendMode&&(a.blendMode=o.blendMode),l.opacity&&(a.opacity*=l.opacity),l.transform&&a.transform(l.transform),a.drawImage(o.image.view,0,0,l.width,l.height),a.restore(),!0):(!o.style||n.Export.running?ct(e,o,a.pixelRatio):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){o.patternTask=null,a.bounds.hit(e.__nowWorld)&&ct(e,o,a.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let d=0,l=i.length;d<l;d++)a=i[d].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[d].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:z,getPatternData:Q,fillOrFitMode:j,clipMode:U,repeatMode:N},{toPoint:ft}=t.AroundHelper,pt={},gt={};function _t(t,e,i){let a;for(let o=0,s=e.length;o<s;o++)a=e[o],"string"==typeof a?t.addColorStop(o/(s-1),n.ColorConvert.string(a,i)):t.addColorStop(a.offset,n.ColorConvert.string(a.color,i))}const{getAngle:wt,getDistance:yt}=t.PointHelper,{get:mt,rotateOfOuter:vt,scaleOfOuter:xt}=t.MatrixHelper,{toPoint:bt}=t.AroundHelper,Bt={},Et={};function Rt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=wt(e,n);o=mt(),a?(xt(o,e,s/r*(i||1),1),vt(o,e,t+90)):(xt(o,e,1,s/r*(i||1)),vt(o,e,t))}return o}const{getDistance:Lt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,St={},Pt={};const At={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;ft(i||"top",n,pt),ft(a||"bottom",n,gt);const d=t.Platform.canvas.createLinearGradient(pt.x,pt.y,gt.x,gt.y);_t(d,e.stops,r);const l={type:o,style:d};return s&&(l.blendMode=s),l},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:d}=e;bt(i||"center",n,Bt),bt(a||"bottom",n,Et);const l=t.Platform.canvas.createRadialGradient(Bt.x,Bt.y,0,Bt.x,Bt.y,yt(Bt,Et));_t(l,e.stops,s);const c={type:o,style:l},h=Rt(n,Bt,Et,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:d}=e;kt(i||"center",n,St),kt(a||"bottom",n,Pt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,St.x,St.y):t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Pt));_t(l,e.stops,s);const c={type:o,style:l},h=Rt(n,St,Pt,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Rt},{copy:Ct,toOffsetOutBounds:Ot}=t.BoundsHelper,Wt={},Tt={};function Mt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Ct(Wt,e.bounds),Wt.x+=n.x-s.x,Wt.y+=n.y-s.y,i){const{matrix:t}=a;Wt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Wt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Wt.width*=i,Wt.height*=i}e.copyWorld(a.canvas,e.bounds,Wt)}else i&&(Ct(Wt,n),Wt.x-=n.width/2*(i-1),Wt.y-=n.height/2*(i-1),Wt.width*=i,Wt.height*=i),e.copyWorld(a.canvas,s,i?Wt:n)}const{toOffsetOutBounds:It}=t.BoundsHelper,Dt={};const Ht={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ot(l,Tt),r.forEach(((r,g)=>{f.setWorldShadow(Tt.offsetX+r.x*h,Tt.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Mt(f,Tt,a,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;It(l,Dt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Dt.offsetX+r.x*h,Dt.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Mt(f,Dt,a,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ft}=t.LeafBoundsHelper;function Gt(t,e,n,i,a,o){switch(e){case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Ut(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}n.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(s&&(Gt(this,s,t,a,i,o),i=a=null),"path"===n.__.mask?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=jt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="alpha",i||(i=jt(t)),a||(a=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Ft(n,e)||n.__render(a||t,e);Gt(this,s,t,a,i,o)};const Nt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Yt=Nt+"_#~&*+\\=|≮≯≈≠=…",qt=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 Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Xt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),zt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Qt=Vt(Nt),Jt=Vt(Yt),Zt=Vt("- —/~|┆·");var $t;!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"}($t||($t={}));const{Letter:Kt,Single:te,Before:ee,After:ne,Symbol:ie,Break:ae}=$t;function oe(t){return Xt[t]?Kt:Zt[t]?ae:zt[t]?ee:Qt[t]?ne:Jt[t]?ie:qt.test(t)?te:Kt}const se={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function re(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=se,{Letter:le,Single:ce,Before:he,After:ue,Symbol:fe,Break:pe}=$t;let ge,_e,we,ye,me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce=[];function Oe(t,e){Be&&!be&&(be=Be),ge.data.push({char:t,width:e}),we+=e}function We(){ye+=we,ge.width=we,_e.words.push(ge),ge={data:[]},we=0}function Te(){Se&&(Pe.paraNumber++,_e.paraStart=!0,Se=!1),Be&&(_e.startCharSize=be,_e.endCharSize=Be,be=0),_e.width=ye,Ae.width&&de(_e),Ce.push(_e),_e={words:[]},ye=0}const Me=0,Ie=1,De=2;const{top:He,right:Fe,bottom:Ge,left:je}=t.Direction4;function Ue(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ne={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o&&(i=l[je],o-=l[Fe]+l[je]),s&&(a=l[He],s-=l[He]+l[Ge]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Pe=e,Ce=e.rows,Ae=e.bounds;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ae;if(d||l||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Se=!0,Re=null,be=xe=Be=we=ye=0,ge={data:[]},_e={words:[]};for(let i=0,l=n.length;i<l;i++)ve=n[i],"\n"===ve?(we&&We(),_e.paraEnd=!0,Te(),Se=!0):(Ee=oe(ve),Ee===le&&"none"!==s&&(ve=re(ve,s,!we)),xe=r.measureText(ve).width,a&&(a<0&&(Be=xe),xe+=a),Le=Ee===ce&&(Re===ce||Re===le)||Re===ce&&Ee!==ue,ke=!(Ee!==he&&Ee!==ce||Re!==fe&&Re!==ue),me=Se&&o?d-o:d,t&&d&&ye+we+xe>me&&(e?(we&&We(),Te()):(ke||(ke=Ee===le&&Re==ue),Le||ke||Ee===pe||Ee===he||Ee===ce||we+xe>me?(we&&We(),Te()):Te()))," "===ve&&!0!==Se&&ye+we===0||(Ee===pe?(" "===ve&&we&&We(),Oe(ve,xe),We()):Le||ke?(we&&We(),Oe(ve,xe)):Oe(ve,xe)),Re=Ee);we&&We(),ye&&Te(),Ce.length>0&&(Ce[Ce.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Pe.paraNumber++,Ce.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,i,a){if(!i)switch(n.textAlign){case"left":Ue(e,"x",t[je]);break;case"right":Ue(e,"x",-t[Fe])}if(!a)switch(n.verticalAlign){case"top":Ue(e,"y",t[He]);break;case"bottom":Ue(e,"y",-t[Ge])}}(l,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=i,y=a*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,a),t.overflow=n.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=n.length;o<l;o++){if(h=n[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+=a,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,s<0&&(h.width<0?(f=-h.width+e.fontSize+s,u-=f,f+=e.fontSize):f-=s),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=y}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let d,l,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Me:l>.01?Ie:De,t.isOverflow&&!r&&(t.textMode=!0),h===De?(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===Ie?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.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,n,o),c.overflow&&function(e,n){const{rows:i,overflow:a}=e;let{textOverflow:o}=n;if(i.splice(a),o&&"show"!==o){let e,s;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?t.Platform.canvas.measureText(o).width:0,d=n.x+n.width-r;("none"===n.textWrap?i:[i[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],s=e.x+e.width,!(i===n&&s<d));i--){if(s<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:o,x:s}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ye={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:qe,addPoint:Ve,toBounds:Xe}=t.TwoPointBoundsHelper;const ze={export(e,n,a){return this.running=!0,function(e){Qe||(Qe=new t.TaskProcessor);return new Promise((t=>{Qe.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((s=>{const r=t=>{o(t),s(),this.running=!1},{toURL:d}=t.Platform,{download:l}=t.Platform.origin,c=t.FileHelper.fileType(n);if("json"===n)return r({data:e.toJSON()});if("json"===c)return l(d(JSON.stringify(e.toJSON()),"text"),n),r({data:!0});if("svg"===n)return r({data:e.toSVG()});if("svg"===c)return l(d(e.toSVG(),"svg"),n),r({data:!0});const{leafer:h}=e;h?h.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){a=t.FileHelper.getExportOptions(a);let i,o,s=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=a;let _=a.scale||1,w=a.pixelRatio||1;e.isApp&&(_*=w,w=e.app.pixelRatio);const y=a.screenshot||e.isApp,m=c&&y&&void 0===a.fill?e.fill:a.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(y)i=!0===y?c?h.canvas.bounds:e.worldRenderBounds:y;else{let t=a.relative||(c?"inner":"local");switch(s=l.scaleX,d=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),s/=e.scaleX,d/=e.scaleY;break;case"world":s=1,d=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,d/=d/n.scaleY}i=e.getBounds("render",t)}const{x:b,y:B,width:E,height:R}=new t.Bounds(i).scale(_);let L=t.Creator.canvas({width:Math.round(E),height:Math.round(R),pixelRatio:w});const k={matrix:x.scale(1/_).invert().translate(-b,-B).withScale(1/s*_,1/d*_)};if(f&&(e=h,k.bounds=L.bounds),L.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(L,k),e.fill=t}else e.__render(L,k);if(L.restore(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,d=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=d%n,s=(d-o)/n,r?Ve(r,o,s):qe(r={},o,s)),d++;const l=new t.Bounds;return Xe(r,l),l.scale(1/e.pixelRatio).ceil()}(L);const e=L,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:w};L=t.Creator.canvas(a),L.copyWorld(e,o,a)}v&&L.fillWorld(L.bounds,m||"#FFFFFF","destination-over"),g&&g(L);const S="canvas"===n?L:yield L.export(n,a);r({data:S,width:L.pixelWidth,height:L.pixelHeight,renderBounds:i,trimBounds:o})})))):r({data:!1})}))))}};let Qe;const Je=t.LeaferCanvasBase.prototype,Ze=t.Debug.get("@leafer-ui/export");Je.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},Je.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{Ze.error(t),i(null)}))}))},Je.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},Je.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{Ze.error(t),i(!1)}))}))},Object.assign(n.TextConvert,Ne),Object.assign(n.ColorConvert,Ye),Object.assign(n.Paint,W),Object.assign(n.PaintImage,ut),Object.assign(n.PaintGradient,At),Object.assign(n.Effect,Ht),Object.assign(n.Export,ze),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=a,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,a){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=a;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:r}=a;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>i(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,a)=>i(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(s(n)),a))})),download(t,e){},loadImage:r}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-draw/node",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.26",
|
|
4
4
|
"description": "@leafer-draw/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"leaferjs"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@leafer/node": "1.0.0-rc.
|
|
35
|
-
"@leafer-draw/partner": "1.0.0-rc.
|
|
36
|
-
"@leafer-ui/draw": "1.0.0-rc.
|
|
37
|
-
"@leafer-ui/partner": "1.0.0-rc.
|
|
38
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
34
|
+
"@leafer/node": "1.0.0-rc.26",
|
|
35
|
+
"@leafer-draw/partner": "1.0.0-rc.26",
|
|
36
|
+
"@leafer-ui/draw": "1.0.0-rc.26",
|
|
37
|
+
"@leafer-ui/partner": "1.0.0-rc.26",
|
|
38
|
+
"@leafer-ui/interface": "1.0.0-rc.26"
|
|
39
39
|
}
|
|
40
40
|
}
|