@leafer-ui/node 1.6.1 → 1.6.3

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.
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as o,defineKey as a,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as C}from"fs";import{HitCanvasManager as O,InteractionBase as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,TwoPointBoundsHelper as j,Bounds as z,FileHelper as G,Platform as q,Matrix as H,MathHelper as V,Creator as Q,TaskProcessor as J,Resource as Z,LeaferCanvasBase as $,Debug as K,Plugin as tt,UI as et}from"@leafer-ui/draw";function it(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{l(n.next(t))}catch(t){o(t)}}function r(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class nt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:st,fileType:ot}=n;function at(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(st(e),i),canvasToBolb:(t,e,i)=>it(this,void 0,void 0,(function*(){return t.toBuffer(st(e),i)})),canvasSaveAs:(t,e,i)=>it(this,void 0,void 0,(function*(){return C(e,t.toBuffer(st(ot(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new nt(t,e),image:t=>new o(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class rt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:lt,updateBounds:dt,updateAllWorldOpacity:ht}=f,{pushAllChildBranch:ct,pushAllParent:ut}=g;const{worldBounds:ft}=p;class gt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ft)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ft),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:pt,updateAllChange:_t}=f,wt=w.get("Layouter");class yt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(lt(t,!0),e.add(t),t.isBranch&&ct(t,e),ut(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ut(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||dt(n[t])}dt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&ht(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(o,r,this.times)),i.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(i,o,this.times)),yt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){pt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),_t(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const mt=w.get("Renderer");class vt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,mt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,mt.error(t)}mt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return mt.warn("rendering");if(this.times>3)return mt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(vt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||mt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}vt.clipSpread=10;const{hitRadiusPoint:xt}=B;class bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,l=this.getBestMatchLeaf(a,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:a.length?this.getThroughPath(a):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,o={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,o;for(let t=0,a=i.length;t<a;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(o=n.list[t],!s||!s.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||xt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Bt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Rt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function kt(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?Lt(t,!0,e,i):Et(e,i);break;case"inside":St("inside",t,s,e,i);break;case"outside":St("outside",t,s,e,i)}}function St(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?Lt(e,!0,n,r):Et(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",Rt(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 Et(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function Lt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Et(i,n):n.stroke(),n.restoreBlendMode()):e?Et(i,n):n.stroke())}function At(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new rt(t,e),layouter:(t,e)=>new yt(t,e),renderer:(t,e,i)=>new vt(t,e,i),selector:(t,e)=>new Bt(t,e)}),e.layout=yt.fullLayout;const{getSpread:Wt,getOuterOf:Tt,getByMove:Ct,getIntersectData:Ot}=B;let Mt;function Pt(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:D.string(a,r)};case"image":return P.image(i,t,e,n,!Mt||!Mt[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:D.string(e)}:void 0}}const Dt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),Mt=P.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Pt(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?Rt(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&&P.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?Rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?Rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?Rt(e,i):s?i.fill(s):i.fill())},fillText:Rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)kt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&At(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)kt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),Lt(t,!1,e,i),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Lt(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),Lt(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:kt,drawTextStroke:Et,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Ot(n?Wt(e.bounds,d===h?n*d:[n*h,n*d]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=Tt(s,a),o=Ct(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let It={};const{get:Ft,rotateOfOuter:Yt,translate:Ut,scaleOfOuter:Xt,scale:Nt,rotate:jt}=k;function zt(t,e,i,n,s,o,a){const r=Ft();Ut(r,e.x+i,e.y+n),Nt(r,s,o),a&&Yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Gt(t,e,i,n,s,o,a){const r=Ft();Ut(r,e.x+i,e.y+n),s&&Nt(r,s,o),a&&jt(r,a),t.transform=r}function qt(t,e,i,n,s,o,a,r,l,d){const h=Ft();if(l)if("center"===d)Yt(h,{x:i/2,y:n/2},l);else switch(jt(h,l),l){case 90:Ut(h,n,0);break;case 180:Ut(h,i,n);break;case 270:Ut(h,0,i)}It.x=e.x+s,It.y=e.y+o,Ut(h,It.x,It.y),a&&Xt(h,It,a,r),t.transform=h}const{get:Ht,translate:Vt}=k,Qt=new _,Jt={},Zt={};function $t(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,g=e.width===n&&e.height===s,p={mode:a},_="center"!==r&&(c||0)%180==90,w=_?s:n,y=_?n:s;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(d||h)&&(S.getScaleData(d,h,i,Zt),m=Zt.scaleX,v=Zt.scaleY);else if(!g||c){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-n*m)/2,b+=(e.height-s*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),E.toPoint(r,t,e,Jt,!0),x+=Jt.x,b+=Jt.y}switch(l&&(x+=l.x,b+=l.y),a){case"stretch":g||(n=e.width,s=e.height);break;case"normal":case"clip":(x||b||m||c)&&Gt(p,e,x,b,m,v,c);break;case"repeat":(!g||m||c)&&qt(p,e,n,s,x,b,m,v,c,r),u||(p.repeat="repeat");break;default:m&&zt(p,e,x,b,m,v,c)}return p.transform||(e.x||e.y)&&(p.transform=Ht(),Vt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=n,p.height=s,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let te,ee=new _;const{isSame:ie}=B;function ne(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||$t(s,n,i,o),!0}function se(t,e){re(t,L.LOAD,e)}function oe(t,e){re(t,L.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,L.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function le(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:he,copy:ce}=k,{ceil:ue,abs:fe}=Math;function ge(t,i,n){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||t.destroyed)return!1;{s=fe(s),o=fe(o);const{image:t,data:r}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(d=de(),ce(d,g),he(d,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const _=h*c;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,h/=l,c/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=de(),g&&ce(d,g)),he(d,1/s,1/o));const y=t.getCanvas(ue(h)||1,ue(c)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=a,!0}}const{abs:pe}=Math;const _e={image:function(t,e,i,n,s){let o,a;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?o=te.leafPaint:(o={type:i.type,image:r},te=r.use>1?{leafPaint:o,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,o,n),s&&(se(t,a),oe(t,a))):r.error?s&&ae(t,a,r.error):(s&&(le(t,!0),se(t,a)),o.loadId=r.load((()=>{le(t,!1),t.destroyed||(ne(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,a)),o.loadId=null}),(e=>{le(t,!1),ae(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=n;if(!l||n.patternId===o+"-"+a+"-"+r&&!F.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||F.running)){let{width:t,height:i}=l;t*=pe(o)*r,i*=pe(a)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||F.running?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>it(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a,r;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,x.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:$t,getPatternData:Kt,fillOrFitMode:zt,clipMode:Gt,repeatMode:qt},{toPoint:we}=A,ye={},me={};function ve(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),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:xe,getDistance:be}=W,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Se}=A,Ee={},Le={};function Ae(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=xe(e,i);o=Be(),s?(ke(o,e,a/r*(n||1),1),Re(o,e,t+90)):(ke(o,e,1,a/r*(n||1)),Re(o,e,t))}return o}const{getDistance:We}=W,{toPoint:Te}=A,Ce={},Oe={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;we(n||"top",i,ye),we(s||"bottom",i,me);const l=e.canvas.createLinearGradient(ye.x,ye.y,me.x,me.y);ve(l,t.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=t;Se(n||"center",i,Ee),Se(s||"bottom",i,Le);const d=e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,be(Ee,Le));ve(d,t.stops,a);const h={type:o,style:d},c=Ae(i,Ee,Le,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=t;Te(n||"center",i,Ce),Te(s||"bottom",i,Oe);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Ce.x,Ce.y):e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,We(Ce,Oe));ve(d,t.stops,a);const h={type:o,style:d},c=Ae(i,Ce,Oe,l||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ae},{copy:Pe,toOffsetOutBounds:De}=B,Ie={},Fe={};function Ye(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(Pe(Ie,t.bounds),Ie.x+=i.x-a.x,Ie.y+=i.y-a.y,n){const{matrix:t}=s;Ie.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Ie.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Ie.width*=n,Ie.height*=n}t.copyWorld(s.canvas,t.bounds,Ie)}else n&&(Pe(Ie,i),Ie.x-=i.width/2*(n-1),Ie.y-=i.height/2*(n-1),Ie.width*=n,Ie.height*=n),t.copyWorld(s.canvas,a,n?Ie:i)}const{toOffsetOutBounds:Ue}=B,Xe={};const Ne={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(d,Fe),r.forEach(((r,p)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,D.string(r.color)),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ye(f,Fe,s,i),n=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),n=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ue(d,Xe),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*c,Xe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ye(f,Xe,s,i),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,d,"source-out"),n=d),f.fillWorld(n,D.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:je}=p;function ze(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),qe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":qe(t,i,n,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function qe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r&&(a&&(ze(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=Ge(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Ge(t)),s||(s=Ge(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);ze(this,a,t,s,n,o)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=He+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Je(He),ti=Je(Ve),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:ni,Single:si,Before:oi,After:ai,Symbol:ri,Break:li}=ii;function di(t){return Ze[t]?ni:ei[t]?li:$e[t]?oi:Ke[t]?ai:ti[t]?ri:Qe.test(t)?si:ni}const hi={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 ci(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:ui}=hi,{Letter:fi,Single:gi,Before:pi,After:_i,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Wi,Ti,Ci,Oi,Mi,Pi,Di=[];function Ii(t,e){Ei&&!Si&&(Si=Ei),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Yi(){Ci&&(Oi.paraNumber++,vi.paraStart=!0,Ci=!1),Ei&&(vi.startCharSize=Si,vi.endCharSize=Ei,Si=0),vi.width=bi,Mi.width?ui(vi):Pi&&Ui(),Di.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Oi.maxWidth||0)&&(Oi.maxWidth=bi)}const{top:Xi,right:Ni,bottom:ji,left:zi}=T;function Gi(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 qi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(o?(n=d[zi],o-=d[Ni]+d[zi]):i.autoSizeAlign||(n=d[zi]),a?(s=d[Xi],a-=d[Xi]+d[ji]):i.autoSizeAlign||(s=d[Xi]));const h={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Oi=t,Di=t.rows,Mi=t.bounds,Pi=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:l,height:d}=Mi;if(l||d||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ci=!0,Ai=null,Si=ki=Ei=xi=bi=0,mi={data:[]},vi={words:[]};for(let n=0,d=i.length;n<d;n++)Ri=i[n],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Yi(),Ci=!0):(Li=di(Ri),Li===fi&&"none"!==a&&(Ri=ci(Ri,a,!xi)),ki=r.measureText(Ri).width,s&&(s<0&&(Ei=ki),ki+=s),Wi=Li===gi&&(Ai===gi||Ai===fi)||Ai===gi&&Li!==_i,Ti=!(Li!==pi&&Li!==gi||Ai!==wi&&Ai!==_i),Bi=Ci&&o?l-o:l,t&&l&&bi+xi+ki>Bi&&(e?(xi&&Fi(),bi&&Yi()):(Ti||(Ti=Li===fi&&Ai==_i),Wi||Ti||Li===yi||Li===pi||Li===gi||xi+ki>Bi?(xi&&Fi(),bi&&Yi()):bi&&Yi()))," "===Ri&&!0!==Ci&&bi+xi===0||(Li===yi?(" "===Ri&&xi&&Fi(),Ii(Ri,ki),Fi()):Wi||Ti?(xi&&Fi(),Ii(Ri,ki)):Ii(Ri,ki)),Ai=Li);xi&&Fi(),bi&&Yi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Oi.paraNumber++,bi=r.measureText(t).width,Di.push({x:o||0,text:t,width:bi,paraStart:!0}),Pi&&Ui()}))}(h,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[zi]);break;case"right":Gi(e,"x",-t[Ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Xi]);break;case"bottom":Gi(e,"y",-t[ji])}}(d,h,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),y=a;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,h=s;a<h;a++){if(m=i[a],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&a>0&&(y+=c),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,d,h,c,u;n.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,h=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,o),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,h=n+s-d;("none"===i.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],l=t.x+t.width,!(n===i&&l<h));n--){if(l<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,o),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=D.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const Hi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.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+")"}};Object.assign(U,qi),Object.assign(D,Hi),Object.assign(X,Dt),Object.assign(P,_e),Object.assign(I,Me),Object.assign(N,Ne);const{setPoint:Vi,addPoint:Qi,toBounds:Ji}=j;const Zi={syncExport(t,e,i){let n;this.running=!0;const s=G.fileType(e),o=e.includes(".");i=G.getExportOptions(i);const{toURL:a}=q,{download:r}=q.origin;if("json"===s)o&&r(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===s)o&&r(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let s,o,a=1,r=1;const{worldTransform:l,isLeafer:d,leafer:h,isFrame:c}=t,{slice:u,trim:f,padding:g,onCanvas:p}=i,_=void 0===i.smooth?!h||h.config.smooth:i.smooth,w=i.contextSettings||(h?h.config.contextSettings:void 0),y=i.screenshot||t.isApp,m=d&&y&&void 0===i.fill?t.fill:i.fill,v=G.isOpaqueImage(e)||m,x=new H;if(y)s=!0===y?d?h.canvas.bounds:t.worldRenderBounds:y;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),a/=t.scaleX,r/=t.scaleY;break;case"world":a=1,r=1;break;case"page":e=h||t;default:x.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};V.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:R,y:k,width:S,height:E}=new z(s).scale(b.scaleX,b.scaleY),L={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-k).withScale(1/a*b.scaleX,1/r*b.scaleY)};let A,W=Q.canvas({width:Math.floor(S),height:Math.floor(E),pixelRatio:B,smooth:_,contextSettings:w});if(u&&(A=t,A.__worldOpacity=0,t=h||t,L.bounds=W.bounds),W.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(W,L),t.fill=e}else t.__render(W,L);if(W.restore(),A&&A.__updateWorldOpacity(),f){o=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?Qi(a,s,o):Vi(a={},s,o)),r++;const l=new z;return Ji(a,l),l.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:B};W=Q.canvas(n),W.copyWorld(t,o,n)}if(g){const[t,e,i,n]=V.fourNumber(g),s=W,{width:o,height:a}=s;W=Q.canvas({width:o+n+e,height:a+t+i,pixelRatio:B}),W.copyWorld(s,s.bounds,{x:n,y:t,width:o,height:a})}v&&W.fillWorld(W.bounds,m||"#FFFFFF","destination-over"),p&&p(W);n={data:"canvas"===e?W:W.export(e,i),width:W.pixelWidth,height:W.pixelHeight,renderBounds:s,trimBounds:o}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){$i||($i=new J);return new Promise((e=>{$i.add((()=>it(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const o=()=>it(this,void 0,void 0,(function*(){if(!Z.isComplete)return q.requestRender(o);const a=Zi.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),n(a),s()}));t.updateLayout(),Ki(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))))}};let $i;function Ki(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ki(t)))}const tn=$.prototype,en=K.get("@leafer-in/export");tn.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},tn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},tn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},tt.add("export"),Object.assign(F,Zi),et.prototype.export=function(t,e){return F.export(this,t,e)},et.prototype.syncExport=function(t,e){return F.syncExport(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new nt(t,e),hitCanvasManager:()=>new O});export{yt as Layouter,nt as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,rt as Watcher,at as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as S,AlignHelper as E,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as W}from"fs";import{Platform as O,HitCanvasManager as P,InteractionBase as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as I,PaintGradient as F,Export as Y,Group as U,TextConvert as X,Paint as N,Effect as j,TwoPointBoundsHelper as z,Bounds as G,FileHelper as q,Platform as H,Matrix as V,MathHelper as Q,Creator as J,TaskProcessor as Z,Resource as $,LeaferCanvasBase as K,Debug as tt,Plugin as et,UI as it}from"@leafer-ui/draw";function nt(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class st extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:at,fileType:ot}=n;function rt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(at(e),i),canvasToBolb:(t,e,i)=>nt(this,void 0,void 0,(function*(){return t.toBuffer(at(e),i)})),canvasSaveAs:(t,e,i)=>nt(this,void 0,void 0,(function*(){return W(e,t.toBuffer(at(ot(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new st(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class lt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:dt,updateBounds:ct,updateChange:ht}=f,{pushAllChildBranch:ut,pushAllParent:ft}=p;const{worldBounds:pt}=g;class gt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,pt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,pt),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:_t,updateAllChange:wt}=f,yt=w.get("Layouter");class mt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){yt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?yt.warn("layouting"):this.times>3?yt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(dt(t,!0),e.add(t),t.isBranch&&ut(t,e),ft(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ft(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||ct(n[t])}ct(i)}}))}(this.__levelList),function(t){t.list.forEach(ht)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),mt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),wt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const vt=w.get("Renderer");class xt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,vt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,vt.error(t)}vt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return vt.warn("rendering");if(this.times>3)return vt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(xt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||vt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}xt.clipSpread=10;const{hitRadiusPoint:bt}=B;class Bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||bt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class kt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Bt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Rt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function St(t,e){t.__.__font?Rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}Object.assign(s,{watcher:(t,e)=>new lt(t,e),layouter:(t,e)=>new mt(t,e),renderer:(t,e,i)=>new xt(t,e,i),selector:(t,e)=>new kt(t,e)}),e.layout=mt.fullLayout;const Et={};function Lt(t,e,i){switch(e.__.strokeAlign){case"center":At(t,1,e,i);break;case"inside":Tt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,i):Tt(t,"outside",e,i)}}function At(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?Wt(t,!0,i,n):Ct(i,n)}function Tt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,At(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",Rt(i,s),s.blendMode="normal",i.__worldFlipped||O.fullImageShadow?n.copyWorldByReset(s,i.__nowWorld):n.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function Ct(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function Wt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Ct(i,n):n.stroke(),n.restoreBlendMode()):e?Ct(i,n):n.stroke())}function Ot(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)Lt(t,e,i);else switch(n.strokeAlign){case"center":Pt(t,1,e,i);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),Pt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)Pt(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Pt(t,2,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(s),e.__worldFlipped||O.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,s),a.recycle(e.__nowWorld)}}(t,e,i)}}function Pt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?Wt(t,!1,i,n):n.stroke(),s.__useArrow&&Et.strokeArrow(t,i,n)}const{getSpread:Mt,getOuterOf:Dt,getByMove:It,getIntersectData:Ft}=B;let Yt;const{stintSet:Ut}=l,{hasTransparent:Xt}=I;function Nt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout;switch(e.type){case"image":n=D.image(i,t,e,s,!Yt||!Yt[e.url]);break;case"linear":n=F.linearGradient(e,s);break;case"radial":n=F.radialGradient(e,s);break;case"angular":n=F.conicGradient(e,s);break;case"solid":const{type:a,blendMode:o,color:r,opacity:l}=e;n={type:a,blendMode:o,style:I.string(r,l)};break;default:void 0!==e.r&&(n={type:"solid",style:I.string(e)})}return n&&("string"==typeof n.style&&Xt(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const jt={compute:function(t,e){const i=e.__,n=[];let s,a,o=i.__input[t];o instanceof Array||(o=[o]),Yt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Nt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n.every((t=>t.isTransparent))&&(n.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(Ut(i,"__isAlphaPixelFill",s),Ut(i,"__isTransparentFill",a)):(Ut(i,"__isAlphaPixelStroke",s),Ut(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,St(e,i)},fills:function(t,e,i){let n;for(let s=0,a=t.length;s<a;s++){if(n=t[s],n.image){if(D.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),St(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:Rt,stroke:Ot,strokes:function(t,e,i){Ot(t,e,i)},strokeText:Lt,drawTextStroke:Ct,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Ft(n?Mt(e.bounds,d===c?n*d:[n*c,n*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,c*=f),r=Dt(s,o),a=It(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let zt={};const{get:Gt,rotateOfOuter:qt,translate:Ht,scaleOfOuter:Vt,scale:Qt,rotate:Jt}=R;function Zt(t,e,i,n,s,a,o){const r=Gt();Ht(r,e.x+i,e.y+n),Qt(r,s,a),o&&qt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function $t(t,e,i,n,s,a,o){const r=Gt();Ht(r,e.x+i,e.y+n),s&&Qt(r,s,a),o&&Jt(r,o),t.transform=r}function Kt(t,e,i,n,s,a,o,r,l,d){const c=Gt();if(l)if("center"===d)qt(c,{x:i/2,y:n/2},l);else switch(Jt(c,l),l){case 90:Ht(c,n,0);break;case 180:Ht(c,i,n);break;case 270:Ht(c,0,i)}zt.x=e.x+s,zt.y=e.y+a,Ht(c,zt.x,zt.y),o&&Vt(c,zt,o,r),t.transform=c}const{get:te,translate:ee}=R,ie=new _,ne={},se={};function ae(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=oe(i,n,e)}function oe(t,e,i){t.padding&&(e=ie.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(h||0)%180==90;let w,y;switch(B.set(se,0,0,_?s:n,_?n:s),o&&"cover"!==o&&"fit"!==o?((d||c)&&(S.getScaleData(d,c,i,ne),w=ne.scaleX,y=ne.scaleY),r&&(w&&B.scale(se,w,y,!0),E.toPoint(r,se,e,se,!0,!0))):p&&!h||(w=y=B.getFitScale(e,se,"fit"!==o),B.put(e,i,r,w,!1,se),B.scale(se,w,y,!0)),l&&L.move(se,l),o){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(se.x||se.y||w||h)&&$t(g,e,se.x,se.y,w,y,h);break;case"repeat":(!p||w||h)&&Kt(g,e,n,s,se.x,se.y,w,y,h,r),u||(g.repeat="repeat");break;default:w&&Zt(g,e,se.x,se.y,w,y,h)}return g.transform||(e.x||e.y)&&(g.transform=te(),ee(g.transform,e.x,e.y)),w&&"stretch"!==o&&(g.scaleX=w,g.scaleY=y),g.width=n,g.height=s,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let re,le=new _;const{isSame:de}=B;function ce(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||ae(s,n,i,a),!0}function he(t,e){pe(t,A.LOAD,e)}function ue(t,e){pe(t,A.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),pe(t,A.ERROR,e)}function pe(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function ge(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=R,{ceil:me,abs:ve}=Math;function xe(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=ve(s),a=ve(a);const{image:t,data:r}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=_e(),ye(d,p),we(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,c*=s,h*=a;const _=c*h;if(!g&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=_e(),p&&ye(d,p)),we(d,1/s,1/a));const y=t.getCanvas(me(c)||1,me(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:be}=Math;const Be={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return re&&i===re.paint&&de(n,re.boxBounds)?a=re.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),re=r.use>1?{leafPaint:a,paint:i,boxBounds:le.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ce(t,e,i,r,a,n),s&&(he(t,o),ue(t,o))):r.error?s&&fe(t,o,r.error):(s&&(ge(t,!0),he(t,o)),a.loadId=r.load((()=>{ge(t,!1),t.destroyed||(ce(t,e,i,r,a,n)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,o)),a.loadId=null}),(e=>{ge(t,!1),fe(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=n;if(!l||n.patternId===a+"-"+o+"-"+r&&!Y.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||Y.running)){let{width:t,height:i}=l;t*=be(a)*r,i*=be(o)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||Y.running?xe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>nt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&xe(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:xe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o,r;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,x.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:ae,getPatternData:oe,fillOrFitMode:Zt,clipMode:$t,repeatMode:Kt},{toPoint:ke}=T,{hasTransparent:Re}=I,Se={},Ee={};function Le(t,e,i,n){if(i){let s,a,o,r;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(o=t/(l-1),a=I.string(s,n)):(o=s.offset,a=I.string(s.color,n)),e.addColorStop(o,a),!r&&Re(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Ae,getDistance:Te}=L,{get:Ce,rotateOfOuter:We,scaleOfOuter:Oe}=R,{toPoint:Pe}=T,Me={},De={};function Ie(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=Ae(e,i);a=Ce(),s?(Oe(a,e,o/r*(n||1),1),We(a,e,t+90)):(Oe(a,e,1,o/r*(n||1)),We(a,e,t))}return a}const{getDistance:Fe}=L,{toPoint:Ye}=T,Ue={},Xe={};const Ne={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:o}=t;ke(n||"top",i,Se),ke(s||"bottom",i,Ee);const r=e.canvas.createLinearGradient(Se.x,Se.y,Ee.x,Ee.y),l={type:a,style:r};return Le(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Pe(n||"center",i,Me),Pe(s||"bottom",i,De);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Te(Me,De)),d={type:a,style:l};Le(d,l,t.stops,o);const c=Ie(i,Me,De,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Ye(n||"center",i,Ue),Ye(s||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ue.x,Ue.y):e.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Fe(Ue,Xe)),d={type:a,style:l};Le(d,l,t.stops,o);const c=Ie(i,Ue,Xe,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ie},{copy:je,toOffsetOutBounds:ze}=B,Ge={},qe={};function He(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(je(Ge,t.bounds),Ge.x+=i.x-o.x,Ge.y+=i.y-o.y,n){const{matrix:t}=s;Ge.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ge.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ge.width*=n,Ge.height*=n}t.copyWorld(s.canvas,t.bounds,Ge)}else n&&(je(Ge,i),Ge.x-=i.width/2*(n-1),Ge.y-=i.height/2*(n-1),Ge.width*=n,Ge.height*=n),t.copyWorld(s.canvas,o,n?Ge:i)}const{toOffsetOutBounds:Ve}=B,Qe={};const Je={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ze(d,qe),r.forEach(((r,g)=>{f.setWorldShadow(qe.offsetX+r.x*h,qe.offsetY+r.y*u,r.blur*h,I.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,qe,s,i),n=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),n=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ve(d,Qe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Qe.offsetX+r.x*h,Qe.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,Qe,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,c,d,"source-out"),n=d),f.fillWorld(n,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ze}=g;function $e(t,e,i,n,s,a){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),ti(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ti(t,i,n,a);break;case"path":i.restore()}}function Ke(t){return t.getSameCanvas(!1,!0)}function ti(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}U.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)i=l[d],r=i.__.mask,r&&(o&&($e(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ke(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ke(t)),s||(s=Ke(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Ze(i,e)||i.__render(s||t,e);$e(this,o,t,s,n,a)};const ei=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ii=ei+"_#~&*+\\=|≮≯≈≠=…",ni=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 si(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ai=si("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oi=si("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ri=si(ei),li=si(ii),di=si("- —/~|┆·");var ci;!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"}(ci||(ci={}));const{Letter:hi,Single:ui,Before:fi,After:pi,Symbol:gi,Break:_i}=ci;function wi(t){return ai[t]?hi:di[t]?_i:oi[t]?fi:ri[t]?pi:li[t]?gi:ni.test(t)?ui:hi}const yi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function mi(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:vi}=yi,{Letter:xi,Single:bi,Before:Bi,After:ki,Symbol:Ri,Break:Si}=ci;let Ei,Li,Ai,Ti,Ci,Wi,Oi,Pi,Mi,Di,Ii,Fi,Yi,Ui,Xi,Ni,ji,zi=[];function Gi(t,e){Mi&&!Pi&&(Pi=Mi),Ei.data.push({char:t,width:e}),Ai+=e}function qi(){Ti+=Ai,Ei.width=Ai,Li.words.push(Ei),Ei={data:[]},Ai=0}function Hi(){Ui&&(Xi.paraNumber++,Li.paraStart=!0,Ui=!1),Mi&&(Li.startCharSize=Pi,Li.endCharSize=Mi,Pi=0),Li.width=Ti,Ni.width?vi(Li):ji&&Vi(),zi.push(Li),Li={words:[]},Ti=0}function Vi(){Ti>(Xi.maxWidth||0)&&(Xi.maxWidth=Ti)}const{top:Qi,right:Ji,bottom:Zi,left:$i}=C;function Ki(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 tn={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(n=d[$i],a-=d[Ji]+d[$i]):i.autoSizeAlign||(n=d[$i]),o?(s=d[Qi],o-=d[Qi]+d[Zi]):i.autoSizeAlign||(s=d[Qi]));const c={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Xi=t,zi=t.rows,Ni=t.bounds,ji=!Ni.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:l,height:d}=Ni;if(l||d||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ui=!0,Ii=null,Pi=Oi=Mi=Ai=Ti=0,Ei={data:[]},Li={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Wi=i[n],"\n"===Wi?(Ai&&qi(),Li.paraEnd=!0,Hi(),Ui=!0):(Di=wi(Wi),Di===xi&&"none"!==o&&(Wi=mi(Wi,o,!Ai)),Oi=r.measureText(Wi).width,s&&(s<0&&(Mi=Oi),Oi+=s),Fi=Di===bi&&(Ii===bi||Ii===xi)||Ii===bi&&Di!==ki,Yi=!(Di!==Bi&&Di!==bi||Ii!==Ri&&Ii!==ki),Ci=Ui&&a?l-a:l,t&&l&&Ti+Ai+Oi>Ci&&(e?(Ai&&qi(),Ti&&Hi()):(Yi||(Yi=Di===xi&&Ii==ki),Fi||Yi||Di===Si||Di===Bi||Di===bi||Ai+Oi>Ci?(Ai&&qi(),Ti&&Hi()):Ti&&Hi()))," "===Wi&&!0!==Ui&&Ti+Ai===0||(Di===Si?(" "===Wi&&Ai&&qi(),Gi(Wi,Oi),qi()):Fi||Yi?(Ai&&qi(),Gi(Wi,Oi)):Gi(Wi,Oi)),Ii=Di);Ai&&qi(),Ti&&Hi(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Xi.paraNumber++,Ti=r.measureText(t).width,zi.push({x:a||0,text:t,width:Ti,paraStart:!0}),ji&&Vi()}))}(c,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ki(e,"x",t[$i]);break;case"right":Ki(e,"x",-t[Ji])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ki(e,"y",t[Qi]);break;case"bottom":Ki(e,"y",-t[Zi])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;n.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=n+s-d;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===i&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,a),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=I.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const en={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.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+")"}};Object.assign(X,tn),Object.assign(I,en),Object.assign(N,jt),Object.assign(D,Be),Object.assign(F,Ne),Object.assign(j,Je);const{setPoint:nn,addPoint:sn,toBounds:an}=z;const on={syncExport(t,e,i){let n;this.running=!0;const s=q.fileType(e),a=e.includes(".");i=q.getExportOptions(i);const{toURL:o}=H,{download:r}=H.origin;if("json"===s)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&r(o(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&void 0===i.fill?t.fill:i.fill,x=q.isOpaqueImage(e)||v,b=new V;if(g)s=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,s,B);let k=i.pixelRatio||1,{x:R,y:S,width:E,height:L}=new G(s).scale(B.scaleX,B.scaleY);f&&(R+=f.x,S+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-R,-S).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,C=J.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=C.bounds),C.save(),h&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?sn(o,s,a):nn(o={},s,a)),r++;const l=new G;return an(o,l),l.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:k};C=J.canvas(n),C.copyWorld(t,a,n)}if(_){const[t,e,i,n]=Q.fourNumber(_),s=C,{width:a,height:o}=s;C=J.canvas({width:a+n+e,height:o+t+i,pixelRatio:k}),C.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);n={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){rn||(rn=new Z);return new Promise((e=>{rn.add((()=>nt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const a=()=>nt(this,void 0,void 0,(function*(){if(!$.isComplete)return H.requestRender(a);const o=on.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),n(o),s()}));t.updateLayout(),ln(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let rn;function ln(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ln(t)))}const dn=K.prototype,cn=tt.get("@leafer-in/export");dn.export=function(t,e){const{quality:i,blob:n}=q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},dn.toBlob=function(t,e){return new Promise((i=>{H.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{cn.error(t),i(null)}))}))},dn.toDataURL=function(t,e){return H.origin.canvasToDataURL(this.view,t,e)},dn.saveAs=function(t,e){return new Promise((i=>{H.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{cn.error(t),i(!1)}))}))},et.add("export"),Object.assign(Y,on),it.prototype.export=function(t,e){return Y.export(this,t,e)},it.prototype.syncExport=function(t,e){return Y.syncExport(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new st(t,e),hitCanvasManager:()=>new P});export{mt as Layouter,st as LeaferCanvas,Bt as Picker,xt as Renderer,kt as Selector,lt as Watcher,rt as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map