leafer-ui 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/web.cjs +11 -7
- package/dist/web.esm.js +11 -7
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +14 -10
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +14 -10
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<img width="98" titel="gitee" src="https://www.leaferjs.com/svg/gitee-stars.svg" />
|
|
20
20
|
</a>
|
|
21
21
|
<a target="_blank" href="https://github.com/leaferjs/leafer-ui" aria-label="github" rel="noopener">
|
|
22
|
-
<img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=
|
|
22
|
+
<img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=0801" />
|
|
23
23
|
</a>
|
|
24
24
|
</div>
|
|
25
25
|
|
package/dist/web.cjs
CHANGED
|
@@ -1538,18 +1538,22 @@ const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIn
|
|
|
1538
1538
|
|
|
1539
1539
|
function shape(ui, current, options) {
|
|
1540
1540
|
const canvas = current.getSameCanvas();
|
|
1541
|
-
const nowWorld = ui.__nowWorld;
|
|
1541
|
+
const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
|
|
1542
1542
|
let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1543
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
1544
|
-
if (
|
|
1545
|
-
if (scaleY < 0) scaleY = -scaleY;
|
|
1546
|
-
if (current.bounds.includes(nowWorld)) {
|
|
1543
|
+
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1544
|
+
if (currentBounds.includes(nowWorld)) {
|
|
1547
1545
|
worldCanvas = canvas;
|
|
1548
1546
|
bounds = shapeBounds = nowWorld;
|
|
1549
1547
|
} else {
|
|
1550
1548
|
const {renderShapeSpread: spread} = ui.__layout;
|
|
1551
|
-
|
|
1552
|
-
|
|
1549
|
+
let worldClipBounds;
|
|
1550
|
+
if (core.Platform.fullImageShadow) {
|
|
1551
|
+
worldClipBounds = nowWorld;
|
|
1552
|
+
} else {
|
|
1553
|
+
const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
|
|
1554
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorld);
|
|
1555
|
+
}
|
|
1556
|
+
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1553
1557
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
1554
1558
|
if (fitMatrix.a < 1) {
|
|
1555
1559
|
worldCanvas = current.getSameCanvas();
|
package/dist/web.esm.js
CHANGED
|
@@ -1542,18 +1542,22 @@ const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIn
|
|
|
1542
1542
|
|
|
1543
1543
|
function shape(ui, current, options) {
|
|
1544
1544
|
const canvas = current.getSameCanvas();
|
|
1545
|
-
const nowWorld = ui.__nowWorld;
|
|
1545
|
+
const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
|
|
1546
1546
|
let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1547
|
-
let {scaleX: scaleX, scaleY: scaleY} =
|
|
1548
|
-
if (
|
|
1549
|
-
if (scaleY < 0) scaleY = -scaleY;
|
|
1550
|
-
if (current.bounds.includes(nowWorld)) {
|
|
1547
|
+
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1548
|
+
if (currentBounds.includes(nowWorld)) {
|
|
1551
1549
|
worldCanvas = canvas;
|
|
1552
1550
|
bounds = shapeBounds = nowWorld;
|
|
1553
1551
|
} else {
|
|
1554
1552
|
const {renderShapeSpread: spread} = ui.__layout;
|
|
1555
|
-
|
|
1556
|
-
|
|
1553
|
+
let worldClipBounds;
|
|
1554
|
+
if (Platform.fullImageShadow) {
|
|
1555
|
+
worldClipBounds = nowWorld;
|
|
1556
|
+
} else {
|
|
1557
|
+
const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
|
|
1558
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorld);
|
|
1559
|
+
}
|
|
1560
|
+
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1557
1561
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
1558
1562
|
if (fitMatrix.a < 1) {
|
|
1559
1563
|
worldCanvas = current.getSameCanvas();
|
package/dist/web.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,DataHelper as n,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as v,BranchHelper as y,LeafBoundsHelper as m,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as k,Run as E,ImageManager as L,BoundsHelper as T,Plugin as S,MathHelper as R,isObject as P,Matrix as M,getMatrixData as C,MatrixHelper as A,AlignHelper as D,PointHelper as O,ImageEvent as W,AroundHelper as I,Direction4 as z,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as j,Cursor as G,HitCanvasManager as Y}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as X,Paint as V,ColorConvert as N,PaintGradient as H,Export as q,Group as K,TextConvert as Q,Effect as $}from"@leafer-ui/draw";const Z=t.get("LeaferCanvas");class J extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else Z.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),Z.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};n.copyAttrs(e,this,o),this.resize(t),this.resizeListener&&!r(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:tt,fileType:et}=l;function it(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=tt(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,tt(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(tt(et(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new J(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:st}=navigator;st.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),st.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):st.indexOf("Mac")>-1?i.os="Mac":st.indexOf("Linux")>-1&&(i.os="Linux");class nt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=n.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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:ot,updateBounds:rt,updateChange:at}=v,{pushAllChildBranch:ht,pushAllParent:lt}=y;const{worldBounds:ct}=m;class dt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ut,updateAllChange:ft}=v,pt=t.get("Layouter");class gt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=n.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(k.START),this.layoutOnce(),t.emitEvent(new k(k.END,this.layoutedBlocks,this.times))}catch(t){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=E.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=k,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new k(n,a,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?(ot(t,!0),e.add(t),t.isBranch&&ht(t,e),lt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lt(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||rt(s[t])}rt(i)}})}(this.__levelList),function(t){t.list.forEach(at)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new k(o,a,this.times)),i.emitEvent(new k(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,E.end(e)}fullLayout(){const t=E.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=k,o=this.getBlocks(new f(e));e.emitEvent(new k(i,o,this.times)),gt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new k(s,o,this.times)),e.emitEvent(new k(n,o,this.times)),this.addBlocks(o),E.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?y.updateBounds(t):v.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new dt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new dt(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_([[k.REQUEST,this.layout,this],[k.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=t.get("Renderer");class wt{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=n.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(k.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,_t.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),L.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=E.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(wt.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),E.end(e)}fullRender(){const t=E.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),E.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;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 e=this.requestTime=Date.now();i.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),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 x(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 x(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||_t.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 p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[k.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}wt.clipSpread=10;const{hitRadiusPoint:vt}=T;class yt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||v.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&v.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=>v.worldHittable(t))}getPath(t){const e=new f;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 f;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 f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||vt(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:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[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 mt{constructor(t,e){this.config={},e&&(this.config=n.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,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()}}Object.assign(c,{watcher:(t,e)=>new nt(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>new mt(t,e)}),i.layout=gt.fullLayout;const xt={convert(t,e){const i=U.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=U.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=xt.getTouch(t),s=U.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},bt={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Bt}=U;class kt extends j{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(bt.convert(t))}onKeyUp(t){this.keyUp(bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(xt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(xt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=xt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(xt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(xt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(xt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(xt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=xt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Bt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(xt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=xt.getTouch(t);this.pointerMove(xt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=xt.getTouch(t);this.pointerUp(xt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(U.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&G.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Et(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function Lt(t,e){t.__.__font?Et(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i){switch(e.__.strokeAlign){case"center":St(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?St(t,2,e,i):Rt(t,"outside",e,i)}}function St(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Pt(i,s))}function Rt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,St(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Et(i,n),n.blendMode="normal",v.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Pt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=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(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Mt(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!X.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Pt(s,n):n.stroke(),n.restoreBlendMode()):i?Pt(s,n):n.stroke()}}function Ct(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Tt(t,e,i);else switch(s.strokeAlign){case"center":At(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),At(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)At(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),At(t,2,e,o),o.clipUI(s),o.clearWorld(n),v.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function At(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&V.strokeArrow(t,i,s)}const{getSpread:Dt,getOuterOf:Ot,getByMove:Wt,getIntersectData:It}=T;let zt;const{stintSet:Ft}=n,{hasTransparent:Ut}=N;function jt(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout;switch(e.type){case"image":n=X.image(i,t,e,o,!zt||!zt[e.url]);break;case"linear":n=H.linearGradient(e,o);break;case"radial":n=H.radialGradient(e,o);break;case"angular":n=H.conicGradient(e,o);break;case"solid":const{type:s,color:a,opacity:h}=e;n={type:s,style:N.string(a,h)};break;default:r(e.r)||(n={type:"solid",style:N.string(e)})}if(n){if(s(n.style)&&Ut(n.style)&&(n.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}e.editing&&(n.editing=e.editing),e.blendMode&&(n.blendMode=e.blendMode)}return n}const Gt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),zt=X.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=jt(t,a[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),o=!0),"fill"===t?(Ft(i,"__isAlphaPixelFill",n),Ft(i,"__isTransparentFill",o)):(Ft(i,"__isAlphaPixelStroke",n),Ft(i,"__isTransparentStroke",o),Ft(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Lt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(X.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),Lt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Lt(e,i),i.restoreBlendMode()):Lt(e,i)}},fillPathOrText:Lt,fillText:Et,stroke:Ct,strokes:function(t,e,i){Ct(t,e,i)},strokeText:Tt,drawTextStroke:Pt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,l,{scaleX:c,scaleY:d}=n;if(c<0&&(c=-c),d<0&&(d=-d),e.bounds.includes(n))l=s,o=h=n;else{const{renderShapeSpread:s}=t.__layout,u=It(s?Dt(e.bounds,c===d?s*c:[s*d,s*c]):e.bounds,n);a=e.bounds.getFitMatrix(u);let{a:f,d:p}=a;a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),c*=f,d*=p),h=Ot(n,a),o=Wt(h,-a.e,-a.f);const g=i.matrix;g?(r=new M(a),r.multiply(g),f*=g.scaleX,p*=g.scaleY):r=a,r.withScale(f,p),i=Object.assign(Object.assign({},i),{matrix:r})}return t.__renderShape(s,i),{canvas:s,matrix:r,fitMatrix:a,bounds:o,worldCanvas:l,shapeBounds:h,scaleX:c,scaleY:d}}};let Yt={},Xt=C();const{get:Vt,rotateOfOuter:Nt,translate:Ht,scaleOfOuter:qt,multiplyParent:Kt,scale:Qt,rotate:$t,skew:Zt}=A;function Jt(t,e,i,s,n,o,r){const a=Vt();Ht(a,e.x+i,e.y+s),Qt(a,n,o),r&&Nt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function te(t,e,i,s,n,o,r,a,h){const l=Vt();ie(l,e,i,s,n,o,r,a),h&&(Xt.a=e.width/h.width,Xt.d=e.height/h.height,Kt(l,Xt)),t.transform=l}function ee(t,e,i,s,n,o,r,a,h,l,c,d){const u=Vt();if(d)ie(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)Nt(u,{x:i/2,y:s/2},h);else switch($t(u,h),h){case 90:Ht(u,s,0);break;case 180:Ht(u,i,s);break;case 270:Ht(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+o,Ht(u,Yt.x,Yt.y),r&&qt(u,Yt,r,a)}t.transform=u}function ie(t,e,i,s,n,o,r,a){r&&$t(t,r),a&&Zt(t,a.x,a.y),n&&Qt(t,n,o),Ht(t,e.x+i,e.y+s)}const{get:se,translate:ne}=A,oe=new x,re={},ae={};function he(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=le(i,s,e)}function le(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,v=e.width===n&&e.height===o,y={mode:a},m="center"!==h&&(u||0)%180==90;let x,b;switch(T.set(ae,0,0,m?o:n,m?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,re),x=re.scaleX,b=re.scaleY),(h||_||g)&&(x&&T.scale(ae,x,b,!0),h&&D.toPoint(h,ae,e,ae,!0,!0))):v&&!u||(x=b=T.getFitScale(e,ae,"fit"!==a),T.put(e,i,h,x,!1,ae),T.scale(ae,x,b,!0)),l&&O.move(ae,l),a){case"stretch":v||(n=e.width,o=e.height);break;case"normal":case"clip":(ae.x||ae.y||x||p||u||f)&&te(y,e,ae.x,ae.y,x,b,u,f,t.clipSize);break;case"repeat":(!v||x||u||f)&&ee(y,e,n,o,ae.x,ae.y,x,b,u,f,h,t.freeTransform),g||(y.repeat="repeat");const i=P(g);(_||i)&&(y.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:ce(o,i,n.width,e&&e.x),y:ce(r,s,n.height,e&&e.y)}}(_,i&&g,ae.width,ae.height,e));break;default:x&&Jt(y,e,ae.x,ae.y,x,b,u)}return y.transform||(e.x||e.y)&&(y.transform=se(),ne(y.transform,e.x,e.y)),x&&"stretch"!==a&&(y.scaleX=x,y.scaleY=b),y.width=n,y.height=o,r&&(y.opacity=r),w&&(y.filters=w),g&&(y.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ce(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let de,ue=new x;const{isSame:fe}=T;function pe(t,e,i,s,n,o){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||he(n,s,i,o),!0}function ge(t,e){ve(t,W.LOAD,e)}function _e(t,e){ve(t,W.LOADED,e)}function we(t,e,i){e.error=i,t.forceUpdate("surface"),ve(t,W.ERROR,e)}function ve(t,e,i){t.hasEvent(e)&&t.emitEvent(new W(e,i))}function ye(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:me,scale:xe,copy:be}=A,{floor:Be,max:ke,abs:Ee}=Math;function Le(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=a;n*=s,o*=s;const w=_&&_.x*n,v=_&&_.y*o;u&&(u=Ee(u),f=Ee(f),l=me(),be(l,p),xe(l,1/u,1/f),n*=u,o*=f),c*=n,d*=o;const y=c*d;if(!g&&y>i.image.maxCacheSize)return!1;let m=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}if(y>m&&(h=Math.sqrt(y/m)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=me(),p&&be(l,p)),xe(l,1/n,1/o)),l){const t=c+(w||0),e=d+(v||0);xe(l,t/ke(Be(t),1),e/ke(Be(e),1))}const x=t.getCanvas(c,d,a.opacity,a.filters,w,v),b=t.getPattern(x,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=b,e.patternId=r,!0}}function Te(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let o,r;const a=L.get(i);return de&&i===de.paint&&fe(s,de.boxBounds)?o=de.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),de=a.use>1?{leafPaint:o,paint:i,boxBounds:ue.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(pe(t,e,i,a,o,s),n&&(ge(t,r),_e(t,r))):a.error?n&&we(t,r,a.error):(n&&(ye(t,!0),ge(t,r)),o.loadId=a.load(()=>{ye(t,!1),t.destroyed||(pe(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),_e(t,r)),o.loadId=void 0},e=>{ye(t,!1),we(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||q.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.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,e,s,l),!0):(!s.style||s.sync||q.running?Le(t,s,h):s.patternTask||(s.patternTask=L.patternTasker.add(()=>Te(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Le(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Le,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,L.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:he,getPatternData:le,fillOrFitMode:Jt,clipMode:te,repeatMode:ee},{toPoint:Re}=I,{hasTransparent:Pe}=N,Me={},Ce={};function Ae(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&Pe(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Oe}=O,{get:We,rotateOfOuter:Ie,scaleOfOuter:ze}=A,{toPoint:Fe}=I,Ue={},je={};function Ge(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=De(e,i);o=We(),n?(ze(o,e,r/a*(s||1),1),Ie(o,e,t+90)):(ze(o,e,1,r/a*(s||1)),Ie(o,e,t))}return o}const{getDistance:Ye}=O,{toPoint:Xe}=I,Ve={},Ne={};const He={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Re(s||"top",e,Me),Re(n||"bottom",e,Ce);const a=i.canvas.createLinearGradient(Me.x,Me.y,Ce.x,Ce.y),h={type:o,style:a};return Ae(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Fe(s||"center",e,Ue),Fe(n||"bottom",e,je);const h=i.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Oe(Ue,je)),l={type:o,style:h};Ae(l,h,t.stops,r);const c=Ge(e,Ue,je,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Xe(s||"center",e,Ve),Xe(n||"bottom",e,Ne);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Ve.x,Ve.y):i.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ye(Ve,Ne)),l={type:o,style:h};Ae(l,h,t.stops,r);const c=Ge(e,Ve,Ne,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Ge},{copy:qe,toOffsetOutBounds:Ke}=T,Qe={},$e={};function Ze(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(qe(Qe,t.bounds),Qe.x+=e.x-r.x,Qe.y+=e.y-r.y,s){const{fitMatrix:t}=n;Qe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Qe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Qe.width*=s,Qe.height*=s}t.copyWorld(n.canvas,t.bounds,Qe)}else s&&(qe(Qe,e),Qe.x-=e.width/2*(s-1),Qe.y-=e.height/2*(s-1),Qe.width*=s,Qe.height*=s),t.copyWorld(n.canvas,r,s?Qe:e)}const{toOffsetOutBounds:Je}=T,ti={};const ei={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;Ke(l,$e),a.forEach((a,g)=>{let _=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.setWorldShadow($e.offsetX+a.x*d*_,$e.offsetY+a.y*u*_,a.blur*d*_,N.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*_:0,Ze(f,$e,n,i),s=l,a.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s,!0)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;Je(l,ti),a.forEach((a,g)=>{let _=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(ti.offsetX+a.x*d*_,ti.offsetY+a.y*u*_,a.blur*d*_),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*_:0,Ze(f,ti,n,i),f.restore(),h?(f.copyWorld(f,l,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,N.string(a.color),"source-in"),v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s,!0)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ii}=m;let si;function ni(t,e,i,s,n,o,r,a){switch(e){case"grayscale":si||(si=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);ri(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ri(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r,!0)}K.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(ni(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,si=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||ii(i,e)||i.__render(t,e);continue}const c=1===o&&i.__.__blendMode;c&&ni(this,r,t,n,s,o,void 0,!1),ii(i,e)||i.__render(n||t,e),c&&ni(this,r,t,n,s,o,c,!1)}ni(this,r,t,n,s,o,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=ai+"_#~&*+\\=|≮≯≈≠=…",li=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 ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const di=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ui=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fi=ci(ai),pi=ci(hi),gi=ci("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:wi,Single:vi,Before:yi,After:mi,Symbol:xi,Break:bi}=_i;function Bi(t){return di[t]?wi:gi[t]?bi:ui[t]?yi:fi[t]?mi:pi[t]?xi:li.test(t)?vi:wi}const ki={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)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:Li}=ki,{Letter:Ti,Single:Si,Before:Ri,After:Pi,Symbol:Mi,Break:Ci}=_i;let Ai,Di,Oi,Wi,Ii,zi,Fi,Ui,ji,Gi,Yi,Xi,Vi,Ni,Hi,qi,Ki,Qi=[];function $i(t,e){ji&&!Ui&&(Ui=ji),Ai.data.push({char:t,width:e}),Oi+=e}function Zi(){Wi+=Oi,Ai.width=Oi,Di.words.push(Ai),Ai={data:[]},Oi=0}function Ji(){Ni&&(Hi.paraNumber++,Di.paraStart=!0,Ni=!1),ji&&(Di.startCharSize=Ui,Di.endCharSize=ji,Ui=0),Di.width=Wi,qi.width?Li(Di):Ki&&ts(),Qi.push(Di),Di={words:[]},Wi=0}function ts(){Wi>(Hi.maxWidth||0)&&(Hi.maxWidth=Wi)}const{top:es,right:is,bottom:ss,left:ns}=z;function os(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 rs={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[ns],r-=c[is]+c[ns]):e.autoSizeAlign||(n=c[ns]),a?(o=c[es],a-=c[es]+c[ss]):e.autoSizeAlign||(o=c[es]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){Hi=t,Qi=t.rows,qi=t.bounds,Ki=!qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=qi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ni=!0,Yi=null,Ui=Fi=ji=Oi=Wi=0,Ai={data:[]},Di={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)zi=e[s],"\n"===zi?(Oi&&Zi(),Di.paraEnd=!0,Ji(),Ni=!0):(Gi=Bi(zi),Gi===Ti&&"none"!==r&&(zi=Ei(zi,r,!Oi)),Fi=a.measureText(zi).width,n&&(n<0&&(ji=Fi),Fi+=n),Xi=Gi===Si&&(Yi===Si||Yi===Ti)||Yi===Si&&Gi!==Pi,Vi=!(Gi!==Ri&&Gi!==Si||Yi!==Mi&&Yi!==Pi),Ii=Ni&&o?h-o:h,t&&h&&Wi+Oi+Fi>Ii&&(i?(Oi&&Zi(),Wi&&Ji()):(Vi||(Vi=Gi===Ti&&Yi==Pi),Xi||Vi||Gi===Ci||Gi===Ri||Gi===Si||Oi+Fi>Ii?(Oi&&Zi(),Wi&&Ji()):Wi&&Ji()))," "===zi&&!0!==Ni&&Wi+Oi===0||(Gi===Ci?(" "===zi&&Oi&&Zi(),$i(zi,Fi),Zi()):Xi||Vi?(Oi&&Zi(),$i(zi,Fi)):$i(zi,Fi)),Yi=Gi);Oi&&Zi(),Wi&&Ji(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Hi.paraNumber++,Wi=a.measureText(t).width,Qi.push({x:o||0,text:t,width:Wi,paraStart:!0}),Ki&&ts()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[ns]);break;case"right":os(e,"x",-t[is])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[es]);break;case"bottom":os(e,"y",-t[ss])}}(c,d,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),v=r;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}v+=p;let y,m,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!h)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&r>0&&(v+=d),y.y=v,v+=o,t.overflow>r&&v>w&&(y.isOverflow=!0,t.overflow=r+1),m=y.x,x=y.width,a<0&&(y.width<0?(x=-y.width+e.fontSize+a,m-=x,x+=e.fontSize):x-=a),m<s.x&&(s.x=m),x>s.width&&(s.width=x),h&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,P(n)?(i=n.type,n.color&&(t.decorationColor=N.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,e),d}};const as={string:function(t,e){const i=F(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let n=r(t.a)?1:t.a;i&&(n*=e);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};Object.assign(Q,rs),Object.assign(N,as),Object.assign(V,Gt),Object.assign(X,Se),Object.assign(H,He),Object.assign($,ei),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new J(t,e),hitCanvasManager:()=>new Y}),it();export{kt as Interaction,gt as Layouter,J as LeaferCanvas,yt as Picker,wt as Renderer,mt as Selector,nt as Watcher,it as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,DataHelper as n,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as v,BranchHelper as y,LeafBoundsHelper as m,Bounds as x,isArray as b,LeafLevelList as B,LayoutEvent as k,Run as E,ImageManager as L,BoundsHelper as T,Plugin as S,MathHelper as R,isObject as P,Matrix as M,getMatrixData as C,MatrixHelper as A,AlignHelper as D,PointHelper as O,ImageEvent as W,AroundHelper as I,Direction4 as z,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as j,Cursor as G,HitCanvasManager as Y}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as X,Paint as V,ColorConvert as N,PaintGradient as H,Export as q,Group as K,TextConvert as Q,Effect as $}from"@leafer-ui/draw";const Z=t.get("LeaferCanvas");class J extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else Z.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),Z.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};n.copyAttrs(e,this,o),this.resize(t),this.resizeListener&&!r(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:tt,fileType:et}=l;function it(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=tt(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,tt(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(tt(et(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new J(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:st}=navigator;st.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),st.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):st.indexOf("Mac")>-1?i.os="Mac":st.indexOf("Linux")>-1&&(i.os="Linux");class nt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=n.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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:ot,updateBounds:rt,updateChange:at}=v,{pushAllChildBranch:ht,pushAllParent:lt}=y;const{worldBounds:ct}=m;class dt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ut,updateAllChange:ft}=v,pt=t.get("Layouter");class gt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new B,this.target=t,e&&(this.config=n.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(k.START),this.layoutOnce(),t.emitEvent(new k(k.END,this.layoutedBlocks,this.times))}catch(t){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=E.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=k,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new k(n,a,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?(ot(t,!0),e.add(t),t.isBranch&&ht(t,e),lt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lt(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||rt(s[t])}rt(i)}})}(this.__levelList),function(t){t.list.forEach(at)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new k(o,a,this.times)),i.emitEvent(new k(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,E.end(e)}fullLayout(){const t=E.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=k,o=this.getBlocks(new f(e));e.emitEvent(new k(i,o,this.times)),gt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new k(s,o,this.times)),e.emitEvent(new k(n,o,this.times)),this.addBlocks(o),E.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?y.updateBounds(t):v.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new dt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new dt(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_([[k.REQUEST,this.layout,this],[k.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=t.get("Renderer");class wt{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=n.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(k.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,_t.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),L.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=E.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(wt.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),E.end(e)}fullRender(){const t=E.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),E.end(t)}__render(e,i){const{canvas:s}=this,n=e.includes(this.target.__world),o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&s.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(s,e),this.target.__render(s,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;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 e=this.requestTime=Date.now();i.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),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 x(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 x(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||_t.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 p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[k.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}wt.clipSpread=10;const{hitRadiusPoint:vt}=T;class yt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:o}=this.point,r={x:n,y:o,radiusX:0,radiusY:0};for(let n=0,o=t.length;n<o;n++)if(e=t[n],(i||v.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&v.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=>v.worldHittable(t))}getPath(t){const e=new f;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 f;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 f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||vt(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:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[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 mt{constructor(t,e){this.config={},e&&(this.config=n.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,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()}}Object.assign(c,{watcher:(t,e)=>new nt(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>new mt(t,e)}),i.layout=gt.fullLayout;const xt={convert(t,e){const i=U.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=U.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=xt.getTouch(t),s=U.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},bt={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Bt}=U;class kt extends j{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(bt.convert(t))}onKeyUp(t){this.keyUp(bt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(xt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(xt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=xt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(xt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(xt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(xt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(xt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=xt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Bt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(xt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=xt.getTouch(t);this.pointerMove(xt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=xt.getTouch(t);this.pointerUp(xt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(U.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&G.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Et(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function Lt(t,e){t.__.__font?Et(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i){switch(e.__.strokeAlign){case"center":St(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?St(t,2,e,i):Rt(t,"outside",e,i)}}function St(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Pt(i,s))}function Rt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,St(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Et(i,n),n.blendMode="normal",v.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Pt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=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(o){const{decorationHeight:t}=s;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Mt(t,e,i,s,n){let o;const r=s.__,{__hasMultiStrokeStyle:a}=r;a||n.setStroke(void 0,r.__strokeWidth*e,r);for(let h=0,l=t.length;h<l;h++)if(o=t[h],(!o.image||!X.checkImage(s,n,o,!1))&&o.style){if(a){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.blendMode?(n.saveBlendMode(o.blendMode),i?Pt(s,n):n.stroke(),n.restoreBlendMode()):i?Pt(s,n):n.stroke()}}function Ct(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Tt(t,e,i);else switch(s.strokeAlign){case"center":At(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),At(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)At(t,2,e,i);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),At(t,2,e,o),o.clipUI(s),o.clearWorld(n),v.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i)}}function At(t,e,i,s){const n=i.__;P(t)?Mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&V.strokeArrow(t,i,s)}const{getSpread:Dt,getOuterOf:Ot,getByMove:Wt,getIntersectData:It}=T;let zt;const{stintSet:Ft}=n,{hasTransparent:Ut}=N;function jt(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout;switch(e.type){case"image":n=X.image(i,t,e,o,!zt||!zt[e.url]);break;case"linear":n=H.linearGradient(e,o);break;case"radial":n=H.radialGradient(e,o);break;case"angular":n=H.conicGradient(e,o);break;case"solid":const{type:s,color:a,opacity:h}=e;n={type:s,style:N.string(a,h)};break;default:r(e.r)||(n={type:"solid",style:N.string(e)})}if(n){if(s(n.style)&&Ut(n.style)&&(n.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}e.editing&&(n.editing=e.editing),e.blendMode&&(n.blendMode=e.blendMode)}return n}const Gt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),zt=X.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=jt(t,a[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),o=!0),"fill"===t?(Ft(i,"__isAlphaPixelFill",n),Ft(i,"__isTransparentFill",o)):(Ft(i,"__isAlphaPixelStroke",n),Ft(i,"__isTransparentStroke",o),Ft(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,Lt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(X.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),Lt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Lt(e,i),i.restoreBlendMode()):Lt(e,i)}},fillPathOrText:Lt,fillText:Et,stroke:Ct,strokes:function(t,e,i){Ct(t,e,i)},strokeText:Tt,drawTextStroke:Pt,shape:function(t,e,s){const n=e.getSameCanvas(),o=t.__nowWorld,r=e.bounds;let a,h,l,c,d,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(o))d=n,a=c=o;else{const{renderShapeSpread:n}=t.__layout;let p;if(i.fullImageShadow)p=o;else{const t=n?Dt(r,u===f?n*u:[n*f,n*u]):r;p=It(t,o)}l=r.getFitMatrix(p);let{a:g,d:_}=l;l.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,s),u*=g,f*=_),c=Ot(o,l),a=Wt(c,-l.e,-l.f);const w=s.matrix;w?(h=new M(l),h.multiply(w),g*=w.scaleX,_*=w.scaleY):h=l,h.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:l,bounds:a,worldCanvas:d,shapeBounds:c,scaleX:u,scaleY:f}}};let Yt={},Xt=C();const{get:Vt,rotateOfOuter:Nt,translate:Ht,scaleOfOuter:qt,multiplyParent:Kt,scale:Qt,rotate:$t,skew:Zt}=A;function Jt(t,e,i,s,n,o,r){const a=Vt();Ht(a,e.x+i,e.y+s),Qt(a,n,o),r&&Nt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function te(t,e,i,s,n,o,r,a,h){const l=Vt();ie(l,e,i,s,n,o,r,a),h&&(Xt.a=e.width/h.width,Xt.d=e.height/h.height,Kt(l,Xt)),t.transform=l}function ee(t,e,i,s,n,o,r,a,h,l,c,d){const u=Vt();if(d)ie(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)Nt(u,{x:i/2,y:s/2},h);else switch($t(u,h),h){case 90:Ht(u,s,0);break;case 180:Ht(u,i,s);break;case 270:Ht(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+o,Ht(u,Yt.x,Yt.y),r&&qt(u,Yt,r,a)}t.transform=u}function ie(t,e,i,s,n,o,r,a){r&&$t(t,r),a&&Zt(t,a.x,a.y),n&&Qt(t,n,o),Ht(t,e.x+i,e.y+s)}const{get:se,translate:ne}=A,oe=new x,re={},ae={};function he(t,e,i,s){const{changeful:n,sync:o,scaleFixed:r}=i;n&&(t.changeful=n),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=le(i,s,e)}function le(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:o}=i;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,v=e.width===n&&e.height===o,y={mode:a},m="center"!==h&&(u||0)%180==90;let x,b;switch(T.set(ae,0,0,m?o:n,m?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,re),x=re.scaleX,b=re.scaleY),(h||_||g)&&(x&&T.scale(ae,x,b,!0),h&&D.toPoint(h,ae,e,ae,!0,!0))):v&&!u||(x=b=T.getFitScale(e,ae,"fit"!==a),T.put(e,i,h,x,!1,ae),T.scale(ae,x,b,!0)),l&&O.move(ae,l),a){case"stretch":v||(n=e.width,o=e.height);break;case"normal":case"clip":(ae.x||ae.y||x||p||u||f)&&te(y,e,ae.x,ae.y,x,b,u,f,t.clipSize);break;case"repeat":(!v||x||u||f)&&ee(y,e,n,o,ae.x,ae.y,x,b,u,f,h,t.freeTransform),g||(y.repeat="repeat");const i=P(g);(_||i)&&(y.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:ce(o,i,n.width,e&&e.x),y:ce(r,s,n.height,e&&e.y)}}(_,i&&g,ae.width,ae.height,e));break;default:x&&Jt(y,e,ae.x,ae.y,x,b,u)}return y.transform||(e.x||e.y)&&(y.transform=se(),ne(y.transform,e.x,e.y)),x&&"stretch"!==a&&(y.scaleX=x,y.scaleY=b),y.width=n,y.height=o,r&&(y.opacity=r),w&&(y.filters=w),g&&(y.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ce(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let de,ue=new x;const{isSame:fe}=T;function pe(t,e,i,s,n,o){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||he(n,s,i,o),!0}function ge(t,e){ve(t,W.LOAD,e)}function _e(t,e){ve(t,W.LOADED,e)}function we(t,e,i){e.error=i,t.forceUpdate("surface"),ve(t,W.ERROR,e)}function ve(t,e,i){t.hasEvent(e)&&t.emitEvent(new W(e,i))}function ye(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:me,scale:xe,copy:be}=A,{floor:Be,max:ke,abs:Ee}=Math;function Le(t,e,s){let{scaleX:n,scaleY:o}=t.getRenderScaleData(!0,e.scaleFixed);const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=a;n*=s,o*=s;const w=_&&_.x*n,v=_&&_.y*o;u&&(u=Ee(u),f=Ee(f),l=me(),be(l,p),xe(l,1/u,1/f),n*=u,o*=f),c*=n,d*=o;const y=c*d;if(!g&&y>i.image.maxCacheSize)return!1;let m=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}if(y>m&&(h=Math.sqrt(y/m)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(l||(l=me(),p&&be(l,p)),xe(l,1/n,1/o)),l){const t=c+(w||0),e=d+(v||0);xe(l,t/ke(Be(t),1),e/ke(Be(e),1))}const x=t.getCanvas(c,d,a.opacity,a.filters,w,v),b=t.getPattern(x,g||i.origin.noRepeat||"no-repeat",l,e);return e.style=b,e.patternId=r,!0}}function Te(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let o,r;const a=L.get(i);return de&&i===de.paint&&fe(s,de.boxBounds)?o=de.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),de=a.use>1?{leafPaint:o,paint:i,boxBounds:ue.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(pe(t,e,i,a,o,s),n&&(ge(t,r),_e(t,r))):a.error?n&&we(t,r,a.error):(n&&(ye(t,!0),ge(t,r)),o.loadId=a.load(()=>{ye(t,!1),t.destroyed||(pe(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),_e(t,r)),o.loadId=void 0},e=>{ye(t,!1),we(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=e,{data:l}=s;if(!l||s.patternId===o+"-"+r+"-"+h&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&a.isResizing(t)||q.running)){let{width:t,height:e}=l;t*=o*h,e*=r*h,l.scaleX&&(t*=l.scaleX,e*=l.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.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,e,s,l),!0):(!s.style||s.sync||q.running?Le(t,s,h):s.patternTask||(s.patternTask=L.patternTasker.add(()=>Te(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Le(t,s,h),t.forceUpdate("surface")}),300)),!1)},createPattern:Le,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,L.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createData:he,getPatternData:le,fillOrFitMode:Jt,clipMode:te,repeatMode:ee},{toPoint:Re}=I,{hasTransparent:Pe}=N,Me={},Ce={};function Ae(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&Pe(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Oe}=O,{get:We,rotateOfOuter:Ie,scaleOfOuter:ze}=A,{toPoint:Fe}=I,Ue={},je={};function Ge(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=De(e,i);o=We(),n?(ze(o,e,r/a*(s||1),1),Ie(o,e,t+90)):(ze(o,e,1,r/a*(s||1)),Ie(o,e,t))}return o}const{getDistance:Ye}=O,{toPoint:Xe}=I,Ve={},Ne={};const He={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Re(s||"top",e,Me),Re(n||"bottom",e,Ce);const a=i.canvas.createLinearGradient(Me.x,Me.y,Ce.x,Ce.y),h={type:o,style:a};return Ae(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Fe(s||"center",e,Ue),Fe(n||"bottom",e,je);const h=i.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Oe(Ue,je)),l={type:o,style:h};Ae(l,h,t.stops,r);const c=Ge(e,Ue,je,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Xe(s||"center",e,Ve),Xe(n||"bottom",e,Ne);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Ve.x,Ve.y):i.canvas.createRadialGradient(Ve.x,Ve.y,0,Ve.x,Ve.y,Ye(Ve,Ne)),l={type:o,style:h};Ae(l,h,t.stops,r);const c=Ge(e,Ve,Ne,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Ge},{copy:qe,toOffsetOutBounds:Ke}=T,Qe={},$e={};function Ze(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(qe(Qe,t.bounds),Qe.x+=e.x-r.x,Qe.y+=e.y-r.y,s){const{fitMatrix:t}=n;Qe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Qe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Qe.width*=s,Qe.height*=s}t.copyWorld(n.canvas,t.bounds,Qe)}else s&&(qe(Qe,e),Qe.x-=e.width/2*(s-1),Qe.y-=e.height/2*(s-1),Qe.width*=s,Qe.height*=s),t.copyWorld(n.canvas,r,s?Qe:e)}const{toOffsetOutBounds:Je}=T,ti={};const ei={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;Ke(l,$e),a.forEach((a,g)=>{let _=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.setWorldShadow($e.offsetX+a.x*d*_,$e.offsetY+a.y*u*_,a.blur*d*_,N.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*_:0,Ze(f,$e,n,i),s=l,a.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s,!0)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=a.length-1;Je(l,ti),a.forEach((a,g)=>{let _=1;if(a.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(ti.offsetX+a.x*d*_,ti.offsetY+a.y*u*_,a.blur*d*_),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*_:0,Ze(f,ti,n,i),f.restore(),h?(f.copyWorld(f,l,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,l,"source-out"),s=l),f.fillWorld(s,N.string(a.color),"source-in"),v.copyCanvasByWorld(t,e,f,s,a.blendMode),p&&g<p&&f.clearWorld(s,!0)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ii}=m;let si;function ni(t,e,i,s,n,o,r,a){switch(e){case"grayscale":si||(si=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);ri(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ri(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r,!0)}K.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(ni(this,r,t,n,s,o,void 0,!0),s=n=null),o=i.__.opacity,si=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a||ii(i,e)||i.__render(t,e);continue}const c=1===o&&i.__.__blendMode;c&&ni(this,r,t,n,s,o,void 0,!1),ii(i,e)||i.__render(n||t,e),c&&ni(this,r,t,n,s,o,c,!1)}ni(this,r,t,n,s,o,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=ai+"_#~&*+\\=|≮≯≈≠=…",li=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 ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const di=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ui=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fi=ci(ai),pi=ci(hi),gi=ci("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:wi,Single:vi,Before:yi,After:mi,Symbol:xi,Break:bi}=_i;function Bi(t){return di[t]?wi:gi[t]?bi:ui[t]?yi:fi[t]?mi:pi[t]?xi:li.test(t)?vi:wi}const ki={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)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:Li}=ki,{Letter:Ti,Single:Si,Before:Ri,After:Pi,Symbol:Mi,Break:Ci}=_i;let Ai,Di,Oi,Wi,Ii,zi,Fi,Ui,ji,Gi,Yi,Xi,Vi,Ni,Hi,qi,Ki,Qi=[];function $i(t,e){ji&&!Ui&&(Ui=ji),Ai.data.push({char:t,width:e}),Oi+=e}function Zi(){Wi+=Oi,Ai.width=Oi,Di.words.push(Ai),Ai={data:[]},Oi=0}function Ji(){Ni&&(Hi.paraNumber++,Di.paraStart=!0,Ni=!1),ji&&(Di.startCharSize=Ui,Di.endCharSize=ji,Ui=0),Di.width=Wi,qi.width?Li(Di):Ki&&ts(),Qi.push(Di),Di={words:[]},Wi=0}function ts(){Wi>(Hi.maxWidth||0)&&(Hi.maxWidth=Wi)}const{top:es,right:is,bottom:ss,left:ns}=z;function os(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 rs={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=e;c&&(r?(n=c[ns],r-=c[is]+c[ns]):e.autoSizeAlign||(n=c[ns]),a?(o=c[es],a-=c[es]+c[ss]):e.autoSizeAlign||(o=c[es]));const d={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=l};return function(t,e,s){Hi=t,Qi=t.rows,qi=t.bounds,Ki=!qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=qi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ni=!0,Yi=null,Ui=Fi=ji=Oi=Wi=0,Ai={data:[]},Di={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)zi=e[s],"\n"===zi?(Oi&&Zi(),Di.paraEnd=!0,Ji(),Ni=!0):(Gi=Bi(zi),Gi===Ti&&"none"!==r&&(zi=Ei(zi,r,!Oi)),Fi=a.measureText(zi).width,n&&(n<0&&(ji=Fi),Fi+=n),Xi=Gi===Si&&(Yi===Si||Yi===Ti)||Yi===Si&&Gi!==Pi,Vi=!(Gi!==Ri&&Gi!==Si||Yi!==Mi&&Yi!==Pi),Ii=Ni&&o?h-o:h,t&&h&&Wi+Oi+Fi>Ii&&(i?(Oi&&Zi(),Wi&&Ji()):(Vi||(Vi=Gi===Ti&&Yi==Pi),Xi||Vi||Gi===Ci||Gi===Ri||Gi===Si||Oi+Fi>Ii?(Oi&&Zi(),Wi&&Ji()):Wi&&Ji()))," "===zi&&!0!==Ni&&Wi+Oi===0||(Gi===Ci?(" "===zi&&Oi&&Zi(),$i(zi,Fi),Zi()):Xi||Vi?(Oi&&Zi(),$i(zi,Fi)):$i(zi,Fi)),Yi=Gi);Oi&&Zi(),Wi&&Ji(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Hi.paraNumber++,Wi=a.measureText(t).width,Qi.push({x:o||0,text:t,width:Wi,paraStart:!0}),Ki&&ts()})}(d,t,e),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[ns]);break;case"right":os(e,"x",-t[is])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[es]);break;case"bottom":os(e,"y",-t[ss])}}(c,d,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),v=r;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}v+=p;let y,m,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!h)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&r>0&&(v+=d),y.y=v,v+=o,t.overflow>r&&v>w&&(y.isOverflow=!0,t.overflow=r+1),m=y.x,x=y.width,a<0&&(y.width<0?(x=-y.width+e.fontSize+a,m-=x,x+=e.fontSize):x-=a),m<s.x&&(s.x=m),x>s.width&&(s.width=x),h&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;s.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,e,r),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,e,n,r),"none"!==h&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,P(n)?(i=n.type,n.color&&(t.decorationColor=N.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,e),d}};const as={string:function(t,e){const i=F(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let n=r(t.a)?1:t.a;i&&(n*=e);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};Object.assign(Q,rs),Object.assign(N,as),Object.assign(V,Gt),Object.assign(X,Se),Object.assign(H,He),Object.assign($,ei),Object.assign(c,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new J(t,e),hitCanvasManager:()=>new Y}),it();export{kt as Interaction,gt as Layouter,J as LeaferCanvas,yt as Picker,wt as Renderer,mt as Selector,nt as Watcher,it as useCanvas};
|
|
2
2
|
//# sourceMappingURL=web.esm.min.js.map
|