leafer-ui
Version:
一款革新、好用的 Canvas 引擎, 轻松实现专业图形编辑。适用于图形编辑、小游戏、互动应用、组态软件、生成图片与短视频等场景。
1 lines • 51.9 kB
JavaScript
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class s extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let i=t.isString(e)?document.getElementById(e):e;if(i)if(i instanceof HTMLCanvasElement)this.view=i;else{let t=i;if(i===window||i===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else n.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:o,fileType:r}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=o(e),s=t.toDataURL(n,i);return"image/bmp"===n?s.replace("image/png;","image/bmp;"):s},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,o(e),i)),canvasSaveAs:(e,i,n)=>{const s=e.toDataURL(o(r(i)),n);return t.Platform.origin.download(s,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:h}=navigator;h.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?t.Platform.os="Mac":h.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:c,updateBounds:d,updateChange:u}=t.LeafHelper,{pushAllChildBranch:f,pushAllParent:p}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper;class v{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,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:w,updateAllChange:_}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,h=this.getBlocks(s);h.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(o,h,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?(c(t,!0),e.add(t),t.isBranch&&f(t,e),p(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),p(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||d(n[t])}d(i)}})}(this.__levelList),function(t){t.list.forEach(u)}(s),this.extraBlock&&h.push(this.extraBlock),h.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,h,this.times)),n.emitEvent(new t.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new v([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new v(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=new t.Bounds(s);n.save(),s.spread(b.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,o),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),t.Platform.render(this.target,n,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}b.clipSpread=10;const{hitRadiusPoint:L}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o,!!n.findList),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(e,i,n,s){const o=this.findList=new t.LeafList;if(e.length){let i;const{x:s,y:r}=this.point,a={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=e.length;s<r;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),o.length)){if(i.isBranchLeaf&&e.some(e=>e!==i&&t.LeafHelper.hasParent(e,i))){o.reset();break}return o.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),o.length)return o.list[0];return s?null:n?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const i=new t.LeafList,n=[],{target:s}=this;for(;e&&(e.syncEventer&&n.push(e.syncEventer),i.add(e),(e=e.parent)!==s););return n.length&&n.forEach(t=>{for(;t&&(t.__.hittable&&i.add(t),(t=t.parent)!==s););}),s&&i.add(s),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren&&(!n.isLeafer||"draw"!==n.mode));t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.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 o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||L(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask){let i,s=[];const{children:o}=n;for(let n=0,r=o.length;n<r;n++)if(i=o[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 P{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new E(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:o}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(e,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new b(t,e,i),selector:(t,e)=>new P(t,e)}),t.Platform.layout=y.fullLayout,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const B={convert(t,i){const n=e.InteractionHelper.getBase(t),{x:s,y:o}=i,r=Object.assign(Object.assign({},n),{x:s,y:o,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===r.pointerType&&(r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist),r},convertMouse(t,i){const n=e.InteractionHelper.getBase(t),{x:s,y:o}=i;return Object.assign(Object.assign({},n),{x:s,y:o,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=B.getTouch(t),s=e.InteractionHelper.getBase(t),{x:o,y:r}=i;return Object.assign(Object.assign({},s),{x:o,y:r,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},S={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{pathCanDrag:R}=e.InteractionHelper;class k extends e.InteractionBase{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(S.convert(t))}onKeyUp(t){this.keyUp(S.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(B.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(B.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=B.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(B.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(B.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(B.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(B.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=B.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&R(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(B.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=B.getTouch(t);this.pointerMove(B.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=B.getTouch(t);this.pointerUp(B.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})}),n}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},e.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(i){if(this.useMultiTouch)return;this.preventDefaultWheel(i);const n=e.InteractionHelper.getBase(i);Object.assign(n,this.getLocal(i));const s=i.scale/this.lastGestureScale,o=(i.rotation-this.lastGestureRotation)/Math.PI*180*(t.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},n),{scale:s*s})),this.rotate(Object.assign(Object.assign({},n),{rotation:o})),this.lastGestureScale=i.scale,this.lastGestureRotation=i.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(e){super.setCursor(e);const i=[];this.eachCursor(e,i),t.isObject(i[i.length-1])&&i.push("default"),this.canvas.view.style.cursor=i.map(e=>t.isObject(e)?`url(${e.url}) ${e.x||0} ${e.y||0}`:e).join(",")}eachCursor(i,n,s=0){if(s++,t.isArray(i))i.forEach(t=>this.eachCursor(t,n,s));else{const o=t.isString(i)&&e.Cursor.get(i);o&&s<2?this.eachCursor(o,n,s):n.push(i)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function T(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(s){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,o)))}}function C(t,e){t.__.__font?T(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function M(t,e,i){switch(e.__.strokeAlign){case"center":O(t,1,e,i);break;case"inside":A(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?O(t,2,e,i):A(t,"outside",e,i)}}function O(e,i,n,s){const o=n.__;t.isObject(e)?W(e,i,!0,n,s):(s.setStroke(e,o.__strokeWidth*i,o),D(n,s))}function A(e,i,n,s){const o=s.getSameCanvas(!0,!0);o.font=n.__.__font,O(e,2,n,o),o.blendMode="outside"===i?"destination-out":"destination-in",T(n,o),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,o),o.recycle(n.__nowWorld)}function D(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=n;s.forEach(i=>o.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function W(t,e,n,s,o){let r;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||o.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,c=t.length;l<c;l++)if(r=t[l],(!r.image||!i.PaintImage.checkImage(s,o,r,!1))&&r.style){if(h){const{strokeStyle:t}=r;t?o.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):o.setStroke(r.style,a.__strokeWidth*e,a)}else o.strokeStyle=r.style;r.blendMode?(o.saveBlendMode(r.blendMode),n?D(s,o):o.stroke(),o.restoreBlendMode()):n?D(s,o):o.stroke()}}function I(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)M(e,i,n);else switch(s.strokeAlign){case"center":H(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),H(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)H(e,2,i,n);else{const{renderBounds:o}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),H(e,2,i,r),r.clipUI(s),r.clearWorld(o),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function H(e,n,s,o){const r=s.__;t.isObject(e)?W(e,n,!1,s,o):(o.setStroke(e,r.__strokeWidth*n,r),o.stroke()),r.__useArrow&&i.Paint.strokeArrow(e,s,o)}const{getSpread:z,copyAndSpread:F,toOuterOf:j,getOuterOf:U,getByMove:G,move:Y,getIntersectData:V}=t.BoundsHelper,X={};let N;const{stintSet:q}=t.DataHelper,{hasTransparent:K}=i.ColorConvert;function Q(e,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let o;const{boxBounds:r}=s.__layout;switch(n.type){case"image":o=i.PaintImage.image(s,e,n,r,!N||!N[n.url]);break;case"linear":o=i.PaintGradient.linearGradient(n,r);break;case"radial":o=i.PaintGradient.radialGradient(n,r);break;case"angular":o=i.PaintGradient.conicGradient(n,r);break;case"solid":const{type:a,color:h,opacity:l}=n;o={type:a,style:i.ColorConvert.string(h,l)};break;default:t.isUndefined(n.r)||(o={type:"solid",style:i.ColorConvert.string(n)})}if(o){if(t.isString(o.style)&&K(o.style)&&(o.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;o.strokeStyle=n.style}n.editing&&(o.editing=n.editing),n.blendMode&&(o.blendMode=n.blendMode)}return o}const $={compute:function(e,n){const s=n.__,o=[];let r,a,h,l=s.__input[e];t.isArray(l)||(l=[l]),N=i.PaintImage.recycleImage(e,s);for(let t,i=0,s=l.length;i<s;i++)(t=Q(e,l[i],n))&&(o.push(t),t.strokeStyle&&(h||(h=1),t.strokeStyle.strokeWidth&&(h=Math.max(h,t.strokeStyle.strokeWidth))));s["_"+e]=o.length?o:void 0,o.length&&o.every(t=>t.isTransparent)&&(o.some(t=>t.image)&&(r=!0),a=!0),"fill"===e?(q(s,"__isAlphaPixelFill",r),q(s,"__isTransparentFill",a)):(q(s,"__isAlphaPixelStroke",r),q(s,"__isTransparentStroke",a),q(s,"__hasMultiStrokeStyle",h))},fill:function(t,e,i){i.fillStyle=t,C(e,i)},fills:function(t,e,n){let s;for(let o=0,r=t.length;o<r;o++){if(s=t[o],s.image){if(i.PaintImage.checkImage(e,n,s,!e.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&e.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&i>1)&&n.scale(1/t,1/i)}s.blendMode&&(n.blendMode=s.blendMode),C(e,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),C(e,n),n.restoreBlendMode()):C(e,n)}},fillPathOrText:C,fillText:T,stroke:I,strokes:function(t,e,i){I(t,e,i)},strokeText:M,drawTextStroke:D,shape:function(e,i,n){const s=i.getSameCanvas(),o=i.bounds,r=e.__nowWorld,a=e.__layout,h=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let l,c,d,u,f,p;j(a.strokeSpread?(F(X,a.boxBounds,a.strokeSpread),X):a.boxBounds,r,h);let{scaleX:g,scaleY:v}=e.getRenderScaleData(!0);if(o.includes(h))p=s,l=f=h,c=r;else{let s;if(t.Platform.fullImageShadow)s=h;else{const e=a.renderShapeSpread?z(o,t.FourNumberHelper.swapAndScale(a.renderShapeSpread,g,v)):o;s=V(e,h)}u=o.getFitMatrix(s);let{a:w,d:_}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=w,v*=_),f=U(h,u),l=G(f,-u.e,-u.f),c=U(r,u),Y(c,-u.e,-u.f);const m=n.matrix;m?(d=new t.Matrix(u),d.multiply(m),w*=m.scaleX,_*=m.scaleY):d=u,d.withScale(w,_),n=Object.assign(Object.assign({},n),{matrix:d})}return e.__renderShape(s,n),{canvas:s,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:v}}};let Z={},J=t.getMatrixData();const{get:tt,set:et,rotateOfOuter:it,translate:nt,scaleOfOuter:st,multiplyParent:ot,scale:rt,rotate:at,skew:ht}=t.MatrixHelper;function lt(t,e,i,n){const s=tt();nt(s,e.x,e.y),i&&rt(s,i,n),t.transform=s}function ct(t,e,i,n,s,o,r){const a=tt();nt(a,e.x+i,e.y+n),rt(a,s,o),r&&it(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function dt(t,e,i,n,s,o,r,a,h,l){const c=tt();ft(c,e,i,n,s,o,r,a),h&&(r||a?(et(J),st(J,e,h,l),ot(c,J)):st(c,e,h,l)),t.transform=c}function ut(t,e,i,n,s,o,r,a,h,l,c,d){const u=tt();if(d)ft(u,e,s,o,r,a,h,l);else{if(h)if("center"===c)it(u,{x:i/2,y:n/2},h);else switch(at(u,h),h){case 90:nt(u,n,0);break;case 180:nt(u,i,n);break;case 270:nt(u,0,i)}Z.x=e.x+s,Z.y=e.y+o,nt(u,Z.x,Z.y),r&&st(u,Z,r,a)}t.transform=u}function ft(t,e,i,n,s,o,r,a){r&&at(t,r),a&&ht(t,a.x,a.y),s&&rt(t,s,o),nt(t,e.x+i,e.y+n)}const{get:pt,translate:gt}=t.MatrixHelper,vt=new t.Bounds,wt={},_t={};function mt(t,e,i,n){const{changeful:s,sync:o,scaleFixed:r}=i;s&&(t.changeful=s),o&&(t.sync=o),r&&(t.scaleFixed=r),t.data=yt(i,n,e)}function yt(e,i,n){e.padding&&(i=vt.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=n;const{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:v,filters:w}=e,_=i.width===s&&i.height===o,m={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(_t,0,0,y?o:s,y?s:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,n,wt),x=wt.scaleX,b=wt.scaleY),(h||v||g)&&(x&&t.BoundsHelper.scale(_t,x,b,!0),h&&t.AlignHelper.toPoint(h,_t,i,_t,!0,!0))):_&&!u||(x=b=t.BoundsHelper.getFitScale(i,_t,"fit"!==a),t.BoundsHelper.put(i,n,h,x,!1,_t),t.BoundsHelper.scale(_t,x,b,!0)),l&&t.PointHelper.move(_t,l),a){case"stretch":_||(x=i.width/s,b=i.height/o,lt(m,i,x,b));break;case"normal":case"clip":if(_t.x||_t.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),dt(m,i,_t.x,_t.y,x,b,u,f,t,e),t&&(x=x?x*t:t,b=b?b*e:e)}break;case"repeat":(!_||x||u||f)&&ut(m,i,s,o,_t.x,_t.y,x,b,u,f,h,e.freeTransform),g||(m.repeat="repeat");const n=t.isObject(g);(v||n)&&(m.gap=function(e,i,n,s,o){let r,a;t.isObject(e)?(r=e.x,a=e.y):r=a=e;return{x:xt(r,n,o.width,i&&i.x),y:xt(a,s,o.height,i&&i.y)}}(v,n&&g,_t.width,_t.height,i));break;default:x&&ct(m,i,_t.x,_t.y,x,b,u)}return m.transform||(i.x||i.y)&>(m.transform=pt(),i.x,i.y),m.width=s,m.height=o,x&&(m.scaleX=x,m.scaleY=b),r&&(m.opacity=r),w&&(m.filters=w),g&&(m.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),m}function xt(e,i,n,s){const o=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&o<0?0:o}let bt,Lt=new t.Bounds;const{isSame:Et}=t.BoundsHelper;function Pt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||mt(s,n,i,o),!0}function Bt(e,i){kt(e,t.ImageEvent.LOAD,i)}function St(e,i){kt(e,t.ImageEvent.LOADED,i)}function Rt(e,i,n){i.error=n,e.forceUpdate("surface"),kt(e,t.ImageEvent.ERROR,i)}function kt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function Tt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ct,scale:Mt,copy:Ot}=t.MatrixHelper,{floor:At,ceil:Dt,max:Wt,abs:It}=Math;function Ht(e,i,n){let{scaleX:s,scaleY:o}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+o+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:a,data:h}=i;let l,c,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:v,gap:w}=h;s*=n,o*=n,f&&(f=It(f),p=It(p),c=Ct(),Ot(c,g),Mt(c,1/f,1/p),s*=f,o*=p),d*=s,u*=o;const _=d*u;if(!v&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(a.isSVG){const t=d/a.width;t>1&&(l=t/Dt(t))}else{const t=a.width*a.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,o/=l,d/=l,u/=l),f&&(s/=f,o/=p);const y=w&&w.x*s,x=w&&w.y*o;if(g||1!==s||1!==o){const t=d+(y||0),e=u+(x||0);s/=t/Wt(At(t),1),o/=e/Wt(At(e),1),c||(c=Ct(),g&&Ot(c,g)),Mt(c,1/s,1/o)}const b=a.getCanvas(d,u,h.opacity,h.filters,y,x,e.leafer&&e.leafer.config.smooth),L=a.getPattern(b,v||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=L,i.patternId=r,!0}}function zt(t,e,i,n){return new(i||(i=Promise))(function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Ft={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return bt&&n===bt.paint&&Et(s,bt.boxBounds)?r=bt.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),bt=h.use>1?{leafPaint:r,paint:n,boxBounds:Lt.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(Pt(e,i,n,h,r,s),o&&(Bt(e,a),St(e,a))):h.error?o&&Rt(e,a,h.error):(o&&(Tt(e,!0),Bt(e,a)),r.loadId=h.load(()=>{Tt(e,!1),e.destroyed||(Pt(e,i,n,h,r,s)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),St(e,a)),r.loadId=void 0},t=>{Tt(e,!1),Rt(e,a,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{h.ready||(h.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):h.isPlacehold=!0)),r},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:a}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:h}=n,{data:l}=s;if(!l||s.patternId===r+"-"+a+"-"+h&&!i.Export.running)return!1;if(o)if(l.repeat)o=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=l;e*=r*h,i*=a*h,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(e.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,n,s,l),!0):(!s.style||s.sync||i.Export.running?Ht(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>zt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Ht(e,s,h),e.forceUpdate("surface")}),300)),!1)},createPattern:Ht,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,o,r,a,h;for(let l=0,c=n.length;l<c;l++)s=n[l],o=s.image,h=o&&o.url,h&&(r||(r={}),r[h]=!0,t.ImageManager.recycle(o),o.loading&&(a||(a=i.__input&&i.__input[e]||[],t.isArray(a)||(a=[a])),o.unload(n[l].loadId,!a.some(t=>t.url===h))));return r}return null},createData:mt,getPatternData:yt,stretchMode:lt,fillOrFitMode:ct,clipMode:dt,repeatMode:ut},{toPoint:jt}=t.AroundHelper,{hasTransparent:Ut}=i.ColorConvert,Gt={},Yt={};function Vt(e,n,s,o){if(s){let r,a,h,l;for(let e=0,c=s.length;e<c;e++)r=s[e],t.isString(r)?(h=e/(c-1),a=i.ColorConvert.string(r,o)):(h=r.offset,a=i.ColorConvert.string(r.color,o)),n.addColorStop(h,a),!l&&Ut(a)&&(l=!0);l&&(e.isTransparent=!0)}}const{getAngle:Xt,getDistance:Nt}=t.PointHelper,{get:qt,rotateOfOuter:Kt,scaleOfOuter:Qt}=t.MatrixHelper,{toPoint:$t}=t.AroundHelper,Zt={},Jt={};function te(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Xt(e,i);o=qt(),s?(Qt(o,e,r/a*(n||1),1),Kt(o,e,t+90)):(Qt(o,e,1,r/a*(n||1)),Kt(o,e,t))}return o}const{getDistance:ee}=t.PointHelper,{toPoint:ie}=t.AroundHelper,ne={},se={};const oe={linearGradient:function(e,i){let{from:n,to:s,type:o,opacity:r}=e;jt(n||"top",i,Gt),jt(s||"bottom",i,Yt);const a=t.Platform.canvas.createLinearGradient(Gt.x,Gt.y,Yt.x,Yt.y),h={type:o,style:a};return Vt(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;$t(n||"center",i,Zt),$t(s||"bottom",i,Jt);const h=t.Platform.canvas.createRadialGradient(Zt.x,Zt.y,0,Zt.x,Zt.y,Nt(Zt,Jt)),l={type:o,style:h};Vt(l,h,e.stops,r);const c=te(i,Zt,Jt,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;ie(n||"center",i,ne),ie(s||"bottom",i,se);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,ne.x,ne.y):t.Platform.canvas.createRadialGradient(ne.x,ne.y,0,ne.x,ne.y,ee(ne,se)),l={type:o,style:h};Vt(l,h,e.stops,r);const c=te(i,ne,se,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:te},{copy:re,move:ae,toOffsetOutBounds:he}=t.BoundsHelper,{max:le,abs:ce}=Math,de={},ue=new t.Matrix,fe={};function pe(t,e){let i,n,s,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,o=1.5*(t.blur||0),s=ce(t.spread||0),r=le(r,s+o-n),a=le(a,s+o+i),h=le(h,s+o+n),l=le(l,s+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function ge(e,i,n){const{shapeBounds:s}=n;let o,r;t.Platform.fullImageShadow?(re(de,e.bounds),ae(de,i.x-s.x,i.y-s.y),o=e.bounds,r=de):(o=s,r=i),e.copyWorld(n.canvas,o,r)}const{toOffsetOutBounds:ve}=t.BoundsHelper,we={};const _e=pe;const me={shadow:function(e,n,s){let o,r;const{__nowWorld:a}=e,{shadow:h}=e.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),v=h.length-1;he(c,fe,d),h.forEach((h,w)=>{let _=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.setWorldShadow(fe.offsetX+(h.x||0)*f*_,fe.offsetY+(h.y||0)*p*_,(h.blur||0)*f*_,i.ColorConvert.string(h.color)),r=i.Effect.getShadowTransform(e,g,s,h,fe,_),r&&g.setTransform(r),ge(g,fe,s),r&&g.resetTransform(),o=d,h.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),o=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,o,h.blendMode),v&&w<v&&g.clearWorld(o)}),g.recycle(o)},innerShadow:function(e,n,s){let o,r;const{__nowWorld:a}=e,{innerShadow:h}=e.__,{worldCanvas:l,bounds:c,renderBounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),v=h.length-1;ve(c,we,d),h.forEach((h,w)=>{let _=1;if(h.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}g.save(),g.setWorldShadow(we.offsetX+(h.x||0)*f*_,we.offsetY+(h.y||0)*p*_,(h.blur||0)*f*_),r=i.Effect.getShadowTransform(e,g,s,h,we,_,!0),r&&g.setTransform(r),ge(g,we,s),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),o=a):(g.copyWorld(s.canvas,u,c,"source-out"),o=d),g.fillWorld(o,i.ColorConvert.string(h.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,o,h.blendMode),v&&w<v&&g.clearWorld(o)}),g.recycle(o)},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:pe,getShadowTransform:function(t,e,i,n,s,o,r){if(n.spread){const i=1+2*n.spread/t.__layout.strokeBounds.width*o*(r?-1:1);return ue.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},i),ue}},isTransformShadow(t){},getInnerShadowSpread:_e},{excludeRenderBounds:ye}=t.LeafBoundsHelper;let xe;function be(t,e,i,n,s,o,r,a){switch(e){case"grayscale":xe||(xe=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),o&&n.recycle(r);Ee(t,e,i,1,s,o)}(t,i,n,s,r,a);break;case"opacity-path":Ee(t,i,n,o,r,a);break;case"path":a&&i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function Ee(t,e,i,n,s,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),o?i.recycle(r):i.clearWorld(r)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(be(this,r,t,s,n,o,void 0,!0),n=s=null),"clipping"!==a&&"clipping-path"!==a||ye(i,e)||i.__render(t,e),o=i.__.opacity,xe=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",s||(s=Le(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e));continue}const c=1===o&&i.__.__blendMode;c&&be(this,r,t,s,n,o,void 0,!1),ye(i,e)||i.__render(s||t,e),c&&be(this,r,t,s,n,o,c,!1)}be(this,r,t,s,n,o,void 0,!0)};const Pe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Be=Pe+"_#~&*+\\=|≮≯≈≠=…",Se=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 Re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ke=Re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Te=Re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=Re(Pe),Me=Re(Be),Oe=Re("- —/~|┆·");var Ae;!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"}(Ae||(Ae={}));const{Letter:De,Single:We,Before:Ie,After:He,Symbol:ze,Break:Fe}=Ae;function je(t){return ke[t]?De:Oe[t]?Fe:Te[t]?Ie:Ce[t]?He:Me[t]?ze:Se.test(t)?We:De}const Ue={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ge(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:Ye}=Ue,{Letter:Ve,Single:Xe,Before:Ne,After:qe,Symbol:Ke,Break:Qe}=Ae;let $e,Ze,Je,ti,ei,ii,ni,si,oi,ri,ai,hi,li,ci,di,ui,fi,pi=[];function gi(t,e){oi&&!si&&(si=oi),$e.data.push({char:t,width:e}),Je+=e}function vi(){ti+=Je,$e.width=Je,Ze.words.push($e),$e={data:[]},Je=0}function wi(){ci&&(di.paraNumber++,Ze.paraStart=!0,ci=!1),oi&&(Ze.startCharSize=si,Ze.endCharSize=oi,si=0),Ze.width=ti,ui.width?Ye(Ze):fi&&_i(),pi.push(Ze),Ze={words:[]},ti=0}function _i(){ti>(di.maxWidth||0)&&(di.maxWidth=ti)}const{top:mi,right:yi,bottom:xi,left:bi}=t.Direction4;function Li(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 Ei={getDrawData:function(e,n){t.isString(e)||(e=String(e));let s=0,o=0,r=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:h,__font:l,__padding:c}=n;c&&(r?(s=c[bi],r-=c[yi]+c[bi]):n.autoSizeAlign||(s=c[bi]),a?(o=c[mi],a-=c[mi]+c[xi]):n.autoSizeAlign||(o=c[mi]));const d={bounds:{x:s,y:o,width:r,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,i,n){di=e,pi=e.rows,ui=e.bounds,fi=!ui.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=ui;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;ci=!0,ai=null,si=ni=oi=Je=ti=0,$e={data:[]},Ze={words:[]},s&&(i=[...i]);for(let n=0,l=i.length;n<l;n++)ii=i[n],"\n"===ii?(Je&&vi(),Ze.paraEnd=!0,wi(),ci=!0):(ri=je(ii),ri===Ve&&"none"!==r&&(ii=Ge(ii,r,!Je)),ni=a.measureText(ii).width,s&&(s<0&&(oi=ni),ni+=s),hi=ri===Xe&&(ai===Xe||ai===Ve)||ai===Xe&&ri!==qe,li=!(ri!==Ne&&ri!==Xe||ai!==Ke&&ai!==qe),ei=ci&&o?h-o:h,t&&h&&ti+Je+ni>ei&&(e?(Je&&vi(),ti&&wi()):(li||(li=ri===Ve&&ai==qe),hi||li||ri===Qe||ri===Ne||ri===Xe||Je+ni>ei?(Je&&vi(),ti&&wi()):ti&&wi()))," "===ii&&!0!==ci&&ti+Je===0||(ri===Qe?(" "===ii&&Je&&vi(),gi(ii,ni),vi()):hi||li?(Je&&vi(),gi(ii,ni)):gi(ii,ni)),ai=ri);Je&&vi(),ti&&wi(),pi.length>0&&(pi[pi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{di.paraNumber++,ti=a.measureText(t).width,pi.push({x:o||0,text:t,width:ti,paraStart:!0}),fi&&_i()})}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Li(e,"x",t[bi]);break;case"right":Li(e,"x",-t[yi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Li(e,"y",t[mi]);break;case"bottom":Li(e,"y",-t[xi])}}(c,d,n,r,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:v}=n,w=o*s+(d?d*(t.paraNumber-1):0),_=r;if(h&&w>v)w=Math.max(v,o),s>1&&(t.overflow=s);else if(v||u)switch(c){case"middle":p+=(v-w)/2;break;case"bottom":p+=v-w}_+=p;let m,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!h)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&r>0&&(_+=d),m.y=_,_+=o,t.overflow>r&&_>w&&(m.isOverflow=!0,t.overflow=r+1),y=m.x,x=m.width,a<0&&(m.width<0?(x=-m.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<n.x&&(n.x=y),x>n.width&&(n.width=x),h&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d,u;n.forEach(t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==s||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(d,n,r),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,c=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<c));n--){if(h<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.w