@leafer-ui/node 1.0.0-rc.3 → 1.0.0-rc.30
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 +1396 -927
- package/dist/node.esm.js +1397 -928
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +12 -8
- package/src/index.ts +13 -0
- package/types/index.d.ts +1 -0
package/dist/node.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as _,Run as f,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,LeaferImage as x,InteractionBase as b,MatrixHelper as B,ImageEvent as R,PointHelper as E,MathHelper as L,TaskProcessor as k}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as S,Paint as A,Effect as C,TextConvert as O,Export as M}from"@leafer-ui/core";export*from"@leafer-ui/core";class T{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.default(i,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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:I,updateAllWorldOpacity:W}=a,{pushAllChildBranch:D,pushAllParent:P}=o;const{worldBounds:F}=h,{setByListWithHandle:N}=l;class U{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){N(this.beforeBounds,this.updatedList.list,F)}setAfter(){N(this.afterBounds,this.updatedList.list,F),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:Y,updateAllChange:H}=a,{pushAllBranchStack:V,updateWorldBoundsByBranchStack:j}=o,q=c.get("Layouter");class X{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,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.running)return;const{target:t}=this;this.times=0;try{t.emit(_.START),this.layoutOnce(),t.emitEvent(new _(_.END,this.layoutedBlocks,this.times))}catch(t){q.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?q.warn("layouting"):this.times>3?q.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=f.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=_,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new _(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(I(t),e.push(t),t.isBranch&&D(t,e),P(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),P(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&W(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new _(r,o,this.times)),s.emitEvent(new _(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=_,a=this.getBlocks(new t(s));s.emitEvent(new _(i,a,this.times)),X.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new _(n,a,this.times)),s.emitEvent(new _(r,a,this.times)),this.addBlocks(a),f.end(e)}static fullLayout(t){if(Y(t),t.isBranch){const e=[t];V(t,e),j(e)}else t.__updateWorldBounds();H(t)}createBlock(t){return new U(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(){const{target:t}=this;this.__eventIds=[t.on_(_.REQUEST,this.layout,this),t.on_(_.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const G=c.get("Renderer");class z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(_.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,G.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,G.error(t)}G.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?G.warn("rendering"):this.times>3?G.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return G.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),f.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||G.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(_.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:Q}=l;class Z{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||Q(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class K{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new Z(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(_.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new T(t,e),layouter:(t,e)=>new X(t,e),renderer:(t,e,s)=>new z(t,e,s),selector:(t,e)=>new K(t,e)}),p.layout=X.fullLayout;class $ extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}function J(t,e){if(!p.origin){if("skia"===t){const{Canvas:t,loadImage:s}=e;p.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:s}}p.canvas=m.canvas()}}Object.assign(m,{canvas:(t,e)=>new $(t,e),image:t=>new x(t),hitCanvas:(t,e)=>new $(t,e),interaction:(t,e,s,i)=>new b(t,e,s,i)}),p.name="node",p.requestRender=function(t){setTimeout(t)},p.devicePixelRatio=1,p.conicGradientSupport=!0,p.realtimeLayout=!0;const{get:tt,rotateOfOuter:et,translate:st,scaleOfOuter:it,scale:nt,rotate:rt}=B;const{get:at,translate:ot}=B;function dt(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const _=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(_.transform=at(),ot(_.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=tt();st(r,e.x,e.y),s&&st(r,s.x,s.y),i&&("number"==typeof i?nt(r,i):nt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&rt(r,n),t.transform=r}(_,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=tt();if(r)switch(rt(a,r),r){case 90:st(a,i,0);break;case 180:st(a,s,i);break;case 270:st(a,0,s)}st(a,e.x,e.y),n&&(it(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(_,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=tt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;st(a,c,u),nt(a,l),r&&et(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(_,o,i,n,r,l)}_.width=n,_.height=r,a&&(_.opacity=a)}function ht(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function lt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new R(t,e))}function ct(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:ut,scale:_t,copy:ft}=B;function gt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:_,scaleY:f,opacity:g,transform:y,mode:w}=a;_&&(l=ut(),ft(l,y),_t(l,1/_,1/f),i*=_,n*=f),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),_&&(i/=_,n/=f),(y||1!==i||1!==n)&&(l||(l=ut(),y&&ft(l,y)),_t(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function pt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>ct(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&>(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):gt(t,s,e.pixelRatio),!1}return!1}function yt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function wt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function mt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?bt(t,s,e,!0):xt(t,e);break;case"inside":vt(t,e,s,"inside",n);break;case"outside":vt(t,e,s,"outside",n)}}function vt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?bt(t,s,o,!0):xt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",wt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function xt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function bt(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&pt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?xt(t,s):s.stroke(),s.restoreBlendMode()):i?xt(t,s):s.stroke())}const{getSpread:Bt,getOuterOf:Rt,getByMove:Et,getIntersectData:Lt}=l;const kt={x:.5,y:0},St={x:.5,y:1};function At(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,S.string(i.color,s))}const{set:Ct,getAngle:Ot,getDistance:Mt}=E,{get:Tt,rotateOfOuter:It,scaleOfOuter:Wt}=B,Dt={x:.5,y:.5},Pt={x:.5,y:1},Ft={},Nt={};const{set:Ut,getAngle:Yt,getDistance:Ht}=E,{get:Vt,rotateOfOuter:jt,scaleOfOuter:qt}=B,Xt={x:.5,y:.5},Gt={x:.5,y:1},zt={},Qt={};let Zt;function Kt(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:S.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ht(t,e,a)&&dt(r,a,s,i),n&&(lt(R.LOAD,o),lt(R.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,lt(R.ERROR,o)):(n&<(R.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ht(t,e,a)&&(dt(r,a,s,i),t.forceUpdate("surface")),lt(R.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,lt(R.ERROR,o)}))),r}(t,s,e,i,!Zt||!Zt[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=kt),i||(i=St);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);At(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Dt),i||(i=Pt);const{x:d,y:h,width:l,height:c}=e;let u;Ct(Ft,d+s.x*l,h+s.y*c),Ct(Nt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Tt(),Wt(u,Ft,l/c*(o||1),1),It(u,Ft,Ot(Ft,Nt)+90));const _=p.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Mt(Ft,Nt));At(_,t.stops,r);const f={type:n,style:_,transform:u};return a&&(f.blendMode=a),f}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Xt),i||(i=Gt);const{x:d,y:h,width:l,height:c}=e;Ut(zt,d+s.x*l,h+s.y*c),Ut(Qt,d+i.x*l,h+i.y*c);const u=Vt(),_=Yt(zt,Qt);p.conicGradientRotate90?(qt(u,zt,l/c*(o||1),1),jt(u,zt,_+90)):(qt(u,zt,1,l/c*(o||1)),jt(u,zt,_));const f=p.conicGradientSupport?p.canvas.createConicGradient(0,zt.x,zt.y):p.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Ht(zt,Qt));At(f,t.stops,r);const g={type:n,style:f,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:S.string(e)}:void 0}}var $t=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),Zt=yt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=Kt(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:xt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:wt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&pt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?wt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?wt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?wt(t,e):n?e.fill(n):e.fill())},recycleImage:yt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=Rt(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Lt(i?Bt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=Rt(d,r),n=Et(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:mt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)mt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),bt(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),bt(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),bt(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:Jt,toOffsetOutBounds:te}=l,ee={},se={};function ie(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(Jt(ee,t.bounds),ee.x+=e.x-r.x,ee.y+=e.y-r.y,s){const{matrix:t}=i;ee.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),ee.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),ee.width*=s,ee.height*=s}t.copyWorld(i.canvas,t.bounds,ee)}else s&&(Jt(ee,e),ee.x-=e.width/2*(s-1),ee.y-=e.height/2*(s-1),ee.width*=s,ee.height*=s),t.copyWorld(i.canvas,r,s?ee:e)}const{toOffsetOutBounds:ne}=l,re={};var ae=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;ne(l,re),d.forEach(((i,d)=>{f.save(),f.setWorldShadow(re.offsetX+i.x*u,re.offsetY+i.y*_,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(f,re,r,s),f.restore(),h?(f.copyWorld(f,l,a,"copy"),f.copyWorld(h,a,a,"source-out"),n=a):(f.copyWorld(s.canvas,c,l,"source-out"),n=l),f.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(f,n,a,i.blendMode):e.copyWorldToInner(f,n,o.renderBounds,i.blendMode),g&&d<g&&f.clear()})),f.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:_}=s,f=e.getSameCanvas(),g=d.length-1;te(l,se),d.forEach(((i,d)=>{f.setWorldShadow(se.offsetX+i.x*u,se.offsetY+i.y*_,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,ie(f,se,r,s),n=l,i.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,a,"copy"),n=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(f,n,a,i.blendMode):e.copyWorldToInner(f,n,o.renderBounds,i.blendMode),g&&d<g&&f.clear()})),f.recycle()}});const oe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",de=oe+"_#~&*+\\=|≮≯≈≠=…",he=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 le(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ce=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ue=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),_e=le(oe),fe=le(de),ge=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:ye,Single:we,Before:me,After:ve,Symbol:xe,Break:be}=pe;function Be(t){return ce[t]?ye:ge[t]?be:ue[t]?me:_e[t]?ve:fe[t]?xe:he.test(t)?we:ye}const Re={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ee(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Le}=Re,{Letter:ke,Single:Se,Before:Ae,After:Ce,Symbol:Oe,Break:Me}=pe;let Te,Ie,We,De,Pe,Fe,Ne,Ue,Ye,He,Ve,je,qe,Xe,Ge,ze,Qe=[];function Ze(t,e){Ye&&!Ue&&(Ue=Ye),Te.data.push({char:t,width:e}),We+=e}function Ke(){De+=We,Te.width=We,Ie.words.push(Te),Te={data:[]},We=0}function $e(){Xe&&(Ge.paraNumber++,Ie.paraStart=!0,Xe=!1),Ye&&(Ie.startCharSize=Ue,Ie.endCharSize=Ye,Ue=0),Ie.width=De,ze.width&&Le(Ie),Qe.push(Ie),Ie={words:[]},De=0}const Je={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=L.fourNumber(h);n&&(s=o,n-=e+o),r&&(i=t,r-=t+a)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,s){Ge=t,Qe=t.rows,ze=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=ze;if(o||d||i||"none"!==r){Xe=!0,Ve=null,Ue=Ne=Ye=We=De=0,Te={data:[]},Ie={words:[]};for(let t=0,s=e.length;t<s;t++)Fe=e[t],"\n"===Fe?(We&&Ke(),Ie.paraEnd=!0,$e(),Xe=!0):(He=Be(Fe),He===ke&&"none"!==r&&(Fe=Ee(Fe,r,!We)),Ne=a.measureText(Fe).width,i&&(i<0&&(Ye=Ne),Ne+=i),je=He===Se&&(Ve===Se||Ve===ke)||Ve===Se&&He!==Ce,qe=!(He!==Ae&&He!==Se||Ve!==Oe&&Ve!==Ce),Pe=Xe&&n?o-n:o,o&&De+We+Ne>Pe&&(qe||(qe=He===ke&&Ve==Ce),je||qe||He===Me||He===Ae||He===Se||We+Ne>Pe?(We&&Ke(),$e()):$e())," "===Fe&&!0!==Xe&&De+We===0||(He===Me?(" "===Fe&&We&&Ke(),Ze(Fe,Ne),Ke()):je||qe?(We&&Ke(),Ze(Fe,Ne)):Ze(Fe,Ne)),Ve=He);We&&Ke(),De&&$e(),Qe.length>0&&(Qe[Qe.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ge.paraNumber++,Qe.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,_,{x:f,y:g,width:p,height:y}=i,w=n*s.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&w>y)w=Math.max(y,n),t.overflow=s.length;else switch(d){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=f,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,_=c.width,a<0&&(c.width<0?(_=-c.width+e.fontSize+a,u-=_,_+=e.fontSize):_-=a),u<i.x&&(i.x=u),_>i.width&&(i.width=_)}i.y=g,i.height=w}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ts={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},es={export(t,e,s){return function(t){ss||(ss=new k);return new Promise((e=>{ss.add((()=>ct(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>ct(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let ss;Object.assign(A,$t),Object.assign(C,ae),Object.assign(O,Je),Object.assign(S,ts),Object.assign(M,es);export{X as Layouter,$ as LeaferCanvas,z as Renderer,K as Selector,T as Watcher,J as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as S,PointHelper as M,Direction4 as A,TwoPointBoundsHelper as C,TaskProcessor as W,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{InteractionBase as I,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as F,PaintGradient as N,Export as U,Group as Y,TextConvert as j,Paint as G,Effect as H}from"@leafer-ui/draw";function V(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class X 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:q,fileType:z}=o;function Q(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(q(e),i),canvasToBolb:(t,e,i)=>V(this,void 0,void 0,(function*(){return t.toBuffer(q(e),i)})),canvasSaveAs:(t,e,i)=>V(this,void 0,void 0,(function*(){return O(e,t.toBuffer(q(z(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=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new X(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new a;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 a,this.target=t,e&&(this.config=r.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:K,updateAllWorldOpacity:$}=u,{pushAllChildBranch:tt,pushAllParent:et}=f;const{worldBounds:it}=_,nt={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,it),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:ot,updateAllChange:at}=u,rt=p.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(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?(Z(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(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||K(n[t])}K(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&$(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(o,r,this.times)),i.emitEvent(new y(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(i,o,this.times)),dt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(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(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=p.get("Renderer");class lt{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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new g,ht.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,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;if(!e)return ht.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(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 g(0,0,1,1)),this.changed=!0}}__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||ht.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(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(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)}}const{hitRadiusPoint:ct}=B;class ut{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new a(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new a;const{x:n,y:s}=this.point,o={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,o),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 a;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new a;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new a,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,o;for(let t=0,a=i.length;t<a;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(o=n.list[t],!s||!s.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ct(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.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()}}const{Yes:ft,NoAndSkip:gt,YesAndSkip:_t}=R,pt={},wt={},yt={};class mt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new ut(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":pt.id=t.substring(1),t=pt;break;case".":wt.className=t.substring(1),t=wt;break;default:yt.tag=t,t=yt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?r.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,o;for(let a=0,r=t.length;a<r;a++){if(s=t[a],o=e(s,n),o===ft||o===_t){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&o<gt&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function vt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function xt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?Rt(t,!0,e,i):Bt(e,i);break;case"inside":bt("inside",t,s,e,i);break;case"outside":bt("outside",t,s,e,i)}}function bt(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?Rt(e,!0,n,r):Bt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",vt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function Bt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function Rt(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Bt(i,n):n.stroke(),n.restoreBlendMode()):e?Bt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new mt(t,e)}),e.layout=dt.fullLayout;const{getSpread:kt,getOuterOf:Et,getByMove:Lt,getIntersectData:St}=B;let Mt;function At(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:F.string(a,r)};case"image":return D.image(i,t,e,n,!Mt||!Mt[e.url]);case"linear":return N.linearGradient(e,n);case"radial":return N.radialGradient(e,n);case"angular":return N.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:F.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),Mt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=At(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?vt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&D.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?vt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?vt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?vt(e,i):s?i.fill(s):i.fill())},fillText:vt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)xt(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)xt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),Rt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Rt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),Rt(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:xt,drawTextStroke:Bt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=St(n?kt(e.bounds,h===l?n*h:[n*l,n*h]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=Et(s,a),o=Lt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Wt={};const{get:Tt,rotateOfOuter:Ot,translate:It,scaleOfOuter:Pt,scale:Dt,rotate:Ft}=k;function Nt(t,e,i,n,s,o,a){const r=Tt();It(r,e.x+i,e.y+n),Dt(r,s,o),a&&Ot(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ut(t,e,i,n,s,o,a){const r=Tt();It(r,e.x+i,e.y+n),s&&Dt(r,s,o),a&&Ft(r,a),t.transform=r}function Yt(t,e,i,n,s,o,a,r,d,h){const l=Tt();if(d)if("center"===h)Ot(l,{x:i/2,y:n/2},d);else switch(Ft(l,d),d){case 90:It(l,n,0);break;case 180:It(l,i,n);break;case 270:It(l,0,i)}Wt.x=e.x+s,Wt.y=e.y+o,It(l,Wt.x,Wt.y),a&&Pt(l,Wt,a,r),t.transform=l}const{get:jt,translate:Gt}=k,Ht=new g,Vt={};function Xt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=qt(i,n,e)}function qt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ht.set(e).shrink(t.padding));const{opacity:o,mode:a,align:r,offset:d,scale:h,size:l,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:a},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/s):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Vt,!0),v+=Vt.x,x+=Vt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ut(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Yt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Nt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=jt(),Gt(g.transform,e.x,e.y)),y&&"strench"!==a&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let zt,Qt=new g;const{isSame:Jt}=B;function Zt(t,e,i,n,s,o){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||Xt(s,n,i,o),!0}function Kt(t,e){ee(t,L.LOAD,e)}function $t(t,e){ee(t,L.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,L.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:se,copy:oe}=k,{ceil:ae,abs:re}=Math;function de(t,i,n){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=re(s),o=re(o);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=ne(),oe(h,_),se(h,1/u,1/f),s*=u,o*=f),s*=n,o*=n,l*=s,c*=o;const w=l*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,l/=d,c/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(h||(h=ne(),_&&oe(h,_)),se(h,1/s,1/o));const m=t.getCanvas(ae(l)||1,ae(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=a,!0}}const{abs:he}=Math;const le={image:function(t,e,i,n,s){let o,a;const r=v.get(i);return zt&&i===zt.paint&&Jt(n,zt.boxBounds)?o=zt.leafPaint:(o={type:i.type,image:r},zt=r.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Zt(t,e,i,r,o,n),s&&(Kt(t,a),$t(t,a))):r.error?s&&te(t,a,r.error):(ie(t,!0),s&&Kt(t,a),o.loadId=r.load((()=>{ie(t,!1),t.destroyed||(Zt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,a)),o.loadId=null}),(e=>{ie(t,!1),te(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=he(o)*i.pixelRatio,n*=he(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize||U.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||U.running?de(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>V(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&de(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:de,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,v.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Xt,getPatternData:qt,fillOrFitMode:Nt,clipMode:Ut,repeatMode:Yt},{toPoint:ce}=S,ue={},fe={};function ge(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),F.string(n,i)):t.addColorStop(n.offset,F.string(n.color,i))}const{getAngle:_e,getDistance:pe}=M,{get:we,rotateOfOuter:ye,scaleOfOuter:me}=k,{toPoint:ve}=S,xe={},be={};function Be(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=_e(e,i);o=we(),s?(me(o,e,a/r*(n||1),1),ye(o,e,t+90)):(me(o,e,1,a/r*(n||1)),ye(o,e,t))}return o}const{getDistance:Re}=M,{toPoint:ke}=S,Ee={},Le={};const Se={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ce(n||"top",i,ue),ce(s||"bottom",i,fe);const d=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y);ge(d,t.stops,r);const h={type:o,style:d};return a&&(h.blendMode=a),h},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ve(n||"center",i,xe),ve(s||"bottom",i,be);const h=e.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,pe(xe,be));ge(h,t.stops,a);const l={type:o,style:h},c=Be(i,xe,be,d,!0);return c&&(l.transform=c),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ke(n||"center",i,Ee),ke(s||"bottom",i,Le);const h=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Re(Ee,Le));ge(h,t.stops,a);const l={type:o,style:h},c=Be(i,Ee,Le,d||1,e.conicGradientRotate90);return c&&(l.transform=c),r&&(l.blendMode=r),l},getTransform:Be},{copy:Me,toOffsetOutBounds:Ae}=B,Ce={},We={};function Te(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(Me(Ce,t.bounds),Ce.x+=i.x-a.x,Ce.y+=i.y-a.y,n){const{matrix:t}=s;Ce.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Ce.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Ce.width*=n,Ce.height*=n}t.copyWorld(s.canvas,t.bounds,Ce)}else n&&(Me(Ce,i),Ce.x-=i.width/2*(n-1),Ce.y-=i.height/2*(n-1),Ce.width*=n,Ce.height*=n),t.copyWorld(s.canvas,a,n?Ce:i)}const{toOffsetOutBounds:Oe}=B,Ie={};const Pe={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ae(h,We),r.forEach(((r,_)=>{f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Te(f,We,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Oe(h,Ie),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ie.offsetX+r.x*c,Ie.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Te(f,Ie,s,i),f.restore(),d?(f.copyWorld(f,h,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&_<g&&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:De}=_;function Fe(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ue(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ue(t,i,n,o);break;case"path":i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(a&&(Fe(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ne(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ne(t)),s||(s=Ne(t)),i.__render(n,e)),"clipping"!==i.__.mask)||De(i,e)||i.__render(s||t,e);Fe(this,a,t,s,n,o)};const Ye=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",je=Ye+"_#~&*+\\=|≮≯≈≠=…",Ge=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 He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ve=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Xe=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=He(Ye),ze=He(je),Qe=He("- —/~|┆·");var Je;!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"}(Je||(Je={}));const{Letter:Ze,Single:Ke,Before:$e,After:ti,Symbol:ei,Break:ii}=Je;function ni(t){return Ve[t]?Ze:Qe[t]?ii:Xe[t]?$e:qe[t]?ti:ze[t]?ei:Ge.test(t)?Ke:Ze}const si={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function oi(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:ai}=si,{Letter:ri,Single:di,Before:hi,After:li,Symbol:ci,Break:ui}=Je;let fi,gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li,Si,Mi=[];function Ai(t,e){xi&&!vi&&(vi=xi),fi.data.push({char:t,width:e}),_i+=e}function Ci(){pi+=_i,fi.width=_i,gi.words.push(fi),fi={data:[]},_i=0}function Wi(){Ei&&(Li.paraNumber++,gi.paraStart=!0,Ei=!1),xi&&(gi.startCharSize=vi,gi.endCharSize=xi,vi=0),gi.width=pi,Si.width&&ai(gi),Mi.push(gi),gi={words:[]},pi=0}const Ti=0,Oi=1,Ii=2;const{top:Pi,right:Di,bottom:Fi,left:Ni}=A;function Ui(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 Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(o&&(n=h[Ni],o-=h[Di]+h[Ni]),a&&(s=h[Pi],a-=h[Pi]+h[Fi]));const l={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Li=t,Mi=t.rows,Si=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:h}=Si;if(d||h||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,Bi=null,vi=mi=xi=_i=pi=0,fi={data:[]},gi={words:[]};for(let n=0,h=i.length;n<h;n++)yi=i[n],"\n"===yi?(_i&&Ci(),gi.paraEnd=!0,Wi(),Ei=!0):(bi=ni(yi),bi===ri&&"none"!==a&&(yi=oi(yi,a,!_i)),mi=r.measureText(yi).width,s&&(s<0&&(xi=mi),mi+=s),Ri=bi===di&&(Bi===di||Bi===ri)||Bi===di&&bi!==li,ki=!(bi!==hi&&bi!==di||Bi!==ci&&Bi!==li),wi=Ei&&o?d-o:d,t&&d&&pi+_i+mi>wi&&(e?(_i&&Ci(),pi&&Wi()):(ki||(ki=bi===ri&&Bi==li),Ri||ki||bi===ui||bi===hi||bi===di||_i+mi>wi?(_i&&Ci(),pi&&Wi()):pi&&Wi()))," "===yi&&!0!==Ei&&pi+_i===0||(bi===ui?(" "===yi&&_i&&Ci(),Ai(yi,mi),Ci()):Ri||ki?(_i&&Ci(),Ai(yi,mi)):Ai(yi,mi)),Bi=bi);_i&&Ci(),pi&&Wi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,Mi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ui(e,"x",t[Ni]);break;case"right":Ui(e,"x",-t[Di])}if(!s)switch(i.verticalAlign){case"top":Ui(e,"y",t[Pi]);break;case"bottom":Ui(e,"y",-t[Fi])}}(h,l,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let o=0,h=i.length;o<h;o++){if(c=i[o],c.x=g,c.width<p||c.width>p&&!r)switch(d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&o>0&&(m+=l),c.y=m,m+=s,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ti:h>.01?Oi:Ii,t.isOverflow&&!r&&(t.textMode=!0),c===Ii?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Oi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const h=r?e.canvas.measureText(r).width:0,l=n+s-h;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<l));n--){if(d<l&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const ji={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Gi,addPoint:Hi,toBounds:Vi}=C;const Xi={export(t,i,s){this.running=!0;const a=o.fileType(i);return s=o.getExportOptions(s),function(t){qi||(qi=new W);return new Promise((e=>{qi.add((()=>V(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((d=>{const h=t=>{r(t),d(),this.running=!1},{toURL:l}=e,{download:c}=e.origin;if("json"===i)return h({data:t.toJSON(s.json)});if("json"===a)return c(l(JSON.stringify(t.toJSON(s.json)),"text"),i),h({data:!0});if("svg"===i)return h({data:t.toSVG()});if("svg"===a)return c(l(t.toSVG(),"svg"),i),h({data:!0});const{leafer:u}=t;u?(zi(t),u.waitViewCompleted((()=>V(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;const v=void 0===s.smooth?u.config.smooth:s.smooth,x=s.contextSettings||u.config.contextSettings;t.isApp&&(y*=m,m=t.app.pixelRatio);const b=s.screenshot||t.isApp,B=c&&b&&void 0===s.fill?t.fill:s.fill,R=o.isOpaqueImage(i)||B,k=new T;if(b)e=!0===b?c?u.canvas.bounds:t.worldRenderBounds:b;else{let i=s.relative||(c?"inner":"local");switch(r=l.scaleX,d=l.scaleY,i){case"inner":k.set(l);break;case"local":k.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":i=t.leafer;default:k.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",i)}const{x:E,y:L,width:S,height:M}=new g(e).scale(y);let A=n.canvas({width:Math.round(S),height:Math.round(M),pixelRatio:m,smooth:v,contextSettings:x});const C={matrix:k.scale(1/y).invert().translate(-E,-L).withScale(1/r*y,1/d*y)};if(_&&(t=u,C.bounds=A.bounds),A.save(),f&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(A,C),t.fill=e}else t.__render(A,C);if(A.restore(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Hi(a,s,o):Gi(a={},s,o)),r++;const d=new g;return Vi(a,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:m};A=n.canvas(s),A.copyWorld(t,a,s)}R&&A.fillWorld(A.bounds,B||"#FFFFFF","destination-over"),w&&w(A);const W="canvas"===i?A:yield A.export(i,s);h({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let qi;function zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>zi(t)))}const Qi=t.prototype,Ji=p.get("@leafer-ui/export");Qi.export=function(t,e){const{quality:i,blob:n}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Qi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Ji.error(t),n(null)}))}))},Qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Qi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Ji.error(t),n(!1)}))}))},Object.assign(j,Yi),Object.assign(F,ji),Object.assign(G,Ct),Object.assign(D,le),Object.assign(N,Se),Object.assign(H,Pe),Object.assign(U,Xi),Object.assign(n,{interaction:(t,e,i,n)=>new I(t,e,i,n),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new P});export{dt as Layouter,X as LeaferCanvas,lt as Renderer,mt as Selector,J as Watcher,Q as useCanvas};
|
package/dist/node.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(e,s){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.push(e.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:n,updateAllWorldOpacity:i}=t.LeafHelper,{pushAllChildBranch:r,pushAllParent:a}=t.BranchHelper;const{worldBounds:o}=t.LeafBoundsHelper,{setByListWithHandle:d}=t.BoundsHelper;class l{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){d(this.beforeBounds,this.updatedList.list,o)}setAfter(){d(this.afterBounds,this.updatedList.list,o),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:h,updateAllChange:c}=t.LeafHelper,{pushAllBranchStack:u,updateWorldBoundsByBranchStack:f}=t.BranchHelper,g=t.Debug.get("Layouter");class _{constructor(e,s){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,s&&(this.config=t.DataHelper.default(s,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.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){g.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?g.warn("layouting"):this.times>3?g.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const s=t.Run.start("PartLayout"),{target:o,__updatedList:d}=this,{BEFORE:l,LAYOUT:h,AFTER:c}=t.LayoutEvent,u=this.getBlocks(d);u.forEach((t=>{t.setBefore()})),o.emitEvent(new t.LayoutEvent(l,u,this.times)),d.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(n(t),e.push(t),t.isBranch&&r(t,e),a(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),a(t,e)))}))}(d,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&i(t),t.__updateChange()}))}(d),u.forEach((t=>t.setAfter())),o.emitEvent(new t.LayoutEvent(h,u,this.times)),o.emitEvent(new t.LayoutEvent(c,u,this.times)),this.addBlocks(u),this.__levelList.reset(),this.__updatedList=null,t.Run.end(s)}fullLayout(){const e=t.Run.start("FullLayout"),{target:s}=this,{BEFORE:n,LAYOUT:i,AFTER:r}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(s));s.emitEvent(new t.LayoutEvent(n,a,this.times)),_.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new t.LayoutEvent(i,a,this.times)),s.emitEvent(new t.LayoutEvent(r,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(t){if(h(t),t.isBranch){const e=[t];u(t,e),f(e)}else t.__updateWorldBounds();c(t)}createBlock(t){return new l(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(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const p=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,s,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=s,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:s}=this;this.times=0,this.totalBounds=new t.Bounds,p.log(s.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,p.error(t)}p.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?p.warn("rendering"):this.times>3?p.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return p.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const s=t.Run.start("PartRender"),{canvas:n}=this,i=e.getIntersect(n.bounds),r=e.includes(this.target.__world),a=(new t.Bounds).copy(i);n.save(),r&&!t.Debug.showRepaint?n.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,a),n.restore(),t.Run.end(s)}fullRender(){const e=t.Run.start("FullRender"),{canvas:s}=this;s.save(),s.clear(),this.__render(s.bounds),s.restore(),t.Run.end(e)}__render(e,s){const n=(null==e?void 0:e.includes(this.target.__world))?{}:{bounds:e};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(n),t.Debug.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const s=new t.Bounds;s.setByList(e),e.length=0,e.push(s)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(t.AnimateEvent.FRAME),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:s,height:n}=e.old;new t.Bounds(0,0,s,n).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||p.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,s,n){this.target.emitEvent(new t.RenderEvent(e,this.times,s,n))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:m}=t.BoundsHelper;class w{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const n=s.through||!1,i=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=i?this.getPath(a):this.getHitablePath(a);return this.clear(),n?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let s;this.findList=[];const{x:n,y:i}=this.point,r={x:n,y:i,radiusX:0,radiusY:0};for(let n=0,i=e.length;n<i;n++)if(s=e[n],t.LeafHelper.worldHittable(s)&&(this.hitChild(s,r),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const s=new t.LeafList;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let n,i=new t.LeafList;for(let t=s.list.length-1;t>-1&&(n=s.list[t],n.__.hittable)&&(i.unshift(n),n.__.hitChildren);t--);return i}getThroughPath(e){const s=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let i,r,a;for(let t=0,e=n.length;t<e;t++){i=n[t],r=n[t+1];for(let t=0,e=i.length;t<e&&(a=i.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,n;const{point:i}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(n=!!s.__.hitRadius||m(s.__world,i),s.isBranch?(n||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,i)):n&&this.hitChild(s,i))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class v{constructor(e,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=e,s&&(this.config=t.DataHelper.default(s,this.config)),this.findPath=new w(e,this),this.__listenEvents()}getByPoint(e,s,n){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.findPath.getByPoint(e,s,n)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,n=this.innerIdList[t];return n||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,n=this.idList[t];return n||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let n=0,i=s.length;n<i;n++){if(e(t=s[n]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new _(t,e),renderer:(t,e,s)=>new y(t,e,s),selector:(t,e)=>new v(t,e)}),t.Platform.layout=_.fullLayout;class x extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}Object.assign(t.Creator,{canvas:(t,e)=>new x(t,e),image:e=>new t.LeaferImage(e),hitCanvas:(t,e)=>new x(t,e),interaction:(e,s,n,i)=>new t.InteractionBase(e,s,n,i)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0,t.Platform.realtimeLayout=!0;const{get:b,rotateOfOuter:B,translate:E,scaleOfOuter:L,scale:R,rotate:k}=t.MatrixHelper;const{get:S,translate:C}=t.MatrixHelper;function P(t,e,s,n){let{width:i,height:r}=e;const{opacity:a,mode:o,offset:d,scale:l,rotation:h,blendMode:c}=s,u=n.width===i&&n.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(i=n.width,r=n.height),(n.x||n.y)&&(f.transform=S(),C(f.transform,n.x,n.y));break;case"clip":(d||l||h)&&function(t,e,s,n,i){const r=b();E(r,e.x,e.y),s&&E(r,s.x,s.y),n&&("number"==typeof n?R(r,n):R(r,n.x,n.y),t.scaleX=r.a,t.scaleY=r.d),i&&k(r,i),t.transform=r}(f,n,d,l,h);break;case"repeat":(!u||l||h)&&function(t,e,s,n,i,r){const a=b();if(r)switch(k(a,r),r){case 90:E(a,n,0);break;case 180:E(a,s,n);break;case 270:E(a,0,s)}E(a,e.x,e.y),i&&(L(a,e,i),t.scaleX=t.scaleY=i),t.transform=a}(f,n,i,r,l,h);break;default:u&&!h||function(t,e,s,n,i,r){const a=b(),o=r&&180!==r,d=s.width/(o?i:n),l=s.height/(o?n:i),h="fit"===e?Math.min(d,l):Math.max(d,l),c=s.x+(s.width-n*h)/2,u=s.y+(s.height-i*h)/2;E(a,c,u),R(a,h),r&&B(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=h,t.transform=a}(f,o,n,i,r,h)}f.width=i,f.height=r,a&&(f.opacity=a)}function A(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function O(e,s){s.target.hasEvent(e)&&s.target.emitEvent(new t.ImageEvent(e,s))}function I(t,e,s,n){return new(s||(s=Promise))((function(i,r){function a(t){try{d(n.next(t))}catch(t){r(t)}}function o(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:M,scale:T,copy:W}=t.MatrixHelper;function D(e,s,n){let{scaleX:i,scaleY:r}=e.__world;const a=i+"-"+r;if(s.patternId===a||e.destroyed)return!1;{s.patternId=a,i=Math.abs(i),r=Math.abs(r);const{image:e,data:o}=s,d=e.isSVG?4096:Math.min(e.width,4096),l=e.isSVG?4096:Math.min(e.height,4096);let h,c,{width:u,height:f,scaleX:g,scaleY:_,opacity:p,transform:y,mode:m}=o;g&&(c=M(),W(c,y),T(c,1/g,1/_),i*=g,r*=_),i*=n,r*=n,u*=i,f*=r,(u>d||f>l)&&(h=Math.max(u/d,f/l)),h&&(i/=h,r/=h,u/=h,f/=h),g&&(i/=g,r/=_),(y||1!==i||1!==r)&&(c||(c=M(),y&&W(c,y)),T(c,1/i,1/r));const w=t.Platform.canvas.createPattern(e.getCanvas(u<1?1:u,f<1?1:f,p),"repeat"===m?"repeat":t.Platform.origin.noRepeat||"no-repeat");try{s.transform&&(s.transform=null),c&&(w.setTransform?w.setTransform(c):s.transform=c)}catch(t){s.transform=c}return s.style=w,!0}}function H(e,s,n,i){const{scaleX:r,scaleY:a}=e.__world;if(n.data&&n.patternId!==r+"-"+a){if(i)if(n.image.isSVG&&"repeat"!==n.data.mode){let{width:t,height:e}=n.data;t*=r*s.pixelRatio,e*=a*s.pixelRatio,i=t>4096||e>4096}else i=!1;if(i){s.save(),s.clip();const{data:t}=n;return n.blendMode&&(s.blendMode=n.blendMode),t.opacity&&(s.opacity*=t.opacity),t.transform&&s.transform(t.transform),s.drawImage(n.image.view,0,0,t.width,t.height),s.restore(),!0}return n.style?t.ImageManager.patternTasker.add((()=>I(this,void 0,void 0,(function*(){s.bounds.hit(e.__world)&&D(e,n,s.pixelRatio)&&e.forceUpdate("surface")}))),300):D(e,n,s.pixelRatio),!1}return!1}function F(e,s){const n="fill"===s?e._fill:e._stroke;if(n instanceof Array){let i,r,a,o;for(let d=0,l=n.length;d<l;d++)i=n[d].image,o=i&&i.url,o&&(r||(r={}),r[o]=!0,t.ImageManager.recycle(i),i.loading&&(a||(a=e.__input&&e.__input[s]||[],a instanceof Array||(a=[a])),i.unload(n[d].loadId,!a.some((t=>t.url===o)))));return r}return null}function N(t,e){let s;const{rows:n,decorationY:i,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)s=n[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),i&&e.fillRect(s.x,s.y+i,s.width,r)}function j(t,e,s){const{strokeAlign:n}=t.__,i="string"!=typeof s;switch(n){case"center":e.setStroke(i?void 0:s,t.__.strokeWidth,t.__),i?V(t,s,e,!0):Y(t,e);break;case"inside":U(t,e,s,"inside",i);break;case"outside":U(t,e,s,"outside",i)}}function U(t,e,s,n,i){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(i?void 0:s,2*r,t.__),o.font=a,i?V(t,s,o,!0):Y(t,o),o.blendMode="outside"===n?"destination-out":"destination-in",N(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Y(t,e){let s;const{rows:n,decorationY:i,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),i&&e.strokeRect(s.x,s.y+i,s.width,r)}function V(t,e,s,n){let i;for(let r=0,a=e.length;r<a;r++)i=e[r],i.image&&H(t,s,i,!1)||i.style&&(s.strokeStyle=i.style,i.blendMode?(s.saveBlendMode(i.blendMode),n?Y(t,s):s.stroke(),s.restoreBlendMode()):n?Y(t,s):s.stroke())}const{getSpread:q,getOuterOf:X,getByMove:G,getIntersectData:z}=t.BoundsHelper;const Q={x:.5,y:0},Z={x:.5,y:1};function K(t,s,n){let i;for(let r=0,a=s.length;r<a;r++)i=s[r],t.addColorStop(i.offset,e.ColorConvert.string(i.color,n))}const{set:$,getAngle:J,getDistance:tt}=t.PointHelper,{get:et,rotateOfOuter:st,scaleOfOuter:nt}=t.MatrixHelper,it={x:.5,y:.5},rt={x:.5,y:1},at={},ot={};const{set:dt,getAngle:lt,getDistance:ht}=t.PointHelper,{get:ct,rotateOfOuter:ut,scaleOfOuter:ft}=t.MatrixHelper,gt={x:.5,y:.5},_t={x:.5,y:1},pt={},yt={};let mt;function wt(s,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:r}=s.__layout;switch(n.type){case"solid":let{type:a,blendMode:o,color:d,opacity:l}=n;return{type:a,blendMode:o,style:e.ColorConvert.string(d,l)};case"image":return function(e,s,n,i,r){const a={type:n.type},o=a.image=t.ImageManager.get(n),d=(r||o.loading)&&{target:e,image:o,attrName:s,attrValue:n};return o.ready?(A(e,s,o)&&P(a,o,n,i),r&&(O(t.ImageEvent.LOAD,d),O(t.ImageEvent.LOADED,d))):o.error?r&&(e.forceUpdate("surface"),d.error=o.error,O(t.ImageEvent.ERROR,d)):(r&&O(t.ImageEvent.LOAD,d),a.loadId=o.load((()=>{e.destroyed||(A(e,s,o)&&(P(a,o,n,i),e.forceUpdate("surface")),O(t.ImageEvent.LOADED,d))}),(s=>{e.forceUpdate("surface"),d.error=s,O(t.ImageEvent.ERROR,d)}))),a}(s,i,n,r,!mt||!mt[n.url]);case"linear":return function(e,s){let{from:n,to:i,type:r,blendMode:a,opacity:o}=e;n||(n=Q),i||(i=Z);const d=t.Platform.canvas.createLinearGradient(s.x+n.x*s.width,s.y+n.y*s.height,s.x+i.x*s.width,s.y+i.y*s.height);K(d,e.stops,o);const l={type:r,style:d};return a&&(l.blendMode=a),l}(n,r);case"radial":return function(e,s){let{from:n,to:i,type:r,opacity:a,blendMode:o,stretch:d}=e;n||(n=it),i||(i=rt);const{x:l,y:h,width:c,height:u}=s;let f;$(at,l+n.x*c,h+n.y*u),$(ot,l+i.x*c,h+i.y*u),(c!==u||d)&&(f=et(),nt(f,at,c/u*(d||1),1),st(f,at,J(at,ot)+90));const g=t.Platform.canvas.createRadialGradient(at.x,at.y,0,at.x,at.y,tt(at,ot));K(g,e.stops,a);const _={type:r,style:g,transform:f};return o&&(_.blendMode=o),_}(n,r);case"angular":return function(e,s){let{from:n,to:i,type:r,opacity:a,blendMode:o,stretch:d}=e;n||(n=gt),i||(i=_t);const{x:l,y:h,width:c,height:u}=s;dt(pt,l+n.x*c,h+n.y*u),dt(yt,l+i.x*c,h+i.y*u);const f=ct(),g=lt(pt,yt);t.Platform.conicGradientRotate90?(ft(f,pt,c/u*(d||1),1),ut(f,pt,g+90)):(ft(f,pt,1,c/u*(d||1)),ut(f,pt,g));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,pt.x,pt.y):t.Platform.canvas.createRadialGradient(pt.x,pt.y,0,pt.x,pt.y,ht(pt,yt));K(_,e.stops,a);const p={type:r,style:_,transform:f};return o&&(p.blendMode=o),p}(n,r);default:return n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}var vt=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let n,i=t.__.__input[e];i instanceof Array||(i=[i]),mt=F(t.__,e);for(let r=0,a=i.length;r<a;r++)n=wt(t,i[r],e),n&&s.push(n);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Y,fill:function(t,e,s){e.fillStyle=s,t.__.__font?N(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:N,fills:function(t,e,s){let n;const{windingRule:i,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)n=s[a],n.image&&H(t,e,n,!r)||n.style&&(e.fillStyle=n.style,n.transform?(e.save(),e.transform(n.transform),n.blendMode&&(e.blendMode=n.blendMode),r?N(t,e):i?e.fill(i):e.fill(),e.restore()):n.blendMode?(e.saveBlendMode(n.blendMode),r?N(t,e):i?e.fill(i):e.fill(),e.restoreBlendMode()):r?N(t,e):i?e.fill(i):e.fill())},recycleImage:F,shape:function(t,e,s){const n=e.getSameCanvas();let i,r,a,o;const{__world:d}=t;let{scaleX:l,scaleY:h}=d;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(d,s.matrix))s.matrix?(l*=s.matrix.a,h*=s.matrix.d,i=a=X(d,s.matrix)):i=a=d,o=n;else{const{renderShapeSpread:n}=t.__layout,c=z(n?q(e.bounds,n*l,n*h):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),l*=r.a,h*=r.d),a=X(d,r),i=G(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(n,s),{canvas:n,matrix:r,bounds:i,worldCanvas:o,shapeBounds:a,scaleX:l,scaleY:h}},stroke:function(t,e,s){const n=t.__,{strokeWidth:i,strokeAlign:r,__font:a}=n;if(i)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(s,i,n),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*i,n),n.windingRule?e.clip(n.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*i,t.__),t.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:j,strokes:function(t,e,s){const n=t.__,{strokeWidth:i,strokeAlign:r,__font:a}=n;if(i)if(a)j(t,e,s);else switch(r){case"center":e.setStroke(void 0,i,n),V(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*i,n),n.windingRule?e.clip(n.windingRule):e.clip(),V(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*i,t.__),V(t,s,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:xt,toOffsetOutBounds:bt}=t.BoundsHelper,Bt={},Et={};function Lt(e,s,n,i){const{bounds:r,shapeBounds:a}=i;if(t.Platform.fullImageShadow){if(xt(Bt,e.bounds),Bt.x+=s.x-a.x,Bt.y+=s.y-a.y,n){const{matrix:t}=i;Bt.x-=(r.x+(t?t.e:0)+r.width/2)*(n-1),Bt.y-=(r.y+(t?t.f:0)+r.height/2)*(n-1),Bt.width*=n,Bt.height*=n}e.copyWorld(i.canvas,e.bounds,Bt)}else n&&(xt(Bt,s),Bt.x-=s.width/2*(n-1),Bt.y-=s.height/2*(n-1),Bt.width*=n,Bt.height*=n),e.copyWorld(i.canvas,a,n?Bt:s)}const{toOffsetOutBounds:Rt}=t.BoundsHelper,kt={};var St=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:n}=t.__;s.setWorldBlur(n*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,n){let i,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;Rt(h,kt),d.forEach(((n,d)=>{g.save(),g.setWorldShadow(kt.offsetX+n.x*u,kt.offsetY+n.y*f,n.blur*u),r=n.spread?1-2*n.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,kt,r,s),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),i=a):(g.copyWorld(s.canvas,c,h,"source-out"),i=h),g.fillWorld(i,n.color,"source-in"),t.__hasMirror?e.copyWorldByReset(g,i,a,n.blendMode):e.copyWorldToInner(g,i,o.renderBounds,n.blendMode),_&&d<_&&g.clear()})),g.recycle()},shadow:function(t,e,s,n){let i,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:l,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=s,g=e.getSameCanvas(),_=d.length-1;bt(h,Et),d.forEach(((n,d)=>{g.setWorldShadow(Et.offsetX+n.x*u,Et.offsetY+n.y*f,n.blur*u,n.color),r=n.spread?1+2*n.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Lt(g,Et,r,s),i=h,n.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),i=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,c,h,"destination-out")),t.__hasMirror?e.copyWorldByReset(g,i,a,n.blendMode):e.copyWorldToInner(g,i,o.renderBounds,n.blendMode),_&&d<_&&g.clear()})),g.recycle()}});const Ct=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pt=Ct+"_#~&*+\\=|≮≯≈≠=…",At=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 Ot(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const It=Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Mt=Ot("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Tt=Ot(Ct),Wt=Ot(Pt),Dt=Ot("- —/~|┆·");var Ht;!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"}(Ht||(Ht={}));const{Letter:Ft,Single:Nt,Before:jt,After:Ut,Symbol:Yt,Break:Vt}=Ht;function qt(t){return It[t]?Ft:Dt[t]?Vt:Mt[t]?jt:Tt[t]?Ut:Wt[t]?Yt:At.test(t)?Nt:Ft}const Xt={trimRight(t){const{words:e}=t;let s,n=0,i=e.length;for(let r=i-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)n++,t.width-=s.width;n&&e.splice(i-n,n)}};function Gt(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:zt}=Xt,{Letter:Qt,Single:Zt,Before:Kt,After:$t,Symbol:Jt,Break:te}=Ht;let ee,se,ne,ie,re,ae,oe,de,le,he,ce,ue,fe,ge,_e,pe,ye=[];function me(t,e){le&&!de&&(de=le),ee.data.push({char:t,width:e}),ne+=e}function we(){ie+=ne,ee.width=ne,se.words.push(ee),ee={data:[]},ne=0}function ve(){ge&&(_e.paraNumber++,se.paraStart=!0,ge=!1),le&&(se.startCharSize=de,se.endCharSize=le,de=0),se.width=ie,pe.width&&zt(se),ye.push(se),se={words:[]},ie=0}const xe={getDrawData(e,s){"string"!=typeof e&&(e=String(e));let n=0,i=0,r=s.__getInput("width")||0,a=s.__getInput("height")||0;const{textDecoration:o,textOverflow:d,__font:l,padding:h}=s;if(h){const[e,s,o,d]=t.MathHelper.fourNumber(h);r&&(n=d,r-=s+d),a&&(i=e,a-=e+o)}const c={bounds:{x:n,y:i,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,s,n){_e=e,ye=e.rows,pe=e.bounds;const{__letterSpacing:i,paraIndent:r,textCase:a}=n,{canvas:o}=t.Platform,{width:d,height:l}=pe;if(d||l||i||"none"!==a){ge=!0,ce=null,de=oe=le=ne=ie=0,ee={data:[]},se={words:[]};for(let t=0,e=s.length;t<e;t++)ae=s[t],"\n"===ae?(ne&&we(),se.paraEnd=!0,ve(),ge=!0):(he=qt(ae),he===Qt&&"none"!==a&&(ae=Gt(ae,a,!ne)),oe=o.measureText(ae).width,i&&(i<0&&(le=oe),oe+=i),ue=he===Zt&&(ce===Zt||ce===Qt)||ce===Zt&&he!==$t,fe=!(he!==Kt&&he!==Zt||ce!==Jt&&ce!==$t),re=ge&&r?d-r:d,d&&ie+ne+oe>re&&(fe||(fe=he===Qt&&ce==$t),ue||fe||he===te||he===Kt||he===Zt||ne+oe>re?(ne&&we(),ve()):ve())," "===ae&&!0!==ge&&ie+ne===0||(he===te?(" "===ae&&ne&&we(),me(ae,oe),we()):ue||fe?(ne&&we(),me(ae,oe)):me(ae,oe)),ce=he);ne&&we(),ie&&ve(),ye.length>0&&(ye[ye.length-1].paraEnd=!0)}else s.split("\n").forEach((t=>{_e.paraNumber++,ye.push({x:r||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(c,e,s),function(t,e){const{rows:s,bounds:n}=t,{__lineHeight:i,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:l,textOverflow:h}=e;let c,u,f,{x:g,y:_,width:p,height:y}=n,m=i*s.length+(l?l*(t.paraNumber-1):0),w=r;if("show"!==h&&m>y)m=Math.max(y,i),t.overflow=s.length;else switch(d){case"middle":_+=(y-m)/2;break;case"bottom":_+=y-m}w+=_;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=g,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&r>0&&(w+=l),c.y=w,w+=i,t.overflow>r&&w>m&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f)}n.y=_,n.height=m}(c,s),function(t,e,s,n){const{rows:i}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,l,h,c,u;i.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=s&&"justify"===r&&t.words.length>1?(s-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?0:l>.01?1:2,2===c?(t.text="",t.x+=h,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,s,r),c.overflow&&function(e,s){const{rows:n,overflow:i}=e;if(n.splice(i),"hide"!==s){"ellipsis"===s&&(s="...");const r=t.Platform.canvas.measureText(s).width,a=n[i-1];let o,d,l=a.data.length-1;const{x:h,width:c}=e.bounds,u=h+c-r;for(let t=l;t>-1&&(o=a.data[t],d=o.x+o.width,!(t===l&&d<u));t--){if(d<u&&" "!==o.char){a.data.splice(t+1),a.width-=o.width;break}a.width-=o.width}a.width+=r,a.data.push({char:s,x:d})}}(c,d),"none"!==o&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(c,s),c}},be={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},Be={export(e,s,n){return function(e){Ee||(Ee=new t.TaskProcessor);return new Promise((t=>{Ee.add((()=>I(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((t=>new Promise((i=>{const{leafer:r}=e;r?r.waitViewCompleted((()=>I(this,void 0,void 0,(function*(){let e,a,o,{canvas:d}=r,{unreal:l}=d;switch(l&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof n){case"object":n.quality&&(e=n.quality),n.blob&&(a=!0);break;case"number":e=n;break;case"boolean":a=n}o=s.includes(".")?yield d.saveAs(s,e):a?yield d.toBlob(s,e):yield d.toDataURL(s,e),t({data:o}),i(),l&&d.recycle()})))):(t({data:!1}),i())}))))}};let Ee;Object.assign(e.Paint,vt),Object.assign(e.Effect,St),Object.assign(e.TextConvert,xe),Object.assign(e.ColorConvert,be),Object.assign(e.Export,Be),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=_,exports.LeaferCanvas=x,exports.Renderer=y,exports.Selector=v,exports.Watcher=s,exports.useCanvas=function(e,s){if(!t.Platform.origin){if("skia"===e){const{Canvas:e,loadImage:n}=s;t.Platform.origin={createCanvas:(t,s,n)=>new e(t,s,n),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),loadImage:n}}t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),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:w,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,d,this.times)),i.emitEvent(new t.LayoutEvent(r,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,o;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:R,YesAndSkip:k}=t.Answer,P={},C={},S={};class M{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":P.id=e.substring(1),e=P;break;case".":C.className=e.substring(1),e=C;break;default:S.tag=e,e=S}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,i),a===E||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function A(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function I(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?T(t,!0,e,n):O(e,n);break;case"inside":W("inside",t,s,e,n);break;case"outside":W("outside",t,s,e,n)}}function W(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?T(e,!0,i,r):O(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function O(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function T(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?O(n,s):s.stroke(),s.restoreBlendMode()):e?O(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new M(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:D,getOuterOf:H,getByMove:F,getIntersectData:N}=t.BoundsHelper;let j;function U(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,d)};case"image":return i.PaintImage.image(n,t,e,s,!j||!j[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const G={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),j=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=o.length;i<a;i++)n=U(t,o[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?A(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),T(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),T(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),T(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:O,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,c=N(i?D(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),r=H(s,o),a=F(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Y={};const{get:q,rotateOfOuter:V,translate:X,scaleOfOuter:z,scale:Q,rotate:J}=t.MatrixHelper;function Z(t,e,n,i,s,a,o){const r=q();X(r,e.x+n,e.y+i),Q(r,s,a),o&&V(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function K(t,e,n,i,s,a,o){const r=q();X(r,e.x+n,e.y+i),s&&Q(r,s,a),o&&J(r,o),t.transform=r}function $(t,e,n,i,s,a,o,r,d,l){const h=q();if(d)if("center"===l)V(h,{x:n/2,y:i/2},d);else switch(J(h,d),d){case 90:X(h,i,0);break;case 180:X(h,n,i);break;case 270:X(h,0,n)}Y.x=e.x+s,Y.y=e.y+a,X(h,Y.x,Y.y),o&&z(h,Y,o,r),t.transform=h}const{get:tt,translate:et}=t.MatrixHelper,nt=new t.Bounds,it={};function st(t,e,n,i){const{blendMode:s}=n;s&&(t.blendMode=s),t.data=at(n,i,e)}function at(e,n,i){let{width:s,height:a}=i;e.padding&&(n=nt.set(n).shrink(e.padding));const{opacity:o,mode:r,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:r},_="center"!==d&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(y=("number"==typeof c?c:c.width)/s,v=("number"==typeof c?c:c.height)/a):h&&(y="number"==typeof h?h:h.x,v="number"==typeof h?h:h.y);else if(!g||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,B+=(n.height-a*v)/2}if(d){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,it,!0),x+=it.x,B+=it.y}switch(l&&(x+=l.x,B+=l.y),r){case"strench":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&K(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&$(p,n,s,a,x,B,y,v,u,d),f||(p.repeat="repeat");break;default:y&&Z(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=tt(),et(p.transform,n.x,n.y)),y&&"strench"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let ot,rt=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function lt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||st(s,i,n,a),!0}function ht(e,n){ft(e,t.ImageEvent.LOAD,n)}function ct(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,i){n.error=i,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function gt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:_t,copy:wt}=t.MatrixHelper,{ceil:mt,abs:yt}=Math;function vt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a;if(n.patternId===o||e.destroyed)return!1;{s=yt(s),a=yt(a);const{image:e,data:r}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=pt(),wt(l,p),_t(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=pt(),p&&wt(l,p)),_t(l,1/s,1/a));const y=e.getCanvas(mt(h)||1,mt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:xt}=Math;const Bt={image:function(e,n,i,s,a){let o,r;const d=t.ImageManager.get(i);return ot&&i===ot.paint&&dt(s,ot.boxBounds)?o=ot.leafPaint:(o={type:i.type,image:d},ot=d.use>1?{leafPaint:o,paint:i,boxBounds:rt.set(s)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(lt(e,n,i,d,o,s),a&&(ht(e,r),ct(e,r))):d.error?a&&ut(e,r,d.error):(gt(e,!0),a&&ht(e,r),o.loadId=d.load((()=>{gt(e,!1),e.destroyed||(lt(e,n,i,d,o,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,r)),o.loadId=null}),(t=>{gt(e,!1),ut(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,a,o){const{scaleX:r,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(a.data&&a.patternId!==r+"-"+d){const{data:l}=a;if(o)if(l.repeat)o=!1;else{let{width:e,height:s}=l;e*=xt(r)*n.pixelRatio,s*=xt(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,s*=l.scaleY),o=e*s>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?vt(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&vt(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:vt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:st,getPatternData:at,fillOrFitMode:Z,clipMode:K,repeatMode:$},{toPoint:bt}=t.AroundHelper,Lt={},Et={};function Rt(t,e,n){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{getAngle:kt,getDistance:Pt}=t.PointHelper,{get:Ct,rotateOfOuter:St,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:At}=t.AroundHelper,It={},Wt={};function Ot(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=kt(e,n);a=Ct(),s?(Mt(a,e,o/r*(i||1),1),St(a,e,t+90)):(Mt(a,e,1,o/r*(i||1)),St(a,e,t))}return a}const{getDistance:Tt}=t.PointHelper,{toPoint:Dt}=t.AroundHelper,Ht={},Ft={};const Nt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;bt(i||"top",n,Lt),bt(s||"bottom",n,Et);const d=t.Platform.canvas.createLinearGradient(Lt.x,Lt.y,Et.x,Et.y);Rt(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;At(i||"center",n,It),At(s||"bottom",n,Wt);const l=t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Pt(It,Wt));Rt(l,e.stops,o);const h={type:a,style:l},c=Ot(n,It,Wt,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;Dt(i||"center",n,Ht),Dt(s||"bottom",n,Ft);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ht.x,Ht.y):t.Platform.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Tt(Ht,Ft));Rt(l,e.stops,o);const h={type:a,style:l},c=Ot(n,Ht,Ft,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ot},{copy:jt,toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={},Yt={};function qt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(jt(Gt,e.bounds),Gt.x+=n.x-o.x,Gt.y+=n.y-o.y,i){const{matrix:t}=s;Gt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Gt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Gt.width*=i,Gt.height*=i}e.copyWorld(s.canvas,e.bounds,Gt)}else i&&(jt(Gt,n),Gt.x-=n.width/2*(i-1),Gt.y-=n.height/2*(i-1),Gt.width*=i,Gt.height*=i),e.copyWorld(s.canvas,o,i?Gt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,Xt={};const zt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Ut(l,Yt),r.forEach(((r,p)=>{f.setWorldShadow(Yt.offsetX+r.x*c,Yt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qt(f,Yt,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Vt(l,Xt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Xt.offsetX+r.x*c,Xt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qt(f,Xt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Qt}=t.LeafBoundsHelper;function Jt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Kt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Kt(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Jt(this,o,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Zt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Qt(n,e)||n.__render(s||t,e);Jt(this,o,t,s,i,a)};const $t=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",te=$t+"_#~&*+\\=|≮≯≈≠=…",ee=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 ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ie=ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),se=ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ae=ne($t),oe=ne(te),re=ne("- —/~|┆·");var de;!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"}(de||(de={}));const{Letter:le,Single:he,Before:ce,After:ue,Symbol:fe,Break:ge}=de;function pe(t){return ie[t]?le:re[t]?ge:se[t]?ce:ae[t]?ue:oe[t]?fe:ee.test(t)?he:le}const _e={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function we(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:me}=_e,{Letter:ye,Single:ve,Before:xe,After:Be,Symbol:be,Break:Le}=de;let Ee,Re,ke,Pe,Ce,Se,Me,Ae,Ie,We,Oe,Te,De,He,Fe,Ne,je=[];function Ue(t,e){Ie&&!Ae&&(Ae=Ie),Ee.data.push({char:t,width:e}),ke+=e}function Ge(){Pe+=ke,Ee.width=ke,Re.words.push(Ee),Ee={data:[]},ke=0}function Ye(){He&&(Fe.paraNumber++,Re.paraStart=!0,He=!1),Ie&&(Re.startCharSize=Ae,Re.endCharSize=Ie,Ae=0),Re.width=Pe,Ne.width&&me(Re),je.push(Re),Re={words:[]},Pe=0}const qe=0,Ve=1,Xe=2;const{top:ze,right:Qe,bottom:Je,left:Ze}=t.Direction4;function Ke(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const $e={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Ze],a-=l[Qe]+l[Ze]),o&&(s=l[ze],o-=l[ze]+l[Je]));const h={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Fe=e,je=e.rows,Ne=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ne;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;He=!0,Oe=null,Ae=Me=Ie=ke=Pe=0,Ee={data:[]},Re={words:[]};for(let i=0,l=n.length;i<l;i++)Se=n[i],"\n"===Se?(ke&&Ge(),Re.paraEnd=!0,Ye(),He=!0):(We=pe(Se),We===ye&&"none"!==o&&(Se=we(Se,o,!ke)),Me=r.measureText(Se).width,s&&(s<0&&(Ie=Me),Me+=s),Te=We===ve&&(Oe===ve||Oe===ye)||Oe===ve&&We!==Be,De=!(We!==xe&&We!==ve||Oe!==be&&Oe!==Be),Ce=He&&a?d-a:d,t&&d&&Pe+ke+Me>Ce&&(e?(ke&&Ge(),Pe&&Ye()):(De||(De=We===ye&&Oe==Be),Te||De||We===Le||We===xe||We===ve||ke+Me>Ce?(ke&&Ge(),Pe&&Ye()):Pe&&Ye()))," "===Se&&!0!==He&&Pe+ke===0||(We===Le?(" "===Se&&ke&&Ge(),Ue(Se,Me),Ge()):Te||De?(ke&&Ge(),Ue(Se,Me)):Ue(Se,Me)),Oe=We);ke&&Ge(),Pe&&Ye(),je.length>0&&(je[je.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Fe.paraNumber++,je.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ke(e,"x",t[Ze]);break;case"right":Ke(e,"x",-t[Qe])}if(!s)switch(n.verticalAlign){case"top":Ke(e,"y",t[ze]);break;case"bottom":Ke(e,"y",-t[Je])}}(l,h,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:w}=i,m=s*n.length+(h?h*(t.paraNumber-1):0),y=a;if(r&&m>w)m=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":p+=(w-m)/2;break;case"bottom":p+=w-m}y+=p;for(let a=0,l=n.length;a<l;a++){if(c=n[a],c.x=g,c.width<_||c.width>_&&!r)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(y+=h),c.y=y,y+=s,t.overflow>a&&y>m&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?qe:l>.01?Ve:Xe,t.isOverflow&&!r&&(t.textMode=!0),c===Xe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ve?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,h=i+s-l;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<h));i--){if(d<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const tn={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:en,addPoint:nn,toBounds:sn}=t.TwoPointBoundsHelper;const an={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n);return i=t.FileHelper.getExportOptions(i),function(e){on||(on=new t.TaskProcessor);return new Promise((t=>{on.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1},{toURL:l}=t.Platform,{download:h}=t.Platform.origin;if("json"===n)return d({data:e.toJSON(i.json)});if("json"===a)return h(l(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!0});if("svg"===n)return d({data:e.toSVG()});if("svg"===a)return h(l(e.toSVG(),"svg"),n),d({data:!0});const{leafer:c}=e;c?(rn(e),c.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i;let _=i.scale||1,w=i.pixelRatio||1;const m=void 0===i.smooth?c.config.smooth:i.smooth,y=i.contextSettings||c.config.contextSettings;e.isApp&&(_*=w,w=e.app.pixelRatio);const v=i.screenshot||e.isApp,x=h&&v&&void 0===i.fill?e.fill:i.fill,B=t.FileHelper.isOpaqueImage(n)||x,b=new t.Matrix;if(v)s=!0===v?h?c.canvas.bounds:e.worldRenderBounds:v;else{let t=i.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,t){case"inner":b.set(l);break;case"local":b.set(l).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:b.set(l).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const{x:L,y:E,width:R,height:k}=new t.Bounds(s).scale(_);let P=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:w,smooth:m,contextSettings:y});const C={matrix:b.scale(1/_).invert().translate(-L,-E).withScale(1/o*_,1/r*_)};if(f&&(e=c,C.bounds=P.bounds),P.save(),u&&void 0!==x){const t=e.get("fill");e.fill="",e.__render(P,C),e.fill=t}else e.__render(P,C);if(P.restore(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,o=(d-a)/n,r?nn(r,a,o):en(r={},a,o)),d++;const l=new t.Bounds;return sn(r,l),l.scale(1/e.pixelRatio).ceil()}(P);const e=P,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:w};P=t.Creator.canvas(s),P.copyWorld(e,a,s)}B&&P.fillWorld(P.bounds,x||"#FFFFFF","destination-over"),p&&p(P);const S="canvas"===n?P:yield P.export(n,i);d({data:S,width:P.pixelWidth,height:P.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let on;function rn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>rn(t)))}const dn=t.LeaferCanvasBase.prototype,ln=t.Debug.get("@leafer-ui/export");dn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},dn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{ln.error(t),i(null)}))}))},dn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},dn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{ln.error(t),i(!1)}))}))},Object.assign(i.TextConvert,$e),Object.assign(i.ColorConvert,tn),Object.assign(i.Paint,G),Object.assign(i.PaintImage,Bt),Object.assign(i.PaintGradient,Nt),Object.assign(i.Effect,zt),Object.assign(i.Export,an),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=M,exports.Watcher=d,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>a(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/node",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.30",
|
|
4
4
|
"description": "@leafer-ui/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "dist/
|
|
8
|
+
"main": "dist/node.esm.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
"import": "./dist/node.esm.js",
|
|
11
|
-
"require": "./dist/node.cjs"
|
|
11
|
+
"require": "./dist/node.cjs",
|
|
12
|
+
"types": "./types/index.d.ts"
|
|
12
13
|
},
|
|
13
14
|
"types": "types/index.d.ts",
|
|
14
15
|
"files": [
|
|
@@ -29,10 +30,13 @@
|
|
|
29
30
|
"leaferjs"
|
|
30
31
|
],
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@leafer/
|
|
33
|
-
"@leafer
|
|
34
|
-
"@leafer
|
|
35
|
-
"@leafer
|
|
36
|
-
"leafer-
|
|
33
|
+
"@leafer/core": "1.0.0-rc.30",
|
|
34
|
+
"@leafer/node": "1.0.0-rc.30",
|
|
35
|
+
"@leafer/partner": "1.0.0-rc.30",
|
|
36
|
+
"@leafer/interface": "1.0.0-rc.30",
|
|
37
|
+
"@leafer-ui/draw": "1.0.0-rc.30",
|
|
38
|
+
"@leafer-ui/core": "1.0.0-rc.30",
|
|
39
|
+
"@leafer-ui/partner": "1.0.0-rc.30",
|
|
40
|
+
"@leafer-ui/interface": "1.0.0-rc.30"
|
|
37
41
|
}
|
|
38
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
export * from '@leafer/node'
|
|
2
|
+
export * from '@leafer/partner'
|
|
3
|
+
|
|
2
4
|
export * from '@leafer-ui/core'
|
|
3
5
|
export * from '@leafer-ui/partner'
|
|
6
|
+
|
|
7
|
+
import { ICreator } from '@leafer/interface'
|
|
8
|
+
import { Creator, LeaferCanvas } from '@leafer/node'
|
|
9
|
+
import { InteractionBase, HitCanvasManager } from '@leafer-ui/core'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Object.assign(Creator, {
|
|
13
|
+
interaction: (target, canvas, selector, options?) => { return new InteractionBase(target, canvas, selector, options) },
|
|
14
|
+
hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
|
|
15
|
+
hitCanvasManager: () => new HitCanvasManager()
|
|
16
|
+
} as ICreator)
|
package/types/index.d.ts
CHANGED