leafer-ui 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/dist/web.cjs +77 -47
- package/dist/web.esm.js +78 -48
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +242 -144
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +240 -144
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"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.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(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===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 i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;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()}}else 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})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}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&&void 0!==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.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!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):h.indexOf("AppleWebKit")>-1&&(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:p,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper;class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){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:v,updateAllChange:w}=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&&p(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||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){v(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new _([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){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:60},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,!0),n.clipWorld(s,!0),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),this.target.__render(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);const i=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__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.target=this.canvas=this.config=null)}}b.clipSpread=10;const{hitRadiusPoint:E}=t.BoundsHelper;class L{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);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o),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}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);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||E(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(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&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class B{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new L(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)}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 B(t,e)}),t.Platform.layout=y.fullLayout;const P={convert(t,i){const n=e.InteractionHelper.getBase(t),s=Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,i){const n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=P.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},R={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{pathCanDrag:k}=e.InteractionHelper;class C 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(R.convert(t))}onKeyUp(t){this.keyUp(R.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(P.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(P.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=P.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(P.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(P.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(P.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(P.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=P.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&k(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(P.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=P.getTouch(t);this.pointerMove(P.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=P.getTouch(t);this.pointerUp(P.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(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,i,n=0){if(n++,t instanceof Array)t.forEach((t=>this.eachCursor(t,i,n)));else{const s="string"==typeof t&&e.Cursor.get(t);s&&n<2?this.eachCursor(s,i,n):i.push(t)}}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 S(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":A(t,1,e,i);break;case"inside":O(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?A(t,2,e,i):O(t,"outside",e,i)}}function A(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?I(t,!0,i,n):W(i,n)}function O(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,A(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",T(i,s),s.blendMode="normal",D(n,s,i),s.recycle(i.__nowWorld)}function D(e,i,n){n.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(i,n.__nowWorld):e.copyWorldToInner(i,n.__nowWorld,n.__layout.renderBounds)}function W(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 I(t,e,n,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?W(n,s):s.stroke(),s.restoreBlendMode()):e?W(n,s):s.stroke())}function H(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)M(t,e,i);else switch(n.strokeAlign){case"center":z(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),z(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)z(t,2,e,i);else{const{renderBounds:s}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),z(t,2,e,o),o.clipUI(n),o.clearWorld(s),D(i,o,e),o.recycle(e.__nowWorld)}}(t,e,i)}}function z(t,e,n,s){const o=n.__;s.setStroke(!o.__isStrokes&&t,o.__strokeWidth*e,o),o.__isStrokes?I(t,!1,n,s):s.stroke(),o.__useArrow&&i.Paint.strokeArrow(t,n,s)}const{getSpread:j,getOuterOf:F,getByMove:G,getIntersectData:U}=t.BoundsHelper;let Y;const{stintSet:V}=t.DataHelper,{hasTransparent:X}=i.ColorConvert;function N(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:o}=n.__layout;switch(e.type){case"image":s=i.PaintImage.image(n,t,e,o,!Y||!Y[e.url]);break;case"linear":s=i.PaintGradient.linearGradient(e,o);break;case"radial":s=i.PaintGradient.radialGradient(e,o);break;case"angular":s=i.PaintGradient.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:i.ColorConvert.string(a,h)};break;default:void 0!==e.r&&(s={type:"solid",style:i.ColorConvert.string(e)})}return s&&("string"==typeof s.style&&X(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const q={compute:function(t,e){const n=e.__,s=[];let o,r,a=n.__input[t];a instanceof Array||(a=[a]),Y=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)(i=N(t,a[n],e))&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),r=!0),"fill"===t?(V(n,"__isAlphaPixelFill",o),V(n,"__isTransparentFill",r)):(V(n,"__isAlphaPixelStroke",o),V(n,"__isTransparentStroke",r))},fill:function(t,e,i){i.fillStyle=t,S(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}}n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),S(e,n),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:T,stroke:H,strokes:function(t,e,i){H(t,e,i)},strokeText:M,drawTextStroke:W,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))h=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,d=U(n?j(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=F(s,r),o=G(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let K={};const{get:Q,rotateOfOuter:$,translate:Z,scaleOfOuter:J,scale:tt,rotate:et,skew:it}=t.MatrixHelper;function nt(t,e,i,n,s,o,r){const a=Q();Z(a,e.x+i,e.y+n),tt(a,s,o),r&&$(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function st(t,e,i,n,s,o,r,a){const h=Q();r&&et(h,r),a&&it(h,a.x,a.y),s&&tt(h,s,o),Z(h,e.x+i,e.y+n),t.transform=h}function ot(t,e,i,n,s,o,r,a,h,l){const c=Q();if(h)if("center"===l)$(c,{x:i/2,y:n/2},h);else switch(et(c,h),h){case 90:Z(c,n,0);break;case 180:Z(c,i,n);break;case 270:Z(c,0,i)}K.x=e.x+s,K.y=e.y+o,Z(c,K.x,K.y),r&&J(c,K,r,a),t.transform=c}const{get:rt,translate:at}=t.MatrixHelper,ht=new t.Bounds,lt={},ct={};function dt(t,e,i,n){const{changeful:s,sync:o,editing:r}=i;s&&(t.changeful=s),o&&(t.sync=o),r&&(t.editing=r),t.data=ut(i,n,e)}function ut(e,i,n){e.padding&&(i=ht.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:p,repeat:f,filters:g}=e,_=i.width===s&&i.height===o,v={mode:a},w="center"!==h&&(u||0)%180==90;let m,y;switch(t.BoundsHelper.set(ct,0,0,w?o:s,w?s:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,n,lt),m=lt.scaleX,y=lt.scaleY),h&&(m&&t.BoundsHelper.scale(ct,m,y,!0),t.AlignHelper.toPoint(h,ct,i,ct,!0,!0))):_&&!u||(m=y=t.BoundsHelper.getFitScale(i,ct,"fit"!==a),t.BoundsHelper.put(i,n,h,m,!1,ct),t.BoundsHelper.scale(ct,m,y,!0)),l&&t.PointHelper.move(ct,l),a){case"stretch":_||(s=i.width,o=i.height);break;case"normal":case"clip":(ct.x||ct.y||m||u||p)&&st(v,i,ct.x,ct.y,m,y,u,p);break;case"repeat":(!_||m||u)&&ot(v,i,s,o,ct.x,ct.y,m,y,u,h),f||(v.repeat="repeat");break;default:m&&nt(v,i,ct.x,ct.y,m,y,u)}return v.transform||(i.x||i.y)&&(v.transform=rt(),at(v.transform,i.x,i.y)),m&&"stretch"!==a&&(v.scaleX=m,v.scaleY=y),v.width=s,v.height=o,r&&(v.opacity=r),g&&(v.filters=g),f&&(v.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),v}let pt,ft=new t.Bounds;const{isSame:gt}=t.BoundsHelper;function _t(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||dt(s,n,i,o),!0}function vt(e,i){yt(e,t.ImageEvent.LOAD,i)}function wt(e,i){yt(e,t.ImageEvent.LOADED,i)}function mt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:bt,scale:Et,copy:Lt}=t.MatrixHelper,{ceil:Bt,abs:Pt}=Math;function Rt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+n;if(i.patternId===r||e.destroyed)return!1;{s=Pt(s),o=Pt(o);const{image:e,data:a}=i;let h,l,{width:c,height:d,scaleX:u,scaleY:p,transform:f,repeat:g}=a;u&&(u=Pt(u),p=Pt(p),l=bt(),Lt(l,f),Et(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,c*=s,d*=o;const _=c*d;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let v=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;v>t&&(v=t)}_>v&&(h=Math.sqrt(_/v)),h&&(s/=h,o/=h,c/=h,d/=h),u&&(s/=u,o/=p),(f||1!==s||1!==o)&&(l||(l=bt(),f&&Lt(l,f)),Et(l,1/s,1/o));const w=e.getCanvas(Bt(c)||1,Bt(d)||1,a.opacity,a.filters),m=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function kt(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{abs:Ct}=Math;const Tt={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return pt&&n===pt.paint&>(s,pt.boxBounds)?r=pt.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),pt=h.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(_t(e,i,n,h,r,s),o&&(vt(e,a),wt(e,a))):h.error?o&&mt(e,a,h.error):(o&&(xt(e,!0),vt(e,a)),r.loadId=h.load((()=>{xt(e,!1),e.destroyed||(_t(e,i,n,h,r,s)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),wt(e,a)),r.loadId=void 0}),(t=>{xt(e,!1),mt(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}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{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||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=l;e*=Ct(r)*h,i*=Ct(a)*h,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(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?Rt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>kt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Rt(e,s,h),e.forceUpdate("surface")}))),300)),!1)},createPattern:Rt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){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]||[],a instanceof Array||(a=[a])),o.unload(n[l].loadId,!a.some((t=>t.url===h)))));return r}return null},createData:dt,getPatternData:ut,fillOrFitMode:nt,clipMode:st,repeatMode:ot},{toPoint:St}=t.AroundHelper,{hasTransparent:Mt}=i.ColorConvert,At={},Ot={};function Dt(t,e,n,s){if(n){let o,r,a,h;for(let t=0,l=n.length;t<l;t++)o=n[t],"string"==typeof o?(a=t/(l-1),r=i.ColorConvert.string(o,s)):(a=o.offset,r=i.ColorConvert.string(o.color,s)),e.addColorStop(a,r),!h&&Mt(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Wt,getDistance:It}=t.PointHelper,{get:Ht,rotateOfOuter:zt,scaleOfOuter:jt}=t.MatrixHelper,{toPoint:Ft}=t.AroundHelper,Gt={},Ut={};function Yt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Wt(e,i);o=Ht(),s?(jt(o,e,r/a*(n||1),1),zt(o,e,t+90)):(jt(o,e,1,r/a*(n||1)),zt(o,e,t))}return o}const{getDistance:Vt}=t.PointHelper,{toPoint:Xt}=t.AroundHelper,Nt={},qt={};const Kt={linearGradient:function(e,i){let{from:n,to:s,type:o,opacity:r}=e;St(n||"top",i,At),St(s||"bottom",i,Ot);const a=t.Platform.canvas.createLinearGradient(At.x,At.y,Ot.x,Ot.y),h={type:o,style:a};return Dt(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Ft(n||"center",i,Gt),Ft(s||"bottom",i,Ut);const h=t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,It(Gt,Ut)),l={type:o,style:h};Dt(l,h,e.stops,r);const c=Yt(i,Gt,Ut,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Xt(n||"center",i,Nt),Xt(s||"bottom",i,qt);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Vt(Nt,qt)),l={type:o,style:h};Dt(l,h,e.stops,r);const c=Yt(i,Nt,qt,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Yt},{copy:Qt,toOffsetOutBounds:$t}=t.BoundsHelper,Zt={},Jt={};function te(e,i,n,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Qt(Zt,e.bounds),Zt.x+=i.x-r.x,Zt.y+=i.y-r.y,n){const{matrix:t}=s;Zt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Zt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Zt.width*=n,Zt.height*=n}e.copyWorld(s.canvas,e.bounds,Zt)}else n&&(Qt(Zt,i),Zt.x-=i.width/2*(n-1),Zt.y-=i.height/2*(n-1),Zt.width*=n,Zt.height*=n),e.copyWorld(s.canvas,r,n?Zt:i)}const{toOffsetOutBounds:ee}=t.BoundsHelper,ie={};const ne={shadow:function(t,e,n){let s,o;const{__nowWorld:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:u,scaleY:p}=n,f=e.getSameCanvas(),g=h.length-1;$t(c,Jt),h.forEach(((h,_)=>{f.setWorldShadow(Jt.offsetX+h.x*u,Jt.offsetY+h.y*p,h.blur*u,i.ColorConvert.string(h.color)),o=h.spread?1+2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,te(f,Jt,o,n),s=c,h.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,c,r,"copy"),s=r),l?f.copyWorld(l,r,r,"destination-out"):f.copyWorld(n.canvas,d,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,r,h.blendMode):e.copyWorldToInner(f,s,a.renderBounds,h.blendMode),g&&_<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:u,scaleY:p}=n,f=e.getSameCanvas(),g=h.length-1;ee(c,ie),h.forEach(((h,_)=>{f.save(),f.setWorldShadow(ie.offsetX+h.x*u,ie.offsetY+h.y*p,h.blur*u),o=h.spread?1-2*h.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,te(f,ie,o,n),f.restore(),l?(f.copyWorld(f,c,r,"copy"),f.copyWorld(l,r,r,"source-out"),s=r):(f.copyWorld(n.canvas,d,c,"source-out"),s=c),f.fillWorld(s,i.ColorConvert.string(h.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,r,h.blendMode):e.copyWorldToInner(f,s,a.renderBounds,h.blendMode),g&&_<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:se}=t.LeafBoundsHelper;function oe(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ae(t,i,n,o);break;case"path":i.restore()}}function re(t){return t.getSameCanvas(!1,!0)}function ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}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++)i=h[l],a=i.__.mask,a&&(r&&(oe(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=re(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=re(t)),s||(s=re(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||se(i,e)||i.__render(s||t,e);oe(this,r,t,s,n,o)};const he=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",le=he+"_#~&*+\\=|≮≯≈≠=…",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"),pe=de("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fe=de(he),ge=de(le),_e=de("- —/~|┆·");var ve;!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"}(ve||(ve={}));const{Letter:we,Single:me,Before:ye,After:xe,Symbol:be,Break:Ee}=ve;function Le(t){return ue[t]?we:_e[t]?Ee:pe[t]?ye:fe[t]?xe:ge[t]?be:ce.test(t)?me:we}const Be={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 Pe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Re}=Be,{Letter:ke,Single:Ce,Before:Te,After:Se,Symbol:Me,Break:Ae}=ve;let Oe,De,We,Ie,He,ze,je,Fe,Ge,Ue,Ye,Ve,Xe,Ne,qe,Ke,Qe,$e=[];function Ze(t,e){Ge&&!Fe&&(Fe=Ge),Oe.data.push({char:t,width:e}),We+=e}function Je(){Ie+=We,Oe.width=We,De.words.push(Oe),Oe={data:[]},We=0}function ti(){Ne&&(qe.paraNumber++,De.paraStart=!0,Ne=!1),Ge&&(De.startCharSize=Fe,De.endCharSize=Ge,Fe=0),De.width=Ie,Ke.width?Re(De):Qe&&ei(),$e.push(De),De={words:[]},Ie=0}function ei(){Ie>(qe.maxWidth||0)&&(qe.maxWidth=Ie)}const{top:ii,right:ni,bottom:si,left:oi}=t.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 ai={getDrawData:function(e,n){"string"!=typeof 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[oi],r-=c[ni]+c[oi]):n.autoSizeAlign||(s=c[oi]),a?(o=c[ii],a-=c[ii]+c[si]):n.autoSizeAlign||(o=c[ii]));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){qe=e,$e=e.rows,Ke=e.bounds,Qe=!Ke.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=Ke;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ne=!0,Ye=null,Fe=je=Ge=We=Ie=0,Oe={data:[]},De={words:[]},s&&(i=[...i]);for(let n=0,l=i.length;n<l;n++)ze=i[n],"\n"===ze?(We&&Je(),De.paraEnd=!0,ti(),Ne=!0):(Ue=Le(ze),Ue===ke&&"none"!==r&&(ze=Pe(ze,r,!We)),je=a.measureText(ze).width,s&&(s<0&&(Ge=je),je+=s),Ve=Ue===Ce&&(Ye===Ce||Ye===ke)||Ye===Ce&&Ue!==Se,Xe=!(Ue!==Te&&Ue!==Ce||Ye!==Me&&Ye!==Se),He=Ne&&o?h-o:h,t&&h&&Ie+We+je>He&&(e?(We&&Je(),Ie&&ti()):(Xe||(Xe=Ue===ke&&Ye==Se),Ve||Xe||Ue===Ae||Ue===Te||Ue===Ce||We+je>He?(We&&Je(),Ie&&ti()):Ie&&ti()))," "===ze&&!0!==Ne&&Ie+We===0||(Ue===Ae?(" "===ze&&We&&Je(),Ze(ze,je),Je()):Ve||Xe?(We&&Je(),Ze(ze,je)):Ze(ze,je)),Ye=Ue);We&&Je(),Ie&&ti(),$e.length>0&&($e[$e.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{qe.paraNumber++,Ie=a.measureText(t).width,$e.push({x:o||0,text:t,width:Ie,paraStart:!0}),Qe&&ei()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ri(e,"x",t[oi]);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])}}(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:p,y:f,width:g,height:_}=n,v=o*s+(d?d*(t.paraNumber-1):0),w=r;if(h&&v>_)v=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":f+=(_-v)/2;break;case"bottom":f+=_-v}w+=f;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=p,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&&(w+=d),m.y=w,w+=o,t.overflow>r&&w>v&&(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=f,n.height=v}(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.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,n,s,r),"none"!==h&&function(t,e){let n;const{fontSize:s,textDecoration:o}=e;switch(t.decorationHeight=s/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,n),d}};const hi={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,ai),Object.assign(i.ColorConvert,hi),Object.assign(i.Paint,q),Object.assign(i.PaintImage,Tt),Object.assign(i.PaintGradient,Kt),Object.assign(i.Effect,ne),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=C,exports.Layouter=y,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=B,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");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.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(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===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 i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;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()}}else 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})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}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&&void 0!==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.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!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):h.indexOf("AppleWebKit")>-1&&(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,e instanceof Array&&(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:_,updateAllChange:w}=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){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(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:60},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,!0),n.clipWorld(s,!0),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),this.target.__render(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);const i=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__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.target=this.canvas=this.config=null)}}b.clipSpread=10;const{hitRadiusPoint:E}=t.BoundsHelper;class L{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);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o),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}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);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||E(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(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&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class B{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new L(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)}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 B(t,e)}),t.Platform.layout=y.fullLayout;const P={convert(t,i){const n=e.InteractionHelper.getBase(t),s=Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,i){const n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=P.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},k={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 C 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(k.convert(t))}onKeyUp(t){this.keyUp(k.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(P.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(P.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=P.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(P.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(P.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(P.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(P.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=P.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(P.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=P.getTouch(t);this.pointerMove(P.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=P.getTouch(t);this.pointerUp(P.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(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,i,n=0){if(n++,t instanceof Array)t.forEach((t=>this.eachCursor(t,i,n)));else{const s="string"==typeof t&&e.Cursor.get(t);s&&n<2?this.eachCursor(s,i,n):i.push(t)}}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 S(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":A(t,1,e,i);break;case"inside":D(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?A(t,2,e,i):D(t,"outside",e,i)}}function A(t,e,i,n){const s=i.__;"object"==typeof t?W(t,e,!0,i,n):(n.setStroke(t,s.__strokeWidth*e,s),O(i,n))}function D(e,i,n,s){const o=s.getSameCanvas(!0,!0);o.font=n.__.__font,A(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 O(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?O(s,o):o.stroke(),o.restoreBlendMode()):n?O(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(t,e,n,s){const o=n.__;"object"==typeof t?W(t,e,!1,n,s):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&i.Paint.strokeArrow(t,n,s)}const{getSpread:z,getOuterOf:j,getByMove:F,getIntersectData:G}=t.BoundsHelper;let U;const{stintSet:Y}=t.DataHelper,{hasTransparent:V}=i.ColorConvert;function X(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:o}=n.__layout;switch(e.type){case"image":s=i.PaintImage.image(n,t,e,o,!U||!U[e.url]);break;case"linear":s=i.PaintGradient.linearGradient(e,o);break;case"radial":s=i.PaintGradient.radialGradient(e,o);break;case"angular":s=i.PaintGradient.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:i.ColorConvert.string(a,h)};break;default:void 0!==e.r&&(s={type:"solid",style:i.ColorConvert.string(e)})}if(s){if("string"==typeof s.style&&V(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.blendMode&&(s.blendMode=e.blendMode)}return s}const N={compute:function(t,e){const n=e.__,s=[];let o,r,a,h=n.__input[t];h instanceof Array||(h=[h]),U=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=h.length;n<o;n++)(i=X(t,h[n],e))&&(s.push(i),i.strokeStyle&&(a||(a=1),i.strokeStyle.strokeWidth&&(a=Math.max(a,i.strokeStyle.strokeWidth))));n["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),r=!0),"fill"===t?(Y(n,"__isAlphaPixelFill",o),Y(n,"__isTransparentFill",r)):(Y(n,"__isAlphaPixelStroke",o),Y(n,"__isTransparentStroke",r),Y(n,"__hasMultiStrokeStyle",a))},fill:function(t,e,i){i.fillStyle=t,S(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);n.scale(1/t,1/i)}s.blendMode&&(n.blendMode=s.blendMode),S(e,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:T,stroke:I,strokes:function(t,e,i){I(t,e,i)},strokeText:M,drawTextStroke:O,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))h=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,d=G(n?z(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(d);let{a:u,d:f}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=f),a=j(s,r),o=F(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let q={},K=t.getMatrixData();const{get:Q,rotateOfOuter:$,translate:Z,scaleOfOuter:J,multiplyParent:tt,scale:et,rotate:it,skew:nt}=t.MatrixHelper;function st(t,e,i,n,s,o,r){const a=Q();Z(a,e.x+i,e.y+n),et(a,s,o),r&&$(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function ot(t,e,i,n,s,o,r,a,h){const l=Q();r&&it(l,r),a&&nt(l,a.x,a.y),s&&et(l,s,o),Z(l,e.x+i,e.y+n),h&&(K.a=e.width/h.width,K.d=e.height/h.height,tt(l,K)),t.transform=l}function rt(t,e,i,n,s,o,r,a,h,l){const c=Q();if(h)if("center"===l)$(c,{x:i/2,y:n/2},h);else switch(it(c,h),h){case 90:Z(c,n,0);break;case 180:Z(c,i,n);break;case 270:Z(c,0,i)}q.x=e.x+s,q.y=e.y+o,Z(c,q.x,q.y),r&&J(c,q,r,a),t.transform=c}const{get:at,translate:ht}=t.MatrixHelper,lt=new t.Bounds,ct={},dt={};function ut(t,e,i,n){const{changeful:s,sync:o,editing:r,scaleFixed:a}=i;s&&(t.changeful=s),o&&(t.sync=o),r&&(t.editing=r),a&&(t.scaleFixed=a),t.data=ft(i,n,e)}function ft(e,i,n){e.padding&&(i=lt.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,filters:v}=e,_=i.width===s&&i.height===o,w={mode:a},m="center"!==h&&(u||0)%180==90;let y,x;switch(t.BoundsHelper.set(dt,0,0,m?o:s,m?s:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(t.MathHelper.getScaleData(c,d,n,ct),y=ct.scaleX,x=ct.scaleY),h&&(y&&t.BoundsHelper.scale(dt,y,x,!0),t.AlignHelper.toPoint(h,dt,i,dt,!0,!0))):_&&!u||(y=x=t.BoundsHelper.getFitScale(i,dt,"fit"!==a),t.BoundsHelper.put(i,n,h,y,!1,dt),t.BoundsHelper.scale(dt,y,x,!0)),l&&t.PointHelper.move(dt,l),a){case"stretch":_||(s=i.width,o=i.height);break;case"normal":case"clip":(dt.x||dt.y||y||p||u||f)&&ot(w,i,dt.x,dt.y,y,x,u,f,e.clipSize);break;case"repeat":(!_||y||u)&&rt(w,i,s,o,dt.x,dt.y,y,x,u,h),g||(w.repeat="repeat");break;default:y&&st(w,i,dt.x,dt.y,y,x,u)}return w.transform||(i.x||i.y)&&(w.transform=at(),ht(w.transform,i.x,i.y)),y&&"stretch"!==a&&(w.scaleX=y,w.scaleY=x),w.width=s,w.height=o,r&&(w.opacity=r),v&&(w.filters=v),g&&(w.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat"),w}let pt,gt=new t.Bounds;const{isSame:vt}=t.BoundsHelper;function _t(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||ut(s,n,i,o),!0}function wt(e,i){xt(e,t.ImageEvent.LOAD,i)}function mt(e,i){xt(e,t.ImageEvent.LOADED,i)}function yt(e,i,n){i.error=n,e.forceUpdate("surface"),xt(e,t.ImageEvent.ERROR,i)}function xt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function bt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Et,scale:Lt,copy:Bt}=t.MatrixHelper,{ceil:Pt,abs:kt}=Math;function Rt(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:e,data:a}=i;let h,l,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g}=a;u&&(u=kt(u),f=kt(f),l=Et(),Bt(l,p),Lt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,d*=o;const v=c*d;if(!g&&v>t.Platform.image.maxCacheSize)return!1;let _=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;_>t&&(_=t)}v>_&&(h=Math.sqrt(v/_)),h&&(s/=h,o/=h,c/=h,d/=h),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Et(),p&&Bt(l,p)),Lt(l,1/s,1/o));const w=e.getCanvas(Pt(c)||1,Pt(d)||1,a.opacity,a.filters),m=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function Ct(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 Tt={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return pt&&n===pt.paint&&vt(s,pt.boxBounds)?r=pt.leafPaint:(r={type:n.type,image:h},h.hasAlphaPixel&&(r.isTransparent=!0),pt=h.use>1?{leafPaint:r,paint:n,boxBounds:gt.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(_t(e,i,n,h,r,s),o&&(wt(e,a),mt(e,a))):h.error?o&&yt(e,a,h.error):(o&&(bt(e,!0),wt(e,a)),r.loadId=h.load((()=>{bt(e,!1),e.destroyed||(_t(e,i,n,h,r,s)&&(h.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),mt(e,a)),r.loadId=void 0}),(t=>{bt(e,!1),yt(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||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?Rt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>Ct(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Rt(e,s,h),e.forceUpdate("surface")}))),300)),!1)},createPattern:Rt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){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]||[],a instanceof Array||(a=[a])),o.unload(n[l].loadId,!a.some((t=>t.url===h)))));return r}return null},createData:ut,getPatternData:ft,fillOrFitMode:st,clipMode:ot,repeatMode:rt},{toPoint:St}=t.AroundHelper,{hasTransparent:Mt}=i.ColorConvert,At={},Dt={};function Ot(t,e,n,s){if(n){let o,r,a,h;for(let t=0,l=n.length;t<l;t++)o=n[t],"string"==typeof o?(a=t/(l-1),r=i.ColorConvert.string(o,s)):(a=o.offset,r=i.ColorConvert.string(o.color,s)),e.addColorStop(a,r),!h&&Mt(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Wt,getDistance:It}=t.PointHelper,{get:Ht,rotateOfOuter:zt,scaleOfOuter:jt}=t.MatrixHelper,{toPoint:Ft}=t.AroundHelper,Gt={},Ut={};function Yt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Wt(e,i);o=Ht(),s?(jt(o,e,r/a*(n||1),1),zt(o,e,t+90)):(jt(o,e,1,r/a*(n||1)),zt(o,e,t))}return o}const{getDistance:Vt}=t.PointHelper,{toPoint:Xt}=t.AroundHelper,Nt={},qt={};const Kt={linearGradient:function(e,i){let{from:n,to:s,type:o,opacity:r}=e;St(n||"top",i,At),St(s||"bottom",i,Dt);const a=t.Platform.canvas.createLinearGradient(At.x,At.y,Dt.x,Dt.y),h={type:o,style:a};return Ot(h,a,e.stops,r),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Ft(n||"center",i,Gt),Ft(s||"bottom",i,Ut);const h=t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,It(Gt,Ut)),l={type:o,style:h};Ot(l,h,e.stops,r);const c=Yt(i,Gt,Ut,a,!0);return c&&(l.transform=c),l},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,stretch:a}=e;Xt(n||"center",i,Nt),Xt(s||"bottom",i,qt);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Vt(Nt,qt)),l={type:o,style:h};Ot(l,h,e.stops,r);const c=Yt(i,Nt,qt,a||1,t.Platform.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:Yt},{copy:Qt,toOffsetOutBounds:$t}=t.BoundsHelper,Zt={},Jt={};function te(e,i,n,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Qt(Zt,e.bounds),Zt.x+=i.x-r.x,Zt.y+=i.y-r.y,n){const{matrix:t}=s;Zt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Zt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Zt.width*=n,Zt.height*=n}e.copyWorld(s.canvas,e.bounds,Zt)}else n&&(Qt(Zt,i),Zt.x-=i.width/2*(n-1),Zt.y-=i.height/2*(n-1),Zt.width*=n,Zt.height*=n),e.copyWorld(s.canvas,r,n?Zt:i)}const{toOffsetOutBounds:ee}=t.BoundsHelper,ie={};const ne={shadow:function(e,n,s){let o,r;const{__nowWorld:a,__layout:h}=e,{shadow:l}=e.__,{worldCanvas:c,bounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),v=l.length-1;$t(d,Jt),l.forEach(((l,_)=>{g.setWorldShadow(Jt.offsetX+l.x*f,Jt.offsetY+l.y*p,l.blur*f,i.ColorConvert.string(l.color)),r=l.spread?1+2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0)):0,te(g,Jt,r,s),o=d,l.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,d,a,"copy"),o=a),c?g.copyWorld(c,a,a,"destination-out"):g.copyWorld(s.canvas,u,d,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,n,g,o,l.blendMode),v&&_<v&&g.clearWorld(o,!0)})),g.recycle(o)},innerShadow:function(e,n,s){let o,r;const{__nowWorld:a,__layout:h}=e,{innerShadow:l}=e.__,{worldCanvas:c,bounds:d,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),v=l.length-1;ee(d,ie),l.forEach(((l,_)=>{g.save(),g.setWorldShadow(ie.offsetX+l.x*f,ie.offsetY+l.y*p,l.blur*f),r=l.spread?1-2*l.spread/(h.boxBounds.width+2*(h.strokeBoxSpread||0)):0,te(g,ie,r,s),g.restore(),c?(g.copyWorld(g,d,a,"copy"),g.copyWorld(c,a,a,"source-out"),o=a):(g.copyWorld(s.canvas,u,d,"source-out"),o=d),g.fillWorld(o,i.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,n,g,o,l.blendMode),v&&_<v&&g.clearWorld(o,!0)})),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){}},{excludeRenderBounds:se}=t.LeafBoundsHelper;function oe(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ae(t,i,n,o);break;case"path":i.restore()}}function re(t){return t.getSameCanvas(!1,!0)}function ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}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++)i=h[l],a=i.__.mask,a?(r&&(oe(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=re(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=re(t)),s||(s=re(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a||se(i,e)||i.__render(t,e)):se(i,e)||i.__render(s||t,e);oe(this,r,t,s,n,o)};const he=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",le=he+"_#~&*+\\=|≮≯≈≠=…",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("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pe=de(he),ge=de(le),ve=de("- —/~|┆·");var _e;!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"}(_e||(_e={}));const{Letter:we,Single:me,Before:ye,After:xe,Symbol:be,Break:Ee}=_e;function Le(t){return ue[t]?we:ve[t]?Ee:fe[t]?ye:pe[t]?xe:ge[t]?be:ce.test(t)?me:we}const Be={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 Pe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ke}=Be,{Letter:Re,Single:Ce,Before:Te,After:Se,Symbol:Me,Break:Ae}=_e;let De,Oe,We,Ie,He,ze,je,Fe,Ge,Ue,Ye,Ve,Xe,Ne,qe,Ke,Qe,$e=[];function Ze(t,e){Ge&&!Fe&&(Fe=Ge),De.data.push({char:t,width:e}),We+=e}function Je(){Ie+=We,De.width=We,Oe.words.push(De),De={data:[]},We=0}function ti(){Ne&&(qe.paraNumber++,Oe.paraStart=!0,Ne=!1),Ge&&(Oe.startCharSize=Fe,Oe.endCharSize=Ge,Fe=0),Oe.width=Ie,Ke.width?ke(Oe):Qe&&ei(),$e.push(Oe),Oe={words:[]},Ie=0}function ei(){Ie>(qe.maxWidth||0)&&(qe.maxWidth=Ie)}const{top:ii,right:ni,bottom:si,left:oi}=t.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 ai={getDrawData:function(e,n){"string"!=typeof 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[oi],r-=c[ni]+c[oi]):n.autoSizeAlign||(s=c[oi]),a?(o=c[ii],a-=c[ii]+c[si]):n.autoSizeAlign||(o=c[ii]));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){qe=e,$e=e.rows,Ke=e.bounds,Qe=!Ke.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=Ke;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ne=!0,Ye=null,Fe=je=Ge=We=Ie=0,De={data:[]},Oe={words:[]},s&&(i=[...i]);for(let n=0,l=i.length;n<l;n++)ze=i[n],"\n"===ze?(We&&Je(),Oe.paraEnd=!0,ti(),Ne=!0):(Ue=Le(ze),Ue===Re&&"none"!==r&&(ze=Pe(ze,r,!We)),je=a.measureText(ze).width,s&&(s<0&&(Ge=je),je+=s),Ve=Ue===Ce&&(Ye===Ce||Ye===Re)||Ye===Ce&&Ue!==Se,Xe=!(Ue!==Te&&Ue!==Ce||Ye!==Me&&Ye!==Se),He=Ne&&o?h-o:h,t&&h&&Ie+We+je>He&&(e?(We&&Je(),Ie&&ti()):(Xe||(Xe=Ue===Re&&Ye==Se),Ve||Xe||Ue===Ae||Ue===Te||Ue===Ce||We+je>He?(We&&Je(),Ie&&ti()):Ie&&ti()))," "===ze&&!0!==Ne&&Ie+We===0||(Ue===Ae?(" "===ze&&We&&Je(),Ze(ze,je),Je()):Ve||Xe?(We&&Je(),Ze(ze,je)):Ze(ze,je)),Ye=Ue);We&&Je(),Ie&&ti(),$e.length>0&&($e[$e.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{qe.paraNumber++,Ie=a.measureText(t).width,$e.push({x:o||0,text:t,width:Ie,paraStart:!0}),Qe&&ei()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ri(e,"x",t[oi]);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])}}(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,_=o*s+(d?d*(t.paraNumber-1):0),w=r;if(h&&_>v)_=Math.max(v,o),s>1&&(t.overflow=s);else if(v||u)switch(c){case"middle":p+=(v-_)/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&&(w+=d),m.y=w,w+=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=_}(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.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,n,s,r),"none"!==h&&function(t,e){let n;const{fontSize:s,textDecoration:o}=e;switch(t.decorationHeight=s/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,n),d}};const hi={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,ai),Object.assign(i.ColorConvert,hi),Object.assign(i.Paint,N),Object.assign(i.PaintImage,Tt),Object.assign(i.PaintGradient,Kt),Object.assign(i.Effect,ne),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=C,exports.Layouter=y,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=B,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
2
2
|
//# sourceMappingURL=web.min.cjs.map
|