@leafer-ui/node 1.9.9 → 1.9.11

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,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function o(t){try{l(i.throw(t))}catch(t){r(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(s,o)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class r 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:s,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new r(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,t.isArray(e)&&(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:m}=t.LeafHelper,y=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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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:r,LAYOUT:s,AFTER:o}=t.LayoutEvent,l=this.getBlocks(a);l.forEach(t=>t.setBefore()),i.emitEvent(new t.LayoutEvent(r,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(s,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:r}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),w.fullLayout(n),s.forEach(t=>{t.setAfter()}),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(r,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new 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:120},this.frames=[],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),r=new t.Bounds(a);i.save(),a.spread(x.clipSpread).ceil(),i.clearWorld(a),i.clipWorld(a),this.__render(a,r),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),r=a?{includes:a}:{bounds:e,includes:a};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),t.Platform.render(this.target,i,r),this.renderBounds=n=n||e,this.renderOptions=r,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);this.requestTime=this.frameTime||Date.now();const n=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&e>i)return t.Platform.requestRender(n);const{frames:a}=this;a.length>30&&a.shift(),a.push(e),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(n)}__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.config={},this.target=this.canvas=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,r=i.ignoreHittable||!1,s=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(s.isBranchLeaf?{children:[s]}:s);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,r),d=r?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}}hitPoint(t,e,n){return!!this.getByPoint(t,e,n).target}getBestMatchLeaf(e,n,i){const a=this.findList=new t.LeafList;if(e.length){let n;const{x:r,y:s}=this.point,o={x:r,y:s,radiusX:0,radiusY:0};for(let r=0,s=e.length;r<s;r++)if(n=e[r],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),a.length)){if(n.isBranchLeaf&&e.some(e=>e!==n&&t.LeafHelper.hasParent(e,n))){a.reset();break}return a.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),a.length)return a.list[0];return i?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}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&&(!i.isLeafer||"draw"!==i.mode));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,r,s;for(let t=0,e=i.length;t<e;t++){a=i[t],r=i[t+1];for(let t=0,e=a.length;t<e&&(s=a.list[t],!r||!r.has(s));t++)n.add(s)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let r=t.length-1;r>-1;r--)n=t[r],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(n.topChildren&&this.eachFind(n.topChildren,!1),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){let n,a=[];const{children:r}=i;for(let i=0,s=r.length;i<s;i++)if(n=r[i],n.__.mask&&a.push(n),n===t){if(a&&!a.every(t=>t.__hitWorld(e)))return;break}}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:r}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),r.getByPoint(e,n,i)}hitPoint(t,e,n){return this.picker.hitPoint(t,e,n)}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 r;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)r=i[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:r}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>a.forEach(n=>e.fillRect(t.x,t.y+n,t.width,r)))}}function S(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function R(t,e,n){switch(e.__.strokeAlign){case"center":k(t,1,e,n);break;case"inside":P(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?k(t,2,e,n):P(t,"outside",e,n)}}function k(e,n,i,a){const r=i.__;t.isObject(e)?A(e,n,!0,i,a):(a.setStroke(e,r.__strokeWidth*n,r),C(i,a))}function P(e,n,i,a){const r=a.getSameCanvas(!0,!0);r.font=i.__.__font,k(e,2,i,r),r.blendMode="outside"===n?"destination-out":"destination-in",L(i,r),r.blendMode="normal",t.LeafHelper.copyCanvasByWorld(i,a,r),r.recycle(i.__nowWorld)}function C(t,e){let n,i=t.__.__textDrawData;const{rows:a,decorationY:r}=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(r){const{decorationHeight:t}=i;a.forEach(n=>r.forEach(i=>e.strokeRect(n.x,n.y+i,n.width,t)))}}function A(t,e,n,a,r){let s;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||r.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(s=t[d],(!s.image||!i.PaintImage.checkImage(a,r,s,!1))&&s.style){if(l){const{strokeStyle:t}=s;t?r.setStroke(s.style,o.__getRealStrokeWidth(t)*e,o,t):r.setStroke(s.style,o.__strokeWidth*e,o)}else r.strokeStyle=s.style;s.blendMode?(r.saveBlendMode(s.blendMode),n?C(a,r):r.stroke(),r.restoreBlendMode()):n?C(a,r):r.stroke()}}function T(e,n,i){const a=n.__;if(a.__strokeWidth)if(a.__font)R(e,n,i);else switch(a.strokeAlign){case"center":O(e,1,n,i);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),O(t,2,e,n),n.restore()}(e,n,i);break;case"outside":!function(e,n,i){const a=n.__;if(a.__fillAfterStroke)O(e,2,n,i);else{const{renderBounds:r}=n.__layout,s=i.getSameCanvas(!0,!0);n.__drawRenderPath(s),O(e,2,n,s),s.clipUI(a),s.clearWorld(r),t.LeafHelper.copyCanvasByWorld(n,i,s),s.recycle(n.__nowWorld)}}(e,n,i)}}function O(e,n,a,r){const s=a.__;t.isObject(e)?A(e,n,!1,a,r):(r.setStroke(e,s.__strokeWidth*n,s),r.stroke()),s.__useArrow&&i.Paint.strokeArrow(e,a,r)}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,t.Platform.render=function(e,n,i){const a=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new t.LeafList,e.__render(n,i),i.topList.length&&i.topList.forEach(t=>t.__render(n,a))};const{getSpread:M,copyAndSpread:W,toOuterOf:H,getOuterOf:D,getByMove:I,move:F,getIntersectData:U}=t.BoundsHelper,j={};let Y;const{stintSet:X}=t.DataHelper,{hasTransparent:q}=i.ColorConvert;function z(e,n,a){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let r;const{boxBounds:s}=a.__layout;switch(n.type){case"image":r=i.PaintImage.image(a,e,n,s,!Y||!Y[n.url]);break;case"linear":r=i.PaintGradient.linearGradient(n,s);break;case"radial":r=i.PaintGradient.radialGradient(n,s);break;case"angular":r=i.PaintGradient.conicGradient(n,s);break;case"solid":const{type:o,color:l,opacity:d}=n;r={type:o,style:i.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(r={type:"solid",style:i.ColorConvert.string(n)})}if(r){if(t.isString(r.style)&&q(r.style)&&(r.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;r.strokeStyle=n.style}n.editing&&(r.editing=n.editing),n.blendMode&&(r.blendMode=n.blendMode)}return r}const G={compute:function(e,n){const a=n.__,r=[];let s,o,l,d=a.__input[e];t.isArray(d)||(d=[d]),Y=i.PaintImage.recycleImage(e,a);for(let t,i=0,a=d.length;i<a;i++)(t=z(e,d[i],n))&&(r.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));a["_"+e]=r.length?r:void 0,r.length&&r.every(t=>t.isTransparent)&&(r.some(t=>t.image)&&(s=!0),o=!0),"fill"===e?(X(a,"__isAlphaPixelFill",s),X(a,"__isTransparentFill",o)):(X(a,"__isAlphaPixelStroke",s),X(a,"__isTransparentStroke",o),X(a,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,S(e,n)},fills:function(t,e,n){let a;for(let r=0,s=t.length;r<s;r++){if(a=t[r],a.image){if(i.PaintImage.checkImage(e,n,a,!e.__.__font))continue;if(!a.style){!r&&a.image.isPlacehold&&e.drawImagePlaceholder(n,a.image);continue}}if(n.fillStyle=a.style,a.transform||a.scaleFixed){if(n.save(),a.transform&&n.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&i>1)&&n.scale(1/t,1/i)}a.blendMode&&(n.blendMode=a.blendMode),S(e,n),n.restore()}else a.blendMode?(n.saveBlendMode(a.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:L,stroke:T,strokes:function(t,e,n){T(t,e,n)},strokeText:R,drawTextStroke:C,shape:function(e,n,i){const a=n.getSameCanvas(),r=n.bounds,s=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;H(o.strokeSpread?(W(j,o.boxBounds,o.strokeSpread),j):o.boxBounds,s,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(r.includes(l))p=a,d=f=l,c=s;else{let a;if(t.Platform.fullImageShadow)a=l;else{const e=o.renderShapeSpread?M(r,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):r;a=U(e,l)}u=r.getFitMatrix(a);let{a:m,d:y}=u;u.a<1&&(p=n.getSameCanvas(),e.__renderShape(p,i),g*=m,_*=y),f=D(l,u),d=I(f,-u.e,-u.f),c=D(s,u),F(c,-u.e,-u.f);const w=i.matrix;w?(h=new t.Matrix(u),h.multiply(w),m*=w.scaleX,y*=w.scaleY):h=u,h.withScale(m,y),i=Object.assign(Object.assign({},i),{matrix:h})}return e.__renderShape(a,i),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let N={},V=t.getMatrixData();const{get:Q,rotateOfOuter:J,translate:Z,scaleOfOuter:K,multiplyParent:$,scale:tt,rotate:et,skew:nt}=t.MatrixHelper;function it(t,e,n,i,a,r,s){const o=Q();Z(o,e.x+n,e.y+i),tt(o,a,r),s&&J(o,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=o}function at(t,e,n,i,a,r,s,o,l,d){const c=Q();st(c,e,n,i,a,r,s,o),l&&(V.a=l,V.d=d,$(c,V)),t.transform=c}function rt(t,e,n,i,a,r,s,o,l,d,c,h){const u=Q();if(h)st(u,e,a,r,s,o,l,d);else{if(l)if("center"===c)J(u,{x:n/2,y:i/2},l);else switch(et(u,l),l){case 90:Z(u,i,0);break;case 180:Z(u,n,i);break;case 270:Z(u,0,n)}N.x=e.x+a,N.y=e.y+r,Z(u,N.x,N.y),s&&K(u,N,s,o)}t.transform=u}function st(t,e,n,i,a,r,s,o){s&&et(t,s),o&&nt(t,o.x,o.y),a&&tt(t,a,r),Z(t,e.x+n,e.y+i)}const{get:ot,translate:lt}=t.MatrixHelper,dt=new t.Bounds,ct={},ht={};function ut(t,e,n,i){const{changeful:a,sync:r,scaleFixed:s}=n;a&&(t.changeful=a),r&&(t.sync=r),s&&(t.scaleFixed=s),t.data=ft(n,i,e)}function ft(e,n,i){e.padding&&(n=dt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:a,height:r}=i;const{opacity:s,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===a&&n.height===r,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(ht,0,0,v?r:a,v?a:r),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,i,ct),x=ct.scaleX,b=ct.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(ht,x,b,!0),l&&t.AlignHelper.toPoint(l,ht,n,ht,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,ht,"fit"!==o),t.BoundsHelper.put(n,i,l,x,!1,ht),t.BoundsHelper.scale(ht,x,b,!0)),d&&t.PointHelper.move(ht,d),o){case"stretch":y||(a=n.width,r=n.height);break;case"normal":case"clip":if(ht.x||ht.y||x||p||u||f){let t,e;p&&(t=n.width/p.width,e=n.height/p.height),at(w,n,ht.x,ht.y,x,b,u,f,t,e),t&&(x=x?x*t:x,b=b?b*e:e)}break;case"repeat":(!y||x||u||f)&&rt(w,n,a,r,ht.x,ht.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const i=t.isObject(g);(_||i)&&(w.gap=function(e,n,i,a,r){let s,o;t.isObject(e)?(s=e.x,o=e.y):s=o=e;return{x:pt(s,i,r.width,n&&n.x),y:pt(o,a,r.height,n&&n.y)}}(_,i&&g,ht.width,ht.height,n));break;default:x&&it(w,n,ht.x,ht.y,x,b,u)}return w.transform||(n.x||n.y)&&(w.transform=ot(),lt(w.transform,n.x,n.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=a,w.height=r,s&&(w.opacity=s),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function pt(e,n,i,a){const r=t.isString(e)||a?(a?i-a*n:i%n)/((a||Math.floor(i/n))-1):e;return"auto"===e&&r<0?0:r}let gt,_t=new t.Bounds;const{isSame:mt}=t.BoundsHelper;function yt(t,e,n,i,a,r){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||ut(a,i,n,r),!0}function wt(e,n){bt(e,t.ImageEvent.LOAD,n)}function vt(e,n){bt(e,t.ImageEvent.LOADED,n)}function xt(e,n,i){n.error=i,e.forceUpdate("surface"),bt(e,t.ImageEvent.ERROR,n)}function bt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function Bt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Et,scale:Lt,copy:St}=t.MatrixHelper,{floor:Rt,ceil:kt,max:Pt,abs:Ct}=Math;function At(e,n,i){let{scaleX:a,scaleY:r}=e.getRenderScaleData(!0,n.scaleFixed);const s=a+"-"+r+"-"+i;if(n.patternId===s||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;a*=i,r*=i,f&&(f=Ct(f),p=Ct(p),c=Et(),St(c,g),Lt(c,1/f,1/p),a*=f,r*=p),h*=a,u*=r;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/kt(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(a/=d,r/=d,h/=d,u/=d),f&&(a/=f,r/=p);const v=m&&m.x*a,x=m&&m.y*r;if(g||1!==a||1!==r){const t=h+(v||0),e=u+(x||0);a/=t/Pt(Rt(t),1),r/=e/Pt(Rt(e),1),c||(c=Et(),g&&St(c,g)),Lt(c,1/a,1/r)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),B=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=B,n.patternId=s,!0}}const Tt={image:function(e,n,i,a,r){let s,o;const l=t.ImageManager.get(i);return gt&&i===gt.paint&&mt(a,gt.boxBounds)?s=gt.leafPaint:(s={type:i.type,image:l},l.hasAlphaPixel&&(s.isTransparent=!0),gt=l.use>1?{leafPaint:s,paint:i,boxBounds:_t.set(a)}:null),(r||l.loading)&&(o={image:l,attrName:n,attrValue:i}),l.ready?(yt(e,n,i,l,s,a),r&&(wt(e,o),vt(e,o))):l.error?r&&xt(e,o,l.error):(r&&(Bt(e,!0),wt(e,o)),s.loadId=l.load(()=>{Bt(e,!1),e.destroyed||(yt(e,n,i,l,s,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),vt(e,o)),s.loadId=void 0},t=>{Bt(e,!1),xt(e,o,t),s.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),s},checkImage:function(e,n,r,s){const{scaleX:o,scaleY:l}=e.getRenderScaleData(!0,r.scaleFixed),{pixelRatio:d}=n,{data:c}=r;if(!c||r.patternId===o+"-"+l+"-"+d&&!i.Export.running)return!1;if(s)if(c.repeat)s=!1;else if(!(r.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:n}=c;e*=o*d,n*=l*d,c.scaleX&&(e*=c.scaleX,n*=c.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(e.__.__isFastShadow&&(n.fillStyle=r.style||"#000",n.fill()),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,r,c),!0):(!r.style||r.sync||i.Export.running?At(e,r,d):r.patternTask||(r.patternTask=t.ImageManager.patternTasker.add(()=>a(this,void 0,void 0,function*(){r.patternTask=null,n.bounds.hit(e.__nowWorld)&&At(e,r,d),e.forceUpdate("surface")}),300)),!1)},createPattern:At,recycleImage:function(e,n){const i=n["_"+e];if(t.isArray(i)){let a,r,s,o,l;for(let d=0,c=i.length;d<c;d++)a=i[d],r=a.image,l=r&&r.url,l&&(s||(s={}),s[l]=!0,t.ImageManager.recycle(r),r.loading&&(o||(o=n.__input&&n.__input[e]||[],t.isArray(o)||(o=[o])),r.unload(i[d].loadId,!o.some(t=>t.url===l))));return s}return null},createData:ut,getPatternData:ft,fillOrFitMode:it,clipMode:at,repeatMode:rt},{toPoint:Ot}=t.AroundHelper,{hasTransparent:Mt}=i.ColorConvert,Wt={},Ht={};function Dt(e,n,a,r){if(a){let s,o,l,d;for(let e=0,c=a.length;e<c;e++)s=a[e],t.isString(s)?(l=e/(c-1),o=i.ColorConvert.string(s,r)):(l=s.offset,o=i.ColorConvert.string(s.color,r)),n.addColorStop(l,o),!d&&Mt(o)&&(d=!0);d&&(e.isTransparent=!0)}}const{getAngle:It,getDistance:Ft}=t.PointHelper,{get:Ut,rotateOfOuter:jt,scaleOfOuter:Yt}=t.MatrixHelper,{toPoint:Xt}=t.AroundHelper,qt={},zt={};function Gt(t,e,n,i,a){let r;const{width:s,height:o}=t;if(s!==o||i){const t=It(e,n);r=Ut(),a?(Yt(r,e,s/o*(i||1),1),jt(r,e,t+90)):(Yt(r,e,1,s/o*(i||1)),jt(r,e,t))}return r}const{getDistance:Nt}=t.PointHelper,{toPoint:Vt}=t.AroundHelper,Qt={},Jt={};const Zt={linearGradient:function(e,n){let{from:i,to:a,type:r,opacity:s}=e;Ot(i||"top",n,Wt),Ot(a||"bottom",n,Ht);const o=t.Platform.canvas.createLinearGradient(Wt.x,Wt.y,Ht.x,Ht.y),l={type:r,style:o};return Dt(l,o,e.stops,s),l},radialGradient:function(e,n){let{from:i,to:a,type:r,opacity:s,stretch:o}=e;Xt(i||"center",n,qt),Xt(a||"bottom",n,zt);const l=t.Platform.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,Ft(qt,zt)),d={type:r,style:l};Dt(d,l,e.stops,s);const c=Gt(n,qt,zt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:a,type:r,opacity:s,stretch:o}=e;Vt(i||"center",n,Qt),Vt(a||"bottom",n,Jt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Qt.x,Qt.y):t.Platform.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,Nt(Qt,Jt)),d={type:r,style:l};Dt(d,l,e.stops,s);const c=Gt(n,Qt,Jt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Gt},{copy:Kt,move:$t,toOffsetOutBounds:te}=t.BoundsHelper,{max:ee}=Math,ne={},ie=new t.Matrix,ae={};function re(t,e){let n,i,a,r,s=0,o=0,l=0,d=0;return e.forEach(t=>{n=t.x||0,i=t.y||0,a=t.spread||0,r=1.5*(t.blur||0),s=ee(s,a+r-i),o=ee(o,a+r+n),l=ee(l,a+r+i),d=ee(d,a+r-n)}),s===o&&o===l&&l===d?s:[s,o,l,d]}function se(e,n,i){const{shapeBounds:a}=i;let r,s;t.Platform.fullImageShadow?(Kt(ne,e.bounds),$t(ne,n.x-a.x,n.y-a.y),r=e.bounds,s=ne):(r=a,s=n),e.copyWorld(i.canvas,r,s)}const{toOffsetOutBounds:oe}=t.BoundsHelper,le={};const de=re;const ce={shadow:function(e,n,a){let r,s;const{__nowWorld:o}=e,{shadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),_=l.length-1;te(c,ae,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(ae.offsetX+(l.x||0)*f*y,ae.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y,i.ColorConvert.string(l.color)),s=i.Effect.getShadowTransform(e,g,a,l,ae,y),s&&g.setTransform(s),se(g,ae,a),s&&g.resetTransform(),r=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),r=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(a.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,r,l.blendMode),_&&m<_&&g.clearWorld(r)}),g.recycle(r)},innerShadow:function(e,n,a){let r,s;const{__nowWorld:o}=e,{innerShadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),_=l.length-1;oe(c,le,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(le.offsetX+(l.x||0)*f*y,le.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y),s=i.Effect.getShadowTransform(e,g,a,l,le,y,!0),s&&g.setTransform(s),se(g,le,a),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),r=o):(g.copyWorld(a.canvas,u,c,"source-out"),r=h),g.fillWorld(r,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,r,l.blendMode),_&&m<_&&g.clearWorld(r)}),g.recycle(r)},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){},getShadowRenderSpread:re,getShadowTransform:function(t,e,n,i,a,r,s){if(i.spread){const n=1+2*i.spread/t.__layout.strokeBounds.width*r*(s?-1:1);return ie.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},n),ie}},isTransformShadow(t){},getInnerShadowSpread:de},{excludeRenderBounds:he}=t.LeafBoundsHelper;let ue;function fe(t,e,n,i,a,r,s,o){switch(e){case"grayscale":ue||(ue=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,i,a,r){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),r&&i.recycle(s);ge(t,e,n,1,a,r)}(t,n,i,a,s,o);break;case"opacity-path":ge(t,n,i,r,s,o);break;case"path":o&&n.restore()}}function pe(t){return t.getSameCanvas(!1,!0)}function ge(t,e,n,i,a,r){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s,void 0,a),r?n.recycle(s):n.clearWorld(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,r,s,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(n=l[d],o=n.__.mask,o){s&&(fe(this,s,t,a,i,r,void 0,!0),i=a=null),"clipping"!==o&&"clipping-path"!==o||he(n,e)||n.__render(t,e),r=n.__.opacity,ue=!1,"path"===o||"clipping-path"===o?(r<1?(s="opacity-path",a||(a=pe(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===o?"grayscale":"alpha",i||(i=pe(t)),a||(a=pe(t)),n.__render(i,e));continue}const c=1===r&&n.__.__blendMode;c&&fe(this,s,t,a,i,r,void 0,!1),he(n,e)||n.__render(a||t,e),c&&fe(this,s,t,a,i,r,c,!1)}fe(this,s,t,a,i,r,void 0,!0)};const _e=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",me=_e+"_#~&*+\\=|≮≯≈≠=…",ye=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 we(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ve=we("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),xe=we("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),be=we(_e),Be=we(me),Ee=we("- —/~|┆·");var Le;!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"}(Le||(Le={}));const{Letter:Se,Single:Re,Before:ke,After:Pe,Symbol:Ce,Break:Ae}=Le;function Te(t){return ve[t]?Se:Ee[t]?Ae:xe[t]?ke:be[t]?Pe:Be[t]?Ce:ye.test(t)?Re:Se}const Oe={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let r=a-1;r>-1&&(n=e[r].data[0]," "===n.char);r--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function Me(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:We}=Oe,{Letter:He,Single:De,Before:Ie,After:Fe,Symbol:Ue,Break:je}=Le;let Ye,Xe,qe,ze,Ge,Ne,Ve,Qe,Je,Ze,Ke,$e,tn,en,nn,an,rn,sn=[];function on(t,e){Je&&!Qe&&(Qe=Je),Ye.data.push({char:t,width:e}),qe+=e}function ln(){ze+=qe,Ye.width=qe,Xe.words.push(Ye),Ye={data:[]},qe=0}function dn(){en&&(nn.paraNumber++,Xe.paraStart=!0,en=!1),Je&&(Xe.startCharSize=Qe,Xe.endCharSize=Je,Qe=0),Xe.width=ze,an.width?We(Xe):rn&&cn(),sn.push(Xe),Xe={words:[]},ze=0}function cn(){ze>(nn.maxWidth||0)&&(nn.maxWidth=ze)}const{top:hn,right:un,bottom:fn,left:pn}=t.Direction4;function gn(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 _n={getDrawData:function(e,n){t.isString(e)||(e=String(e));let a=0,r=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(s?(a=c[pn],s-=c[un]+c[pn]):n.autoSizeAlign||(a=c[pn]),o?(r=c[hn],o-=c[hn]+c[fn]):n.autoSizeAlign||(r=c[hn]));const h={bounds:{x:a,y:r,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){nn=e,sn=e.rows,an=e.bounds,rn=!an.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:r,textCase:s}=i,{canvas:o}=t.Platform,{width:l,height:d}=an;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;en=!0,Ke=null,Qe=Ve=Je=qe=ze=0,Ye={data:[]},Xe={words:[]},a&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Ne=n[i],"\n"===Ne?(qe&&ln(),Xe.paraEnd=!0,dn(),en=!0):(Ze=Te(Ne),Ze===He&&"none"!==s&&(Ne=Me(Ne,s,!qe)),Ve=o.measureText(Ne).width,a&&(a<0&&(Je=Ve),Ve+=a),$e=Ze===De&&(Ke===De||Ke===He)||Ke===De&&Ze!==Fe,tn=!(Ze!==Ie&&Ze!==De||Ke!==Ue&&Ke!==Fe),Ge=en&&r?l-r:l,t&&l&&ze+qe+Ve>Ge&&(e?(qe&&ln(),ze&&dn()):(tn||(tn=Ze===He&&Ke==Fe),$e||tn||Ze===je||Ze===Ie||Ze===De||qe+Ve>Ge?(qe&&ln(),ze&&dn()):ze&&dn()))," "===Ne&&!0!==en&&ze+qe===0||(Ze===je?(" "===Ne&&qe&&ln(),on(Ne,Ve),ln()):$e||tn?(qe&&ln(),on(Ne,Ve)):on(Ne,Ve)),Ke=Ze);qe&&ln(),ze&&dn(),sn.length>0&&(sn[sn.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{nn.paraNumber++,ze=o.measureText(t).width,sn.push({x:r||0,text:t,width:ze,paraStart:!0}),rn&&cn()})}(h,e,n),c&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":gn(e,"x",t[pn]);break;case"right":gn(e,"x",-t[un])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":gn(e,"y",t[hn]);break;case"bottom":gn(e,"y",-t[fn])}}(c,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,a=n.length,{__lineHeight:r,__baseLine:s,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,m=r*a+(h?h*(t.paraNumber-1):0),y=s;if(l&&m>_)m=Math.max(_,r),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let s=0,c=a;s<c;s++){if(w=n[s],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&&s>0&&(y+=h),w.y=y,y+=r,t.overflow>s&&y>m&&(w.isOverflow=!0,t.overflow=s+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=m}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:a,paraIndent:r,letterSpacing:s}=e;let o,l,d,c,h,u;i.forEach(t=>{t.words&&(d=r&&t.paraStart?r:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,c=s||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!s&&(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,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:r,overflow:s}=e;let{textOverflow:o}=n;if(r.splice(s),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?r:[r[s-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,s),"none"!==l&&function(e,n){let a,r=0;const{fontSize:s,textDecoration:o}=n;switch(e.decorationHeight=s/11,t.isObject(o)?(a=o.type,o.color&&(e.decorationColor=i.ColorConvert.string(o.color)),o.offset&&(r=Math.min(.3*s,Math.max(o.offset,.15*-s)))):a=o,a){case"under":e.decorationY=[.15*s+r];break;case"delete":e.decorationY=[.35*-s];break;case"under-delete":e.decorationY=[.15*s+r,.35*-s]}}(h,n),h}};const mn={string:function(e,n){if(!e)return"#000";const a=t.isNumber(n)&&n<1;if(t.isString(e)){if(!a||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let r=t.isUndefined(e.a)?1:e.a;a&&(r*=n);const s=e.r+","+e.g+","+e.b;return 1===r?"rgb("+s+")":"rgba("+s+","+r+")"}};Object.assign(i.TextConvert,_n),Object.assign(i.ColorConvert,mn),Object.assign(i.Paint,G),Object.assign(i.PaintImage,Tt),Object.assign(i.PaintGradient,Zt),Object.assign(i.Effect,ce);const{setPoint:yn,addPoint:wn,toBounds:vn}=i.TwoPointBoundsHelper;const xn={syncExport(t,e,n){let a;i.Export.running=!0;try{const r=i.FileHelper.fileType(e),s=e.includes(".");n=i.FileHelper.getExportOptions(n);const{toURL:o}=i.Platform,{download:l}=i.Platform.origin;if("json"===r)s&&l(o(JSON.stringify(t.toJSON(n.json)),"text"),e),a={data:!!s||t.toJSON(n.json)};else if("svg"===r)s&&l(o(t.toSVG(),"svg"),e),a={data:!!s||t.toSVG()};else{let r,s,o=1,l=1;const{worldTransform:d,isLeafer:c,leafer:h,isFrame:u}=t,{slice:f,clip:p,trim:g,screenshot:_,padding:m,onCanvas:y}=n,w=i.isUndefined(n.smooth)?!h||h.config.smooth:n.smooth,v=n.contextSettings||(h?h.config.contextSettings:void 0),x=c&&_&&i.isUndefined(n.fill)?t.fill:n.fill,b=i.FileHelper.isOpaqueImage(e)||x,B=new i.Matrix;if(_)r=!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}r=t.getBounds("render",e)}const E={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,r,E);let L=n.pixelRatio||1,{x:S,y:R,width:k,height:P}=new i.Bounds(r).scale(E.scaleX,E.scaleY);p&&(S+=p.x,R+=p.y,k=p.width,P=p.height);const C={exporting:!0,matrix:B.scale(1/E.scaleX,1/E.scaleY).invert().translate(-S,-R).withScale(1/o*E.scaleX,1/l*E.scaleY)};let A,T=i.Creator.canvas({width:Math.floor(k),height:Math.floor(P),pixelRatio:L,smooth:w,contextSettings:v});f&&(A=t,A.__worldOpacity=0,t=h||t,C.bounds=T.bounds),T.save();const O=u&&!i.isUndefined(x),M=t.get("fill");if(O&&(t.fill=""),i.Platform.render(t,T,C),O&&(t.fill=M),T.restore(),A&&A.__updateWorldOpacity(),g){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let r,s,o,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(r=l%e,s=(l-r)/e,o?wn(o,r,s):yn(o={},r,s)),l++;const d=new i.Bounds;return o&&(vn(o,d),d.scale(1/t.pixelRatio).ceil()),d}(T);const t=T,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:L};T=i.Creator.canvas(a),T.copyWorld(t,s,a),t.destroy()}if(m){const[t,e,n,a]=i.MathHelper.fourNumber(m),r=T,{width:s,height:o}=r;T=i.Creator.canvas({width:s+a+e,height:o+t+n,pixelRatio:L}),T.copyWorld(r,r.bounds,{x:a,y:t,width:s,height:o}),r.destroy()}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),y&&y(T);a={data:"canvas"===e?T:T.export(e,n),width:T.pixelWidth,height:T.pixelHeight,renderBounds:r,trimBounds:s};const W=h&&h.app;W&&W.canvasManager&&W.canvasManager.clearRecycled()}}catch(t){a={data:"",error:t}}return i.Export.running=!1,a},export(t,e,n){return i.Export.running=!0,function(t){bn||(bn=new i.TaskProcessor);return new Promise(e=>{bn.add(()=>a(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(r=>new Promise(s=>{const o=()=>a(this,void 0,void 0,function*(){if(!i.Resource.isComplete)return i.Platform.requestRender(o);const a=i.Export.syncExport(t,e,n);a.data instanceof Promise&&(a.data=yield a.data),r(a),s()});t.updateLayout(),Bn(t);const{leafer:l}=t;l?l.waitViewCompleted(o):o()}))}};let bn;function Bn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Bn(t))}const En=i.LeaferCanvasBase.prototype,Ln=i.Debug.get("@leafer-in/export");En.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)},En.toBlob=function(t,e){return new Promise(n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then(t=>{n(t)}).catch(t=>{Ln.error(t),n(null)})})},En.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},En.saveAs=function(t,e){return new Promise(n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then(()=>{n(!0)}).catch(t=>{Ln.error(t),n(!1)})})},i.Plugin.add("export"),Object.assign(i.Export,xn),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 r(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=w,exports.LeaferCanvas=r,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:r}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,function*(){return t.toBuffer(s(e),n)}),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,function*(){return e.writeFileSync(n,t.toBuffer(s(o(n)),i))}),download(t,e){},loadImage:e=>r(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,t.isArray(e)&&(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:m}=t.LeafHelper,y=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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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),m(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:120},this.frames=[],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),i.clipWorld(a),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),t.Platform.render(this.target,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);this.requestTime=this.frameTime||Date.now();const n=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&e>i)return t.Platform.requestRender(n);const{frames:a}=this;a.length>30&&a.shift(),a.push(e),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(n)}__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.config={},this.target=this.canvas=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.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,s,!!i.findList),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}}hitPoint(t,e,n){return!!this.getByPoint(t,e,n).target}getBestMatchLeaf(e,n,i,a){const s=this.findList=new t.LeafList;if(e.length){let n;const{x:a,y:r}=this.point,o={x:a,y:r,radiusX:0,radiusY:0};for(let a=0,r=e.length;a<r;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),s.length)){if(n.isBranchLeaf&&e.some(e=>e!==n&&t.LeafHelper.hasParent(e,n))){s.reset();break}return s.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),s.length)return s.list[0];return a?null:i?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const n=new t.LeafList,i=[],{target:a}=this;for(;e&&(e.syncEventer&&i.push(e.syncEventer),n.add(e),(e=e.parent)!==a););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&n.add(t),(t=t.parent)!==a););}),a&&n.add(a),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&&(!i.isLeafer||"draw"!==i.mode));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)&&(n.topChildren&&this.eachFind(n.topChildren,!1),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){let n,a=[];const{children:s}=i;for(let i=0,r=s.length;i<r;i++)if(n=s[i],n.__.mask&&a.push(n),n===t){if(a&&!a.every(t=>t.__hitWorld(e)))return;break}}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)}hitPoint(t,e,n){return this.picker.hitPoint(t,e,n)}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 S(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function R(t,e,n){switch(e.__.strokeAlign){case"center":k(t,1,e,n);break;case"inside":P(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?k(t,2,e,n):P(t,"outside",e,n)}}function k(e,n,i,a){const s=i.__;t.isObject(e)?A(e,n,!0,i,a):(a.setStroke(e,s.__strokeWidth*n,s),C(i,a))}function P(e,n,i,a){const s=a.getSameCanvas(!0,!0);s.font=i.__.__font,k(e,2,i,s),s.blendMode="outside"===n?"destination-out":"destination-in",L(i,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(i,a,s),s.recycle(i.__nowWorld)}function C(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 A(t,e,n,a,s){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!i.PaintImage.checkImage(a,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),n?C(a,s):s.stroke(),s.restoreBlendMode()):n?C(a,s):s.stroke()}}function T(e,n,i){const a=n.__;if(a.__strokeWidth)if(a.__font)R(e,n,i);else switch(a.strokeAlign){case"center":O(e,1,n,i);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),O(t,2,e,n),n.restore()}(e,n,i);break;case"outside":!function(e,n,i){const a=n.__;if(a.__fillAfterStroke)O(e,2,n,i);else{const{renderBounds:s}=n.__layout,r=i.getSameCanvas(!0,!0);n.__drawRenderPath(r),O(e,2,n,r),r.clipUI(a),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(n,i,r),r.recycle(n.__nowWorld)}}(e,n,i)}}function O(e,n,a,s){const r=a.__;t.isObject(e)?A(e,n,!1,a,s):(s.setStroke(e,r.__strokeWidth*n,r),s.stroke()),r.__useArrow&&i.Paint.strokeArrow(e,a,s)}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,t.Platform.render=function(e,n,i){const a=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new t.LeafList,e.__render(n,i),i.topList.length&&i.topList.forEach(t=>t.__render(n,a))};const{getSpread:M,copyAndSpread:W,toOuterOf:H,getOuterOf:D,getByMove:I,move:F,getIntersectData:U}=t.BoundsHelper,j={};let Y;const{stintSet:X}=t.DataHelper,{hasTransparent:q}=i.ColorConvert;function z(e,n,a){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:r}=a.__layout;switch(n.type){case"image":s=i.PaintImage.image(a,e,n,r,!Y||!Y[n.url]);break;case"linear":s=i.PaintGradient.linearGradient(n,r);break;case"radial":s=i.PaintGradient.radialGradient(n,r);break;case"angular":s=i.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;s={type:o,style:i.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(s={type:"solid",style:i.ColorConvert.string(n)})}if(s){if(t.isString(s.style)&&q(s.style)&&(s.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;s.strokeStyle=n.style}n.editing&&(s.editing=n.editing),n.blendMode&&(s.blendMode=n.blendMode)}return s}const G={compute:function(e,n){const a=n.__,s=[];let r,o,l,d=a.__input[e];t.isArray(d)||(d=[d]),Y=i.PaintImage.recycleImage(e,a);for(let t,i=0,a=d.length;i<a;i++)(t=z(e,d[i],n))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));a["_"+e]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===e?(X(a,"__isAlphaPixelFill",r),X(a,"__isTransparentFill",o)):(X(a,"__isAlphaPixelStroke",r),X(a,"__isTransparentStroke",o),X(a,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,S(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}}if(n.fillStyle=a.style,a.transform||a.scaleFixed){if(n.save(),a.transform&&n.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&i>1)&&n.scale(1/t,1/i)}a.blendMode&&(n.blendMode=a.blendMode),S(e,n),n.restore()}else a.blendMode?(n.saveBlendMode(a.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:L,stroke:T,strokes:function(t,e,n){T(t,e,n)},strokeText:R,drawTextStroke:C,shape:function(e,n,i){const a=n.getSameCanvas(),s=n.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;H(o.strokeSpread?(W(j,o.boxBounds,o.strokeSpread),j):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(s.includes(l))p=a,d=f=l,c=r;else{let a;if(t.Platform.fullImageShadow)a=l;else{const e=o.renderShapeSpread?M(s,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):s;a=U(e,l)}u=s.getFitMatrix(a);let{a:m,d:y}=u;u.a<1&&(p=n.getSameCanvas(),e.__renderShape(p,i),g*=m,_*=y),f=D(l,u),d=I(f,-u.e,-u.f),c=D(r,u),F(c,-u.e,-u.f);const w=i.matrix;w?(h=new t.Matrix(u),h.multiply(w),m*=w.scaleX,y*=w.scaleY):h=u,h.withScale(m,y),i=Object.assign(Object.assign({},i),{matrix:h})}return e.__renderShape(a,i),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let N={},V=t.getMatrixData();const{get:Q,set:J,rotateOfOuter:Z,translate:K,scaleOfOuter:$,multiplyParent:tt,scale:et,rotate:nt,skew:it}=t.MatrixHelper;function at(t,e,n,i){const a=Q();K(a,e.x,e.y),n&&et(a,n,i),t.transform=a}function st(t,e,n,i,a,s,r){const o=Q();K(o,e.x+n,e.y+i),et(o,a,s),r&&Z(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function rt(t,e,n,i,a,s,r,o,l,d){const c=Q();lt(c,e,n,i,a,s,r,o),l&&(r||o?(J(V),$(V,e,l,d),tt(c,V)):$(c,e,l,d)),t.transform=c}function ot(t,e,n,i,a,s,r,o,l,d,c,h){const u=Q();if(h)lt(u,e,a,s,r,o,l,d);else{if(l)if("center"===c)Z(u,{x:n/2,y:i/2},l);else switch(nt(u,l),l){case 90:K(u,i,0);break;case 180:K(u,n,i);break;case 270:K(u,0,n)}N.x=e.x+a,N.y=e.y+s,K(u,N.x,N.y),r&&$(u,N,r,o)}t.transform=u}function lt(t,e,n,i,a,s,r,o){r&&nt(t,r),o&&it(t,o.x,o.y),a&&et(t,a,s),K(t,e.x+n,e.y+i)}const{get:dt,translate:ct}=t.MatrixHelper,ht=new t.Bounds,ut={},ft={};function pt(t,e,n,i){const{changeful:a,sync:s,scaleFixed:r}=n;a&&(t.changeful=a),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=gt(n,i,e)}function gt(e,n,i){e.padding&&(n=ht.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,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===a&&n.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(ft,0,0,v?s:a,v?a:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,i,ut),x=ut.scaleX,b=ut.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(ft,x,b,!0),l&&t.AlignHelper.toPoint(l,ft,n,ft,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,ft,"fit"!==o),t.BoundsHelper.put(n,i,l,x,!1,ft),t.BoundsHelper.scale(ft,x,b,!0)),d&&t.PointHelper.move(ft,d),o){case"stretch":y||(x=n.width/a,b=n.height/s,at(w,n,x,b));break;case"normal":case"clip":if(ft.x||ft.y||x||p||u||f){let t,e;p&&(t=n.width/p.width,e=n.height/p.height),rt(w,n,ft.x,ft.y,x,b,u,f,t,e),t&&(x=x?x*t:t,b=b?b*e:e)}break;case"repeat":(!y||x||u||f)&&ot(w,n,a,s,ft.x,ft.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const i=t.isObject(g);(_||i)&&(w.gap=function(e,n,i,a,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:_t(r,i,s.width,n&&n.x),y:_t(o,a,s.height,n&&n.y)}}(_,i&&g,ft.width,ft.height,n));break;default:x&&st(w,n,ft.x,ft.y,x,b,u)}return w.transform||(n.x||n.y)&&ct(w.transform=dt(),n.x,n.y),w.width=a,w.height=s,x&&(w.scaleX=x,w.scaleY=b),r&&(w.opacity=r),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function _t(e,n,i,a){const s=t.isString(e)||a?(a?i-a*n:i%n)/((a||Math.floor(i/n))-1):e;return"auto"===e&&s<0?0:s}let mt,yt=new t.Bounds;const{isSame:wt}=t.BoundsHelper;function vt(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||pt(a,i,n,s),!0}function xt(e,n){Et(e,t.ImageEvent.LOAD,n)}function bt(e,n){Et(e,t.ImageEvent.LOADED,n)}function Bt(e,n,i){n.error=i,e.forceUpdate("surface"),Et(e,t.ImageEvent.ERROR,n)}function Et(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function Lt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:St,scale:Rt,copy:kt}=t.MatrixHelper,{floor:Pt,ceil:Ct,max:At,abs:Tt}=Math;function Ot(e,n,i){let{scaleX:a,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed);const r=a+"-"+s+"-"+i;if(n.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;a*=i,s*=i,f&&(f=Tt(f),p=Tt(p),c=St(),kt(c,g),Rt(c,1/f,1/p),a*=f,s*=p),h*=a,u*=s;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/Ct(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(a/=d,s/=d,h/=d,u/=d),f&&(a/=f,s/=p);const v=m&&m.x*a,x=m&&m.y*s;if(g||1!==a||1!==s){const t=h+(v||0),e=u+(x||0);a/=t/At(Pt(t),1),s/=e/At(Pt(e),1),c||(c=St(),g&&kt(c,g)),Rt(c,1/a,1/s)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),B=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=B,n.patternId=r,!0}}const Mt={image:function(e,n,i,a,s){let r,o;const l=t.ImageManager.get(i);return mt&&i===mt.paint&&wt(a,mt.boxBounds)?r=mt.leafPaint:(r={type:i.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),mt=l.use>1?{leafPaint:r,paint:i,boxBounds:yt.set(a)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:i}),l.ready?(vt(e,n,i,l,r,a),s&&(xt(e,o),bt(e,o))):l.error?s&&Bt(e,o,l.error):(s&&(Lt(e,!0),xt(e,o)),r.loadId=l.load(()=>{Lt(e,!1),e.destroyed||(vt(e,n,i,l,r,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),bt(e,o)),r.loadId=void 0},t=>{Lt(e,!1),Bt(e,o,t),r.loadId=void 0}),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}=e.getRenderScaleData(!0,s.scaleFixed),{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||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:n}=c;e*=o*d,n*=l*d,c.scaleX&&(e*=c.scaleX,n*=c.scaleY),r=e*n>t.Platform.image.maxCacheSize}return r?(e.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),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?Ot(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)&&Ot(e,s,d),e.forceUpdate("surface")}),300)),!1)},createPattern:Ot,recycleImage:function(e,n){const i=n["_"+e];if(t.isArray(i)){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]||[],t.isArray(o)||(o=[o])),s.unload(i[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:pt,getPatternData:gt,stretchMode:at,fillOrFitMode:st,clipMode:rt,repeatMode:ot},{toPoint:Wt}=t.AroundHelper,{hasTransparent:Ht}=i.ColorConvert,Dt={},It={};function Ft(e,n,a,s){if(a){let r,o,l,d;for(let e=0,c=a.length;e<c;e++)r=a[e],t.isString(r)?(l=e/(c-1),o=i.ColorConvert.string(r,s)):(l=r.offset,o=i.ColorConvert.string(r.color,s)),n.addColorStop(l,o),!d&&Ht(o)&&(d=!0);d&&(e.isTransparent=!0)}}const{getAngle:Ut,getDistance:jt}=t.PointHelper,{get:Yt,rotateOfOuter:Xt,scaleOfOuter:qt}=t.MatrixHelper,{toPoint:zt}=t.AroundHelper,Gt={},Nt={};function Vt(t,e,n,i,a){let s;const{width:r,height:o}=t;if(r!==o||i){const t=Ut(e,n);s=Yt(),a?(qt(s,e,r/o*(i||1),1),Xt(s,e,t+90)):(qt(s,e,1,r/o*(i||1)),Xt(s,e,t))}return s}const{getDistance:Qt}=t.PointHelper,{toPoint:Jt}=t.AroundHelper,Zt={},Kt={};const $t={linearGradient:function(e,n){let{from:i,to:a,type:s,opacity:r}=e;Wt(i||"top",n,Dt),Wt(a||"bottom",n,It);const o=t.Platform.canvas.createLinearGradient(Dt.x,Dt.y,It.x,It.y),l={type:s,style:o};return Ft(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,stretch:o}=e;zt(i||"center",n,Gt),zt(a||"bottom",n,Nt);const l=t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,jt(Gt,Nt)),d={type:s,style:l};Ft(d,l,e.stops,r);const c=Vt(n,Gt,Nt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,stretch:o}=e;Jt(i||"center",n,Zt),Jt(a||"bottom",n,Kt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Zt.x,Zt.y):t.Platform.canvas.createRadialGradient(Zt.x,Zt.y,0,Zt.x,Zt.y,Qt(Zt,Kt)),d={type:s,style:l};Ft(d,l,e.stops,r);const c=Vt(n,Zt,Kt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Vt},{copy:te,move:ee,toOffsetOutBounds:ne}=t.BoundsHelper,{max:ie,abs:ae}=Math,se={},re=new t.Matrix,oe={};function le(t,e){let n,i,a,s,r=0,o=0,l=0,d=0;return e.forEach(t=>{n=t.x||0,i=t.y||0,s=1.5*(t.blur||0),a=ae(t.spread||0),r=ie(r,a+s-i),o=ie(o,a+s+n),l=ie(l,a+s+i),d=ie(d,a+s-n)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function de(e,n,i){const{shapeBounds:a}=i;let s,r;t.Platform.fullImageShadow?(te(se,e.bounds),ee(se,n.x-a.x,n.y-a.y),s=e.bounds,r=se):(s=a,r=n),e.copyWorld(i.canvas,s,r)}const{toOffsetOutBounds:ce}=t.BoundsHelper,he={};const ue=le;const fe={shadow:function(e,n,a){let s,r;const{__nowWorld:o}=e,{shadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),_=l.length-1;ne(c,oe,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(oe.offsetX+(l.x||0)*f*y,oe.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y,i.ColorConvert.string(l.color)),r=i.Effect.getShadowTransform(e,g,a,l,oe,y),r&&g.setTransform(r),de(g,oe,a),r&&g.resetTransform(),s=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),s=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(a.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,s,l.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(e,n,a){let s,r;const{__nowWorld:o}=e,{innerShadow:l}=e.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=n.getSameCanvas(),_=l.length-1;ce(c,he,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(he.offsetX+(l.x||0)*f*y,he.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y),r=i.Effect.getShadowTransform(e,g,a,l,he,y,!0),r&&g.setTransform(r),de(g,he,a),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),s=o):(g.copyWorld(a.canvas,u,c,"source-out"),s=h),g.fillWorld(s,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,s,l.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},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){},getShadowRenderSpread:le,getShadowTransform:function(t,e,n,i,a,s,r){if(i.spread){const n=2*i.spread*s*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return re.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+n/o,1+n/l),re}},isTransformShadow(t){},getInnerShadowSpread:ue},{excludeRenderBounds:pe}=t.LeafBoundsHelper;let ge;function _e(t,e,n,i,a,s,r,o){switch(e){case"grayscale":ge||(ge=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,i,a,s){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,r),s&&i.recycle(r);ye(t,e,n,1,a,s)}(t,n,i,a,r,o);break;case"opacity-path":ye(t,n,i,s,r,o);break;case"path":o&&n.restore()}}function me(t){return t.getSameCanvas(!1,!0)}function ye(t,e,n,i,a,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,r,void 0,a),s?n.recycle(r):n.clearWorld(r)}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++){if(n=l[d],o=n.__.mask,o){r&&(_e(this,r,t,a,i,s,void 0,!0),i=a=null),"clipping"!==o&&"clipping-path"!==o||pe(n,e)||n.__render(t,e),s=n.__.opacity,ge=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",a||(a=me(t))):(r="path",t.save()),n.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=me(t)),a||(a=me(t)),n.__render(i,e));continue}const c=1===s&&n.__.__blendMode;c&&_e(this,r,t,a,i,s,void 0,!1),pe(n,e)||n.__render(a||t,e),c&&_e(this,r,t,a,i,s,c,!1)}_e(this,r,t,a,i,s,void 0,!0)};const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ve=we+"_#~&*+\\=|≮≯≈≠=…",xe=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 be(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Be=be("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ee=be("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Le=be(we),Se=be(ve),Re=be("- —/~|┆·");var ke;!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"}(ke||(ke={}));const{Letter:Pe,Single:Ce,Before:Ae,After:Te,Symbol:Oe,Break:Me}=ke;function We(t){return Be[t]?Pe:Re[t]?Me:Ee[t]?Ae:Le[t]?Te:Se[t]?Oe:xe.test(t)?Ce:Pe}const He={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 De(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:Ie}=He,{Letter:Fe,Single:Ue,Before:je,After:Ye,Symbol:Xe,Break:qe}=ke;let ze,Ge,Ne,Ve,Qe,Je,Ze,Ke,$e,tn,en,nn,an,sn,rn,on,ln,dn=[];function cn(t,e){$e&&!Ke&&(Ke=$e),ze.data.push({char:t,width:e}),Ne+=e}function hn(){Ve+=Ne,ze.width=Ne,Ge.words.push(ze),ze={data:[]},Ne=0}function un(){sn&&(rn.paraNumber++,Ge.paraStart=!0,sn=!1),$e&&(Ge.startCharSize=Ke,Ge.endCharSize=$e,Ke=0),Ge.width=Ve,on.width?Ie(Ge):ln&&fn(),dn.push(Ge),Ge={words:[]},Ve=0}function fn(){Ve>(rn.maxWidth||0)&&(rn.maxWidth=Ve)}const{top:pn,right:gn,bottom:_n,left:mn}=t.Direction4;function yn(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 wn={getDrawData:function(e,n){t.isString(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[mn],r-=c[gn]+c[mn]):n.autoSizeAlign||(a=c[mn]),o?(s=c[pn],o-=c[pn]+c[_n]):n.autoSizeAlign||(s=c[pn]));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){rn=e,dn=e.rows,on=e.bounds,ln=!on.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=i,{canvas:o}=t.Platform,{width:l,height:d}=on;if(l||d||a||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;sn=!0,en=null,Ke=Ze=$e=Ne=Ve=0,ze={data:[]},Ge={words:[]},a&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Je=n[i],"\n"===Je?(Ne&&hn(),Ge.paraEnd=!0,un(),sn=!0):(tn=We(Je),tn===Fe&&"none"!==r&&(Je=De(Je,r,!Ne)),Ze=o.measureText(Je).width,a&&(a<0&&($e=Ze),Ze+=a),nn=tn===Ue&&(en===Ue||en===Fe)||en===Ue&&tn!==Ye,an=!(tn!==je&&tn!==Ue||en!==Xe&&en!==Ye),Qe=sn&&s?l-s:l,t&&l&&Ve+Ne+Ze>Qe&&(e?(Ne&&hn(),Ve&&un()):(an||(an=tn===Fe&&en==Ye),nn||an||tn===qe||tn===je||tn===Ue||Ne+Ze>Qe?(Ne&&hn(),Ve&&un()):Ve&&un()))," "===Je&&!0!==sn&&Ve+Ne===0||(tn===qe?(" "===Je&&Ne&&hn(),cn(Je,Ze),hn()):nn||an?(Ne&&hn(),cn(Je,Ze)):cn(Je,Ze)),en=tn);Ne&&hn(),Ve&&un(),dn.length>0&&(dn[dn.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{rn.paraNumber++,Ve=o.measureText(t).width,dn.push({x:s||0,text:t,width:Ve,paraStart:!0}),ln&&fn()})}(h,e,n),c&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":yn(e,"x",t[mn]);break;case"right":yn(e,"x",-t[gn])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":yn(e,"y",t[pn]);break;case"bottom":yn(e,"y",-t[_n])}}(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,m=s*a+(h?h*(t.paraNumber-1):0),y=r;if(l&&m>_)m=Math.max(_,s),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=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&&(y+=h),w.y=y,y+=s,t.overflow>r&&y>m&&(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=m}(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(e,n){let a,s=0;const{fontSize:r,textDecoration:o}=n;switch(e.decorationHeight=r/11,t.isObject(o)?(a=o.type,o.color&&(e.decorationColor=i.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):a=o,a){case"under":e.decorationY=[.15*r+s];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+s,.35*-r]}}(h,n),h}};const vn={string:function(e,n){if(!e)return"#000";const a=t.isNumber(n)&&n<1;if(t.isString(e)){if(!a||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let s=t.isUndefined(e.a)?1:e.a;a&&(s*=n);const r=e.r+","+e.g+","+e.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(i.TextConvert,wn),Object.assign(i.ColorConvert,vn),Object.assign(i.Paint,G),Object.assign(i.PaintImage,Mt),Object.assign(i.PaintGradient,$t),Object.assign(i.Effect,fe);const{setPoint:xn,addPoint:bn,toBounds:Bn}=i.TwoPointBoundsHelper;const En={syncExport(t,e,n){let a;i.Export.running=!0;try{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:m,onCanvas:y}=n,w=i.isUndefined(n.smooth)?!h||h.config.smooth:n.smooth,v=n.contextSettings||(h?h.config.contextSettings:void 0),x=c&&_&&i.isUndefined(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:S,y:R,width:k,height:P}=new i.Bounds(s).scale(E.scaleX,E.scaleY);p&&(S+=p.x,R+=p.y,k=p.width,P=p.height);const C={exporting:!0,matrix:B.scale(1/E.scaleX,1/E.scaleY).invert().translate(-S,-R).withScale(1/o*E.scaleX,1/l*E.scaleY)};let A,T=i.Creator.canvas({width:Math.floor(k),height:Math.floor(P),pixelRatio:L,smooth:w,contextSettings:v});f&&(A=t,A.__worldOpacity=0,t=h||t,C.bounds=T.bounds),T.save();const O=u&&!i.isUndefined(x),M=t.get("fill");if(O&&(t.fill=""),i.Platform.render(t,T,C),O&&(t.fill=M),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?bn(o,s,r):xn(o={},s,r)),l++;const d=new i.Bounds;return o&&(Bn(o,d),d.scale(1/t.pixelRatio).ceil()),d}(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),t.destroy()}if(m){const[t,e,n,a]=i.MathHelper.fourNumber(m),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}),s.destroy()}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),y&&y(T);a={data:"canvas"===e?T:T.export(e,n),width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:r};const W=h&&h.app;W&&W.canvasManager&&W.canvasManager.clearRecycled()}}catch(t){a={data:"",error:t}}return i.Export.running=!1,a},export(t,e,n){return i.Export.running=!0,function(t){Ln||(Ln=new i.TaskProcessor);return new Promise(e=>{Ln.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=i.Export.syncExport(t,e,n);a.data instanceof Promise&&(a.data=yield a.data),s(a),r()});t.updateLayout(),Sn(t);const{leafer:l}=t;l?l.waitViewCompleted(o):o()}))}};let Ln;function Sn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Sn(t))}const Rn=i.LeaferCanvasBase.prototype,kn=i.Debug.get("@leafer-in/export");Rn.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)},Rn.toBlob=function(t,e){return new Promise(n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then(t=>{n(t)}).catch(t=>{kn.error(t),n(null)})})},Rn.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},Rn.saveAs=function(t,e){return new Promise(n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then(()=>{n(!0)}).catch(t=>{kn.error(t),n(!1)})})},i.Plugin.add("export"),Object.assign(i.Export,En),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