leafer-draw 1.9.4 → 1.9.5

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/dist/web.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n 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(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),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,n){if(this.resizeListener=n,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),i.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:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.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:s,fileType:a}=t.FileHelper;function r(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=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,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:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),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 n(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:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.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:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||c(n[t])}c(i)}})}(this.__levelList),function(t){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{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,v.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,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);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||v.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)}}function b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":L(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):L(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?S(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),k(n,s))}function L(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function k(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function S(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?k(s,a):a.stroke(),a.restoreBlendMode()):n?k(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?S(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:A,getOuterOf:O,getByMove:D,getIntersectData:T}=t.BoundsHelper;let W;const{stintSet:M}=t.DataHelper,{hasTransparent:I}=e.ColorConvert;function z(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!W||!W[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&I(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const H={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),W=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=z(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(M(s,"__isAlphaPixelFill",r),M(s,"__isTransparentFill",o)):(M(s,"__isAlphaPixelStroke",r),M(s,"__isTransparentStroke",o),M(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.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:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:k,shape:function(e,i,n){const s=i.getSameCanvas(),a=e.__nowWorld,r=i.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(a))h=s,o=c=a;else{const{renderShapeSpread:s}=e.__layout;let p;if(t.Platform.fullImageShadow)p=a;else{const t=s?A(r,u===f?s*u:[s*f,s*u]):r;p=T(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),e.__renderShape(h,n),u*=g,f*=_),c=O(a,d),o=D(c,-d.e,-d.f);const m=n.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),n=Object.assign(Object.assign({},n),{matrix:l})}return e.__renderShape(s,n),{canvas:s,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let F={},j=t.getMatrixData();const{get:U,rotateOfOuter:G,translate:V,scaleOfOuter:Y,multiplyParent:N,scale:X,rotate:q,skew:Q}=t.MatrixHelper;function Z(t,e,i,n,s,a,r){const o=U();V(o,e.x+i,e.y+n),X(o,s,a),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function $(t,e,i,n,s,a,r,o,l){const d=U();J(d,e,i,n,s,a,r,o),l&&(j.a=e.width/l.width,j.d=e.height/l.height,N(d,j)),t.transform=d}function K(t,e,i,n,s,a,r,o,l,d,c,h){const u=U();if(h)J(u,e,s,a,r,o,l,d);else{if(l)if("center"===c)G(u,{x:i/2,y:n/2},l);else switch(q(u,l),l){case 90:V(u,n,0);break;case 180:V(u,i,n);break;case 270:V(u,0,i)}F.x=e.x+s,F.y=e.y+a,V(u,F.x,F.y),r&&Y(u,F,r,o)}t.transform=u}function J(t,e,i,n,s,a,r,o){r&&q(t,r),o&&Q(t,o.x,o.y),s&&X(t,s,a),V(t,e.x+i,e.y+n)}const{get:tt,translate:et}=t.MatrixHelper,it=new t.Bounds,nt={},st={};function at(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=rt(i,n,e)}function rt(e,i,n){e.padding&&(i=it.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(st,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,n,nt),x=nt.scaleX,b=nt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(st,x,b,!0),l&&t.AlignHelper.toPoint(l,st,i,st,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,st,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,st),t.BoundsHelper.scale(st,x,b,!0)),d&&t.PointHelper.move(st,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":(st.x||st.y||x||p||u||f)&&$(y,i,st.x,st.y,x,b,u,f,e.clipSize);break;case"repeat":(!w||x||u||f)&&K(y,i,s,a,st.x,st.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ot(r,n,a.width,i&&i.x),y:ot(o,s,a.height,i&&i.y)}}(_,n&&g,st.width,st.height,i));break;default:x&&Z(y,i,st.x,st.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=tt(),et(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ot(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let lt,dt=new t.Bounds;const{isSame:ct}=t.BoundsHelper;function ht(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||at(s,n,i,a),!0}function ut(e,i){gt(e,t.ImageEvent.LOAD,i)}function ft(e,i){gt(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,i)}function gt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function _t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:wt,copy:yt}=t.MatrixHelper,{floor:vt,max:xt,abs:bt}=Math;function Et(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:e,data:o}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=o;s*=n,a*=n;const m=_&&_.x*s,w=_&&_.y*a;u&&(u=bt(u),f=bt(f),d=mt(),yt(d,p),wt(d,1/u,1/f),s*=u,a*=f),c*=s,h*=a;const y=c*h;if(!g&&y>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)}if(y>v&&(l=Math.sqrt(y/v)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=mt(),p&&yt(d,p)),wt(d,1/s,1/a)),d){const t=c+(m||0),e=h+(w||0);wt(d,t/xt(vt(t),1),e/xt(vt(e),1))}const x=e.getCanvas(c,h,o.opacity,o.filters,m,w),b=e.getPattern(x,g||t.Platform.origin.noRepeat||"no-repeat",d,i);return i.style=b,i.patternId=r,!0}}function Bt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Rt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return lt&&n===lt.paint&&ct(s,lt.boxBounds)?r=lt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),lt=l.use>1?{leafPaint:r,paint:n,boxBounds:dt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(ht(e,i,n,l,r,s),a&&(ut(e,o),ft(e,o))):l.error?a&&pt(e,o,l.error):(a&&(_t(e,!0),ut(e,o)),r.loadId=l.load(()=>{_t(e,!1),e.destroyed||(ht(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,o)),r.loadId=void 0},t=>{_t(e,!1),pt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__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()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?Et(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Bt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&Et(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:Et,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,c=n.length;d<c;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:rt,fillOrFitMode:Z,clipMode:$,repeatMode:K},{toPoint:Lt}=t.AroundHelper,{hasTransparent:kt}=e.ColorConvert,St={},Pt={};function Ct(i,n,s,a){if(s){let r,o,l,d;for(let i=0,c=s.length;i<c;i++)r=s[i],t.isString(r)?(l=i/(c-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&kt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:At,getDistance:Ot}=t.PointHelper,{get:Dt,rotateOfOuter:Tt,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:Mt}=t.AroundHelper,It={},zt={};function Ht(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=At(e,i);a=Dt(),s?(Wt(a,e,r/o*(n||1),1),Tt(a,e,t+90)):(Wt(a,e,1,r/o*(n||1)),Tt(a,e,t))}return a}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Ut={},Gt={};const Vt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;Lt(n||"top",i,St),Lt(s||"bottom",i,Pt);const o=t.Platform.canvas.createLinearGradient(St.x,St.y,Pt.x,Pt.y),l={type:a,style:o};return Ct(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;Mt(n||"center",i,It),Mt(s||"bottom",i,zt);const l=t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Ot(It,zt)),d={type:a,style:l};Ct(d,l,e.stops,r);const c=Ht(i,It,zt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;jt(n||"center",i,Ut),jt(s||"bottom",i,Gt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ut.x,Ut.y):t.Platform.canvas.createRadialGradient(Ut.x,Ut.y,0,Ut.x,Ut.y,Ft(Ut,Gt)),d={type:a,style:l};Ct(d,l,e.stops,r);const c=Ht(i,Ut,Gt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ht},{copy:Yt,toOffsetOutBounds:Nt}=t.BoundsHelper,Xt={},qt={};function Qt(e,i,n,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Yt(Xt,e.bounds),Xt.x+=i.x-r.x,Xt.y+=i.y-r.y,n){const{fitMatrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Yt(Xt,i),Xt.x-=i.width/2*(n-1),Xt.y-=i.height/2*(n-1),Xt.width*=n,Xt.height*=n),e.copyWorld(s.canvas,r,n?Xt:i)}const{toOffsetOutBounds:Zt}=t.BoundsHelper,$t={};const Kt={shadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{shadow:d}=i.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;Nt(h,qt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(qt.offsetX+d.x*f*w,qt.offsetY+d.y*p*w,d.blur*f*w,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Qt(g,qt,r,s),a=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),a=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(s.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{innerShadow:d}=i.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;Zt(h,$t),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow($t.offsetX+d.x*f*w,$t.offsetY+d.y*p*w,d.blur*f*w),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Qt(g,$t,r,s),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,h,"source-out"),a=h),g.fillWorld(a,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Jt}=t.LeafBoundsHelper;let te;function ee(t,e,i,n,s,a,r,o){switch(e){case"grayscale":te||(te=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);ne(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":ne(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ie(t){return t.getSameCanvas(!1,!0)}function ne(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(ee(this,r,t,s,n,a,void 0,!0),n=s=null),a=i.__.opacity,te=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ie(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ie(t)),s||(s=ie(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||Jt(i,e)||i.__render(t,e);continue}const c=1===a&&i.__.__blendMode;c&&ee(this,r,t,s,n,a,void 0,!1),Jt(i,e)||i.__render(s||t,e),c&&ee(this,r,t,s,n,a,c,!1)}ee(this,r,t,s,n,a,void 0,!0)};const se=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ae=se+"_#~&*+\\=|≮≯≈≠=…",re=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 oe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const le=oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),de=oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ce=oe(se),he=oe(ae),ue=oe("- —/~|┆·");var fe;!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"}(fe||(fe={}));const{Letter:pe,Single:ge,Before:_e,After:me,Symbol:we,Break:ye}=fe;function ve(t){return le[t]?pe:ue[t]?ye:de[t]?_e:ce[t]?me:he[t]?we:re.test(t)?ge:pe}const xe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function be(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ee}=xe,{Letter:Be,Single:Re,Before:Le,After:ke,Symbol:Se,Break:Pe}=fe;let Ce,Ae,Oe,De,Te,We,Me,Ie,ze,He,Fe,je,Ue,Ge,Ve,Ye,Ne,Xe=[];function qe(t,e){ze&&!Ie&&(Ie=ze),Ce.data.push({char:t,width:e}),Oe+=e}function Qe(){De+=Oe,Ce.width=Oe,Ae.words.push(Ce),Ce={data:[]},Oe=0}function Ze(){Ge&&(Ve.paraNumber++,Ae.paraStart=!0,Ge=!1),ze&&(Ae.startCharSize=Ie,Ae.endCharSize=ze,Ie=0),Ae.width=De,Ye.width?Ee(Ae):Ne&&$e(),Xe.push(Ae),Ae={words:[]},De=0}function $e(){De>(Ve.maxWidth||0)&&(Ve.maxWidth=De)}const{top:Ke,right:Je,bottom:ti,left:ei}=t.Direction4;function ii(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 ni={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(r?(s=c[ei],r-=c[Je]+c[ei]):n.autoSizeAlign||(s=c[ei]),o?(a=c[Ke],o-=c[Ke]+c[ti]):n.autoSizeAlign||(a=c[Ke]));const h={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ve=e,Xe=e.rows,Ye=e.bounds,Ne=!Ye.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=Ye;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ge=!0,Fe=null,Ie=Me=ze=Oe=De=0,Ce={data:[]},Ae={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)We=i[n],"\n"===We?(Oe&&Qe(),Ae.paraEnd=!0,Ze(),Ge=!0):(He=ve(We),He===Be&&"none"!==r&&(We=be(We,r,!Oe)),Me=o.measureText(We).width,s&&(s<0&&(ze=Me),Me+=s),je=He===Re&&(Fe===Re||Fe===Be)||Fe===Re&&He!==ke,Ue=!(He!==Le&&He!==Re||Fe!==Se&&Fe!==ke),Te=Ge&&a?l-a:l,t&&l&&De+Oe+Me>Te&&(e?(Oe&&Qe(),De&&Ze()):(Ue||(Ue=He===Be&&Fe==ke),je||Ue||He===Pe||He===Le||He===Re||Oe+Me>Te?(Oe&&Qe(),De&&Ze()):De&&Ze()))," "===We&&!0!==Ge&&De+Oe===0||(He===Pe?(" "===We&&Oe&&Qe(),qe(We,Me),Qe()):je||Ue?(Oe&&Qe(),qe(We,Me)):qe(We,Me)),Fe=He);Oe&&Qe(),De&&Ze(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ve.paraNumber++,De=o.measureText(t).width,Xe.push({x:a||0,text:t,width:De,paraStart:!0}),Ne&&$e()})}(h,i,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ii(e,"x",t[ei]);break;case"right":ii(e,"x",-t[Je])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ii(e,"y",t[Ke]);break;case"bottom":ii(e,"y",-t[ti])}}(c,h,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=s;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(h,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,n,r),h.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(h,n,s,r),"none"!==l&&function(i,n){let s;const{fontSize:a,textDecoration:r}=n;switch(i.decorationHeight=a/11,t.isObject(r)?(s=r.type,r.color&&(i.decorationColor=e.ColorConvert.string(r.color))):s=r,s){case"under":i.decorationY=[.15*a];break;case"delete":i.decorationY=[.35*-a];break;case"under-delete":i.decorationY=[.15*a,.35*-a]}}(h,n),h}};const si={string:function(i,n){const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,ni),Object.assign(e.ColorConvert,si),Object.assign(e.Paint,H),Object.assign(e.PaintImage,Rt),Object.assign(e.PaintGradient,Vt),Object.assign(e.Effect,Kt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n 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(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(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=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,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:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),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 n(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:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.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:d,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.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,v.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,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),n=()=>{const e=1e3/(Date.now()-i),{maxFPS:s}=this.config;if(s&&e>s-.5)return t.Platform.requestRender(n);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(n)}__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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":L(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):L(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?k(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),S(n,s))}function L(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function S(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function k(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?S(s,a):a.stroke(),a.restoreBlendMode()):n?S(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?k(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:A,getOuterOf:O,getByMove:D,getIntersectData:W}=t.BoundsHelper;let T;const{stintSet:M}=t.DataHelper,{hasTransparent:I}=e.ColorConvert;function z(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!T||!T[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&I(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const H={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=z(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(M(s,"__isAlphaPixelFill",r),M(s,"__isTransparentFill",o)):(M(s,"__isAlphaPixelStroke",r),M(s,"__isTransparentStroke",o),M(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.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:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:S,shape:function(e,i,n){const s=i.getSameCanvas(),a=e.__nowWorld,r=i.bounds;let o,l,d,h,c,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(a))c=s,o=h=a;else{const{renderShapeSpread:s}=e.__layout;let p;if(t.Platform.fullImageShadow)p=a;else{const t=s?A(r,u===f?s*u:[s*f,s*u]):r;p=W(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(c=i.getSameCanvas(),e.__renderShape(c,n),u*=g,f*=_),h=O(a,d),o=D(h,-d.e,-d.f);const m=n.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),n=Object.assign(Object.assign({},n),{matrix:l})}return e.__renderShape(s,n),{canvas:s,matrix:l,fitMatrix:d,bounds:o,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let F={},U=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:V,scaleOfOuter:Y,multiplyParent:N,scale:q,rotate:X,skew:Q}=t.MatrixHelper;function Z(t,e,i,n,s,a,r){const o=j();V(o,e.x+i,e.y+n),q(o,s,a),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function $(t,e,i,n,s,a,r,o,l){const d=j();J(d,e,i,n,s,a,r,o),l&&(U.a=e.width/l.width,U.d=e.height/l.height,N(d,U)),t.transform=d}function K(t,e,i,n,s,a,r,o,l,d,h,c){const u=j();if(c)J(u,e,s,a,r,o,l,d);else{if(l)if("center"===h)G(u,{x:i/2,y:n/2},l);else switch(X(u,l),l){case 90:V(u,n,0);break;case 180:V(u,i,n);break;case 270:V(u,0,i)}F.x=e.x+s,F.y=e.y+a,V(u,F.x,F.y),r&&Y(u,F,r,o)}t.transform=u}function J(t,e,i,n,s,a,r,o){r&&X(t,r),o&&Q(t,o.x,o.y),s&&q(t,s,a),V(t,e.x+i,e.y+n)}const{get:tt,translate:et}=t.MatrixHelper,it=new t.Bounds,nt={},st={};function at(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=rt(i,n,e)}function rt(e,i,n){e.padding&&(i=it.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(st,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((h||c)&&(t.MathHelper.getScaleData(h,c,n,nt),x=nt.scaleX,b=nt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(st,x,b,!0),l&&t.AlignHelper.toPoint(l,st,i,st,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,st,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,st),t.BoundsHelper.scale(st,x,b,!0)),d&&t.PointHelper.move(st,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":(st.x||st.y||x||p||u||f)&&$(y,i,st.x,st.y,x,b,u,f,e.clipSize);break;case"repeat":(!w||x||u||f)&&K(y,i,s,a,st.x,st.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ot(r,n,a.width,i&&i.x),y:ot(o,s,a.height,i&&i.y)}}(_,n&&g,st.width,st.height,i));break;default:x&&Z(y,i,st.x,st.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=tt(),et(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ot(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let lt,dt=new t.Bounds;const{isSame:ht}=t.BoundsHelper;function ct(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||at(s,n,i,a),!0}function ut(e,i){gt(e,t.ImageEvent.LOAD,i)}function ft(e,i){gt(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,i)}function gt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function _t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:wt,copy:yt}=t.MatrixHelper,{floor:vt,ceil:xt,max:bt,abs:Et}=Math;function Bt(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Et(f),p=Et(p),h=mt(),yt(h,g),wt(h,1/f,1/p),s*=f,a*=p),c*=s,u*=a;const w=c*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=c+(v||0),e=u+(x||0);s/=t/bt(vt(t),1),a/=e/bt(vt(e),1),h||(h=mt(),g&&yt(h,g)),wt(h,1/s,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=E,i.patternId=r,!0}}function Rt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Lt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return lt&&n===lt.paint&&ht(s,lt.boxBounds)?r=lt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),lt=l.use>1?{leafPaint:r,paint:n,boxBounds:dt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(ct(e,i,n,l,r,s),a&&(ut(e,o),ft(e,o))):l.error?a&&pt(e,o,l.error):(a&&(_t(e,!0),ut(e,o)),r.loadId=l.load(()=>{_t(e,!1),e.destroyed||(ct(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,o)),r.loadId=void 0},t=>{_t(e,!1),pt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__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()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?Bt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Rt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&Bt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,h=n.length;d<h;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:rt,fillOrFitMode:Z,clipMode:$,repeatMode:K},{toPoint:St}=t.AroundHelper,{hasTransparent:kt}=e.ColorConvert,Pt={},Ct={};function At(i,n,s,a){if(s){let r,o,l,d;for(let i=0,h=s.length;i<h;i++)r=s[i],t.isString(r)?(l=i/(h-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&kt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Ot,getDistance:Dt}=t.PointHelper,{get:Wt,rotateOfOuter:Tt,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,zt={},Ht={};function Ft(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Ot(e,i);a=Wt(),s?(Mt(a,e,r/o*(n||1),1),Tt(a,e,t+90)):(Mt(a,e,1,r/o*(n||1)),Tt(a,e,t))}return a}const{getDistance:Ut}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},Vt={};const Yt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;St(n||"top",i,Pt),St(s||"bottom",i,Ct);const o=t.Platform.canvas.createLinearGradient(Pt.x,Pt.y,Ct.x,Ct.y),l={type:a,style:o};return At(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;It(n||"center",i,zt),It(s||"bottom",i,Ht);const l=t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Dt(zt,Ht)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,zt,Ht,o,!0);return h&&(d.transform=h),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;jt(n||"center",i,Gt),jt(s||"bottom",i,Vt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ut(Gt,Vt)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,Gt,Vt,o||1,t.Platform.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ft},{copy:Nt,toOffsetOutBounds:qt}=t.BoundsHelper,Xt={},Qt={};function Zt(e,i,n,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Nt(Xt,e.bounds),Xt.x+=i.x-r.x,Xt.y+=i.y-r.y,n){const{fitMatrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Nt(Xt,i),Xt.x-=i.width/2*(n-1),Xt.y-=i.height/2*(n-1),Xt.width*=n,Xt.height*=n),e.copyWorld(s.canvas,r,n?Xt:i)}const{toOffsetOutBounds:$t}=t.BoundsHelper,Kt={};const Jt={shadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{shadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;qt(c,Qt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Qt.offsetX+d.x*f*w,Qt.offsetY+d.y*p*w,d.blur*f*w,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Qt,r,s),a=c,d.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,c,o,"copy"),a=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{innerShadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;$t(c,Kt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Kt.offsetX+d.x*f*w,Kt.offsetY+d.y*p*w,d.blur*f*w),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Kt,r,s),g.restore(),h?(g.copyWorld(g,c,o,"copy"),g.copyWorld(h,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=c),g.fillWorld(a,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:te}=t.LeafBoundsHelper;let ee;function ie(t,e,i,n,s,a,r,o){switch(e){case"grayscale":ee||(ee=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);se(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":se(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ne(t){return t.getSameCanvas(!1,!0)}function se(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(ie(this,r,t,s,n,a,void 0,!0),n=s=null),a=i.__.opacity,ee=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ne(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ne(t)),s||(s=ne(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||te(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&ie(this,r,t,s,n,a,void 0,!1),te(i,e)||i.__render(s||t,e),h&&ie(this,r,t,s,n,a,h,!1)}ie(this,r,t,s,n,a,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",re=ae+"_#~&*+\\=|≮≯≈≠=…",oe=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 le(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const de=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ce=le(ae),ue=le(re),fe=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:ge,Single:_e,Before:me,After:we,Symbol:ye,Break:ve}=pe;function xe(t){return de[t]?ge:fe[t]?ve:he[t]?me:ce[t]?we:ue[t]?ye:oe.test(t)?_e:ge}const be={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ee(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:Be}=be,{Letter:Re,Single:Le,Before:Se,After:ke,Symbol:Pe,Break:Ce}=pe;let Ae,Oe,De,We,Te,Me,Ie,ze,He,Fe,Ue,je,Ge,Ve,Ye,Ne,qe,Xe=[];function Qe(t,e){He&&!ze&&(ze=He),Ae.data.push({char:t,width:e}),De+=e}function Ze(){We+=De,Ae.width=De,Oe.words.push(Ae),Ae={data:[]},De=0}function $e(){Ve&&(Ye.paraNumber++,Oe.paraStart=!0,Ve=!1),He&&(Oe.startCharSize=ze,Oe.endCharSize=He,ze=0),Oe.width=We,Ne.width?Be(Oe):qe&&Ke(),Xe.push(Oe),Oe={words:[]},We=0}function Ke(){We>(Ye.maxWidth||0)&&(Ye.maxWidth=We)}const{top:Je,right:ti,bottom:ei,left:ii}=t.Direction4;function ni(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 si={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=n;h&&(r?(s=h[ii],r-=h[ti]+h[ii]):n.autoSizeAlign||(s=h[ii]),o?(a=h[Je],o-=h[Je]+h[ei]):n.autoSizeAlign||(a=h[Je]));const c={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ye=e,Xe=e.rows,Ne=e.bounds,qe=!Ne.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=Ne;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ve=!0,Ue=null,ze=Ie=He=De=We=0,Ae={data:[]},Oe={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Me=i[n],"\n"===Me?(De&&Ze(),Oe.paraEnd=!0,$e(),Ve=!0):(Fe=xe(Me),Fe===Re&&"none"!==r&&(Me=Ee(Me,r,!De)),Ie=o.measureText(Me).width,s&&(s<0&&(He=Ie),Ie+=s),je=Fe===Le&&(Ue===Le||Ue===Re)||Ue===Le&&Fe!==ke,Ge=!(Fe!==Se&&Fe!==Le||Ue!==Pe&&Ue!==ke),Te=Ve&&a?l-a:l,t&&l&&We+De+Ie>Te&&(e?(De&&Ze(),We&&$e()):(Ge||(Ge=Fe===Re&&Ue==ke),je||Ge||Fe===Ce||Fe===Se||Fe===Le||De+Ie>Te?(De&&Ze(),We&&$e()):We&&$e()))," "===Me&&!0!==Ve&&We+De===0||(Fe===Ce?(" "===Me&&De&&Ze(),Qe(Me,Ie),Ze()):je||Ge?(De&&Ze(),Qe(Me,Ie)):Qe(Me,Ie)),Ue=Fe);De&&Ze(),We&&$e(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ye.paraNumber++,We=o.measureText(t).width,Xe.push({x:a||0,text:t,width:We,paraStart:!0}),qe&&Ke()})}(c,i,n),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ni(e,"x",t[ii]);break;case"right":ni(e,"x",-t[ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ni(e,"y",t[Je]);break;case"bottom":ni(e,"y",-t[ei])}}(h,c,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(c?c*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&r>0&&(w+=c),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,n,r),c.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<h));n--){if(l<h&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,n,s,r),"none"!==l&&function(i,n){let s;const{fontSize:a,textDecoration:r}=n;switch(i.decorationHeight=a/11,t.isObject(r)?(s=r.type,r.color&&(i.decorationColor=e.ColorConvert.string(r.color))):s=r,s){case"under":i.decorationY=[.15*a];break;case"delete":i.decorationY=[.35*-a];break;case"under-delete":i.decorationY=[.15*a,.35*-a]}}(c,n),c}};const ai={string:function(i,n){const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,si),Object.assign(e.ColorConvert,ai),Object.assign(e.Paint,H),Object.assign(e.PaintImage,Lt),Object.assign(e.PaintGradient,Yt),Object.assign(e.Effect,Jt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
2
2
  //# sourceMappingURL=web.min.cjs.map