@leafer-ui/node 1.6.6 → 1.6.7

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