@leafer-ui/node 1.0.0-rc.9 → 1.0.1

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