@leafer-ui/worker 1.9.0 → 1.9.2
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.cjs +17 -12
- package/dist/worker.esm.js +17 -12
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +233 -158
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +238 -160
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/worker.cjs
CHANGED
|
@@ -534,8 +534,8 @@ class Renderer {
|
|
|
534
534
|
const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
|
|
535
535
|
canvas.save();
|
|
536
536
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
537
|
-
canvas.clearWorld(bounds
|
|
538
|
-
canvas.clipWorld(bounds
|
|
537
|
+
canvas.clearWorld(bounds);
|
|
538
|
+
canvas.clipWorld(bounds);
|
|
539
539
|
this.__render(bounds, realBounds);
|
|
540
540
|
canvas.restore();
|
|
541
541
|
core.Run.end(t);
|
|
@@ -758,6 +758,7 @@ class Picker {
|
|
|
758
758
|
hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point);
|
|
759
759
|
if (child.isBranch) {
|
|
760
760
|
if (hit || child.__ignoreHitWorld) {
|
|
761
|
+
if (child.topChildren) this.eachFind(child.topChildren, false);
|
|
761
762
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
762
763
|
if (child.isBranchLeaf) this.hitChild(child, point);
|
|
763
764
|
}
|
|
@@ -1025,18 +1026,22 @@ const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIn
|
|
|
1025
1026
|
|
|
1026
1027
|
function shape(ui, current, options) {
|
|
1027
1028
|
const canvas = current.getSameCanvas();
|
|
1028
|
-
const nowWorld = ui.__nowWorld;
|
|
1029
|
+
const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
|
|
1029
1030
|
let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1030
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
1031
|
-
if (
|
|
1032
|
-
if (scaleY < 0) scaleY = -scaleY;
|
|
1033
|
-
if (current.bounds.includes(nowWorld)) {
|
|
1031
|
+
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1032
|
+
if (currentBounds.includes(nowWorld)) {
|
|
1034
1033
|
worldCanvas = canvas;
|
|
1035
1034
|
bounds = shapeBounds = nowWorld;
|
|
1036
1035
|
} else {
|
|
1037
1036
|
const {renderShapeSpread: spread} = ui.__layout;
|
|
1038
|
-
|
|
1039
|
-
|
|
1037
|
+
let worldClipBounds;
|
|
1038
|
+
if (core.Platform.fullImageShadow) {
|
|
1039
|
+
worldClipBounds = nowWorld;
|
|
1040
|
+
} else {
|
|
1041
|
+
const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
|
|
1042
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorld);
|
|
1043
|
+
}
|
|
1044
|
+
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1040
1045
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
1041
1046
|
if (fitMatrix.a < 1) {
|
|
1042
1047
|
worldCanvas = current.getSameCanvas();
|
|
@@ -1776,7 +1781,7 @@ function shadow(ui, current, shape) {
|
|
|
1776
1781
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
1777
1782
|
}
|
|
1778
1783
|
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1779
|
-
if (end && index < end) other.clearWorld(copyBounds
|
|
1784
|
+
if (end && index < end) other.clearWorld(copyBounds);
|
|
1780
1785
|
});
|
|
1781
1786
|
other.recycle(copyBounds);
|
|
1782
1787
|
}
|
|
@@ -1840,7 +1845,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1840
1845
|
}
|
|
1841
1846
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), "source-in");
|
|
1842
1847
|
core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1843
|
-
if (end && index < end) other.clearWorld(copyBounds
|
|
1848
|
+
if (end && index < end) other.clearWorld(copyBounds);
|
|
1844
1849
|
});
|
|
1845
1850
|
other.recycle(copyBounds);
|
|
1846
1851
|
}
|
|
@@ -1939,7 +1944,7 @@ function copyContent(leaf, canvas, content, maskOpacity, blendMode, recycle) {
|
|
|
1939
1944
|
canvas.resetTransform();
|
|
1940
1945
|
canvas.opacity = maskOpacity;
|
|
1941
1946
|
canvas.copyWorld(content, realBounds, undefined, blendMode);
|
|
1942
|
-
recycle ? content.recycle(realBounds) : content.clearWorld(realBounds
|
|
1947
|
+
recycle ? content.recycle(realBounds) : content.clearWorld(realBounds);
|
|
1943
1948
|
}
|
|
1944
1949
|
|
|
1945
1950
|
const money = "¥¥$€££¢¢";
|
package/dist/worker.esm.js
CHANGED
|
@@ -538,8 +538,8 @@ class Renderer {
|
|
|
538
538
|
const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
539
539
|
canvas.save();
|
|
540
540
|
bounds.spread(Renderer.clipSpread).ceil();
|
|
541
|
-
canvas.clearWorld(bounds
|
|
542
|
-
canvas.clipWorld(bounds
|
|
541
|
+
canvas.clearWorld(bounds);
|
|
542
|
+
canvas.clipWorld(bounds);
|
|
543
543
|
this.__render(bounds, realBounds);
|
|
544
544
|
canvas.restore();
|
|
545
545
|
Run.end(t);
|
|
@@ -762,6 +762,7 @@ class Picker {
|
|
|
762
762
|
hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point);
|
|
763
763
|
if (child.isBranch) {
|
|
764
764
|
if (hit || child.__ignoreHitWorld) {
|
|
765
|
+
if (child.topChildren) this.eachFind(child.topChildren, false);
|
|
765
766
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
766
767
|
if (child.isBranchLeaf) this.hitChild(child, point);
|
|
767
768
|
}
|
|
@@ -1029,18 +1030,22 @@ const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIn
|
|
|
1029
1030
|
|
|
1030
1031
|
function shape(ui, current, options) {
|
|
1031
1032
|
const canvas = current.getSameCanvas();
|
|
1032
|
-
const nowWorld = ui.__nowWorld;
|
|
1033
|
+
const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
|
|
1033
1034
|
let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1034
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
1035
|
-
if (
|
|
1036
|
-
if (scaleY < 0) scaleY = -scaleY;
|
|
1037
|
-
if (current.bounds.includes(nowWorld)) {
|
|
1035
|
+
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1036
|
+
if (currentBounds.includes(nowWorld)) {
|
|
1038
1037
|
worldCanvas = canvas;
|
|
1039
1038
|
bounds = shapeBounds = nowWorld;
|
|
1040
1039
|
} else {
|
|
1041
1040
|
const {renderShapeSpread: spread} = ui.__layout;
|
|
1042
|
-
|
|
1043
|
-
|
|
1041
|
+
let worldClipBounds;
|
|
1042
|
+
if (Platform.fullImageShadow) {
|
|
1043
|
+
worldClipBounds = nowWorld;
|
|
1044
|
+
} else {
|
|
1045
|
+
const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
|
|
1046
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorld);
|
|
1047
|
+
}
|
|
1048
|
+
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1044
1049
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
1045
1050
|
if (fitMatrix.a < 1) {
|
|
1046
1051
|
worldCanvas = current.getSameCanvas();
|
|
@@ -1780,7 +1785,7 @@ function shadow(ui, current, shape) {
|
|
|
1780
1785
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
1781
1786
|
}
|
|
1782
1787
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1783
|
-
if (end && index < end) other.clearWorld(copyBounds
|
|
1788
|
+
if (end && index < end) other.clearWorld(copyBounds);
|
|
1784
1789
|
});
|
|
1785
1790
|
other.recycle(copyBounds);
|
|
1786
1791
|
}
|
|
@@ -1844,7 +1849,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1844
1849
|
}
|
|
1845
1850
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
|
|
1846
1851
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1847
|
-
if (end && index < end) other.clearWorld(copyBounds
|
|
1852
|
+
if (end && index < end) other.clearWorld(copyBounds);
|
|
1848
1853
|
});
|
|
1849
1854
|
other.recycle(copyBounds);
|
|
1850
1855
|
}
|
|
@@ -1943,7 +1948,7 @@ function copyContent(leaf, canvas, content, maskOpacity, blendMode, recycle) {
|
|
|
1943
1948
|
canvas.resetTransform();
|
|
1944
1949
|
canvas.opacity = maskOpacity;
|
|
1945
1950
|
canvas.copyWorld(content, realBounds, undefined, blendMode);
|
|
1946
|
-
recycle ? content.recycle(realBounds) : content.clearWorld(realBounds
|
|
1951
|
+
recycle ? content.recycle(realBounds) : content.clearWorld(realBounds);
|
|
1947
1952
|
}
|
|
1948
1953
|
|
|
1949
1954
|
const money = "¥¥$€££¢¢";
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as h,ChildEvent as d,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as _,Bounds as p,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,Matrix as R,isUndefined as L,isString as A,getMatrixData as T,MatrixHelper as C,MathHelper as W,AlignHelper as O,PointHelper as P,ImageEvent as M,AroundHelper as D,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as Y,InteractionBase as z}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as U,Paint as G,ColorConvert as X,PaintGradient as N,Export as q,Group as H,TextConvert as j,Effect as V}from"@leafer-ui/draw";class Q 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:Z}=s;function $(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Z(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:Z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(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=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),J.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):J.indexOf("Mac")>-1?e.os="Mac":J.indexOf("Linux")>-1&&(e.os="Linux");class K{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=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===d.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 o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[d.ADD,d.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=f,{pushAllChildBranch:st,pushAllParent:nt}=g;const{worldBounds:at}=_;class rt{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,y(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),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:lt}=f,ht=w.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.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:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,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?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(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||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),dt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(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(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=w.get("Renderer");class ut{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=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(h.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,ct.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(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=new p(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new p(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new h(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[h.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[h.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}ut.clipSpread=10;const{hitRadiusPoint:ft}=B;class gt{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 o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);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,r=i.length;t<r;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||ft(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&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){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new gt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function pt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?pt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function wt(t,e,i){switch(e.__.strokeAlign){case"center":mt(t,1,e,i);break;case"inside":xt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?mt(t,2,e,i):xt(t,"outside",e,i)}}function mt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),vt(i,s))}function xt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,mt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",pt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function vt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function bt(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,h=t.length;l<h;l++)if(a=t[l],(!a.image||!U.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?vt(s,n):n.stroke(),n.restoreBlendMode()):i?vt(s,n):n.stroke()}}function kt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)wt(t,e,i);else switch(s.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Bt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Bt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Bt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Bt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&G.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=dt.fullLayout;const{getSpread:St,getOuterOf:Et,getByMove:Rt,getIntersectData:Lt}=B;let At;const{stintSet:Tt}=l,{hasTransparent:Ct}=X;function Wt(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,n,!At||!At[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:X.string(r,o)};break;default:L(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(A(s.style)&&Ct(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Ot={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];y(o)||(o=[o]),At=U.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Wt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:pt,stroke:kt,strokes:function(t,e,i){kt(t,e,i)},strokeText:wt,drawTextStroke:vt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,r,o,l,h,{scaleX:d,scaleY:c}=n;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(n))h=s,a=l=n;else{const{renderShapeSpread:s}=t.__layout,u=Lt(s?St(e.bounds,d===c?s*d:[s*c,s*d]):e.bounds,n);o=e.bounds.getFitMatrix(u);let{a:f,d:g}=o;o.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=f,c*=g),l=Et(n,o),a=Rt(l,-o.e,-o.f);const _=i.matrix;_?(r=new R(o),r.multiply(_),f*=_.scaleX,g*=_.scaleY):r=o,r.withScale(f,g),i=Object.assign(Object.assign({},i),{matrix:r})}return t.__renderShape(s,i),{canvas:s,matrix:r,fitMatrix:o,bounds:a,worldCanvas:h,shapeBounds:l,scaleX:d,scaleY:c}}};let Pt={},Mt=T();const{get:Dt,rotateOfOuter:Ft,translate:It,scaleOfOuter:Yt,multiplyParent:zt,scale:Ut,rotate:Gt,skew:Xt}=C;function Nt(t,e,i,s,n,a,r){const o=Dt();It(o,e.x+i,e.y+s),Ut(o,n,a),r&&Ft(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function qt(t,e,i,s,n,a,r,o,l){const h=Dt();jt(h,e,i,s,n,a,r,o),l&&(Mt.a=e.width/l.width,Mt.d=e.height/l.height,zt(h,Mt)),t.transform=h}function Ht(t,e,i,s,n,a,r,o,l,h,d,c){const u=Dt();if(c)jt(u,e,n,a,r,o,l,h);else{if(l)if("center"===d)Ft(u,{x:i/2,y:s/2},l);else switch(Gt(u,l),l){case 90:It(u,s,0);break;case 180:It(u,i,s);break;case 270:It(u,0,i)}Pt.x=e.x+n,Pt.y=e.y+a,It(u,Pt.x,Pt.y),r&&Yt(u,Pt,r,o)}t.transform=u}function jt(t,e,i,s,n,a,r,o){r&&Gt(t,r),o&&Xt(t,o.x,o.y),n&&Ut(t,n,a),It(t,e.x+i,e.y+s)}const{get:Vt,translate:Qt}=C,Zt=new p,$t={},Jt={};function Kt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=te(i,s,e)}function te(t,e,i){t.padding&&(e=Zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:h,size:d,rotation:c,skew:u,clipSize:f,repeat:g,gap:_,filters:p}=t,y=e.width===s&&e.height===n,w={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(Jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((h||d)&&(W.getScaleData(h,d,i,$t),x=$t.scaleX,v=$t.scaleY),(o||_||g)&&(x&&B.scale(Jt,x,v,!0),o&&O.toPoint(o,Jt,e,Jt,!0,!0))):y&&!c||(x=v=B.getFitScale(e,Jt,"fit"!==r),B.put(e,i,o,x,!1,Jt),B.scale(Jt,x,v,!0)),l&&P.move(Jt,l),r){case"stretch":y||(s=e.width,n=e.height);break;case"normal":case"clip":(Jt.x||Jt.y||x||f||c||u)&&qt(w,e,Jt.x,Jt.y,x,v,c,u,t.clipSize);break;case"repeat":(!y||x||c||u)&&Ht(w,e,s,n,Jt.x,Jt.y,x,v,c,u,o,t.freeTransform),g||(w.repeat="repeat");const i=E(g);(_||i)&&(w.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:ee(a,i,n.width,e&&e.x),y:ee(r,s,n.height,e&&e.y)}}(_,i&&g,Jt.width,Jt.height,e));break;default:x&&Nt(w,e,Jt.x,Jt.y,x,v,c)}return w.transform||(e.x||e.y)&&(w.transform=Vt(),Qt(w.transform,e.x,e.y)),x&&"stretch"!==r&&(w.scaleX=x,w.scaleY=v),w.width=s,w.height=n,a&&(w.opacity=a),p&&(w.filters=p),g&&(w.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function ee(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let ie,se=new p;const{isSame:ne}=B;function ae(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||Kt(n,s,i,a),!0}function re(t,e){he(t,M.LOAD,e)}function oe(t,e){he(t,M.LOADED,e)}function le(t,e,i){e.error=i,t.forceUpdate("surface"),he(t,M.ERROR,e)}function he(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ce,scale:ue,copy:fe}=C,{floor:ge,max:_e,abs:pe}=Math;function ye(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:t,data:o}=i;let l,h,{width:d,height:c,scaleX:u,scaleY:f,transform:g,repeat:_,gap:p}=o;n*=s,a*=s;const y=p&&p.x*n,w=p&&p.y*a;u&&(u=pe(u),f=pe(f),h=ce(),fe(h,g),ue(h,1/u,1/f),n*=u,a*=f),d*=n,c*=a;const m=d*c;if(!_&&m>e.image.maxCacheSize)return!1;let x=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;x>e&&(x=e)}if(m>x&&(l=Math.sqrt(m/x)),l&&(n/=l,a/=l,d/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=ce(),g&&fe(h,g)),ue(h,1/n,1/a)),h){const t=d+(y||0),e=c+(w||0);ue(h,t/_e(ge(t),1),e/_e(ge(e),1))}const v=t.getCanvas(d,c,o.opacity,o.filters,y,w),b=t.getPattern(v,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=b,i.patternId=r,!0}}function we(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const me={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return ie&&i===ie.paint&&ne(s,ie.boxBounds)?a=ie.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ie=o.use>1?{leafPaint:a,paint:i,boxBounds:se.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ae(t,e,i,o,a,s),n&&(re(t,r),oe(t,r))):o.error?n&&le(t,r,o.error):(n&&(de(t,!0),re(t,r)),a.loadId=o.load(()=>{de(t,!1),t.destroyed||(ae(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,r)),a.loadId=void 0},e=>{de(t,!1),le(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||q.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||q.running?ye(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>we(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ye(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ye,recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let s,n,a,r,o;for(let l=0,h=i.length;l<h;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],y(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Kt,getPatternData:te,fillOrFitMode:Nt,clipMode:qt,repeatMode:Ht},{toPoint:xe}=D,{hasTransparent:ve}=X,be={},ke={};function Be(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=X.string(n,s)):(r=n.offset,a=X.string(n.color,s)),e.addColorStop(r,a),!o&&ve(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Se,getDistance:Ee}=P,{get:Re,rotateOfOuter:Le,scaleOfOuter:Ae}=C,{toPoint:Te}=D,Ce={},We={};function Oe(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Se(e,i);a=Re(),n?(Ae(a,e,r/o*(s||1),1),Le(a,e,t+90)):(Ae(a,e,1,r/o*(s||1)),Le(a,e,t))}return a}const{getDistance:Pe}=P,{toPoint:Me}=D,De={},Fe={};const Ie={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;xe(s||"top",i,be),xe(n||"bottom",i,ke);const o=e.canvas.createLinearGradient(be.x,be.y,ke.x,ke.y),l={type:a,style:o};return Be(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Te(s||"center",i,Ce),Te(n||"bottom",i,We);const l=e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Ee(Ce,We)),h={type:a,style:l};Be(h,l,t.stops,r);const d=Oe(i,Ce,We,o,!0);return d&&(h.transform=d),h},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Me(s||"center",i,De),Me(n||"bottom",i,Fe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,De.x,De.y):e.canvas.createRadialGradient(De.x,De.y,0,De.x,De.y,Pe(De,Fe)),h={type:a,style:l};Be(h,l,t.stops,r);const d=Oe(i,De,Fe,o||1,e.conicGradientRotate90);return d&&(h.transform=d),h},getTransform:Oe},{copy:Ye,toOffsetOutBounds:ze}=B,Ue={},Ge={};function Xe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Ye(Ue,t.bounds),Ue.x+=i.x-r.x,Ue.y+=i.y-r.y,s){const{fitMatrix:t}=n;Ue.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ue.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ue.width*=s,Ue.height*=s}t.copyWorld(n.canvas,t.bounds,Ue)}else s&&(Ye(Ue,i),Ue.x-=i.width/2*(s-1),Ue.y-=i.height/2*(s-1),Ue.width*=s,Ue.height*=s),t.copyWorld(n.canvas,r,s?Ue:i)}const{toOffsetOutBounds:Ne}=B,qe={};const He={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),_=o.length-1;ze(h,Ge),o.forEach((o,p)=>{let y=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Ge.offsetX+o.x*c*y,Ge.offsetY+o.y*u*y,o.blur*c*y,X.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*y:0,Xe(g,Ge,n,i),s=h,o.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),f.copyCanvasByWorld(t,e,g,s,o.blendMode),_&&p<_&&g.clearWorld(s,!0)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),_=o.length-1;Ne(h,qe),o.forEach((o,p)=>{let y=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(qe.offsetX+o.x*c*y,qe.offsetY+o.y*u*y,o.blur*c*y),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*y:0,Xe(g,qe,n,i),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,d,h,"source-out"),s=h),g.fillWorld(s,X.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,o.blendMode),_&&p<_&&g.clearWorld(s,!0)}),g.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:je}=_;let Ve;function Qe(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Ve||(Ve=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);$e(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":$e(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ze(t){return t.getSameCanvas(!1,!0)}function $e(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r,!0)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let h=0,d=l.length;h<d;h++){if(i=l[h],o=i.__.mask,o){r&&(Qe(this,r,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Ve=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ze(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ze(t)),n||(n=Ze(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||je(i,e)||i.__render(t,e);continue}const d=1===a&&i.__.__blendMode;d&&Qe(this,r,t,n,s,a,void 0,!1),je(i,e)||i.__render(n||t,e),d&&Qe(this,r,t,n,s,a,d,!1)}Qe(this,r,t,n,s,a,void 0,!0)};const Je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ke=Je+"_#~&*+\\=|≮≯≈≠=…",ti=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 ei(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ii=ei("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),si=ei("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ni=ei(Je),ai=ei(Ke),ri=ei("- —/~|┆·");var oi;!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"}(oi||(oi={}));const{Letter:li,Single:hi,Before:di,After:ci,Symbol:ui,Break:fi}=oi;function gi(t){return ii[t]?li:ri[t]?fi:si[t]?di:ni[t]?ci:ai[t]?ui:ti.test(t)?hi:li}const _i={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 pi(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:yi}=_i,{Letter:wi,Single:mi,Before:xi,After:vi,Symbol:bi,Break:ki}=oi;let Bi,Si,Ei,Ri,Li,Ai,Ti,Ci,Wi,Oi,Pi,Mi,Di,Fi,Ii,Yi,zi,Ui=[];function Gi(t,e){Wi&&!Ci&&(Ci=Wi),Bi.data.push({char:t,width:e}),Ei+=e}function Xi(){Ri+=Ei,Bi.width=Ei,Si.words.push(Bi),Bi={data:[]},Ei=0}function Ni(){Fi&&(Ii.paraNumber++,Si.paraStart=!0,Fi=!1),Wi&&(Si.startCharSize=Ci,Si.endCharSize=Wi,Ci=0),Si.width=Ri,Yi.width?yi(Si):zi&&qi(),Ui.push(Si),Si={words:[]},Ri=0}function qi(){Ri>(Ii.maxWidth||0)&&(Ii.maxWidth=Ri)}const{top:Hi,right:ji,bottom:Vi,left:Qi}=F;function Zi(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 $i={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:h}=i;h&&(a?(s=h[Qi],a-=h[ji]+h[Qi]):i.autoSizeAlign||(s=h[Qi]),r?(n=h[Hi],r-=h[Hi]+h[Vi]):i.autoSizeAlign||(n=h[Hi]));const d={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Ii=t,Ui=t.rows,Yi=t.bounds,zi=!Yi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:h}=Yi;if(l||h||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Fi=!0,Pi=null,Ci=Ti=Wi=Ei=Ri=0,Bi={data:[]},Si={words:[]},n&&(i=[...i]);for(let s=0,h=i.length;s<h;s++)Ai=i[s],"\n"===Ai?(Ei&&Xi(),Si.paraEnd=!0,Ni(),Fi=!0):(Oi=gi(Ai),Oi===wi&&"none"!==r&&(Ai=pi(Ai,r,!Ei)),Ti=o.measureText(Ai).width,n&&(n<0&&(Wi=Ti),Ti+=n),Mi=Oi===mi&&(Pi===mi||Pi===wi)||Pi===mi&&Oi!==vi,Di=!(Oi!==xi&&Oi!==mi||Pi!==bi&&Pi!==vi),Li=Fi&&a?l-a:l,t&&l&&Ri+Ei+Ti>Li&&(e?(Ei&&Xi(),Ri&&Ni()):(Di||(Di=Oi===wi&&Pi==vi),Mi||Di||Oi===ki||Oi===xi||Oi===mi||Ei+Ti>Li?(Ei&&Xi(),Ri&&Ni()):Ri&&Ni()))," "===Ai&&!0!==Fi&&Ri+Ei===0||(Oi===ki?(" "===Ai&&Ei&&Xi(),Gi(Ai,Ti),Xi()):Mi||Di?(Ei&&Xi(),Gi(Ai,Ti)):Gi(Ai,Ti)),Pi=Oi);Ei&&Xi(),Ri&&Ni(),Ui.length>0&&(Ui[Ui.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ii.paraNumber++,Ri=o.measureText(t).width,Ui.push({x:a||0,text:t,width:Ri,paraStart:!0}),zi&&qi()})}(d,t,i),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Zi(e,"x",t[Qi]);break;case"right":Zi(e,"x",-t[ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Zi(e,"y",t[Hi]);break;case"bottom":Zi(e,"y",-t[Vi])}}(h,d,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:h,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:_,height:p}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=r;if(l&&y>p)y=Math.max(p,a),n>1&&(t.overflow=n);else if(p||u)switch(d){case"middle":g+=(p-y)/2;break;case"bottom":g+=p-y}w+=g;let m,x,v,b=_||u?_:t.maxWidth;for(let r=0,d=n;r<d;r++){if(m=i[r],m.x=f,m.width<_||m.width>_&&!l)switch(h){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(w+=c),m.y=w,w+=a,t.overflow>r&&w>y&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&_&&_<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(d,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,h,d,c,u;s.forEach(t=>{t.words&&(h=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-h)/(u-1):0,d=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=h,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=h,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(d,i,a),d.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?e.canvas.measureText(o).width:0,d=s+n-h;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,i,s,a),"none"!==o&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,E(n)?(i=n.type,n.color&&(t.decorationColor=X.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,i),d}};const Ji={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!X.object)return t;t=X.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(j,$i),Object.assign(X,Ji),Object.assign(G,Ot),Object.assign(U,me),Object.assign(N,Ie),Object.assign(V,He),Object.assign(n,{interaction:(t,e,i,s)=>new z(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new Y}),$();export{dt as Layouter,Q as LeaferCanvas,gt as Picker,ut as Renderer,_t as Selector,K as Watcher,$ as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as h,ChildEvent as d,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,Matrix as R,isUndefined as L,isString as A,getMatrixData as T,MatrixHelper as C,MathHelper as W,AlignHelper as O,PointHelper as P,ImageEvent as M,AroundHelper as D,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as Y,InteractionBase as z}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as U,Paint as G,ColorConvert as X,PaintGradient as N,Export as q,Group as H,TextConvert as j,Effect as V}from"@leafer-ui/draw";class Q 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:Z}=s;function $(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Z(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:Z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(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=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),J.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):J.indexOf("Mac")>-1?e.os="Mac":J.indexOf("Linux")>-1&&(e.os="Linux");class K{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=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===d.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 o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[d.ADD,d.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=f,{pushAllChildBranch:st,pushAllParent:nt}=g;const{worldBounds:at}=p;class rt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,y(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),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:lt}=f,ht=w.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.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:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,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?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(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||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),dt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(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(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=w.get("Renderer");class ut{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=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(h.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(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=new _(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}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=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__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.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new h(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[h.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[h.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}ut.clipSpread=10;const{hitRadiusPoint:ft}=B;class gt{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 o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);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,r=i.length;t<r;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||ft(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&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){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class pt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new gt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function _t(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?_t(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function wt(t,e,i){switch(e.__.strokeAlign){case"center":mt(t,1,e,i);break;case"inside":xt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?mt(t,2,e,i):xt(t,"outside",e,i)}}function mt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),vt(i,s))}function xt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,mt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",_t(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function vt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function bt(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,h=t.length;l<h;l++)if(a=t[l],(!a.image||!U.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?vt(s,n):n.stroke(),n.restoreBlendMode()):i?vt(s,n):n.stroke()}}function kt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)wt(t,e,i);else switch(s.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Bt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Bt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Bt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Bt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&G.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new pt(t,e)}),e.layout=dt.fullLayout;const{getSpread:St,getOuterOf:Et,getByMove:Rt,getIntersectData:Lt}=B;let At;const{stintSet:Tt}=l,{hasTransparent:Ct}=X;function Wt(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,n,!At||!At[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:X.string(r,o)};break;default:L(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(A(s.style)&&Ct(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Ot={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];y(o)||(o=[o]),At=U.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Wt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:_t,stroke:kt,strokes:function(t,e,i){kt(t,e,i)},strokeText:wt,drawTextStroke:vt,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,r=i.bounds;let o,l,h,d,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(a))c=n,o=d=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(e.fullImageShadow)g=a;else{const t=n?St(r,u===f?n*u:[n*f,n*u]):r;g=Lt(t,a)}h=r.getFitMatrix(g);let{a:p,d:_}=h;h.a<1&&(c=i.getSameCanvas(),t.__renderShape(c,s),u*=p,f*=_),d=Et(a,h),o=Rt(d,-h.e,-h.f);const y=s.matrix;y?(l=new R(h),l.multiply(y),p*=y.scaleX,_*=y.scaleY):l=h,l.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:h,bounds:o,worldCanvas:c,shapeBounds:d,scaleX:u,scaleY:f}}};let Pt={},Mt=T();const{get:Dt,rotateOfOuter:Ft,translate:It,scaleOfOuter:Yt,multiplyParent:zt,scale:Ut,rotate:Gt,skew:Xt}=C;function Nt(t,e,i,s,n,a,r){const o=Dt();It(o,e.x+i,e.y+s),Ut(o,n,a),r&&Ft(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function qt(t,e,i,s,n,a,r,o,l){const h=Dt();jt(h,e,i,s,n,a,r,o),l&&(Mt.a=e.width/l.width,Mt.d=e.height/l.height,zt(h,Mt)),t.transform=h}function Ht(t,e,i,s,n,a,r,o,l,h,d,c){const u=Dt();if(c)jt(u,e,n,a,r,o,l,h);else{if(l)if("center"===d)Ft(u,{x:i/2,y:s/2},l);else switch(Gt(u,l),l){case 90:It(u,s,0);break;case 180:It(u,i,s);break;case 270:It(u,0,i)}Pt.x=e.x+n,Pt.y=e.y+a,It(u,Pt.x,Pt.y),r&&Yt(u,Pt,r,o)}t.transform=u}function jt(t,e,i,s,n,a,r,o){r&&Gt(t,r),o&&Xt(t,o.x,o.y),n&&Ut(t,n,a),It(t,e.x+i,e.y+s)}const{get:Vt,translate:Qt}=C,Zt=new _,$t={},Jt={};function Kt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=te(i,s,e)}function te(t,e,i){t.padding&&(e=Zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:h,size:d,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,y=e.width===s&&e.height===n,w={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(Jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((h||d)&&(W.getScaleData(h,d,i,$t),x=$t.scaleX,v=$t.scaleY),(o||p||g)&&(x&&B.scale(Jt,x,v,!0),o&&O.toPoint(o,Jt,e,Jt,!0,!0))):y&&!c||(x=v=B.getFitScale(e,Jt,"fit"!==r),B.put(e,i,o,x,!1,Jt),B.scale(Jt,x,v,!0)),l&&P.move(Jt,l),r){case"stretch":y||(s=e.width,n=e.height);break;case"normal":case"clip":(Jt.x||Jt.y||x||f||c||u)&&qt(w,e,Jt.x,Jt.y,x,v,c,u,t.clipSize);break;case"repeat":(!y||x||c||u)&&Ht(w,e,s,n,Jt.x,Jt.y,x,v,c,u,o,t.freeTransform),g||(w.repeat="repeat");const i=E(g);(p||i)&&(w.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:ee(a,i,n.width,e&&e.x),y:ee(r,s,n.height,e&&e.y)}}(p,i&&g,Jt.width,Jt.height,e));break;default:x&&Nt(w,e,Jt.x,Jt.y,x,v,c)}return w.transform||(e.x||e.y)&&(w.transform=Vt(),Qt(w.transform,e.x,e.y)),x&&"stretch"!==r&&(w.scaleX=x,w.scaleY=v),w.width=s,w.height=n,a&&(w.opacity=a),_&&(w.filters=_),g&&(w.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function ee(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let ie,se=new _;const{isSame:ne}=B;function ae(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||Kt(n,s,i,a),!0}function re(t,e){he(t,M.LOAD,e)}function oe(t,e){he(t,M.LOADED,e)}function le(t,e,i){e.error=i,t.forceUpdate("surface"),he(t,M.ERROR,e)}function he(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ce,scale:ue,copy:fe}=C,{floor:ge,max:pe,abs:_e}=Math;function ye(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:t,data:o}=i;let l,h,{width:d,height:c,scaleX:u,scaleY:f,transform:g,repeat:p,gap:_}=o;n*=s,a*=s;const y=_&&_.x*n,w=_&&_.y*a;u&&(u=_e(u),f=_e(f),h=ce(),fe(h,g),ue(h,1/u,1/f),n*=u,a*=f),d*=n,c*=a;const m=d*c;if(!p&&m>e.image.maxCacheSize)return!1;let x=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;x>e&&(x=e)}if(m>x&&(l=Math.sqrt(m/x)),l&&(n/=l,a/=l,d/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=ce(),g&&fe(h,g)),ue(h,1/n,1/a)),h){const t=d+(y||0),e=c+(w||0);ue(h,t/pe(ge(t),1),e/pe(ge(e),1))}const v=t.getCanvas(d,c,o.opacity,o.filters,y,w),b=t.getPattern(v,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=b,i.patternId=r,!0}}function we(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const me={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return ie&&i===ie.paint&&ne(s,ie.boxBounds)?a=ie.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ie=o.use>1?{leafPaint:a,paint:i,boxBounds:se.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ae(t,e,i,o,a,s),n&&(re(t,r),oe(t,r))):o.error?n&&le(t,r,o.error):(n&&(de(t,!0),re(t,r)),a.loadId=o.load(()=>{de(t,!1),t.destroyed||(ae(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,r)),a.loadId=void 0},e=>{de(t,!1),le(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||q.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||q.running?ye(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>we(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ye(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ye,recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let s,n,a,r,o;for(let l=0,h=i.length;l<h;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],y(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Kt,getPatternData:te,fillOrFitMode:Nt,clipMode:qt,repeatMode:Ht},{toPoint:xe}=D,{hasTransparent:ve}=X,be={},ke={};function Be(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=X.string(n,s)):(r=n.offset,a=X.string(n.color,s)),e.addColorStop(r,a),!o&&ve(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Se,getDistance:Ee}=P,{get:Re,rotateOfOuter:Le,scaleOfOuter:Ae}=C,{toPoint:Te}=D,Ce={},We={};function Oe(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Se(e,i);a=Re(),n?(Ae(a,e,r/o*(s||1),1),Le(a,e,t+90)):(Ae(a,e,1,r/o*(s||1)),Le(a,e,t))}return a}const{getDistance:Pe}=P,{toPoint:Me}=D,De={},Fe={};const Ie={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;xe(s||"top",i,be),xe(n||"bottom",i,ke);const o=e.canvas.createLinearGradient(be.x,be.y,ke.x,ke.y),l={type:a,style:o};return Be(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Te(s||"center",i,Ce),Te(n||"bottom",i,We);const l=e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Ee(Ce,We)),h={type:a,style:l};Be(h,l,t.stops,r);const d=Oe(i,Ce,We,o,!0);return d&&(h.transform=d),h},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Me(s||"center",i,De),Me(n||"bottom",i,Fe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,De.x,De.y):e.canvas.createRadialGradient(De.x,De.y,0,De.x,De.y,Pe(De,Fe)),h={type:a,style:l};Be(h,l,t.stops,r);const d=Oe(i,De,Fe,o||1,e.conicGradientRotate90);return d&&(h.transform=d),h},getTransform:Oe},{copy:Ye,toOffsetOutBounds:ze}=B,Ue={},Ge={};function Xe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Ye(Ue,t.bounds),Ue.x+=i.x-r.x,Ue.y+=i.y-r.y,s){const{fitMatrix:t}=n;Ue.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ue.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ue.width*=s,Ue.height*=s}t.copyWorld(n.canvas,t.bounds,Ue)}else s&&(Ye(Ue,i),Ue.x-=i.width/2*(s-1),Ue.y-=i.height/2*(s-1),Ue.width*=s,Ue.height*=s),t.copyWorld(n.canvas,r,s?Ue:i)}const{toOffsetOutBounds:Ne}=B,qe={};const He={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;ze(h,Ge),o.forEach((o,_)=>{let y=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Ge.offsetX+o.x*c*y,Ge.offsetY+o.y*u*y,o.blur*c*y,X.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*y:0,Xe(g,Ge,n,i),s=h,o.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),f.copyCanvasByWorld(t,e,g,s,o.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;Ne(h,qe),o.forEach((o,_)=>{let y=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(qe.offsetX+o.x*c*y,qe.offsetY+o.y*u*y,o.blur*c*y),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*y:0,Xe(g,qe,n,i),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,d,h,"source-out"),s=h),g.fillWorld(s,X.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,o.blendMode),p&&_<p&&g.clearWorld(s)}),g.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:je}=p;let Ve;function Qe(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Ve||(Ve=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);$e(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":$e(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ze(t){return t.getSameCanvas(!1,!0)}function $e(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let h=0,d=l.length;h<d;h++){if(i=l[h],o=i.__.mask,o){r&&(Qe(this,r,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Ve=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ze(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ze(t)),n||(n=Ze(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||je(i,e)||i.__render(t,e);continue}const d=1===a&&i.__.__blendMode;d&&Qe(this,r,t,n,s,a,void 0,!1),je(i,e)||i.__render(n||t,e),d&&Qe(this,r,t,n,s,a,d,!1)}Qe(this,r,t,n,s,a,void 0,!0)};const Je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ke=Je+"_#~&*+\\=|≮≯≈≠=…",ti=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 ei(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ii=ei("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),si=ei("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ni=ei(Je),ai=ei(Ke),ri=ei("- —/~|┆·");var oi;!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"}(oi||(oi={}));const{Letter:li,Single:hi,Before:di,After:ci,Symbol:ui,Break:fi}=oi;function gi(t){return ii[t]?li:ri[t]?fi:si[t]?di:ni[t]?ci:ai[t]?ui:ti.test(t)?hi:li}const pi={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 _i(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:yi}=pi,{Letter:wi,Single:mi,Before:xi,After:vi,Symbol:bi,Break:ki}=oi;let Bi,Si,Ei,Ri,Li,Ai,Ti,Ci,Wi,Oi,Pi,Mi,Di,Fi,Ii,Yi,zi,Ui=[];function Gi(t,e){Wi&&!Ci&&(Ci=Wi),Bi.data.push({char:t,width:e}),Ei+=e}function Xi(){Ri+=Ei,Bi.width=Ei,Si.words.push(Bi),Bi={data:[]},Ei=0}function Ni(){Fi&&(Ii.paraNumber++,Si.paraStart=!0,Fi=!1),Wi&&(Si.startCharSize=Ci,Si.endCharSize=Wi,Ci=0),Si.width=Ri,Yi.width?yi(Si):zi&&qi(),Ui.push(Si),Si={words:[]},Ri=0}function qi(){Ri>(Ii.maxWidth||0)&&(Ii.maxWidth=Ri)}const{top:Hi,right:ji,bottom:Vi,left:Qi}=F;function Zi(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 $i={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:h}=i;h&&(a?(s=h[Qi],a-=h[ji]+h[Qi]):i.autoSizeAlign||(s=h[Qi]),r?(n=h[Hi],r-=h[Hi]+h[Vi]):i.autoSizeAlign||(n=h[Hi]));const d={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Ii=t,Ui=t.rows,Yi=t.bounds,zi=!Yi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:h}=Yi;if(l||h||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Fi=!0,Pi=null,Ci=Ti=Wi=Ei=Ri=0,Bi={data:[]},Si={words:[]},n&&(i=[...i]);for(let s=0,h=i.length;s<h;s++)Ai=i[s],"\n"===Ai?(Ei&&Xi(),Si.paraEnd=!0,Ni(),Fi=!0):(Oi=gi(Ai),Oi===wi&&"none"!==r&&(Ai=_i(Ai,r,!Ei)),Ti=o.measureText(Ai).width,n&&(n<0&&(Wi=Ti),Ti+=n),Mi=Oi===mi&&(Pi===mi||Pi===wi)||Pi===mi&&Oi!==vi,Di=!(Oi!==xi&&Oi!==mi||Pi!==bi&&Pi!==vi),Li=Fi&&a?l-a:l,t&&l&&Ri+Ei+Ti>Li&&(e?(Ei&&Xi(),Ri&&Ni()):(Di||(Di=Oi===wi&&Pi==vi),Mi||Di||Oi===ki||Oi===xi||Oi===mi||Ei+Ti>Li?(Ei&&Xi(),Ri&&Ni()):Ri&&Ni()))," "===Ai&&!0!==Fi&&Ri+Ei===0||(Oi===ki?(" "===Ai&&Ei&&Xi(),Gi(Ai,Ti),Xi()):Mi||Di?(Ei&&Xi(),Gi(Ai,Ti)):Gi(Ai,Ti)),Pi=Oi);Ei&&Xi(),Ri&&Ni(),Ui.length>0&&(Ui[Ui.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ii.paraNumber++,Ri=o.measureText(t).width,Ui.push({x:a||0,text:t,width:Ri,paraStart:!0}),zi&&qi()})}(d,t,i),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Zi(e,"x",t[Qi]);break;case"right":Zi(e,"x",-t[ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Zi(e,"y",t[Hi]);break;case"bottom":Zi(e,"y",-t[Vi])}}(h,d,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:h,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=r;if(l&&y>_)y=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,d=n;r<d;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(h){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(w+=c),m.y=w,w+=a,t.overflow>r&&w>y&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(d,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,h,d,c,u;s.forEach(t=>{t.words&&(h=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-h)/(u-1):0,d=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=h,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=h,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(d,i,a),d.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?e.canvas.measureText(o).width:0,d=s+n-h;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,i,s,a),"none"!==o&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,E(n)?(i=n.type,n.color&&(t.decorationColor=X.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,i),d}};const Ji={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!X.object)return t;t=X.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(j,$i),Object.assign(X,Ji),Object.assign(G,Ot),Object.assign(U,me),Object.assign(N,Ie),Object.assign(V,He),Object.assign(n,{interaction:(t,e,i,s)=>new z(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new Y}),$();export{dt as Layouter,Q as LeaferCanvas,gt as Picker,ut as Renderer,pt as Selector,K as Watcher,$ as useCanvas};
|
|
2
2
|
//# sourceMappingURL=worker.esm.min.js.map
|