@leafer-ui/miniapp 1.9.9 → 1.9.10

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,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?(t.isString(i)?("#"!==i[0]&&(i="#"+i),this.viewSelect=t.Platform.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:i,height:n,pixelRatio:s}=this.config,a={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(e,i,n,s,a){this.context.roundRect(e,i,n,s,t.isNumber(a)?[a]:a)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then(t=>{this.clientBounds=t,e&&e()})}startAutoLayout(e,i){this.resizeListener||(this.resizeListener=i,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),t.isUndefined(this.width)||this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let r=e.toDataURL(s(a(i)),n);return r=r.substring(r.indexOf("64,")+3),t.Platform.origin.download(r,i)},download:(e,n)=>new Promise((s,a)=>{let r;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,r=!0);const o=i.getFileSystemManager();o.writeFile({filePath:n,data:e,encoding:"base64",success(){r?t.Platform.miniapp.saveToAlbum(n).then(()=>{o.unlink({filePath:n}),s()}):s()},fail(t){a(t)}})}),loadImage:e=>new Promise((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})}),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:i}=t.Platform.renderCanvas||t.Platform.canvas;i.requestAnimationFrame?i.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:d,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper;class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,m=t.Debug.get("Layouter");class w{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.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.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,f=this.getBlocks(s);f.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,f,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?(l(t,!0),e.add(t),t.isBranch&&d(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))})}(s,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||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,f,this.times)),n.emitEvent(new t.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),w.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(i.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){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(v.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}v.clipSpread=10;const{hitRadiusPoint:x}=t.BoundsHelper;class b{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,a=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,n.bottomList,a),h=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(e,i,n){const s=this.findList=new t.LeafList;if(e.length){let i;const{x:a,y:r}=this.point,o={x:a,y:r,radiusX:0,radiusY:0};for(let a=0,r=e.length;a<r;a++)if(i=e[a],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,o),s.length)){if(i.isBranchLeaf&&e.some(e=>e!==i&&t.LeafHelper.hasParent(e,i))){s.reset();break}return s.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),s.length)return s.list[0];return n?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren&&(!n.isLeafer||"draw"!==n.mode));t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=n.length;t<e;t++){s=n[t],a=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||x(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&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){let i,s=[];const{children:a}=n;for(let n=0,r=a.length;n<r;n++)if(i=a[n],i.__.mask&&s.push(i),i===t){if(s&&!s.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class L{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new b(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:a}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),a.getByPoint(e,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,i)=>new v(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=w.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const S={convertTouch(t,i){const n=S.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class E extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,i){return e.isUndefined(t.x)?super.getLocal(t,i):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=S.getTouch(t);this.pointerDown(S.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=S.getTouch(t);this.pointerMove(S.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=S.getTouch(t);this.pointerUp(S.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})}),n}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}destroy(){super.destroy(),this.touches=null}}function B(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function R(t,e){t.__.__font?B(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function k(t,e,i){switch(e.__.strokeAlign){case"center":P(t,1,e,i);break;case"inside":T(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?P(t,2,e,i):T(t,"outside",e,i)}}function P(e,i,n,s){const a=n.__;t.isObject(e)?A(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),C(n,s))}function T(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,P(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",B(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function C(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function A(t,e,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let h=0,c=t.length;h<c;h++)if(r=t[h],(!r.image||!i.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?C(s,a):a.stroke(),a.restoreBlendMode()):n?C(s,a):a.stroke()}}function O(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)k(e,i,n);else switch(s.strokeAlign){case"center":M(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),M(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)M(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),M(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function M(e,n,s,a){const r=s.__;t.isObject(e)?A(e,n,!1,s,a):(a.setStroke(e,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&i.Paint.strokeArrow(e,s,a)}const{getSpread:W,copyAndSpread:I,toOuterOf:H,getOuterOf:D,getByMove:z,move:F,getIntersectData:j}=t.BoundsHelper,U={};let G;const{stintSet:Y}=t.DataHelper,{hasTransparent:N}=i.ColorConvert;function q(e,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=i.PaintImage.image(s,e,n,r,!G||!G[n.url]);break;case"linear":a=i.PaintGradient.linearGradient(n,r);break;case"radial":a=i.PaintGradient.radialGradient(n,r);break;case"angular":a=i.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:h}=n;a={type:o,style:i.ColorConvert.string(l,h)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:i.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&N(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const X={compute:function(e,n){const s=n.__,a=[];let r,o,l,h=s.__input[e];t.isArray(h)||(h=[h]),G=i.PaintImage.recycleImage(e,s);for(let t,i=0,s=h.length;i<s;i++)(t=q(e,h[i],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+e]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===e?(Y(s,"__isAlphaPixelFill",r),Y(s,"__isTransparentFill",o)):(Y(s,"__isAlphaPixelStroke",r),Y(s,"__isTransparentStroke",o),Y(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,R(e,i)},fills:function(t,e,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(i.PaintImage.checkImage(e,n,s,!e.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&e.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&i>1)&&n.scale(1/t,1/i)}s.blendMode&&(n.blendMode=s.blendMode),R(e,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),R(e,n),n.restoreBlendMode()):R(e,n)}},fillPathOrText:R,fillText:B,stroke:O,strokes:function(t,e,i){O(t,e,i)},strokeText:k,drawTextStroke:C,shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let h,c,d,u,f,p;H(o.strokeSpread?(I(U,o.boxBounds,o.strokeSpread),U):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(a.includes(l))p=s,h=f=l,c=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?W(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):a;s=j(e,l)}u=a.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=m,_*=w),f=D(l,u),h=z(f,-u.e,-u.f),c=D(r,u),F(c,-u.e,-u.f);const y=n.matrix;y?(d=new t.Matrix(u),d.multiply(y),m*=y.scaleX,w*=y.scaleY):d=u,d.withScale(m,w),n=Object.assign(Object.assign({},n),{matrix:d})}return e.__renderShape(s,n),{canvas:s,matrix:d,fitMatrix:u,bounds:h,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let V={},Q=t.getMatrixData();const{get:K,rotateOfOuter:Z,translate:$,scaleOfOuter:J,multiplyParent:tt,scale:et,rotate:it,skew:nt}=t.MatrixHelper;function st(t,e,i,n,s,a,r){const o=K();$(o,e.x+i,e.y+n),et(o,s,a),r&&Z(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function at(t,e,i,n,s,a,r,o,l,h){const c=K();ot(c,e,i,n,s,a,r,o),l&&(Q.a=l,Q.d=h,tt(c,Q)),t.transform=c}function rt(t,e,i,n,s,a,r,o,l,h,c,d){const u=K();if(d)ot(u,e,s,a,r,o,l,h);else{if(l)if("center"===c)Z(u,{x:i/2,y:n/2},l);else switch(it(u,l),l){case 90:$(u,n,0);break;case 180:$(u,i,n);break;case 270:$(u,0,i)}V.x=e.x+s,V.y=e.y+a,$(u,V.x,V.y),r&&J(u,V,r,o)}t.transform=u}function ot(t,e,i,n,s,a,r,o){r&&it(t,r),o&&nt(t,o.x,o.y),s&&et(t,s,a),$(t,e.x+i,e.y+n)}const{get:lt,translate:ht}=t.MatrixHelper,ct=new t.Bounds,dt={},ut={};function ft(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=pt(i,n,e)}function pt(e,i,n){e.padding&&(i=ct.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:h,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(ut,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((c||d)&&(t.MathHelper.getScaleData(c,d,n,dt),x=dt.scaleX,b=dt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(ut,x,b,!0),l&&t.AlignHelper.toPoint(l,ut,i,ut,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,ut,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,ut),t.BoundsHelper.scale(ut,x,b,!0)),h&&t.PointHelper.move(ut,h),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":if(ut.x||ut.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),at(y,i,ut.x,ut.y,x,b,u,f,t,e),t&&(x=x?x*t:x,b=b?b*e:e)}break;case"repeat":(!w||x||u||f)&&rt(y,i,s,a,ut.x,ut.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:gt(r,n,a.width,i&&i.x),y:gt(o,s,a.height,i&&i.y)}}(_,n&&g,ut.width,ut.height,i));break;default:x&&st(y,i,ut.x,ut.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=lt(),ht(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function gt(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let _t,mt=new t.Bounds;const{isSame:wt}=t.BoundsHelper;function yt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||ft(s,n,i,a),!0}function vt(e,i){Lt(e,t.ImageEvent.LOAD,i)}function xt(e,i){Lt(e,t.ImageEvent.LOADED,i)}function bt(e,i,n){i.error=n,e.forceUpdate("surface"),Lt(e,t.ImageEvent.ERROR,i)}function Lt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function St(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Et,scale:Bt,copy:Rt}=t.MatrixHelper,{floor:kt,ceil:Pt,max:Tt,abs:Ct}=Math;function At(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let h,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Ct(f),p=Ct(p),c=Et(),Rt(c,g),Bt(c,1/f,1/p),s*=f,a*=p),d*=s,u*=a;const w=d*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=d/o.width;t>1&&(h=t/Pt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(h=Math.sqrt(w/y)),h&&(s/=h,a/=h,d/=h,u/=h),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=d+(v||0),e=u+(x||0);s/=t/Tt(kt(t),1),a/=e/Tt(kt(e),1),c||(c=Et(),g&&Rt(c,g)),Bt(c,1/s,1/a)}const b=o.getCanvas(d,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),L=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=L,i.patternId=r,!0}}function Ot(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Mt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return _t&&n===_t.paint&&wt(s,_t.boxBounds)?r=_t.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),_t=l.use>1?{leafPaint:r,paint:n,boxBounds:mt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(yt(e,i,n,l,r,s),a&&(vt(e,o),xt(e,o))):l.error?a&&bt(e,o,l.error):(a&&(St(e,!0),vt(e,o)),r.loadId=l.load(()=>{St(e,!1),e.destroyed||(yt(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),xt(e,o)),r.loadId=void 0},t=>{St(e,!1),bt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,n,s,a){const{scaleX:r,scaleY:o}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:h}=s;if(!h||s.patternId===r+"-"+o+"-"+l&&!i.Export.running)return!1;if(a)if(h.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=h;e*=r*l,i*=o*l,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(e.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,n,s,h),!0):(!s.style||s.sync||i.Export.running?At(e,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Ot(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&At(e,s,l),e.forceUpdate("surface")}),300)),!1)},createPattern:At,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let h=0,c=n.length;h<c;h++)s=n[h],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[h].loadId,!o.some(t=>t.url===l))));return r}return null},createData:ft,getPatternData:pt,fillOrFitMode:st,clipMode:at,repeatMode:rt},{toPoint:Wt}=t.AroundHelper,{hasTransparent:It}=i.ColorConvert,Ht={},Dt={};function zt(e,n,s,a){if(s){let r,o,l,h;for(let e=0,c=s.length;e<c;e++)r=s[e],t.isString(r)?(l=e/(c-1),o=i.ColorConvert.string(r,a)):(l=r.offset,o=i.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!h&&It(o)&&(h=!0);h&&(e.isTransparent=!0)}}const{getAngle:Ft,getDistance:jt}=t.PointHelper,{get:Ut,rotateOfOuter:Gt,scaleOfOuter:Yt}=t.MatrixHelper,{toPoint:Nt}=t.AroundHelper,qt={},Xt={};function Vt(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Ft(e,i);a=Ut(),s?(Yt(a,e,r/o*(n||1),1),Gt(a,e,t+90)):(Yt(a,e,1,r/o*(n||1)),Gt(a,e,t))}return a}const{getDistance:Qt}=t.PointHelper,{toPoint:Kt}=t.AroundHelper,Zt={},$t={};const Jt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;Wt(n||"top",i,Ht),Wt(s||"bottom",i,Dt);const o=t.Platform.canvas.createLinearGradient(Ht.x,Ht.y,Dt.x,Dt.y),l={type:a,style:o};return zt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Nt(n||"center",i,qt),Nt(s||"bottom",i,Xt);const l=t.Platform.canvas.createRadialGradient(qt.x,qt.y,0,qt.x,qt.y,jt(qt,Xt)),h={type:a,style:l};zt(h,l,e.stops,r);const c=Vt(i,qt,Xt,o,!0);return c&&(h.transform=c),h},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Kt(n||"center",i,Zt),Kt(s||"bottom",i,$t);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Zt.x,Zt.y):t.Platform.canvas.createRadialGradient(Zt.x,Zt.y,0,Zt.x,Zt.y,Qt(Zt,$t)),h={type:a,style:l};zt(h,l,e.stops,r);const c=Vt(i,Zt,$t,o||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),h},getTransform:Vt},{copy:te,move:ee,toOffsetOutBounds:ie}=t.BoundsHelper,{max:ne}=Math,se={},ae=new t.Matrix,re={};function oe(t,e){let i,n,s,a,r=0,o=0,l=0,h=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,s=t.spread||0,a=1.5*(t.blur||0),r=ne(r,s+a-n),o=ne(o,s+a+i),l=ne(l,s+a+n),h=ne(h,s+a-i)}),r===o&&o===l&&l===h?r:[r,o,l,h]}function le(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(te(se,e.bounds),ee(se,i.x-s.x,i.y-s.y),a=e.bounds,r=se):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:he}=t.BoundsHelper,ce={};const de=oe;const ue={shadow:function(e,n,s){let a,r;const{__nowWorld:o}=e,{shadow:l}=e.__,{worldCanvas:h,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;ie(c,re,d),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(re.offsetX+(l.x||0)*f*w,re.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,i.ColorConvert.string(l.color)),r=i.Effect.getShadowTransform(e,g,s,l,re,w),r&&g.setTransform(r),le(g,re,s),r&&g.resetTransform(),a=d,l.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,d,o,"copy"),a=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(e,n,s){let a,r;const{__nowWorld:o}=e,{innerShadow:l}=e.__,{worldCanvas:h,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;he(c,ce,d),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ce.offsetX+(l.x||0)*f*w,ce.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=i.Effect.getShadowTransform(e,g,s,l,ce,w,!0),r&&g.setTransform(r),le(g,ce,s),g.restore(),h?(g.copyWorld(g,d,o,"copy"),g.copyWorld(h,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=d),g.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},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){},getShadowRenderSpread:oe,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=1+2*n.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return ae.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},i),ae}},isTransformShadow(t){},getInnerShadowSpread:de},{excludeRenderBounds:fe}=t.LeafBoundsHelper;let pe;function ge(t,e,i,n,s,a,r,o){switch(e){case"grayscale":pe||(pe=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);me(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":me(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function _e(t){return t.getSameCanvas(!1,!0)}function me(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let h=0,c=l.length;h<c;h++){if(i=l[h],o=i.__.mask,o){r&&(ge(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||fe(i,e)||i.__render(t,e),a=i.__.opacity,pe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=_e(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=_e(t)),s||(s=_e(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&ge(this,r,t,s,n,a,void 0,!1),fe(i,e)||i.__render(s||t,e),c&&ge(this,r,t,s,n,a,c,!1)}ge(this,r,t,s,n,a,void 0,!0)};const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ye=we+"_#~&*+\\=|≮≯≈≠=…",ve=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 xe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const be=xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Le=xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Se=xe(we),Ee=xe(ye),Be=xe("- —/~|┆·");var Re;!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"}(Re||(Re={}));const{Letter:ke,Single:Pe,Before:Te,After:Ce,Symbol:Ae,Break:Oe}=Re;function Me(t){return be[t]?ke:Be[t]?Oe:Le[t]?Te:Se[t]?Ce:Ee[t]?Ae:ve.test(t)?Pe:ke}const We={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ie(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:He}=We,{Letter:De,Single:ze,Before:Fe,After:je,Symbol:Ue,Break:Ge}=Re;let Ye,Ne,qe,Xe,Ve,Qe,Ke,Ze,$e,Je,ti,ei,ii,ni,si,ai,ri,oi=[];function li(t,e){$e&&!Ze&&(Ze=$e),Ye.data.push({char:t,width:e}),qe+=e}function hi(){Xe+=qe,Ye.width=qe,Ne.words.push(Ye),Ye={data:[]},qe=0}function ci(){ni&&(si.paraNumber++,Ne.paraStart=!0,ni=!1),$e&&(Ne.startCharSize=Ze,Ne.endCharSize=$e,Ze=0),Ne.width=Xe,ai.width?He(Ne):ri&&di(),oi.push(Ne),Ne={words:[]},Xe=0}function di(){Xe>(si.maxWidth||0)&&(si.maxWidth=Xe)}const{top:ui,right:fi,bottom:pi,left:gi}=t.Direction4;function _i(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 mi={getDrawData:function(e,n){t.isString(e)||(e=String(e));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:h,__padding:c}=n;c&&(r?(s=c[gi],r-=c[fi]+c[gi]):n.autoSizeAlign||(s=c[gi]),o?(a=c[ui],o-=c[ui]+c[pi]):n.autoSizeAlign||(a=c[ui]));const d={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){si=e,oi=e.rows,ai=e.bounds,ri=!ai.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:h}=ai;if(l||h||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;ni=!0,ti=null,Ze=Ke=$e=qe=Xe=0,Ye={data:[]},Ne={words:[]},s&&(i=[...i]);for(let n=0,h=i.length;n<h;n++)Qe=i[n],"\n"===Qe?(qe&&hi(),Ne.paraEnd=!0,ci(),ni=!0):(Je=Me(Qe),Je===De&&"none"!==r&&(Qe=Ie(Qe,r,!qe)),Ke=o.measureText(Qe).width,s&&(s<0&&($e=Ke),Ke+=s),ei=Je===ze&&(ti===ze||ti===De)||ti===ze&&Je!==je,ii=!(Je!==Fe&&Je!==ze||ti!==Ue&&ti!==je),Ve=ni&&a?l-a:l,t&&l&&Xe+qe+Ke>Ve&&(e?(qe&&hi(),Xe&&ci()):(ii||(ii=Je===De&&ti==je),ei||ii||Je===Ge||Je===Fe||Je===ze||qe+Ke>Ve?(qe&&hi(),Xe&&ci()):Xe&&ci()))," "===Qe&&!0!==ni&&Xe+qe===0||(Je===Ge?(" "===Qe&&qe&&hi(),li(Qe,Ke),hi()):ei||ii?(qe&&hi(),li(Qe,Ke)):li(Qe,Ke)),ti=Je);qe&&hi(),Xe&&ci(),oi.length>0&&(oi[oi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{si.paraNumber++,Xe=o.measureText(t).width,oi.push({x:a||0,text:t,width:Xe,paraStart:!0}),ri&&di()})}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":_i(e,"x",t[gi]);break;case"right":_i(e,"x",-t[fi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":_i(e,"y",t[ui]);break;case"bottom":_i(e,"y",-t[pi])}}(c,d,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:h,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(d?d*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(h){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&r>0&&(w+=d),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,h,c,d,u;n.forEach(t=>{t.words&&(h=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-h)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(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,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):o=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(d,n,r),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?t.Platform.canvas.measureText(o).width:0,c=n+s-h;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=h,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(d,n,s,r),"none"!==l&&function(e,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(e.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(e.decorationColor=i.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":e.decorationY=[.15*r+a];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+a,.35*-r]}}(d,n),d}};const wi={string:function(e,n){if(!e)return"#000";const s=t.isNumber(n)&&n<1;if(t.isString(e)){if(!s||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let a=t.isUndefined(e.a)?1:e.a;s&&(a*=n);const r=e.r+","+e.g+","+e.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(i.TextConvert,mi),Object.assign(i.ColorConvert,wi),Object.assign(i.Paint,X),Object.assign(i.PaintImage,Mt),Object.assign(i.PaintGradient,Jt),Object.assign(i.Effect,ue),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new E(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&r(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=E,exports.Layouter=w,exports.LeaferCanvas=n,exports.Picker=b,exports.Renderer=v,exports.Selector=L,exports.Watcher=o,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?(t.isString(i)?("#"!==i[0]&&(i="#"+i),this.viewSelect=t.Platform.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:i,height:n,pixelRatio:s}=this.config,a={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(e,i,n,s,a){this.context.roundRect(e,i,n,s,t.isNumber(a)?[a]:a)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then(t=>{this.clientBounds=t,e&&e()})}startAutoLayout(e,i){this.resizeListener||(this.resizeListener=i,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),t.isUndefined(this.width)||this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let r=e.toDataURL(s(a(i)),n);return r=r.substring(r.indexOf("64,")+3),t.Platform.origin.download(r,i)},download:(e,n)=>new Promise((s,a)=>{let r;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,r=!0);const o=i.getFileSystemManager();o.writeFile({filePath:n,data:e,encoding:"base64",success(){r?t.Platform.miniapp.saveToAlbum(n).then(()=>{o.unlink({filePath:n}),s()}):s()},fail(t){a(t)}})}),loadImage:e=>new Promise((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})}),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:i}=t.Platform.renderCanvas||t.Platform.canvas;i.requestAnimationFrame?i.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:d,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper;class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,m=t.Debug.get("Layouter");class w{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.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.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,f=this.getBlocks(s);f.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,f,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?(l(t,!0),e.add(t),t.isBranch&&d(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))})}(s,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||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,f,this.times)),n.emitEvent(new t.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),w.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(i.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){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(v.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}v.clipSpread=10;const{hitRadiusPoint:x}=t.BoundsHelper;class b{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,a=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,n.bottomList,a,!!n.findList),h=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(e,i,n,s){const a=this.findList=new t.LeafList;if(e.length){let i;const{x:s,y:r}=this.point,o={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=e.length;s<r;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,o),a.length)){if(i.isBranchLeaf&&e.some(e=>e!==i&&t.LeafHelper.hasParent(e,i))){a.reset();break}return a.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),a.length)return a.list[0];return s?null:n?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const i=new t.LeafList,n=[],{target:s}=this;for(;e&&(e.syncEventer&&n.push(e.syncEventer),i.add(e),(e=e.parent)!==s););return n.length&&n.forEach(t=>{for(;t&&(t.__.hittable&&i.add(t),(t=t.parent)!==s););}),s&&i.add(s),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren&&(!n.isLeafer||"draw"!==n.mode));t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=n.length;t<e;t++){s=n[t],a=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||x(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&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){let i,s=[];const{children:a}=n;for(let n=0,r=a.length;n<r;n++)if(i=a[n],i.__.mask&&s.push(i),i===t){if(s&&!s.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class L{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new b(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:a}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),a.getByPoint(e,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,i)=>new v(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=w.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const E={convertTouch(t,i){const n=E.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class S extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,i){return e.isUndefined(t.x)?super.getLocal(t,i):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=E.getTouch(t);this.pointerDown(E.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=E.getTouch(t);this.pointerMove(E.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=E.getTouch(t);this.pointerUp(E.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})}),n}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}destroy(){super.destroy(),this.touches=null}}function B(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function R(t,e){t.__.__font?B(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function k(t,e,i){switch(e.__.strokeAlign){case"center":P(t,1,e,i);break;case"inside":T(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?P(t,2,e,i):T(t,"outside",e,i)}}function P(e,i,n,s){const a=n.__;t.isObject(e)?A(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),C(n,s))}function T(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,P(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",B(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function C(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function A(t,e,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let h=0,c=t.length;h<c;h++)if(r=t[h],(!r.image||!i.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?C(s,a):a.stroke(),a.restoreBlendMode()):n?C(s,a):a.stroke()}}function M(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)k(e,i,n);else switch(s.strokeAlign){case"center":O(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),O(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)O(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),O(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function O(e,n,s,a){const r=s.__;t.isObject(e)?A(e,n,!1,s,a):(a.setStroke(e,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&i.Paint.strokeArrow(e,s,a)}const{getSpread:W,copyAndSpread:I,toOuterOf:H,getOuterOf:D,getByMove:z,move:F,getIntersectData:j}=t.BoundsHelper,U={};let G;const{stintSet:Y}=t.DataHelper,{hasTransparent:N}=i.ColorConvert;function q(e,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=i.PaintImage.image(s,e,n,r,!G||!G[n.url]);break;case"linear":a=i.PaintGradient.linearGradient(n,r);break;case"radial":a=i.PaintGradient.radialGradient(n,r);break;case"angular":a=i.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:h}=n;a={type:o,style:i.ColorConvert.string(l,h)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:i.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&N(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const X={compute:function(e,n){const s=n.__,a=[];let r,o,l,h=s.__input[e];t.isArray(h)||(h=[h]),G=i.PaintImage.recycleImage(e,s);for(let t,i=0,s=h.length;i<s;i++)(t=q(e,h[i],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+e]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===e?(Y(s,"__isAlphaPixelFill",r),Y(s,"__isTransparentFill",o)):(Y(s,"__isAlphaPixelStroke",r),Y(s,"__isTransparentStroke",o),Y(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,R(e,i)},fills:function(t,e,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(i.PaintImage.checkImage(e,n,s,!e.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&e.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&i>1)&&n.scale(1/t,1/i)}s.blendMode&&(n.blendMode=s.blendMode),R(e,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),R(e,n),n.restoreBlendMode()):R(e,n)}},fillPathOrText:R,fillText:B,stroke:M,strokes:function(t,e,i){M(t,e,i)},strokeText:k,drawTextStroke:C,shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let h,c,d,u,f,p;H(o.strokeSpread?(I(U,o.boxBounds,o.strokeSpread),U):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(a.includes(l))p=s,h=f=l,c=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?W(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):a;s=j(e,l)}u=a.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=m,_*=w),f=D(l,u),h=z(f,-u.e,-u.f),c=D(r,u),F(c,-u.e,-u.f);const y=n.matrix;y?(d=new t.Matrix(u),d.multiply(y),m*=y.scaleX,w*=y.scaleY):d=u,d.withScale(m,w),n=Object.assign(Object.assign({},n),{matrix:d})}return e.__renderShape(s,n),{canvas:s,matrix:d,fitMatrix:u,bounds:h,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let V={},Q=t.getMatrixData();const{get:K,set:Z,rotateOfOuter:$,translate:J,scaleOfOuter:tt,multiplyParent:et,scale:it,rotate:nt,skew:st}=t.MatrixHelper;function at(t,e,i,n){const s=K();J(s,e.x,e.y),i&&it(s,i,n),t.transform=s}function rt(t,e,i,n,s,a,r){const o=K();J(o,e.x+i,e.y+n),it(o,s,a),r&&$(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function ot(t,e,i,n,s,a,r,o,l,h){const c=K();ht(c,e,i,n,s,a,r,o),l&&(r||o?(Z(Q),tt(Q,e,l,h),et(c,Q)):tt(c,e,l,h)),t.transform=c}function lt(t,e,i,n,s,a,r,o,l,h,c,d){const u=K();if(d)ht(u,e,s,a,r,o,l,h);else{if(l)if("center"===c)$(u,{x:i/2,y:n/2},l);else switch(nt(u,l),l){case 90:J(u,n,0);break;case 180:J(u,i,n);break;case 270:J(u,0,i)}V.x=e.x+s,V.y=e.y+a,J(u,V.x,V.y),r&&tt(u,V,r,o)}t.transform=u}function ht(t,e,i,n,s,a,r,o){r&&nt(t,r),o&&st(t,o.x,o.y),s&&it(t,s,a),J(t,e.x+i,e.y+n)}const{get:ct,translate:dt}=t.MatrixHelper,ut=new t.Bounds,ft={},pt={};function gt(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=_t(i,n,e)}function _t(e,i,n){e.padding&&(i=ut.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:h,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(pt,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((c||d)&&(t.MathHelper.getScaleData(c,d,n,ft),x=ft.scaleX,b=ft.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(pt,x,b,!0),l&&t.AlignHelper.toPoint(l,pt,i,pt,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,pt,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,pt),t.BoundsHelper.scale(pt,x,b,!0)),h&&t.PointHelper.move(pt,h),o){case"stretch":w||(x=i.width/s,b=i.height/a,at(y,i,x,b));break;case"normal":case"clip":if(pt.x||pt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),ot(y,i,pt.x,pt.y,x,b,u,f,t,e),t&&(x=x?x*t:t,b=b?b*e:e)}break;case"repeat":(!w||x||u||f)&&lt(y,i,s,a,pt.x,pt.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:mt(r,n,a.width,i&&i.x),y:mt(o,s,a.height,i&&i.y)}}(_,n&&g,pt.width,pt.height,i));break;default:x&&rt(y,i,pt.x,pt.y,x,b,u)}return y.transform||(i.x||i.y)&&dt(y.transform=ct(),i.x,i.y),y.width=s,y.height=a,x&&(y.scaleX=x,y.scaleY=b),r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function mt(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let wt,yt=new t.Bounds;const{isSame:vt}=t.BoundsHelper;function xt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||gt(s,n,i,a),!0}function bt(e,i){St(e,t.ImageEvent.LOAD,i)}function Lt(e,i){St(e,t.ImageEvent.LOADED,i)}function Et(e,i,n){i.error=n,e.forceUpdate("surface"),St(e,t.ImageEvent.ERROR,i)}function St(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function Bt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Rt,scale:kt,copy:Pt}=t.MatrixHelper,{floor:Tt,ceil:Ct,max:At,abs:Mt}=Math;function Ot(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let h,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Mt(f),p=Mt(p),c=Rt(),Pt(c,g),kt(c,1/f,1/p),s*=f,a*=p),d*=s,u*=a;const w=d*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=d/o.width;t>1&&(h=t/Ct(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(h=Math.sqrt(w/y)),h&&(s/=h,a/=h,d/=h,u/=h),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=d+(v||0),e=u+(x||0);s/=t/At(Tt(t),1),a/=e/At(Tt(e),1),c||(c=Rt(),g&&Pt(c,g)),kt(c,1/s,1/a)}const b=o.getCanvas(d,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),L=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=L,i.patternId=r,!0}}function Wt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const It={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return wt&&n===wt.paint&&vt(s,wt.boxBounds)?r=wt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),wt=l.use>1?{leafPaint:r,paint:n,boxBounds:yt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(xt(e,i,n,l,r,s),a&&(bt(e,o),Lt(e,o))):l.error?a&&Et(e,o,l.error):(a&&(Bt(e,!0),bt(e,o)),r.loadId=l.load(()=>{Bt(e,!1),e.destroyed||(xt(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),Lt(e,o)),r.loadId=void 0},t=>{Bt(e,!1),Et(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,n,s,a){const{scaleX:r,scaleY:o}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:h}=s;if(!h||s.patternId===r+"-"+o+"-"+l&&!i.Export.running)return!1;if(a)if(h.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=h;e*=r*l,i*=o*l,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(e.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,n,s,h),!0):(!s.style||s.sync||i.Export.running?Ot(e,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Wt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Ot(e,s,l),e.forceUpdate("surface")}),300)),!1)},createPattern:Ot,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let h=0,c=n.length;h<c;h++)s=n[h],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[h].loadId,!o.some(t=>t.url===l))));return r}return null},createData:gt,getPatternData:_t,stretchMode:at,fillOrFitMode:rt,clipMode:ot,repeatMode:lt},{toPoint:Ht}=t.AroundHelper,{hasTransparent:Dt}=i.ColorConvert,zt={},Ft={};function jt(e,n,s,a){if(s){let r,o,l,h;for(let e=0,c=s.length;e<c;e++)r=s[e],t.isString(r)?(l=e/(c-1),o=i.ColorConvert.string(r,a)):(l=r.offset,o=i.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!h&&Dt(o)&&(h=!0);h&&(e.isTransparent=!0)}}const{getAngle:Ut,getDistance:Gt}=t.PointHelper,{get:Yt,rotateOfOuter:Nt,scaleOfOuter:qt}=t.MatrixHelper,{toPoint:Xt}=t.AroundHelper,Vt={},Qt={};function Kt(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Ut(e,i);a=Yt(),s?(qt(a,e,r/o*(n||1),1),Nt(a,e,t+90)):(qt(a,e,1,r/o*(n||1)),Nt(a,e,t))}return a}const{getDistance:Zt}=t.PointHelper,{toPoint:$t}=t.AroundHelper,Jt={},te={};const ee={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;Ht(n||"top",i,zt),Ht(s||"bottom",i,Ft);const o=t.Platform.canvas.createLinearGradient(zt.x,zt.y,Ft.x,Ft.y),l={type:a,style:o};return jt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Xt(n||"center",i,Vt),Xt(s||"bottom",i,Qt);const l=t.Platform.canvas.createRadialGradient(Vt.x,Vt.y,0,Vt.x,Vt.y,Gt(Vt,Qt)),h={type:a,style:l};jt(h,l,e.stops,r);const c=Kt(i,Vt,Qt,o,!0);return c&&(h.transform=c),h},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;$t(n||"center",i,Jt),$t(s||"bottom",i,te);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Jt.x,Jt.y):t.Platform.canvas.createRadialGradient(Jt.x,Jt.y,0,Jt.x,Jt.y,Zt(Jt,te)),h={type:a,style:l};jt(h,l,e.stops,r);const c=Kt(i,Jt,te,o||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),h},getTransform:Kt},{copy:ie,move:ne,toOffsetOutBounds:se}=t.BoundsHelper,{max:ae,abs:re}=Math,oe={},le=new t.Matrix,he={};function ce(t,e){let i,n,s,a,r=0,o=0,l=0,h=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,a=1.5*(t.blur||0),s=re(t.spread||0),r=ae(r,s+a-n),o=ae(o,s+a+i),l=ae(l,s+a+n),h=ae(h,s+a-i)}),r===o&&o===l&&l===h?r:[r,o,l,h]}function de(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(ie(oe,e.bounds),ne(oe,i.x-s.x,i.y-s.y),a=e.bounds,r=oe):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:ue}=t.BoundsHelper,fe={};const pe=ce;const ge={shadow:function(e,n,s){let a,r;const{__nowWorld:o}=e,{shadow:l}=e.__,{worldCanvas:h,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;se(c,he,d),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(he.offsetX+(l.x||0)*f*w,he.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,i.ColorConvert.string(l.color)),r=i.Effect.getShadowTransform(e,g,s,l,he,w),r&&g.setTransform(r),de(g,he,s),r&&g.resetTransform(),a=d,l.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,d,o,"copy"),a=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(e,n,s){let a,r;const{__nowWorld:o}=e,{innerShadow:l}=e.__,{worldCanvas:h,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;ue(c,fe,d),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(fe.offsetX+(l.x||0)*f*w,fe.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=i.Effect.getShadowTransform(e,g,s,l,fe,w,!0),r&&g.setTransform(r),de(g,fe,s),g.restore(),h?(g.copyWorld(g,d,o,"copy"),g.copyWorld(h,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=d),g.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},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){},getShadowRenderSpread:ce,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=1+2*n.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return le.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},i),le}},isTransformShadow(t){},getInnerShadowSpread:pe},{excludeRenderBounds:_e}=t.LeafBoundsHelper;let me;function we(t,e,i,n,s,a,r,o){switch(e){case"grayscale":me||(me=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);ve(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":ve(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ye(t){return t.getSameCanvas(!1,!0)}function ve(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let h=0,c=l.length;h<c;h++){if(i=l[h],o=i.__.mask,o){r&&(we(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||_e(i,e)||i.__render(t,e),a=i.__.opacity,me=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ye(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ye(t)),s||(s=ye(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&we(this,r,t,s,n,a,void 0,!1),_e(i,e)||i.__render(s||t,e),c&&we(this,r,t,s,n,a,c,!1)}we(this,r,t,s,n,a,void 0,!0)};const xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",be=xe+"_#~&*+\\=|≮≯≈≠=…",Le=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 Ee(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Se=Ee("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Be=Ee("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Re=Ee(xe),ke=Ee(be),Pe=Ee("- —/~|┆·");var Te;!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"}(Te||(Te={}));const{Letter:Ce,Single:Ae,Before:Me,After:Oe,Symbol:We,Break:Ie}=Te;function He(t){return Se[t]?Ce:Pe[t]?Ie:Be[t]?Me:Re[t]?Oe:ke[t]?We:Le.test(t)?Ae:Ce}const De={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ze(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:je,Single:Ue,Before:Ge,After:Ye,Symbol:Ne,Break:qe}=Te;let Xe,Ve,Qe,Ke,Ze,$e,Je,ti,ei,ii,ni,si,ai,ri,oi,li,hi,ci=[];function di(t,e){ei&&!ti&&(ti=ei),Xe.data.push({char:t,width:e}),Qe+=e}function ui(){Ke+=Qe,Xe.width=Qe,Ve.words.push(Xe),Xe={data:[]},Qe=0}function fi(){ri&&(oi.paraNumber++,Ve.paraStart=!0,ri=!1),ei&&(Ve.startCharSize=ti,Ve.endCharSize=ei,ti=0),Ve.width=Ke,li.width?Fe(Ve):hi&&pi(),ci.push(Ve),Ve={words:[]},Ke=0}function pi(){Ke>(oi.maxWidth||0)&&(oi.maxWidth=Ke)}const{top:gi,right:_i,bottom:mi,left:wi}=t.Direction4;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 vi={getDrawData:function(e,n){t.isString(e)||(e=String(e));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:h,__padding:c}=n;c&&(r?(s=c[wi],r-=c[_i]+c[wi]):n.autoSizeAlign||(s=c[wi]),o?(a=c[gi],o-=c[gi]+c[mi]):n.autoSizeAlign||(a=c[gi]));const d={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){oi=e,ci=e.rows,li=e.bounds,hi=!li.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:h}=li;if(l||h||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;ri=!0,ni=null,ti=Je=ei=Qe=Ke=0,Xe={data:[]},Ve={words:[]},s&&(i=[...i]);for(let n=0,h=i.length;n<h;n++)$e=i[n],"\n"===$e?(Qe&&ui(),Ve.paraEnd=!0,fi(),ri=!0):(ii=He($e),ii===je&&"none"!==r&&($e=ze($e,r,!Qe)),Je=o.measureText($e).width,s&&(s<0&&(ei=Je),Je+=s),si=ii===Ue&&(ni===Ue||ni===je)||ni===Ue&&ii!==Ye,ai=!(ii!==Ge&&ii!==Ue||ni!==Ne&&ni!==Ye),Ze=ri&&a?l-a:l,t&&l&&Ke+Qe+Je>Ze&&(e?(Qe&&ui(),Ke&&fi()):(ai||(ai=ii===je&&ni==Ye),si||ai||ii===qe||ii===Ge||ii===Ue||Qe+Je>Ze?(Qe&&ui(),Ke&&fi()):Ke&&fi()))," "===$e&&!0!==ri&&Ke+Qe===0||(ii===qe?(" "===$e&&Qe&&ui(),di($e,Je),ui()):si||ai?(Qe&&ui(),di($e,Je)):di($e,Je)),ni=ii);Qe&&ui(),Ke&&fi(),ci.length>0&&(ci[ci.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{oi.paraNumber++,Ke=o.measureText(t).width,ci.push({x:a||0,text:t,width:Ke,paraStart:!0}),hi&&pi()})}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":yi(e,"x",t[wi]);break;case"right":yi(e,"x",-t[_i])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":yi(e,"y",t[gi]);break;case"bottom":yi(e,"y",-t[mi])}}(c,d,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:h,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(d?d*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(h){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&r>0&&(w+=d),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,h,c,d,u;n.forEach(t=>{t.words&&(h=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-h)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(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,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):o=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(d,n,r),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?t.Platform.canvas.measureText(o).width:0,c=n+s-h;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=h,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(d,n,s,r),"none"!==l&&function(e,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(e.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(e.decorationColor=i.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":e.decorationY=[.15*r+a];break;case"delete":e.decorationY=[.35*-r];break;case"under-delete":e.decorationY=[.15*r+a,.35*-r]}}(d,n),d}};const xi={string:function(e,n){if(!e)return"#000";const s=t.isNumber(n)&&n<1;if(t.isString(e)){if(!s||!i.ColorConvert.object)return e;e=i.ColorConvert.object(e)}let a=t.isUndefined(e.a)?1:e.a;s&&(a*=n);const r=e.r+","+e.g+","+e.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(i.TextConvert,vi),Object.assign(i.ColorConvert,xi),Object.assign(i.Paint,X),Object.assign(i.PaintImage,It),Object.assign(i.PaintGradient,ee),Object.assign(i.Effect,ge),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new S(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&r(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=S,exports.Layouter=w,exports.LeaferCanvas=n,exports.Picker=b,exports.Renderer=v,exports.Selector=L,exports.Watcher=o,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
2
2
  //# sourceMappingURL=miniapp.min.cjs.map