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