@leafer-draw/node 1.9.7 → 1.9.9

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