leafer-draw 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +2 -1
- package/dist/web.esm.js +2 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +39 -26
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +39 -26
- package/dist/web.module.min.js +1 -1
- package/package.json +2 -2
package/dist/web.cjs
CHANGED
|
@@ -93,7 +93,8 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
93
93
|
this.view.height = Math.ceil(height * pixelRatio);
|
|
94
94
|
}
|
|
95
95
|
updateClientBounds() {
|
|
96
|
-
|
|
96
|
+
if (this.view.parentElement)
|
|
97
|
+
this.clientBounds = this.view.getBoundingClientRect();
|
|
97
98
|
}
|
|
98
99
|
startAutoLayout(autoBounds, listener) {
|
|
99
100
|
this.resizeListener = listener;
|
package/dist/web.esm.js
CHANGED
|
@@ -94,7 +94,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
94
94
|
this.view.height = Math.ceil(height * pixelRatio);
|
|
95
95
|
}
|
|
96
96
|
updateClientBounds() {
|
|
97
|
-
|
|
97
|
+
if (this.view.parentElement)
|
|
98
|
+
this.clientBounds = this.view.getBoundingClientRect();
|
|
98
99
|
}
|
|
99
100
|
startAutoLayout(autoBounds, listener) {
|
|
100
101
|
this.resizeListener = listener;
|
package/dist/web.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,defineKey as l,FileHelper as c,LeafList as h,RenderEvent as u,ChildEvent as p,WatchEvent as f,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as y,LeafBoundsHelper as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as O,Direction4 as W,TwoPointBoundsHelper as C,TaskProcessor as T,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as D,ColorConvert as P,PaintGradient as I,Export as z,Group as F,TextConvert as V,Paint as Y,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class G 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 n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(n.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="string"==typeof 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 X.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:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){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),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(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:n,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(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.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:N,fileType:j}=c;function q(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,N(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(N(j(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new G(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:H}=navigator;H.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):H.indexOf("Safari")>-1&&-1===H.indexOf("Chrome")&&(i.fullImageShadow=!0),H.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):H.indexOf("Mac")>-1?i.os="Mac":H.indexOf("Linux")>-1&&(i.os="Linux");class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:Z,updateAllWorldOpacity:$}=_,{pushAllChildBranch:K,pushAllParent:tt}=w;const{worldBounds:et}=m,it={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:st,updateAllChange:ot}=_,at=t.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,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.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&K(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||Z(n[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new h(e));e.emitEvent(new x(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){st(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=t.get("Renderer");class lt{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(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,dt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new y(s);n.save(),o&&!t.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.showHitView&&this.renderHitView(s),t.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(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 y(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||dt.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 u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ct(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function ht(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):pt(e,i);break;case"inside":ut("inside",t,s,e,i);break;case"outside":ut("outside",t,s,e,i)}}function ut(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ft(e,!0,n,r):pt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ct(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function pt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?pt(i,n):n.stroke(),n.restoreBlendMode()):e?pt(i,n):n.stroke())}function gt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(r,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=rt.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=R;let vt;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:P.string(a,r)};case"image":return D.image(i,t,e,n,!vt||!vt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),vt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=xt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ct(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&D.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?ct(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?ct(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?ct(e,i):s?i.fill(s):i.fill())},fillText:ct,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ft(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:pt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=mt(n?_t(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:p}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=p),r=wt(s,a),o=yt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let Bt={};const{get:Rt,rotateOfOuter:kt,translate:St,scaleOfOuter:Et,scale:Lt,rotate:At}=k;function Ot(t,e,i,n,s,o,a){const r=Rt();St(r,e.x+i,e.y+n),Lt(r,s,o),a&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,n,s,o,a){const r=Rt();St(r,e.x+i,e.y+n),s&&Lt(r,s,o),a&&At(r,a),t.transform=r}function Ct(t,e,i,n,s,o,a,r,d,l){const c=Rt();if(d)if("center"===l)kt(c,{x:i/2,y:n/2},d);else switch(At(c,d),d){case 90:St(c,n,0);break;case 180:St(c,i,n);break;case 270:St(c,0,i)}Bt.x=e.x+s,Bt.y=e.y+o,St(c,Bt.x,Bt.y),a&&Et(c,Bt,a,r),t.transform=c}const{get:Tt,translate:Mt}=k,Dt=new y,Pt={},It={};function zt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Ft(i,n,e)}function Ft(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Dt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,p=e.width===n&&e.height===s,f={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,i,It),y=It.scaleX,m=It.scaleY);else if(!p||h){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Pt,!0),v+=Pt.x,x+=Pt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Wt(f,e,v,x,y,m,h);break;case"repeat":(!p||y||h)&&Ct(f,e,n,s,v,x,y,m,h,r),u||(f.repeat="repeat");break;default:y&&Ot(f,e,v,x,y,m,h)}return f.transform||(e.x||e.y)&&(f.transform=Tt(),Mt(f.transform,e.x,e.y)),y&&"stretch"!==a&&(f.scaleX=y,f.scaleY=m),f.width=n,f.height=s,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let Vt,Yt=new y;const{isSame:Ut}=R;function Xt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||zt(s,n,i,o),!0}function Gt(t,e){qt(t,L.LOAD,e)}function Nt(t,e){qt(t,L.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,L.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Ht(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Jt,copy:Zt}=k,{ceil:$t,abs:Kt}=Math;function te(t,e,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Kt(s),o=Kt(o);const{image:t,data:r}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=r;u&&(l=Qt(),Zt(l,g),Jt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=p),(g||1!==s||1!==o)&&(l||(l=Qt(),g&&Zt(l,g)),Jt(l,1/s,1/o));const m=t.getCanvas($t(c)||1,$t(h)||1,f),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return Vt&&i===Vt.paint&&Ut(n,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:r},Vt=r.use>1?{leafPaint:o,paint:i,boxBounds:Yt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Xt(t,e,i,r,o,n),s&&(Gt(t,a),Nt(t,a))):r.error?s&&jt(t,a,r.error):(s&&(Ht(t,!0),Gt(t,a)),o.loadId=r.load((()=>{Ht(t,!1),t.destroyed||(Xt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,a)),o.loadId=null}),(e=>{Ht(t,!1),jt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=e;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:e}=d;t*=ie(o)*r,e*=ie(a)*r,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),s=t*e>i.image.maxCacheSize||z.running}return s?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode),d.opacity&&(e.opacity*=d.opacity),d.transform&&e.transform(d.transform),e.drawImage(n.image.view,0,0,d.width,d.height),e.restore(),!0):(!n.style||n.sync||z.running?te(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&te(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:zt,getPatternData:Ft,fillOrFitMode:Ot,clipMode:Wt,repeatMode:Ct},{toPoint:se}=A,oe={},ae={};function re(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:de,getDistance:le}=O,{get:ce,rotateOfOuter:he,scaleOfOuter:ue}=k,{toPoint:pe}=A,fe={},ge={};function _e(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=de(e,i);o=ce(),s?(ue(o,e,a/r*(n||1),1),he(o,e,t+90)):(ue(o,e,1,a/r*(n||1)),he(o,e,t))}return o}const{getDistance:we}=O,{toPoint:ye}=A,me={},ve={};const xe={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;se(n||"top",e,oe),se(s||"bottom",e,ae);const d=i.canvas.createLinearGradient(oe.x,oe.y,ae.x,ae.y);re(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;pe(n||"center",e,fe),pe(s||"bottom",e,ge);const l=i.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,le(fe,ge));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,fe,ge,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ye(n||"center",e,me),ye(s||"bottom",e,ve);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,me.x,me.y):i.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,ve));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,me,ve,d||1,i.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:_e},{copy:be,toOffsetOutBounds:Be}=R,Re={},ke={};function Se(t,e,n,s){const{bounds:o,shapeBounds:a}=s;if(i.fullImageShadow){if(be(Re,t.bounds),Re.x+=e.x-a.x,Re.y+=e.y-a.y,n){const{matrix:t}=s;Re.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Re.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Re.width*=n,Re.height*=n}t.copyWorld(s.canvas,t.bounds,Re)}else n&&(be(Re,e),Re.x-=e.width/2*(n-1),Re.y-=e.height/2*(n-1),Re.width*=n,Re.height*=n),t.copyWorld(s.canvas,a,n?Re:e)}const{toOffsetOutBounds:Ee}=R,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Be(l,ke),r.forEach(((r,g)=>{p.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Se(p,ke,s,i),n=l,r.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,o,"copy"),n=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,r.blendMode):e.copyWorldToInner(p,n,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Ee(l,Le),r.forEach(((r,g)=>{p.save(),p.setWorldShadow(Le.offsetX+r.x*h,Le.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Se(p,Le,s,i),p.restore(),d?(p.copyWorld(p,l,o,"copy"),p.copyWorld(d,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,c,l,"source-out"),n=l),p.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,r.blendMode):e.copyWorldToInner(p,n,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Oe}=m;function We(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Te(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Te(t,i,n,o);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function Te(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(We(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ce(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Ce(t)),s||(s=Ce(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Oe(i,e)||i.__render(s||t,e);We(this,a,t,s,n,o)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",De=Me+"_#~&*+\\=|≮≯≈≠=…",Pe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ze=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Fe=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ie(Me),Ye=Ie(De),Ue=Ie("- —/~|┆·");var Xe;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Xe||(Xe={}));const{Letter:Ge,Single:Ne,Before:je,After:qe,Symbol:He,Break:Qe}=Xe;function Je(t){return ze[t]?Ge:Ue[t]?Qe:Fe[t]?je:Ve[t]?qe:Ye[t]?He:Pe.test(t)?Ne:Ge}const Ze={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function $e(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:Ke}=Ze,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:oi}=Xe;let ai,ri,di,li,ci,hi,ui,pi,fi,gi,_i,wi,yi,mi,vi,xi,bi,Bi=[];function Ri(t,e){fi&&!pi&&(pi=fi),ai.data.push({char:t,width:e}),di+=e}function ki(){li+=di,ai.width=di,ri.words.push(ai),ai={data:[]},di=0}function Si(){mi&&(vi.paraNumber++,ri.paraStart=!0,mi=!1),fi&&(ri.startCharSize=pi,ri.endCharSize=fi,pi=0),ri.width=li,xi.width?Ke(ri):bi&&Ei(),Bi.push(ri),ri={words:[]},li=0}function Ei(){li>(vi.maxWidth||0)&&(vi.maxWidth=li)}const Li=0,Ai=1,Oi=2;const{top:Wi,right:Ci,bottom:Ti,left:Mi}=W;function Di(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Pi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(n=l[Mi],o-=l[Ci]+l[Mi]):e.autoSizeAlign||(n=l[Mi]),a?(s=l[Wi],a-=l[Wi]+l[Ti]):e.autoSizeAlign||(s=l[Wi]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){vi=t,Bi=t.rows,xi=t.bounds,bi=!xi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=i,{width:d,height:l}=xi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,i="break"===n.textWrap;mi=!0,_i=null,pi=ui=fi=di=li=0,ai={data:[]},ri={words:[]};for(let n=0,l=e.length;n<l;n++)hi=e[n],"\n"===hi?(di&&ki(),ri.paraEnd=!0,Si(),mi=!0):(gi=Je(hi),gi===ti&&"none"!==a&&(hi=$e(hi,a,!di)),ui=r.measureText(hi).width,s&&(s<0&&(fi=ui),ui+=s),wi=gi===ei&&(_i===ei||_i===ti)||_i===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||_i!==si&&_i!==ni),ci=mi&&o?d-o:d,t&&d&&li+di+ui>ci&&(i?(di&&ki(),li&&Si()):(yi||(yi=gi===ti&&_i==ni),wi||yi||gi===oi||gi===ii||gi===ei||di+ui>ci?(di&&ki(),li&&Si()):li&&Si()))," "===hi&&!0!==mi&&li+di===0||(gi===oi?(" "===hi&&di&&ki(),Ri(hi,ui),ki()):wi||yi?(di&&ki(),Ri(hi,ui)):Ri(hi,ui)),_i=gi);di&&ki(),li&&Si(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{vi.paraNumber++,li=r.measureText(t).width,Bi.push({x:o||0,text:t,width:li,paraStart:!0}),bi&&Ei()}))}(c,t,e),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Di(e,"x",t[Mi]);break;case"right":Di(e,"x",-t[Ci])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Di(e,"y",t[Wi]);break;case"bottom":Di(e,"y",-t[Ti])}}(l,c,e,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:p,width:f,height:g}=n,_=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||h)switch(l){case"middle":p+=(g-_)/2;break;case"bottom":p+=g-_}w+=p;let y,m,v,x=f||h?f:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(y=i[o],y.x=u,y.width<f||y.width>f&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&f&&f<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(c,e),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Li:l>.01?Ai:Oi,t.isOverflow&&!r&&(t.textMode=!0),h===Oi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ai?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,c=n+s-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:zi,addPoint:Fi,toBounds:Vi}=C;const Yi={export(t,e,n){this.running=!0;const s=c.fileType(e),o=e.includes(".");return n=c.getExportOptions(n),function(t){Ui||(Ui=new T);return new Promise((e=>{Ui.add((()=>ee(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((d=>{const l=t=>{a(t),d(),this.running=!1},{toURL:h}=i,{download:u}=i.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),e),l({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),e),l({data:!!o||t.toSVG()});const{leafer:p}=t;p?(Xi(t),p.waitViewCompleted((()=>ee(this,void 0,void 0,(function*(){let i,s,o=1,a=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:f,trim:g,onCanvas:_}=n,w=void 0===n.smooth?p.config.smooth:n.smooth,m=n.contextSettings||p.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=c.isOpaqueImage(e)||x,B=new M;if(v)i=!0===v?h?p.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(h?"inner":"local");switch(o=d.scaleX,a=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,a/=t.scaleY;break;case"world":o=1,a=1;break;case"page":e=t.leafer;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,a/=a/i.scaleY}i=t.getBounds("render",e)}const R={scaleX:1,scaleY:1};S.getScaleData(n.scale,n.size,i,R);let k=n.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:O}=new y(i).scale(R.scaleX,R.scaleY),W={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/o*R.scaleX,1/a*R.scaleY)};let C,T=r.canvas({width:Math.round(A),height:Math.round(O),pixelRatio:k,smooth:w,contextSettings:m});if(f&&(C=t,C.__worldOpacity=0,t=p,W.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,W),t.fill=e}else t.__render(T,W);if(T.restore(),C&&C.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Fi(a,s,o):zi(a={},s,o)),r++;const d=new y;return Vi(a,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:k};T=r.canvas(n),T.copyWorld(t,s,n)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),_&&_(T);const D="canvas"===e?T:yield T.export(e,n);l({data:D,width:T.pixelWidth,height:T.pixelHeight,renderBounds:i,trimBounds:s})}))))):l({data:!1})}))))}};let Ui;function Xi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Xi(t)))}const Gi=e.prototype,Ni=t.get("@leafer-ui/export");Gi.export=function(t,e){const{quality:i,blob:n}=c.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Gi.toBlob=function(t,e){return new Promise((n=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{Ni.error(t),n(null)}))}))},Gi.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Gi.saveAs=function(t,e){return new Promise((n=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{Ni.error(t),n(!1)}))}))},Object.assign(V,Pi),Object.assign(P,Ii),Object.assign(Y,bt),Object.assign(D,ne),Object.assign(I,xe),Object.assign(U,Ae),Object.assign(z,Yi),q();export{rt as Layouter,G as LeaferCanvas,lt as Renderer,Q as Watcher,q as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,defineKey as l,FileHelper as c,LeafList as h,RenderEvent as u,ChildEvent as p,WatchEvent as f,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as y,LeafBoundsHelper as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as O,Direction4 as W,TwoPointBoundsHelper as C,TaskProcessor as T,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as D,ColorConvert as P,PaintGradient as I,Export as z,Group as F,TextConvert as V,Paint as Y,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class G 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 n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(n.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="string"==typeof 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 X.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:n}=this.view;n.width=t+"px",n.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),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(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:n,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(t),r={width:o,height:a,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=e;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};n.copyAttrs(e,this,s),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(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.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:N,fileType:j}=c;function q(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,N(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(N(j(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new G(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:H}=navigator;H.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):H.indexOf("Safari")>-1&&-1===H.indexOf("Chrome")&&(i.fullImageShadow=!0),H.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):H.indexOf("Mac")>-1?i.os="Mac":H.indexOf("Linux")>-1&&(i.os="Linux");class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:Z,updateAllWorldOpacity:$}=_,{pushAllChildBranch:K,pushAllParent:tt}=w;const{worldBounds:et}=m,it={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:st,updateAllChange:ot}=_,at=t.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,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.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new x(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&K(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||Z(n[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=x,o=this.getBlocks(new h(e));e.emitEvent(new x(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(n,o,this.times)),e.emitEvent(new x(s,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){st(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=t.get("Renderer");class lt{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(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,dt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new y(s);n.save(),o&&!t.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.showHitView&&this.renderHitView(s),t.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(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 y(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||dt.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 u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function ct(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function ht(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):pt(e,i);break;case"inside":ut("inside",t,s,e,i);break;case"outside":ut("outside",t,s,e,i)}}function ut(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ft(e,!0,n,r):pt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ct(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function pt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?pt(i,n):n.stroke(),n.restoreBlendMode()):e?pt(i,n):n.stroke())}function gt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(r,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=rt.fullLayout;const{getSpread:_t,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=R;let vt;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:P.string(a,r)};case"image":return D.image(i,t,e,n,!vt||!vt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),vt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=xt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ct(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&D.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?ct(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?ct(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?ct(e,i):s?i.fill(s):i.fill())},fillText:ct,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ft(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:pt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=mt(n?_t(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:p}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=p),r=wt(s,a),o=yt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let Bt={};const{get:Rt,rotateOfOuter:kt,translate:St,scaleOfOuter:Et,scale:Lt,rotate:At}=k;function Ot(t,e,i,n,s,o,a){const r=Rt();St(r,e.x+i,e.y+n),Lt(r,s,o),a&&kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Wt(t,e,i,n,s,o,a){const r=Rt();St(r,e.x+i,e.y+n),s&&Lt(r,s,o),a&&At(r,a),t.transform=r}function Ct(t,e,i,n,s,o,a,r,d,l){const c=Rt();if(d)if("center"===l)kt(c,{x:i/2,y:n/2},d);else switch(At(c,d),d){case 90:St(c,n,0);break;case 180:St(c,i,n);break;case 270:St(c,0,i)}Bt.x=e.x+s,Bt.y=e.y+o,St(c,Bt.x,Bt.y),a&&Et(c,Bt,a,r),t.transform=c}const{get:Tt,translate:Mt}=k,Dt=new y,Pt={},It={};function zt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Ft(i,n,e)}function Ft(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Dt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,p=e.width===n&&e.height===s,f={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,i,It),y=It.scaleX,m=It.scaleY);else if(!p||h){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Pt,!0),v+=Pt.x,x+=Pt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Wt(f,e,v,x,y,m,h);break;case"repeat":(!p||y||h)&&Ct(f,e,n,s,v,x,y,m,h,r),u||(f.repeat="repeat");break;default:y&&Ot(f,e,v,x,y,m,h)}return f.transform||(e.x||e.y)&&(f.transform=Tt(),Mt(f.transform,e.x,e.y)),y&&"stretch"!==a&&(f.scaleX=y,f.scaleY=m),f.width=n,f.height=s,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let Vt,Yt=new y;const{isSame:Ut}=R;function Xt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||zt(s,n,i,o),!0}function Gt(t,e){qt(t,L.LOAD,e)}function Nt(t,e){qt(t,L.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,L.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Ht(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Jt,copy:Zt}=k,{ceil:$t,abs:Kt}=Math;function te(t,e,n){let{scaleX:s,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Kt(s),o=Kt(o);const{image:t,data:r}=e;let d,l,{width:c,height:h,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=r;u&&(l=Qt(),Zt(l,g),Jt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=p),(g||1!==s||1!==o)&&(l||(l=Qt(),g&&Zt(l,g)),Jt(l,1/s,1/o));const m=t.getCanvas($t(c)||1,$t(h)||1,f),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let o,a;const r=B.get(i);return Vt&&i===Vt.paint&&Ut(n,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:r},Vt=r.use>1?{leafPaint:o,paint:i,boxBounds:Yt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Xt(t,e,i,r,o,n),s&&(Gt(t,a),Nt(t,a))):r.error?s&&jt(t,a,r.error):(s&&(Ht(t,!0),Gt(t,a)),o.loadId=r.load((()=>{Ht(t,!1),t.destroyed||(Xt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,a)),o.loadId=null}),(e=>{Ht(t,!1),jt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=e;if(!n.data||n.patternId===o+"-"+a+"-"+r&&!z.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:e}=d;t*=ie(o)*r,e*=ie(a)*r,d.scaleX&&(t*=d.scaleX,e*=d.scaleY),s=t*e>i.image.maxCacheSize||z.running}return s?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode),d.opacity&&(e.opacity*=d.opacity),d.transform&&e.transform(d.transform),e.drawImage(n.image.view,0,0,d.width,d.height),e.restore(),!0):(!n.style||n.sync||z.running?te(t,n,r):n.patternTask||(n.patternTask=B.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&te(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,B.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:zt,getPatternData:Ft,fillOrFitMode:Ot,clipMode:Wt,repeatMode:Ct},{toPoint:se}=A,oe={},ae={};function re(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:de,getDistance:le}=O,{get:ce,rotateOfOuter:he,scaleOfOuter:ue}=k,{toPoint:pe}=A,fe={},ge={};function _e(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=de(e,i);o=ce(),s?(ue(o,e,a/r*(n||1),1),he(o,e,t+90)):(ue(o,e,1,a/r*(n||1)),he(o,e,t))}return o}const{getDistance:we}=O,{toPoint:ye}=A,me={},ve={};const xe={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;se(n||"top",e,oe),se(s||"bottom",e,ae);const d=i.canvas.createLinearGradient(oe.x,oe.y,ae.x,ae.y);re(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;pe(n||"center",e,fe),pe(s||"bottom",e,ge);const l=i.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,le(fe,ge));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,fe,ge,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ye(n||"center",e,me),ye(s||"bottom",e,ve);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,me.x,me.y):i.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,ve));re(l,t.stops,a);const c={type:o,style:l},h=_e(e,me,ve,d||1,i.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:_e},{copy:be,toOffsetOutBounds:Be}=R,Re={},ke={};function Se(t,e,n,s){const{bounds:o,shapeBounds:a}=s;if(i.fullImageShadow){if(be(Re,t.bounds),Re.x+=e.x-a.x,Re.y+=e.y-a.y,n){const{matrix:t}=s;Re.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Re.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Re.width*=n,Re.height*=n}t.copyWorld(s.canvas,t.bounds,Re)}else n&&(be(Re,e),Re.x-=e.width/2*(n-1),Re.y-=e.height/2*(n-1),Re.width*=n,Re.height*=n),t.copyWorld(s.canvas,a,n?Re:e)}const{toOffsetOutBounds:Ee}=R,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Be(l,ke),r.forEach(((r,g)=>{p.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Se(p,ke,s,i),n=l,r.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,l,o,"copy"),n=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,r.blendMode):e.copyWorldToInner(p,n,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),f=r.length-1;Ee(l,Le),r.forEach(((r,g)=>{p.save(),p.setWorldShadow(Le.offsetX+r.x*h,Le.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Se(p,Le,s,i),p.restore(),d?(p.copyWorld(p,l,o,"copy"),p.copyWorld(d,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,c,l,"source-out"),n=l),p.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,r.blendMode):e.copyWorldToInner(p,n,a.renderBounds,r.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Oe}=m;function We(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Te(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Te(t,i,n,o);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function Te(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)i=d[l],r=i.__.mask,r&&(a&&(We(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ce(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Ce(t)),s||(s=Ce(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Oe(i,e)||i.__render(s||t,e);We(this,a,t,s,n,o)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",De=Me+"_#~&*+\\=|≮≯≈≠=…",Pe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ze=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Fe=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ie(Me),Ye=Ie(De),Ue=Ie("- —/~|┆·");var Xe;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Xe||(Xe={}));const{Letter:Ge,Single:Ne,Before:je,After:qe,Symbol:He,Break:Qe}=Xe;function Je(t){return ze[t]?Ge:Ue[t]?Qe:Fe[t]?je:Ve[t]?qe:Ye[t]?He:Pe.test(t)?Ne:Ge}const Ze={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function $e(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:Ke}=Ze,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:oi}=Xe;let ai,ri,di,li,ci,hi,ui,pi,fi,gi,_i,wi,yi,mi,vi,xi,bi,Bi=[];function Ri(t,e){fi&&!pi&&(pi=fi),ai.data.push({char:t,width:e}),di+=e}function ki(){li+=di,ai.width=di,ri.words.push(ai),ai={data:[]},di=0}function Si(){mi&&(vi.paraNumber++,ri.paraStart=!0,mi=!1),fi&&(ri.startCharSize=pi,ri.endCharSize=fi,pi=0),ri.width=li,xi.width?Ke(ri):bi&&Ei(),Bi.push(ri),ri={words:[]},li=0}function Ei(){li>(vi.maxWidth||0)&&(vi.maxWidth=li)}const Li=0,Ai=1,Oi=2;const{top:Wi,right:Ci,bottom:Ti,left:Mi}=W;function Di(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Pi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o?(n=l[Mi],o-=l[Ci]+l[Mi]):e.autoSizeAlign||(n=l[Mi]),a?(s=l[Wi],a-=l[Wi]+l[Ti]):e.autoSizeAlign||(s=l[Wi]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){vi=t,Bi=t.rows,xi=t.bounds,bi=!xi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=i,{width:d,height:l}=xi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,i="break"===n.textWrap;mi=!0,_i=null,pi=ui=fi=di=li=0,ai={data:[]},ri={words:[]};for(let n=0,l=e.length;n<l;n++)hi=e[n],"\n"===hi?(di&&ki(),ri.paraEnd=!0,Si(),mi=!0):(gi=Je(hi),gi===ti&&"none"!==a&&(hi=$e(hi,a,!di)),ui=r.measureText(hi).width,s&&(s<0&&(fi=ui),ui+=s),wi=gi===ei&&(_i===ei||_i===ti)||_i===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||_i!==si&&_i!==ni),ci=mi&&o?d-o:d,t&&d&&li+di+ui>ci&&(i?(di&&ki(),li&&Si()):(yi||(yi=gi===ti&&_i==ni),wi||yi||gi===oi||gi===ii||gi===ei||di+ui>ci?(di&&ki(),li&&Si()):li&&Si()))," "===hi&&!0!==mi&&li+di===0||(gi===oi?(" "===hi&&di&&ki(),Ri(hi,ui),ki()):wi||yi?(di&&ki(),Ri(hi,ui)):Ri(hi,ui)),_i=gi);di&&ki(),li&&Si(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{vi.paraNumber++,li=r.measureText(t).width,Bi.push({x:o||0,text:t,width:li,paraStart:!0}),bi&&Ei()}))}(c,t,e),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Di(e,"x",t[Mi]);break;case"right":Di(e,"x",-t[Ci])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Di(e,"y",t[Wi]);break;case"bottom":Di(e,"y",-t[Ti])}}(l,c,e,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:p,width:f,height:g}=n,_=s*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||h)switch(l){case"middle":p+=(g-_)/2;break;case"bottom":p+=g-_}w+=p;let y,m,v,x=f||h?f:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(y=i[o],y.x=u,y.width<f||y.width>f&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&f&&f<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(c,e),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Li:l>.01?Ai:Oi,t.isOverflow&&!r&&(t.textMode=!0),h===Oi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ai?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=e;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?i.canvas.measureText(r).width:0,c=n+s-l;("none"===e.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<c));n--){if(d<c&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:zi,addPoint:Fi,toBounds:Vi}=C;const Yi={export(t,e,n){this.running=!0;const s=c.fileType(e),o=e.includes(".");return n=c.getExportOptions(n),function(t){Ui||(Ui=new T);return new Promise((e=>{Ui.add((()=>ee(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((d=>{const l=t=>{a(t),d(),this.running=!1},{toURL:h}=i,{download:u}=i.origin;if("json"===s)return o&&u(h(JSON.stringify(t.toJSON(n.json)),"text"),e),l({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&u(h(t.toSVG(),"svg"),e),l({data:!!o||t.toSVG()});const{leafer:p}=t;p?(Xi(t),p.waitViewCompleted((()=>ee(this,void 0,void 0,(function*(){let i,s,o=1,a=1;const{worldTransform:d,isLeafer:h,isFrame:u}=t,{slice:f,trim:g,onCanvas:_}=n,w=void 0===n.smooth?p.config.smooth:n.smooth,m=n.contextSettings||p.config.contextSettings,v=n.screenshot||t.isApp,x=h&&v&&void 0===n.fill?t.fill:n.fill,b=c.isOpaqueImage(e)||x,B=new M;if(v)i=!0===v?h?p.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(h?"inner":"local");switch(o=d.scaleX,a=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,a/=t.scaleY;break;case"world":o=1,a=1;break;case"page":e=t.leafer;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,a/=a/i.scaleY}i=t.getBounds("render",e)}const R={scaleX:1,scaleY:1};S.getScaleData(n.scale,n.size,i,R);let k=n.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:O}=new y(i).scale(R.scaleX,R.scaleY),W={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/o*R.scaleX,1/a*R.scaleY)};let C,T=r.canvas({width:Math.round(A),height:Math.round(O),pixelRatio:k,smooth:w,contextSettings:m});if(f&&(C=t,C.__worldOpacity=0,t=p,W.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,W),t.fill=e}else t.__render(T,W);if(T.restore(),C&&C.__updateWorldOpacity(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Fi(a,s,o):zi(a={},s,o)),r++;const d=new y;return Vi(a,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:k};T=r.canvas(n),T.copyWorld(t,s,n)}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),_&&_(T);const D="canvas"===e?T:yield T.export(e,n);l({data:D,width:T.pixelWidth,height:T.pixelHeight,renderBounds:i,trimBounds:s})}))))):l({data:!1})}))))}};let Ui;function Xi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Xi(t)))}const Gi=e.prototype,Ni=t.get("@leafer-ui/export");Gi.export=function(t,e){const{quality:i,blob:n}=c.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Gi.toBlob=function(t,e){return new Promise((n=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{Ni.error(t),n(null)}))}))},Gi.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Gi.saveAs=function(t,e){return new Promise((n=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{Ni.error(t),n(!1)}))}))},Object.assign(V,Pi),Object.assign(P,Ii),Object.assign(Y,bt),Object.assign(D,ne),Object.assign(I,xe),Object.assign(U,Ae),Object.assign(z,Yi),q();export{rt as Layouter,G as LeaferCanvas,lt as Renderer,Q as Watcher,q as useCanvas};
|
package/dist/web.js
CHANGED
|
@@ -2050,11 +2050,11 @@ var LeaferUI = (function (exports) {
|
|
|
2050
2050
|
toBlob(_type, _quality) { return undefined; }
|
|
2051
2051
|
toDataURL(_type, _quality) { return undefined; }
|
|
2052
2052
|
saveAs(_filename, _quality) { return undefined; }
|
|
2053
|
-
resize(size) {
|
|
2053
|
+
resize(size, safeResize = true) {
|
|
2054
2054
|
if (this.isSameSize(size))
|
|
2055
2055
|
return;
|
|
2056
2056
|
let takeCanvas;
|
|
2057
|
-
if (this.context && !this.unreal && this.width) {
|
|
2057
|
+
if (this.context && !this.unreal && safeResize && this.width) {
|
|
2058
2058
|
takeCanvas = this.getSameCanvas();
|
|
2059
2059
|
takeCanvas.copyWorld(this);
|
|
2060
2060
|
}
|
|
@@ -4256,18 +4256,21 @@ var LeaferUI = (function (exports) {
|
|
|
4256
4256
|
L.setTransform(t, matrix, resize);
|
|
4257
4257
|
},
|
|
4258
4258
|
setTransform(t, transform, resize) {
|
|
4259
|
-
const
|
|
4259
|
+
const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
|
|
4260
|
+
const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
|
|
4260
4261
|
if (resize) {
|
|
4261
|
-
const scaleX = layout.scaleX / t.scaleX;
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4262
|
+
const scaleX = layout.scaleX / t.scaleX, scaleY = layout.scaleY / t.scaleY;
|
|
4263
|
+
delete layout.scaleX, delete layout.scaleY;
|
|
4264
|
+
if (originPoint) {
|
|
4265
|
+
BoundsHelper.scale(t.boxBounds, Math.abs(scaleX), Math.abs(scaleY));
|
|
4266
|
+
const changedPoint = L.getInnerOrigin(t, data.origin);
|
|
4267
|
+
PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
|
|
4268
|
+
}
|
|
4265
4269
|
t.set(layout);
|
|
4266
|
-
t.scaleResize(scaleX, scaleY,
|
|
4270
|
+
t.scaleResize(scaleX, scaleY, false);
|
|
4267
4271
|
}
|
|
4268
|
-
else
|
|
4272
|
+
else
|
|
4269
4273
|
t.set(layout);
|
|
4270
|
-
}
|
|
4271
4274
|
},
|
|
4272
4275
|
getFlipTransform(t, axis) {
|
|
4273
4276
|
const m = getMatrixData();
|
|
@@ -4950,14 +4953,15 @@ var LeaferUI = (function (exports) {
|
|
|
4950
4953
|
if (list) {
|
|
4951
4954
|
let item;
|
|
4952
4955
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
4953
|
-
item = list[i]
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4956
|
+
if (item = list[i]) {
|
|
4957
|
+
item.listener(event);
|
|
4958
|
+
if (item.once) {
|
|
4959
|
+
this.off(type, item.listener, capture);
|
|
4960
|
+
i--, len--;
|
|
4961
|
+
}
|
|
4962
|
+
if (event && event.isStopNow)
|
|
4963
|
+
break;
|
|
4958
4964
|
}
|
|
4959
|
-
if (event && event.isStopNow)
|
|
4960
|
-
break;
|
|
4961
4965
|
}
|
|
4962
4966
|
}
|
|
4963
4967
|
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
@@ -5434,7 +5438,7 @@ var LeaferUI = (function (exports) {
|
|
|
5434
5438
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5435
5439
|
this[attrName] = value;
|
|
5436
5440
|
}
|
|
5437
|
-
forceRender(_bounds) {
|
|
5441
|
+
forceRender(_bounds, _sync) {
|
|
5438
5442
|
this.forceUpdate('surface');
|
|
5439
5443
|
}
|
|
5440
5444
|
__updateWorldMatrix() { }
|
|
@@ -6004,7 +6008,7 @@ var LeaferUI = (function (exports) {
|
|
|
6004
6008
|
}
|
|
6005
6009
|
}
|
|
6006
6010
|
|
|
6007
|
-
const version = "1.2.
|
|
6011
|
+
const version = "1.2.2";
|
|
6008
6012
|
|
|
6009
6013
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
6010
6014
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6096,7 +6100,8 @@ var LeaferUI = (function (exports) {
|
|
|
6096
6100
|
this.view.height = Math.ceil(height * pixelRatio);
|
|
6097
6101
|
}
|
|
6098
6102
|
updateClientBounds() {
|
|
6099
|
-
|
|
6103
|
+
if (this.view.parentElement)
|
|
6104
|
+
this.clientBounds = this.view.getBoundingClientRect();
|
|
6100
6105
|
}
|
|
6101
6106
|
startAutoLayout(autoBounds, listener) {
|
|
6102
6107
|
this.resizeListener = listener;
|
|
@@ -7803,10 +7808,13 @@ var LeaferUI = (function (exports) {
|
|
|
7803
7808
|
const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
|
|
7804
7809
|
Object.keys(data).forEach(key => this[key] = data[key]);
|
|
7805
7810
|
}
|
|
7806
|
-
forceRender(bounds) {
|
|
7807
|
-
|
|
7808
|
-
if (
|
|
7809
|
-
|
|
7811
|
+
forceRender(bounds, sync) {
|
|
7812
|
+
const { renderer } = this;
|
|
7813
|
+
if (renderer) {
|
|
7814
|
+
renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
7815
|
+
if (this.viewReady)
|
|
7816
|
+
sync ? renderer.render() : renderer.update();
|
|
7817
|
+
}
|
|
7810
7818
|
}
|
|
7811
7819
|
requestRender(change = false) {
|
|
7812
7820
|
if (this.renderer)
|
|
@@ -7923,6 +7931,8 @@ var LeaferUI = (function (exports) {
|
|
|
7923
7931
|
this.requestRender();
|
|
7924
7932
|
}
|
|
7925
7933
|
}
|
|
7934
|
+
else
|
|
7935
|
+
this.requestRender();
|
|
7926
7936
|
}
|
|
7927
7937
|
__checkViewCompleted(emit = true) {
|
|
7928
7938
|
this.nextRender(() => {
|
|
@@ -8488,10 +8498,10 @@ var LeaferUI = (function (exports) {
|
|
|
8488
8498
|
__updateSize() {
|
|
8489
8499
|
const { canvas } = this;
|
|
8490
8500
|
if (canvas) {
|
|
8491
|
-
const { smooth } = this.__;
|
|
8501
|
+
const { smooth, safeResize } = this.__;
|
|
8502
|
+
canvas.resize(this.__, safeResize);
|
|
8492
8503
|
if (canvas.smooth !== smooth)
|
|
8493
8504
|
canvas.smooth = smooth;
|
|
8494
|
-
canvas.resize(this.__);
|
|
8495
8505
|
}
|
|
8496
8506
|
}
|
|
8497
8507
|
destroy() {
|
|
@@ -8517,6 +8527,9 @@ var LeaferUI = (function (exports) {
|
|
|
8517
8527
|
__decorate([
|
|
8518
8528
|
resizeType(true)
|
|
8519
8529
|
], exports.Canvas.prototype, "smooth", void 0);
|
|
8530
|
+
__decorate([
|
|
8531
|
+
dataType(false)
|
|
8532
|
+
], exports.Canvas.prototype, "safeResize", void 0);
|
|
8520
8533
|
__decorate([
|
|
8521
8534
|
resizeType()
|
|
8522
8535
|
], exports.Canvas.prototype, "contextSettings", void 0);
|
package/dist/web.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}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="string"==typeof 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:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.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:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;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),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}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.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:A,getByMove:C,getIntersectData:O}=t.BoundsHelper;let W;function M(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const T={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=M(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=A(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let D={};const{get:I,rotateOfOuter:F,translate:H,scaleOfOuter:z,scale:V,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),V(r,s,o),a&&F(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),s&&V(r,s,o),a&&Y(r,a),t.transform=r}function U(t,e,n,i,s,o,a,r,l,d){const c=I();if(l)if("center"===d)F(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}D.x=e.x+s,D.y=e.y+o,H(c,D.x,D.y),a&&z(c,D,a,r),t.transform=c}const{get:X,translate:N}=t.MatrixHelper,q=new t.Bounds,Q={},J={};function Z(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=$(n,i,e)}function $(e,n,i){let{width:s,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,J),v=J.scaleX,y=J.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,Q,!0),x+=Q.x,b+=Q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&U(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&G(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=X(),N(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let K,tt=new t.Bounds;const{isSame:et}=t.BoundsHelper;function nt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Z(s,i,n,o),!0}function it(e,n){at(e,t.ImageEvent.LOAD,n)}function st(e,n){at(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:lt,scale:dt,copy:ct}=t.MatrixHelper,{ceil:ht,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=lt(),ct(d,g),dt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=lt(),g&&ct(d,g)),dt(d,1/s,1/o));const v=e.getCanvas(ht(c)||1,ht(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return K&&i===K.paint&&et(s,K.boxBounds)?a=K.leafPaint:(a={type:i.type,image:l},K=l.use>1?{leafPaint:a,paint:i,boxBounds:tt.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(nt(e,n,i,l,a,s),o&&(it(e,r),st(e,r))):l.error?o&&ot(e,r,l.error):(o&&(rt(e,!0),it(e,r)),a.loadId=l.load((()=>{rt(e,!1),e.destroyed||(nt(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,r)),a.loadId=null}),(t=>{rt(e,!1),ot(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=gt(a)*l,i*=gt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ft(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ft(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Z,getPatternData:$,fillOrFitMode:G,clipMode:j,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},vt={};function yt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:xt,getDistance:bt}=t.PointHelper,{get:Bt,rotateOfOuter:Et,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=xt(e,n);o=Bt(),s?(Rt(o,e,a/r*(i||1),1),Et(o,e,t+90)):(Rt(o,e,1,a/r*(i||1)),Et(o,e,t))}return o}const{getDistance:At}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;wt(i||"top",n,mt),wt(s||"bottom",n,vt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,vt.x,vt.y);yt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const d=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,kt,Pt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,Ot),Ct(s||"bottom",n,Wt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,At(Ot,Wt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,Ot,Wt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Tt,toOffsetOutBounds:Dt}=t.BoundsHelper,It={},Ft={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Tt(It,e.bounds),It.x+=n.x-a.x,It.y+=n.y-a.y,i){const{matrix:t}=s;It.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),It.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),It.width*=i,It.height*=i}e.copyWorld(s.canvas,e.bounds,It)}else i&&(Tt(It,n),It.x-=n.width/2*(i-1),It.y-=n.height/2*(i-1),It.width*=i,It.height*=i),e.copyWorld(s.canvas,a,i?It:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Vt={};const Yt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,Ft),r.forEach(((r,g)=>{f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Ft,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;zt(d,Vt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*h,Vt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Vt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Xt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Xt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ut(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Nt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Nt+"_#~&*+\\=|≮≯≈≠=…",Qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Jt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Jt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Jt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Jt(Nt),te=Jt(qt),ee=Jt("- —/~|┆·");var ne;!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"}(ne||(ne={}));const{Letter:ie,Single:se,Before:oe,After:ae,Symbol:re,Break:le}=ne;function de(t){return Zt[t]?ie:ee[t]?le:$t[t]?oe:Kt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function he(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ae,Ce,Oe,We,Me,Te,De=[];function Ie(t,e){ke&&!Le&&(Le=ke),ve.data.push({char:t,width:e}),xe+=e}function Fe(){be+=xe,ve.width=xe,ye.words.push(ve),ve={data:[]},xe=0}function He(){Oe&&(We.paraNumber++,ye.paraStart=!0,Oe=!1),ke&&(ye.startCharSize=Le,ye.endCharSize=ke,Le=0),ye.width=be,Me.width?ue(ye):Te&&ze(),De.push(ye),ye={words:[]},be=0}function ze(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const Ve=0,Ye=1,Ge=2;const{top:je,right:Ue,bottom:Xe,left:Ne}=t.Direction4;function qe(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ne],o-=d[Ue]+d[Ne]):n.autoSizeAlign||(i=d[Ne]),a?(s=d[je],a-=d[je]+d[Xe]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){We=e,De=e.rows,Me=e.bounds,Te=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Me;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Le=Re=ke=xe=be=0,ve={data:[]},ye={words:[]};for(let i=0,d=n.length;i<d;i++)Ee=n[i],"\n"===Ee?(xe&&Fe(),ye.paraEnd=!0,He(),Oe=!0):(Pe=de(Ee),Pe===fe&&"none"!==a&&(Ee=he(Ee,a,!xe)),Re=r.measureText(Ee).width,s&&(s<0&&(ke=Re),Re+=s),Ae=Pe===pe&&(Se===pe||Se===fe)||Se===pe&&Pe!==_e,Ce=!(Pe!==ge&&Pe!==pe||Se!==we&&Se!==_e),Be=Oe&&o?l-o:l,t&&l&&be+xe+Re>Be&&(e?(xe&&Fe(),be&&He()):(Ce||(Ce=Pe===fe&&Se==_e),Ae||Ce||Pe===me||Pe===ge||Pe===pe||xe+Re>Be?(xe&&Fe(),be&&He()):be&&He()))," "===Ee&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Ee&&xe&&Fe(),Ie(Ee,Re),Fe()):Ae||Ce?(xe&&Fe(),Ie(Ee,Re)):Ie(Ee,Re)),Se=Pe);xe&&Fe(),be&&He(),De.length>0&&(De[De.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=r.measureText(t).width,De.push({x:o||0,text:t,width:be,paraStart:!0}),Te&&ze()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":qe(e,"x",t[Ne]);break;case"right":qe(e,"x",-t[Ue])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":qe(e,"y",t[je]);break;case"bottom":qe(e,"y",-t[Xe])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Ve:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Je={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:Ze,addPoint:$e,toBounds:Ke}=t.TwoPointBoundsHelper;const tn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){en||(en=new t.TaskProcessor);return new Promise((t=>{en.add((()=>pt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(nn(e),h.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,P),e.fill=t}else e.__render(A,P);if(A.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?$e(r,o,a):Ze(r={},o,a)),l++;const d=new t.Bounds;return Ke(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let en;function nn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>nn(t)))}const sn=t.LeaferCanvasBase.prototype,on=t.Debug.get("@leafer-ui/export");sn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},sn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{on.error(t),i(null)}))}))},sn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},sn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{on.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Qe),Object.assign(e.ColorConvert,Je),Object.assign(e.Paint,T),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,Yt),Object.assign(e.Export,tn),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}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="string"==typeof 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:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.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:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;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),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}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.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:A,getByMove:C,getIntersectData:O}=t.BoundsHelper;let W;function M(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const T={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=M(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=A(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let D={};const{get:I,rotateOfOuter:F,translate:H,scaleOfOuter:z,scale:V,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),V(r,s,o),a&&F(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),s&&V(r,s,o),a&&Y(r,a),t.transform=r}function U(t,e,n,i,s,o,a,r,l,d){const c=I();if(l)if("center"===d)F(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}D.x=e.x+s,D.y=e.y+o,H(c,D.x,D.y),a&&z(c,D,a,r),t.transform=c}const{get:X,translate:N}=t.MatrixHelper,q=new t.Bounds,Q={},J={};function Z(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=$(n,i,e)}function $(e,n,i){let{width:s,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,J),v=J.scaleX,y=J.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,Q,!0),x+=Q.x,b+=Q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&U(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&G(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=X(),N(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let K,tt=new t.Bounds;const{isSame:et}=t.BoundsHelper;function nt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Z(s,i,n,o),!0}function it(e,n){at(e,t.ImageEvent.LOAD,n)}function st(e,n){at(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:lt,scale:dt,copy:ct}=t.MatrixHelper,{ceil:ht,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=lt(),ct(d,g),dt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=lt(),g&&ct(d,g)),dt(d,1/s,1/o));const v=e.getCanvas(ht(c)||1,ht(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return K&&i===K.paint&&et(s,K.boxBounds)?a=K.leafPaint:(a={type:i.type,image:l},K=l.use>1?{leafPaint:a,paint:i,boxBounds:tt.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(nt(e,n,i,l,a,s),o&&(it(e,r),st(e,r))):l.error?o&&ot(e,r,l.error):(o&&(rt(e,!0),it(e,r)),a.loadId=l.load((()=>{rt(e,!1),e.destroyed||(nt(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,r)),a.loadId=null}),(t=>{rt(e,!1),ot(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=gt(a)*l,i*=gt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ft(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ft(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Z,getPatternData:$,fillOrFitMode:G,clipMode:j,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},vt={};function yt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:xt,getDistance:bt}=t.PointHelper,{get:Bt,rotateOfOuter:Et,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=xt(e,n);o=Bt(),s?(Rt(o,e,a/r*(i||1),1),Et(o,e,t+90)):(Rt(o,e,1,a/r*(i||1)),Et(o,e,t))}return o}const{getDistance:At}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;wt(i||"top",n,mt),wt(s||"bottom",n,vt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,vt.x,vt.y);yt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const d=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,kt,Pt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,Ot),Ct(s||"bottom",n,Wt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,At(Ot,Wt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,Ot,Wt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Tt,toOffsetOutBounds:Dt}=t.BoundsHelper,It={},Ft={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Tt(It,e.bounds),It.x+=n.x-a.x,It.y+=n.y-a.y,i){const{matrix:t}=s;It.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),It.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),It.width*=i,It.height*=i}e.copyWorld(s.canvas,e.bounds,It)}else i&&(Tt(It,n),It.x-=n.width/2*(i-1),It.y-=n.height/2*(i-1),It.width*=i,It.height*=i),e.copyWorld(s.canvas,a,i?It:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Vt={};const Yt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,Ft),r.forEach(((r,g)=>{f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Ft,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;zt(d,Vt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*h,Vt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Vt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Xt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Xt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ut(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Nt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Nt+"_#~&*+\\=|≮≯≈≠=…",Qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Jt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Jt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Jt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Jt(Nt),te=Jt(qt),ee=Jt("- —/~|┆·");var ne;!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"}(ne||(ne={}));const{Letter:ie,Single:se,Before:oe,After:ae,Symbol:re,Break:le}=ne;function de(t){return Zt[t]?ie:ee[t]?le:$t[t]?oe:Kt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function he(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ae,Ce,Oe,We,Me,Te,De=[];function Ie(t,e){ke&&!Le&&(Le=ke),ve.data.push({char:t,width:e}),xe+=e}function Fe(){be+=xe,ve.width=xe,ye.words.push(ve),ve={data:[]},xe=0}function He(){Oe&&(We.paraNumber++,ye.paraStart=!0,Oe=!1),ke&&(ye.startCharSize=Le,ye.endCharSize=ke,Le=0),ye.width=be,Me.width?ue(ye):Te&&ze(),De.push(ye),ye={words:[]},be=0}function ze(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const Ve=0,Ye=1,Ge=2;const{top:je,right:Ue,bottom:Xe,left:Ne}=t.Direction4;function qe(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ne],o-=d[Ue]+d[Ne]):n.autoSizeAlign||(i=d[Ne]),a?(s=d[je],a-=d[je]+d[Xe]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){We=e,De=e.rows,Me=e.bounds,Te=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Me;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Le=Re=ke=xe=be=0,ve={data:[]},ye={words:[]};for(let i=0,d=n.length;i<d;i++)Ee=n[i],"\n"===Ee?(xe&&Fe(),ye.paraEnd=!0,He(),Oe=!0):(Pe=de(Ee),Pe===fe&&"none"!==a&&(Ee=he(Ee,a,!xe)),Re=r.measureText(Ee).width,s&&(s<0&&(ke=Re),Re+=s),Ae=Pe===pe&&(Se===pe||Se===fe)||Se===pe&&Pe!==_e,Ce=!(Pe!==ge&&Pe!==pe||Se!==we&&Se!==_e),Be=Oe&&o?l-o:l,t&&l&&be+xe+Re>Be&&(e?(xe&&Fe(),be&&He()):(Ce||(Ce=Pe===fe&&Se==_e),Ae||Ce||Pe===me||Pe===ge||Pe===pe||xe+Re>Be?(xe&&Fe(),be&&He()):be&&He()))," "===Ee&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Ee&&xe&&Fe(),Ie(Ee,Re),Fe()):Ae||Ce?(xe&&Fe(),Ie(Ee,Re)):Ie(Ee,Re)),Se=Pe);xe&&Fe(),be&&He(),De.length>0&&(De[De.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=r.measureText(t).width,De.push({x:o||0,text:t,width:be,paraStart:!0}),Te&&ze()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":qe(e,"x",t[Ne]);break;case"right":qe(e,"x",-t[Ue])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":qe(e,"y",t[je]);break;case"bottom":qe(e,"y",-t[Xe])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Ve:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Je={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:Ze,addPoint:$e,toBounds:Ke}=t.TwoPointBoundsHelper;const tn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){en||(en=new t.TaskProcessor);return new Promise((t=>{en.add((()=>pt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(nn(e),h.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,P),e.fill=t}else e.__render(A,P);if(A.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?$e(r,o,a):Ze(r={},o,a)),l++;const d=new t.Bounds;return Ke(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let en;function nn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>nn(t)))}const sn=t.LeaferCanvasBase.prototype,on=t.Debug.get("@leafer-ui/export");sn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},sn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{on.error(t),i(null)}))}))},sn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},sn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{on.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Qe),Object.assign(e.ColorConvert,Je),Object.assign(e.Paint,T),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,Yt),Object.assign(e.Export,tn),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|