@leafer-ui/worker 1.0.0-rc.11 → 1.0.0-rc.16
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/worker.esm.js +48 -26
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +270 -150
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +265 -150
- package/dist/worker.module.min.js +1 -1
- package/package.json +7 -7
package/dist/worker.esm.js
CHANGED
|
@@ -391,9 +391,11 @@ class Layouter {
|
|
|
391
391
|
updateAllChange(target);
|
|
392
392
|
}
|
|
393
393
|
addExtra(leaf) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
if (!this.__updatedList.has(leaf)) {
|
|
395
|
+
const { updatedList, beforeBounds } = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
396
|
+
updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
|
|
397
|
+
updatedList.add(leaf);
|
|
398
|
+
}
|
|
397
399
|
}
|
|
398
400
|
createBlock(data) {
|
|
399
401
|
return new LayoutBlockData(data);
|
|
@@ -1367,9 +1369,9 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1367
1369
|
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
1368
1370
|
if (attrName === 'fill' && !ui.__.__naturalWidth) {
|
|
1369
1371
|
const data = ui.__;
|
|
1370
|
-
data.__naturalWidth = image.width;
|
|
1371
|
-
data.__naturalHeight = image.height;
|
|
1372
|
-
if (data.
|
|
1372
|
+
data.__naturalWidth = image.width / data.pixelRatio;
|
|
1373
|
+
data.__naturalHeight = image.height / data.pixelRatio;
|
|
1374
|
+
if (data.__autoSide) {
|
|
1373
1375
|
ui.forceUpdate('width');
|
|
1374
1376
|
if (ui.__proxyData) {
|
|
1375
1377
|
ui.setProxyAttr('width', data.width);
|
|
@@ -1399,7 +1401,7 @@ function emit(ui, type, data) {
|
|
|
1399
1401
|
}
|
|
1400
1402
|
|
|
1401
1403
|
const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
|
|
1402
|
-
const {
|
|
1404
|
+
const { ceil, abs: abs$1 } = Math;
|
|
1403
1405
|
function createPattern(ui, paint, pixelRatio) {
|
|
1404
1406
|
let { scaleX, scaleY } = ui.__world;
|
|
1405
1407
|
const id = scaleX + '-' + scaleY;
|
|
@@ -1450,7 +1452,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1450
1452
|
}
|
|
1451
1453
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1452
1454
|
}
|
|
1453
|
-
const canvas = image.getCanvas(width
|
|
1455
|
+
const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
|
|
1454
1456
|
const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
|
|
1455
1457
|
paint.style = pattern;
|
|
1456
1458
|
paint.patternId = id;
|
|
@@ -2393,37 +2395,55 @@ const ExportModule = {
|
|
|
2393
2395
|
const { leafer } = leaf;
|
|
2394
2396
|
if (leafer) {
|
|
2395
2397
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2396
|
-
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2397
2398
|
options = FileHelper.getExportOptions(options);
|
|
2398
|
-
|
|
2399
|
+
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2400
|
+
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
2401
|
+
const { slice, trim, onCanvas } = options;
|
|
2402
|
+
const scale = options.scale || 1;
|
|
2399
2403
|
const pixelRatio = options.pixelRatio || 1;
|
|
2400
2404
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2401
|
-
const fill =
|
|
2405
|
+
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
|
|
2402
2406
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
2403
2407
|
if (screenshot) {
|
|
2404
|
-
renderBounds = screenshot === true ? (
|
|
2408
|
+
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2405
2409
|
}
|
|
2406
2410
|
else {
|
|
2407
|
-
const
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2411
|
+
const location = options.location || ((isLeafer || isFrame) ? 'inner' : 'local');
|
|
2412
|
+
scaleX = worldTransform.scaleX;
|
|
2413
|
+
scaleY = worldTransform.scaleY;
|
|
2414
|
+
switch (location) {
|
|
2415
|
+
case 'inner':
|
|
2416
|
+
matrix.set(worldTransform).invert();
|
|
2417
|
+
break;
|
|
2418
|
+
case 'local':
|
|
2419
|
+
matrix.set(worldTransform).divide(leaf.localTransform).invert();
|
|
2420
|
+
scaleX /= leaf.scaleX;
|
|
2421
|
+
scaleY /= leaf.scaleY;
|
|
2422
|
+
break;
|
|
2423
|
+
case 'world':
|
|
2424
|
+
scaleX = 1;
|
|
2425
|
+
scaleY = 1;
|
|
2426
|
+
break;
|
|
2427
|
+
}
|
|
2428
|
+
renderBounds = leaf.getBounds('render', location);
|
|
2418
2429
|
}
|
|
2419
|
-
|
|
2420
|
-
|
|
2430
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scale).ceil();
|
|
2431
|
+
let canvas = Creator.canvas({ width, height, pixelRatio });
|
|
2432
|
+
const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
2421
2433
|
if (slice) {
|
|
2422
2434
|
leaf = leafer;
|
|
2423
2435
|
renderOptions.bounds = canvas.bounds;
|
|
2424
2436
|
}
|
|
2425
2437
|
canvas.save();
|
|
2426
|
-
|
|
2438
|
+
if (isFrame && fill !== undefined) {
|
|
2439
|
+
const oldFill = leaf.get('fill');
|
|
2440
|
+
leaf.fill = '';
|
|
2441
|
+
leaf.__render(canvas, renderOptions);
|
|
2442
|
+
leaf.fill = oldFill;
|
|
2443
|
+
}
|
|
2444
|
+
else {
|
|
2445
|
+
leaf.__render(canvas, renderOptions);
|
|
2446
|
+
}
|
|
2427
2447
|
canvas.restore();
|
|
2428
2448
|
if (trim) {
|
|
2429
2449
|
trimBounds = getTrimBounds(canvas);
|
|
@@ -2434,6 +2454,8 @@ const ExportModule = {
|
|
|
2434
2454
|
}
|
|
2435
2455
|
if (needFill)
|
|
2436
2456
|
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
2457
|
+
if (onCanvas)
|
|
2458
|
+
onCanvas(canvas);
|
|
2437
2459
|
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
2438
2460
|
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
2439
2461
|
}));
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as x,AnimateEvent as v,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as W,HitCanvasManager as C}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as T,PaintGradient as P,Export as F,Group as D,TextConvert as Y,Paint as N,Effect as G}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:X}=a;function U(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:X(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:X(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((i,s)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new H(t,e),image:t=>new n(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:V}=navigator;V.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):V.indexOf("Safari")>-1&&-1===V.indexOf("Chrome")&&(e.fullImageShadow=!0),V.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):V.indexOf("Mac")>-1?e.os="Mac":V.indexOf("Linux")>-1&&(e.os="Linux");class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:z,updateAllWorldOpacity:Q}=u,{pushAllChildBranch:Z,pushAllParent:K}=f;const{worldBounds:$}=g,J={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),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:et,updateAllChange:it}=u,st=p.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new y(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?(q(t,!0),e.add(t),t.isBranch&&Z(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||z(s[t])}z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),nt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,a,this.times)),e.emitEvent(new y(n,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){et(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),it(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new tt([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=p.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?at.warn("rendering"):this.times>3?at.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!p.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(s),p.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(v.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(B.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:rt}=b;class dt{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=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t);let i,s=new o;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 o,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}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||rt(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){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ht,NoAndSkip:lt,YesAndSkip:ct}=R;class ut{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},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new dt(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"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(y.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&&u.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===ht||a===ct){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<lt&&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_(c.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 ft(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 _t(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?wt(t,!0,e,i):pt(e,i);break;case"inside":gt("inside",t,n,e,i);break;case"outside":gt("outside",t,n,e,i)}}function gt(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?wt(e,!0,s,r):pt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",ft(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 pt(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 wt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?pt(i,s):s.stroke(),s.restoreBlendMode()):e?pt(i,s):s.stroke())}Object.assign(s,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new ut(t,e)}),e.layout=nt.fullLayout;const{getSpread:yt,getOuterOf:mt,getByMove:xt,getIntersectData:vt}=b;let Bt;function bt(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:T.string(o,r)};case"image":return I.image(i,t,e,s,!Bt||!Bt[e.url]);case"linear":return P.linearGradient(e,s);case"radial":return P.radialGradient(e,s);case"angular":return P.conicGradient(e,s);default:return e.r?{type:"solid",style:T.string(e)}:void 0}}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Bt=I.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=bt(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?ft(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&&I.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?ft(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?ft(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?ft(e,i):n?i.fill(n):i.fill())},fillText:ft,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)_t(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)_t(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),wt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),wt(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),wt(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:_t,drawTextStroke:pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=n;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=vt(s?yt(e.bounds,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),h*=u,l*=f),r=mt(n,o),a=xt(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:h,scaleY:l}}};let kt={};const{get:Et,rotateOfOuter:Lt,translate:St,scaleOfOuter:Mt,scale:At,rotate:Ot}=k;function Wt(t,e,i,s,n,a){const o=Et(),r=a&&180!==a,d=i.width/(r?n:s),h=i.height/(r?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;St(o,c,u),At(o,l),a&&Lt(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function Ct(t,e,i,s,n,a,o){const r=Et();St(r,e.x,e.y),(i||s)&&St(r,i,s),n&&(At(r,n,a),t.scaleX=r.a,t.scaleY=r.d),o&&Ot(r,o),t.transform=r}function It(t,e,i,s,n,a,o,r,d){const h=Et();if(d)switch(Ot(h,d),d){case 90:St(h,s,0);break;case 180:St(h,i,s);break;case 270:St(h,0,i)}kt.x=e.x,kt.y=e.y,(n||a)&&(kt.x+=n,kt.y+=a),St(h,kt.x,kt.y),o&&(Mt(h,kt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:Tt,translate:Pt}=k;function Ft(t,e,i,s){let{width:n,height:a}=e;const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=Tt(),Pt(g.transform,s.x,s.y));break;case"clip":(d||y||c)&&Ct(g,s,p,w,y,m,c);break;case"repeat":(!_||y||c)&&It(g,s,n,a,p,w,y,m,c),f||(g.repeat="repeat");break;default:_&&!c||Wt(g,r,s,n,a,c)}g.width=n,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Dt,Yt=new _;const{isSame:Nt}=b;function Gt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ft(n,s,i,a),!0}function Ht(t,e){Vt(t,E.LOAD,e)}function Xt(t,e){Vt(t,E.LOADED,e)}function Ut(t,e,i){e.error=i,t.forceUpdate("surface"),Vt(t,E.ERROR,e)}function Vt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}const{get:jt,scale:qt,copy:zt}=k,{round:Qt,abs:Zt}=Math;function Kt(t,i,s){let{scaleX:n,scaleY:a}=t.__world;const o=n+"-"+a;if(i.patternId===o||t.destroyed)return!1;{n=Zt(n),a=Zt(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=jt(),zt(h,g),qt(h,1/u,1/f),n*=u,a*=f),n*=s,a*=s,l*=n,c*=a;const w=l*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,l/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=jt(),g&&zt(h,g)),qt(h,1/n,1/a));const m=t.getCanvas(l<1?1:Qt(l),c<1?1:Qt(c),_),x=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=x,i.patternId=o,!0}}function $t(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;const{abs:Jt}=Math;const te={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return Dt&&i===Dt.paint&&Nt(s,Dt.boxBounds)?a=Dt.leafPaint:(a={type:i.type},a.image=r,Dt=r.use>1?{leafPaint:a,paint:i,boxBounds:Yt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,s),n&&(Ht(t,o),Xt(t,o))):r.error?n&&Ut(t,o,r.error):(n&&Ht(t,o),a.loadId=r.load((()=>{t.destroyed||(Gt(t,e,i,r,a,s)&&t.forceUpdate("surface"),Xt(t,o)),a.loadId=null}),(e=>{Ut(t,o,e),a.loadId=null}))),a},createData:Ft,fillOrFitMode:Wt,clipMode:Ct,repeatMode:It,createPattern:Kt,checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.__world;if(s.data&&s.patternId!==a+"-"+o){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=Jt(a)*i.pixelRatio,s*=Jt(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||F.running?Kt(t,s,i.pixelRatio):s.patternTask||(s.patternTask=x.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__world)&&Kt(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},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}},ee={x:.5,y:0},ie={x:.5,y:1};function se(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,T.string(s.color,i))}const{set:ne,getAngle:ae,getDistance:oe}=L,{get:re,rotateOfOuter:de,scaleOfOuter:he}=k,le={x:.5,y:.5},ce={x:.5,y:1},ue={},fe={};const{set:_e,getAngle:ge,getDistance:pe}=L,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=k,xe={x:.5,y:.5},ve={x:.5,y:1},Be={},be={};const Re={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;s||(s=ee),n||(n=ie);const d=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);se(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=le),n||(n=ce);const{x:h,y:l,width:c,height:u}=i;let f;ne(ue,h+s.x*c,l+s.y*u),ne(fe,h+n.x*c,l+n.y*u),(c!==u||d)&&(f=re(),he(f,ue,c/u*(d||1),1),de(f,ue,ae(ue,fe)+90));const _=e.canvas.createRadialGradient(ue.x,ue.y,0,ue.x,ue.y,oe(ue,fe));se(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=xe),n||(n=ve);const{x:h,y:l,width:c,height:u}=i;_e(Be,h+s.x*c,l+s.y*u),_e(be,h+n.x*c,l+n.y*u);const f=we(),_=ge(Be,be);e.conicGradientRotate90?(me(f,Be,c/u*(d||1),1),ye(f,Be,_+90)):(me(f,Be,1,c/u*(d||1)),ye(f,Be,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,Be.x,Be.y):e.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,pe(Be,be));se(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:ke,toOffsetOutBounds:Ee}=b,Le={},Se={};function Me(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(ke(Le,t.bounds),Le.x+=i.x-o.x,Le.y+=i.y-o.y,s){const{matrix:t}=n;Le.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Le.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(ke(Le,i),Le.x-=i.width/2*(s-1),Le.y-=i.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,o,s?Le:i)}const{toOffsetOutBounds:Ae}=b,Oe={};const We={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ee(h,Se),r.forEach(((r,g)=>{f.setWorldShadow(Se.offsetX+r.x*c,Se.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Me(f,Se,n,i),s=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"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:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ae(h,Oe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Me(f,Oe,n,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=h),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.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ce}=g;function Ie(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),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,a);break;case"path":i.restore()}}function Te(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}D.prototype.__renderMask=function(t,e){let i,s,n,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Ie(this,o,t,n,s,a),s=n=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Te(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=Te(t)),n||(n=Te(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ce(i,e)||i.__render(n||t,e);Ie(this,o,t,n,s,a)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",De=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Xe=Ne(Fe),Ue=Ne(De),Ve=Ne("- —/~|┆·");var je;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(je||(je={}));const{Letter:qe,Single:ze,Before:Qe,After:Ze,Symbol:Ke,Break:$e}=je;function Je(t){return Ge[t]?qe:Ve[t]?$e:He[t]?Qe:Xe[t]?Ze:Ue[t]?Ke:Ye.test(t)?ze:qe}const ti={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 ei(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:ii}=ti,{Letter:si,Single:ni,Before:ai,After:oi,Symbol:ri,Break:di}=je;let hi,li,ci,ui,fi,_i,gi,pi,wi,yi,mi,xi,vi,Bi,bi,Ri,ki=[];function Ei(t,e){wi&&!pi&&(pi=wi),hi.data.push({char:t,width:e}),ci+=e}function Li(){ui+=ci,hi.width=ci,li.words.push(hi),hi={data:[]},ci=0}function Si(){Bi&&(bi.paraNumber++,li.paraStart=!0,Bi=!1),wi&&(li.startCharSize=pi,li.endCharSize=wi,pi=0),li.width=ui,Ri.width&&ii(li),ki.push(li),li={words:[]},ui=0}const Mi=0,Ai=1,Oi=2;const{top:Wi,right:Ci,bottom:Ii,left:Ti}=S;function Pi(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 Fi={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:h}=i;h&&(a&&(s=h[Ti],a-=h[Ci]+h[Ti]),o&&(n=h[Wi],o-=h[Wi]+h[Ii]));const l={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){bi=t,ki=t.rows,Ri=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:h}=Ri;if(d||h||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Bi=!0,mi=null,pi=gi=wi=ci=ui=0,hi={data:[]},li={words:[]};for(let s=0,h=i.length;s<h;s++)_i=i[s],"\n"===_i?(ci&&Li(),li.paraEnd=!0,Si(),Bi=!0):(yi=Je(_i),yi===si&&"none"!==o&&(_i=ei(_i,o,!ci)),gi=r.measureText(_i).width,n&&(n<0&&(wi=gi),gi+=n),xi=yi===ni&&(mi===ni||mi===si)||mi===ni&&yi!==oi,vi=!(yi!==ai&&yi!==ni||mi!==ri&&mi!==oi),fi=Bi&&a?d-a:d,t&&d&&ui+ci+gi>fi&&(e?(ci&&Li(),Si()):(vi||(vi=yi===si&&mi==oi),xi||vi||yi===di||yi===ai||yi===ni||ci+gi>fi?(ci&&Li(),Si()):Si()))," "===_i&&!0!==Bi&&ui+ci===0||(yi===di?(" "===_i&&ci&&Li(),Ei(_i,gi),Li()):xi||vi?(ci&&Li(),Ei(_i,gi)):Ei(_i,gi)),mi=yi);ci&&Li(),ui&&Si(),ki.length>0&&(ki[ki.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{bi.paraNumber++,ki.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Pi(e,"x",t[Ti]);break;case"right":Pi(e,"x",-t[Ci])}if(!n)switch(i.verticalAlign){case"top":Pi(e,"y",t[Wi]);break;case"bottom":Pi(e,"y",-t[Ii])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),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}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Mi:h>.01?Ai:Oi,t.isOverflow&&!r&&(t.textMode=!0),c===Oi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ai?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:a}=i;if(s.splice(n),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<d));s--){if(o<d&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Di={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Yi,addPoint:Ni,toBounds:Gi}=M;const Hi={export(t,e,i){return this.running=!0,function(t){Xi||(Xi=new A);return new Promise((e=>{Xi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){let n,o,h=1,l=1;i=a.getExportOptions(i);const{scale:c,slice:u,trim:f}=i,g=i.pixelRatio||1,p=i.screenshot||t.isApp,w=void 0===i.fill?t.isLeafer&&p?t.fill:"":i.fill,y=a.isOpaqueImage(e)||w,m=new O;if(p)n=!0===p?t.isLeafer?d.canvas.bounds:t.worldRenderBounds:p;else{const{localTransform:e,__world:i}=t;m.set(i).divide(e).invert(),h=1/(i.scaleX/t.scaleX),l=1/(i.scaleY/t.scaleY),n=t.getBounds("render","local")}let{x:x,y:v,width:B,height:b}=n;c&&(m.scale(c),B*=c,b*=c,h*=c,l*=c);let R=s.canvas({width:Math.ceil(B),height:Math.ceil(B),pixelRatio:g});const k={matrix:m.translate(-x,-v).withScale(h,l)};if(u&&(t=d,k.bounds=R.bounds),R.save(),t.__render(R,k),R.restore(),f){o=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?Ni(o,n,a):Yi(o={},n,a)),r++;const d=new _;return Gi(o,d),d.scale(1/t.pixelRatio).ceil()}(R);const t=R,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:g};R=s.canvas(n),R.copyWorld(t,o,n)}y&&R.fillWorld(R.bounds,w||"#FFFFFF","destination-over");const E="canvas"===e?R:yield R.export(e,i);r({data:E,width:R.pixelWidth,height:R.pixelHeight,renderBounds:n,trimBounds:o})})))):r({data:!1})}))))}};let Xi;Object.assign(Y,Fi),Object.assign(T,Di),Object.assign(N,Rt),Object.assign(I,te),Object.assign(P,Re),Object.assign(G,We),Object.assign(F,Hi),Object.assign(s,{interaction:(t,e,i,s)=>new W(t,e,i,s),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new C}),U();export{nt as Layouter,H as LeaferCanvas,ot as Renderer,ut as Selector,j as Watcher,U as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as W,HitCanvasManager as C}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as T,ColorConvert as I,PaintGradient as P,Export as F,Group as D,TextConvert as Y,Paint as N,Effect as G}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:H}=a;function U(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:H(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:H(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((i,s)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new X(t,e),image:t=>new n(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:V}=navigator;V.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):V.indexOf("Safari")>-1&&-1===V.indexOf("Chrome")&&(e.fullImageShadow=!0),V.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):V.indexOf("Mac")>-1?e.os="Mac":V.indexOf("Linux")>-1&&(e.os="Linux");class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:z,updateAllWorldOpacity:Q}=u,{pushAllChildBranch:Z,pushAllParent:K}=f;const{worldBounds:$}=g,J={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),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:et,updateAllChange:it}=u,st=p.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new y(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?(q(t,!0),e.add(t),t.isBranch&&Z(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||z(s[t])}z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),nt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,a,this.times)),e.emitEvent(new y(n,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){et(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=p.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?at.warn("rendering"):this.times>3?at.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!p.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(s),p.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(B.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:rt}=b;class dt{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=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t);let i,s=new o;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 o,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}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||rt(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){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ht,NoAndSkip:lt,YesAndSkip:ct}=R;class ut{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},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new dt(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"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(y.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&&u.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===ht||a===ct){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<lt&&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_(c.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 ft(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 _t(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?wt(t,!0,e,i):pt(e,i);break;case"inside":gt("inside",t,n,e,i);break;case"outside":gt("outside",t,n,e,i)}}function gt(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?wt(e,!0,s,r):pt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",ft(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 pt(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 wt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&T.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?pt(i,s):s.stroke(),s.restoreBlendMode()):e?pt(i,s):s.stroke())}Object.assign(s,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new ut(t,e)}),e.layout=nt.fullLayout;const{getSpread:yt,getOuterOf:mt,getByMove:vt,getIntersectData:xt}=b;let Bt;function bt(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:I.string(o,r)};case"image":return T.image(i,t,e,s,!Bt||!Bt[e.url]);case"linear":return P.linearGradient(e,s);case"radial":return P.radialGradient(e,s);case"angular":return P.conicGradient(e,s);default:return e.r?{type:"solid",style:I.string(e)}:void 0}}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Bt=T.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=bt(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?ft(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&&T.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?ft(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?ft(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?ft(e,i):n?i.fill(n):i.fill())},fillText:ft,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)_t(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)_t(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),wt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),wt(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),wt(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:_t,drawTextStroke:pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=n;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=xt(s?yt(e.bounds,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),h*=u,l*=f),r=mt(n,o),a=vt(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:h,scaleY:l}}};let kt={};const{get:Et,rotateOfOuter:Lt,translate:St,scaleOfOuter:Mt,scale:At,rotate:Ot}=k;function Wt(t,e,i,s,n,a){const o=Et(),r=a&&180!==a,d=i.width/(r?n:s),h=i.height/(r?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;St(o,c,u),At(o,l),a&&Lt(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function Ct(t,e,i,s,n,a,o){const r=Et();St(r,e.x,e.y),(i||s)&&St(r,i,s),n&&(At(r,n,a),t.scaleX=r.a,t.scaleY=r.d),o&&Ot(r,o),t.transform=r}function Tt(t,e,i,s,n,a,o,r,d){const h=Et();if(d)switch(Ot(h,d),d){case 90:St(h,s,0);break;case 180:St(h,i,s);break;case 270:St(h,0,i)}kt.x=e.x,kt.y=e.y,(n||a)&&(kt.x+=n,kt.y+=a),St(h,kt.x,kt.y),o&&(Mt(h,kt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:It,translate:Pt}=k;function Ft(t,e,i,s){let{width:n,height:a}=e;const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=It(),Pt(g.transform,s.x,s.y));break;case"clip":(d||y||c)&&Ct(g,s,p,w,y,m,c);break;case"repeat":(!_||y||c)&&Tt(g,s,n,a,p,w,y,m,c),f||(g.repeat="repeat");break;default:_&&!c||Wt(g,r,s,n,a,c)}g.width=n,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Dt,Yt=new _;const{isSame:Nt}=b;function Gt(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||Ft(n,s,i,a),!0}function Xt(t,e){Vt(t,E.LOAD,e)}function Ht(t,e){Vt(t,E.LOADED,e)}function Ut(t,e,i){e.error=i,t.forceUpdate("surface"),Vt(t,E.ERROR,e)}function Vt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}const{get:jt,scale:qt,copy:zt}=k,{ceil:Qt,abs:Zt}=Math;function Kt(t,i,s){let{scaleX:n,scaleY:a}=t.__world;const o=n+"-"+a;if(i.patternId===o||t.destroyed)return!1;{n=Zt(n),a=Zt(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=jt(),zt(h,g),qt(h,1/u,1/f),n*=u,a*=f),n*=s,a*=s,l*=n,c*=a;const w=l*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,l/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=jt(),g&&zt(h,g)),qt(h,1/n,1/a));const m=t.getCanvas(Qt(l)||1,Qt(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}function $t(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;const{abs:Jt}=Math;const te={image:function(t,e,i,s,n){let a,o;const r=v.get(i);return Dt&&i===Dt.paint&&Nt(s,Dt.boxBounds)?a=Dt.leafPaint:(a={type:i.type},a.image=r,Dt=r.use>1?{leafPaint:a,paint:i,boxBounds:Yt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,s),n&&(Xt(t,o),Ht(t,o))):r.error?n&&Ut(t,o,r.error):(n&&Xt(t,o),a.loadId=r.load((()=>{t.destroyed||(Gt(t,e,i,r,a,s)&&t.forceUpdate("surface"),Ht(t,o)),a.loadId=null}),(e=>{Ut(t,o,e),a.loadId=null}))),a},createData:Ft,fillOrFitMode:Wt,clipMode:Ct,repeatMode:Tt,createPattern:Kt,checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.__world;if(s.data&&s.patternId!==a+"-"+o){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=Jt(a)*i.pixelRatio,s*=Jt(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||F.running?Kt(t,s,i.pixelRatio):s.patternTask||(s.patternTask=v.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__world)&&Kt(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},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,v.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}},ee={x:.5,y:0},ie={x:.5,y:1};function se(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,I.string(s.color,i))}const{set:ne,getAngle:ae,getDistance:oe}=L,{get:re,rotateOfOuter:de,scaleOfOuter:he}=k,le={x:.5,y:.5},ce={x:.5,y:1},ue={},fe={};const{set:_e,getAngle:ge,getDistance:pe}=L,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=k,ve={x:.5,y:.5},xe={x:.5,y:1},Be={},be={};const Re={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;s||(s=ee),n||(n=ie);const d=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);se(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=le),n||(n=ce);const{x:h,y:l,width:c,height:u}=i;let f;ne(ue,h+s.x*c,l+s.y*u),ne(fe,h+n.x*c,l+n.y*u),(c!==u||d)&&(f=re(),he(f,ue,c/u*(d||1),1),de(f,ue,ae(ue,fe)+90));const _=e.canvas.createRadialGradient(ue.x,ue.y,0,ue.x,ue.y,oe(ue,fe));se(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=ve),n||(n=xe);const{x:h,y:l,width:c,height:u}=i;_e(Be,h+s.x*c,l+s.y*u),_e(be,h+n.x*c,l+n.y*u);const f=we(),_=ge(Be,be);e.conicGradientRotate90?(me(f,Be,c/u*(d||1),1),ye(f,Be,_+90)):(me(f,Be,1,c/u*(d||1)),ye(f,Be,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,Be.x,Be.y):e.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,pe(Be,be));se(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:ke,toOffsetOutBounds:Ee}=b,Le={},Se={};function Me(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(ke(Le,t.bounds),Le.x+=i.x-o.x,Le.y+=i.y-o.y,s){const{matrix:t}=n;Le.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Le.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(ke(Le,i),Le.x-=i.width/2*(s-1),Le.y-=i.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,o,s?Le:i)}const{toOffsetOutBounds:Ae}=b,Oe={};const We={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ee(h,Se),r.forEach(((r,g)=>{f.setWorldShadow(Se.offsetX+r.x*c,Se.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Me(f,Se,n,i),s=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"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:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ae(h,Oe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Me(f,Oe,n,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=h),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.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ce}=g;function Te(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),Pe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Pe(t,i,s,a);break;case"path":i.restore()}}function Ie(t){return t.getSameCanvas(!1,!0)}function Pe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}D.prototype.__renderMask=function(t,e){let i,s,n,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Te(this,o,t,n,s,a),s=n=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Ie(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=Ie(t)),n||(n=Ie(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ce(i,e)||i.__render(n||t,e);Te(this,o,t,n,s,a)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",De=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Xe=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=Ne(Fe),Ue=Ne(De),Ve=Ne("- —/~|┆·");var je;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(je||(je={}));const{Letter:qe,Single:ze,Before:Qe,After:Ze,Symbol:Ke,Break:$e}=je;function Je(t){return Ge[t]?qe:Ve[t]?$e:Xe[t]?Qe:He[t]?Ze:Ue[t]?Ke:Ye.test(t)?ze:qe}const ti={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 ei(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:ii}=ti,{Letter:si,Single:ni,Before:ai,After:oi,Symbol:ri,Break:di}=je;let hi,li,ci,ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,Bi,bi,Ri,ki=[];function Ei(t,e){wi&&!pi&&(pi=wi),hi.data.push({char:t,width:e}),ci+=e}function Li(){ui+=ci,hi.width=ci,li.words.push(hi),hi={data:[]},ci=0}function Si(){Bi&&(bi.paraNumber++,li.paraStart=!0,Bi=!1),wi&&(li.startCharSize=pi,li.endCharSize=wi,pi=0),li.width=ui,Ri.width&&ii(li),ki.push(li),li={words:[]},ui=0}const Mi=0,Ai=1,Oi=2;const{top:Wi,right:Ci,bottom:Ti,left:Ii}=S;function Pi(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 Fi={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:h}=i;h&&(a&&(s=h[Ii],a-=h[Ci]+h[Ii]),o&&(n=h[Wi],o-=h[Wi]+h[Ti]));const l={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){bi=t,ki=t.rows,Ri=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:h}=Ri;if(d||h||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Bi=!0,mi=null,pi=gi=wi=ci=ui=0,hi={data:[]},li={words:[]};for(let s=0,h=i.length;s<h;s++)_i=i[s],"\n"===_i?(ci&&Li(),li.paraEnd=!0,Si(),Bi=!0):(yi=Je(_i),yi===si&&"none"!==o&&(_i=ei(_i,o,!ci)),gi=r.measureText(_i).width,n&&(n<0&&(wi=gi),gi+=n),vi=yi===ni&&(mi===ni||mi===si)||mi===ni&&yi!==oi,xi=!(yi!==ai&&yi!==ni||mi!==ri&&mi!==oi),fi=Bi&&a?d-a:d,t&&d&&ui+ci+gi>fi&&(e?(ci&&Li(),Si()):(xi||(xi=yi===si&&mi==oi),vi||xi||yi===di||yi===ai||yi===ni||ci+gi>fi?(ci&&Li(),Si()):Si()))," "===_i&&!0!==Bi&&ui+ci===0||(yi===di?(" "===_i&&ci&&Li(),Ei(_i,gi),Li()):vi||xi?(ci&&Li(),Ei(_i,gi)):Ei(_i,gi)),mi=yi);ci&&Li(),ui&&Si(),ki.length>0&&(ki[ki.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{bi.paraNumber++,ki.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Pi(e,"x",t[Ii]);break;case"right":Pi(e,"x",-t[Ci])}if(!n)switch(i.verticalAlign){case"top":Pi(e,"y",t[Wi]);break;case"bottom":Pi(e,"y",-t[Ti])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),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}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Mi:h>.01?Ai:Oi,t.isOverflow&&!r&&(t.textMode=!0),c===Oi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ai?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:a}=i;if(s.splice(n),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<d));s--){if(o<d&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Di={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Yi,addPoint:Ni,toBounds:Gi}=M;const Xi={export(t,e,i){return this.running=!0,function(t){Hi||(Hi=new A);return new Promise((e=>{Hi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){i=a.getExportOptions(i);let n,o,h=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=i,y=i.scale||1,m=i.pixelRatio||1,v=i.screenshot||t.isApp,x=u&&v?void 0===i.fill?t.fill:void 0:i.fill,B=a.isOpaqueImage(e)||x,b=new O;if(v)n=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{const e=i.location||(u||f?"inner":"local");switch(h=c.scaleX,l=c.scaleY,e){case"inner":b.set(c).invert();break;case"local":b.set(c).divide(t.localTransform).invert(),h/=t.scaleX,l/=t.scaleY;break;case"world":h=1,l=1}n=t.getBounds("render",e)}const{x:R,y:k,width:E,height:L}=new _(n).scale(y).ceil();let S=s.canvas({width:E,height:L,pixelRatio:m});const M={matrix:b.scale(y).translate(-R,-k).withScale(1/h*y,1/l*y)};if(g&&(t=d,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=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?Ni(o,n,a):Yi(o={},n,a)),r++;const d=new _;return Gi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:m};S=s.canvas(n),S.copyWorld(t,o,n)}B&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===e?S:yield S.export(e,i);r({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:n,trimBounds:o})})))):r({data:!1})}))))}};let Hi;Object.assign(Y,Fi),Object.assign(I,Di),Object.assign(N,Rt),Object.assign(T,te),Object.assign(P,Re),Object.assign(G,We),Object.assign(F,Xi),Object.assign(s,{interaction:(t,e,i,s)=>new W(t,e,i,s),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new C}),U();export{nt as Layouter,X as LeaferCanvas,ot as Renderer,ut as Selector,j as Watcher,U as useCanvas};
|