@leafer-ui/worker 1.3.1 → 1.3.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 +3 -3
- package/dist/worker.esm.js +3 -3
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +20 -9
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +20 -9
- package/dist/worker.module.min.js +1 -1
- package/package.json +10 -10
package/dist/worker.cjs
CHANGED
|
@@ -534,7 +534,7 @@ class Renderer {
|
|
|
534
534
|
partRender() {
|
|
535
535
|
const { canvas, updateBlocks: list } = this;
|
|
536
536
|
if (!list)
|
|
537
|
-
return
|
|
537
|
+
return;
|
|
538
538
|
this.mergeBlocks();
|
|
539
539
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
540
540
|
this.clipRender(block); });
|
|
@@ -2081,7 +2081,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2081
2081
|
rows.forEach(row => {
|
|
2082
2082
|
if (row.words) {
|
|
2083
2083
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2084
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2084
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2085
2085
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2086
2086
|
if (row.isOverflow && !letterSpacing)
|
|
2087
2087
|
row.textMode = true;
|
|
@@ -2103,7 +2103,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2103
2103
|
else {
|
|
2104
2104
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2105
2105
|
}
|
|
2106
|
-
if (!row.paraEnd
|
|
2106
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2107
2107
|
charX += addWordWidth;
|
|
2108
2108
|
row.width += addWordWidth;
|
|
2109
2109
|
}
|
package/dist/worker.esm.js
CHANGED
|
@@ -535,7 +535,7 @@ class Renderer {
|
|
|
535
535
|
partRender() {
|
|
536
536
|
const { canvas, updateBlocks: list } = this;
|
|
537
537
|
if (!list)
|
|
538
|
-
return
|
|
538
|
+
return;
|
|
539
539
|
this.mergeBlocks();
|
|
540
540
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
541
541
|
this.clipRender(block); });
|
|
@@ -2082,7 +2082,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2082
2082
|
rows.forEach(row => {
|
|
2083
2083
|
if (row.words) {
|
|
2084
2084
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2085
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2085
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2086
2086
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2087
2087
|
if (row.isOverflow && !letterSpacing)
|
|
2088
2088
|
row.textMode = true;
|
|
@@ -2104,7 +2104,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2104
2104
|
else {
|
|
2105
2105
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2106
2106
|
}
|
|
2107
|
-
if (!row.paraEnd
|
|
2107
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2108
2108
|
charX += addWordWidth;
|
|
2109
2109
|
row.width += addWordWidth;
|
|
2110
2110
|
}
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as g,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as E,AlignHelper as S,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as T,HitCanvasManager as C}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as P,PaintGradient as D,Export as I,Group as F,TextConvert as Y,Paint as G,Effect as z}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:U}=o;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:U(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:U(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:N}=navigator;N.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):N.indexOf("Safari")>-1&&-1===N.indexOf("Chrome")&&(e.fullImageShadow=!0),N.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):N.indexOf("Mac")>-1?e.os="Mac":N.indexOf("Linux")>-1&&(e.os="Linux");class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.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:q,updateBounds:V,updateAllWorldOpacity:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:J}=p,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,J),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:et,updateAllChange:it}=f,nt=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,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:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,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||V(n[t])}V(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){et(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=w.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,at.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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 at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(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||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.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:rt}=B;class dt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||rt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class lt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new dt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function ct(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?_t(t,!0,e,i):ft(e,i);break;case"inside":ut("inside",t,s,e,i);break;case"outside":ut("outside",t,s,e,i)}}function ut(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?_t(e,!0,n,r):ft(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ht(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ft(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function _t(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ft(i,n):n.stroke(),n.restoreBlendMode()):e?ft(i,n):n.stroke())}function gt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new lt(t,e)}),e.layout=st.fullLayout;const{getSpread:pt,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=B;let vt;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:P.string(o,r)};case"image":return M.image(i,t,e,n,!vt||!vt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),vt=M.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=xt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ht(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&M.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?ht(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?ht(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?ht(e,i):s?i.fill(s):i.fill())},fillText:ht,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)ct(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)ct(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),_t(t,!1,e,i),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),_t(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),_t(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:ct,drawTextStroke:ft,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=mt(n?pt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(s,o),a=yt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Bt={};const{get:kt,rotateOfOuter:Rt,translate:Et,scaleOfOuter:St,scale:Lt,rotate:At}=R;function Wt(t,e,i,n,s,a,o){const r=kt();Et(r,e.x+i,e.y+n),Lt(r,s,a),o&&Rt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ot(t,e,i,n,s,a,o){const r=kt();Et(r,e.x+i,e.y+n),s&&Lt(r,s,a),o&&At(r,o),t.transform=r}function Tt(t,e,i,n,s,a,o,r,d,l){const h=kt();if(d)if("center"===l)Rt(h,{x:i/2,y:n/2},d);else switch(At(h,d),d){case 90:Et(h,n,0);break;case 180:Et(h,i,n);break;case 270:Et(h,0,i)}Bt.x=e.x+s,Bt.y=e.y+a,Et(h,Bt.x,Bt.y),o&&St(h,Bt,o,r),t.transform=h}const{get:Ct,translate:Mt}=R,Pt=new g,Dt={},It={};function Ft(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Yt(i,n,e)}function Yt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Pt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,_={mode:o},g="center"!==r&&(c||0)%180==90,p=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(E.getScaleData(l,h,i,It),y=It.scaleX,m=It.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),S.toPoint(r,t,e,Dt,!0),v+=Dt.x,x+=Dt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ot(_,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Tt(_,e,n,s,v,x,y,m,c,r),u||(_.repeat="repeat");break;default:y&&Wt(_,e,v,x,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=Ct(),Mt(_.transform,e.x,e.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=m),_.width=n,_.height=s,a&&(_.opacity=a),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Gt,zt=new g;const{isSame:Ht}=B;function Ut(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||Ft(s,n,i,a),!0}function Xt(t,e){qt(t,L.LOAD,e)}function Nt(t,e){qt(t,L.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,L.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Zt,copy:$t}=R,{ceil:Jt,abs:Kt}=Math;function te(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=Kt(s),a=Kt(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(l=Qt(),$t(l,g),Zt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(l||(l=Qt(),g&&$t(l,g)),Zt(l,1/s,1/a));const m=t.getCanvas(Jt(h)||1,Jt(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return Gt&&i===Gt.paint&&Ht(n,Gt.boxBounds)?a=Gt.leafPaint:(a={type:i.type,image:r},Gt=r.use>1?{leafPaint:a,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Ut(t,e,i,r,a,n),s&&(Xt(t,o),Nt(t,o))):r.error?s&&jt(t,o,r.error):(s&&(Vt(t,!0),Xt(t,o)),a.loadId=r.load((()=>{Vt(t,!1),t.destroyed||(Ut(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,o)),a.loadId=null}),(e=>{Vt(t,!1),jt(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!I.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=ie(a)*r,i*=ie(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||I.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||I.running?te(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&te(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:Ft,getPatternData:Yt,fillOrFitMode:Wt,clipMode:Ot,repeatMode:Tt},{toPoint:se}=A,ae={},oe={};function re(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:de,getDistance:le}=W,{get:he,rotateOfOuter:ce,scaleOfOuter:ue}=R,{toPoint:fe}=A,_e={},ge={};function pe(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=de(e,i);a=he(),s?(ue(a,e,o/r*(n||1),1),ce(a,e,t+90)):(ue(a,e,1,o/r*(n||1)),ce(a,e,t))}return a}const{getDistance:we}=W,{toPoint:ye}=A,me={},ve={};const xe={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;se(n||"top",i,ae),se(s||"bottom",i,oe);const d=e.canvas.createLinearGradient(ae.x,ae.y,oe.x,oe.y);re(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;fe(n||"center",i,_e),fe(s||"bottom",i,ge);const l=e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,le(_e,ge));re(l,t.stops,o);const h={type:a,style:l},c=pe(i,_e,ge,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;ye(n||"center",i,me),ye(s||"bottom",i,ve);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,me.x,me.y):e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,ve));re(l,t.stops,o);const h={type:a,style:l},c=pe(i,me,ve,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:pe},{copy:be,toOffsetOutBounds:Be}=B,ke={},Re={};function Ee(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(be(ke,t.bounds),ke.x+=i.x-o.x,ke.y+=i.y-o.y,n){const{matrix:t}=s;ke.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),ke.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),ke.width*=n,ke.height*=n}t.copyWorld(s.canvas,t.bounds,ke)}else n&&(be(ke,i),ke.x-=i.width/2*(n-1),ke.y-=i.height/2*(n-1),ke.width*=n,ke.height*=n),t.copyWorld(s.canvas,o,n?ke:i)}const{toOffsetOutBounds:Se}=B,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Be(l,Re),r.forEach(((r,g)=>{f.setWorldShadow(Re.offsetX+r.x*c,Re.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Re,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Se(l,Le),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Le.offsetX+r.x*c,Le.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Le,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},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:We}=p;function Oe(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ce(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ce(t,i,n,a);break;case"path":i.restore()}}function Te(t){return t.getSameCanvas(!1,!0)}function Ce(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(Oe(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Te(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Te(t)),s||(s=Te(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||We(i,e)||i.__render(s||t,e);Oe(this,o,t,s,n,a)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pe=Me+"_#~&*+\\=|≮≯≈≠=…",De=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 Fe=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Ie(Me),ze=Ie(Pe),He=Ie("- —/~|┆·");var Ue;!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"}(Ue||(Ue={}));const{Letter:Xe,Single:Ne,Before:je,After:qe,Symbol:Ve,Break:Qe}=Ue;function Ze(t){return Fe[t]?Xe:He[t]?Qe:Ye[t]?je:Ge[t]?qe:ze[t]?Ve:De.test(t)?Ne:Xe}const $e={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 Je(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ke}=$e,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:ai}=Ue;let oi,ri,di,li,hi,ci,ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,bi,Bi=[];function ki(t,e){_i&&!fi&&(fi=_i),oi.data.push({char:t,width:e}),di+=e}function Ri(){li+=di,oi.width=di,ri.words.push(oi),oi={data:[]},di=0}function Ei(){mi&&(vi.paraNumber++,ri.paraStart=!0,mi=!1),_i&&(ri.startCharSize=fi,ri.endCharSize=_i,fi=0),ri.width=li,xi.width?Ke(ri):bi&&Si(),Bi.push(ri),ri={words:[]},li=0}function Si(){li>(vi.maxWidth||0)&&(vi.maxWidth=li)}const Li=0,Ai=1,Wi=2;const{top:Oi,right:Ti,bottom:Ci,left:Mi}=O;function Pi(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 Di={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[Mi],a-=l[Ti]+l[Mi]):i.autoSizeAlign||(n=l[Mi]),o?(s=l[Oi],o-=l[Oi]+l[Ci]):i.autoSizeAlign||(s=l[Oi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){vi=t,Bi=t.rows,xi=t.bounds,bi=!xi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=xi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;mi=!0,pi=null,fi=ui=_i=di=li=0,oi={data:[]},ri={words:[]};for(let n=0,l=i.length;n<l;n++)ci=i[n],"\n"===ci?(di&&Ri(),ri.paraEnd=!0,Ei(),mi=!0):(gi=Ze(ci),gi===ti&&"none"!==o&&(ci=Je(ci,o,!di)),ui=r.measureText(ci).width,s&&(s<0&&(_i=ui),ui+=s),wi=gi===ei&&(pi===ei||pi===ti)||pi===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||pi!==si&&pi!==ni),hi=mi&&a?d-a:d,t&&d&&li+di+ui>hi&&(e?(di&&Ri(),li&&Ei()):(yi||(yi=gi===ti&&pi==ni),wi||yi||gi===ai||gi===ii||gi===ei||di+ui>hi?(di&&Ri(),li&&Ei()):li&&Ei()))," "===ci&&!0!==mi&&li+di===0||(gi===ai?(" "===ci&&di&&Ri(),ki(ci,ui),Ri()):wi||yi?(di&&Ri(),ki(ci,ui)):ki(ci,ui)),pi=gi);di&&Ri(),li&&Ei(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{vi.paraNumber++,li=r.measureText(t).width,Bi.push({x:a||0,text:t,width:li,paraStart:!0}),bi&&Si()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Pi(e,"x",t[Mi]);break;case"right":Pi(e,"x",-t[Ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Pi(e,"y",t[Oi]);break;case"bottom":Pi(e,"y",-t[Ci])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:_,height:g}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>g)p=Math.max(g,s),t.overflow=i.length;else if(g||c)switch(l){case"middle":f+=(g-p)/2;break;case"bottom":f+=g-p}w+=f;let y,m,v,x=_||c?_:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<_||y.width>_&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Li:l>.01?Ai:Wi,t.isOverflow&&!r&&(t.textMode=!0),c===Wi?(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===Ai?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.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,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,i),h}};const Ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(Y,Di),Object.assign(P,Ii),Object.assign(G,bt),Object.assign(M,ne),Object.assign(D,xe),Object.assign(z,Ae),Object.assign(n,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new C}),X();export{st as Layouter,H as LeaferCanvas,dt as Picker,ot as Renderer,lt as Selector,j as Watcher,X as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as g,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as E,AlignHelper as S,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as T,HitCanvasManager as C}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as P,PaintGradient as D,Export as I,Group as F,TextConvert as Y,Paint as G,Effect as z}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:U}=o;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:U(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:U(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:N}=navigator;N.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):N.indexOf("Safari")>-1&&-1===N.indexOf("Chrome")&&(e.fullImageShadow=!0),N.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):N.indexOf("Mac")>-1?e.os="Mac":N.indexOf("Linux")>-1&&(e.os="Linux");class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.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:q,updateBounds:V,updateAllWorldOpacity:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:J}=p,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,J),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:et,updateAllChange:it}=f,nt=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,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:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,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||V(n[t])}V(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){et(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=w.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new g,at.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(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||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.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:rt}=B;class dt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||rt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class lt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new dt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function ht(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function ct(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?_t(t,!0,e,i):ft(e,i);break;case"inside":ut("inside",t,s,e,i);break;case"outside":ut("outside",t,s,e,i)}}function ut(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?_t(e,!0,n,r):ft(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ht(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ft(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function _t(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ft(i,n):n.stroke(),n.restoreBlendMode()):e?ft(i,n):n.stroke())}function gt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new lt(t,e)}),e.layout=st.fullLayout;const{getSpread:pt,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=B;let vt;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:P.string(o,r)};case"image":return M.image(i,t,e,n,!vt||!vt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),vt=M.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=xt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ht(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&M.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?ht(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?ht(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?ht(e,i):s?i.fill(s):i.fill())},fillText:ht,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)ct(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)ct(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),_t(t,!1,e,i),n.__useArrow&>(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),_t(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),_t(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:ct,drawTextStroke:ft,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=mt(n?pt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=wt(s,o),a=yt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Bt={};const{get:kt,rotateOfOuter:Rt,translate:Et,scaleOfOuter:St,scale:Lt,rotate:At}=R;function Wt(t,e,i,n,s,a,o){const r=kt();Et(r,e.x+i,e.y+n),Lt(r,s,a),o&&Rt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ot(t,e,i,n,s,a,o){const r=kt();Et(r,e.x+i,e.y+n),s&&Lt(r,s,a),o&&At(r,o),t.transform=r}function Tt(t,e,i,n,s,a,o,r,d,l){const h=kt();if(d)if("center"===l)Rt(h,{x:i/2,y:n/2},d);else switch(At(h,d),d){case 90:Et(h,n,0);break;case 180:Et(h,i,n);break;case 270:Et(h,0,i)}Bt.x=e.x+s,Bt.y=e.y+a,Et(h,Bt.x,Bt.y),o&&St(h,Bt,o,r),t.transform=h}const{get:Ct,translate:Mt}=R,Pt=new g,Dt={},It={};function Ft(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Yt(i,n,e)}function Yt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Pt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,_={mode:o},g="center"!==r&&(c||0)%180==90,p=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(E.getScaleData(l,h,i,It),y=It.scaleX,m=It.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),S.toPoint(r,t,e,Dt,!0),v+=Dt.x,x+=Dt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ot(_,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Tt(_,e,n,s,v,x,y,m,c,r),u||(_.repeat="repeat");break;default:y&&Wt(_,e,v,x,y,m,c)}return _.transform||(e.x||e.y)&&(_.transform=Ct(),Mt(_.transform,e.x,e.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=m),_.width=n,_.height=s,a&&(_.opacity=a),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Gt,zt=new g;const{isSame:Ht}=B;function Ut(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||Ft(s,n,i,a),!0}function Xt(t,e){qt(t,L.LOAD,e)}function Nt(t,e){qt(t,L.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,L.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Zt,copy:$t}=R,{ceil:Jt,abs:Kt}=Math;function te(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=Kt(s),a=Kt(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(l=Qt(),$t(l,g),Zt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(l||(l=Qt(),g&&$t(l,g)),Zt(l,1/s,1/a));const m=t.getCanvas(Jt(h)||1,Jt(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return Gt&&i===Gt.paint&&Ht(n,Gt.boxBounds)?a=Gt.leafPaint:(a={type:i.type,image:r},Gt=r.use>1?{leafPaint:a,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Ut(t,e,i,r,a,n),s&&(Xt(t,o),Nt(t,o))):r.error?s&&jt(t,o,r.error):(s&&(Vt(t,!0),Xt(t,o)),a.loadId=r.load((()=>{Vt(t,!1),t.destroyed||(Ut(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Nt(t,o)),a.loadId=null}),(e=>{Vt(t,!1),jt(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!I.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=ie(a)*r,i*=ie(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||I.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||I.running?te(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&te(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:Ft,getPatternData:Yt,fillOrFitMode:Wt,clipMode:Ot,repeatMode:Tt},{toPoint:se}=A,ae={},oe={};function re(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:de,getDistance:le}=W,{get:he,rotateOfOuter:ce,scaleOfOuter:ue}=R,{toPoint:fe}=A,_e={},ge={};function pe(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=de(e,i);a=he(),s?(ue(a,e,o/r*(n||1),1),ce(a,e,t+90)):(ue(a,e,1,o/r*(n||1)),ce(a,e,t))}return a}const{getDistance:we}=W,{toPoint:ye}=A,me={},ve={};const xe={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;se(n||"top",i,ae),se(s||"bottom",i,oe);const d=e.canvas.createLinearGradient(ae.x,ae.y,oe.x,oe.y);re(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;fe(n||"center",i,_e),fe(s||"bottom",i,ge);const l=e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,le(_e,ge));re(l,t.stops,o);const h={type:a,style:l},c=pe(i,_e,ge,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;ye(n||"center",i,me),ye(s||"bottom",i,ve);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,me.x,me.y):e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,ve));re(l,t.stops,o);const h={type:a,style:l},c=pe(i,me,ve,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:pe},{copy:be,toOffsetOutBounds:Be}=B,ke={},Re={};function Ee(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(be(ke,t.bounds),ke.x+=i.x-o.x,ke.y+=i.y-o.y,n){const{matrix:t}=s;ke.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),ke.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),ke.width*=n,ke.height*=n}t.copyWorld(s.canvas,t.bounds,ke)}else n&&(be(ke,i),ke.x-=i.width/2*(n-1),ke.y-=i.height/2*(n-1),ke.width*=n,ke.height*=n),t.copyWorld(s.canvas,o,n?ke:i)}const{toOffsetOutBounds:Se}=B,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Be(l,Re),r.forEach(((r,g)=>{f.setWorldShadow(Re.offsetX+r.x*c,Re.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Re,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Se(l,Le),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Le.offsetX+r.x*c,Le.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ee(f,Le,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},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:We}=p;function Oe(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ce(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ce(t,i,n,a);break;case"path":i.restore()}}function Te(t){return t.getSameCanvas(!1,!0)}function Ce(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(Oe(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Te(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Te(t)),s||(s=Te(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||We(i,e)||i.__render(s||t,e);Oe(this,o,t,s,n,a)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pe=Me+"_#~&*+\\=|≮≯≈≠=…",De=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 Fe=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Ie(Me),ze=Ie(Pe),He=Ie("- —/~|┆·");var Ue;!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"}(Ue||(Ue={}));const{Letter:Xe,Single:Ne,Before:je,After:qe,Symbol:Ve,Break:Qe}=Ue;function Ze(t){return Fe[t]?Xe:He[t]?Qe:Ye[t]?je:Ge[t]?qe:ze[t]?Ve:De.test(t)?Ne:Xe}const $e={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 Je(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ke}=$e,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:ai}=Ue;let oi,ri,di,li,hi,ci,ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,bi,Bi=[];function ki(t,e){_i&&!fi&&(fi=_i),oi.data.push({char:t,width:e}),di+=e}function Ri(){li+=di,oi.width=di,ri.words.push(oi),oi={data:[]},di=0}function Ei(){mi&&(vi.paraNumber++,ri.paraStart=!0,mi=!1),_i&&(ri.startCharSize=fi,ri.endCharSize=_i,fi=0),ri.width=li,xi.width?Ke(ri):bi&&Si(),Bi.push(ri),ri={words:[]},li=0}function Si(){li>(vi.maxWidth||0)&&(vi.maxWidth=li)}const Li=0,Ai=1,Wi=2;const{top:Oi,right:Ti,bottom:Ci,left:Mi}=O;function Pi(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 Di={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[Mi],a-=l[Ti]+l[Mi]):i.autoSizeAlign||(n=l[Mi]),o?(s=l[Oi],o-=l[Oi]+l[Ci]):i.autoSizeAlign||(s=l[Oi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){vi=t,Bi=t.rows,xi=t.bounds,bi=!xi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=xi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;mi=!0,pi=null,fi=ui=_i=di=li=0,oi={data:[]},ri={words:[]};for(let n=0,l=i.length;n<l;n++)ci=i[n],"\n"===ci?(di&&Ri(),ri.paraEnd=!0,Ei(),mi=!0):(gi=Ze(ci),gi===ti&&"none"!==o&&(ci=Je(ci,o,!di)),ui=r.measureText(ci).width,s&&(s<0&&(_i=ui),ui+=s),wi=gi===ei&&(pi===ei||pi===ti)||pi===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||pi!==si&&pi!==ni),hi=mi&&a?d-a:d,t&&d&&li+di+ui>hi&&(e?(di&&Ri(),li&&Ei()):(yi||(yi=gi===ti&&pi==ni),wi||yi||gi===ai||gi===ii||gi===ei||di+ui>hi?(di&&Ri(),li&&Ei()):li&&Ei()))," "===ci&&!0!==mi&&li+di===0||(gi===ai?(" "===ci&&di&&Ri(),ki(ci,ui),Ri()):wi||yi?(di&&Ri(),ki(ci,ui)):ki(ci,ui)),pi=gi);di&&Ri(),li&&Ei(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{vi.paraNumber++,li=r.measureText(t).width,Bi.push({x:a||0,text:t,width:li,paraStart:!0}),bi&&Si()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Pi(e,"x",t[Mi]);break;case"right":Pi(e,"x",-t[Ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Pi(e,"y",t[Oi]);break;case"bottom":Pi(e,"y",-t[Ci])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:_,height:g}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>g)p=Math.max(g,s),t.overflow=i.length;else if(g||c)switch(l){case"middle":f+=(g-p)/2;break;case"bottom":f+=g-p}w+=f;let y,m,v,x=_||c?_:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<_||y.width>_&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&("justify"===a||"both"===a)&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Li:l>.01?Ai:Wi,t.isOverflow&&!r&&(t.textMode=!0),c===Wi?(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===Ai?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,i),h}};const Ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(Y,Di),Object.assign(P,Ii),Object.assign(G,bt),Object.assign(M,ne),Object.assign(D,xe),Object.assign(z,Ae),Object.assign(n,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new C}),X();export{st as Layouter,H as LeaferCanvas,dt as Picker,ot as Renderer,lt as Selector,j as Watcher,X as useCanvas};
|
package/dist/worker.js
CHANGED
|
@@ -6010,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6010
6010
|
}
|
|
6011
6011
|
}
|
|
6012
6012
|
|
|
6013
|
-
const version = "1.3.
|
|
6013
|
+
const version = "1.3.2";
|
|
6014
6014
|
|
|
6015
6015
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6016
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -6542,7 +6542,7 @@ var LeaferUI = (function (exports) {
|
|
|
6542
6542
|
partRender() {
|
|
6543
6543
|
const { canvas, updateBlocks: list } = this;
|
|
6544
6544
|
if (!list)
|
|
6545
|
-
return
|
|
6545
|
+
return;
|
|
6546
6546
|
this.mergeBlocks();
|
|
6547
6547
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6548
6548
|
this.clipRender(block); });
|
|
@@ -7398,7 +7398,7 @@ var LeaferUI = (function (exports) {
|
|
|
7398
7398
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7399
7399
|
return Plugin.need('animate');
|
|
7400
7400
|
}
|
|
7401
|
-
killAnimate(_type,
|
|
7401
|
+
killAnimate(_type, _nextStyle) { }
|
|
7402
7402
|
export(_filename, _options) {
|
|
7403
7403
|
return Plugin.need('export');
|
|
7404
7404
|
}
|
|
@@ -7894,8 +7894,6 @@ var LeaferUI = (function (exports) {
|
|
|
7894
7894
|
this.created = true;
|
|
7895
7895
|
}
|
|
7896
7896
|
__onReady() {
|
|
7897
|
-
if (this.ready)
|
|
7898
|
-
return;
|
|
7899
7897
|
this.ready = true;
|
|
7900
7898
|
this.emitLeafer(LeaferEvent.BEFORE_READY);
|
|
7901
7899
|
this.emitLeafer(LeaferEvent.READY);
|
|
@@ -7909,6 +7907,20 @@ var LeaferUI = (function (exports) {
|
|
|
7909
7907
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
7910
7908
|
WaitHelper.run(this.__viewReadyWait);
|
|
7911
7909
|
}
|
|
7910
|
+
__onLayoutEnd() {
|
|
7911
|
+
const { grow, growWidth, growHeight } = this.config;
|
|
7912
|
+
if (grow) {
|
|
7913
|
+
let { width, height, pixelRatio } = this;
|
|
7914
|
+
const bounds = grow === 'box' ? this.worldBoxBounds : this.__world;
|
|
7915
|
+
if (growWidth !== false)
|
|
7916
|
+
width = Math.max(1, bounds.x + bounds.width);
|
|
7917
|
+
if (growHeight !== false)
|
|
7918
|
+
height = Math.max(1, bounds.y + bounds.height);
|
|
7919
|
+
this.__doResize({ width, height, pixelRatio });
|
|
7920
|
+
}
|
|
7921
|
+
if (!this.ready)
|
|
7922
|
+
this.__onReady();
|
|
7923
|
+
}
|
|
7912
7924
|
__onNextRender() {
|
|
7913
7925
|
if (this.viewReady) {
|
|
7914
7926
|
WaitHelper.run(this.__nextRenderWait);
|
|
@@ -8002,10 +8014,9 @@ var LeaferUI = (function (exports) {
|
|
|
8002
8014
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8003
8015
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
8004
8016
|
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
8005
|
-
this.once(LayoutEvent.END, () => this.__onReady());
|
|
8006
8017
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
8007
8018
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
8008
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8019
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8009
8020
|
}
|
|
8010
8021
|
__removeListenEvents() {
|
|
8011
8022
|
this.off_(this.__eventIds);
|
|
@@ -11252,7 +11263,7 @@ var LeaferUI = (function (exports) {
|
|
|
11252
11263
|
rows.forEach(row => {
|
|
11253
11264
|
if (row.words) {
|
|
11254
11265
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
11255
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11266
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11256
11267
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
11257
11268
|
if (row.isOverflow && !letterSpacing)
|
|
11258
11269
|
row.textMode = true;
|
|
@@ -11274,7 +11285,7 @@ var LeaferUI = (function (exports) {
|
|
|
11274
11285
|
else {
|
|
11275
11286
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
11276
11287
|
}
|
|
11277
|
-
if (!row.paraEnd
|
|
11288
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
11278
11289
|
charX += addWordWidth;
|
|
11279
11290
|
row.width += addWordWidth;
|
|
11280
11291
|
}
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +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:a}=t.FileHelper;function s(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.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.backgrounder=!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,y=t.Debug.get("Layouter");class m{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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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:a}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,a.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)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),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:a,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),m.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,r,this.times)),n.emitEvent(new t.LayoutEvent(s,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()}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)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),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,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),r=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,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 a=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,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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.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,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 a=i.through||!1,s=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,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),a?{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:a,y:s}=this.point,r={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(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 this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,r;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(r=a.list[t],!s||!s.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}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()}}class L{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function R(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?S(t,!0,e,n):P(e,n);break;case"inside":k("inside",t,a,e,n);break;case"outside":k("outside",t,a,e,n)}}function k(t,e,n,i,a){const{__strokeWidth:s,__font:r}=i.__,o=a.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*s,i.__),o.font=r,n?S(e,!0,i,o):P(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",E(i,o),o.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(o,i.__nowWorld):a.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function P(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function S(t,e,i,a){let s;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&n.PaintImage.checkImage(i,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?P(i,a):a.stroke(),a.restoreBlendMode()):e?P(i,a):a.stroke())}function C(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new L(t,e)}),t.Platform.layout=m.fullLayout;const{getSpread:A,getOuterOf:W,getByMove:O,getIntersectData:M}=t.BoundsHelper;let T;function I(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:r,color:o,opacity:d}=e;return{type:s,blendMode:r,style:n.ColorConvert.string(o,d)};case"image":return n.PaintImage.image(i,t,e,a,!T||!T[e.url]);case"linear":return n.PaintGradient.linearGradient(e,a);case"radial":return n.PaintGradient.radialGradient(e,a);case"angular":return n.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const D={compute:function(t,e){const i=e.__,a=[];let s,r=i.__input[t];r instanceof Array||(r=[r]),T=n.PaintImage.recycleImage(t,i);for(let n,i=0,s=r.length;i<s;i++)n=I(t,r[i],e),n&&a.push(n);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?E(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let a;const{windingRule:s,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)a=t[o],a.image&&n.PaintImage.checkImage(e,i,a,!r)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),r?E(e,i):s?i.fill(s):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),r?E(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):r?E(e,i):s?i.fill(s):i.fill())},fillText:E,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:r}=i;if(a)if(r)R(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&C(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:r}=i;if(a)if(r)R(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),S(t,!1,e,n),i.__useArrow&&C(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),S(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*a,i),S(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,s),r.recycle(e.__nowWorld)}},strokeText:R,drawTextStroke:P,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,r,o,d,{scaleX:l,scaleY:h}=a;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(a))d=i,s=o=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?A(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,a);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=W(a,r),s=O(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:s,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let H={};const{get:F,rotateOfOuter:G,translate:j,scaleOfOuter:Y,scale:z,rotate:q}=t.MatrixHelper;function U(t,e,n,i,a,s,r){const o=F();j(o,e.x+n,e.y+i),z(o,a,s),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function X(t,e,n,i,a,s,r){const o=F();j(o,e.x+n,e.y+i),a&&z(o,a,s),r&&q(o,r),t.transform=o}function N(t,e,n,i,a,s,r,o,d,l){const h=F();if(d)if("center"===l)G(h,{x:n/2,y:i/2},d);else switch(q(h,d),d){case 90:j(h,i,0);break;case 180:j(h,n,i);break;case 270:j(h,0,n)}H.x=e.x+a,H.y=e.y+s,j(h,H.x,H.y),r&&Y(h,H,r,o),t.transform=h}const{get:V,translate:Q}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function J(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=tt(n,i,e)}function tt(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:o,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===a&&n.height===s,p={mode:o},_="center"!==d&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(o&&"cover"!==o&&"fit"!==o)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!g||u){const t=n.width/w,e=n.height/y;m=v="fit"===o?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(d){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(d,e,n,K,!0),x+=K.x,b+=K.y}switch(l&&(x+=l.x,b+=l.y),o){case"stretch":g||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&X(p,n,x,b,m,v,u);break;case"repeat":(!g||m||u)&&N(p,n,a,s,x,b,m,v,u,d),f||(p.repeat="repeat");break;default:m&&U(p,n,x,b,m,v,u)}return p.transform||(n.x||n.y)&&(p.transform=V(),Q(p.transform,n.x,n.y)),m&&"stretch"!==o&&(p.scaleX=m,p.scaleY=v),p.width=a,p.height=s,r&&(p.opacity=r),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let et,nt=new t.Bounds;const{isSame:it}=t.BoundsHelper;function at(t,e,n,i,a,s){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 a.data||J(a,i,n,s),!0}function st(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function lt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ht,scale:ct,copy:ut}=t.MatrixHelper,{ceil:ft,abs:gt}=Math;function pt(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=a+"-"+s+"-"+i;if(n.patternId===r||e.destroyed)return!1;{a=gt(a),s=gt(s);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=ht(),ut(l,p),ct(l,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(a/=d,s/=d,h/=d,c/=d),u&&(a/=u,s/=f),(p||1!==a||1!==s)&&(l||(l=ht(),p&&ut(l,p)),ct(l,1/a,1/s));const m=e.getCanvas(ft(h)||1,ft(c)||1,g),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}function _t(t,e,n,i){return new(n||(n=Promise))((function(a,s){function r(t){try{d(i.next(t))}catch(t){s(t)}}function o(t){try{d(i.throw(t))}catch(t){s(t)}}function d(t){var e;t.done?a(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:wt}=Math;const yt={image:function(e,n,i,a,s){let r,o;const d=t.ImageManager.get(i);return et&&i===et.paint&&it(a,et.boxBounds)?r=et.leafPaint:(r={type:i.type,image:d},et=d.use>1?{leafPaint:r,paint:i,boxBounds:nt.set(a)}:null),(s||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(at(e,n,i,d,r,a),s&&(st(e,o),rt(e,o))):d.error?s&&ot(e,o,d.error):(s&&(lt(e,!0),st(e,o)),r.loadId=d.load((()=>{lt(e,!1),e.destroyed||(at(e,n,i,d,r,a)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,o)),r.loadId=null}),(t=>{lt(e,!1),ot(e,o,t),r.loadId=null}))),r},checkImage:function(e,i,a,s){const{scaleX:r,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=i;if(!a.data||a.patternId===r+"-"+o+"-"+d&&!n.Export.running)return!1;{const{data:l}=a;if(s)if(l.repeat)s=!1;else{let{width:e,height:i}=l;e*=wt(r)*d,i*=wt(o)*d,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),s=e*i>t.Platform.image.maxCacheSize||n.Export.running}return s?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),a.blendMode&&(i.blendMode=a.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(a.image.view,0,0,l.width,l.height),i.restore(),!0):(!a.style||a.sync||n.Export.running?pt(e,a,d):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>_t(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(e.__nowWorld)&&pt(e,a,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:pt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,r,o;for(let d=0,l=i.length;d<l;d++)a=i[d].image,o=a&&a.url,o&&(s||(s={}),s[o]=!0,t.ImageManager.recycle(a),a.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),a.unload(i[d].loadId,!r.some((t=>t.url===o)))));return s}return null},createData:J,getPatternData:tt,fillOrFitMode:U,clipMode:X,repeatMode:N},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,i){if(e){let a;for(let s=0,r=e.length;s<r;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(r-1),n.ColorConvert.string(a,i)):t.addColorStop(a.offset,n.ColorConvert.string(a.color,i))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:r,height:o}=t;if(r!==o||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,r/o*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,r/o*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Mt={},Tt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:r,opacity:o}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const d=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(d,e.stops,o);const l={type:s,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,blendMode:o,stretch:d}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const l=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(l,e.stops,r);const h={type:s,style:l},c=At(n,St,Ct,d,!0);return c&&(h.transform=c),o&&(h.blendMode=o),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,blendMode:o,stretch:d}=e;Ot(i||"center",n,Mt),Ot(a||"bottom",n,Tt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Mt.x,Mt.y):t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Wt(Mt,Tt));bt(l,e.stops,r);const h={type:s,style:l},c=At(n,Mt,Tt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),o&&(h.blendMode=o),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Gt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:r}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-r.x,Ft.y+=n.y-r.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,r,i?Ft:n)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,zt={};const qt={shadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Ht(l,Gt),o.forEach(((o,p)=>{f.setWorldShadow(Gt.offsetX+o.x*c,Gt.offsetY+o.y*u,o.blur*c,o.color),a=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(f,Gt,a,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,s,"copy"),i=s),d?f.copyWorld(d,s,s,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,s,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,a;const{__nowWorld:s,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Yt(l,zt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(zt.offsetX+o.x*c,zt.offsetY+o.y*u,o.blur*c),a=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(f,zt,a,n),f.restore(),d?(f.copyWorld(f,l,s,"copy"),f.copyWorld(d,s,s,"source-out"),i=s):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,s,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:Ut}=t.LeafBoundsHelper;function Xt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}n.Group.prototype.__renderMask=function(t,e){let n,i,a,s,r,o;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)n=d[l],o=n.__.mask,o&&(r&&(Xt(this,r,t,a,i,s),i=a=null),"path"===o||"clipping-path"===o?(n.opacity<1?(r="opacity-path",s=n.opacity,a||(a=Nt(t))):(r="path",t.save()),n.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==o&&"clipping-path"!==o)||Ut(n,e)||n.__render(a||t,e);Xt(this,r,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Zt=Qt+"_#~&*+\\=|≮≯≈≠=…",Kt=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 $t(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Jt=$t("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=$t("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=$t(Qt),ne=$t(Zt),ie=$t("- —/~|┆·");var ae;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ae||(ae={}));const{Letter:se,Single:re,Before:oe,After:de,Symbol:le,Break:he}=ae;function ce(t){return Jt[t]?se:ie[t]?he:te[t]?oe:ee[t]?de:ne[t]?le:Kt.test(t)?re:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(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:ge}=ue,{Letter:pe,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Me,Te,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ge(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Me&&(Te.paraNumber++,be.paraStart=!0,Me=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?ge(be):De&&Ye(),He.push(be),be={words:[]},Le=0}function Ye(){Le>(Te.maxWidth||0)&&(Te.maxWidth=Le)}const ze=0,qe=1,Ue=2;const{top:Xe,right:Ne,bottom:Ve,left:Qe}=t.Direction4;function Ze(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ke={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(s?(i=l[Qe],s-=l[Ne]+l[Qe]):n.autoSizeAlign||(i=l[Qe]),r?(a=l[Xe],r-=l[Xe]+l[Ve]):n.autoSizeAlign||(a=l[Xe]));const h={bounds:{x:i,y:a,width:s,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Te=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ie;if(d||l||a||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Me=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,l=n.length;i<l;i++)Re=n[i],"\n"===Re?(Be&&Ge(),be.paraEnd=!0,je(),Me=!0):(Ce=ce(Re),Ce===pe&&"none"!==r&&(Re=fe(Re,r,!Be)),ke=o.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===pe)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Me&&s?d-s:d,t&&d&&Le+Be+ke>Ee&&(e?(Be&&Ge(),Le&&je()):(Oe||(Oe=Ce===pe&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ge(),Le&&je()):Le&&je()))," "===Re&&!0!==Me&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ge(),Fe(Re,ke),Ge()):We||Oe?(Be&&Ge(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ge(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Te.paraNumber++,Le=o.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ye()}))}(h,e,n),l&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ze(e,"x",t[Qe]);break;case"right":Ze(e,"x",-t[Ne])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ze(e,"y",t[Xe]);break;case"bottom":Ze(e,"y",-t[Ve])}}(l,h,n,s,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(o&&_>p)_=Math.max(p,a),t.overflow=n.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let s=0,l=n.length;s<l;s++){if(y=n[s],y.x=u,y.width<g||y.width>g&&!o)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+1),m=y.x,v=y.width,r<0&&(y.width<0?(v=-y.width+e.fontSize+r,m-=v,v+=e.fontSize):v-=r),m<i.x&&(i.x=m),v>i.width&&(i.width=v),o&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:a}=t,{textAlign:s,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;a.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===s&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?ze:l>.01?qe:Ue,t.isOverflow&&!o&&(t.textMode=!0),c===Ue?(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===qe?(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,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;if(s.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+a-l;("none"===n.textWrap?s:[s[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,s),"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 $e={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(n.TextConvert,Ke),Object.assign(n.ColorConvert,$e),Object.assign(n.Paint,D),Object.assign(n.PaintImage,yt),Object.assign(n.PaintGradient,It),Object.assign(n.Effect,qt),Object.assign(t.Creator,{interaction:(t,n,i,a)=>new e.InteractionBase(t,n,i,a),hitCanvas:(t,e)=>new i(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),s(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=i,exports.Picker=B,exports.Renderer=x,exports.Selector=L,exports.Watcher=o,exports.useCanvas=s,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),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.backgrounder=!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,y=t.Debug.get("Layouter");class m{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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),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)),m.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()}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)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),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 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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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.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,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 this.target&&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.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()}}class L{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,s){return this.finder?this.finder.getBy(e,n,i,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function E(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 R(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?S(t,!0,e,n):P(e,n);break;case"inside":k("inside",t,s,e,n);break;case"outside":k("outside",t,s,e,n)}}function k(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?S(e,!0,i,o):P(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",E(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 P(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 S(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?P(i,s):s.stroke(),s.restoreBlendMode()):e?P(i,s):s.stroke())}function C(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new L(t,e)}),t.Platform.layout=m.fullLayout;const{getSpread:A,getOuterOf:W,getByMove:O,getIntersectData:M}=t.BoundsHelper;let T;function I(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,!T||!T[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 D={compute:function(t,e){const i=e.__,s=[];let a,r=i.__input[t];r instanceof Array||(r=[r]),T=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=r.length;i<a;i++)n=I(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?E(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?E(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?E(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):r?E(e,i):a?i.fill(a):i.fill())},fillText:E,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)R(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&C(e,n);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)R(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),S(t,!1,e,n),i.__useArrow&&C(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),S(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),S(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:R,drawTextStroke:P,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=M(i?A(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=W(s,r),a=O(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 H={};const{get:F,rotateOfOuter:G,translate:j,scaleOfOuter:Y,scale:z,rotate:q}=t.MatrixHelper;function U(t,e,n,i,s,a,r){const o=F();j(o,e.x+n,e.y+i),z(o,s,a),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function X(t,e,n,i,s,a,r){const o=F();j(o,e.x+n,e.y+i),s&&z(o,s,a),r&&q(o,r),t.transform=o}function N(t,e,n,i,s,a,r,o,d,l){const h=F();if(d)if("center"===l)G(h,{x:n/2,y:i/2},d);else switch(q(h,d),d){case 90:j(h,i,0);break;case 180:j(h,n,i);break;case 270:j(h,0,n)}H.x=e.x+s,H.y=e.y+a,j(h,H.x,H.y),r&&Y(h,H,r,o),t.transform=h}const{get:V,translate:Q}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function J(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=tt(n,i,e)}function tt(e,n,i){let{width:s,height:a}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");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,y=_?s:a;let m,v,x=0,b=0;if(o&&"cover"!==o&&"fit"!==o)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!g||u){const t=n.width/w,e=n.height/y;m=v="fit"===o?Math.min(t,e):Math.max(t,e),x+=(n.width-s*m)/2,b+=(n.height-a*v)/2}if(d){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(d,e,n,K,!0),x+=K.x,b+=K.y}switch(l&&(x+=l.x,b+=l.y),o){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||b||m||u)&&X(p,n,x,b,m,v,u);break;case"repeat":(!g||m||u)&&N(p,n,s,a,x,b,m,v,u,d),f||(p.repeat="repeat");break;default:m&&U(p,n,x,b,m,v,u)}return p.transform||(n.x||n.y)&&(p.transform=V(),Q(p.transform,n.x,n.y)),m&&"stretch"!==o&&(p.scaleX=m,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 et,nt=new t.Bounds;const{isSame:it}=t.BoundsHelper;function st(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||J(s,i,n,a),!0}function at(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function lt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ht,scale:ct,copy:ut}=t.MatrixHelper,{ceil:ft,abs:gt}=Math;function pt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=gt(s),a=gt(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=ht(),ut(l,p),ct(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 y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=ht(),p&&ut(l,p)),ct(l,1/s,1/a));const m=e.getCanvas(ft(h)||1,ft(c)||1,g),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}function _t(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:wt}=Math;const yt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return et&&i===et.paint&&it(s,et.boxBounds)?r=et.leafPaint:(r={type:i.type,image:d},et=d.use>1?{leafPaint:r,paint:i,boxBounds:nt.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(st(e,n,i,d,r,s),a&&(at(e,o),rt(e,o))):d.error?a&&ot(e,o,d.error):(a&&(lt(e,!0),at(e,o)),r.loadId=d.load((()=>{lt(e,!1),e.destroyed||(st(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,o)),r.loadId=null}),(t=>{lt(e,!1),ot(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,{pixelRatio:d}=i;if(!s.data||s.patternId===r+"-"+o+"-"+d&&!n.Export.running)return!1;{const{data:l}=s;if(a)if(l.repeat)a=!1;else{let{width:e,height:i}=l;e*=wt(r)*d,i*=wt(o)*d,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),a=e*i>t.Platform.image.maxCacheSize||n.Export.running}return a?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(s.image.view,0,0,l.width,l.height),i.restore(),!0):(!s.style||s.sync||n.Export.running?pt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>_t(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&pt(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:pt,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:J,getPatternData:tt,fillOrFitMode:U,clipMode:X,repeatMode:N},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,i){if(e){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:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,s){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Bt(e,n);a=Et(),s?(kt(a,e,r/o*(i||1),1),Rt(a,e,t+90)):(kt(a,e,1,r/o*(i||1)),Rt(a,e,t))}return a}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Mt={},Tt={};const It={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;mt(i||"top",n,vt),mt(s||"bottom",n,xt);const d=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(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;Pt(i||"center",n,St),Pt(s||"bottom",n,Ct);const l=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(l,e.stops,r);const h={type:a,style:l},c=At(n,St,Ct,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;Ot(i||"center",n,Mt),Ot(s||"bottom",n,Tt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Mt.x,Mt.y):t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Wt(Mt,Tt));bt(l,e.stops,r);const h={type:a,style:l},c=At(n,Mt,Tt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),o&&(h.blendMode=o),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Gt={};function jt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-r.x,Ft.y+=n.y-r.y,i){const{matrix:t}=s;Ft.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Ft.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(s.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(s.canvas,r,i?Ft:n)}const{toOffsetOutBounds:Yt}=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;Ht(l,Gt),o.forEach(((o,p)=>{f.setWorldShadow(Gt.offsetX+o.x*c,Gt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(f,Gt,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;Yt(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,jt(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:Ut}=t.LeafBoundsHelper;function Xt(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Vt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Vt(t,n,i,a);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Vt(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,o;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)n=d[l],o=n.__.mask,o&&(r&&(Xt(this,r,t,s,i,a),i=s=null),"path"===o||"clipping-path"===o?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=Nt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=Nt(t)),s||(s=Nt(t)),n.__render(i,e)),"clipping"!==o&&"clipping-path"!==o)||Ut(n,e)||n.__render(s||t,e);Xt(this,r,t,s,i,a)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Zt=Qt+"_#~&*+\\=|≮≯≈≠=…",Kt=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 $t(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Jt=$t("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=$t("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=$t(Qt),ne=$t(Zt),ie=$t("- —/~|┆·");var se;!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"}(se||(se={}));const{Letter:ae,Single:re,Before:oe,After:de,Symbol:le,Break:he}=se;function ce(t){return Jt[t]?ae:ie[t]?he:te[t]?oe:ee[t]?de:ne[t]?le:Kt.test(t)?re:ae}const ue={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 fe(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:ge}=ue,{Letter:pe,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=se;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Me,Te,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ge(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Me&&(Te.paraNumber++,be.paraStart=!0,Me=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?ge(be):De&&Ye(),He.push(be),be={words:[]},Le=0}function Ye(){Le>(Te.maxWidth||0)&&(Te.maxWidth=Le)}const ze=0,qe=1,Ue=2;const{top:Xe,right:Ne,bottom:Ve,left:Qe}=t.Direction4;function Ze(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 Ke={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[Qe],a-=l[Ne]+l[Qe]):n.autoSizeAlign||(i=l[Qe]),r?(s=l[Xe],r-=l[Xe]+l[Ve]):n.autoSizeAlign||(s=l[Xe]));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){Te=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ie;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Me=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,l=n.length;i<l;i++)Re=n[i],"\n"===Re?(Be&&Ge(),be.paraEnd=!0,je(),Me=!0):(Ce=ce(Re),Ce===pe&&"none"!==r&&(Re=fe(Re,r,!Be)),ke=o.measureText(Re).width,s&&(s<0&&(Se=ke),ke+=s),We=Ce===_e&&(Ae===_e||Ae===pe)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Me&&a?d-a:d,t&&d&&Le+Be+ke>Ee&&(e?(Be&&Ge(),Le&&je()):(Oe||(Oe=Ce===pe&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ge(),Le&&je()):Le&&je()))," "===Re&&!0!==Me&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ge(),Fe(Re,ke),Ge()):We||Oe?(Be&&Ge(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ge(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Te.paraNumber++,Le=o.measureText(t).width,He.push({x:a||0,text:t,width:Le,paraStart:!0}),De&&Ye()}))}(h,e,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ze(e,"x",t[Qe]);break;case"right":Ze(e,"x",-t[Ne])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ze(e,"y",t[Xe]);break;case"bottom":Ze(e,"y",-t[Ve])}}(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,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=a;if(o&&_>p)_=Math.max(p,s),t.overflow=n.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=n.length;a<l;a++){if(y=n[a],y.x=u,y.width<g||y.width>g&&!o)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>_&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,r<0&&(y.width<0?(v=-y.width+e.fontSize+r,m-=v,v+=e.fontSize):v-=r),m<i.x&&(i.x=m),v>i.width&&(i.width=v),o&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(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||"both"===a)&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?ze:l>.01?qe:Ue,t.isOverflow&&!o&&(t.textMode=!0),c===Ue?(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===qe?(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),!l||t.paraEnd&&"both"!==a||(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 $e={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(n.TextConvert,Ke),Object.assign(n.ColorConvert,$e),Object.assign(n.Paint,D),Object.assign(n.PaintImage,yt),Object.assign(n.PaintGradient,It),Object.assign(n.Effect,qt),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=m,exports.LeaferCanvas=i,exports.Picker=B,exports.Renderer=x,exports.Selector=L,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]}})}));
|