@leafer-ui/miniapp 1.3.0 → 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/miniapp.cjs +3 -3
- package/dist/miniapp.esm.js +3 -3
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +20 -9
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +11 -11
package/dist/miniapp.cjs
CHANGED
|
@@ -673,7 +673,7 @@ class Renderer {
|
|
|
673
673
|
partRender() {
|
|
674
674
|
const { canvas, updateBlocks: list } = this;
|
|
675
675
|
if (!list)
|
|
676
|
-
return
|
|
676
|
+
return;
|
|
677
677
|
this.mergeBlocks();
|
|
678
678
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
679
679
|
this.clipRender(block); });
|
|
@@ -2325,7 +2325,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2325
2325
|
rows.forEach(row => {
|
|
2326
2326
|
if (row.words) {
|
|
2327
2327
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2328
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2328
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2329
2329
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2330
2330
|
if (row.isOverflow && !letterSpacing)
|
|
2331
2331
|
row.textMode = true;
|
|
@@ -2347,7 +2347,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2347
2347
|
else {
|
|
2348
2348
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2349
2349
|
}
|
|
2350
|
-
if (!row.paraEnd
|
|
2350
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2351
2351
|
charX += addWordWidth;
|
|
2352
2352
|
row.width += addWordWidth;
|
|
2353
2353
|
}
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -674,7 +674,7 @@ class Renderer {
|
|
|
674
674
|
partRender() {
|
|
675
675
|
const { canvas, updateBlocks: list } = this;
|
|
676
676
|
if (!list)
|
|
677
|
-
return
|
|
677
|
+
return;
|
|
678
678
|
this.mergeBlocks();
|
|
679
679
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
680
680
|
this.clipRender(block); });
|
|
@@ -2326,7 +2326,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2326
2326
|
rows.forEach(row => {
|
|
2327
2327
|
if (row.words) {
|
|
2328
2328
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2329
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2329
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2330
2330
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2331
2331
|
if (row.isOverflow && !letterSpacing)
|
|
2332
2332
|
row.textMode = true;
|
|
@@ -2348,7 +2348,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2348
2348
|
else {
|
|
2349
2349
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2350
2350
|
}
|
|
2351
|
-
if (!row.paraEnd
|
|
2351
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2352
2352
|
charX += addWordWidth;
|
|
2353
2353
|
row.width += addWordWidth;
|
|
2354
2354
|
}
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as c,RenderEvent as l,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as S,Plugin as R,MatrixHelper as k,MathHelper as L,AlignHelper as T,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as M,InteractionBase as O,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as D,PaintGradient as z,Export as F,Group as U,TextConvert as Y,Paint as V,Effect as G,Leafer as j}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:X}=d;function q(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(N(X(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new H(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.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===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:K,updateBounds:Z,updateAllWorldOpacity:$}=p,{pushAllChildBranch:J,pushAllParent:tt}=_;const{worldBounds:et}=y,it={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:nt,updateAllChange:ot}=p,at=m.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&J(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=m.get("Renderer");class dt{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=s.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(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new w,ht.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),B.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,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 ht.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!m.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),m.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),m.showHitView&&this.renderHitView(s),m.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:t}=this;if(t){const e=new w;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 w(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 w(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||ht.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_(x.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.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:ct}=S;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new c(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new c;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),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 c;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,s=new c;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new c,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ct(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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 ut{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,i,s){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new ut(t,e)}),e.layout=rt.fullLayout;const ft={convertTouch(t,e){const i=ft.getTouch(t),s=M.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class gt extends O{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ft.getTouch(t);this.pointerDown(ft.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ft.getTouch(t);this.pointerMove(ft.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ft.getTouch(t);this.pointerUp(ft.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(M.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function pt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function _t(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?mt(t,!0,e,i):yt(e,i);break;case"inside":wt("inside",t,n,e,i);break;case"outside":wt("outside",t,n,e,i)}}function wt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?mt(e,!0,s,r):yt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",pt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function mt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?yt(i,s):s.stroke(),s.restoreBlendMode()):e?yt(i,s):s.stroke())}function vt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:xt,getOuterOf:bt,getByMove:Bt,getIntersectData:St}=S;let Rt;function kt(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:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:D.string(a,r)};case"image":return I.image(i,t,e,s,!Rt||!Rt[e.url]);case"linear":return z.linearGradient(e,s);case"radial":return z.radialGradient(e,s);case"angular":return z.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Lt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Rt=I.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=kt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?pt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?pt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?pt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?pt(e,i):n?i.fill(n):i.fill())},fillText:pt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),mt(t,!1,e,i),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),mt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),mt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:_t,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:c}=n;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,l=St(s?xt(e.bounds,d===c?s*d:[s*c,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(l);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,c*=f),r=bt(n,a),o=Bt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:c}}};let Tt={};const{get:Et,rotateOfOuter:At,translate:Wt,scaleOfOuter:Ct,scale:Mt,rotate:Ot}=k;function Pt(t,e,i,s,n,o,a){const r=Et();Wt(r,e.x+i,e.y+s),Mt(r,n,o),a&&At(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function It(t,e,i,s,n,o,a){const r=Et();Wt(r,e.x+i,e.y+s),n&&Mt(r,n,o),a&&Ot(r,a),t.transform=r}function Dt(t,e,i,s,n,o,a,r,h,d){const c=Et();if(h)if("center"===d)At(c,{x:i/2,y:s/2},h);else switch(Ot(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}Tt.x=e.x+n,Tt.y=e.y+o,Wt(c,Tt.x,Tt.y),a&&Ct(c,Tt,a,r),t.transform=c}const{get:zt,translate:Ft}=k,Ut=new w,Yt={},Vt={};function Gt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=jt(i,s,e)}function jt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:d,size:c,rotation:l,repeat:u}=t,f=e.width===s&&e.height===n,g={mode:a},p="center"!==r&&(l||0)%180==90,_=p?n:s,w=p?s:n;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||c)&&(L.getScaleData(d,c,i,Vt),y=Vt.scaleX,m=Vt.scaleY);else if(!f||l){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),T.toPoint(r,t,e,Yt,!0),v+=Yt.x,x+=Yt.y}switch(h&&(v+=h.x,x+=h.y),a){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||y||l)&&It(g,e,v,x,y,m,l);break;case"repeat":(!f||y||l)&&Dt(g,e,s,n,v,x,y,m,l,r),u||(g.repeat="repeat");break;default:y&&Pt(g,e,v,x,y,m,l)}return g.transform||(e.x||e.y)&&(g.transform=zt(),Ft(g.transform,e.x,e.y)),y&&"stretch"!==a&&(g.scaleX=y,g.scaleY=m),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Ht,Nt=new w;const{isSame:Xt}=S;function qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Gt(n,s,i,o),!0}function Qt(t,e){$t(t,E.LOAD,e)}function Kt(t,e){$t(t,E.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,E.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,scale:ee,copy:ie}=k,{ceil:se,abs:ne}=Math;function oe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ne(n),o=ne(o);const{image:t,data:r}=i;let h,d,{width:c,height:l,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=te(),ie(d,p),ee(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,c*=n,l*=o;const w=c*l;if(!_&&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&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,c/=h,l/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=te(),p&&ie(d,p)),ee(d,1/n,1/o));const m=t.getCanvas(se(c)||1,se(l)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function ae(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:re}=Math;const he={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Ht&&i===Ht.paint&&Xt(s,Ht.boxBounds)?o=Ht.leafPaint:(o={type:i.type,image:r},Ht=r.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(qt(t,e,i,r,o,s),n&&(Qt(t,a),Kt(t,a))):r.error?n&&Zt(t,a,r.error):(n&&(Jt(t,!0),Qt(t,a)),o.loadId=r.load((()=>{Jt(t,!1),t.destroyed||(qt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{Jt(t,!1),Zt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:i}=h;t*=re(o)*r,i*=re(a)*r,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize||F.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||F.running?oe(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ae(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&oe(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:oe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Gt,getPatternData:jt,fillOrFitMode:Pt,clipMode:It,repeatMode:Dt},{toPoint:de}=A,ce={},le={};function ue(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),D.string(s,i)):t.addColorStop(s.offset,D.string(s.color,i))}}const{getAngle:fe,getDistance:ge}=W,{get:pe,rotateOfOuter:_e,scaleOfOuter:we}=k,{toPoint:ye}=A,me={},ve={};function xe(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=fe(e,i);o=pe(),n?(we(o,e,a/r*(s||1),1),_e(o,e,t+90)):(we(o,e,1,a/r*(s||1)),_e(o,e,t))}return o}const{getDistance:be}=W,{toPoint:Be}=A,Se={},Re={};const ke={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;de(s||"top",i,ce),de(n||"bottom",i,le);const h=e.canvas.createLinearGradient(ce.x,ce.y,le.x,le.y);ue(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;ye(s||"center",i,me),ye(n||"bottom",i,ve);const d=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,ge(me,ve));ue(d,t.stops,a);const c={type:o,style:d},l=xe(i,me,ve,h,!0);return l&&(c.transform=l),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Be(s||"center",i,Se),Be(n||"bottom",i,Re);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,be(Se,Re));ue(d,t.stops,a);const c={type:o,style:d},l=xe(i,Se,Re,h||1,e.conicGradientRotate90);return l&&(c.transform=l),r&&(c.blendMode=r),c},getTransform:xe},{copy:Le,toOffsetOutBounds:Te}=S,Ee={},Ae={};function We(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Le(Ee,t.bounds),Ee.x+=i.x-a.x,Ee.y+=i.y-a.y,s){const{matrix:t}=n;Ee.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Ee.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Ee.width*=s,Ee.height*=s}t.copyWorld(n.canvas,t.bounds,Ee)}else s&&(Le(Ee,i),Ee.x-=i.width/2*(s-1),Ee.y-=i.height/2*(s-1),Ee.width*=s,Ee.height*=s),t.copyWorld(n.canvas,a,s?Ee:i)}const{toOffsetOutBounds:Ce}=S,Me={};const Oe={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Te(d,Ae),r.forEach(((r,p)=>{f.setWorldShadow(Ae.offsetX+r.x*l,Ae.offsetY+r.y*u,r.blur*l,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,We(f,Ae,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ce(d,Me),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Me.offsetX+r.x*l,Me.offsetY+r.y*u,r.blur*l),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,We(f,Me,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Pe}=y;function Ie(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),ze(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ze(t,i,s,o);break;case"path":i.restore()}}function De(t){return t.getSameCanvas(!1,!0)}function ze(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}U.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let d=0,c=h.length;d<c;d++)i=h[d],r=i.__.mask,r&&(a&&(Ie(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=De(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=De(t)),n||(n=De(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Pe(i,e)||i.__render(n||t,e);Ie(this,a,t,n,s,o)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),je=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=Ve(Fe),Ne=Ve(Ue),Xe=Ve("- —/~|┆·");var qe;!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"}(qe||(qe={}));const{Letter:Qe,Single:Ke,Before:Ze,After:$e,Symbol:Je,Break:ti}=qe;function ei(t){return Ge[t]?Qe:Xe[t]?ti:je[t]?Ze:He[t]?$e:Ne[t]?Je:Ye.test(t)?Ke:Qe}const ii={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function si(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:ni}=ii,{Letter:oi,Single:ai,Before:ri,After:hi,Symbol:di,Break:ci}=qe;let li,ui,fi,gi,pi,_i,wi,yi,mi,vi,xi,bi,Bi,Si,Ri,ki,Li,Ti=[];function Ei(t,e){mi&&!yi&&(yi=mi),li.data.push({char:t,width:e}),fi+=e}function Ai(){gi+=fi,li.width=fi,ui.words.push(li),li={data:[]},fi=0}function Wi(){Si&&(Ri.paraNumber++,ui.paraStart=!0,Si=!1),mi&&(ui.startCharSize=yi,ui.endCharSize=mi,yi=0),ui.width=gi,ki.width?ni(ui):Li&&Ci(),Ti.push(ui),ui={words:[]},gi=0}function Ci(){gi>(Ri.maxWidth||0)&&(Ri.maxWidth=gi)}const Mi=0,Oi=1,Pi=2;const{top:Ii,right:Di,bottom:zi,left:Fi}=C;function Ui(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o?(s=d[Fi],o-=d[Di]+d[Fi]):i.autoSizeAlign||(s=d[Fi]),a?(n=d[Ii],a-=d[Ii]+d[zi]):i.autoSizeAlign||(n=d[Ii]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Ri=t,Ti=t.rows,ki=t.bounds,Li=!ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=ki;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Si=!0,xi=null,yi=wi=mi=fi=gi=0,li={data:[]},ui={words:[]};for(let s=0,d=i.length;s<d;s++)_i=i[s],"\n"===_i?(fi&&Ai(),ui.paraEnd=!0,Wi(),Si=!0):(vi=ei(_i),vi===oi&&"none"!==a&&(_i=si(_i,a,!fi)),wi=r.measureText(_i).width,n&&(n<0&&(mi=wi),wi+=n),bi=vi===ai&&(xi===ai||xi===oi)||xi===ai&&vi!==hi,Bi=!(vi!==ri&&vi!==ai||xi!==di&&xi!==hi),pi=Si&&o?h-o:h,t&&h&&gi+fi+wi>pi&&(e?(fi&&Ai(),gi&&Wi()):(Bi||(Bi=vi===oi&&xi==hi),bi||Bi||vi===ci||vi===ri||vi===ai||fi+wi>pi?(fi&&Ai(),gi&&Wi()):gi&&Wi()))," "===_i&&!0!==Si&&gi+fi===0||(vi===ci?(" "===_i&&fi&&Ai(),Ei(_i,wi),Ai()):bi||Bi?(fi&&Ai(),Ei(_i,wi)):Ei(_i,wi)),xi=vi);fi&&Ai(),gi&&Wi(),Ti.length>0&&(Ti[Ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ri.paraNumber++,gi=r.measureText(t).width,Ti.push({x:o||0,text:t,width:gi,paraStart:!0}),Li&&Ci()}))}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ui(e,"x",t[Fi]);break;case"right":Ui(e,"x",-t[Di])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ui(e,"y",t[Ii]);break;case"bottom":Ui(e,"y",-t[zi])}}(d,c,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:c,autoSizeAlign:l}=e;let{x:u,y:f,width:g,height:p}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,n),t.overflow=i.length;else if(p||l)switch(d){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let y,m,v,x=g||l?g:t.maxWidth;for(let o=0,d=i.length;o<d;o++){if(y=i[o],y.x=u,y.width<g||y.width>g&&!r)switch(h){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=n,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<s.x&&(s.x=m),v>s.width&&(s.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=_}(c,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,c,l,u;n.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,l=r||t.isOverflow?Mi:d>.01?Oi:Pi,t.isOverflow&&!r&&(t.textMode=!0),l===Pi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{l===Oi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,s,o),"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}}(c,i),c}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(Y,Yi),Object.assign(D,Vi),Object.assign(V,Lt),Object.assign(I,he),Object.assign(z,ke),Object.assign(G,Oe),Object.assign(a,{interaction:(t,e,i,s)=>new gt(t,e,i,s),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new P}),j.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&q(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=k.get()),k.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{gt as Interaction,rt as Layouter,H as LeaferCanvas,lt as Picker,dt as Renderer,ut as Selector,Q as Watcher,q as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as c,RenderEvent as l,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as S,Plugin as R,MatrixHelper as k,MathHelper as L,AlignHelper as T,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as M,InteractionBase as O,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as D,PaintGradient as z,Export as F,Group as U,TextConvert as Y,Paint as V,Effect as G,Leafer as j}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:N,fileType:X}=d;function q(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(N(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(N(X(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new H(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.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===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:K,updateBounds:Z,updateAllWorldOpacity:$}=p,{pushAllChildBranch:J,pushAllParent:tt}=_;const{worldBounds:et}=y,it={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:nt,updateAllChange:ot}=p,at=m.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&J(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),rt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=m.get("Renderer");class dt{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=s.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(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new w,ht.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),B.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,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=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!m.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),m.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),m.showHitView&&this.renderHitView(s),m.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:t}=this;if(t){const e=new w;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 w(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 w(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||ht.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_(x.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.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:ct}=S;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new c(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new c;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),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 c;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,s=new c;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new c,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ct(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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 ut{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,i,s){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new ut(t,e)}),e.layout=rt.fullLayout;const ft={convertTouch(t,e){const i=ft.getTouch(t),s=M.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class gt extends O{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ft.getTouch(t);this.pointerDown(ft.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ft.getTouch(t);this.pointerMove(ft.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ft.getTouch(t);this.pointerUp(ft.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(M.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function pt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function _t(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?mt(t,!0,e,i):yt(e,i);break;case"inside":wt("inside",t,n,e,i);break;case"outside":wt("outside",t,n,e,i)}}function wt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?mt(e,!0,s,r):yt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",pt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function mt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?yt(i,s):s.stroke(),s.restoreBlendMode()):e?yt(i,s):s.stroke())}function vt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:xt,getOuterOf:bt,getByMove:Bt,getIntersectData:St}=S;let Rt;function kt(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:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:D.string(a,r)};case"image":return I.image(i,t,e,s,!Rt||!Rt[e.url]);case"linear":return z.linearGradient(e,s);case"radial":return z.radialGradient(e,s);case"angular":return z.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Lt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Rt=I.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=kt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?pt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?pt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?pt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?pt(e,i):n?i.fill(n):i.fill())},fillText:pt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),mt(t,!1,e,i),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),mt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),mt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:_t,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:c}=n;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,l=St(s?xt(e.bounds,d===c?s*d:[s*c,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(l);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,c*=f),r=bt(n,a),o=Bt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:c}}};let Tt={};const{get:Et,rotateOfOuter:At,translate:Wt,scaleOfOuter:Ct,scale:Mt,rotate:Ot}=k;function Pt(t,e,i,s,n,o,a){const r=Et();Wt(r,e.x+i,e.y+s),Mt(r,n,o),a&&At(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function It(t,e,i,s,n,o,a){const r=Et();Wt(r,e.x+i,e.y+s),n&&Mt(r,n,o),a&&Ot(r,a),t.transform=r}function Dt(t,e,i,s,n,o,a,r,h,d){const c=Et();if(h)if("center"===d)At(c,{x:i/2,y:s/2},h);else switch(Ot(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}Tt.x=e.x+n,Tt.y=e.y+o,Wt(c,Tt.x,Tt.y),a&&Ct(c,Tt,a,r),t.transform=c}const{get:zt,translate:Ft}=k,Ut=new w,Yt={},Vt={};function Gt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=jt(i,s,e)}function jt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:d,size:c,rotation:l,repeat:u}=t,f=e.width===s&&e.height===n,g={mode:a},p="center"!==r&&(l||0)%180==90,_=p?n:s,w=p?s:n;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||c)&&(L.getScaleData(d,c,i,Vt),y=Vt.scaleX,m=Vt.scaleY);else if(!f||l){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),T.toPoint(r,t,e,Yt,!0),v+=Yt.x,x+=Yt.y}switch(h&&(v+=h.x,x+=h.y),a){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||y||l)&&It(g,e,v,x,y,m,l);break;case"repeat":(!f||y||l)&&Dt(g,e,s,n,v,x,y,m,l,r),u||(g.repeat="repeat");break;default:y&&Pt(g,e,v,x,y,m,l)}return g.transform||(e.x||e.y)&&(g.transform=zt(),Ft(g.transform,e.x,e.y)),y&&"stretch"!==a&&(g.scaleX=y,g.scaleY=m),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Ht,Nt=new w;const{isSame:Xt}=S;function qt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Gt(n,s,i,o),!0}function Qt(t,e){$t(t,E.LOAD,e)}function Kt(t,e){$t(t,E.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,E.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,scale:ee,copy:ie}=k,{ceil:se,abs:ne}=Math;function oe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ne(n),o=ne(o);const{image:t,data:r}=i;let h,d,{width:c,height:l,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=te(),ie(d,p),ee(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,c*=n,l*=o;const w=c*l;if(!_&&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&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,c/=h,l/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=te(),p&&ie(d,p)),ee(d,1/n,1/o));const m=t.getCanvas(se(c)||1,se(l)||1,g),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function ae(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:re}=Math;const he={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Ht&&i===Ht.paint&&Xt(s,Ht.boxBounds)?o=Ht.leafPaint:(o={type:i.type,image:r},Ht=r.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(qt(t,e,i,r,o,s),n&&(Qt(t,a),Kt(t,a))):r.error?n&&Zt(t,a,r.error):(n&&(Jt(t,!0),Qt(t,a)),o.loadId=r.load((()=>{Jt(t,!1),t.destroyed||(qt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{Jt(t,!1),Zt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!F.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:i}=h;t*=re(o)*r,i*=re(a)*r,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize||F.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||F.running?oe(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ae(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&oe(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:oe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Gt,getPatternData:jt,fillOrFitMode:Pt,clipMode:It,repeatMode:Dt},{toPoint:de}=A,ce={},le={};function ue(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),D.string(s,i)):t.addColorStop(s.offset,D.string(s.color,i))}}const{getAngle:fe,getDistance:ge}=W,{get:pe,rotateOfOuter:_e,scaleOfOuter:we}=k,{toPoint:ye}=A,me={},ve={};function xe(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=fe(e,i);o=pe(),n?(we(o,e,a/r*(s||1),1),_e(o,e,t+90)):(we(o,e,1,a/r*(s||1)),_e(o,e,t))}return o}const{getDistance:be}=W,{toPoint:Be}=A,Se={},Re={};const ke={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;de(s||"top",i,ce),de(n||"bottom",i,le);const h=e.canvas.createLinearGradient(ce.x,ce.y,le.x,le.y);ue(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;ye(s||"center",i,me),ye(n||"bottom",i,ve);const d=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,ge(me,ve));ue(d,t.stops,a);const c={type:o,style:d},l=xe(i,me,ve,h,!0);return l&&(c.transform=l),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Be(s||"center",i,Se),Be(n||"bottom",i,Re);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,be(Se,Re));ue(d,t.stops,a);const c={type:o,style:d},l=xe(i,Se,Re,h||1,e.conicGradientRotate90);return l&&(c.transform=l),r&&(c.blendMode=r),c},getTransform:xe},{copy:Le,toOffsetOutBounds:Te}=S,Ee={},Ae={};function We(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Le(Ee,t.bounds),Ee.x+=i.x-a.x,Ee.y+=i.y-a.y,s){const{matrix:t}=n;Ee.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Ee.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Ee.width*=s,Ee.height*=s}t.copyWorld(n.canvas,t.bounds,Ee)}else s&&(Le(Ee,i),Ee.x-=i.width/2*(s-1),Ee.y-=i.height/2*(s-1),Ee.width*=s,Ee.height*=s),t.copyWorld(n.canvas,a,s?Ee:i)}const{toOffsetOutBounds:Ce}=S,Me={};const Oe={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Te(d,Ae),r.forEach(((r,p)=>{f.setWorldShadow(Ae.offsetX+r.x*l,Ae.offsetY+r.y*u,r.blur*l,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,We(f,Ae,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ce(d,Me),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Me.offsetX+r.x*l,Me.offsetY+r.y*u,r.blur*l),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,We(f,Me,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Pe}=y;function Ie(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),ze(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ze(t,i,s,o);break;case"path":i.restore()}}function De(t){return t.getSameCanvas(!1,!0)}function ze(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}U.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let d=0,c=h.length;d<c;d++)i=h[d],r=i.__.mask,r&&(a&&(Ie(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=De(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=De(t)),n||(n=De(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Pe(i,e)||i.__render(n||t,e);Ie(this,a,t,n,s,o)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),je=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),He=Ve(Fe),Ne=Ve(Ue),Xe=Ve("- —/~|┆·");var qe;!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"}(qe||(qe={}));const{Letter:Qe,Single:Ke,Before:Ze,After:$e,Symbol:Je,Break:ti}=qe;function ei(t){return Ge[t]?Qe:Xe[t]?ti:je[t]?Ze:He[t]?$e:Ne[t]?Je:Ye.test(t)?Ke:Qe}const ii={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function si(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:ni}=ii,{Letter:oi,Single:ai,Before:ri,After:hi,Symbol:di,Break:ci}=qe;let li,ui,fi,gi,pi,_i,wi,yi,mi,vi,xi,bi,Bi,Si,Ri,ki,Li,Ti=[];function Ei(t,e){mi&&!yi&&(yi=mi),li.data.push({char:t,width:e}),fi+=e}function Ai(){gi+=fi,li.width=fi,ui.words.push(li),li={data:[]},fi=0}function Wi(){Si&&(Ri.paraNumber++,ui.paraStart=!0,Si=!1),mi&&(ui.startCharSize=yi,ui.endCharSize=mi,yi=0),ui.width=gi,ki.width?ni(ui):Li&&Ci(),Ti.push(ui),ui={words:[]},gi=0}function Ci(){gi>(Ri.maxWidth||0)&&(Ri.maxWidth=gi)}const Mi=0,Oi=1,Pi=2;const{top:Ii,right:Di,bottom:zi,left:Fi}=C;function Ui(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o?(s=d[Fi],o-=d[Di]+d[Fi]):i.autoSizeAlign||(s=d[Fi]),a?(n=d[Ii],a-=d[Ii]+d[zi]):i.autoSizeAlign||(n=d[Ii]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Ri=t,Ti=t.rows,ki=t.bounds,Li=!ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=ki;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Si=!0,xi=null,yi=wi=mi=fi=gi=0,li={data:[]},ui={words:[]};for(let s=0,d=i.length;s<d;s++)_i=i[s],"\n"===_i?(fi&&Ai(),ui.paraEnd=!0,Wi(),Si=!0):(vi=ei(_i),vi===oi&&"none"!==a&&(_i=si(_i,a,!fi)),wi=r.measureText(_i).width,n&&(n<0&&(mi=wi),wi+=n),bi=vi===ai&&(xi===ai||xi===oi)||xi===ai&&vi!==hi,Bi=!(vi!==ri&&vi!==ai||xi!==di&&xi!==hi),pi=Si&&o?h-o:h,t&&h&&gi+fi+wi>pi&&(e?(fi&&Ai(),gi&&Wi()):(Bi||(Bi=vi===oi&&xi==hi),bi||Bi||vi===ci||vi===ri||vi===ai||fi+wi>pi?(fi&&Ai(),gi&&Wi()):gi&&Wi()))," "===_i&&!0!==Si&&gi+fi===0||(vi===ci?(" "===_i&&fi&&Ai(),Ei(_i,wi),Ai()):bi||Bi?(fi&&Ai(),Ei(_i,wi)):Ei(_i,wi)),xi=vi);fi&&Ai(),gi&&Wi(),Ti.length>0&&(Ti[Ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ri.paraNumber++,gi=r.measureText(t).width,Ti.push({x:o||0,text:t,width:gi,paraStart:!0}),Li&&Ci()}))}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ui(e,"x",t[Fi]);break;case"right":Ui(e,"x",-t[Di])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ui(e,"y",t[Ii]);break;case"bottom":Ui(e,"y",-t[zi])}}(d,c,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:c,autoSizeAlign:l}=e;let{x:u,y:f,width:g,height:p}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,n),t.overflow=i.length;else if(p||l)switch(d){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let y,m,v,x=g||l?g:t.maxWidth;for(let o=0,d=i.length;o<d;o++){if(y=i[o],y.x=u,y.width<g||y.width>g&&!r)switch(h){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=n,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<s.x&&(s.x=m),v>s.width&&(s.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=_}(c,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,c,l,u;n.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=i&&("justify"===o||"both"===o)&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,l=r||t.isOverflow?Mi:d>.01?Oi:Pi,t.isOverflow&&!r&&(t.textMode=!0),l===Pi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{l===Oi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==o||(h+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,s,o),"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}}(c,i),c}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(Y,Yi),Object.assign(D,Vi),Object.assign(V,Lt),Object.assign(I,he),Object.assign(z,ke),Object.assign(G,Oe),Object.assign(a,{interaction:(t,e,i,s)=>new gt(t,e,i,s),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new P}),j.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&q(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=k.get()),k.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{gt as Interaction,rt as Layouter,H as LeaferCanvas,lt as Picker,dt as Renderer,ut as Selector,Q as Watcher,q as useCanvas};
|
package/dist/miniapp.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=t.Platform.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:i,height:n,pixelRatio:s}=this.config,o={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.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)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,i){this.resizeListener=i,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:o}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let a=e.toDataURL(s(o(i)),n);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,i)},download:(e,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:e=>new Promise(((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:i}=t.Platform.renderCanvas||t.Platform.canvas;i.requestAnimationFrame?i.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!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:h,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(h(t,!0),e.add(t),t.isBranch&&c(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||l(n[t])}l(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),n.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,a,this.times)),y.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,a,this.times)),i.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.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,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),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 i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};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=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){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:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){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,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(a);const{list:r}=this.findList,h=this.getBestMatchLeaf(r,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:h}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,a={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,a;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(a=s.list[t],!o||!o.has(a));t++)i.add(a)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||b(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 L{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,i,n)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=y.fullLayout;const E={convertTouch(t,i){const n=E.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class R extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=E.getTouch(t);this.pointerDown(E.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=E.getTouch(t);this.pointerMove(E.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=E.getTouch(t);this.pointerUp(E.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function S(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function k(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?C(t,!0,e,i):T(e,i);break;case"inside":P("inside",t,s,e,i);break;case"outside":P("outside",t,s,e,i)}}function P(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?C(e,!0,n,r):T(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",S(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 T(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function C(t,e,n,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?T(n,s):s.stroke(),s.restoreBlendMode()):e?T(n,s):s.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:M,getOuterOf:W,getByMove:O,getIntersectData:I}=t.BoundsHelper;let D;function H(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:a,color:r,opacity:h}=e;return{type:o,blendMode:a,style:i.ColorConvert.string(r,h)};case"image":return i.PaintImage.image(n,t,e,s,!D||!D[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const z={compute:function(t,e){const n=e.__,s=[];let o,a=n.__input[t];a instanceof Array||(a=[a]),D=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)i=H(t,a[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,e.__.__font?S(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:o,__font:a}=e.__;for(let r=0,h=t.length;r<h;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!a)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):a?S(e,n):o?n.fill(o):n.fill())},fillText:S,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&A(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 o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),C(t,!1,e,i),n.__useArrow&&A(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),C(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),C(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:T,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=I(n?M(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=f),r=W(s,a),o=O(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:l,scaleY:d}}};let F={};const{get:j,rotateOfOuter:G,translate:U,scaleOfOuter:Y,scale:V,rotate:q}=t.MatrixHelper;function N(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),V(r,s,o),a&&G(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function X(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),s&&V(r,s,o),a&&q(r,a),t.transform=r}function Q(t,e,i,n,s,o,a,r,h,l){const d=j();if(h)if("center"===l)G(d,{x:i/2,y:n/2},h);else switch(q(d,h),h){case 90:U(d,n,0);break;case 180:U(d,i,n);break;case 270:U(d,0,i)}F.x=e.x+s,F.y=e.y+o,U(d,F.x,F.y),a&&Y(d,F,a,r),t.transform=d}const{get:K,translate:Z}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=it(i,n,e)}function it(e,i,n){let{width:s,height:o}=n;e.padding&&(i=$.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:f}=e,g=i.width===s&&i.height===o,p={mode:r},_="center"!==h&&(u||0)%180==90,w=_?o:s,m=_?s:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,tt),y=tt.scaleX,v=tt.scaleY);else if(!g||u){const t=i.width/w,e=i.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(i.width-s*y)/2,b+=(i.height-o*v)/2}if(h){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(h,e,i,J,!0),x+=J.x,b+=J.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":g||(s=i.width,o=i.height);break;case"normal":case"clip":(x||b||y||u)&&X(p,i,x,b,y,v,u);break;case"repeat":(!g||y||u)&&Q(p,i,s,o,x,b,y,v,u,h),f||(p.repeat="repeat");break;default:y&&N(p,i,x,b,y,v,u)}return p.transform||(i.x||i.y)&&(p.transform=K(),Z(p.transform,i.x,i.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let nt,st=new t.Bounds;const{isSame:ot}=t.BoundsHelper;function at(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||et(s,n,i,o),!0}function rt(e,i){dt(e,t.ImageEvent.LOAD,i)}function ht(e,i){dt(e,t.ImageEvent.LOADED,i)}function lt(e,i,n){i.error=n,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,i)}function dt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function ct(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ut,scale:ft,copy:gt}=t.MatrixHelper,{ceil:pt,abs:_t}=Math;function wt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||e.destroyed)return!1;{s=_t(s),o=_t(o);const{image:e,data:r}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=ut(),gt(l,p),ft(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,d*=s,c*=o;const w=d*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(h=Math.sqrt(w/m)),h&&(s/=h,o/=h,d/=h,c/=h),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=ut(),p&>(l,p)),ft(l,1/s,1/o));const y=e.getCanvas(pt(d)||1,pt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function mt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function r(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:yt}=Math;const vt={image:function(e,i,n,s,o){let a,r;const h=t.ImageManager.get(n);return nt&&n===nt.paint&&ot(s,nt.boxBounds)?a=nt.leafPaint:(a={type:n.type,image:h},nt=h.use>1?{leafPaint:a,paint:n,boxBounds:st.set(s)}:null),(o||h.loading)&&(r={image:h,attrName:i,attrValue:n}),h.ready?(at(e,i,n,h,a,s),o&&(rt(e,r),ht(e,r))):h.error?o&<(e,r,h.error):(o&&(ct(e,!0),rt(e,r)),a.loadId=h.load((()=>{ct(e,!1),e.destroyed||(at(e,i,n,h,a,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,r)),a.loadId=null}),(t=>{ct(e,!1),lt(e,r,t),a.loadId=null}))),a},checkImage:function(e,n,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===a+"-"+r+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=yt(a)*h,n*=yt(r)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(s.image.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?wt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&wt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:wt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,a,r;for(let h=0,l=n.length;h<l;h++)s=n[h].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=i.__input&&i.__input[e]||[],a instanceof Array||(a=[a])),s.unload(n[h].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:et,getPatternData:it,fillOrFitMode:N,clipMode:X,repeatMode:Q},{toPoint:xt}=t.AroundHelper,bt={},Bt={};function Lt(t,e,n){if(e){let s;for(let o=0,a=e.length;o<a;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(a-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Et,getDistance:Rt}=t.PointHelper,{get:St,rotateOfOuter:kt,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:Tt}=t.AroundHelper,Ct={},At={};function Mt(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Et(e,i);o=St(),s?(Pt(o,e,a/r*(n||1),1),kt(o,e,t+90)):(Pt(o,e,1,a/r*(n||1)),kt(o,e,t))}return o}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,It={},Dt={};const Ht={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=e;xt(n||"top",i,bt),xt(s||"bottom",i,Bt);const h=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Bt.x,Bt.y);Lt(h,e.stops,r);const l={type:o,style:h};return a&&(l.blendMode=a),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Tt(n||"center",i,Ct),Tt(s||"bottom",i,At);const l=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Rt(Ct,At));Lt(l,e.stops,a);const d={type:o,style:l},c=Mt(i,Ct,At,h,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Ot(n||"center",i,It),Ot(s||"bottom",i,Dt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,It.x,It.y):t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Wt(It,Dt));Lt(l,e.stops,a);const d={type:o,style:l},c=Mt(i,It,Dt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},getTransform:Mt},{copy:zt,toOffsetOutBounds:Ft}=t.BoundsHelper,jt={},Gt={};function Ut(e,i,n,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(zt(jt,e.bounds),jt.x+=i.x-a.x,jt.y+=i.y-a.y,n){const{matrix:t}=s;jt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),jt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),jt.width*=n,jt.height*=n}e.copyWorld(s.canvas,e.bounds,jt)}else n&&(zt(jt,i),jt.x-=i.width/2*(n-1),jt.y-=i.height/2*(n-1),jt.width*=n,jt.height*=n),e.copyWorld(s.canvas,a,n?jt:i)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,Vt={};const qt={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ft(l,Gt),r.forEach(((r,p)=>{f.setWorldShadow(Gt.offsetX+r.x*c,Gt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ut(f,Gt,s,i),n=l,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,o,"copy"),n=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Yt(l,Vt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*c,Vt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ut(f,Vt,s,i),f.restore(),h?(f.copyWorld(f,l,o,"copy"),f.copyWorld(h,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,d,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<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:Nt}=t.LeafBoundsHelper;function Xt(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Kt(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Kt(t,i,n,o);break;case"path":i.restore()}}function Qt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],r=i.__.mask,r&&(a&&(Xt(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Qt(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Qt(t)),s||(s=Qt(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Nt(i,e)||i.__render(s||t,e);Xt(this,a,t,s,n,o)};const Zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$t=Zt+"_#~&*+\\=|≮≯≈≠=…",Jt=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 te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ee=te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ie=te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ne=te(Zt),se=te($t),oe=te("- —/~|┆·");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:re,Single:he,Before:le,After:de,Symbol:ce,Break:ue}=ae;function fe(t){return ee[t]?re:oe[t]?ue:ie[t]?le:ne[t]?de:se[t]?ce:Jt.test(t)?he:re}const ge={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function pe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:_e}=ge,{Letter:we,Single:me,Before:ye,After:ve,Symbol:xe,Break:be}=ae;let Be,Le,Ee,Re,Se,ke,Pe,Te,Ce,Ae,Me,We,Oe,Ie,De,He,ze,Fe=[];function je(t,e){Ce&&!Te&&(Te=Ce),Be.data.push({char:t,width:e}),Ee+=e}function Ge(){Re+=Ee,Be.width=Ee,Le.words.push(Be),Be={data:[]},Ee=0}function Ue(){Ie&&(De.paraNumber++,Le.paraStart=!0,Ie=!1),Ce&&(Le.startCharSize=Te,Le.endCharSize=Ce,Te=0),Le.width=Re,He.width?_e(Le):ze&&Ye(),Fe.push(Le),Le={words:[]},Re=0}function Ye(){Re>(De.maxWidth||0)&&(De.maxWidth=Re)}const Ve=0,qe=1,Ne=2;const{top:Xe,right:Qe,bottom:Ke,left:Ze}=t.Direction4;function $e(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 Je={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:l}=i;l&&(o?(n=l[Ze],o-=l[Qe]+l[Ze]):i.autoSizeAlign||(n=l[Ze]),a?(s=l[Xe],a-=l[Xe]+l[Ke]):i.autoSizeAlign||(s=l[Xe]));const d={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){De=e,Fe=e.rows,He=e.bounds,ze=!He.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=t.Platform,{width:h,height:l}=He;if(h||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ie=!0,Me=null,Te=Pe=Ce=Ee=Re=0,Be={data:[]},Le={words:[]};for(let n=0,l=i.length;n<l;n++)ke=i[n],"\n"===ke?(Ee&&Ge(),Le.paraEnd=!0,Ue(),Ie=!0):(Ae=fe(ke),Ae===we&&"none"!==a&&(ke=pe(ke,a,!Ee)),Pe=r.measureText(ke).width,s&&(s<0&&(Ce=Pe),Pe+=s),We=Ae===me&&(Me===me||Me===we)||Me===me&&Ae!==ve,Oe=!(Ae!==ye&&Ae!==me||Me!==xe&&Me!==ve),Se=Ie&&o?h-o:h,t&&h&&Re+Ee+Pe>Se&&(e?(Ee&&Ge(),Re&&Ue()):(Oe||(Oe=Ae===we&&Me==ve),We||Oe||Ae===be||Ae===ye||Ae===me||Ee+Pe>Se?(Ee&&Ge(),Re&&Ue()):Re&&Ue()))," "===ke&&!0!==Ie&&Re+Ee===0||(Ae===be?(" "===ke&&Ee&&Ge(),je(ke,Pe),Ge()):We||Oe?(Ee&&Ge(),je(ke,Pe)):je(ke,Pe)),Me=Ae);Ee&&Ge(),Re&&Ue(),Fe.length>0&&(Fe[Fe.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{De.paraNumber++,Re=r.measureText(t).width,Fe.push({x:o||0,text:t,width:Re,paraStart:!0}),ze&&Ye()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Qe])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":$e(e,"y",t[Xe]);break;case"bottom":$e(e,"y",-t[Ke])}}(l,d,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,s),t.overflow=i.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(m=i[o],m.x=u,m.width<g||m.width>g&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&d&&o>0&&(w+=d),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<n.x&&(n.x=y),v>n.width&&(n.width=v),r&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=r||t.isOverflow?Ve:l>.01?qe:Ne,t.isOverflow&&!r&&(t.textMode=!0),c===Ne?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===qe?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let e,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,d=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<d));n--){if(h<d&&" "!==e.char){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,n,o),"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}}(d,i),d}};const ti={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,Je),Object.assign(i.ColorConvert,ti),Object.assign(i.Paint,z),Object.assign(i.PaintImage,vt),Object.assign(i.PaintGradient,Ht),Object.assign(i.Effect,qt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new R(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&a(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(t.LeaferImage.prototype.getPattern=function(e,i,n,s){const o=t.Platform.canvas.createPattern(this.view,i),{width:a,height:r}=e;this.width===a&&this.height===r||(n||(n=t.MatrixHelper.get()),t.MatrixHelper.scale(n,a/this.width,r/this.height));try{n&&o.setTransform&&(o.setTransform(n),n=null)}catch(t){}return s&&(s.transform=n),o}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=R,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=B,exports.Renderer=x,exports.Selector=L,exports.Watcher=r,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=t.Platform.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:i,height:n,pixelRatio:s}=this.config,o={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.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)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,i){this.resizeListener=i,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,n={width:t,height:e,pixelRatio:i};this.isSameSize(n)||this.emitResize(n)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:o}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas:(t,e,n)=>{const s={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(s):i.createOffScreenCanvas(s)},canvasToDataURL:(t,e,i)=>t.toDataURL(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let a=e.toDataURL(s(o(i)),n);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,i)},download:(e,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:e=>new Promise(((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:i}=t.Platform.renderCanvas||t.Platform.canvas;i.requestAnimationFrame?i.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!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:h,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(h(t,!0),e.add(t),t.isBranch&&c(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||l(n[t])}l(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),n.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,a,this.times)),y.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,a,this.times)),i.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.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,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};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=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){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:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){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,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(a);const{list:r}=this.findList,h=this.getBestMatchLeaf(r,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:h}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,a={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,a;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(a=s.list[t],!o||!o.has(a));t++)i.add(a)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||b(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 L{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,i,n)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=y.fullLayout;const E={convertTouch(t,i){const n=E.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class R extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=E.getTouch(t);this.pointerDown(E.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=E.getTouch(t);this.pointerMove(E.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=E.getTouch(t);this.pointerUp(E.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function S(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function k(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?C(t,!0,e,i):T(e,i);break;case"inside":P("inside",t,s,e,i);break;case"outside":P("outside",t,s,e,i)}}function P(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?C(e,!0,n,r):T(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",S(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 T(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function C(t,e,n,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?T(n,s):s.stroke(),s.restoreBlendMode()):e?T(n,s):s.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:M,getOuterOf:W,getByMove:O,getIntersectData:I}=t.BoundsHelper;let D;function H(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:a,color:r,opacity:h}=e;return{type:o,blendMode:a,style:i.ColorConvert.string(r,h)};case"image":return i.PaintImage.image(n,t,e,s,!D||!D[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const z={compute:function(t,e){const n=e.__,s=[];let o,a=n.__input[t];a instanceof Array||(a=[a]),D=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)i=H(t,a[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,e.__.__font?S(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:o,__font:a}=e.__;for(let r=0,h=t.length;r<h;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!a)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):a?S(e,n):o?n.fill(o):n.fill())},fillText:S,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&A(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 o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),C(t,!1,e,i),n.__useArrow&&A(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),C(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),C(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:T,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=I(n?M(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=f),r=W(s,a),o=O(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:l,scaleY:d}}};let F={};const{get:j,rotateOfOuter:G,translate:U,scaleOfOuter:Y,scale:V,rotate:q}=t.MatrixHelper;function N(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),V(r,s,o),a&&G(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function X(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),s&&V(r,s,o),a&&q(r,a),t.transform=r}function Q(t,e,i,n,s,o,a,r,h,l){const d=j();if(h)if("center"===l)G(d,{x:i/2,y:n/2},h);else switch(q(d,h),h){case 90:U(d,n,0);break;case 180:U(d,i,n);break;case 270:U(d,0,i)}F.x=e.x+s,F.y=e.y+o,U(d,F.x,F.y),a&&Y(d,F,a,r),t.transform=d}const{get:K,translate:Z}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=it(i,n,e)}function it(e,i,n){let{width:s,height:o}=n;e.padding&&(i=$.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:f}=e,g=i.width===s&&i.height===o,p={mode:r},_="center"!==h&&(u||0)%180==90,w=_?o:s,m=_?s:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,tt),y=tt.scaleX,v=tt.scaleY);else if(!g||u){const t=i.width/w,e=i.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(i.width-s*y)/2,b+=(i.height-o*v)/2}if(h){const e={x:x,y:b,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(h,e,i,J,!0),x+=J.x,b+=J.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":g||(s=i.width,o=i.height);break;case"normal":case"clip":(x||b||y||u)&&X(p,i,x,b,y,v,u);break;case"repeat":(!g||y||u)&&Q(p,i,s,o,x,b,y,v,u,h),f||(p.repeat="repeat");break;default:y&&N(p,i,x,b,y,v,u)}return p.transform||(i.x||i.y)&&(p.transform=K(),Z(p.transform,i.x,i.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let nt,st=new t.Bounds;const{isSame:ot}=t.BoundsHelper;function at(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||et(s,n,i,o),!0}function rt(e,i){dt(e,t.ImageEvent.LOAD,i)}function ht(e,i){dt(e,t.ImageEvent.LOADED,i)}function lt(e,i,n){i.error=n,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,i)}function dt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function ct(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ut,scale:ft,copy:gt}=t.MatrixHelper,{ceil:pt,abs:_t}=Math;function wt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||e.destroyed)return!1;{s=_t(s),o=_t(o);const{image:e,data:r}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=ut(),gt(l,p),ft(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,d*=s,c*=o;const w=d*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(h=Math.sqrt(w/m)),h&&(s/=h,o/=h,d/=h,c/=h),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=ut(),p&>(l,p)),ft(l,1/s,1/o));const y=e.getCanvas(pt(d)||1,pt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function mt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function r(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:yt}=Math;const vt={image:function(e,i,n,s,o){let a,r;const h=t.ImageManager.get(n);return nt&&n===nt.paint&&ot(s,nt.boxBounds)?a=nt.leafPaint:(a={type:n.type,image:h},nt=h.use>1?{leafPaint:a,paint:n,boxBounds:st.set(s)}:null),(o||h.loading)&&(r={image:h,attrName:i,attrValue:n}),h.ready?(at(e,i,n,h,a,s),o&&(rt(e,r),ht(e,r))):h.error?o&<(e,r,h.error):(o&&(ct(e,!0),rt(e,r)),a.loadId=h.load((()=>{ct(e,!1),e.destroyed||(at(e,i,n,h,a,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,r)),a.loadId=null}),(t=>{ct(e,!1),lt(e,r,t),a.loadId=null}))),a},checkImage:function(e,n,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===a+"-"+r+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=yt(a)*h,n*=yt(r)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(s.image.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?wt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&wt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:wt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,a,r;for(let h=0,l=n.length;h<l;h++)s=n[h].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=i.__input&&i.__input[e]||[],a instanceof Array||(a=[a])),s.unload(n[h].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:et,getPatternData:it,fillOrFitMode:N,clipMode:X,repeatMode:Q},{toPoint:xt}=t.AroundHelper,bt={},Bt={};function Lt(t,e,n){if(e){let s;for(let o=0,a=e.length;o<a;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(a-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Et,getDistance:Rt}=t.PointHelper,{get:St,rotateOfOuter:kt,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:Tt}=t.AroundHelper,Ct={},At={};function Mt(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Et(e,i);o=St(),s?(Pt(o,e,a/r*(n||1),1),kt(o,e,t+90)):(Pt(o,e,1,a/r*(n||1)),kt(o,e,t))}return o}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,It={},Dt={};const Ht={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=e;xt(n||"top",i,bt),xt(s||"bottom",i,Bt);const h=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Bt.x,Bt.y);Lt(h,e.stops,r);const l={type:o,style:h};return a&&(l.blendMode=a),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Tt(n||"center",i,Ct),Tt(s||"bottom",i,At);const l=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Rt(Ct,At));Lt(l,e.stops,a);const d={type:o,style:l},c=Mt(i,Ct,At,h,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Ot(n||"center",i,It),Ot(s||"bottom",i,Dt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,It.x,It.y):t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Wt(It,Dt));Lt(l,e.stops,a);const d={type:o,style:l},c=Mt(i,It,Dt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},getTransform:Mt},{copy:zt,toOffsetOutBounds:Ft}=t.BoundsHelper,jt={},Gt={};function Ut(e,i,n,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(zt(jt,e.bounds),jt.x+=i.x-a.x,jt.y+=i.y-a.y,n){const{matrix:t}=s;jt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),jt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),jt.width*=n,jt.height*=n}e.copyWorld(s.canvas,e.bounds,jt)}else n&&(zt(jt,i),jt.x-=i.width/2*(n-1),jt.y-=i.height/2*(n-1),jt.width*=n,jt.height*=n),e.copyWorld(s.canvas,a,n?jt:i)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,Vt={};const qt={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ft(l,Gt),r.forEach(((r,p)=>{f.setWorldShadow(Gt.offsetX+r.x*c,Gt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ut(f,Gt,s,i),n=l,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,o,"copy"),n=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Yt(l,Vt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*c,Vt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ut(f,Vt,s,i),f.restore(),h?(f.copyWorld(f,l,o,"copy"),f.copyWorld(h,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,d,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),g&&p<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:Nt}=t.LeafBoundsHelper;function Xt(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Kt(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Kt(t,i,n,o);break;case"path":i.restore()}}function Qt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],r=i.__.mask,r&&(a&&(Xt(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Qt(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Qt(t)),s||(s=Qt(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Nt(i,e)||i.__render(s||t,e);Xt(this,a,t,s,n,o)};const Zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$t=Zt+"_#~&*+\\=|≮≯≈≠=…",Jt=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 te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ee=te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ie=te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ne=te(Zt),se=te($t),oe=te("- —/~|┆·");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:re,Single:he,Before:le,After:de,Symbol:ce,Break:ue}=ae;function fe(t){return ee[t]?re:oe[t]?ue:ie[t]?le:ne[t]?de:se[t]?ce:Jt.test(t)?he:re}const ge={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function pe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:_e}=ge,{Letter:we,Single:me,Before:ye,After:ve,Symbol:xe,Break:be}=ae;let Be,Le,Ee,Re,Se,ke,Pe,Te,Ce,Ae,Me,We,Oe,Ie,De,He,ze,Fe=[];function je(t,e){Ce&&!Te&&(Te=Ce),Be.data.push({char:t,width:e}),Ee+=e}function Ge(){Re+=Ee,Be.width=Ee,Le.words.push(Be),Be={data:[]},Ee=0}function Ue(){Ie&&(De.paraNumber++,Le.paraStart=!0,Ie=!1),Ce&&(Le.startCharSize=Te,Le.endCharSize=Ce,Te=0),Le.width=Re,He.width?_e(Le):ze&&Ye(),Fe.push(Le),Le={words:[]},Re=0}function Ye(){Re>(De.maxWidth||0)&&(De.maxWidth=Re)}const Ve=0,qe=1,Ne=2;const{top:Xe,right:Qe,bottom:Ke,left:Ze}=t.Direction4;function $e(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 Je={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:l}=i;l&&(o?(n=l[Ze],o-=l[Qe]+l[Ze]):i.autoSizeAlign||(n=l[Ze]),a?(s=l[Xe],a-=l[Xe]+l[Ke]):i.autoSizeAlign||(s=l[Xe]));const d={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){De=e,Fe=e.rows,He=e.bounds,ze=!He.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=t.Platform,{width:h,height:l}=He;if(h||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ie=!0,Me=null,Te=Pe=Ce=Ee=Re=0,Be={data:[]},Le={words:[]};for(let n=0,l=i.length;n<l;n++)ke=i[n],"\n"===ke?(Ee&&Ge(),Le.paraEnd=!0,Ue(),Ie=!0):(Ae=fe(ke),Ae===we&&"none"!==a&&(ke=pe(ke,a,!Ee)),Pe=r.measureText(ke).width,s&&(s<0&&(Ce=Pe),Pe+=s),We=Ae===me&&(Me===me||Me===we)||Me===me&&Ae!==ve,Oe=!(Ae!==ye&&Ae!==me||Me!==xe&&Me!==ve),Se=Ie&&o?h-o:h,t&&h&&Re+Ee+Pe>Se&&(e?(Ee&&Ge(),Re&&Ue()):(Oe||(Oe=Ae===we&&Me==ve),We||Oe||Ae===be||Ae===ye||Ae===me||Ee+Pe>Se?(Ee&&Ge(),Re&&Ue()):Re&&Ue()))," "===ke&&!0!==Ie&&Re+Ee===0||(Ae===be?(" "===ke&&Ee&&Ge(),je(ke,Pe),Ge()):We||Oe?(Ee&&Ge(),je(ke,Pe)):je(ke,Pe)),Me=Ae);Ee&&Ge(),Re&&Ue(),Fe.length>0&&(Fe[Fe.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{De.paraNumber++,Re=r.measureText(t).width,Fe.push({x:o||0,text:t,width:Re,paraStart:!0}),ze&&Ye()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Qe])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":$e(e,"y",t[Xe]);break;case"bottom":$e(e,"y",-t[Ke])}}(l,d,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,s),t.overflow=i.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(m=i[o],m.x=u,m.width<g||m.width>g&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&d&&o>0&&(w+=d),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<n.x&&(n.x=y),v>n.width&&(n.width=v),r&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,l=i&&("justify"===o||"both"===o)&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=r||t.isOverflow?Ve:l>.01?qe:Ne,t.isOverflow&&!r&&(t.textMode=!0),c===Ne?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===qe?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==o||(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let e,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,d=n+s-l;("none"===i.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<d));n--){if(h<d&&" "!==e.char){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,n,o),"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}}(d,i),d}};const ti={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,Je),Object.assign(i.ColorConvert,ti),Object.assign(i.Paint,z),Object.assign(i.PaintImage,vt),Object.assign(i.PaintGradient,Ht),Object.assign(i.Effect,qt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new R(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&a(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(t.LeaferImage.prototype.getPattern=function(e,i,n,s){const o=t.Platform.canvas.createPattern(this.view,i),{width:a,height:r}=e;this.width===a&&this.height===r||(n||(n=t.MatrixHelper.get()),t.MatrixHelper.scale(n,a/this.width,r/this.height));try{n&&o.setTransform&&(o.setTransform(n),n=null)}catch(t){}return s&&(s.transform=n),o}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=R,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=B,exports.Renderer=x,exports.Selector=L,exports.Watcher=r,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]}})}));
|
package/dist/miniapp.module.js
CHANGED
|
@@ -6007,7 +6007,7 @@ class LeafLevelList {
|
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
6009
|
|
|
6010
|
-
const version = "1.3.
|
|
6010
|
+
const version = "1.3.2";
|
|
6011
6011
|
|
|
6012
6012
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6013
6013
|
get allowBackgroundColor() { return false; }
|
|
@@ -6678,7 +6678,7 @@ class Renderer {
|
|
|
6678
6678
|
partRender() {
|
|
6679
6679
|
const { canvas, updateBlocks: list } = this;
|
|
6680
6680
|
if (!list)
|
|
6681
|
-
return
|
|
6681
|
+
return;
|
|
6682
6682
|
this.mergeBlocks();
|
|
6683
6683
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6684
6684
|
this.clipRender(block); });
|
|
@@ -7534,7 +7534,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7534
7534
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7535
7535
|
return Plugin.need('animate');
|
|
7536
7536
|
}
|
|
7537
|
-
killAnimate(_type,
|
|
7537
|
+
killAnimate(_type, _nextStyle) { }
|
|
7538
7538
|
export(_filename, _options) {
|
|
7539
7539
|
return Plugin.need('export');
|
|
7540
7540
|
}
|
|
@@ -8030,8 +8030,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8030
8030
|
this.created = true;
|
|
8031
8031
|
}
|
|
8032
8032
|
__onReady() {
|
|
8033
|
-
if (this.ready)
|
|
8034
|
-
return;
|
|
8035
8033
|
this.ready = true;
|
|
8036
8034
|
this.emitLeafer(LeaferEvent.BEFORE_READY);
|
|
8037
8035
|
this.emitLeafer(LeaferEvent.READY);
|
|
@@ -8045,6 +8043,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8045
8043
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
8046
8044
|
WaitHelper.run(this.__viewReadyWait);
|
|
8047
8045
|
}
|
|
8046
|
+
__onLayoutEnd() {
|
|
8047
|
+
const { grow, growWidth, growHeight } = this.config;
|
|
8048
|
+
if (grow) {
|
|
8049
|
+
let { width, height, pixelRatio } = this;
|
|
8050
|
+
const bounds = grow === 'box' ? this.worldBoxBounds : this.__world;
|
|
8051
|
+
if (growWidth !== false)
|
|
8052
|
+
width = Math.max(1, bounds.x + bounds.width);
|
|
8053
|
+
if (growHeight !== false)
|
|
8054
|
+
height = Math.max(1, bounds.y + bounds.height);
|
|
8055
|
+
this.__doResize({ width, height, pixelRatio });
|
|
8056
|
+
}
|
|
8057
|
+
if (!this.ready)
|
|
8058
|
+
this.__onReady();
|
|
8059
|
+
}
|
|
8048
8060
|
__onNextRender() {
|
|
8049
8061
|
if (this.viewReady) {
|
|
8050
8062
|
WaitHelper.run(this.__nextRenderWait);
|
|
@@ -8138,10 +8150,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8138
8150
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8139
8151
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
8140
8152
|
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
8141
|
-
this.once(LayoutEvent.END, () => this.__onReady());
|
|
8142
8153
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
8143
8154
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
8144
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8155
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8145
8156
|
}
|
|
8146
8157
|
__removeListenEvents() {
|
|
8147
8158
|
this.off_(this.__eventIds);
|
|
@@ -11493,7 +11504,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
11493
11504
|
rows.forEach(row => {
|
|
11494
11505
|
if (row.words) {
|
|
11495
11506
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
11496
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11507
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11497
11508
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
11498
11509
|
if (row.isOverflow && !letterSpacing)
|
|
11499
11510
|
row.textMode = true;
|
|
@@ -11515,7 +11526,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
11515
11526
|
else {
|
|
11516
11527
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
11517
11528
|
}
|
|
11518
|
-
if (!row.paraEnd
|
|
11529
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
11519
11530
|
charX += addWordWidth;
|
|
11520
11531
|
row.width += addWordWidth;
|
|
11521
11532
|
}
|