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