@leafer-ui/worker 1.0.0 → 1.0.2
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/worker.cjs +2667 -0
- package/dist/worker.esm.js +37 -35
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +267 -143
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +265 -144
- package/dist/worker.module.min.js +1 -1
- package/package.json +16 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),n=require("@leafer-ui/draw");class i extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,a)=>{t.convertToBlob({type:s(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)})).catch((t=>{a(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:s(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",t.Platform.image.getRealURL(e),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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,n=e.length;t<n;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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:l,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class p{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,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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.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 n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&c(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&h(t),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,f,this.times)),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),y.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.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),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(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,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.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;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).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.changed=!0}}__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,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(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)}}const{hitRadiusPoint:B}=t.BoundsHelper;class b{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(r);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,r),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:L,YesAndSkip:R}=t.Answer,k={},P={},C={};class M{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new b(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":k.id=e.substring(1),e=k;break;case".":P.className=e.substring(1),e=P;break;default:C.tag=e,e=C}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===E||a===R){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<L&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function S(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function O(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?I(t,!0,e,n):W(e,n);break;case"inside":A("inside",t,s,e,n);break;case"outside":A("outside",t,s,e,n)}}function A(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?I(e,!0,i,o):W(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",S(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function W(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function I(t,e,i,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&n.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?W(i,s):s.stroke(),s.restoreBlendMode()):e?W(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new M(t,e)}),t.Platform.layout=y.fullLayout;const{getSpread:T,getOuterOf:D,getByMove:H,getIntersectData:F}=t.BoundsHelper;let Y;function N(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:n.ColorConvert.string(o,d)};case"image":return n.PaintImage.image(i,t,e,s,!Y||!Y[e.url]);case"linear":return n.PaintGradient.linearGradient(e,s);case"radial":return n.PaintGradient.radialGradient(e,s);case"angular":return n.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const G={compute:function(t,e){const i=e.__,s=[];let a,r=i.__input[t];r instanceof Array||(r=[r]),Y=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=r.length;i<a;i++)n=N(t,r[i],e),n&&s.push(n);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?S(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&n.PaintImage.checkImage(e,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?S(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?S(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):r?S(e,i):a?i.fill(a):i.fill())},fillText:S,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)O(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)O(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),I(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),I(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),I(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:O,drawTextStroke:W,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=F(i?T(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=D(s,r),a=H(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let j={};const{get:X,rotateOfOuter:U,translate:q,scaleOfOuter:V,scale:z,rotate:Q}=t.MatrixHelper;function J(t,e,n,i,s,a,r){const o=X();q(o,e.x+n,e.y+i),z(o,s,a),r&&U(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function K(t,e,n,i,s,a,r){const o=X();q(o,e.x+n,e.y+i),s&&z(o,s,a),r&&Q(o,r),t.transform=o}function Z(t,e,n,i,s,a,r,o,d,l){const h=X();if(d)if("center"===l)U(h,{x:n/2,y:i/2},d);else switch(Q(h,d),d){case 90:q(h,i,0);break;case 180:q(h,n,i);break;case 270:q(h,0,n)}j.x=e.x+s,j.y=e.y+a,q(h,j.x,j.y),r&&V(h,j,r,o),t.transform=h}const{get:$,translate:tt}=t.MatrixHelper,et=new t.Bounds,nt={},it={};function st(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=at(n,i,e)}function at(e,n,i){let{width:s,height:a}=i;e.padding&&(n=et.set(n).shrink(e.padding));const{opacity:r,mode:o,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:o},_="center"!==d&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(o&&"cover"!==o&&"fit"!==o)(h||c)&&(t.MathHelper.getScaleData(h,c,i,it),y=it.scaleX,v=it.scaleY);else if(!g||u){const t=n.width/w,e=n.height/m;y=v="fit"===o?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,B+=(n.height-a*v)/2}if(d){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,nt,!0),x+=nt.x,B+=nt.y}switch(l&&(x+=l.x,B+=l.y),o){case"strench":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&K(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&Z(p,n,s,a,x,B,y,v,u,d),f||(p.repeat="repeat");break;default:y&&J(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=$(),tt(p.transform,n.x,n.y)),y&&"strench"!==o&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,r&&(p.opacity=r),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let rt,ot=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function lt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||st(s,i,n,a),!0}function ht(e,n){ft(e,t.ImageEvent.LOAD,n)}function ct(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,i){n.error=i,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function gt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:_t,copy:wt}=t.MatrixHelper,{ceil:mt,abs:yt}=Math;function vt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=yt(s),a=yt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=o;u&&(l=pt(),wt(l,p),_t(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=pt(),p&&wt(l,p)),_t(l,1/s,1/a));const y=e.getCanvas(mt(h)||1,mt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}function xt(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Bt}=Math;const bt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return rt&&i===rt.paint&&dt(s,rt.boxBounds)?r=rt.leafPaint:(r={type:i.type,image:d},rt=d.use>1?{leafPaint:r,paint:i,boxBounds:ot.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(lt(e,n,i,d,r,s),a&&(ht(e,o),ct(e,o))):d.error?a&&ut(e,o,d.error):(gt(e,!0),a&&ht(e,o),r.loadId=d.load((()=>{gt(e,!1),e.destroyed||(lt(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,o)),r.loadId=null}),(t=>{gt(e,!1),ut(e,o,t),r.loadId=null}))),r},checkImage:function(e,i,s,a){const{scaleX:r,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(!s.data||s.patternId===r+"-"+o&&!n.Export.running)return!1;{const{data:d}=s;if(a)if(d.repeat)a=!1;else{let{width:e,height:s}=d;e*=Bt(r)*i.pixelRatio,s*=Bt(o)*i.pixelRatio,d.scaleX&&(e*=d.scaleX,s*=d.scaleY),a=e*s>t.Platform.image.maxCacheSize||n.Export.running}return a?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||n.Export.running?vt(e,s,i.pixelRatio):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&vt(e,s,i.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}},createPattern:vt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:st,getPatternData:at,fillOrFitMode:J,clipMode:K,repeatMode:Z},{toPoint:Et}=t.AroundHelper,Lt={},Rt={};function kt(t,e,i){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(r-1),n.ColorConvert.string(s,i)):t.addColorStop(s.offset,n.ColorConvert.string(s.color,i))}const{getAngle:Pt,getDistance:Ct}=t.PointHelper,{get:Mt,rotateOfOuter:St,scaleOfOuter:Ot}=t.MatrixHelper,{toPoint:At}=t.AroundHelper,Wt={},It={};function Tt(t,e,n,i,s){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Pt(e,n);a=Mt(),s?(Ot(a,e,r/o*(i||1),1),St(a,e,t+90)):(Ot(a,e,1,r/o*(i||1)),St(a,e,t))}return a}const{getDistance:Dt}=t.PointHelper,{toPoint:Ht}=t.AroundHelper,Ft={},Yt={};const Nt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;Et(i||"top",n,Lt),Et(s||"bottom",n,Rt);const d=t.Platform.canvas.createLinearGradient(Lt.x,Lt.y,Rt.x,Rt.y);kt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;At(i||"center",n,Wt),At(s||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Wt.x,Wt.y,0,Wt.x,Wt.y,Ct(Wt,It));kt(l,e.stops,r);const h={type:a,style:l},c=Tt(n,Wt,It,d,!0);return c&&(h.transform=c),o&&(h.blendMode=o),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;Ht(i||"center",n,Ft),Ht(s||"bottom",n,Yt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Dt(Ft,Yt));kt(l,e.stops,r);const h={type:a,style:l},c=Tt(n,Ft,Yt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),o&&(h.blendMode=o),h},getTransform:Tt},{copy:Gt,toOffsetOutBounds:jt}=t.BoundsHelper,Xt={},Ut={};function qt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Gt(Xt,e.bounds),Xt.x+=n.x-r.x,Xt.y+=n.y-r.y,i){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Xt.width*=i,Xt.height*=i}e.copyWorld(s.canvas,e.bounds,Xt)}else i&&(Gt(Xt,n),Xt.x-=n.width/2*(i-1),Xt.y-=n.height/2*(i-1),Xt.width*=i,Xt.height*=i),e.copyWorld(s.canvas,r,i?Xt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,zt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;jt(l,Ut),o.forEach(((o,p)=>{f.setWorldShadow(Ut.offsetX+o.x*c,Ut.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,Ut,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Vt(l,zt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(zt.offsetX+o.x*c,zt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,zt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Jt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}n.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=Zt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Jt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=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 ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=ie(te),oe=ie(ee),de=ie("- —/~|┆·");var le;!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"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=le;function _e(t){return se[t]?he:de[t]?pe:ae[t]?ue:re[t]?fe:oe[t]?ge:ne.test(t)?ce:he}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=we,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Ee,Break:Le}=le;let Re,ke,Pe,Ce,Me,Se,Oe,Ae,We,Ie,Te,De,He,Fe,Ye,Ne,Ge=[];function je(t,e){We&&!Ae&&(Ae=We),Re.data.push({char:t,width:e}),Pe+=e}function Xe(){Ce+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function Ue(){Fe&&(Ye.paraNumber++,ke.paraStart=!0,Fe=!1),We&&(ke.startCharSize=Ae,ke.endCharSize=We,Ae=0),ke.width=Ce,Ne.width&&ye(ke),Ge.push(ke),ke={words:[]},Ce=0}const qe=0,Ve=1,ze=2;const{top:Qe,right:Je,bottom:Ke,left:Ze}=t.Direction4;function $e(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const tn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[Ze],a-=l[Je]+l[Ze]),r&&(s=l[Qe],r-=l[Qe]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ye=e,Ge=e.rows,Ne=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ne;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Ae=Oe=We=Pe=Ce=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Se=n[i],"\n"===Se?(Pe&&Xe(),ke.paraEnd=!0,Ue(),Fe=!0):(Ie=_e(Se),Ie===ve&&"none"!==r&&(Se=me(Se,r,!Pe)),Oe=o.measureText(Se).width,s&&(s<0&&(We=Oe),Oe+=s),De=Ie===xe&&(Te===xe||Te===ve)||Te===xe&&Ie!==be,He=!(Ie!==Be&&Ie!==xe||Te!==Ee&&Te!==be),Me=Fe&&a?d-a:d,t&&d&&Ce+Pe+Oe>Me&&(e?(Pe&&Xe(),Ce&&Ue()):(He||(He=Ie===ve&&Te==be),De||He||Ie===Le||Ie===Be||Ie===xe||Pe+Oe>Me?(Pe&&Xe(),Ce&&Ue()):Ce&&Ue()))," "===Se&&!0!==Fe&&Ce+Pe===0||(Ie===Le?(" "===Se&&Pe&&Xe(),je(Se,Oe),Xe()):De||He?(Pe&&Xe(),je(Se,Oe)):je(Se,Oe)),Te=Ie);Pe&&Xe(),Ce&&Ue(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Ge.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Je])}if(!s)switch(n.verticalAlign){case"top":$e(e,"y",t[Qe]);break;case"bottom":$e(e,"y",-t[Ke])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:w}=i,m=s*n.length+(h?h*(t.paraNumber-1):0),y=a;if(o&&m>w)m=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":p+=(w-m)/2;break;case"bottom":p+=w-m}y+=p;for(let a=0,l=n.length;a<l;a++){if(c=n[a],c.x=g,c.width<_||c.width>_&&!o)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(y+=h),c.y=y,y+=s,t.overflow>a&&y>m&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?qe:l>.01?Ve:ze,t.isOverflow&&!o&&(t.textMode=!0),c===ze?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ve?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=n;if(a.splice(r),o&&"show"!==o){let e,d;"hide"===o?o="":"ellipsis"===o&&(o="...");const l=o?t.Platform.canvas.measureText(o).width:0,h=i+s-l;("none"===n.textWrap?a:[a[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<h));i--){if(d<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:o,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const en={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:nn,addPoint:sn,toBounds:an}=t.TwoPointBoundsHelper;const rn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),a=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){on||(on=new t.TaskProcessor);return new Promise((t=>{on.add((()=>xt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((o=>{const d=t=>{r(t),o(),this.running=!1},{toURL:l}=t.Platform,{download:h}=t.Platform.origin;if("json"===s)return a&&h(l(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!!a||e.toJSON(i.json)});if("svg"===s)return a&&h(l(e.toSVG(),"svg"),n),d({data:!!a||e.toSVG()});const{leafer:c}=e;c?(dn(e),c.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let s,a,r=1,o=1;const{worldTransform:l,isLeafer:h,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?c.config.smooth:i.smooth,w=i.contextSettings||c.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?c.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"inner":"local");switch(r=l.scaleX,o=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),r/=e.scaleX,o/=e.scaleY;break;case"world":r=1,o=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;r/=r/n.scaleX,o/=o/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:E,y:L,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-E,-L).withScale(1/r*B.scaleX,1/o*B.scaleY)};let C,M=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(C=e,C.__worldOpacity=0,e=c,P.bounds=M.bounds),M.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(M,P),e.fill=t}else e.__render(M,P);if(M.restore(),C&&C.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?sn(o,a,r):nn(o={},a,r)),d++;const l=new t.Bounds;return an(o,l),l.scale(1/e.pixelRatio).ceil()}(M);const e=M,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};M=t.Creator.canvas(s),M.copyWorld(e,a,s)}v&&M.fillWorld(M.bounds,y||"#FFFFFF","destination-over"),p&&p(M);const S="canvas"===n?M:yield M.export(n,i);d({data:S,width:M.pixelWidth,height:M.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let on;function dn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>dn(t)))}const ln=t.LeaferCanvasBase.prototype,hn=t.Debug.get("@leafer-ui/export");ln.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},ln.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{hn.error(t),i(null)}))}))},ln.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},ln.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{hn.error(t),i(!1)}))}))},Object.assign(n.TextConvert,tn),Object.assign(n.ColorConvert,en),Object.assign(n.Paint,G),Object.assign(n.PaintImage,bt),Object.assign(n.PaintGradient,Nt),Object.assign(n.Effect,Qt),Object.assign(n.Export,rn),Object.assign(t.Creator,{interaction:(t,n,i,s)=>new e.InteractionBase(t,n,i,s),hitCanvas:(t,e)=>new i(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Selector=M,exports.Watcher=o,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]}})}));
|