@leafer-draw/node 1.2.2 → 1.3.1
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 +30 -24
- package/dist/node.esm.js +30 -24
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +8 -6
- package/src/index.ts +3 -1
- package/types/index.d.ts +1 -0
package/dist/node.cjs
CHANGED
|
@@ -99,6 +99,7 @@ function useCanvas(canvasType, power) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
core.Platform.name = 'node';
|
|
102
|
+
core.Platform.backgrounder = true;
|
|
102
103
|
core.Platform.requestRender = function (render) { setTimeout(render, 16); };
|
|
103
104
|
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
104
105
|
core.Platform.conicGradientSupport = true;
|
|
@@ -2168,7 +2169,14 @@ const ColorConvertModule = {
|
|
|
2168
2169
|
string
|
|
2169
2170
|
};
|
|
2170
2171
|
|
|
2171
|
-
|
|
2172
|
+
Object.assign(draw.TextConvert, TextConvertModule);
|
|
2173
|
+
Object.assign(draw.ColorConvert, ColorConvertModule);
|
|
2174
|
+
Object.assign(draw.Paint, PaintModule);
|
|
2175
|
+
Object.assign(draw.PaintImage, PaintImageModule);
|
|
2176
|
+
Object.assign(draw.PaintGradient, PaintGradientModule);
|
|
2177
|
+
Object.assign(draw.Effect, EffectModule);
|
|
2178
|
+
|
|
2179
|
+
const { setPoint, addPoint, toBounds } = draw.TwoPointBoundsHelper;
|
|
2172
2180
|
function getTrimBounds(canvas) {
|
|
2173
2181
|
const { width, height } = canvas.view;
|
|
2174
2182
|
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
@@ -2181,7 +2189,7 @@ function getTrimBounds(canvas) {
|
|
|
2181
2189
|
}
|
|
2182
2190
|
index++;
|
|
2183
2191
|
}
|
|
2184
|
-
const bounds = new
|
|
2192
|
+
const bounds = new draw.Bounds();
|
|
2185
2193
|
toBounds(pointBounds, bounds);
|
|
2186
2194
|
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
2187
2195
|
}
|
|
@@ -2189,17 +2197,17 @@ function getTrimBounds(canvas) {
|
|
|
2189
2197
|
const ExportModule = {
|
|
2190
2198
|
export(leaf, filename, options) {
|
|
2191
2199
|
this.running = true;
|
|
2192
|
-
const fileType =
|
|
2200
|
+
const fileType = draw.FileHelper.fileType(filename);
|
|
2193
2201
|
const isDownload = filename.includes('.');
|
|
2194
|
-
options =
|
|
2202
|
+
options = draw.FileHelper.getExportOptions(options);
|
|
2195
2203
|
return addTask((success) => new Promise((resolve) => {
|
|
2196
2204
|
const over = (result) => {
|
|
2197
2205
|
success(result);
|
|
2198
2206
|
resolve();
|
|
2199
2207
|
this.running = false;
|
|
2200
2208
|
};
|
|
2201
|
-
const { toURL } =
|
|
2202
|
-
const { download } =
|
|
2209
|
+
const { toURL } = draw.Platform;
|
|
2210
|
+
const { download } = draw.Platform.origin;
|
|
2203
2211
|
if (fileType === 'json') {
|
|
2204
2212
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2205
2213
|
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
@@ -2219,7 +2227,7 @@ const ExportModule = {
|
|
|
2219
2227
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2220
2228
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2221
2229
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
2222
|
-
const needFill =
|
|
2230
|
+
const needFill = draw.FileHelper.isOpaqueImage(filename) || fill, matrix = new draw.Matrix();
|
|
2223
2231
|
if (screenshot) {
|
|
2224
2232
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2225
2233
|
}
|
|
@@ -2251,16 +2259,16 @@ const ExportModule = {
|
|
|
2251
2259
|
renderBounds = leaf.getBounds('render', relative);
|
|
2252
2260
|
}
|
|
2253
2261
|
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
2254
|
-
|
|
2262
|
+
draw.MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2255
2263
|
let pixelRatio = options.pixelRatio || 1;
|
|
2256
2264
|
if (leaf.isApp) {
|
|
2257
2265
|
scaleData.scaleX *= pixelRatio;
|
|
2258
2266
|
scaleData.scaleY *= pixelRatio;
|
|
2259
2267
|
pixelRatio = leaf.app.pixelRatio;
|
|
2260
2268
|
}
|
|
2261
|
-
const { x, y, width, height } = new
|
|
2269
|
+
const { x, y, width, height } = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2262
2270
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2263
|
-
let canvas =
|
|
2271
|
+
let canvas = draw.Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2264
2272
|
let sliceLeaf;
|
|
2265
2273
|
if (slice) {
|
|
2266
2274
|
sliceLeaf = leaf;
|
|
@@ -2285,7 +2293,7 @@ const ExportModule = {
|
|
|
2285
2293
|
trimBounds = getTrimBounds(canvas);
|
|
2286
2294
|
const old = canvas, { width, height } = trimBounds;
|
|
2287
2295
|
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
2288
|
-
canvas =
|
|
2296
|
+
canvas = draw.Creator.canvas(config);
|
|
2289
2297
|
canvas.copyWorld(old, trimBounds, config);
|
|
2290
2298
|
}
|
|
2291
2299
|
if (needFill)
|
|
@@ -2305,7 +2313,7 @@ const ExportModule = {
|
|
|
2305
2313
|
let tasker;
|
|
2306
2314
|
function addTask(task) {
|
|
2307
2315
|
if (!tasker)
|
|
2308
|
-
tasker = new
|
|
2316
|
+
tasker = new draw.TaskProcessor();
|
|
2309
2317
|
return new Promise((resolve) => {
|
|
2310
2318
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
2311
2319
|
});
|
|
@@ -2317,10 +2325,10 @@ function checkLazy(leaf) {
|
|
|
2317
2325
|
leaf.children.forEach(child => checkLazy(child));
|
|
2318
2326
|
}
|
|
2319
2327
|
|
|
2320
|
-
const canvas =
|
|
2321
|
-
const debug =
|
|
2328
|
+
const canvas = draw.LeaferCanvasBase.prototype;
|
|
2329
|
+
const debug = draw.Debug.get('@leafer-in/export');
|
|
2322
2330
|
canvas.export = function (filename, options) {
|
|
2323
|
-
const { quality, blob } =
|
|
2331
|
+
const { quality, blob } = draw.FileHelper.getExportOptions(options);
|
|
2324
2332
|
if (filename.includes('.'))
|
|
2325
2333
|
return this.saveAs(filename, quality);
|
|
2326
2334
|
else if (blob)
|
|
@@ -2330,7 +2338,7 @@ canvas.export = function (filename, options) {
|
|
|
2330
2338
|
};
|
|
2331
2339
|
canvas.toBlob = function (type, quality) {
|
|
2332
2340
|
return new Promise((resolve) => {
|
|
2333
|
-
|
|
2341
|
+
draw.Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2334
2342
|
resolve(blob);
|
|
2335
2343
|
}).catch((e) => {
|
|
2336
2344
|
debug.error(e);
|
|
@@ -2339,11 +2347,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2339
2347
|
});
|
|
2340
2348
|
};
|
|
2341
2349
|
canvas.toDataURL = function (type, quality) {
|
|
2342
|
-
return
|
|
2350
|
+
return draw.Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
2343
2351
|
};
|
|
2344
2352
|
canvas.saveAs = function (filename, quality) {
|
|
2345
2353
|
return new Promise((resolve) => {
|
|
2346
|
-
|
|
2354
|
+
draw.Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2347
2355
|
resolve(true);
|
|
2348
2356
|
}).catch((e) => {
|
|
2349
2357
|
debug.error(e);
|
|
@@ -2352,13 +2360,11 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2352
2360
|
});
|
|
2353
2361
|
};
|
|
2354
2362
|
|
|
2355
|
-
|
|
2356
|
-
Object.assign(draw.ColorConvert, ColorConvertModule);
|
|
2357
|
-
Object.assign(draw.Paint, PaintModule);
|
|
2358
|
-
Object.assign(draw.PaintImage, PaintImageModule);
|
|
2359
|
-
Object.assign(draw.PaintGradient, PaintGradientModule);
|
|
2360
|
-
Object.assign(draw.Effect, EffectModule);
|
|
2363
|
+
draw.Plugin.add('export');
|
|
2361
2364
|
Object.assign(draw.Export, ExportModule);
|
|
2365
|
+
draw.UI.prototype.export = function (filename, options) {
|
|
2366
|
+
return draw.Export.export(this, filename, options);
|
|
2367
|
+
};
|
|
2362
2368
|
|
|
2363
2369
|
Object.defineProperty(exports, "LeaferImage", {
|
|
2364
2370
|
enumerable: true,
|
package/dist/node.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
|
|
5
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1, TwoPointBoundsHelper, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin, UI } from '@leafer-ui/draw';
|
|
6
6
|
export * from '@leafer-ui/draw';
|
|
7
7
|
|
|
8
8
|
/******************************************************************************
|
|
@@ -100,6 +100,7 @@ function useCanvas(canvasType, power) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
Platform.name = 'node';
|
|
103
|
+
Platform.backgrounder = true;
|
|
103
104
|
Platform.requestRender = function (render) { setTimeout(render, 16); };
|
|
104
105
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
105
106
|
Platform.conicGradientSupport = true;
|
|
@@ -2169,6 +2170,13 @@ const ColorConvertModule = {
|
|
|
2169
2170
|
string
|
|
2170
2171
|
};
|
|
2171
2172
|
|
|
2173
|
+
Object.assign(TextConvert, TextConvertModule);
|
|
2174
|
+
Object.assign(ColorConvert, ColorConvertModule);
|
|
2175
|
+
Object.assign(Paint, PaintModule);
|
|
2176
|
+
Object.assign(PaintImage, PaintImageModule);
|
|
2177
|
+
Object.assign(PaintGradient, PaintGradientModule);
|
|
2178
|
+
Object.assign(Effect, EffectModule);
|
|
2179
|
+
|
|
2172
2180
|
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
2173
2181
|
function getTrimBounds(canvas) {
|
|
2174
2182
|
const { width, height } = canvas.view;
|
|
@@ -2182,7 +2190,7 @@ function getTrimBounds(canvas) {
|
|
|
2182
2190
|
}
|
|
2183
2191
|
index++;
|
|
2184
2192
|
}
|
|
2185
|
-
const bounds = new Bounds();
|
|
2193
|
+
const bounds = new Bounds$1();
|
|
2186
2194
|
toBounds(pointBounds, bounds);
|
|
2187
2195
|
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
2188
2196
|
}
|
|
@@ -2190,17 +2198,17 @@ function getTrimBounds(canvas) {
|
|
|
2190
2198
|
const ExportModule = {
|
|
2191
2199
|
export(leaf, filename, options) {
|
|
2192
2200
|
this.running = true;
|
|
2193
|
-
const fileType = FileHelper.fileType(filename);
|
|
2201
|
+
const fileType = FileHelper$1.fileType(filename);
|
|
2194
2202
|
const isDownload = filename.includes('.');
|
|
2195
|
-
options = FileHelper.getExportOptions(options);
|
|
2203
|
+
options = FileHelper$1.getExportOptions(options);
|
|
2196
2204
|
return addTask((success) => new Promise((resolve) => {
|
|
2197
2205
|
const over = (result) => {
|
|
2198
2206
|
success(result);
|
|
2199
2207
|
resolve();
|
|
2200
2208
|
this.running = false;
|
|
2201
2209
|
};
|
|
2202
|
-
const { toURL } = Platform;
|
|
2203
|
-
const { download } = Platform.origin;
|
|
2210
|
+
const { toURL } = Platform$1;
|
|
2211
|
+
const { download } = Platform$1.origin;
|
|
2204
2212
|
if (fileType === 'json') {
|
|
2205
2213
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2206
2214
|
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
@@ -2220,7 +2228,7 @@ const ExportModule = {
|
|
|
2220
2228
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2221
2229
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2222
2230
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
2223
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
2231
|
+
const needFill = FileHelper$1.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
2224
2232
|
if (screenshot) {
|
|
2225
2233
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2226
2234
|
}
|
|
@@ -2252,16 +2260,16 @@ const ExportModule = {
|
|
|
2252
2260
|
renderBounds = leaf.getBounds('render', relative);
|
|
2253
2261
|
}
|
|
2254
2262
|
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
2255
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2263
|
+
MathHelper$1.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2256
2264
|
let pixelRatio = options.pixelRatio || 1;
|
|
2257
2265
|
if (leaf.isApp) {
|
|
2258
2266
|
scaleData.scaleX *= pixelRatio;
|
|
2259
2267
|
scaleData.scaleY *= pixelRatio;
|
|
2260
2268
|
pixelRatio = leaf.app.pixelRatio;
|
|
2261
2269
|
}
|
|
2262
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2270
|
+
const { x, y, width, height } = new Bounds$1(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2263
2271
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2264
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2272
|
+
let canvas = Creator$1.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2265
2273
|
let sliceLeaf;
|
|
2266
2274
|
if (slice) {
|
|
2267
2275
|
sliceLeaf = leaf;
|
|
@@ -2286,7 +2294,7 @@ const ExportModule = {
|
|
|
2286
2294
|
trimBounds = getTrimBounds(canvas);
|
|
2287
2295
|
const old = canvas, { width, height } = trimBounds;
|
|
2288
2296
|
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
2289
|
-
canvas = Creator.canvas(config);
|
|
2297
|
+
canvas = Creator$1.canvas(config);
|
|
2290
2298
|
canvas.copyWorld(old, trimBounds, config);
|
|
2291
2299
|
}
|
|
2292
2300
|
if (needFill)
|
|
@@ -2318,10 +2326,10 @@ function checkLazy(leaf) {
|
|
|
2318
2326
|
leaf.children.forEach(child => checkLazy(child));
|
|
2319
2327
|
}
|
|
2320
2328
|
|
|
2321
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
2322
|
-
const debug = Debug.get('@leafer-
|
|
2329
|
+
const canvas = LeaferCanvasBase$1.prototype;
|
|
2330
|
+
const debug = Debug$1.get('@leafer-in/export');
|
|
2323
2331
|
canvas.export = function (filename, options) {
|
|
2324
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
2332
|
+
const { quality, blob } = FileHelper$1.getExportOptions(options);
|
|
2325
2333
|
if (filename.includes('.'))
|
|
2326
2334
|
return this.saveAs(filename, quality);
|
|
2327
2335
|
else if (blob)
|
|
@@ -2331,7 +2339,7 @@ canvas.export = function (filename, options) {
|
|
|
2331
2339
|
};
|
|
2332
2340
|
canvas.toBlob = function (type, quality) {
|
|
2333
2341
|
return new Promise((resolve) => {
|
|
2334
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2342
|
+
Platform$1.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2335
2343
|
resolve(blob);
|
|
2336
2344
|
}).catch((e) => {
|
|
2337
2345
|
debug.error(e);
|
|
@@ -2340,11 +2348,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2340
2348
|
});
|
|
2341
2349
|
};
|
|
2342
2350
|
canvas.toDataURL = function (type, quality) {
|
|
2343
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
2351
|
+
return Platform$1.origin.canvasToDataURL(this.view, type, quality);
|
|
2344
2352
|
};
|
|
2345
2353
|
canvas.saveAs = function (filename, quality) {
|
|
2346
2354
|
return new Promise((resolve) => {
|
|
2347
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2355
|
+
Platform$1.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2348
2356
|
resolve(true);
|
|
2349
2357
|
}).catch((e) => {
|
|
2350
2358
|
debug.error(e);
|
|
@@ -2353,12 +2361,10 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2353
2361
|
});
|
|
2354
2362
|
};
|
|
2355
2363
|
|
|
2356
|
-
|
|
2357
|
-
Object.assign(ColorConvert, ColorConvertModule);
|
|
2358
|
-
Object.assign(Paint, PaintModule);
|
|
2359
|
-
Object.assign(PaintImage, PaintImageModule);
|
|
2360
|
-
Object.assign(PaintGradient, PaintGradientModule);
|
|
2361
|
-
Object.assign(Effect, EffectModule);
|
|
2364
|
+
Plugin.add('export');
|
|
2362
2365
|
Object.assign(Export, ExportModule);
|
|
2366
|
+
UI.prototype.export = function (filename, options) {
|
|
2367
|
+
return Export.export(this, filename, options);
|
|
2368
|
+
};
|
|
2363
2369
|
|
|
2364
2370
|
export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
|
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,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as p,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as S,AlignHelper as k,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as T,TaskProcessor as O,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as M}from"fs";import{PaintImage as D,ColorConvert as I,PaintGradient as P,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function z(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 G 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}=a;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:t=>n(e.image.getRealURL(t))},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)=>z(this,void 0,void 0,(function*(){return t.toBuffer(j(e),i)})),canvasSaveAs:(t,e,i)=>z(this,void 0,void 0,(function*(){return M(e,t.toBuffer(j(q(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class H{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Q,updateBounds:J,updateAllWorldOpacity:Z}=f,{pushAllChildBranch:$,pushAllParent:K}=_;const{worldBounds:tt}=g,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:nt,updateAllChange:st}=f,ot=w.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||J(n[t])}J(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Z(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),at.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),st(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=w.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,rt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new p(n);i.save(),s&&!w.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(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.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),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__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.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||rt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.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 lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function ct(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):ut(e,i);break;case"inside":ht("inside",t,s,e,i);break;case"outside":ht("outside",t,s,e,i)}}function ht(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ft(e,!0,n,r):ut(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",lt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ut(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ut(i,n):n.stroke(),n.restoreBlendMode()):e?ut(i,n):n.stroke())}function _t(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=at.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:wt,getIntersectData:yt}=B;let mt;function vt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:I.string(a,r)};case"image":return D.image(i,t,e,n,!mt||!mt[e.url]);case"linear":return P.linearGradient(e,n);case"radial":return P.radialGradient(e,n);case"angular":return P.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:I.string(e)}:void 0}}const xt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),mt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=vt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?lt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&D.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?lt(e,i):s?i.fill(s):i.fill())},fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ct(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&_t(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ct(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i),n.__useArrow&&_t(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ft(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ct,drawTextStroke:ut,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=yt(n?pt(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=gt(s,a),o=wt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let bt={};const{get:Bt,rotateOfOuter:Rt,translate:St,scaleOfOuter:kt,scale:Et,rotate:Lt}=R;function At(t,e,i,n,s,o,a){const r=Bt();St(r,e.x+i,e.y+n),Et(r,s,o),a&&Rt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,n,s,o,a){const r=Bt();St(r,e.x+i,e.y+n),s&&Et(r,s,o),a&&Lt(r,a),t.transform=r}function Tt(t,e,i,n,s,o,a,r,d,l){const c=Bt();if(d)if("center"===l)Rt(c,{x:i/2,y:n/2},d);else switch(Lt(c,d),d){case 90:St(c,n,0);break;case 180:St(c,i,n);break;case 270:St(c,0,i)}bt.x=e.x+s,bt.y=e.y+o,St(c,bt.x,bt.y),a&&kt(c,bt,a,r),t.transform=c}const{get:Ot,translate:Ct}=R,Mt=new p,Dt={},It={};function Pt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Ft(i,n,e)}function Ft(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Mt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,_={mode:a},p="center"!==r&&(h||0)%180==90,g=p?s:n,w=p?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,i,It),y=It.scaleX,m=It.scaleY);else if(!f||h){const t=e.width/g,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),k.toPoint(r,t,e,Dt,!0),v+=Dt.x,x+=Dt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Wt(_,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Tt(_,e,n,s,v,x,y,m,h,r),u||(_.repeat="repeat");break;default:y&&At(_,e,v,x,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=Ot(),Ct(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=n,_.height=s,o&&(_.opacity=o),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Yt,Ut=new p;const{isSame:Xt}=B;function Nt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Pt(s,n,i,o),!0}function zt(t,e){qt(t,E.LOAD,e)}function Gt(t,e){qt(t,E.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,E.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ht,scale:Qt,copy:Jt}=R,{ceil:Zt,abs:$t}=Math;function Kt(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=$t(s),o=$t(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Ht(),Jt(l,p),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),(p||1!==s||1!==o)&&(l||(l=Ht(),p&&Jt(l,p)),Qt(l,1/s,1/o));const m=t.getCanvas(Zt(c)||1,Zt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}const{abs:te}=Math;const ee={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return Yt&&i===Yt.paint&&Xt(n,Yt.boxBounds)?o=Yt.leafPaint:(o={type:i.type,image:r},Yt=r.use>1?{leafPaint:o,paint:i,boxBounds:Ut.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Nt(t,e,i,r,o,n),s&&(zt(t,a),Gt(t,a))):r.error?s&&jt(t,a,r.error):(s&&(Vt(t,!0),zt(t,a)),o.loadId=r.load((()=>{Vt(t,!1),t.destroyed||(Nt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Vt(t,!1),jt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=te(o)*r,i*=te(a)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||F.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||F.running?Kt(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>z(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Kt(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Kt,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,x.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Pt,getPatternData:Ft,fillOrFitMode:At,clipMode:Wt,repeatMode:Tt},{toPoint:ie}=L,ne={},se={};function oe(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),I.string(n,i)):t.addColorStop(n.offset,I.string(n.color,i))}}const{getAngle:ae,getDistance:re}=A,{get:de,rotateOfOuter:le,scaleOfOuter:ce}=R,{toPoint:he}=L,ue={},fe={};function _e(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ae(e,i);o=de(),s?(ce(o,e,a/r*(n||1),1),le(o,e,t+90)):(ce(o,e,1,a/r*(n||1)),le(o,e,t))}return o}const{getDistance:pe}=A,{toPoint:ge}=L,we={},ye={};const me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ie(n||"top",i,ne),ie(s||"bottom",i,se);const d=e.canvas.createLinearGradient(ne.x,ne.y,se.x,se.y);oe(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;he(n||"center",i,ue),he(s||"bottom",i,fe);const l=e.canvas.createRadialGradient(ue.x,ue.y,0,ue.x,ue.y,re(ue,fe));oe(l,t.stops,a);const c={type:o,style:l},h=_e(i,ue,fe,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",i,we),ge(s||"bottom",i,ye);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,we.x,we.y):e.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,pe(we,ye));oe(l,t.stops,a);const c={type:o,style:l},h=_e(i,we,ye,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:_e},{copy:ve,toOffsetOutBounds:xe}=B,be={},Be={};function Re(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ve(be,t.bounds),be.x+=i.x-a.x,be.y+=i.y-a.y,n){const{matrix:t}=s;be.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),be.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),be.width*=n,be.height*=n}t.copyWorld(s.canvas,t.bounds,be)}else n&&(ve(be,i),be.x-=i.width/2*(n-1),be.y-=i.height/2*(n-1),be.width*=n,be.height*=n),t.copyWorld(s.canvas,a,n?be:i)}const{toOffsetOutBounds:Se}=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(),_=r.length-1;xe(l,Be),r.forEach(((r,p)=>{f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(f,Be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&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(),_=r.length-1;Se(l,ke),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Re(f,ke,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Le}=g;function Ae(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Te(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Te(t,i,n,o);break;case"path":i.restore()}}function We(t){return t.getSameCanvas(!1,!0)}function Te(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(Ae(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=We(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=We(t)),s||(s=We(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Le(i,e)||i.__render(s||t,e);Ae(this,a,t,s,n,o)};const Oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=Oe+"_#~&*+\\=|≮≯≈≠=…",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 De(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ie=De("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Pe=De("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Fe=De(Oe),Ye=De(Ce),Ue=De("- —/~|┆·");var Xe;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Xe||(Xe={}));const{Letter:Ne,Single:ze,Before:Ge,After:je,Symbol:qe,Break:Ve}=Xe;function He(t){return Ie[t]?Ne:Ue[t]?Ve:Pe[t]?Ge:Fe[t]?je:Ye[t]?qe:Me.test(t)?ze:Ne}const Qe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Je(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ze}=Qe,{Letter:$e,Single:Ke,Before:ti,After:ei,Symbol:ii,Break:ni}=Xe;let si,oi,ai,ri,di,li,ci,hi,ui,fi,_i,pi,gi,wi,yi,mi,vi,xi=[];function bi(t,e){ui&&!hi&&(hi=ui),si.data.push({char:t,width:e}),ai+=e}function Bi(){ri+=ai,si.width=ai,oi.words.push(si),si={data:[]},ai=0}function Ri(){wi&&(yi.paraNumber++,oi.paraStart=!0,wi=!1),ui&&(oi.startCharSize=hi,oi.endCharSize=ui,hi=0),oi.width=ri,mi.width?Ze(oi):vi&&Si(),xi.push(oi),oi={words:[]},ri=0}function Si(){ri>(yi.maxWidth||0)&&(yi.maxWidth=ri)}const ki=0,Ei=1,Li=2;const{top:Ai,right:Wi,bottom:Ti,left:Oi}=W;function Ci(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Mi={getDrawData:function(t,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[Oi],o-=l[Wi]+l[Oi]):i.autoSizeAlign||(n=l[Oi]),a?(s=l[Ai],a-=l[Ai]+l[Ti]):i.autoSizeAlign||(s=l[Ai]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){yi=t,xi=t.rows,mi=t.bounds,vi=!mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=mi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;wi=!0,_i=null,hi=ci=ui=ai=ri=0,si={data:[]},oi={words:[]};for(let n=0,l=i.length;n<l;n++)li=i[n],"\n"===li?(ai&&Bi(),oi.paraEnd=!0,Ri(),wi=!0):(fi=He(li),fi===$e&&"none"!==a&&(li=Je(li,a,!ai)),ci=r.measureText(li).width,s&&(s<0&&(ui=ci),ci+=s),pi=fi===Ke&&(_i===Ke||_i===$e)||_i===Ke&&fi!==ei,gi=!(fi!==ti&&fi!==Ke||_i!==ii&&_i!==ei),di=wi&&o?d-o:d,t&&d&&ri+ai+ci>di&&(e?(ai&&Bi(),ri&&Ri()):(gi||(gi=fi===$e&&_i==ei),pi||gi||fi===ni||fi===ti||fi===Ke||ai+ci>di?(ai&&Bi(),ri&&Ri()):ri&&Ri()))," "===li&&!0!==wi&&ri+ai===0||(fi===ni?(" "===li&&ai&&Bi(),bi(li,ci),Bi()):pi||gi?(ai&&Bi(),bi(li,ci)):bi(li,ci)),_i=fi);ai&&Bi(),ri&&Ri(),xi.length>0&&(xi[xi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{yi.paraNumber++,ri=r.measureText(t).width,xi.push({x:o||0,text:t,width:ri,paraStart:!0}),vi&&Si()}))}(c,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ci(e,"x",t[Oi]);break;case"right":Ci(e,"x",-t[Wi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ci(e,"y",t[Ai]);break;case"bottom":Ci(e,"y",-t[Ti])}}(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,autoSizeAlign:h}=e;let{x:u,y:f,width:_,height:p}=n,g=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>p)g=Math.max(p,s),t.overflow=i.length;else if(p||h)switch(l){case"middle":f+=(p-g)/2;break;case"bottom":f+=p-g}w+=f;let y,m,v,x=_||h?_:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(y=i[o],y.x=u,y.width<_||y.width>_&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=g}(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?ki:l>.01?Ei:Li,t.isOverflow&&!r&&(t.textMode=!0),h===Li?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ei?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const Di={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:Ii,addPoint:Pi,toBounds:Fi}=T;const Yi={export(t,i,s){this.running=!0;const o=a.fileType(i),r=i.includes(".");return s=a.getExportOptions(s),function(t){Ui||(Ui=new O);return new Promise((e=>{Ui.add((()=>z(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const c=t=>{d(t),l(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===o)return r&&u(h(JSON.stringify(t.toJSON(s.json)),"text"),i),c({data:!!r||t.toJSON(s.json)});if("svg"===o)return r&&u(h(t.toSVG(),"svg"),i),c({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Xi(t),f.waitViewCompleted((()=>z(this,void 0,void 0,(function*(){let e,o,r=1,d=1;const{worldTransform:l,isLeafer:h,isFrame:u}=t,{slice:_,trim:g,onCanvas:w}=s,y=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=h&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(i)||x,B=new C;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(h?"inner":"local");switch(r=l.scaleX,d=l.scaleY,i){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":i=t.leafer;default:B.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};S.getScaleData(s.scale,s.size,e,R);let k=s.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:W}=new p(e).scale(R.scaleX,R.scaleY),T={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/r*R.scaleX,1/d*R.scaleY)};let O,M=n.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:k,smooth:y,contextSettings:m});if(_&&(O=t,O.__worldOpacity=0,t=f,T.bounds=M.bounds),M.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(M,T),t.fill=e}else t.__render(M,T);if(M.restore(),O&&O.__updateWorldOpacity(),g){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Pi(a,s,o):Ii(a={},s,o)),r++;const d=new p;return Fi(a,d),d.scale(1/t.pixelRatio).ceil()}(M);const t=M,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:k};M=n.canvas(s),M.copyWorld(t,o,s)}b&&M.fillWorld(M.bounds,x||"#FFFFFF","destination-over"),w&&w(M);const D="canvas"===i?M:yield M.export(i,s);c({data:D,width:M.pixelWidth,height:M.pixelHeight,renderBounds:e,trimBounds:o})}))))):c({data:!1})}))))}};let Ui;function Xi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Xi(t)))}const Ni=t.prototype,zi=w.get("@leafer-ui/export");Ni.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ni.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{zi.error(t),n(null)}))}))},Ni.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ni.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{zi.error(t),n(!1)}))}))},Object.assign(U,Mi),Object.assign(I,Di),Object.assign(X,xt),Object.assign(D,ee),Object.assign(P,me),Object.assign(N,Ee),Object.assign(F,Yi);export{at as Layouter,G as LeaferCanvas,dt as Renderer,H as Watcher,V as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,Bounds as _,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as S,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{PaintImage as O,ColorConvert as C,PaintGradient as M,Export as D,Group as P,TextConvert as I,Paint as F,Effect as Y,Bounds as U,TwoPointBoundsHelper as X,FileHelper as N,TaskProcessor as z,Platform as G,Matrix as j,MathHelper as q,Creator as V,LeaferCanvasBase as H,Debug as Q,Plugin as J,UI as Z}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function $(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 K 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:tt,fileType:et}=a;function nt(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:t=>i(e.image.getRealURL(t))},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(tt(e),n),canvasToBolb:(t,e,n)=>$(this,void 0,void 0,(function*(){return t.toBuffer(tt(e),n)})),canvasSaveAs:(t,e,n)=>$(this,void 0,void 0,(function*(){return T(e,t.toBuffer(tt(et(e)),n))})),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new K(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class it{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.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:st,updateBounds:ot,updateAllWorldOpacity:at}=f,{pushAllChildBranch:rt,pushAllParent:dt}=p;const{worldBounds:lt}=g,ct={x:0,y:0,width:1e5,height:1e5};class ht{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,lt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ct):this.afterBounds.setListWithFn(t,lt),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:ut,updateAllChange:ft}=f,pt=w.get("Layouter");class _t{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=v.start("PartLayout"),{target:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(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?(st(t,!0),e.add(t),t.isBranch&&rt(t,e),dt(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),dt(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||ot(i[t])}ot(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&at(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),_t.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new ht([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new ht(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const gt=w.get("Renderer");class wt{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=d.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,gt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,gt.error(t)}gt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return gt.warn("rendering");if(this.times>3)return gt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return gt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new _(i);n.save(),s&&!w.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(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.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),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new _(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 _(0,0,1,1)),this.update()}}__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||gt.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 l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.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 yt(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 mt(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?bt(t,!0,e,n):xt(e,n);break;case"inside":vt("inside",t,s,e,n);break;case"outside":vt("outside",t,s,e,n)}}function vt(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?bt(e,!0,i,r):xt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",yt(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 xt(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 bt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?xt(n,i):i.stroke(),i.restoreBlendMode()):e?xt(n,i):i.stroke())}function Bt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(i,{watcher:(t,e)=>new it(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,n)=>new wt(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=_t.fullLayout;const{getSpread:Rt,getOuterOf:kt,getByMove:St,getIntersectData:Et}=B;let Lt;function At(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:C.string(a,r)};case"image":return O.image(n,t,e,i,!Lt||!Lt[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:C.string(e)}:void 0}}const Wt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),Lt=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=At(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?yt(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&&O.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?yt(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?yt(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?yt(e,n):s?n.fill(s):n.fill())},fillText:yt,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)mt(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&Bt(e,n);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)mt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),bt(t,!1,e,n),i.__useArrow&&Bt(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),bt(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),bt(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:mt,drawTextStroke:xt,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=Et(i?Rt(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=kt(s,a),o=St(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 Tt={};const{get:Ot,rotateOfOuter:Ct,translate:Mt,scaleOfOuter:Dt,scale:Pt,rotate:It}=R;function Ft(t,e,n,i,s,o,a){const r=Ot();Mt(r,e.x+n,e.y+i),Pt(r,s,o),a&&Ct(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Yt(t,e,n,i,s,o,a){const r=Ot();Mt(r,e.x+n,e.y+i),s&&Pt(r,s,o),a&&It(r,a),t.transform=r}function Ut(t,e,n,i,s,o,a,r,d,l){const c=Ot();if(d)if("center"===l)Ct(c,{x:n/2,y:i/2},d);else switch(It(c,d),d){case 90:Mt(c,i,0);break;case 180:Mt(c,n,i);break;case 270:Mt(c,0,n)}Tt.x=e.x+s,Tt.y=e.y+o,Mt(c,Tt.x,Tt.y),a&&Dt(c,Tt,a,r),t.transform=c}const{get:Xt,translate:Nt}=R,zt=new _,Gt={},jt={};function qt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Vt(n,i,e)}function Vt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===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)(l||c)&&(k.getScaleData(l,c,n,jt),y=jt.scaleX,m=jt.scaleY);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),S.toPoint(r,t,e,Gt,!0),v+=Gt.x,x+=Gt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Yt(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Ut(p,e,i,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&Ft(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=Xt(),Nt(p.transform,e.x,e.y)),y&&"stretch"!==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 Ht,Qt=new _;const{isSame:Jt}=B;function Zt(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||qt(s,i,n,o),!0}function $t(t,e){ee(t,E.LOAD,e)}function Kt(t,e){ee(t,E.LOADED,e)}function te(t,e,n){e.error=n,t.forceUpdate("surface"),ee(t,E.ERROR,e)}function ee(t,e,n){t.hasEvent(e)&&t.emitEvent(new E(e,n))}function ne(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ie,scale:se,copy:oe}=R,{ceil:ae,abs:re}=Math;function de(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=re(s),o=re(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=ie(),oe(l,_),se(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=ie(),_&&oe(l,_)),se(l,1/s,1/o));const m=t.getCanvas(ae(c)||1,ae(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:le}=Math;const ce={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ht&&n===Ht.paint&&Jt(i,Ht.boxBounds)?o=Ht.leafPaint:(o={type:n.type,image:r},Ht=r.use>1?{leafPaint:o,paint:n,boxBounds:Qt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Zt(t,e,n,r,o,i),s&&($t(t,a),Kt(t,a))):r.error?s&&te(t,a,r.error):(s&&(ne(t,!0),$t(t,a)),o.loadId=r.load((()=>{ne(t,!1),t.destroyed||(Zt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{ne(t,!1),te(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!D.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=le(o)*r,n*=le(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||D.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||D.running?de(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>$(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&de(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:de,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,x.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:qt,getPatternData:Vt,fillOrFitMode:Ft,clipMode:Yt,repeatMode:Ut},{toPoint:he}=L,ue={},fe={};function pe(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),C.string(i,n)):t.addColorStop(i.offset,C.string(i.color,n))}}const{getAngle:_e,getDistance:ge}=A,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=R,{toPoint:ve}=L,xe={},be={};function Be(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=_e(e,n);o=we(),s?(me(o,e,a/r*(i||1),1),ye(o,e,t+90)):(me(o,e,1,a/r*(i||1)),ye(o,e,t))}return o}const{getDistance:Re}=A,{toPoint:ke}=L,Se={},Ee={};const Le={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;he(i||"top",n,ue),he(s||"bottom",n,fe);const d=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y);pe(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;ve(i||"center",n,xe),ve(s||"bottom",n,be);const l=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ge(xe,be));pe(l,t.stops,a);const c={type:o,style:l},h=Be(n,xe,be,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;ke(i||"center",n,Se),ke(s||"bottom",n,Ee);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,Re(Se,Ee));pe(l,t.stops,a);const c={type:o,style:l},h=Be(n,Se,Ee,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Be},{copy:Ae,toOffsetOutBounds:We}=B,Te={},Oe={};function Ce(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(Ae(Te,t.bounds),Te.x+=n.x-a.x,Te.y+=n.y-a.y,i){const{matrix:t}=s;Te.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Te.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Te.width*=i,Te.height*=i}t.copyWorld(s.canvas,t.bounds,Te)}else i&&(Ae(Te,n),Te.x-=n.width/2*(i-1),Te.y-=n.height/2*(i-1),Te.width*=i,Te.height*=i),t.copyWorld(s.canvas,a,i?Te:n)}const{toOffsetOutBounds:Me}=B,De={};const Pe={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;We(l,Oe),r.forEach(((r,_)=>{f.setWorldShadow(Oe.offsetX+r.x*h,Oe.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,Oe,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;Me(l,De),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*h,De.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,De,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:Ie}=g;function Fe(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ue(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ue(t,n,i,o);break;case"path":n.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}P.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(Fe(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ye(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ye(t)),s||(s=Ye(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Ie(n,e)||n.__render(s||t,e);Fe(this,a,t,s,i,o)};const Xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ne=Xe+"_#~&*+\\=|≮≯≈≠=…",ze=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 Ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const je=Ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ge(Xe),He=Ge(Ne),Qe=Ge("- —/~|┆·");var Je;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Je||(Je={}));const{Letter:Ze,Single:$e,Before:Ke,After:tn,Symbol:en,Break:nn}=Je;function sn(t){return je[t]?Ze:Qe[t]?nn:qe[t]?Ke:Ve[t]?tn:He[t]?en:ze.test(t)?$e:Ze}const on={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 an(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:rn}=on,{Letter:dn,Single:ln,Before:cn,After:hn,Symbol:un,Break:fn}=Je;let pn,_n,gn,wn,yn,mn,vn,xn,bn,Bn,Rn,kn,Sn,En,Ln,An,Wn,Tn=[];function On(t,e){bn&&!xn&&(xn=bn),pn.data.push({char:t,width:e}),gn+=e}function Cn(){wn+=gn,pn.width=gn,_n.words.push(pn),pn={data:[]},gn=0}function Mn(){En&&(Ln.paraNumber++,_n.paraStart=!0,En=!1),bn&&(_n.startCharSize=xn,_n.endCharSize=bn,xn=0),_n.width=wn,An.width?rn(_n):Wn&&Dn(),Tn.push(_n),_n={words:[]},wn=0}function Dn(){wn>(Ln.maxWidth||0)&&(Ln.maxWidth=wn)}const Pn=0,In=1,Fn=2;const{top:Yn,right:Un,bottom:Xn,left:Nn}=W;function zn(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 Gn={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[Nn],o-=l[Un]+l[Nn]):n.autoSizeAlign||(i=l[Nn]),a?(s=l[Yn],a-=l[Yn]+l[Xn]):n.autoSizeAlign||(s=l[Yn]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){Ln=t,Tn=t.rows,An=t.bounds,Wn=!An.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=An;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;En=!0,Rn=null,xn=vn=bn=gn=wn=0,pn={data:[]},_n={words:[]};for(let i=0,l=n.length;i<l;i++)mn=n[i],"\n"===mn?(gn&&Cn(),_n.paraEnd=!0,Mn(),En=!0):(Bn=sn(mn),Bn===dn&&"none"!==a&&(mn=an(mn,a,!gn)),vn=r.measureText(mn).width,s&&(s<0&&(bn=vn),vn+=s),kn=Bn===ln&&(Rn===ln||Rn===dn)||Rn===ln&&Bn!==hn,Sn=!(Bn!==cn&&Bn!==ln||Rn!==un&&Rn!==hn),yn=En&&o?d-o:d,t&&d&&wn+gn+vn>yn&&(e?(gn&&Cn(),wn&&Mn()):(Sn||(Sn=Bn===dn&&Rn==hn),kn||Sn||Bn===fn||Bn===cn||Bn===ln||gn+vn>yn?(gn&&Cn(),wn&&Mn()):wn&&Mn()))," "===mn&&!0!==En&&wn+gn===0||(Bn===fn?(" "===mn&&gn&&Cn(),On(mn,vn),Cn()):kn||Sn?(gn&&Cn(),On(mn,vn)):On(mn,vn)),Rn=Bn);gn&&Cn(),wn&&Mn(),Tn.length>0&&(Tn[Tn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ln.paraNumber++,wn=r.measureText(t).width,Tn.push({x:o||0,text:t,width:wn,paraStart:!0}),Wn&&Dn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":zn(e,"x",t[Nn]);break;case"right":zn(e,"x",-t[Un])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":zn(e,"y",t[Yn]);break;case"bottom":zn(e,"y",-t[Xn])}}(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,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:_}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>_)g=Math.max(_,s),t.overflow=n.length;else if(_||h)switch(l){case"middle":f+=(_-g)/2;break;case"bottom":f+=_-g}w+=f;let y,m,v,x=p||h?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<p||y.width>p&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(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?Pn:l>.01?In:Fn,t.isOverflow&&!r&&(t.textMode=!0),h===Fn?(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===In?(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,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"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 jn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!C.object)return t;t=C.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,Gn),Object.assign(C,jn),Object.assign(F,Wt),Object.assign(O,ce),Object.assign(M,Le),Object.assign(Y,Pe);const{setPoint:qn,addPoint:Vn,toBounds:Hn}=X;const Qn={export(t,e,n){this.running=!0;const i=N.fileType(e),s=e.includes(".");return n=N.getExportOptions(n),function(t){Jn||(Jn=new z);return new Promise((e=>{Jn.add((()=>$(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((a=>{const r=t=>{o(t),a(),this.running=!1},{toURL:d}=G,{download:l}=G.origin;if("json"===i)return s&&l(d(JSON.stringify(t.toJSON(n.json)),"text"),e),r({data:!!s||t.toJSON(n.json)});if("svg"===i)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:c}=t;c?(Zn(t),c.waitViewCompleted((()=>$(this,void 0,void 0,(function*(){let i,s,o=1,a=1;const{worldTransform:d,isLeafer:l,isFrame:h}=t,{slice:u,trim:f,onCanvas:p}=n,_=void 0===n.smooth?c.config.smooth:n.smooth,g=n.contextSettings||c.config.contextSettings,w=n.screenshot||t.isApp,y=l&&w&&void 0===n.fill?t.fill:n.fill,m=N.isOpaqueImage(e)||y,v=new j;if(w)i=!0===w?l?c.canvas.bounds:t.worldRenderBounds:w;else{let e=n.relative||(l?"inner":"local");switch(o=d.scaleX,a=d.scaleY,e){case"inner":v.set(d);break;case"local":v.set(d).divide(t.localTransform),o/=t.scaleX,a/=t.scaleY;break;case"world":o=1,a=1;break;case"page":e=t.leafer;default:v.set(d).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,a/=a/n.scaleY}i=t.getBounds("render",e)}const x={scaleX:1,scaleY:1};q.getScaleData(n.scale,n.size,i,x);let b=n.pixelRatio||1;t.isApp&&(x.scaleX*=b,x.scaleY*=b,b=t.app.pixelRatio);const{x:B,y:R,width:k,height:S}=new U(i).scale(x.scaleX,x.scaleY),E={matrix:v.scale(1/x.scaleX,1/x.scaleY).invert().translate(-B,-R).withScale(1/o*x.scaleX,1/a*x.scaleY)};let L,A=V.canvas({width:Math.round(k),height:Math.round(S),pixelRatio:b,smooth:_,contextSettings:g});if(u&&(L=t,L.__worldOpacity=0,t=c,E.bounds=A.bounds),A.save(),h&&void 0!==y){const e=t.get("fill");t.fill="",t.__render(A,E),t.fill=e}else t.__render(A,E);if(A.restore(),L&&L.__updateWorldOpacity(),f){s=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?Vn(a,s,o):qn(a={},s,o)),r++;const d=new U;return Hn(a,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:n}=s,i={x:0,y:0,width:e,height:n,pixelRatio:b};A=V.canvas(i),A.copyWorld(t,s,i)}m&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),p&&p(A);const W="canvas"===e?A:yield A.export(e,n);r({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:i,trimBounds:s})}))))):r({data:!1})}))))}};let Jn;function Zn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Zn(t)))}const $n=H.prototype,Kn=Q.get("@leafer-in/export");$n.export=function(t,e){const{quality:n,blob:i}=N.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},$n.toBlob=function(t,e){return new Promise((n=>{G.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{Kn.error(t),n(null)}))}))},$n.toDataURL=function(t,e){return G.origin.canvasToDataURL(this.view,t,e)},$n.saveAs=function(t,e){return new Promise((n=>{G.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{Kn.error(t),n(!1)}))}))},J.add("export"),Object.assign(D,Qn),Z.prototype.export=function(t,e){return D.export(this,t,e)};export{_t as Layouter,K as LeaferCanvas,wt as Renderer,it as Watcher,nt 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{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}l((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,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>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:l,updateBounds:d,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,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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?(l(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||d(i[t])}d(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),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)),y.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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),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=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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.update()}}__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())}function k(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:P,getByMove:A,getIntersectData:C}=t.BoundsHelper;let W;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:l}=e;return{type:o,blendMode:s,style:n.ColorConvert.string(r,l)};case"image":return n.PaintImage.image(i,t,e,a,!W||!W[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 T={compute:function(t,e){const i=e.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),W=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,l=t.length;r<l;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(),i.__useArrow&&k(e,n);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),i.__useArrow&&k(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,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=C(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=P(a,s),o=A(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:l,shapeBounds:r,scaleX:d,scaleY:c}}};let M={};const{get:I,rotateOfOuter:D,translate:H,scaleOfOuter:F,scale:Y,rotate:j}=t.MatrixHelper;function G(t,e,n,i,a,o,s){const r=I();H(r,e.x+n,e.y+i),Y(r,a,o),s&&D(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=I();H(r,e.x+n,e.y+i),a&&Y(r,a,o),s&&j(r,s),t.transform=r}function X(t,e,n,i,a,o,s,r,l,d){const c=I();if(l)if("center"===d)D(c,{x:n/2,y:i/2},l);else switch(j(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}M.x=e.x+a,M.y=e.y+o,H(c,M.x,M.y),s&&F(c,M,s,r),t.transform=c}const{get:z,translate:N}=t.MatrixHelper,q=new t.Bounds,V={},Q={};function J(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=Z(n,i,e)}function Z(e,n,i){let{width:a,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),y=Q.scaleX,v=Q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*y)/2,b+=(n.height-o*v)/2}if(l){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,V,!0),x+=V.x,b+=V.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&U(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&X(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&G(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=z(),N(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,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 K,$=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(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||J(a,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function at(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:rt,scale:lt,copy:dt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=ht(a),o=ht(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=rt(),dt(d,g),lt(d,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 m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=rt(),g&&dt(d,g)),lt(d,1/a,1/o));const y=e.getCanvas(ct(c)||1,ct(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}const{abs:ft}=Math;const pt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return K&&i===K.paint&&tt(a,K.boxBounds)?s=K.leafPaint:(s={type:i.type,image:l},K=l.use>1?{leafPaint:s,paint:i,boxBounds:$.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(et(e,n,i,l,s,a),o&&(nt(e,r),it(e,r))):l.error?o&&at(e,r,l.error):(o&&(st(e,!0),nt(e,r)),s.loadId=l.load((()=>{st(e,!1),e.destroyed||(et(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,r)),s.loadId=null}),(t=>{st(e,!1),at(e,r,t),s.loadId=null}))),s},checkImage:function(e,a,o,s){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=a;if(!o.data||o.patternId===r+"-"+l+"-"+d&&!n.Export.running)return!1;{const{data:c}=o;if(s)if(c.repeat)s=!1;else{let{width:e,height:i}=c;e*=ft(r)*d,i*=ft(l)*d,c.scaleX&&(e*=c.scaleX,i*=c.scaleY),s=e*i>t.Platform.image.maxCacheSize||n.Export.running}return s?(a.save(),e.windingRule?a.clip(e.windingRule):a.clip(),o.blendMode&&(a.blendMode=o.blendMode),c.opacity&&(a.opacity*=c.opacity),c.transform&&a.transform(c.transform),a.drawImage(o.image.view,0,0,c.width,c.height),a.restore(),!0):(!o.style||o.sync||n.Export.running?ut(e,o,d):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){o.patternTask=null,a.bounds.hit(e.__nowWorld)&&ut(e,o,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].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[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:J,getPatternData:Z,fillOrFitMode:G,clipMode:U,repeatMode:X},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,e,i){if(e){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:yt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=yt(e,n);o=xt(),a?(Bt(o,e,s/r*(i||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(i||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Ct={};const Wt={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;gt(i||"top",n,_t),gt(a||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(a||"bottom",n,Lt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,Rt,Lt,l,!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:l}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ct);const d=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,St(At,Ct));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Ot,toOffsetOutBounds:Tt}=t.BoundsHelper,Mt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Ot(Mt,e.bounds),Mt.x+=n.x-s.x,Mt.y+=n.y-s.y,i){const{matrix:t}=a;Mt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Mt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(a.canvas,e.bounds,Mt)}else i&&(Ot(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(a.canvas,s,i?Mt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Yt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Tt(d,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=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"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:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,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(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),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:jt}=t.LeafBoundsHelper;function Gt(t,e,n,i,a,o){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Xt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Xt(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,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(Gt(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Ut(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Ut(t)),a||(a=Ut(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||jt(n,e)||n.__render(a||t,e);Gt(this,s,t,a,i,o)};const zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=zt+"_#~&*+\\=|≮≯≈≠=…",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 Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Vt(zt),Kt=Vt(Nt),$t=Vt("- —/~|┆·");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:$t[t]?se:Jt[t]?ie:Zt[t]?ae:Kt[t]?oe:qt.test(t)?ne:ee}const le={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 de(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}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce,We,Oe,Te=[];function Me(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),ye+=e}function Ie(){ve+=ye,we.width=ye,me.words.push(we),we={data:[]},ye=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Re&&(me.startCharSize=Ee,me.endCharSize=Re,Ee=0),me.width=ve,We.width?ce(me):Oe&&He(),Te.push(me),me={words:[]},ve=0}function He(){ve>(Ce.maxWidth||0)&&(Ce.maxWidth=ve)}const Fe=0,Ye=1,je=2;const{top:Ge,right:Ue,bottom:Xe,left:ze}=t.Direction4;function Ne(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:l,__padding:d}=n;d&&(o?(i=d[ze],o-=d[Ue]+d[ze]):n.autoSizeAlign||(i=d[ze]),s?(a=d[Ge],s-=d[Ge]+d[Xe]):n.autoSizeAlign||(a=d[Ge]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Te=e.rows,We=e.bounds,Oe=!We.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=ye=ve=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ye&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=de(be,s,!ye)),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?l-o:l,t&&l&&ve+ye+Be>xe&&(e?(ye&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||ye+Be>xe?(ye&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+ye===0||(Le===_e?(" "===be&&ye&&Ie(),Me(be,Be),Ie()):Se||Pe?(ye&&Ie(),Me(be,Be)):Me(be,Be)),ke=Le);ye&&Ie(),ve&&De(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ve=r.measureText(t).width,Te.push({x:o||0,text:t,width:ve,paraStart:!0}),Oe&&He()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Ue])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ge]);break;case"bottom":Ne(e,"y",-t[Xe])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ye:je,t.isOverflow&&!r&&(t.textMode=!0),h===je?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"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 Ve={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=e);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}},{setPoint:Qe,addPoint:Je,toBounds:Ze}=t.TwoPointBoundsHelper;const Ke={export(e,n,a){this.running=!0;const o=t.FileHelper.fileType(n),s=n.includes(".");return a=t.FileHelper.getExportOptions(a),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:c}=t.Platform,{download:h}=t.Platform.origin;if("json"===o)return s&&h(c(JSON.stringify(e.toJSON(a.json)),"text"),n),d({data:!!s||e.toJSON(a.json)});if("svg"===o)return s&&h(c(e.toSVG(),"svg"),n),d({data:!!s||e.toSVG()});const{leafer:u}=e;u?(tn(e),u.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){let i,o,s=1,r=1;const{worldTransform:l,isLeafer:c,isFrame:h}=e,{slice:f,trim:p,onCanvas:g}=a,_=void 0===a.smooth?u.config.smooth:a.smooth,w=a.contextSettings||u.config.contextSettings,m=a.screenshot||e.isApp,y=c&&m&&void 0===a.fill?e.fill:a.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)i=!0===m?c?u.canvas.bounds:e.worldRenderBounds:m;else{let t=a.relative||(c?"inner":"local");switch(s=l.scaleX,r=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}i=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(a.scale,a.size,i,b);let B=a.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(i).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=u,S.bounds=A.bounds),A.save(),h&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(A,S),e.fill=t}else e.__render(A,S);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new t.Bounds;return Ze(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(a),A.copyWorld(e,o,a)}v&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,a);d({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:i,trimBounds:o})}))))):d({data:!1})}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=t.LeaferCanvasBase.prototype,nn=t.Debug.get("@leafer-ui/export");en.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)},en.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},en.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Object.assign(n.TextConvert,qe),Object.assign(n.ColorConvert,Ve),Object.assign(n.Paint,T),Object.assign(n.PaintImage,pt),Object.assign(n.PaintGradient,Wt),Object.assign(n.Effect,Yt),Object.assign(n.Export,Ke),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,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:e=>n(t.Platform.image.getRealURL(e))},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:e=>r(t.Platform.image.getRealURL(e))}}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{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}l((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.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>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:l,updateBounds:d,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,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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?(l(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||d(i[t])}d(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),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)),y.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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),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=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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.update()}}__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())}function k(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:P,getByMove:A,getIntersectData:C}=t.BoundsHelper;let W;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:l}=e;return{type:o,blendMode:s,style:n.ColorConvert.string(r,l)};case"image":return n.PaintImage.image(i,t,e,a,!W||!W[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 T={compute:function(t,e){const i=e.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),W=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,l=t.length;r<l;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(),i.__useArrow&&k(e,n);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),i.__useArrow&&k(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,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=C(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=P(a,s),o=A(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:l,shapeBounds:r,scaleX:d,scaleY:c}}};let M={};const{get:I,rotateOfOuter:D,translate:H,scaleOfOuter:F,scale:Y,rotate:j}=t.MatrixHelper;function U(t,e,n,i,a,o,s){const r=I();H(r,e.x+n,e.y+i),Y(r,a,o),s&&D(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=I();H(r,e.x+n,e.y+i),a&&Y(r,a,o),s&&j(r,s),t.transform=r}function X(t,e,n,i,a,o,s,r,l,d){const c=I();if(l)if("center"===d)D(c,{x:n/2,y:i/2},l);else switch(j(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}M.x=e.x+a,M.y=e.y+o,H(c,M.x,M.y),s&&F(c,M,s,r),t.transform=c}const{get:z,translate:N}=t.MatrixHelper,q=new t.Bounds,V={},Q={};function J(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=Z(n,i,e)}function Z(e,n,i){let{width:a,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),y=Q.scaleX,v=Q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*y)/2,b+=(n.height-o*v)/2}if(l){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,V,!0),x+=V.x,b+=V.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&G(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&X(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&U(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=z(),N(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,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 K,$=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(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||J(a,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function at(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:rt,scale:lt,copy:dt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=ht(a),o=ht(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=rt(),dt(d,g),lt(d,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 m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=rt(),g&&dt(d,g)),lt(d,1/a,1/o));const y=e.getCanvas(ct(c)||1,ct(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}const{abs:ft}=Math;const pt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return K&&i===K.paint&&tt(a,K.boxBounds)?s=K.leafPaint:(s={type:i.type,image:l},K=l.use>1?{leafPaint:s,paint:i,boxBounds:$.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(et(e,n,i,l,s,a),o&&(nt(e,r),it(e,r))):l.error?o&&at(e,r,l.error):(o&&(st(e,!0),nt(e,r)),s.loadId=l.load((()=>{st(e,!1),e.destroyed||(et(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,r)),s.loadId=null}),(t=>{st(e,!1),at(e,r,t),s.loadId=null}))),s},checkImage:function(e,a,o,s){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=a;if(!o.data||o.patternId===r+"-"+l+"-"+d&&!n.Export.running)return!1;{const{data:c}=o;if(s)if(c.repeat)s=!1;else{let{width:e,height:i}=c;e*=ft(r)*d,i*=ft(l)*d,c.scaleX&&(e*=c.scaleX,i*=c.scaleY),s=e*i>t.Platform.image.maxCacheSize||n.Export.running}return s?(a.save(),e.windingRule?a.clip(e.windingRule):a.clip(),o.blendMode&&(a.blendMode=o.blendMode),c.opacity&&(a.opacity*=c.opacity),c.transform&&a.transform(c.transform),a.drawImage(o.image.view,0,0,c.width,c.height),a.restore(),!0):(!o.style||o.sync||n.Export.running?ut(e,o,d):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){o.patternTask=null,a.bounds.hit(e.__nowWorld)&&ut(e,o,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].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[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:J,getPatternData:Z,fillOrFitMode:U,clipMode:G,repeatMode:X},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,e,i){if(e){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:yt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=yt(e,n);o=xt(),a?(Bt(o,e,s/r*(i||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(i||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Ct={};const Wt={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;gt(i||"top",n,_t),gt(a||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(a||"bottom",n,Lt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,Rt,Lt,l,!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:l}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ct);const d=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,St(At,Ct));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Ot,toOffsetOutBounds:Tt}=t.BoundsHelper,Mt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Ot(Mt,e.bounds),Mt.x+=n.x-s.x,Mt.y+=n.y-s.y,i){const{matrix:t}=a;Mt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Mt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(a.canvas,e.bounds,Mt)}else i&&(Ot(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(a.canvas,s,i?Mt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Yt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Tt(d,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=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"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:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,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(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),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:jt}=t.LeafBoundsHelper;function Ut(t,e,n,i,a,o){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Xt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function Gt(t){return t.getSameCanvas(!1,!0)}function Xt(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,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(Ut(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Gt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Gt(t)),a||(a=Gt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||jt(n,e)||n.__render(a||t,e);Ut(this,s,t,a,i,o)};const zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=zt+"_#~&*+\\=|≮≯≈≠=…",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 Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Vt(zt),Kt=Vt(Nt),$t=Vt("- —/~|┆·");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:$t[t]?se:Jt[t]?ie:Zt[t]?ae:Kt[t]?oe:qt.test(t)?ne:ee}const le={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 de(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}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce,We,Oe,Te=[];function Me(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),ye+=e}function Ie(){ve+=ye,we.width=ye,me.words.push(we),we={data:[]},ye=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Re&&(me.startCharSize=Ee,me.endCharSize=Re,Ee=0),me.width=ve,We.width?ce(me):Oe&&He(),Te.push(me),me={words:[]},ve=0}function He(){ve>(Ce.maxWidth||0)&&(Ce.maxWidth=ve)}const Fe=0,Ye=1,je=2;const{top:Ue,right:Ge,bottom:Xe,left:ze}=t.Direction4;function Ne(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:l,__padding:d}=n;d&&(o?(i=d[ze],o-=d[Ge]+d[ze]):n.autoSizeAlign||(i=d[ze]),s?(a=d[Ue],s-=d[Ue]+d[Xe]):n.autoSizeAlign||(a=d[Ue]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Te=e.rows,We=e.bounds,Oe=!We.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=ye=ve=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ye&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=de(be,s,!ye)),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?l-o:l,t&&l&&ve+ye+Be>xe&&(e?(ye&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||ye+Be>xe?(ye&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+ye===0||(Le===_e?(" "===be&&ye&&Ie(),Me(be,Be),Ie()):Se||Pe?(ye&&Ie(),Me(be,Be)):Me(be,Be)),ke=Le);ye&&Ie(),ve&&De(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ve=r.measureText(t).width,Te.push({x:o||0,text:t,width:ve,paraStart:!0}),Oe&&He()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Ge])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ue]);break;case"bottom":Ne(e,"y",-t[Xe])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ye:je,t.isOverflow&&!r&&(t.textMode=!0),h===je?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"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 Ve={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=e);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(n.TextConvert,qe),Object.assign(n.ColorConvert,Ve),Object.assign(n.Paint,T),Object.assign(n.PaintImage,pt),Object.assign(n.PaintGradient,Wt),Object.assign(n.Effect,Yt);const{setPoint:Qe,addPoint:Je,toBounds:Ze}=n.TwoPointBoundsHelper;const Ke={export(t,e,a){this.running=!0;const o=n.FileHelper.fileType(e),s=e.includes(".");return a=n.FileHelper.getExportOptions(a),function(t){$e||($e=new n.TaskProcessor);return new Promise((e=>{$e.add((()=>i(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:c}=n.Platform,{download:h}=n.Platform.origin;if("json"===o)return s&&h(c(JSON.stringify(t.toJSON(a.json)),"text"),e),d({data:!!s||t.toJSON(a.json)});if("svg"===o)return s&&h(c(t.toSVG(),"svg"),e),d({data:!!s||t.toSVG()});const{leafer:u}=t;u?(tn(t),u.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){let i,o,s=1,r=1;const{worldTransform:l,isLeafer:c,isFrame:h}=t,{slice:f,trim:p,onCanvas:g}=a,_=void 0===a.smooth?u.config.smooth:a.smooth,w=a.contextSettings||u.config.contextSettings,m=a.screenshot||t.isApp,y=c&&m&&void 0===a.fill?t.fill:a.fill,v=n.FileHelper.isOpaqueImage(e)||y,x=new n.Matrix;if(m)i=!0===m?c?u.canvas.bounds:t.worldRenderBounds:m;else{let e=a.relative||(c?"inner":"local");switch(s=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),s/=t.scaleX,r/=t.scaleY;break;case"world":s=1,r=1;break;case"page":e=t.leafer;default:x.set(l).divide(t.getTransform(e));const n=e.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}i=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};n.MathHelper.getScaleData(a.scale,a.size,i,b);let B=a.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new n.Bounds(i).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,A=n.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=t,P.__worldOpacity=0,t=u,S.bounds=A.bounds),A.save(),h&&void 0!==y){const e=t.get("fill");t.fill="",t.__render(A,S),t.fill=e}else t.__render(A,S);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(t){const{width:e,height:i}=t.view,{data:a}=t.context.getImageData(0,0,e,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%e,s=(l-o)/e,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new n.Bounds;return Ze(r,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:i}=o,a={x:0,y:0,width:e,height:i,pixelRatio:B};A=n.Creator.canvas(a),A.copyWorld(t,o,a)}v&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===e?A:yield A.export(e,a);d({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:i,trimBounds:o})}))))):d({data:!1})}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=n.LeaferCanvasBase.prototype,nn=n.Debug.get("@leafer-in/export");en.export=function(t,e){const{quality:i,blob:a}=n.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):a?this.toBlob(t,i):this.toDataURL(t,i)},en.toBlob=function(t,e){return new Promise((i=>{n.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(t,e){return n.Platform.origin.canvasToDataURL(this.view,t,e)},en.saveAs=function(t,e){return new Promise((i=>{n.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},n.Plugin.add("export"),Object.assign(n.Export,Ke),n.UI.prototype.export=function(t,e){return n.Export.export(this,t,e)},Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,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:e=>n(t.Platform.image.getRealURL(e))},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:e=>r(t.Platform.image.getRealURL(e))}}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.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "@leafer-draw/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
"leaferjs"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@leafer/node": "1.
|
|
37
|
-
"@leafer-draw/partner": "1.
|
|
38
|
-
"@leafer-ui/draw": "1.
|
|
39
|
-
"@leafer-ui/partner": "1.
|
|
40
|
-
"@leafer-ui/interface": "1.
|
|
36
|
+
"@leafer/node": "1.3.1",
|
|
37
|
+
"@leafer-draw/partner": "1.3.1",
|
|
38
|
+
"@leafer-ui/draw": "1.3.1",
|
|
39
|
+
"@leafer-ui/partner": "1.3.1",
|
|
40
|
+
"@leafer-ui/interface": "1.3.1",
|
|
41
|
+
"@leafer-in/export": "1.3.1",
|
|
42
|
+
"@leafer-in/interface": "1.3.1"
|
|
41
43
|
}
|
|
42
44
|
}
|
package/src/index.ts
CHANGED
package/types/index.d.ts
CHANGED