@leafer-ui/node 1.0.4 → 1.0.5
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 +33 -25
- package/dist/node.esm.js +33 -25
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +12 -12
package/dist/node.cjs
CHANGED
|
@@ -484,6 +484,7 @@ class Renderer {
|
|
|
484
484
|
this.totalBounds = new core.Bounds();
|
|
485
485
|
debug$1.log(target.innerName, '--->');
|
|
486
486
|
try {
|
|
487
|
+
target.app.emit(core.RenderEvent.CHILD_START, target);
|
|
487
488
|
this.emitRender(core.RenderEvent.START);
|
|
488
489
|
this.renderOnce(callback);
|
|
489
490
|
this.emitRender(core.RenderEvent.END, this.totalBounds);
|
|
@@ -781,7 +782,7 @@ class Picker {
|
|
|
781
782
|
if (child.isBranch) {
|
|
782
783
|
if (hit || child.__ignoreHitWorld) {
|
|
783
784
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
784
|
-
if (child.isBranchLeaf
|
|
785
|
+
if (child.isBranchLeaf)
|
|
785
786
|
this.hitChild(child, point);
|
|
786
787
|
}
|
|
787
788
|
}
|
|
@@ -1418,9 +1419,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1418
1419
|
onLoadError(ui, event, image.error);
|
|
1419
1420
|
}
|
|
1420
1421
|
else {
|
|
1421
|
-
|
|
1422
|
-
|
|
1422
|
+
if (firstUse) {
|
|
1423
|
+
ignoreRender(ui, true);
|
|
1423
1424
|
onLoad(ui, event);
|
|
1425
|
+
}
|
|
1424
1426
|
leafPaint.loadId = image.load(() => {
|
|
1425
1427
|
ignoreRender(ui, false);
|
|
1426
1428
|
if (!ui.destroyed) {
|
|
@@ -2032,11 +2034,12 @@ const { trimRight } = TextRowHelper;
|
|
|
2032
2034
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
2033
2035
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
2034
2036
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
2035
|
-
let textDrawData, rows = [], bounds;
|
|
2037
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
2036
2038
|
function createRows(drawData, content, style) {
|
|
2037
2039
|
textDrawData = drawData;
|
|
2038
2040
|
rows = drawData.rows;
|
|
2039
2041
|
bounds = drawData.bounds;
|
|
2042
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
2040
2043
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
2041
2044
|
const { canvas } = core.Platform;
|
|
2042
2045
|
const { width, height } = bounds;
|
|
@@ -2121,7 +2124,10 @@ function createRows(drawData, content, style) {
|
|
|
2121
2124
|
else {
|
|
2122
2125
|
content.split('\n').forEach(content => {
|
|
2123
2126
|
textDrawData.paraNumber++;
|
|
2124
|
-
|
|
2127
|
+
rowWidth = canvas.measureText(content).width;
|
|
2128
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
2129
|
+
if (findMaxWidth)
|
|
2130
|
+
setMaxWidth();
|
|
2125
2131
|
});
|
|
2126
2132
|
}
|
|
2127
2133
|
}
|
|
@@ -2152,10 +2158,16 @@ function addRow() {
|
|
|
2152
2158
|
row.width = rowWidth;
|
|
2153
2159
|
if (bounds.width)
|
|
2154
2160
|
trimRight(row);
|
|
2161
|
+
else if (findMaxWidth)
|
|
2162
|
+
setMaxWidth();
|
|
2155
2163
|
rows.push(row);
|
|
2156
2164
|
row = { words: [] };
|
|
2157
2165
|
rowWidth = 0;
|
|
2158
2166
|
}
|
|
2167
|
+
function setMaxWidth() {
|
|
2168
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
2169
|
+
textDrawData.maxWidth = rowWidth;
|
|
2170
|
+
}
|
|
2159
2171
|
|
|
2160
2172
|
const CharMode = 0;
|
|
2161
2173
|
const WordMode = 1;
|
|
@@ -2227,34 +2239,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
2227
2239
|
|
|
2228
2240
|
function layoutText(drawData, style) {
|
|
2229
2241
|
const { rows, bounds } = drawData;
|
|
2230
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2242
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
2231
2243
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2232
2244
|
let starY = __baseLine;
|
|
2233
2245
|
if (__clipText && realHeight > height) {
|
|
2234
2246
|
realHeight = Math.max(height, __lineHeight);
|
|
2235
2247
|
drawData.overflow = rows.length;
|
|
2236
2248
|
}
|
|
2237
|
-
else {
|
|
2249
|
+
else if (height || autoSizeAlign) {
|
|
2238
2250
|
switch (verticalAlign) {
|
|
2239
2251
|
case 'middle':
|
|
2240
2252
|
y += (height - realHeight) / 2;
|
|
2241
2253
|
break;
|
|
2242
|
-
case 'bottom':
|
|
2243
|
-
y += (height - realHeight);
|
|
2254
|
+
case 'bottom': y += (height - realHeight);
|
|
2244
2255
|
}
|
|
2245
2256
|
}
|
|
2246
2257
|
starY += y;
|
|
2247
|
-
let row, rowX, rowWidth;
|
|
2258
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
2248
2259
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
2249
2260
|
row = rows[i];
|
|
2250
2261
|
row.x = x;
|
|
2251
2262
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
2252
2263
|
switch (textAlign) {
|
|
2253
2264
|
case 'center':
|
|
2254
|
-
row.x += (
|
|
2265
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
2255
2266
|
break;
|
|
2256
|
-
case 'right':
|
|
2257
|
-
row.x += width - row.width;
|
|
2267
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
2258
2268
|
}
|
|
2259
2269
|
}
|
|
2260
2270
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -2359,14 +2369,14 @@ function getDrawData(content, style) {
|
|
|
2359
2369
|
let height = style.__getInput('height') || 0;
|
|
2360
2370
|
const { textDecoration, __font, __padding: padding } = style;
|
|
2361
2371
|
if (padding) {
|
|
2362
|
-
if (width)
|
|
2372
|
+
if (width)
|
|
2373
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
2374
|
+
else if (!style.autoSizeAlign)
|
|
2363
2375
|
x = padding[left];
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
if (
|
|
2376
|
+
if (height)
|
|
2377
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
2378
|
+
else if (!style.autoSizeAlign)
|
|
2367
2379
|
y = padding[top];
|
|
2368
|
-
height -= (padding[top] + padding[bottom]);
|
|
2369
|
-
}
|
|
2370
2380
|
}
|
|
2371
2381
|
const drawData = {
|
|
2372
2382
|
bounds: { x, y, width, height },
|
|
@@ -2386,22 +2396,20 @@ function getDrawData(content, style) {
|
|
|
2386
2396
|
return drawData;
|
|
2387
2397
|
}
|
|
2388
2398
|
function padAutoText(padding, drawData, style, width, height) {
|
|
2389
|
-
if (!width) {
|
|
2399
|
+
if (!width && style.autoSizeAlign) {
|
|
2390
2400
|
switch (style.textAlign) {
|
|
2391
2401
|
case 'left':
|
|
2392
2402
|
offsetText(drawData, 'x', padding[left]);
|
|
2393
2403
|
break;
|
|
2394
|
-
case 'right':
|
|
2395
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
2404
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
2396
2405
|
}
|
|
2397
2406
|
}
|
|
2398
|
-
if (!height) {
|
|
2407
|
+
if (!height && style.autoSizeAlign) {
|
|
2399
2408
|
switch (style.verticalAlign) {
|
|
2400
2409
|
case 'top':
|
|
2401
2410
|
offsetText(drawData, 'y', padding[top]);
|
|
2402
2411
|
break;
|
|
2403
|
-
case 'bottom':
|
|
2404
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
2412
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
2405
2413
|
}
|
|
2406
2414
|
}
|
|
2407
2415
|
}
|
package/dist/node.esm.js
CHANGED
|
@@ -485,6 +485,7 @@ class Renderer {
|
|
|
485
485
|
this.totalBounds = new Bounds();
|
|
486
486
|
debug$1.log(target.innerName, '--->');
|
|
487
487
|
try {
|
|
488
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
488
489
|
this.emitRender(RenderEvent.START);
|
|
489
490
|
this.renderOnce(callback);
|
|
490
491
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -782,7 +783,7 @@ class Picker {
|
|
|
782
783
|
if (child.isBranch) {
|
|
783
784
|
if (hit || child.__ignoreHitWorld) {
|
|
784
785
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
785
|
-
if (child.isBranchLeaf
|
|
786
|
+
if (child.isBranchLeaf)
|
|
786
787
|
this.hitChild(child, point);
|
|
787
788
|
}
|
|
788
789
|
}
|
|
@@ -1419,9 +1420,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1419
1420
|
onLoadError(ui, event, image.error);
|
|
1420
1421
|
}
|
|
1421
1422
|
else {
|
|
1422
|
-
|
|
1423
|
-
|
|
1423
|
+
if (firstUse) {
|
|
1424
|
+
ignoreRender(ui, true);
|
|
1424
1425
|
onLoad(ui, event);
|
|
1426
|
+
}
|
|
1425
1427
|
leafPaint.loadId = image.load(() => {
|
|
1426
1428
|
ignoreRender(ui, false);
|
|
1427
1429
|
if (!ui.destroyed) {
|
|
@@ -2033,11 +2035,12 @@ const { trimRight } = TextRowHelper;
|
|
|
2033
2035
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
2034
2036
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
2035
2037
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
2036
|
-
let textDrawData, rows = [], bounds;
|
|
2038
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
2037
2039
|
function createRows(drawData, content, style) {
|
|
2038
2040
|
textDrawData = drawData;
|
|
2039
2041
|
rows = drawData.rows;
|
|
2040
2042
|
bounds = drawData.bounds;
|
|
2043
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
2041
2044
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
2042
2045
|
const { canvas } = Platform;
|
|
2043
2046
|
const { width, height } = bounds;
|
|
@@ -2122,7 +2125,10 @@ function createRows(drawData, content, style) {
|
|
|
2122
2125
|
else {
|
|
2123
2126
|
content.split('\n').forEach(content => {
|
|
2124
2127
|
textDrawData.paraNumber++;
|
|
2125
|
-
|
|
2128
|
+
rowWidth = canvas.measureText(content).width;
|
|
2129
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
2130
|
+
if (findMaxWidth)
|
|
2131
|
+
setMaxWidth();
|
|
2126
2132
|
});
|
|
2127
2133
|
}
|
|
2128
2134
|
}
|
|
@@ -2153,10 +2159,16 @@ function addRow() {
|
|
|
2153
2159
|
row.width = rowWidth;
|
|
2154
2160
|
if (bounds.width)
|
|
2155
2161
|
trimRight(row);
|
|
2162
|
+
else if (findMaxWidth)
|
|
2163
|
+
setMaxWidth();
|
|
2156
2164
|
rows.push(row);
|
|
2157
2165
|
row = { words: [] };
|
|
2158
2166
|
rowWidth = 0;
|
|
2159
2167
|
}
|
|
2168
|
+
function setMaxWidth() {
|
|
2169
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
2170
|
+
textDrawData.maxWidth = rowWidth;
|
|
2171
|
+
}
|
|
2160
2172
|
|
|
2161
2173
|
const CharMode = 0;
|
|
2162
2174
|
const WordMode = 1;
|
|
@@ -2228,34 +2240,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
2228
2240
|
|
|
2229
2241
|
function layoutText(drawData, style) {
|
|
2230
2242
|
const { rows, bounds } = drawData;
|
|
2231
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2243
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
2232
2244
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2233
2245
|
let starY = __baseLine;
|
|
2234
2246
|
if (__clipText && realHeight > height) {
|
|
2235
2247
|
realHeight = Math.max(height, __lineHeight);
|
|
2236
2248
|
drawData.overflow = rows.length;
|
|
2237
2249
|
}
|
|
2238
|
-
else {
|
|
2250
|
+
else if (height || autoSizeAlign) {
|
|
2239
2251
|
switch (verticalAlign) {
|
|
2240
2252
|
case 'middle':
|
|
2241
2253
|
y += (height - realHeight) / 2;
|
|
2242
2254
|
break;
|
|
2243
|
-
case 'bottom':
|
|
2244
|
-
y += (height - realHeight);
|
|
2255
|
+
case 'bottom': y += (height - realHeight);
|
|
2245
2256
|
}
|
|
2246
2257
|
}
|
|
2247
2258
|
starY += y;
|
|
2248
|
-
let row, rowX, rowWidth;
|
|
2259
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
2249
2260
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
2250
2261
|
row = rows[i];
|
|
2251
2262
|
row.x = x;
|
|
2252
2263
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
2253
2264
|
switch (textAlign) {
|
|
2254
2265
|
case 'center':
|
|
2255
|
-
row.x += (
|
|
2266
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
2256
2267
|
break;
|
|
2257
|
-
case 'right':
|
|
2258
|
-
row.x += width - row.width;
|
|
2268
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
2259
2269
|
}
|
|
2260
2270
|
}
|
|
2261
2271
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -2360,14 +2370,14 @@ function getDrawData(content, style) {
|
|
|
2360
2370
|
let height = style.__getInput('height') || 0;
|
|
2361
2371
|
const { textDecoration, __font, __padding: padding } = style;
|
|
2362
2372
|
if (padding) {
|
|
2363
|
-
if (width)
|
|
2373
|
+
if (width)
|
|
2374
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
2375
|
+
else if (!style.autoSizeAlign)
|
|
2364
2376
|
x = padding[left];
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
if (
|
|
2377
|
+
if (height)
|
|
2378
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
2379
|
+
else if (!style.autoSizeAlign)
|
|
2368
2380
|
y = padding[top];
|
|
2369
|
-
height -= (padding[top] + padding[bottom]);
|
|
2370
|
-
}
|
|
2371
2381
|
}
|
|
2372
2382
|
const drawData = {
|
|
2373
2383
|
bounds: { x, y, width, height },
|
|
@@ -2387,22 +2397,20 @@ function getDrawData(content, style) {
|
|
|
2387
2397
|
return drawData;
|
|
2388
2398
|
}
|
|
2389
2399
|
function padAutoText(padding, drawData, style, width, height) {
|
|
2390
|
-
if (!width) {
|
|
2400
|
+
if (!width && style.autoSizeAlign) {
|
|
2391
2401
|
switch (style.textAlign) {
|
|
2392
2402
|
case 'left':
|
|
2393
2403
|
offsetText(drawData, 'x', padding[left]);
|
|
2394
2404
|
break;
|
|
2395
|
-
case 'right':
|
|
2396
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
2405
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
2397
2406
|
}
|
|
2398
2407
|
}
|
|
2399
|
-
if (!height) {
|
|
2408
|
+
if (!height && style.autoSizeAlign) {
|
|
2400
2409
|
switch (style.verticalAlign) {
|
|
2401
2410
|
case 'top':
|
|
2402
2411
|
offsetText(drawData, 'y', padding[top]);
|
|
2403
2412
|
break;
|
|
2404
|
-
case 'bottom':
|
|
2405
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
2413
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
2406
2414
|
}
|
|
2407
2415
|
}
|
|
2408
2416
|
}
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as g,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Answer as k,MatrixHelper as R,MathHelper as E,AlignHelper as L,ImageEvent as S,AroundHelper as M,PointHelper as A,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as T,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{InteractionBase as P,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as F,ColorConvert as N,PaintGradient as Y,Export as U,Group as X,TextConvert as j,Paint as G,Effect as H}from"@leafer-ui/draw";function V(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class q 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:z,fileType:Q}=o;function J(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),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=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(z(e),i),canvasToBolb:(t,e,i)=>V(this,void 0,void 0,(function*(){return t.toBuffer(z(e),i)})),canvasSaveAs:(t,e,i)=>V(this,void 0,void 0,(function*(){return I(e,t.toBuffer(z(Q(e)),i))})),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new q(t,e),image:t=>new n(t)}),e.name="node",e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class Z{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===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.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_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:$,updateAllWorldOpacity:tt}=f,{pushAllChildBranch:et,pushAllParent:it}=_;const{worldBounds:st}=p,nt={x:0,y:0,width:1e5,height:1e5};class at{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:rt}=f,dt=w.get("Layouter");class lt{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){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new m(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||$(s[t])}$(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,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:s,AFTER:n}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),lt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(s,a,this.times)),e.emitEvent(new m(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=w.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new g,ht.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,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 ht.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,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new g(s);i.save(),n&&!w.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),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 s=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,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(s),w.showBoundsView&&this.renderBoundsView(s),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 g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ht.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)}}const{hitRadiusPoint:ut}=B;class ft{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,n),l=n?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:_t,NoAndSkip:gt,YesAndSkip:pt}=k,wt={},yt={},mt={};class vt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=d.default(e,this.config)),this.picker=new ft(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":wt.id=t.substring(1),t=wt;break;case".":yt.className=t.substring(1),t=yt;break;default:mt.tag=t,t=mt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,n=s instanceof Array;return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?d.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(m.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&f.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let o=0,r=t.length;o<r;o++){if(n=t[o],a=e(n,s),a===_t||a===pt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<gt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(u.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function xt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function bt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Rt(t,!0,e,i):kt(e,i);break;case"inside":Bt("inside",t,n,e,i);break;case"outside":Bt("outside",t,n,e,i)}}function Bt(t,e,i,s,n){const{__strokeWidth:a,__font:o}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,s.__),r.font=o,i?Rt(e,!0,s,r):kt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",xt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function kt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function Rt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&F.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?kt(i,s):s.stroke(),s.restoreBlendMode()):e?kt(i,s):s.stroke())}Object.assign(s,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>new vt(t,e)}),e.layout=lt.fullLayout;const{getSpread:Et,getOuterOf:Lt,getByMove:St,getIntersectData:Mt}=B;let At;function Ct(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:o,opacity:r}=e;return{type:n,blendMode:a,style:N.string(o,r)};case"image":return F.image(i,t,e,s,!At||!At[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const Wt={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),At=F.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=Ct(t,a[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?xt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&F.checkImage(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?xt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?xt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?xt(e,i):n?i.fill(n):i.fill())},fillText:xt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*n,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),Rt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Rt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*n,s),Rt(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:bt,drawTextStroke:kt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Mt(s?Et(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Lt(n,o),a=St(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Tt={};const{get:Ot,rotateOfOuter:It,translate:Pt,scaleOfOuter:Dt,scale:Ft,rotate:Nt}=R;function Yt(t,e,i,s,n,a,o){const r=Ot();Pt(r,e.x+i,e.y+s),Ft(r,n,a),o&&It(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ut(t,e,i,s,n,a,o){const r=Ot();Pt(r,e.x+i,e.y+s),n&&Ft(r,n,a),o&&Nt(r,o),t.transform=r}function Xt(t,e,i,s,n,a,o,r,d,l){const h=Ot();if(d)if("center"===l)It(h,{x:i/2,y:s/2},d);else switch(Nt(h,d),d){case 90:Pt(h,s,0);break;case 180:Pt(h,i,s);break;case 270:Pt(h,0,i)}Tt.x=e.x+n,Tt.y=e.y+a,Pt(h,Tt.x,Tt.y),o&&Dt(h,Tt,o,r),t.transform=h}const{get:jt,translate:Gt}=R,Ht=new g,Vt={},qt={};function zt(t,e,i,s){const{blendMode:n,sync:a}=i;n&&(t.blendMode=n),a&&(t.sync=a),t.data=Qt(i,s,e)}function Qt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ht.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===s&&e.height===n,_={mode:o},g="center"!==r&&(c||0)%180==90,p=g?n:s,w=g?s:n;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(E.getScaleData(l,h,i,qt),y=qt.scaleX,m=qt.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),L.toPoint(r,t,e,Vt,!0),v+=Vt.x,x+=Vt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ut(_,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Xt(_,e,s,n,v,x,y,m,c,r),u||(_.repeat="repeat");break;default:y&&Yt(_,e,v,x,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=jt(),Gt(_.transform,e.x,e.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,a&&(_.opacity=a),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Jt,Zt=new g;const{isSame:Kt}=B;function $t(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||zt(n,s,i,a),!0}function te(t,e){se(t,S.LOAD,e)}function ee(t,e){se(t,S.LOADED,e)}function ie(t,e,i){e.error=i,t.forceUpdate("surface"),se(t,S.ERROR,e)}function se(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function ne(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ae,scale:oe,copy:re}=R,{ceil:de,abs:le}=Math;function he(t,i,s){let{scaleX:n,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{n=le(n),a=le(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(l=ae(),re(l,g),oe(l,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(n/=d,a/=d,h/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(l||(l=ae(),g&&re(l,g)),oe(l,1/n,1/a));const m=t.getCanvas(de(h)||1,de(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:ce}=Math;const ue={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return Jt&&i===Jt.paint&&Kt(s,Jt.boxBounds)?a=Jt.leafPaint:(a={type:i.type,image:r},Jt=r.use>1?{leafPaint:a,paint:i,boxBounds:Zt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?($t(t,e,i,r,a,s),n&&(te(t,o),ee(t,o))):r.error?n&&ie(t,o,r.error):(ne(t,!0),n&&te(t,o),a.loadId=r.load((()=>{ne(t,!1),t.destroyed||($t(t,e,i,r,a,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ee(t,o)),a.loadId=null}),(e=>{ne(t,!1),ie(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===a+"-"+o+"-"+r&&!U.running)return!1;{const{data:d}=s;if(n)if(d.repeat)n=!1;else{let{width:t,height:i}=d;t*=ce(a)*r,i*=ce(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),n=t*i>e.image.maxCacheSize||U.running}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||U.running?he(t,s,r):s.patternTask||(s.patternTask=x.patternTasker.add((()=>V(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&he(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:he,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o;for(let r=0,d=i.length;r<d;r++)s=i[r].image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,x.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[r].loadId,!a.some((t=>t.url===o)))));return n}return null},createData:zt,getPatternData:Qt,fillOrFitMode:Yt,clipMode:Ut,repeatMode:Xt},{toPoint:fe}=M,_e={},ge={};function pe(t,e,i){if(e){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(a-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}}const{getAngle:we,getDistance:ye}=A,{get:me,rotateOfOuter:ve,scaleOfOuter:xe}=R,{toPoint:be}=M,Be={},ke={};function Re(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=we(e,i);a=me(),n?(xe(a,e,o/r*(s||1),1),ve(a,e,t+90)):(xe(a,e,1,o/r*(s||1)),ve(a,e,t))}return a}const{getDistance:Ee}=A,{toPoint:Le}=M,Se={},Me={};const Ae={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;fe(s||"top",i,_e),fe(n||"bottom",i,ge);const d=e.canvas.createLinearGradient(_e.x,_e.y,ge.x,ge.y);pe(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;be(s||"center",i,Be),be(n||"bottom",i,ke);const l=e.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ye(Be,ke));pe(l,t.stops,o);const h={type:a,style:l},c=Re(i,Be,ke,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;Le(s||"center",i,Se),Le(n||"bottom",i,Me);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,Ee(Se,Me));pe(l,t.stops,o);const h={type:a,style:l},c=Re(i,Se,Me,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Re},{copy:Ce,toOffsetOutBounds:We}=B,Te={},Oe={};function Ie(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Ce(Te,t.bounds),Te.x+=i.x-o.x,Te.y+=i.y-o.y,s){const{matrix:t}=n;Te.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Te.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Te.width*=s,Te.height*=s}t.copyWorld(n.canvas,t.bounds,Te)}else s&&(Ce(Te,i),Te.x-=i.width/2*(s-1),Te.y-=i.height/2*(s-1),Te.width*=s,Te.height*=s),t.copyWorld(n.canvas,o,s?Te:i)}const{toOffsetOutBounds:Pe}=B,De={};const Fe={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;We(l,Oe),r.forEach(((r,g)=>{f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,Oe,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Pe(l,De),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*c,De.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,De,n,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ne}=p;function Ye(t,e,i,s,n,a){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Xe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Xe(t,i,s,a);break;case"path":i.restore()}}function Ue(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}X.prototype.__renderMask=function(t,e){let i,s,n,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(o&&(Ye(this,o,t,n,s,a),s=n=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Ue(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=Ue(t)),n||(n=Ue(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ne(i,e)||i.__render(n||t,e);Ye(this,o,t,n,s,a)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=je+"_#~&*+\\=|≮≯≈≠=…",He=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ze=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Qe=Ve(je),Je=Ve(Ge),Ze=Ve("- —/~|┆·");var Ke;!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"}(Ke||(Ke={}));const{Letter:$e,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ke;function ai(t){return qe[t]?$e:Ze[t]?ni:ze[t]?ei:Qe[t]?ii:Je[t]?si:He.test(t)?ti:$e}const oi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ri(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:di}=oi,{Letter:li,Single:hi,Before:ci,After:ui,Symbol:fi,Break:_i}=Ke;let gi,pi,wi,yi,mi,vi,xi,bi,Bi,ki,Ri,Ei,Li,Si,Mi,Ai,Ci=[];function Wi(t,e){Bi&&!bi&&(bi=Bi),gi.data.push({char:t,width:e}),wi+=e}function Ti(){yi+=wi,gi.width=wi,pi.words.push(gi),gi={data:[]},wi=0}function Oi(){Si&&(Mi.paraNumber++,pi.paraStart=!0,Si=!1),Bi&&(pi.startCharSize=bi,pi.endCharSize=Bi,bi=0),pi.width=yi,Ai.width&&di(pi),Ci.push(pi),pi={words:[]},yi=0}const Ii=0,Pi=1,Di=2;const{top:Fi,right:Ni,bottom:Yi,left:Ui}=C;function Xi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a&&(s=l[Ui],a-=l[Ni]+l[Ui]),o&&(n=l[Fi],o-=l[Fi]+l[Yi]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Mi=t,Ci=t.rows,Ai=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:l}=Ai;if(d||l||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Si=!0,Ri=null,bi=xi=Bi=wi=yi=0,gi={data:[]},pi={words:[]};for(let s=0,l=i.length;s<l;s++)vi=i[s],"\n"===vi?(wi&&Ti(),pi.paraEnd=!0,Oi(),Si=!0):(ki=ai(vi),ki===li&&"none"!==o&&(vi=ri(vi,o,!wi)),xi=r.measureText(vi).width,n&&(n<0&&(Bi=xi),xi+=n),Ei=ki===hi&&(Ri===hi||Ri===li)||Ri===hi&&ki!==ui,Li=!(ki!==ci&&ki!==hi||Ri!==fi&&Ri!==ui),mi=Si&&a?d-a:d,t&&d&&yi+wi+xi>mi&&(e?(wi&&Ti(),yi&&Oi()):(Li||(Li=ki===li&&Ri==ui),Ei||Li||ki===_i||ki===ci||ki===hi||wi+xi>mi?(wi&&Ti(),yi&&Oi()):yi&&Oi()))," "===vi&&!0!==Si&&yi+wi===0||(ki===_i?(" "===vi&&wi&&Ti(),Wi(vi,xi),Ti()):Ei||Li?(wi&&Ti(),Wi(vi,xi)):Wi(vi,xi)),Ri=ki);wi&&Ti(),yi&&Oi(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,Ci.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,i),l&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Xi(e,"x",t[Ui]);break;case"right":Xi(e,"x",-t[Ni])}if(!n)switch(i.verticalAlign){case"top":Xi(e,"y",t[Fi]);break;case"bottom":Xi(e,"y",-t[Yi])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(h?h*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,l=i.length;a<l;a++){if(c=i[a],c.x=_,c.width<p||c.width>p&&!r)switch(d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;n.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ii:l>.01?Pi:Di,t.isOverflow&&!r&&(t.textMode=!0),c===Di?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Pi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=s+n-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"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}}(h,i),h}};const Gi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:Hi,addPoint:Vi,toBounds:qi}=W;const zi={export(t,i,n){this.running=!0;const a=o.fileType(i),r=i.includes(".");return n=o.getExportOptions(n),function(t){Qi||(Qi=new T);return new Promise((e=>{Qi.add((()=>V(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const h=t=>{d(t),l(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===a)return r&&u(c(JSON.stringify(t.toJSON(n.json)),"text"),i),h({data:!!r||t.toJSON(n.json)});if("svg"===a)return r&&u(c(t.toSVG(),"svg"),i),h({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Ji(t),f.waitViewCompleted((()=>V(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=t,{slice:_,trim:p,onCanvas:w}=n,y=void 0===n.smooth?f.config.smooth:n.smooth,m=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=c&&v&&void 0===n.fill?t.fill:n.fill,b=o.isOpaqueImage(i)||x,B=new O;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(c?"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 k={scaleX:1,scaleY:1};E.getScaleData(n.scale,n.size,e,k);let R=n.pixelRatio||1;t.isApp&&(k.scaleX*=R,k.scaleY*=R,R=t.app.pixelRatio);const{x:L,y:S,width:M,height:A}=new g(e).scale(k.scaleX,k.scaleY),C={matrix:B.scale(1/k.scaleX,1/k.scaleY).invert().translate(-L,-S).withScale(1/r*k.scaleX,1/d*k.scaleY)};let W,T=s.canvas({width:Math.round(M),height:Math.round(A),pixelRatio:R,smooth:y,contextSettings:m});if(_&&(W=t,W.__worldOpacity=0,t=f,C.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,C),t.fill=e}else t.__render(T,C);if(T.restore(),W&&W.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?Vi(o,n,a):Hi(o={},n,a)),r++;const d=new g;return qi(o,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:R};T=s.canvas(n),T.copyWorld(t,a,n)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),w&&w(T);const I="canvas"===i?T:yield T.export(i,n);h({data:I,width:T.pixelWidth,height:T.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let Qi;function Ji(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ji(t)))}const Zi=t.prototype,Ki=w.get("@leafer-ui/export");Zi.export=function(t,e){const{quality:i,blob:s}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Zi.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{Ki.error(t),s(null)}))}))},Zi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Zi.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{Ki.error(t),s(!1)}))}))},Object.assign(j,ji),Object.assign(N,Gi),Object.assign(G,Wt),Object.assign(F,ue),Object.assign(Y,Ae),Object.assign(H,Fe),Object.assign(U,zi),Object.assign(s,{interaction:(t,e,i,s)=>new P(t,e,i,s),hitCanvas:(t,e)=>new q(t,e),hitCanvasManager:()=>new D});export{lt as Layouter,q as LeaferCanvas,ct as Renderer,vt as Selector,Z as Watcher,J as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as M,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as T,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{InteractionBase as P,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as F,ColorConvert as N,PaintGradient as Y,Export as U,Group as X,TextConvert as j,Paint as z,Effect as G}from"@leafer-ui/draw";function H(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class V 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:q,fileType:Q}=o;function J(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(q(e),i),canvasToBolb:(t,e,i)=>H(this,void 0,void 0,(function*(){return t.toBuffer(q(e),i)})),canvasSaveAs:(t,e,i)=>H(this,void 0,void 0,(function*(){return I(e,t.toBuffer(q(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 V(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class Z{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===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.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_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:$,updateAllWorldOpacity:tt}=f,{pushAllChildBranch:et,pushAllParent:it}=g;const{worldBounds:nt}=p,st={x:0,y:0,width:1e5,height:1e5};class at{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,nt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(st):this.afterBounds.setListWithFn(t,nt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:rt}=f,dt=w.get("Layouter");class lt{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){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=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?(K(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||$(n[t])}$(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(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(a,r,this.times)),i.emitEvent(new m(o,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,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),lt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=w.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,ht.log(e.innerName,"---\x3e");try{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,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.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 ht.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),a=new _(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,a),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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(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 _(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ht.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)}}const{hitRadiusPoint:ut}=B;class ft{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ut(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:gt,NoAndSkip:_t,YesAndSkip:pt}=R,wt={},yt={},mt={};class vt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=d.default(e,this.config)),this.picker=new ft(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":wt.id=t.substring(1),t=wt;break;case".":yt.className=t.substring(1),t=yt;break;default:mt.tag=t,t=mt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?d.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(m.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&f.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===gt||a===pt){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<_t&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(u.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function xt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function bt(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?kt(t,!0,e,i):Rt(e,i);break;case"inside":Bt("inside",t,s,e,i);break;case"outside":Bt("outside",t,s,e,i)}}function Bt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?kt(e,!0,n,r):Rt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",xt(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 Rt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function kt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&F.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Rt(i,n):n.stroke(),n.restoreBlendMode()):e?Rt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>new vt(t,e)}),e.layout=lt.fullLayout;const{getSpread:St,getOuterOf:Et,getByMove:Lt,getIntersectData:At}=B;let Mt;function Ct(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:N.string(o,r)};case"image":return F.image(i,t,e,n,!Mt||!Mt[e.url]);case"linear":return Y.linearGradient(e,n);case"radial":return Y.radialGradient(e,n);case"angular":return Y.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const Wt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=F.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Ct(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?xt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&F.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?xt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?xt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?xt(e,i):s?i.fill(s):i.fill())},fillText:xt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),kt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),kt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),kt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:bt,drawTextStroke:Rt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=At(n?St(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Et(s,o),a=Lt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Tt={};const{get:Ot,rotateOfOuter:It,translate:Pt,scaleOfOuter:Dt,scale:Ft,rotate:Nt}=k;function Yt(t,e,i,n,s,a,o){const r=Ot();Pt(r,e.x+i,e.y+n),Ft(r,s,a),o&&It(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ut(t,e,i,n,s,a,o){const r=Ot();Pt(r,e.x+i,e.y+n),s&&Ft(r,s,a),o&&Nt(r,o),t.transform=r}function Xt(t,e,i,n,s,a,o,r,d,l){const h=Ot();if(d)if("center"===l)It(h,{x:i/2,y:n/2},d);else switch(Nt(h,d),d){case 90:Pt(h,n,0);break;case 180:Pt(h,i,n);break;case 270:Pt(h,0,i)}Tt.x=e.x+s,Tt.y=e.y+a,Pt(h,Tt.x,Tt.y),o&&Dt(h,Tt,o,r),t.transform=h}const{get:jt,translate:zt}=k,Gt=new _,Ht={},Vt={};function qt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Qt(i,n,e)}function Qt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Gt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Vt),y=Vt.scaleX,m=Vt.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Ht,!0),v+=Ht.x,x+=Ht.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ut(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Xt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Yt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=jt(),zt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Jt,Zt=new _;const{isSame:Kt}=B;function $t(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||qt(s,n,i,a),!0}function te(t,e){ne(t,L.LOAD,e)}function ee(t,e){ne(t,L.LOADED,e)}function ie(t,e,i){e.error=i,t.forceUpdate("surface"),ne(t,L.ERROR,e)}function ne(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ae,scale:oe,copy:re}=k,{ceil:de,abs:le}=Math;function he(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=le(s),a=le(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=ae(),re(l,_),oe(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=ae(),_&&re(l,_)),oe(l,1/s,1/a));const m=t.getCanvas(de(h)||1,de(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:ce}=Math;const ue={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return Jt&&i===Jt.paint&&Kt(n,Jt.boxBounds)?a=Jt.leafPaint:(a={type:i.type,image:r},Jt=r.use>1?{leafPaint:a,paint:i,boxBounds:Zt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?($t(t,e,i,r,a,n),s&&(te(t,o),ee(t,o))):r.error?s&&ie(t,o,r.error):(s&&(se(t,!0),te(t,o)),a.loadId=r.load((()=>{se(t,!1),t.destroyed||($t(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ee(t,o)),a.loadId=null}),(e=>{se(t,!1),ie(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!U.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=ce(a)*r,i*=ce(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||U.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||U.running?he(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>H(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&he(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:he,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:qt,getPatternData:Qt,fillOrFitMode:Yt,clipMode:Ut,repeatMode:Xt},{toPoint:fe}=A,ge={},_e={};function pe(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),N.string(n,i)):t.addColorStop(n.offset,N.string(n.color,i))}}const{getAngle:we,getDistance:ye}=M,{get:me,rotateOfOuter:ve,scaleOfOuter:xe}=k,{toPoint:be}=A,Be={},Re={};function ke(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=we(e,i);a=me(),s?(xe(a,e,o/r*(n||1),1),ve(a,e,t+90)):(xe(a,e,1,o/r*(n||1)),ve(a,e,t))}return a}const{getDistance:Se}=M,{toPoint:Ee}=A,Le={},Ae={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;fe(n||"top",i,ge),fe(s||"bottom",i,_e);const d=e.canvas.createLinearGradient(ge.x,ge.y,_e.x,_e.y);pe(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;be(n||"center",i,Be),be(s||"bottom",i,Re);const l=e.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ye(Be,Re));pe(l,t.stops,o);const h={type:a,style:l},c=ke(i,Be,Re,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Ee(n||"center",i,Le),Ee(s||"bottom",i,Ae);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Le.x,Le.y):e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,Se(Le,Ae));pe(l,t.stops,o);const h={type:a,style:l},c=ke(i,Le,Ae,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:ke},{copy:Ce,toOffsetOutBounds:We}=B,Te={},Oe={};function Ie(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ce(Te,t.bounds),Te.x+=i.x-o.x,Te.y+=i.y-o.y,n){const{matrix:t}=s;Te.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Te.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Te.width*=n,Te.height*=n}t.copyWorld(s.canvas,t.bounds,Te)}else n&&(Ce(Te,i),Te.x-=i.width/2*(n-1),Te.y-=i.height/2*(n-1),Te.width*=n,Te.height*=n),t.copyWorld(s.canvas,o,n?Te:i)}const{toOffsetOutBounds:Pe}=B,De={};const Fe={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(l,Oe),r.forEach(((r,_)=>{f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,Oe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Pe(l,De),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*c,De.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,De,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ne}=p;function Ye(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Xe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Xe(t,i,n,a);break;case"path":i.restore()}}function Ue(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}X.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(o&&(Ye(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ue(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ue(t)),s||(s=Ue(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ne(i,e)||i.__render(s||t,e);Ye(this,o,t,s,n,a)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=je+"_#~&*+\\=|≮≯≈≠=…",Ge=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ve=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Qe=He(je),Je=He(ze),Ze=He("- —/~|┆·");var Ke;!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"}(Ke||(Ke={}));const{Letter:$e,Single:ti,Before:ei,After:ii,Symbol:ni,Break:si}=Ke;function ai(t){return Ve[t]?$e:Ze[t]?si:qe[t]?ei:Qe[t]?ii:Je[t]?ni:Ge.test(t)?ti:$e}const oi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ri(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:di}=oi,{Letter:li,Single:hi,Before:ci,After:ui,Symbol:fi,Break:gi}=Ke;let _i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Mi,Ci,Wi=[];function Ti(t,e){Bi&&!bi&&(bi=Bi),_i.data.push({char:t,width:e}),wi+=e}function Oi(){yi+=wi,_i.width=wi,pi.words.push(_i),_i={data:[]},wi=0}function Ii(){Li&&(Ai.paraNumber++,pi.paraStart=!0,Li=!1),Bi&&(pi.startCharSize=bi,pi.endCharSize=Bi,bi=0),pi.width=yi,Mi.width?di(pi):Ci&&Pi(),Wi.push(pi),pi={words:[]},yi=0}function Pi(){yi>(Ai.maxWidth||0)&&(Ai.maxWidth=yi)}const Di=0,Fi=1,Ni=2;const{top:Yi,right:Ui,bottom:Xi,left:ji}=C;function zi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Gi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[ji],a-=l[Ui]+l[ji]):i.autoSizeAlign||(n=l[ji]),o?(s=l[Yi],o-=l[Yi]+l[Xi]):i.autoSizeAlign||(s=l[Yi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ai=t,Wi=t.rows,Mi=t.bounds,Ci=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Li=!0,ki=null,bi=xi=Bi=wi=yi=0,_i={data:[]},pi={words:[]};for(let n=0,l=i.length;n<l;n++)vi=i[n],"\n"===vi?(wi&&Oi(),pi.paraEnd=!0,Ii(),Li=!0):(Ri=ai(vi),Ri===li&&"none"!==o&&(vi=ri(vi,o,!wi)),xi=r.measureText(vi).width,s&&(s<0&&(Bi=xi),xi+=s),Si=Ri===hi&&(ki===hi||ki===li)||ki===hi&&Ri!==ui,Ei=!(Ri!==ci&&Ri!==hi||ki!==fi&&ki!==ui),mi=Li&&a?d-a:d,t&&d&&yi+wi+xi>mi&&(e?(wi&&Oi(),yi&&Ii()):(Ei||(Ei=Ri===li&&ki==ui),Si||Ei||Ri===gi||Ri===ci||Ri===hi||wi+xi>mi?(wi&&Oi(),yi&&Ii()):yi&&Ii()))," "===vi&&!0!==Li&&yi+wi===0||(Ri===gi?(" "===vi&&wi&&Oi(),Ti(vi,xi),Oi()):Si||Ei?(wi&&Oi(),Ti(vi,xi)):Ti(vi,xi)),ki=Ri);wi&&Oi(),yi&&Ii(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ai.paraNumber++,yi=r.measureText(t).width,Wi.push({x:a||0,text:t,width:yi,paraStart:!0}),Ci&&Pi()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":zi(e,"x",t[ji]);break;case"right":zi(e,"x",-t[Ui])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":zi(e,"y",t[Yi]);break;case"bottom":zi(e,"y",-t[Xi])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Di:l>.01?Fi:Ni,t.isOverflow&&!r&&(t.textMode=!0),c===Ni?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Fi?(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)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-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<h));n--){if(d<h&&" "!==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)}}))}}(h,i,n,a),"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}}(h,i),h}};const Hi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.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:Vi,addPoint:qi,toBounds:Qi}=W;const Ji={export(t,i,s){this.running=!0;const a=o.fileType(i),r=i.includes(".");return s=o.getExportOptions(s),function(t){Zi||(Zi=new T);return new Promise((e=>{Zi.add((()=>H(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const h=t=>{d(t),l(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===a)return r&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),h({data:!!r||t.toJSON(s.json)});if("svg"===a)return r&&u(c(t.toSVG(),"svg"),i),h({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Ki(t),f.waitViewCompleted((()=>H(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=t,{slice:g,trim:p,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=c&&v&&void 0===s.fill?t.fill:s.fill,b=o.isOpaqueImage(i)||x,B=new O;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"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:M}=new _(e).scale(R.scaleX,R.scaleY),C={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/r*R.scaleX,1/d*R.scaleY)};let W,T=n.canvas({width:Math.round(A),height:Math.round(M),pixelRatio:k,smooth:y,contextSettings:m});if(g&&(W=t,W.__worldOpacity=0,t=f,C.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,C),t.fill=e}else t.__render(T,C);if(T.restore(),W&&W.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?qi(o,s,a):Vi(o={},s,a)),r++;const d=new _;return Qi(o,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:k};T=n.canvas(s),T.copyWorld(t,a,s)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),w&&w(T);const I="canvas"===i?T:yield T.export(i,s);h({data:I,width:T.pixelWidth,height:T.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let Zi;function Ki(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ki(t)))}const $i=t.prototype,tn=w.get("@leafer-ui/export");$i.export=function(t,e){const{quality:i,blob:n}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},$i.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{tn.error(t),n(null)}))}))},$i.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},$i.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{tn.error(t),n(!1)}))}))},Object.assign(j,Gi),Object.assign(N,Hi),Object.assign(z,Wt),Object.assign(F,ue),Object.assign(Y,Me),Object.assign(G,Fe),Object.assign(U,Ji),Object.assign(n,{interaction:(t,e,i,n)=>new P(t,e,i,n),hitCanvas:(t,e)=>new V(t,e),hitCanvasManager:()=>new D});export{lt as Layouter,V as LeaferCanvas,ct as Renderer,vt as Selector,Z as Watcher,J 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/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(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(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=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 d{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:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{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,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),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:w,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.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&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,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||h(i[t])}h(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()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,d,this.times)),i.emitEvent(new t.LayoutEvent(r,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.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 x.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,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),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 s=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,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),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(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.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)}}const{hitRadiusPoint:b}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,o;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:R,YesAndSkip:k}=t.Answer,P={},C={},S={};class M{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":P.id=e.substring(1),e=P;break;case".":C.className=e.substring(1),e=C;break;default:S.tag=e,e=S}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,i),a===E||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function A(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function I(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?T(t,!0,e,n):W(e,n);break;case"inside":O("inside",t,s,e,n);break;case"outside":O("outside",t,s,e,n)}}function O(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?T(e,!0,i,r):W(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(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 W(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function T(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?W(n,s):s.stroke(),s.restoreBlendMode()):e?W(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new M(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:D,getOuterOf:H,getByMove:F,getIntersectData:N}=t.BoundsHelper;let Y;function j(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,d)};case"image":return i.PaintImage.image(n,t,e,s,!Y||!Y[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const U={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),Y=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=o.length;i<a;i++)n=j(t,o[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?A(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),T(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),T(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),T(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:W,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,c=N(i?D(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),r=H(s,o),a=F(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let G={};const{get:X,rotateOfOuter:q,translate:V,scaleOfOuter:z,scale:Q,rotate:J}=t.MatrixHelper;function K(t,e,n,i,s,a,o){const r=X();V(r,e.x+n,e.y+i),Q(r,s,a),o&&q(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Z(t,e,n,i,s,a,o){const r=X();V(r,e.x+n,e.y+i),s&&Q(r,s,a),o&&J(r,o),t.transform=r}function $(t,e,n,i,s,a,o,r,d,l){const h=X();if(d)if("center"===l)q(h,{x:n/2,y:i/2},d);else switch(J(h,d),d){case 90:V(h,i,0);break;case 180:V(h,n,i);break;case 270:V(h,0,n)}G.x=e.x+s,G.y=e.y+a,V(h,G.x,G.y),o&&z(h,G,o,r),t.transform=h}const{get:tt,translate:et}=t.MatrixHelper,nt=new t.Bounds,it={},st={};function at(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=ot(n,i,e)}function ot(e,n,i){let{width:s,height:a}=i;e.padding&&(n=nt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:r},_="center"!==d&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,st),y=st.scaleX,v=st.scaleY);else if(!g||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-s*y)/2,B+=(n.height-a*v)/2}if(d){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,it,!0),x+=it.x,B+=it.y}switch(l&&(x+=l.x,B+=l.y),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&Z(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&$(p,n,s,a,x,B,y,v,u,d),f||(p.repeat="repeat");break;default:y&&K(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=tt(),et(p.transform,n.x,n.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let rt,dt=new t.Bounds;const{isSame:lt}=t.BoundsHelper;function ht(t,e,n,i,s,a){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||at(s,i,n,a),!0}function ct(e,n){gt(e,t.ImageEvent.LOAD,n)}function ut(e,n){gt(e,t.ImageEvent.LOADED,n)}function ft(e,n,i){n.error=i,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,n)}function gt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:_t,scale:wt,copy:mt}=t.MatrixHelper,{ceil:yt,abs:vt}=Math;function xt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=vt(s),a=vt(a);const{image:e,data:r}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=_t(),mt(l,p),wt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;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&&(d=Math.sqrt(w/m)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=_t(),p&&mt(l,p)),wt(l,1/s,1/a));const y=e.getCanvas(yt(h)||1,yt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:Bt}=Math;const bt={image:function(e,n,i,s,a){let o,r;const d=t.ImageManager.get(i);return rt&&i===rt.paint&<(s,rt.boxBounds)?o=rt.leafPaint:(o={type:i.type,image:d},rt=d.use>1?{leafPaint:o,paint:i,boxBounds:dt.set(s)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(ht(e,n,i,d,o,s),a&&(ct(e,r),ut(e,r))):d.error?a&&ft(e,r,d.error):(pt(e,!0),a&&ct(e,r),o.loadId=d.load((()=>{pt(e,!1),e.destroyed||(ht(e,n,i,d,o,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ut(e,r)),o.loadId=null}),(t=>{pt(e,!1),ft(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,a,o){const{scaleX:r,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:l}=n;if(!a.data||a.patternId===r+"-"+d+"-"+l&&!i.Export.running)return!1;{const{data:h}=a;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=Bt(r)*l,n*=Bt(d)*l,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(a.image.view,0,0,h.width,h.height),n.restore(),!0):(!a.style||a.sync||i.Export.running?xt(e,a,l):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&xt(e,a,l),e.forceUpdate("surface")}))),300)),!1)}},createPattern:xt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:at,getPatternData:ot,fillOrFitMode:K,clipMode:Z,repeatMode:$},{toPoint:Lt}=t.AroundHelper,Et={},Rt={};function kt(t,e,n){if(e){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Pt,getDistance:Ct}=t.PointHelper,{get:St,rotateOfOuter:Mt,scaleOfOuter:At}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,Ot={},Wt={};function Tt(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=Pt(e,n);a=St(),s?(At(a,e,o/r*(i||1),1),Mt(a,e,t+90)):(At(a,e,1,o/r*(i||1)),Mt(a,e,t))}return a}const{getDistance:Dt}=t.PointHelper,{toPoint:Ht}=t.AroundHelper,Ft={},Nt={};const Yt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;Lt(i||"top",n,Et),Lt(s||"bottom",n,Rt);const d=t.Platform.canvas.createLinearGradient(Et.x,Et.y,Rt.x,Rt.y);kt(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;It(i||"center",n,Ot),It(s||"bottom",n,Wt);const l=t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Ct(Ot,Wt));kt(l,e.stops,o);const h={type:a,style:l},c=Tt(n,Ot,Wt,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;Ht(i||"center",n,Ft),Ht(s||"bottom",n,Nt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Dt(Ft,Nt));kt(l,e.stops,o);const h={type:a,style:l},c=Tt(n,Ft,Nt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Tt},{copy:jt,toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={},Xt={};function qt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(jt(Gt,e.bounds),Gt.x+=n.x-o.x,Gt.y+=n.y-o.y,i){const{matrix:t}=s;Gt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Gt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Gt.width*=i,Gt.height*=i}e.copyWorld(s.canvas,e.bounds,Gt)}else i&&(jt(Gt,n),Gt.x-=n.width/2*(i-1),Gt.y-=n.height/2*(i-1),Gt.width*=i,Gt.height*=i),e.copyWorld(s.canvas,o,i?Gt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,zt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Ut(l,Xt),r.forEach(((r,p)=>{f.setWorldShadow(Xt.offsetX+r.x*c,Xt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qt(f,Xt,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Vt(l,zt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*c,zt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qt(f,zt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&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 Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Kt(this,o,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Zt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Jt(n,e)||n.__render(s||t,e);Kt(this,o,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ie(te),re=ie(ee),de=ie("- —/~|┆·");var le;!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"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=le;function _e(t){return se[t]?he:de[t]?pe:ae[t]?ue:oe[t]?fe:re[t]?ge:ne.test(t)?ce:he}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(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:ye}=we,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Le,Break:Ee}=le;let Re,ke,Pe,Ce,Se,Me,Ae,Ie,Oe,We,Te,De,He,Fe,Ne,Ye,je=[];function Ue(t,e){Oe&&!Ie&&(Ie=Oe),Re.data.push({char:t,width:e}),Pe+=e}function Ge(){Ce+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function Xe(){Fe&&(Ne.paraNumber++,ke.paraStart=!0,Fe=!1),Oe&&(ke.startCharSize=Ie,ke.endCharSize=Oe,Ie=0),ke.width=Ce,Ye.width&&ye(ke),je.push(ke),ke={words:[]},Ce=0}const qe=0,Ve=1,ze=2;const{top:Qe,right:Je,bottom:Ke,left:Ze}=t.Direction4;function $e(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 tn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Ze],a-=l[Je]+l[Ze]),o&&(s=l[Qe],o-=l[Qe]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ne=e,je=e.rows,Ye=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ye;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Ie=Ae=Oe=Pe=Ce=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Me=n[i],"\n"===Me?(Pe&&Ge(),ke.paraEnd=!0,Xe(),Fe=!0):(We=_e(Me),We===ve&&"none"!==o&&(Me=me(Me,o,!Pe)),Ae=r.measureText(Me).width,s&&(s<0&&(Oe=Ae),Ae+=s),De=We===xe&&(Te===xe||Te===ve)||Te===xe&&We!==be,He=!(We!==Be&&We!==xe||Te!==Le&&Te!==be),Se=Fe&&a?d-a:d,t&&d&&Ce+Pe+Ae>Se&&(e?(Pe&&Ge(),Ce&&Xe()):(He||(He=We===ve&&Te==be),De||He||We===Ee||We===Be||We===xe||Pe+Ae>Se?(Pe&&Ge(),Ce&&Xe()):Ce&&Xe()))," "===Me&&!0!==Fe&&Ce+Pe===0||(We===Ee?(" "===Me&&Pe&&Ge(),Ue(Me,Ae),Ge()):De||He?(Pe&&Ge(),Ue(Me,Ae)):Ue(Me,Ae)),Te=We);Pe&&Ge(),Ce&&Xe(),je.length>0&&(je[je.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ne.paraNumber++,je.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Je])}if(!s)switch(n.verticalAlign){case"top":$e(e,"y",t[Qe]);break;case"bottom":$e(e,"y",-t[Ke])}}(l,h,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:w}=i,m=s*n.length+(h?h*(t.paraNumber-1):0),y=a;if(r&&m>w)m=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":p+=(w-m)/2;break;case"bottom":p+=w-m}y+=p;for(let a=0,l=n.length;a<l;a++){if(c=n[a],c.x=g,c.width<_||c.width>_&&!r)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(y+=h),c.y=y,y+=s,t.overflow>a&&y>m&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?qe:l>.01?Ve:ze,t.isOverflow&&!r&&(t.textMode=!0),c===ze?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ve?(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)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,h=i+s-l;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<h));i--){if(d<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"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}}(h,n),h}};const en={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:nn,addPoint:sn,toBounds:an}=t.TwoPointBoundsHelper;const on={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){rn||(rn=new t.TaskProcessor);return new Promise((t=>{rn.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((d=>{const l=t=>{r(t),d(),this.running=!1},{toURL:h}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(h(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(h(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:u}=e;u?(dn(e),u.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:d,isLeafer:h,isFrame:c}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?u.config.smooth:i.smooth,w=i.contextSettings||u.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?u.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"inner":"local");switch(o=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-L,-E).withScale(1/o*B.scaleX,1/r*B.scaleY)};let C,S=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(C=e,C.__worldOpacity=0,e=u,P.bounds=S.bounds),S.save(),c&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(S,P),e.fill=t}else e.__render(S,P);if(S.restore(),C&&C.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,o=(d-a)/n,r?sn(r,a,o):nn(r={},a,o)),d++;const l=new t.Bounds;return an(r,l),l.scale(1/e.pixelRatio).ceil()}(S);const e=S,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};S=t.Creator.canvas(s),S.copyWorld(e,a,s)}v&&S.fillWorld(S.bounds,y||"#FFFFFF","destination-over"),p&&p(S);const M="canvas"===n?S:yield S.export(n,i);l({data:M,width:S.pixelWidth,height:S.pixelHeight,renderBounds:s,trimBounds:a})}))))):l({data:!1})}))))}};let rn;function dn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>dn(t)))}const ln=t.LeaferCanvasBase.prototype,hn=t.Debug.get("@leafer-ui/export");ln.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},ln.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{hn.error(t),i(null)}))}))},ln.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},ln.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{hn.error(t),i(!1)}))}))},Object.assign(i.TextConvert,tn),Object.assign(i.ColorConvert,en),Object.assign(i.Paint,U),Object.assign(i.PaintImage,bt),Object.assign(i.PaintGradient,Yt),Object.assign(i.Effect,Qt),Object.assign(i.Export,on),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=M,exports.Watcher=d,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;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:a}=i;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)=>s(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>a(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/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,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:r}=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 l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{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,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),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:w,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,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||h(i[t])}h(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()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{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,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.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 x.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,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),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 s=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,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),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(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.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)}}const{hitRadiusPoint:b}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,a),d=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,o;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:R,YesAndSkip:k}=t.Answer,P={},S={},C={};class M{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":P.id=e.substring(1),e=P;break;case".":S.className=e.substring(1),e=S;break;default:C.tag=e,e=C}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,i),a===E||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function A(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function I(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?T(t,!0,e,n):O(e,n);break;case"inside":W("inside",t,s,e,n);break;case"outside":W("outside",t,s,e,n)}}function W(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?T(e,!0,i,r):O(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(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 O(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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,a)}function T(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?O(n,s):s.stroke(),s.restoreBlendMode()):e?O(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new M(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:D,getOuterOf:H,getByMove:F,getIntersectData:N}=t.BoundsHelper;let Y;function j(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:l}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,s,!Y||!Y[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const U={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),Y=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=o.length;i<a;i++)n=j(t,o[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?A(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),T(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),T(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),T(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:O,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,c=N(i?D(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=H(s,o),a=F(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let G={};const{get:X,rotateOfOuter:z,translate:q,scaleOfOuter:V,scale:Q,rotate:J}=t.MatrixHelper;function K(t,e,n,i,s,a,o){const r=X();q(r,e.x+n,e.y+i),Q(r,s,a),o&&z(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Z(t,e,n,i,s,a,o){const r=X();q(r,e.x+n,e.y+i),s&&Q(r,s,a),o&&J(r,o),t.transform=r}function $(t,e,n,i,s,a,o,r,l,d){const h=X();if(l)if("center"===d)z(h,{x:n/2,y:i/2},l);else switch(J(h,l),l){case 90:q(h,i,0);break;case 180:q(h,n,i);break;case 270:q(h,0,n)}G.x=e.x+s,G.y=e.y+a,q(h,G.x,G.y),o&&V(h,G,o,r),t.transform=h}const{get:tt,translate:et}=t.MatrixHelper,nt=new t.Bounds,it={},st={};function at(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=ot(n,i,e)}function ot(e,n,i){let{width:s,height:a}=i;e.padding&&(n=nt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:r},_="center"!==l&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,st),y=st.scaleX,v=st.scaleY);else if(!g||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-s*y)/2,B+=(n.height-a*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,it,!0),x+=it.x,B+=it.y}switch(d&&(x+=d.x,B+=d.y),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&Z(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&$(p,n,s,a,x,B,y,v,u,l),f||(p.repeat="repeat");break;default:y&&K(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=tt(),et(p.transform,n.x,n.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let rt,lt=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function ht(t,e,n,i,s,a){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||at(s,i,n,a),!0}function ct(e,n){gt(e,t.ImageEvent.LOAD,n)}function ut(e,n){gt(e,t.ImageEvent.LOADED,n)}function ft(e,n,i){n.error=i,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,n)}function gt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:_t,scale:wt,copy:mt}=t.MatrixHelper,{ceil:yt,abs:vt}=Math;function xt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=vt(s),a=vt(a);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=_t(),mt(d,p),wt(d,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;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&&(s/=l,a/=l,h/=l,c/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=_t(),p&&mt(d,p)),wt(d,1/s,1/a));const y=e.getCanvas(yt(h)||1,yt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:Bt}=Math;const bt={image:function(e,n,i,s,a){let o,r;const l=t.ImageManager.get(i);return rt&&i===rt.paint&&dt(s,rt.boxBounds)?o=rt.leafPaint:(o={type:i.type,image:l},rt=l.use>1?{leafPaint:o,paint:i,boxBounds:lt.set(s)}:null),(a||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(ht(e,n,i,l,o,s),a&&(ct(e,r),ut(e,r))):l.error?a&&ft(e,r,l.error):(a&&(pt(e,!0),ct(e,r)),o.loadId=l.load((()=>{pt(e,!1),e.destroyed||(ht(e,n,i,l,o,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ut(e,r)),o.loadId=null}),(t=>{pt(e,!1),ft(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,a,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!a.data||a.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=a;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=Bt(r)*d,n*=Bt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(a.image.view,0,0,h.width,h.height),n.restore(),!0):(!a.style||a.sync||i.Export.running?xt(e,a,d):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&xt(e,a,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:xt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:at,getPatternData:ot,fillOrFitMode:K,clipMode:Z,repeatMode:$},{toPoint:Lt}=t.AroundHelper,Et={},Rt={};function kt(t,e,n){if(e){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Pt,getDistance:St}=t.PointHelper,{get:Ct,rotateOfOuter:Mt,scaleOfOuter:At}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,Wt={},Ot={};function Tt(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=Pt(e,n);a=Ct(),s?(At(a,e,o/r*(i||1),1),Mt(a,e,t+90)):(At(a,e,1,o/r*(i||1)),Mt(a,e,t))}return a}const{getDistance:Dt}=t.PointHelper,{toPoint:Ht}=t.AroundHelper,Ft={},Nt={};const Yt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;Lt(i||"top",n,Et),Lt(s||"bottom",n,Rt);const l=t.Platform.canvas.createLinearGradient(Et.x,Et.y,Rt.x,Rt.y);kt(l,e.stops,r);const d={type:a,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;It(i||"center",n,Wt),It(s||"bottom",n,Ot);const d=t.Platform.canvas.createRadialGradient(Wt.x,Wt.y,0,Wt.x,Wt.y,St(Wt,Ot));kt(d,e.stops,o);const h={type:a,style:d},c=Tt(n,Wt,Ot,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;Ht(i||"center",n,Ft),Ht(s||"bottom",n,Nt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Dt(Ft,Nt));kt(d,e.stops,o);const h={type:a,style:d},c=Tt(n,Ft,Nt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Tt},{copy:jt,toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={},Xt={};function zt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(jt(Gt,e.bounds),Gt.x+=n.x-o.x,Gt.y+=n.y-o.y,i){const{matrix:t}=s;Gt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Gt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Gt.width*=i,Gt.height*=i}e.copyWorld(s.canvas,e.bounds,Gt)}else i&&(jt(Gt,n),Gt.x-=n.width/2*(i-1),Gt.y-=n.height/2*(i-1),Gt.width*=i,Gt.height*=i),e.copyWorld(s.canvas,o,i?Gt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Vt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Ut(d,Xt),r.forEach(((r,p)=>{f.setWorldShadow(Xt.offsetX+r.x*c,Xt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,Xt,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),i=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(n.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;qt(d,Vt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*c,Vt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,Vt,s,n),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&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 Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(o&&(Kt(this,o,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Zt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Jt(n,e)||n.__render(s||t,e);Kt(this,o,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ie(te),re=ie(ee),le=ie("- —/~|┆·");var de;!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"}(de||(de={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=de;function _e(t){return se[t]?he:le[t]?pe:ae[t]?ue:oe[t]?fe:re[t]?ge:ne.test(t)?ce:he}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(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:ye}=we,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Le,Break:Ee}=de;let Re,ke,Pe,Se,Ce,Me,Ae,Ie,We,Oe,Te,De,He,Fe,Ne,Ye,je,Ue=[];function Ge(t,e){We&&!Ie&&(Ie=We),Re.data.push({char:t,width:e}),Pe+=e}function Xe(){Se+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function ze(){Fe&&(Ne.paraNumber++,ke.paraStart=!0,Fe=!1),We&&(ke.startCharSize=Ie,ke.endCharSize=We,Ie=0),ke.width=Se,Ye.width?ye(ke):je&&qe(),Ue.push(ke),ke={words:[]},Se=0}function qe(){Se>(Ne.maxWidth||0)&&(Ne.maxWidth=Se)}const Ve=0,Qe=1,Je=2;const{top:Ke,right:Ze,bottom:$e,left:tn}=t.Direction4;function en(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 nn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(a?(i=d[tn],a-=d[Ze]+d[tn]):n.autoSizeAlign||(i=d[tn]),o?(s=d[Ke],o-=d[Ke]+d[$e]):n.autoSizeAlign||(s=d[Ke]));const h={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ne=e,Ue=e.rows,Ye=e.bounds,je=!Ye.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ye;if(l||d||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Ie=Ae=We=Pe=Se=0,Re={data:[]},ke={words:[]};for(let i=0,d=n.length;i<d;i++)Me=n[i],"\n"===Me?(Pe&&Xe(),ke.paraEnd=!0,ze(),Fe=!0):(Oe=_e(Me),Oe===ve&&"none"!==o&&(Me=me(Me,o,!Pe)),Ae=r.measureText(Me).width,s&&(s<0&&(We=Ae),Ae+=s),De=Oe===xe&&(Te===xe||Te===ve)||Te===xe&&Oe!==be,He=!(Oe!==Be&&Oe!==xe||Te!==Le&&Te!==be),Ce=Fe&&a?l-a:l,t&&l&&Se+Pe+Ae>Ce&&(e?(Pe&&Xe(),Se&&ze()):(He||(He=Oe===ve&&Te==be),De||He||Oe===Ee||Oe===Be||Oe===xe||Pe+Ae>Ce?(Pe&&Xe(),Se&&ze()):Se&&ze()))," "===Me&&!0!==Fe&&Se+Pe===0||(Oe===Ee?(" "===Me&&Pe&&Xe(),Ge(Me,Ae),Xe()):De||He?(Pe&&Xe(),Ge(Me,Ae)):Ge(Me,Ae)),Te=Oe);Pe&&Xe(),Se&&ze(),Ue.length>0&&(Ue[Ue.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ne.paraNumber++,Se=r.measureText(t).width,Ue.push({x:a||0,text:t,width:Se,paraStart:!0}),je&&qe()}))}(h,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[Ze])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[$e])}}(d,h,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&_>p)_=Math.max(p,s),t.overflow=n.length;else if(p||c)switch(d){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let a=0,d=n.length;a<d;a++){if(m=n[a],m.x=u,m.width<g||m.width>g&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&a>0&&(w+=h),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),y=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,y-=v,v+=e.fontSize):v-=o),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let l,d,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,d=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ve:d>.01?Qe:Je,t.isOverflow&&!r&&(t.textMode=!0),c===Je?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,l=t.x,t.data=[],t.words.forEach((e=>{c===Qe?(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)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+s-d;("none"===n.textWrap?a:[a[o-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<h));i--){if(l<h&&" "!==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)}}))}}(h,n,i,a),"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}}(h,n),h}};const sn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:an,addPoint:on,toBounds:rn}=t.TwoPointBoundsHelper;const ln={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){dn||(dn=new t.TaskProcessor);return new Promise((t=>{dn.add((()=>s(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:h}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(h(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(h(e.toSVG(),"svg"),n),d({data:!!o||e.toSVG()});const{leafer:u}=e;u?(hn(e),u.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?u.config.smooth:i.smooth,w=i.contextSettings||u.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?u.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-L,-E).withScale(1/o*B.scaleX,1/r*B.scaleY)};let S,C=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=u,P.bounds=C.bounds),C.save(),c&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=l%n,o=(l-a)/n,r?on(r,a,o):an(r={},a,o)),l++;const d=new t.Bounds;return rn(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};C=t.Creator.canvas(s),C.copyWorld(e,a,s)}v&&C.fillWorld(C.bounds,y||"#FFFFFF","destination-over"),p&&p(C);const M="canvas"===n?C:yield C.export(n,i);d({data:M,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let dn;function hn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>hn(t)))}const cn=t.LeaferCanvasBase.prototype,un=t.Debug.get("@leafer-ui/export");cn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},cn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{un.error(t),i(null)}))}))},cn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},cn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{un.error(t),i(!1)}))}))},Object.assign(i.TextConvert,nn),Object.assign(i.ColorConvert,sn),Object.assign(i.Paint,U),Object.assign(i.PaintImage,bt),Object.assign(i.PaintGradient,Yt),Object.assign(i.Effect,Qt),Object.assign(i.Export,ln),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=M,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;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:a}=i;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)=>s(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>a(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-ui/node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "@leafer-ui/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
],
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/leaferjs/ui.git"
|
|
24
|
+
"url": "https://github.com/leaferjs/leafer-ui.git"
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/platform/node",
|
|
27
|
-
"bugs": "https://github.com/leaferjs/ui/issues",
|
|
26
|
+
"homepage": "https://github.com/leaferjs/leafer-ui/tree/main/packages/platform/node",
|
|
27
|
+
"bugs": "https://github.com/leaferjs/leafer-ui/issues",
|
|
28
28
|
"keywords": [
|
|
29
29
|
"leafer node",
|
|
30
30
|
"leafer-node",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"leaferjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@leafer/core": "1.0.
|
|
36
|
-
"@leafer/node": "1.0.
|
|
37
|
-
"@leafer/partner": "1.0.
|
|
38
|
-
"@leafer/interface": "1.0.
|
|
39
|
-
"@leafer-ui/draw": "1.0.
|
|
40
|
-
"@leafer-ui/core": "1.0.
|
|
41
|
-
"@leafer-ui/partner": "1.0.
|
|
42
|
-
"@leafer-ui/interface": "1.0.
|
|
35
|
+
"@leafer/core": "1.0.5",
|
|
36
|
+
"@leafer/node": "1.0.5",
|
|
37
|
+
"@leafer/partner": "1.0.5",
|
|
38
|
+
"@leafer/interface": "1.0.5",
|
|
39
|
+
"@leafer-ui/draw": "1.0.5",
|
|
40
|
+
"@leafer-ui/core": "1.0.5",
|
|
41
|
+
"@leafer-ui/partner": "1.0.5",
|
|
42
|
+
"@leafer-ui/interface": "1.0.5"
|
|
43
43
|
}
|
|
44
44
|
}
|