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