@leafer-ui/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 +12 -12
package/dist/node.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as S,MathHelper as R,AlignHelper as E,PointHelper as L,ImageEvent as A,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{HitCanvasManager as W,InteractionBase as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,Paint as D,ColorConvert as I,PaintGradient as F,Export as U,Group as Y,TextConvert as X,Effect as N,TwoPointBoundsHelper as j,Bounds as z,FileHelper as G,Platform as q,Matrix as H,MathHelper as V,Creator as Q,TaskProcessor as J,Resource as Z,LeaferCanvasBase as $,Debug as K,Plugin as tt,UI as et}from"@leafer-ui/draw";function it(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 st 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:nt,fileType:at}=s;function ot(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(nt(e),i),canvasToBolb:(t,e,i)=>it(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>it(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(at(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 st(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 rt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:lt,updateBounds:dt,updateChange:ht}=f,{pushAllChildBranch:ct,pushAllParent:ut}=g;const{worldBounds:ft}=p;class gt{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,ft)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ft),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:pt,updateAllChange:_t}=f,wt=w.get("Layouter");class yt{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){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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?(lt(t,!0),e.add(t),t.isBranch&&ct(t,e),ut(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ut(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||dt(s[t])}dt(i)}}))}(this.__levelList),function(t){t.list.forEach(ht)}(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)),yt.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){pt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),_t(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const mt=w.get("Renderer");class vt{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 _,mt.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,mt.error(t)}mt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return mt.warn("rendering");if(this.times>3)return mt.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(vt.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),w.showRepaint&&w.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||mt.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)}}vt.clipSpread=10;const{hitRadiusPoint:xt}=B;class bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||xt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Bt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function kt(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 St(t,e){t.__.__font?kt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Rt(t,e,i){switch(e.__.strokeAlign){case"center":Et(t,1,e,i);break;case"inside":Lt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Et(t,2,e,i):Lt(t,"outside",e,i)}}function Et(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?Ct(t,!0,i,s):Tt(i,s)}function Lt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Et(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",kt(i,n),n.blendMode="normal",At(s,n,i),n.recycle(i.__nowWorld)}function At(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function Tt(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 Ct(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&M.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Tt(i,s):s.stroke(),s.restoreBlendMode()):e?Tt(i,s):s.stroke())}function Ot(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Rt(t,e,i);else switch(s.strokeAlign){case"center":Wt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Wt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Wt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Wt(t,2,e,a),a.clipUI(s),a.clearWorld(n),At(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function Wt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?Ct(t,!1,i,s):s.stroke(),n.__useArrow&&D.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new rt(t,e),layouter:(t,e)=>new yt(t,e),renderer:(t,e,i)=>new vt(t,e,i),selector:(t,e)=>new Bt(t,e)}),e.layout=yt.fullLayout;const{getSpread:Pt,getOuterOf:Mt,getByMove:Dt,getIntersectData:It}=B;let Ft;const{stintSet:Ut}=l,{hasTransparent:Yt}=I;function Xt(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=M.image(i,t,e,n,!Ft||!Ft[e.url]);break;case"linear":s=F.linearGradient(e,n);break;case"radial":s=F.radialGradient(e,n);break;case"angular":s=F.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:I.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:I.string(e)})}return s&&("string"==typeof s.style&&Yt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Nt={compute:function(t,e){const i=e.__,s=[];let n,a,o=i.__input[t];o instanceof Array||(o=[o]),Ft=M.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Xt(t,o[n],e))&&s.push(i);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?(Ut(i,"__isAlphaPixelFill",n),Ut(i,"__isTransparentFill",a)):(Ut(i,"__isAlphaPixelStroke",n),Ut(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,St(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(M.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),St(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:kt,stroke:Ot,strokes:function(t,e,i){Ot(t,e,i)},strokeText:Rt,drawTextStroke:Tt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=It(s?Pt(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=Mt(n,o),a=Dt(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:h}}};let jt={};const{get:zt,rotateOfOuter:Gt,translate:qt,scaleOfOuter:Ht,scale:Vt,rotate:Qt,skew:Jt}=S;function Zt(t,e,i,s,n,a,o){const r=zt();qt(r,e.x+i,e.y+s),Vt(r,n,a),o&&Gt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function $t(t,e,i,s,n,a,o,r){const l=zt();o&&Qt(l,o),r&&Jt(l,r.x,r.y),n&&Vt(l,n,a),qt(l,e.x+i,e.y+s),t.transform=l}function Kt(t,e,i,s,n,a,o,r,l,d){const h=zt();if(l)if("center"===d)Gt(h,{x:i/2,y:s/2},l);else switch(Qt(h,l),l){case 90:qt(h,s,0);break;case 180:qt(h,i,s);break;case 270:qt(h,0,i)}jt.x=e.x+n,jt.y=e.y+a,qt(h,jt.x,jt.y),o&&Ht(h,jt,o,r),t.transform=h}const{get:te,translate:ee}=S,ie=new _,se={},ne={};function ae(t,e,i,s){const{changeful:n,sync:a,editing:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.editing=o),t.data=oe(i,s,e)}function oe(t,e,i){t.padding&&(e=ie.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:h,rotation:c,skew:u,repeat:f,filters:g}=t,p=e.width===s&&e.height===n,_={mode:o},w="center"!==r&&(c||0)%180==90;let y,m;switch(B.set(ne,0,0,w?n:s,w?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(R.getScaleData(d,h,i,se),y=se.scaleX,m=se.scaleY),r&&(y&&B.scale(ne,y,m,!0),E.toPoint(r,ne,e,ne,!0,!0))):p&&!c||(y=m=B.getFitScale(e,ne,"fit"!==o),B.put(e,i,r,y,!1,ne),B.scale(ne,y,m,!0)),l&&L.move(ne,l),o){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(ne.x||ne.y||y||c||u)&&$t(_,e,ne.x,ne.y,y,m,c,u);break;case"repeat":(!p||y||c)&&Kt(_,e,s,n,ne.x,ne.y,y,m,c,r),f||(_.repeat="repeat");break;default:y&&Zt(_,e,ne.x,ne.y,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=te(),ee(_.transform,e.x,e.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=m),_.width=s,_.height=n,a&&(_.opacity=a),g&&(_.filters=g),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let re,le=new _;const{isSame:de}=B;function he(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||ae(n,s,i,a),!0}function ce(t,e){ge(t,A.LOAD,e)}function ue(t,e){ge(t,A.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),ge(t,A.ERROR,e)}function ge(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=S,{ceil:me,abs:ve}=Math;function xe(t,i,s){let{scaleX:n,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{n=ve(n),a=ve(a);const{image:t,data:r}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(u=ve(u),f=ve(f),d=_e(),ye(d,g),we(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!p&&_>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&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(d||(d=_e(),g&&ye(d,g)),we(d,1/n,1/a));const y=t.getCanvas(me(h)||1,me(c)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:be}=Math;const Be={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return re&&i===re.paint&&de(s,re.boxBounds)?a=re.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),re=r.use>1?{leafPaint:a,paint:i,boxBounds:le.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(he(t,e,i,r,a,s),n&&(ce(t,o),ue(t,o))):r.error?n&&fe(t,o,r.error):(n&&(pe(t,!0),ce(t,o)),a.loadId=r.load((()=>{pe(t,!1),t.destroyed||(he(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,o)),a.loadId=void 0}),(e=>{pe(t,!1),fe(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}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!U.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||U.running)){let{width:t,height:i}=l;t*=be(a)*r,i*=be(o)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(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||U.running?xe(t,s,r):s.patternTask||(s.patternTask=x.patternTasker.add((()=>it(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&xe(t,s,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:xe,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:ae,getPatternData:oe,fillOrFitMode:Zt,clipMode:$t,repeatMode:Kt},{toPoint:ke}=T,{hasTransparent:Se}=I,Re={},Ee={};function Le(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=I.string(n,s)):(o=n.offset,a=I.string(n.color,s)),e.addColorStop(o,a),!r&&Se(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Ae,getDistance:Te}=L,{get:Ce,rotateOfOuter:Oe,scaleOfOuter:We}=S,{toPoint:Pe}=T,Me={},De={};function Ie(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Ae(e,i);a=Ce(),n?(We(a,e,o/r*(s||1),1),Oe(a,e,t+90)):(We(a,e,1,o/r*(s||1)),Oe(a,e,t))}return a}const{getDistance:Fe}=L,{toPoint:Ue}=T,Ye={},Xe={};const Ne={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;ke(s||"top",i,Re),ke(n||"bottom",i,Ee);const r=e.canvas.createLinearGradient(Re.x,Re.y,Ee.x,Ee.y),l={type:a,style:r};return Le(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Pe(s||"center",i,Me),Pe(n||"bottom",i,De);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Te(Me,De)),d={type:a,style:l};Le(d,l,t.stops,o);const h=Ie(i,Me,De,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ue(s||"center",i,Ye),Ue(n||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ye.x,Ye.y):e.canvas.createRadialGradient(Ye.x,Ye.y,0,Ye.x,Ye.y,Fe(Ye,Xe)),d={type:a,style:l};Le(d,l,t.stops,o);const h=Ie(i,Ye,Xe,r||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ie},{copy:je,toOffsetOutBounds:ze}=B,Ge={},qe={};function He(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(je(Ge,t.bounds),Ge.x+=i.x-o.x,Ge.y+=i.y-o.y,s){const{matrix:t}=n;Ge.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ge.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ge.width*=s,Ge.height*=s}t.copyWorld(n.canvas,t.bounds,Ge)}else s&&(je(Ge,i),Ge.x-=i.width/2*(s-1),Ge.y-=i.height/2*(s-1),Ge.width*=s,Ge.height*=s),t.copyWorld(n.canvas,o,s?Ge:i)}const{toOffsetOutBounds:Ve}=B,Qe={};const Je={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;ze(d,qe),r.forEach(((r,p)=>{f.setWorldShadow(qe.offsetX+r.x*c,qe.offsetY+r.y*u,r.blur*c,I.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,qe,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ve(d,Qe),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Qe.offsetX+r.x*c,Qe.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,Qe,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.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:Ze}=p;function $e(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),ti(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ti(t,i,s,a);break;case"path":i.restore()}}function Ke(t){return t.getSameCanvas(!1,!0)}function ti(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r&&(o&&($e(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=Ke(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Ke(t)),n||(n=Ke(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Ze(i,e)||i.__render(n||t,e);$e(this,o,t,n,s,a)};const ei=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ii=ei+"_#~&*+\\=|≮≯≈≠=…",si=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 ni(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ai=ni("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oi=ni("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ri=ni(ei),li=ni(ii),di=ni("- —/~|┆·");var hi;!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"}(hi||(hi={}));const{Letter:ci,Single:ui,Before:fi,After:gi,Symbol:pi,Break:_i}=hi;function wi(t){return ai[t]?ci:di[t]?_i:oi[t]?fi:ri[t]?gi:li[t]?pi:si.test(t)?ui:ci}const yi={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 mi(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:vi}=yi,{Letter:xi,Single:bi,Before:Bi,After:ki,Symbol:Si,Break:Ri}=hi;let Ei,Li,Ai,Ti,Ci,Oi,Wi,Pi,Mi,Di,Ii,Fi,Ui,Yi,Xi,Ni,ji,zi=[];function Gi(t,e){Mi&&!Pi&&(Pi=Mi),Ei.data.push({char:t,width:e}),Ai+=e}function qi(){Ti+=Ai,Ei.width=Ai,Li.words.push(Ei),Ei={data:[]},Ai=0}function Hi(){Yi&&(Xi.paraNumber++,Li.paraStart=!0,Yi=!1),Mi&&(Li.startCharSize=Pi,Li.endCharSize=Mi,Pi=0),Li.width=Ti,Ni.width?vi(Li):ji&&Vi(),zi.push(Li),Li={words:[]},Ti=0}function Vi(){Ti>(Xi.maxWidth||0)&&(Xi.maxWidth=Ti)}const{top:Qi,right:Ji,bottom:Zi,left:$i}=C;function Ki(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 ts={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[$i],a-=d[Ji]+d[$i]):i.autoSizeAlign||(s=d[$i]),o?(n=d[Qi],o-=d[Qi]+d[Zi]):i.autoSizeAlign||(n=d[Qi]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Xi=t,zi=t.rows,Ni=t.bounds,ji=!Ni.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=Ni;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Yi=!0,Ii=null,Pi=Wi=Mi=Ai=Ti=0,Ei={data:[]},Li={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Oi=i[s],"\n"===Oi?(Ai&&qi(),Li.paraEnd=!0,Hi(),Yi=!0):(Di=wi(Oi),Di===xi&&"none"!==o&&(Oi=mi(Oi,o,!Ai)),Wi=r.measureText(Oi).width,n&&(n<0&&(Mi=Wi),Wi+=n),Fi=Di===bi&&(Ii===bi||Ii===xi)||Ii===bi&&Di!==ki,Ui=!(Di!==Bi&&Di!==bi||Ii!==Si&&Ii!==ki),Ci=Yi&&a?l-a:l,t&&l&&Ti+Ai+Wi>Ci&&(e?(Ai&&qi(),Ti&&Hi()):(Ui||(Ui=Di===xi&&Ii==ki),Fi||Ui||Di===Ri||Di===Bi||Di===bi||Ai+Wi>Ci?(Ai&&qi(),Ti&&Hi()):Ti&&Hi()))," "===Oi&&!0!==Yi&&Ti+Ai===0||(Di===Ri?(" "===Oi&&Ai&&qi(),Gi(Oi,Wi),qi()):Fi||Ui?(Ai&&qi(),Gi(Oi,Wi)):Gi(Oi,Wi)),Ii=Di);Ai&&qi(),Ti&&Hi(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Xi.paraNumber++,Ti=r.measureText(t).width,zi.push({x:a||0,text:t,width:Ti,paraStart:!0}),ji&&Vi()}))}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ki(e,"x",t[$i]);break;case"right":Ki(e,"x",-t[Ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ki(e,"y",t[Qi]);break;case"bottom":Ki(e,"y",-t[Zi])}}(d,h,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:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(y+=c),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<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,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,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(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===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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)}))}(h,i,a),h.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,h=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<h));s--){if(l<h&&" "!==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)}}))}}(h,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=I.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]}}(h,i),h}};const es={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.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(X,ts),Object.assign(I,es),Object.assign(D,Nt),Object.assign(M,Be),Object.assign(F,Ne),Object.assign(N,Je);const{setPoint:is,addPoint:ss,toBounds:ns}=j;const as={syncExport(t,e,i){let s;this.running=!0;const n=G.fileType(e),a=e.includes(".");i=G.getExportOptions(i);const{toURL:o}=q,{download:r}=q.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:h,isFrame:c}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!h||h.config.smooth:i.smooth,m=i.contextSettings||(h?h.config.contextSettings:void 0),v=d&&p&&void 0===i.fill?t.fill:i.fill,x=G.isOpaqueImage(e)||v,b=new H;if(p)n=!0===p?d?h.canvas.bounds:t.worldRenderBounds:p;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=h||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};V.getScaleData(i.scale,i.size,n,B);let k=i.pixelRatio||1,{x:S,y:R,width:E,height:L}=new z(n).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,C=Q.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=h||t,A.bounds=C.bounds),C.save(),c&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),g){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?ss(o,n,a):is(o={},n,a)),r++;const l=new z;return ns(o,l),l.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:k};C=Q.canvas(s),C.copyWorld(t,a,s)}if(_){const[t,e,i,s]=V.fourNumber(_),n=C,{width:a,height:o}=n;C=Q.canvas({width:a+s+e,height:o+t+i,pixelRatio:k}),C.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o})}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:n,trimBounds:a}}return this.running=!1,s},export(t,e,i){return this.running=!0,function(t){os||(os=new J);return new Promise((e=>{os.add((()=>it(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const a=()=>it(this,void 0,void 0,(function*(){if(!Z.isComplete)return q.requestRender(a);const o=as.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()}));t.updateLayout(),rs(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let os;function rs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>rs(t)))}const ls=$.prototype,ds=K.get("@leafer-in/export");ls.export=function(t,e){const{quality:i,blob:s}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ls.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{ds.error(t),i(null)}))}))},ls.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},ls.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{ds.error(t),i(!1)}))}))},tt.add("export"),Object.assign(U,as),et.prototype.export=function(t,e){return U.export(this,t,e)},et.prototype.syncExport=function(t,e){return U.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,s)=>new P(t,e,i,s),hitCanvas:(t,e)=>new st(t,e),hitCanvasManager:()=>new W});export{yt as Layouter,st as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,rt as Watcher,ot 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 h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,Debug as y,LeafLevelList as w,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,getMatrixData as S,MatrixHelper as R,MathHelper as E,AlignHelper as L,PointHelper as A,ImageEvent as T,AroundHelper as C,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as P}from"fs";import{HitCanvasManager as W,InteractionBase as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,Paint as F,ColorConvert as I,PaintGradient as Y,Export as U,Group as X,TextConvert as j,Effect as z,TwoPointBoundsHelper as N,Bounds as G,FileHelper as q,Platform as H,Matrix as V,MathHelper as Q,Creator as J,TaskProcessor as Z,Resource as $,LeaferCanvasBase as K,Debug as tt,Plugin as et,UI as it}from"@leafer-ui/draw";function st(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 nt 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:at,fileType:ot}=s;function rt(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(at(e),i),canvasToBolb:(t,e,i)=>st(this,void 0,void 0,(function*(){return t.toBuffer(at(e),i)})),canvasSaveAs:(t,e,i)=>st(this,void 0,void 0,(function*(){return P(e,t.toBuffer(at(ot(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 nt(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 lt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:dt,updateBounds:ht,updateChange:ct}=f,{pushAllChildBranch:ut,pushAllParent:ft}=g;const{worldBounds:gt}=p;class pt{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,gt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,gt),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:_t,updateAllChange:yt}=f,wt=y.get("Layouter");class mt{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){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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?(dt(t,!0),e.add(t),t.isBranch&&ut(t,e),ft(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ft(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||ht(s[t])}ht(i)}}))}(this.__levelList),function(t){t.list.forEach(ct)}(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)),mt.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){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),yt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new pt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new pt(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const vt=y.get("Renderer");class xt{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 _,vt.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,vt.error(t)}vt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return vt.warn("rendering");if(this.times>3)return vt.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(xt.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||vt.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)}}xt.clipSpread=10;const{hitRadiusPoint:bt}=B;class Bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||bt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class kt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function St(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 Rt(t,e){t.__.__font?St(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Et(t,e,i){switch(e.__.strokeAlign){case"center":Lt(t,1,e,i);break;case"inside":At(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Lt(t,2,e,i):At(t,"outside",e,i)}}function Lt(t,e,i,s){const n=i.__;"object"==typeof t?Ct(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Tt(i,s))}function At(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Lt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",St(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Tt(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 Ct(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||!M.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?Tt(s,n):n.stroke(),n.restoreBlendMode()):i?Tt(s,n):n.stroke()}}function Ot(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Et(t,e,i);else switch(s.strokeAlign){case"center":Pt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Pt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Pt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Pt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Pt(t,e,i,s){const n=i.__;"object"==typeof t?Ct(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&F.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new lt(t,e),layouter:(t,e)=>new mt(t,e),renderer:(t,e,i)=>new xt(t,e,i),selector:(t,e)=>new kt(t,e)}),e.layout=mt.fullLayout;const{getSpread:Wt,getOuterOf:Dt,getByMove:Mt,getIntersectData:Ft}=B;let It;const{stintSet:Yt}=l,{hasTransparent:Ut}=I;function Xt(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=M.image(i,t,e,n,!It||!It[e.url]);break;case"linear":s=Y.linearGradient(e,n);break;case"radial":s=Y.radialGradient(e,n);break;case"angular":s=Y.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:I.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:I.string(e)})}if(s){if("string"==typeof s.style&&Ut(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 jt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];r instanceof Array||(r=[r]),It=M.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Xt(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?(Yt(i,"__isAlphaPixelFill",n),Yt(i,"__isTransparentFill",a)):(Yt(i,"__isAlphaPixelStroke",n),Yt(i,"__isTransparentStroke",a),Yt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Rt(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(M.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),Rt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Rt(e,i),i.restoreBlendMode()):Rt(e,i)}},fillPathOrText:Rt,fillText:St,stroke:Ot,strokes:function(t,e,i){Ot(t,e,i)},strokeText:Et,drawTextStroke:Tt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Ft(s?Wt(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=Dt(n,o),a=Mt(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:h}}};let zt={},Nt=S();const{get:Gt,rotateOfOuter:qt,translate:Ht,scaleOfOuter:Vt,multiplyParent:Qt,scale:Jt,rotate:Zt,skew:$t}=R;function Kt(t,e,i,s,n,a,o){const r=Gt();Ht(r,e.x+i,e.y+s),Jt(r,n,a),o&&qt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function te(t,e,i,s,n,a,o,r,l){const d=Gt();o&&Zt(d,o),r&&$t(d,r.x,r.y),n&&Jt(d,n,a),Ht(d,e.x+i,e.y+s),l&&(Nt.a=e.width/l.width,Nt.d=e.height/l.height,Qt(d,Nt)),t.transform=d}function ee(t,e,i,s,n,a,o,r,l,d){const h=Gt();if(l)if("center"===d)qt(h,{x:i/2,y:s/2},l);else switch(Zt(h,l),l){case 90:Ht(h,s,0);break;case 180:Ht(h,i,s);break;case 270:Ht(h,0,i)}zt.x=e.x+n,zt.y=e.y+a,Ht(h,zt.x,zt.y),o&&Vt(h,zt,o,r),t.transform=h}const{get:ie,translate:se}=R,ne=new _,ae={},oe={};function re(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=le(i,s,e)}function le(t,e,i){t.padding&&(e=ne.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:h,rotation:c,skew:u,clipSize:f,repeat:g,filters:p}=t,_=e.width===s&&e.height===n,y={mode:o},w="center"!==r&&(c||0)%180==90;let m,v;switch(B.set(oe,0,0,w?n:s,w?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(E.getScaleData(d,h,i,ae),m=ae.scaleX,v=ae.scaleY),r&&(m&&B.scale(oe,m,v,!0),L.toPoint(r,oe,e,oe,!0,!0))):_&&!c||(m=v=B.getFitScale(e,oe,"fit"!==o),B.put(e,i,r,m,!1,oe),B.scale(oe,m,v,!0)),l&&A.move(oe,l),o){case"stretch":_||(s=e.width,n=e.height);break;case"normal":case"clip":(oe.x||oe.y||m||f||c||u)&&te(y,e,oe.x,oe.y,m,v,c,u,t.clipSize);break;case"repeat":(!_||m||c)&&ee(y,e,s,n,oe.x,oe.y,m,v,c,r),g||(y.repeat="repeat");break;default:m&&Kt(y,e,oe.x,oe.y,m,v,c)}return y.transform||(e.x||e.y)&&(y.transform=ie(),se(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),p&&(y.filters=p),g&&(y.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat"),y}let de,he=new _;const{isSame:ce}=B;function ue(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||re(n,s,i,a),!0}function fe(t,e){_e(t,T.LOAD,e)}function ge(t,e){_e(t,T.LOADED,e)}function pe(t,e,i){e.error=i,t.forceUpdate("surface"),_e(t,T.ERROR,e)}function _e(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function ye(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:we,scale:me,copy:ve}=R,{ceil:xe,abs:be}=Math;function Be(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:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(u=be(u),f=be(f),d=we(),ve(d,g),me(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!p&&_>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,h/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(d||(d=we(),g&&ve(d,g)),me(d,1/n,1/a));const w=t.getCanvas(xe(h)||1,xe(c)||1,r.opacity,r.filters),m=t.getPattern(w,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const ke={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return de&&i===de.paint&&ce(s,de.boxBounds)?a=de.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),de=r.use>1?{leafPaint:a,paint:i,boxBounds:he.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ue(t,e,i,r,a,s),n&&(fe(t,o),ge(t,o))):r.error?n&&pe(t,o,r.error):(n&&(ye(t,!0),fe(t,o)),a.loadId=r.load((()=>{ye(t,!1),t.destroyed||(ue(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ge(t,o)),a.loadId=void 0}),(e=>{ye(t,!1),pe(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&&!U.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||U.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||U.running?Be(t,s,r):s.patternTask||(s.patternTask=x.patternTasker.add((()=>st(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Be(t,s,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:Be,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:re,getPatternData:le,fillOrFitMode:Kt,clipMode:te,repeatMode:ee},{toPoint:Se}=C,{hasTransparent:Re}=I,Ee={},Le={};function Ae(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=I.string(n,s)):(o=n.offset,a=I.string(n.color,s)),e.addColorStop(o,a),!r&&Re(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Te,getDistance:Ce}=A,{get:Oe,rotateOfOuter:Pe,scaleOfOuter:We}=R,{toPoint:De}=C,Me={},Fe={};function Ie(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Te(e,i);a=Oe(),n?(We(a,e,o/r*(s||1),1),Pe(a,e,t+90)):(We(a,e,1,o/r*(s||1)),Pe(a,e,t))}return a}const{getDistance:Ye}=A,{toPoint:Ue}=C,Xe={},je={};const ze={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;Se(s||"top",i,Ee),Se(n||"bottom",i,Le);const r=e.canvas.createLinearGradient(Ee.x,Ee.y,Le.x,Le.y),l={type:a,style:r};return Ae(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;De(s||"center",i,Me),De(n||"bottom",i,Fe);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Ce(Me,Fe)),d={type:a,style:l};Ae(d,l,t.stops,o);const h=Ie(i,Me,Fe,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ue(s||"center",i,Xe),Ue(n||"bottom",i,je);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Xe.x,Xe.y):e.canvas.createRadialGradient(Xe.x,Xe.y,0,Xe.x,Xe.y,Ye(Xe,je)),d={type:a,style:l};Ae(d,l,t.stops,o);const h=Ie(i,Xe,je,r||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ie},{copy:Ne,toOffsetOutBounds:Ge}=B,qe={},He={};function Ve(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Ne(qe,t.bounds),qe.x+=i.x-o.x,qe.y+=i.y-o.y,s){const{matrix:t}=n;qe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),qe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),qe.width*=s,qe.height*=s}t.copyWorld(n.canvas,t.bounds,qe)}else s&&(Ne(qe,i),qe.x-=i.width/2*(s-1),qe.y-=i.height/2*(s-1),qe.width*=s,qe.height*=s),t.copyWorld(n.canvas,o,s?qe:i)}const{toOffsetOutBounds:Qe}=B,Je={};const Ze={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ge(d,He),r.forEach(((r,_)=>{g.setWorldShadow(He.offsetX+r.x*c,He.offsetY+r.y*u,r.blur*c,I.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ve(g,He,n,i),s=d,r.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,h,d,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Qe(d,Je),r.forEach(((r,_)=>{g.save(),g.setWorldShadow(Je.offsetX+r.x*c,Je.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ve(g,Je,n,i),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,d,"source-out"),s=d),g.fillWorld(s,I.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.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:$e}=p;function Ke(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),ei(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ei(t,i,s,a);break;case"path":i.restore()}}function ti(t){return t.getSameCanvas(!1,!0)}function ei(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}X.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r?(o&&(Ke(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=ti(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ti(t)),n||(n=ti(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||$e(i,e)||i.__render(t,e)):$e(i,e)||i.__render(n||t,e);Ke(this,o,t,n,s,a)};const ii=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",si=ii+"_#~&*+\\=|≮≯≈≠=…",ni=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 ai(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const oi=ai("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ri=ai("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),li=ai(ii),di=ai(si),hi=ai("- —/~|┆·");var ci;!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"}(ci||(ci={}));const{Letter:ui,Single:fi,Before:gi,After:pi,Symbol:_i,Break:yi}=ci;function wi(t){return oi[t]?ui:hi[t]?yi:ri[t]?gi:li[t]?pi:di[t]?_i:ni.test(t)?fi:ui}const mi={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 vi(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:xi}=mi,{Letter:bi,Single:Bi,Before:ki,After:Si,Symbol:Ri,Break:Ei}=ci;let Li,Ai,Ti,Ci,Oi,Pi,Wi,Di,Mi,Fi,Ii,Yi,Ui,Xi,ji,zi,Ni,Gi=[];function qi(t,e){Mi&&!Di&&(Di=Mi),Li.data.push({char:t,width:e}),Ti+=e}function Hi(){Ci+=Ti,Li.width=Ti,Ai.words.push(Li),Li={data:[]},Ti=0}function Vi(){Xi&&(ji.paraNumber++,Ai.paraStart=!0,Xi=!1),Mi&&(Ai.startCharSize=Di,Ai.endCharSize=Mi,Di=0),Ai.width=Ci,zi.width?xi(Ai):Ni&&Qi(),Gi.push(Ai),Ai={words:[]},Ci=0}function Qi(){Ci>(ji.maxWidth||0)&&(ji.maxWidth=Ci)}const{top:Ji,right:Zi,bottom:$i,left:Ki}=O;function ts(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 es={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[Ki],a-=d[Zi]+d[Ki]):i.autoSizeAlign||(s=d[Ki]),o?(n=d[Ji],o-=d[Ji]+d[$i]):i.autoSizeAlign||(n=d[Ji]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){ji=t,Gi=t.rows,zi=t.bounds,Ni=!zi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=zi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Xi=!0,Ii=null,Di=Wi=Mi=Ti=Ci=0,Li={data:[]},Ai={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Pi=i[s],"\n"===Pi?(Ti&&Hi(),Ai.paraEnd=!0,Vi(),Xi=!0):(Fi=wi(Pi),Fi===bi&&"none"!==o&&(Pi=vi(Pi,o,!Ti)),Wi=r.measureText(Pi).width,n&&(n<0&&(Mi=Wi),Wi+=n),Yi=Fi===Bi&&(Ii===Bi||Ii===bi)||Ii===Bi&&Fi!==Si,Ui=!(Fi!==ki&&Fi!==Bi||Ii!==Ri&&Ii!==Si),Oi=Xi&&a?l-a:l,t&&l&&Ci+Ti+Wi>Oi&&(e?(Ti&&Hi(),Ci&&Vi()):(Ui||(Ui=Fi===bi&&Ii==Si),Yi||Ui||Fi===Ei||Fi===ki||Fi===Bi||Ti+Wi>Oi?(Ti&&Hi(),Ci&&Vi()):Ci&&Vi()))," "===Pi&&!0!==Xi&&Ci+Ti===0||(Fi===Ei?(" "===Pi&&Ti&&Hi(),qi(Pi,Wi),Hi()):Yi||Ui?(Ti&&Hi(),qi(Pi,Wi)):qi(Pi,Wi)),Ii=Fi);Ti&&Hi(),Ci&&Vi(),Gi.length>0&&(Gi[Gi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{ji.paraNumber++,Ci=r.measureText(t).width,Gi.push({x:a||0,text:t,width:Ci,paraStart:!0}),Ni&&Qi()}))}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ts(e,"x",t[Ki]);break;case"right":ts(e,"x",-t[Zi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ts(e,"y",t[Ji]);break;case"bottom":ts(e,"y",-t[$i])}}(d,h,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:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=o;if(l&&y>_)y=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(w+=c),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&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,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,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(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===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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)}))}(h,i,a),h.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,h=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<h));s--){if(l<h&&" "!==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)}}))}}(h,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=I.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]}}(h,i),h}};const is={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.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(j,es),Object.assign(I,is),Object.assign(F,jt),Object.assign(M,ke),Object.assign(Y,ze),Object.assign(z,Ze);const{setPoint:ss,addPoint:ns,toBounds:as}=N;const os={syncExport(t,e,i){let s;U.running=!0;try{const n=q.fileType(e),a=e.includes(".");i=q.getExportOptions(i);const{toURL:o}=H,{download:r}=H.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:h,isFrame:c}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:y}=i,w=void 0===i.smooth?!h||h.config.smooth:i.smooth,m=i.contextSettings||(h?h.config.contextSettings:void 0),v=d&&p&&void 0===i.fill?t.fill:i.fill,x=q.isOpaqueImage(e)||v,b=new V;if(p)n=!0===p?d?h.canvas.bounds:t.worldRenderBounds:p;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=h||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 k=i.pixelRatio||1,{x:S,y:R,width:E,height:L}=new G(n).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,C=J.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:w,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=h||t,A.bounds=C.bounds),C.save(),c&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),g){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?ns(o,n,a):ss(o={},n,a)),r++;const l=new G;return o&&(as(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:k};C=J.canvas(s),C.copyWorld(t,a,s)}if(_){const[t,e,i,s]=Q.fourNumber(_),n=C,{width:a,height:o}=n;C=J.canvas({width:a+s+e,height:o+t+i,pixelRatio:k}),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 U.running=!1,s},export(t,e,i){return U.running=!0,function(t){rs||(rs=new Z);return new Promise((e=>{rs.add((()=>st(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const a=()=>st(this,void 0,void 0,(function*(){if(!$.isComplete)return H.requestRender(a);const o=U.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()}));t.updateLayout(),ls(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let rs;function ls(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ls(t)))}const ds=K.prototype,hs=tt.get("@leafer-in/export");ds.export=function(t,e){const{quality:i,blob:s}=q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ds.toBlob=function(t,e){return new Promise((i=>{H.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{hs.error(t),i(null)}))}))},ds.toDataURL=function(t,e){return H.origin.canvasToDataURL(this.view,t,e)},ds.saveAs=function(t,e){return new Promise((i=>{H.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{hs.error(t),i(!1)}))}))},et.add("export"),Object.assign(U,os),it.prototype.export=function(t,e){return U.export(this,t,e)},it.prototype.syncExport=function(t,e){return U.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,s)=>new D(t,e,i,s),hitCanvas:(t,e)=>new nt(t,e),hitCanvasManager:()=>new W});export{mt as Layouter,nt as LeaferCanvas,Bt as Picker,xt as Renderer,kt as Selector,lt as Watcher,rt as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|