@leafer-ui/miniapp 1.9.4 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/miniapp.cjs CHANGED
@@ -58,6 +58,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
58
58
  this.view = core.Platform.origin.createCanvas(1, 1);
59
59
  }
60
60
  updateViewSize() {
61
+ if (this.unreal) return;
61
62
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
62
63
  this.view.width = Math.ceil(width * pixelRatio);
63
64
  this.view.height = Math.ceil(height * pixelRatio);
@@ -69,6 +70,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
69
70
  });
70
71
  }
71
72
  startAutoLayout(autoBounds, listener) {
73
+ if (this.resizeListener) return;
72
74
  this.resizeListener = listener;
73
75
  if (autoBounds) {
74
76
  this.checkSize = this.checkSize.bind(this);
@@ -578,7 +580,7 @@ class Renderer {
578
580
  this.times = 0;
579
581
  this.config = {
580
582
  usePartRender: true,
581
- maxFPS: 60
583
+ maxFPS: 120
582
584
  };
583
585
  this.target = target;
584
586
  this.canvas = canvas;
@@ -733,11 +735,15 @@ class Renderer {
733
735
  if (this.requestTime || !target) return;
734
736
  if (target.parentApp) return target.parentApp.requestRender(false);
735
737
  const requestTime = this.requestTime = Date.now();
736
- core.Platform.requestRender(() => {
737
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
738
+ const render = () => {
739
+ const nowFPS = 1e3 / (Date.now() - requestTime);
740
+ const {maxFPS: maxFPS} = this.config;
741
+ if (maxFPS && nowFPS > maxFPS - .5) return core.Platform.requestRender(render);
742
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
738
743
  this.requestTime = 0;
739
744
  this.checkRender();
740
- });
745
+ };
746
+ core.Platform.requestRender(render);
741
747
  }
742
748
  __onResize(e) {
743
749
  if (this.canvas.unreal) return;
@@ -780,7 +786,8 @@ class Renderer {
780
786
  if (this.target) {
781
787
  this.stop();
782
788
  this.__removeListenEvents();
783
- this.target = this.canvas = this.config = null;
789
+ this.config = {};
790
+ this.target = this.canvas = null;
784
791
  }
785
792
  }
786
793
  }
@@ -1714,7 +1721,7 @@ function ignoreRender(ui, value) {
1714
1721
 
1715
1722
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1716
1723
 
1717
- const {floor: floor, max: max, abs: abs} = Math;
1724
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1718
1725
 
1719
1726
  function createPattern(ui, paint, pixelRatio) {
1720
1727
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1724,8 +1731,6 @@ function createPattern(ui, paint, pixelRatio) {
1724
1731
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1725
1732
  scaleX *= pixelRatio;
1726
1733
  scaleY *= pixelRatio;
1727
- const xGap = gap && gap.x * scaleX;
1728
- const yGap = gap && gap.y * scaleY;
1729
1734
  if (sx) {
1730
1735
  sx = abs(sx);
1731
1736
  sy = abs(sy);
@@ -1742,7 +1747,10 @@ function createPattern(ui, paint, pixelRatio) {
1742
1747
  if (size > core.Platform.image.maxCacheSize) return false;
1743
1748
  }
1744
1749
  let maxSize = core.Platform.image.maxPatternSize;
1745
- if (!image.isSVG) {
1750
+ if (image.isSVG) {
1751
+ const ws = width / image.width;
1752
+ if (ws > 1) imageScale = ws / ceil(ws);
1753
+ } else {
1746
1754
  const imageSize = image.width * image.height;
1747
1755
  if (maxSize > imageSize) maxSize = imageSize;
1748
1756
  }
@@ -1757,18 +1765,20 @@ function createPattern(ui, paint, pixelRatio) {
1757
1765
  scaleX /= sx;
1758
1766
  scaleY /= sy;
1759
1767
  }
1768
+ const xGap = gap && gap.x * scaleX;
1769
+ const yGap = gap && gap.y * scaleY;
1760
1770
  if (transform || scaleX !== 1 || scaleY !== 1) {
1771
+ const canvasWidth = width + (xGap || 0);
1772
+ const canvasHeight = height + (yGap || 0);
1773
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1774
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1761
1775
  if (!imageMatrix) {
1762
1776
  imageMatrix = get$1();
1763
1777
  if (transform) copy$1(imageMatrix, transform);
1764
1778
  }
1765
1779
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1766
1780
  }
1767
- if (imageMatrix) {
1768
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1769
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1770
- }
1771
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1781
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1772
1782
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1773
1783
  paint.style = pattern;
1774
1784
  paint.patternId = id;
@@ -62,6 +62,7 @@ class LeaferCanvas extends LeaferCanvasBase {
62
62
  this.view = Platform.origin.createCanvas(1, 1);
63
63
  }
64
64
  updateViewSize() {
65
+ if (this.unreal) return;
65
66
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
66
67
  this.view.width = Math.ceil(width * pixelRatio);
67
68
  this.view.height = Math.ceil(height * pixelRatio);
@@ -73,6 +74,7 @@ class LeaferCanvas extends LeaferCanvasBase {
73
74
  });
74
75
  }
75
76
  startAutoLayout(autoBounds, listener) {
77
+ if (this.resizeListener) return;
76
78
  this.resizeListener = listener;
77
79
  if (autoBounds) {
78
80
  this.checkSize = this.checkSize.bind(this);
@@ -582,7 +584,7 @@ class Renderer {
582
584
  this.times = 0;
583
585
  this.config = {
584
586
  usePartRender: true,
585
- maxFPS: 60
587
+ maxFPS: 120
586
588
  };
587
589
  this.target = target;
588
590
  this.canvas = canvas;
@@ -737,11 +739,15 @@ class Renderer {
737
739
  if (this.requestTime || !target) return;
738
740
  if (target.parentApp) return target.parentApp.requestRender(false);
739
741
  const requestTime = this.requestTime = Date.now();
740
- Platform.requestRender(() => {
741
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
742
+ const render = () => {
743
+ const nowFPS = 1e3 / (Date.now() - requestTime);
744
+ const {maxFPS: maxFPS} = this.config;
745
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
746
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
742
747
  this.requestTime = 0;
743
748
  this.checkRender();
744
- });
749
+ };
750
+ Platform.requestRender(render);
745
751
  }
746
752
  __onResize(e) {
747
753
  if (this.canvas.unreal) return;
@@ -784,7 +790,8 @@ class Renderer {
784
790
  if (this.target) {
785
791
  this.stop();
786
792
  this.__removeListenEvents();
787
- this.target = this.canvas = this.config = null;
793
+ this.config = {};
794
+ this.target = this.canvas = null;
788
795
  }
789
796
  }
790
797
  }
@@ -1718,7 +1725,7 @@ function ignoreRender(ui, value) {
1718
1725
 
1719
1726
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1720
1727
 
1721
- const {floor: floor, max: max, abs: abs} = Math;
1728
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1722
1729
 
1723
1730
  function createPattern(ui, paint, pixelRatio) {
1724
1731
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1728,8 +1735,6 @@ function createPattern(ui, paint, pixelRatio) {
1728
1735
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1729
1736
  scaleX *= pixelRatio;
1730
1737
  scaleY *= pixelRatio;
1731
- const xGap = gap && gap.x * scaleX;
1732
- const yGap = gap && gap.y * scaleY;
1733
1738
  if (sx) {
1734
1739
  sx = abs(sx);
1735
1740
  sy = abs(sy);
@@ -1746,7 +1751,10 @@ function createPattern(ui, paint, pixelRatio) {
1746
1751
  if (size > Platform.image.maxCacheSize) return false;
1747
1752
  }
1748
1753
  let maxSize = Platform.image.maxPatternSize;
1749
- if (!image.isSVG) {
1754
+ if (image.isSVG) {
1755
+ const ws = width / image.width;
1756
+ if (ws > 1) imageScale = ws / ceil(ws);
1757
+ } else {
1750
1758
  const imageSize = image.width * image.height;
1751
1759
  if (maxSize > imageSize) maxSize = imageSize;
1752
1760
  }
@@ -1761,18 +1769,20 @@ function createPattern(ui, paint, pixelRatio) {
1761
1769
  scaleX /= sx;
1762
1770
  scaleY /= sy;
1763
1771
  }
1772
+ const xGap = gap && gap.x * scaleX;
1773
+ const yGap = gap && gap.y * scaleY;
1764
1774
  if (transform || scaleX !== 1 || scaleY !== 1) {
1775
+ const canvasWidth = width + (xGap || 0);
1776
+ const canvasHeight = height + (yGap || 0);
1777
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1778
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1765
1779
  if (!imageMatrix) {
1766
1780
  imageMatrix = get$1();
1767
1781
  if (transform) copy$1(imageMatrix, transform);
1768
1782
  }
1769
1783
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1770
1784
  }
1771
- if (imageMatrix) {
1772
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1773
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1774
- }
1775
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1785
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1776
1786
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1777
1787
  paint.style = pattern;
1778
1788
  paint.patternId = id;
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as h,FileHelper as c,Creator as l,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as g,ChildEvent as p,WatchEvent as _,PropertyEvent as w,LeafHelper as y,BranchHelper as m,LeafBoundsHelper as v,Bounds as x,isArray as b,Debug as S,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as T,BoundsHelper as E,Plugin as L,isObject as A,Matrix as C,getMatrixData as P,MatrixHelper as M,MathHelper as W,AlignHelper as O,PointHelper as D,ImageEvent as z,AroundHelper as I,Direction4 as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as Y,isUndefined as X,HitCanvasManager as G}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as N,Paint as j,ColorConvert as H,PaintGradient as q,Export as V,Group as Q,TextConvert as K,Effect as Z,Leafer as $}from"@leafer-ui/draw";class J extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.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:e,height:a,pixelRatio:o}=this.config,r={width:e||t.width,height:a||t.height,pixelRatio:o};this.resize(r),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.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&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.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,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,o),this.resize(t),r(this.width)||this.resizeListener(new h(t,e))}}const{mineType:tt,fileType:et}=c;function it(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(tt(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(tt(et(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let o;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,o=!0);const r=e.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?i.miniapp.saveToAlbum(s).then(()=>{r.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:t=>new Promise((e,s)=>{const n=i.canvas.view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.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(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=l.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(l,{canvas:(t,e)=>new J(t,e),image:t=>new d(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class st{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=a.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(g.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[p.ADD,p.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:nt,updateBounds:at,updateChange:ot}=y,{pushAllChildBranch:rt,pushAllParent:ht}=m;const{worldBounds:ct}=v;class lt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:dt,updateAllChange:ut}=y,ft=S.get("Layouter");class gt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=a.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ft.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ft.warn("layouting"):this.times>3?ft.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(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?(nt(t,!0),e.add(t),t.isBranch&&rt(t,e),ht(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ht(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||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ot)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),gt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){dt(t,!0),t.isBranch?m.updateBounds(t):y.updateBounds(t),ut(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new lt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new lt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const pt=S.get("Renderer");class _t{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=a.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(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(g.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(g.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(g.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,pt.log(e.innerName,"---\x3e");try{this.emitRender(g.START),this.renderOnce(t),this.emitRender(g.END,this.totalBounds),T.clearRecycled()}catch(t){this.rendering=!1,pt.error(t)}pt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return pt.warn("rendering");if(this.times>3)return pt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(g.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(g.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(g.RENDER,this.renderBounds,this.renderOptions),this.emitRender(g.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(_t.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),S.showRepaint&&S.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now();i.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.checkRender()})}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(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 x(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||pt.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 g(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[g.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[g.AGAIN,this.renderAgain,this],[h.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}_t.clipSpread=10;const{hitRadiusPoint:wt}=E;class yt{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,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:o}=this.findList,r=this.getBestMatchLeaf(o,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:r}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:a}=this.point,o={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||y.worldHittable(e))&&(this.hitChild(e,o),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&y.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>y.worldHittable(t))}getPath(t){const e=new f;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 f;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 f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||wt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),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){let i,n=[];const{children:a}=s;for(let s=0,o=a.length;s<o;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class mt{constructor(t,e){this.config={},e&&(this.config=a.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=l.finder&&l.finder()}getByPoint(t,e,s){const{target:n,picker:a}=this;return i.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):L.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new st(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new _t(t,e,i),selector:(t,e)=>new mt(t,e)}),i.layout=gt.fullLayout;const vt={convertTouch(t,e){const i=vt.getTouch(t),s=U.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 xt extends Y{__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 X(t.x)?super.getLocal(t,e):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=vt.getTouch(t);this.pointerDown(vt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=vt.getTouch(t);this.pointerMove(vt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=vt.getTouch(t);this.pointerUp(vt.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(U.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 bt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function St(t,e){t.__.__font?bt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function kt(t,e,i){switch(e.__.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Bt(t,2,e,i):Rt(t,"outside",e,i)}}function Bt(t,e,i,s){const n=i.__;A(t)?Et(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Tt(i,s))}function Rt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Bt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",bt(i,n),n.blendMode="normal",y.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Tt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Et(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let h=0,c=t.length;h<c;h++)if(a=t[h],(!a.image||!N.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?Tt(s,n):n.stroke(),n.restoreBlendMode()):i?Tt(s,n):n.stroke()}}function Lt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)kt(t,e,i);else switch(s.strokeAlign){case"center":At(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),At(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)At(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),At(t,2,e,a),a.clipUI(s),a.clearWorld(n),y.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function At(t,e,i,s){const n=i.__;A(t)?Et(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&j.strokeArrow(t,i,s)}const{getSpread:Ct,getOuterOf:Pt,getByMove:Mt,getIntersectData:Wt}=E;let Ot;const{stintSet:Dt}=a,{hasTransparent:zt}=H;function It(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":n=N.image(s,t,i,a,!Ot||!Ot[i.url]);break;case"linear":n=q.linearGradient(i,a);break;case"radial":n=q.radialGradient(i,a);break;case"angular":n=q.conicGradient(i,a);break;case"solid":const{type:e,color:o,opacity:h}=i;n={type:e,style:H.string(o,h)};break;default:r(i.r)||(n={type:"solid",style:H.string(i)})}if(n){if(e(n.style)&&zt(n.style)&&(n.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}i.editing&&(n.editing=i.editing),i.blendMode&&(n.blendMode=i.blendMode)}return n}const Ft={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];b(r)||(r=[r]),Ot=N.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=It(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Dt(i,"__isAlphaPixelFill",n),Dt(i,"__isTransparentFill",a)):(Dt(i,"__isAlphaPixelStroke",n),Dt(i,"__isTransparentStroke",a),Dt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,St(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(N.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),St(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:bt,stroke:Lt,strokes:function(t,e,i){Lt(t,e,i)},strokeText:kt,drawTextStroke:Tt,shape:function(t,e,s){const n=e.getSameCanvas(),a=t.__nowWorld,o=e.bounds;let r,h,c,l,d,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))d=n,r=l=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(i.fullImageShadow)g=a;else{const t=n?Ct(o,u===f?n*u:[n*f,n*u]):o;g=Wt(t,a)}c=o.getFitMatrix(g);let{a:p,d:_}=c;c.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,s),u*=p,f*=_),l=Pt(a,c),r=Mt(l,-c.e,-c.f);const w=s.matrix;w?(h=new C(c),h.multiply(w),p*=w.scaleX,_*=w.scaleY):h=c,h.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:c,bounds:r,worldCanvas:d,shapeBounds:l,scaleX:u,scaleY:f}}};let Ut={},Yt=P();const{get:Xt,rotateOfOuter:Gt,translate:Nt,scaleOfOuter:jt,multiplyParent:Ht,scale:qt,rotate:Vt,skew:Qt}=M;function Kt(t,e,i,s,n,a,o){const r=Xt();Nt(r,e.x+i,e.y+s),qt(r,n,a),o&&Gt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Zt(t,e,i,s,n,a,o,r,h){const c=Xt();Jt(c,e,i,s,n,a,o,r),h&&(Yt.a=e.width/h.width,Yt.d=e.height/h.height,Ht(c,Yt)),t.transform=c}function $t(t,e,i,s,n,a,o,r,h,c,l,d){const u=Xt();if(d)Jt(u,e,n,a,o,r,h,c);else{if(h)if("center"===l)Gt(u,{x:i/2,y:s/2},h);else switch(Vt(u,h),h){case 90:Nt(u,s,0);break;case 180:Nt(u,i,s);break;case 270:Nt(u,0,i)}Ut.x=e.x+n,Ut.y=e.y+a,Nt(u,Ut.x,Ut.y),o&&jt(u,Ut,o,r)}t.transform=u}function Jt(t,e,i,s,n,a,o,r){o&&Vt(t,o),r&&Qt(t,r.x,r.y),n&&qt(t,n,a),Nt(t,e.x+i,e.y+s)}const{get:te,translate:ee}=M,ie=new x,se={},ne={};function ae(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=oe(i,s,e)}function oe(t,i,s){t.padding&&(i=ie.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=s;const{opacity:o,mode:r,align:h,offset:c,scale:l,size:d,rotation:u,skew:f,clipSize:g,repeat:p,gap:_,filters:w}=t,y=i.width===n&&i.height===a,m={mode:r},v="center"!==h&&(u||0)%180==90;let x,b;switch(E.set(ne,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((l||d)&&(W.getScaleData(l,d,s,se),x=se.scaleX,b=se.scaleY),(h||_||p)&&(x&&E.scale(ne,x,b,!0),h&&O.toPoint(h,ne,i,ne,!0,!0))):y&&!u||(x=b=E.getFitScale(i,ne,"fit"!==r),E.put(i,s,h,x,!1,ne),E.scale(ne,x,b,!0)),c&&D.move(ne,c),r){case"stretch":y||(n=i.width,a=i.height);break;case"normal":case"clip":(ne.x||ne.y||x||g||u||f)&&Zt(m,i,ne.x,ne.y,x,b,u,f,t.clipSize);break;case"repeat":(!y||x||u||f)&&$t(m,i,n,a,ne.x,ne.y,x,b,u,f,h,t.freeTransform),p||(m.repeat="repeat");const e=A(p);(_||e)&&(m.gap=function(t,e,i,s,n){let a,o;A(t)?(a=t.x,o=t.y):a=o=t;return{x:re(a,i,n.width,e&&e.x),y:re(o,s,n.height,e&&e.y)}}(_,e&&p,ne.width,ne.height,i));break;default:x&&Kt(m,i,ne.x,ne.y,x,b,u)}return m.transform||(i.x||i.y)&&(m.transform=te(),ee(m.transform,i.x,i.y)),x&&"stretch"!==r&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=a,o&&(m.opacity=o),w&&(m.filters=w),p&&(m.repeat=e(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function re(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let he,ce=new x;const{isSame:le}=E;function de(t,e,i,s,n,a){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||ae(n,s,i,a),!0}function ue(t,e){pe(t,z.LOAD,e)}function fe(t,e){pe(t,z.LOADED,e)}function ge(t,e,i){e.error=i,t.forceUpdate("surface"),pe(t,z.ERROR,e)}function pe(t,e,i){t.hasEvent(e)&&t.emitEvent(new z(e,i))}function _e(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:we,scale:ye,copy:me}=M,{floor:ve,max:xe,abs:be}=Math;function Se(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:t,data:r}=e;let h,c,{width:l,height:d,scaleX:u,scaleY:f,transform:g,repeat:p,gap:_}=r;n*=s,a*=s;const w=_&&_.x*n,y=_&&_.y*a;u&&(u=be(u),f=be(f),c=we(),me(c,g),ye(c,1/u,1/f),n*=u,a*=f),l*=n,d*=a;const m=l*d;if(!p&&m>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}if(m>v&&(h=Math.sqrt(m/v)),h&&(n/=h,a/=h,l/=h,d/=h),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(c||(c=we(),g&&me(c,g)),ye(c,1/n,1/a)),c){const t=l+(w||0),e=d+(y||0);ye(c,t/xe(ve(t),1),e/xe(ve(e),1))}const x=t.getCanvas(l,d,r.opacity,r.filters,w,y),b=t.getPattern(x,p||i.origin.noRepeat||"no-repeat",c,e);return e.style=b,e.patternId=o,!0}}function ke(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(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(o,r)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Be={image:function(t,e,i,s,n){let a,o;const r=T.get(i);return he&&i===he.paint&&le(s,he.boxBounds)?a=he.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),he=r.use>1?{leafPaint:a,paint:i,boxBounds:ce.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(de(t,e,i,r,a,s),n&&(ue(t,o),fe(t,o))):r.error?n&&ge(t,o,r.error):(n&&(_e(t,!0),ue(t,o)),a.loadId=r.load(()=>{_e(t,!1),t.destroyed||(de(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),fe(t,o)),a.loadId=void 0},e=>{_e(t,!1),ge(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=e,{data:c}=s;if(!c||s.patternId===a+"-"+o+"-"+r&&!V.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&h.isResizing(t)||V.running)){let{width:t,height:e}=c;t*=a*r,e*=o*r,c.scaleX&&(t*=c.scaleX,e*=c.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,c),!0):(!s.style||s.sync||V.running?Se(t,s,r):s.patternTask||(s.patternTask=T.patternTasker.add(()=>ke(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&Se(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:Se,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,a,o,r;for(let h=0,c=i.length;h<c;h++)s=i[h],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,T.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],b(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===r))));return a}return null},createData:ae,getPatternData:oe,fillOrFitMode:Kt,clipMode:Zt,repeatMode:$t},{toPoint:Re}=I,{hasTransparent:Te}=H,Ee={},Le={};function Ae(t,i,s,n){if(s){let a,o,r,h;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(r=t/(c-1),o=H.string(a,n)):(r=a.offset,o=H.string(a.color,n)),i.addColorStop(r,o),!h&&Te(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Ce,getDistance:Pe}=D,{get:Me,rotateOfOuter:We,scaleOfOuter:Oe}=M,{toPoint:De}=I,ze={},Ie={};function Fe(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Ce(e,i);a=Me(),n?(Oe(a,e,o/r*(s||1),1),We(a,e,t+90)):(Oe(a,e,1,o/r*(s||1)),We(a,e,t))}return a}const{getDistance:Ue}=D,{toPoint:Ye}=I,Xe={},Ge={};const Ne={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;Re(s||"top",e,Ee),Re(n||"bottom",e,Le);const r=i.canvas.createLinearGradient(Ee.x,Ee.y,Le.x,Le.y),h={type:a,style:r};return Ae(h,r,t.stops,o),h},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;De(s||"center",e,ze),De(n||"bottom",e,Ie);const h=i.canvas.createRadialGradient(ze.x,ze.y,0,ze.x,ze.y,Pe(ze,Ie)),c={type:a,style:h};Ae(c,h,t.stops,o);const l=Fe(e,ze,Ie,r,!0);return l&&(c.transform=l),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ye(s||"center",e,Xe),Ye(n||"bottom",e,Ge);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Xe.x,Xe.y):i.canvas.createRadialGradient(Xe.x,Xe.y,0,Xe.x,Xe.y,Ue(Xe,Ge)),c={type:a,style:h};Ae(c,h,t.stops,o);const l=Fe(e,Xe,Ge,r||1,i.conicGradientRotate90);return l&&(c.transform=l),c},getTransform:Fe},{copy:je,toOffsetOutBounds:He}=E,qe={},Ve={};function Qe(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(je(qe,t.bounds),qe.x+=e.x-o.x,qe.y+=e.y-o.y,s){const{fitMatrix:t}=n;qe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),qe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),qe.width*=s,qe.height*=s}t.copyWorld(n.canvas,t.bounds,qe)}else s&&(je(qe,e),qe.x-=e.width/2*(s-1),qe.y-=e.height/2*(s-1),qe.width*=s,qe.height*=s),t.copyWorld(n.canvas,o,s?qe:e)}const{toOffsetOutBounds:Ke}=E,Ze={};const $e={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;He(c,Ve),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ve.offsetX+r.x*d*_,Ve.offsetY+r.y*u*_,r.blur*d*_,H.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Qe(f,Ve,n,i),s=c,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,c,a,"copy"),s=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(i.canvas,l,c,"destination-out")),y.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ke(c,Ze),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ze.offsetX+r.x*d*_,Ze.offsetY+r.y*u*_,r.blur*d*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Qe(f,Ze,n,i),f.restore(),h?(f.copyWorld(f,c,a,"copy"),f.copyWorld(h,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,c,"source-out"),s=c),f.fillWorld(s,H.string(r.color),"source-in"),y.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),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:Je}=v;let ti;function ei(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ti||(ti=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);si(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":si(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ii(t){return t.getSameCanvas(!1,!0)}function si(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}Q.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:h}=this;for(let c=0,l=h.length;c<l;c++){if(i=h[c],r=i.__.mask,r){o&&(ei(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,ti=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ii(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ii(t)),n||(n=ii(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Je(i,e)||i.__render(t,e);continue}const l=1===a&&i.__.__blendMode;l&&ei(this,o,t,n,s,a,void 0,!1),Je(i,e)||i.__render(n||t,e),l&&ei(this,o,t,n,s,a,l,!1)}ei(this,o,t,n,s,a,void 0,!0)};const ni=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ai=ni+"_#~&*+\\=|≮≯≈≠=…",oi=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 ri(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const hi=ri("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ci=ri("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),li=ri(ni),di=ri(ai),ui=ri("- —/~|┆·");var fi;!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"}(fi||(fi={}));const{Letter:gi,Single:pi,Before:_i,After:wi,Symbol:yi,Break:mi}=fi;function vi(t){return hi[t]?gi:ui[t]?mi:ci[t]?_i:li[t]?wi:di[t]?yi:oi.test(t)?pi:gi}const xi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function bi(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:Si}=xi,{Letter:ki,Single:Bi,Before:Ri,After:Ti,Symbol:Ei,Break:Li}=fi;let Ai,Ci,Pi,Mi,Wi,Oi,Di,zi,Ii,Fi,Ui,Yi,Xi,Gi,Ni,ji,Hi,qi=[];function Vi(t,e){Ii&&!zi&&(zi=Ii),Ai.data.push({char:t,width:e}),Pi+=e}function Qi(){Mi+=Pi,Ai.width=Pi,Ci.words.push(Ai),Ai={data:[]},Pi=0}function Ki(){Gi&&(Ni.paraNumber++,Ci.paraStart=!0,Gi=!1),Ii&&(Ci.startCharSize=zi,Ci.endCharSize=Ii,zi=0),Ci.width=Mi,ji.width?Si(Ci):Hi&&Zi(),qi.push(Ci),Ci={words:[]},Mi=0}function Zi(){Mi>(Ni.maxWidth||0)&&(Ni.maxWidth=Mi)}const{top:$i,right:Ji,bottom:ts,left:es}=F;function is(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 ss={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,o=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:h,__font:c,__padding:l}=s;l&&(o?(n=l[es],o-=l[Ji]+l[es]):s.autoSizeAlign||(n=l[es]),r?(a=l[$i],r-=l[$i]+l[ts]):s.autoSizeAlign||(a=l[$i]));const d={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=c};return function(t,e,s){Ni=t,qi=t.rows,ji=t.bounds,Hi=!ji.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:h,height:c}=ji;if(h||c||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Gi=!0,Ui=null,zi=Di=Ii=Pi=Mi=0,Ai={data:[]},Ci={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Oi=e[s],"\n"===Oi?(Pi&&Qi(),Ci.paraEnd=!0,Ki(),Gi=!0):(Fi=vi(Oi),Fi===ki&&"none"!==o&&(Oi=bi(Oi,o,!Pi)),Di=r.measureText(Oi).width,n&&(n<0&&(Ii=Di),Di+=n),Yi=Fi===Bi&&(Ui===Bi||Ui===ki)||Ui===Bi&&Fi!==Ti,Xi=!(Fi!==Ri&&Fi!==Bi||Ui!==Ei&&Ui!==Ti),Wi=Gi&&a?h-a:h,t&&h&&Mi+Pi+Di>Wi&&(i?(Pi&&Qi(),Mi&&Ki()):(Xi||(Xi=Fi===ki&&Ui==Ti),Yi||Xi||Fi===Li||Fi===Ri||Fi===Bi||Pi+Di>Wi?(Pi&&Qi(),Mi&&Ki()):Mi&&Ki()))," "===Oi&&!0!==Gi&&Mi+Pi===0||(Fi===Li?(" "===Oi&&Pi&&Qi(),Vi(Oi,Di),Qi()):Yi||Xi?(Pi&&Qi(),Vi(Oi,Di)):Vi(Oi,Di)),Ui=Fi);Pi&&Qi(),Mi&&Ki(),qi.length>0&&(qi[qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ni.paraNumber++,Mi=r.measureText(t).width,qi.push({x:a||0,text:t,width:Mi,paraStart:!0}),Hi&&Zi()})}(d,t,s),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":is(e,"x",t[es]);break;case"right":is(e,"x",-t[Ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":is(e,"y",t[$i]);break;case"bottom":is(e,"y",-t[ts])}}(l,d,s,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:h,textAlign:c,verticalAlign:l,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(d?d*(t.paraNumber-1):0),y=o;if(h&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(l){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let o=0,l=n;o<l;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!h)switch(c){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&o>0&&(y+=d),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),h&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(d,s),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,h,c,l,d,u;s.forEach(t=>{t.words&&(c=a&&t.paraStart?a:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,l=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===l?(t.x+=c,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===l?(d={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(r+=h,t.width+=h)})),t.words=null)})}(d,s,o),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?i.canvas.measureText(r).width:0,l=s+n-c;("none"===e.textWrap?a:[a[o-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<l));s--){if(h<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,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)}})}}(d,s,n,o),"none"!==h&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,A(n)?(i=n.type,n.color&&(t.decorationColor=H.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,s),d}};const ns={string:function(t,i){const n=s(i)&&i<1;if(e(t)){if(!n||!H.object)return t;t=H.object(t)}let a=r(t.a)?1:t.a;n&&(a*=i);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(K,ss),Object.assign(H,ns),Object.assign(j,Ft),Object.assign(N,Be),Object.assign(q,Ne),Object.assign(Z,$e),Object.assign(l,{interaction:(t,e,i,s)=>new xt(t,e,i,s),hitCanvas:(t,e)=>new J(t,e),hitCanvasManager:()=>new G}),$.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&it(0,wx)}catch(t){}export{xt as Interaction,gt as Layouter,J as LeaferCanvas,yt as Picker,_t as Renderer,mt as Selector,st as Watcher,it as useCanvas};
1
+ import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as h,FileHelper as c,Creator as l,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as g,ChildEvent as p,WatchEvent as _,PropertyEvent as w,LeafHelper as y,BranchHelper as m,LeafBoundsHelper as v,Bounds as x,isArray as b,Debug as S,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as T,BoundsHelper as E,Plugin as L,isObject as A,Matrix as C,getMatrixData as P,MatrixHelper as M,MathHelper as W,AlignHelper as O,PointHelper as D,ImageEvent as z,AroundHelper as F,Direction4 as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as Y,isUndefined as X,HitCanvasManager as G}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as N,Paint as j,ColorConvert as q,PaintGradient as H,Export as V,Group as Q,TextConvert as K,Effect as Z,Leafer as $}from"@leafer-ui/draw";class J extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.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:e,height:a,pixelRatio:o}=this.config,r={width:e||t.width,height:a||t.height,pixelRatio:o};this.resize(r),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;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&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.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,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,o),this.resize(t),r(this.width)||this.resizeListener(new h(t,e))}}const{mineType:tt,fileType:et}=c;function it(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(tt(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(tt(et(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let o;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,o=!0);const r=e.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?i.miniapp.saveToAlbum(s).then(()=>{r.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:t=>new Promise((e,s)=>{const n=i.canvas.view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.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(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=l.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(l,{canvas:(t,e)=>new J(t,e),image:t=>new d(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class st{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;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 f,this.target=t,e&&(this.config=a.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(g.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[p.ADD,p.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:nt,updateBounds:at,updateChange:ot}=y,{pushAllChildBranch:rt,pushAllParent:ht}=m;const{worldBounds:ct}=v;class lt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ct)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ct),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:dt,updateAllChange:ut}=y,ft=S.get("Layouter");class gt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=a.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ft.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ft.warn("layouting"):this.times>3?ft.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.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=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(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?(nt(t,!0),e.add(t),t.isBranch&&rt(t,e),ht(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ht(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||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ot)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),gt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){dt(t,!0),t.isBranch?m.updateBounds(t):y.updateBounds(t),ut(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new lt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new lt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const pt=S.get("Renderer");class _t{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:120},this.target=t,this.canvas=e,i&&(this.config=a.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(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(g.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(g.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(g.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,pt.log(e.innerName,"---\x3e");try{this.emitRender(g.START),this.renderOnce(t),this.emitRender(g.END,this.totalBounds),T.clearRecycled()}catch(t){this.rendering=!1,pt.error(t)}pt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return pt.warn("rendering");if(this.times>3)return pt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(g.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(g.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(g.RENDER,this.renderBounds,this.renderOptions),this.emitRender(g.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(_t.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),S.showRepaint&&S.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-e),{maxFPS:n}=this.config;if(n&&t>n-.5)return i.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};i.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(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 x(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||pt.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 g(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[g.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[g.AGAIN,this.renderAgain,this],[h.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}_t.clipSpread=10;const{hitRadiusPoint:wt}=E;class yt{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,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:o}=this.findList,r=this.getBestMatchLeaf(o,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:o.length?this.getThroughPath(o):h}:{path:h,target:r}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new f;if(t.length){let e;const{x:n,y:a}=this.point,o={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||y.worldHittable(e))&&(this.hitChild(e,o),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&y.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>y.worldHittable(t))}getPath(t){const e=new f;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 f;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 f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||wt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),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){let i,n=[];const{children:a}=s;for(let s=0,o=a.length;s<o;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class mt{constructor(t,e){this.config={},e&&(this.config=a.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=l.finder&&l.finder()}getByPoint(t,e,s){const{target:n,picker:a}=this;return i.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):L.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new st(t,e),layouter:(t,e)=>new gt(t,e),renderer:(t,e,i)=>new _t(t,e,i),selector:(t,e)=>new mt(t,e)}),i.layout=gt.fullLayout;const vt={convertTouch(t,e){const i=vt.getTouch(t),s=U.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 xt extends Y{__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 X(t.x)?super.getLocal(t,e):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=vt.getTouch(t);this.pointerDown(vt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=vt.getTouch(t);this.pointerMove(vt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=vt.getTouch(t);this.pointerUp(vt.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(U.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 bt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function St(t,e){t.__.__font?bt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function kt(t,e,i){switch(e.__.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":Rt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Bt(t,2,e,i):Rt(t,"outside",e,i)}}function Bt(t,e,i,s){const n=i.__;A(t)?Et(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Tt(i,s))}function Rt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Bt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",bt(i,n),n.blendMode="normal",y.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Tt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function Et(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let h=0,c=t.length;h<c;h++)if(a=t[h],(!a.image||!N.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?Tt(s,n):n.stroke(),n.restoreBlendMode()):i?Tt(s,n):n.stroke()}}function Lt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)kt(t,e,i);else switch(s.strokeAlign){case"center":At(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),At(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)At(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),At(t,2,e,a),a.clipUI(s),a.clearWorld(n),y.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function At(t,e,i,s){const n=i.__;A(t)?Et(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&j.strokeArrow(t,i,s)}const{getSpread:Ct,getOuterOf:Pt,getByMove:Mt,getIntersectData:Wt}=E;let Ot;const{stintSet:Dt}=a,{hasTransparent:zt}=q;function Ft(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":n=N.image(s,t,i,a,!Ot||!Ot[i.url]);break;case"linear":n=H.linearGradient(i,a);break;case"radial":n=H.radialGradient(i,a);break;case"angular":n=H.conicGradient(i,a);break;case"solid":const{type:e,color:o,opacity:h}=i;n={type:e,style:q.string(o,h)};break;default:r(i.r)||(n={type:"solid",style:q.string(i)})}if(n){if(e(n.style)&&zt(n.style)&&(n.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}i.editing&&(n.editing=i.editing),i.blendMode&&(n.blendMode=i.blendMode)}return n}const It={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];b(r)||(r=[r]),Ot=N.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Ft(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Dt(i,"__isAlphaPixelFill",n),Dt(i,"__isTransparentFill",a)):(Dt(i,"__isAlphaPixelStroke",n),Dt(i,"__isTransparentStroke",a),Dt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,St(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(N.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),St(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:bt,stroke:Lt,strokes:function(t,e,i){Lt(t,e,i)},strokeText:kt,drawTextStroke:Tt,shape:function(t,e,s){const n=e.getSameCanvas(),a=t.__nowWorld,o=e.bounds;let r,h,c,l,d,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))d=n,r=l=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(i.fullImageShadow)g=a;else{const t=n?Ct(o,u===f?n*u:[n*f,n*u]):o;g=Wt(t,a)}c=o.getFitMatrix(g);let{a:p,d:_}=c;c.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,s),u*=p,f*=_),l=Pt(a,c),r=Mt(l,-c.e,-c.f);const w=s.matrix;w?(h=new C(c),h.multiply(w),p*=w.scaleX,_*=w.scaleY):h=c,h.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:c,bounds:r,worldCanvas:d,shapeBounds:l,scaleX:u,scaleY:f}}};let Ut={},Yt=P();const{get:Xt,rotateOfOuter:Gt,translate:Nt,scaleOfOuter:jt,multiplyParent:qt,scale:Ht,rotate:Vt,skew:Qt}=M;function Kt(t,e,i,s,n,a,o){const r=Xt();Nt(r,e.x+i,e.y+s),Ht(r,n,a),o&&Gt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Zt(t,e,i,s,n,a,o,r,h){const c=Xt();Jt(c,e,i,s,n,a,o,r),h&&(Yt.a=e.width/h.width,Yt.d=e.height/h.height,qt(c,Yt)),t.transform=c}function $t(t,e,i,s,n,a,o,r,h,c,l,d){const u=Xt();if(d)Jt(u,e,n,a,o,r,h,c);else{if(h)if("center"===l)Gt(u,{x:i/2,y:s/2},h);else switch(Vt(u,h),h){case 90:Nt(u,s,0);break;case 180:Nt(u,i,s);break;case 270:Nt(u,0,i)}Ut.x=e.x+n,Ut.y=e.y+a,Nt(u,Ut.x,Ut.y),o&&jt(u,Ut,o,r)}t.transform=u}function Jt(t,e,i,s,n,a,o,r){o&&Vt(t,o),r&&Qt(t,r.x,r.y),n&&Ht(t,n,a),Nt(t,e.x+i,e.y+s)}const{get:te,translate:ee}=M,ie=new x,se={},ne={};function ae(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=oe(i,s,e)}function oe(t,i,s){t.padding&&(i=ie.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=s;const{opacity:o,mode:r,align:h,offset:c,scale:l,size:d,rotation:u,skew:f,clipSize:g,repeat:p,gap:_,filters:w}=t,y=i.width===n&&i.height===a,m={mode:r},v="center"!==h&&(u||0)%180==90;let x,b;switch(E.set(ne,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((l||d)&&(W.getScaleData(l,d,s,se),x=se.scaleX,b=se.scaleY),(h||_||p)&&(x&&E.scale(ne,x,b,!0),h&&O.toPoint(h,ne,i,ne,!0,!0))):y&&!u||(x=b=E.getFitScale(i,ne,"fit"!==r),E.put(i,s,h,x,!1,ne),E.scale(ne,x,b,!0)),c&&D.move(ne,c),r){case"stretch":y||(n=i.width,a=i.height);break;case"normal":case"clip":(ne.x||ne.y||x||g||u||f)&&Zt(m,i,ne.x,ne.y,x,b,u,f,t.clipSize);break;case"repeat":(!y||x||u||f)&&$t(m,i,n,a,ne.x,ne.y,x,b,u,f,h,t.freeTransform),p||(m.repeat="repeat");const e=A(p);(_||e)&&(m.gap=function(t,e,i,s,n){let a,o;A(t)?(a=t.x,o=t.y):a=o=t;return{x:re(a,i,n.width,e&&e.x),y:re(o,s,n.height,e&&e.y)}}(_,e&&p,ne.width,ne.height,i));break;default:x&&Kt(m,i,ne.x,ne.y,x,b,u)}return m.transform||(i.x||i.y)&&(m.transform=te(),ee(m.transform,i.x,i.y)),x&&"stretch"!==r&&(m.scaleX=x,m.scaleY=b),m.width=n,m.height=a,o&&(m.opacity=o),w&&(m.filters=w),p&&(m.repeat=e(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function re(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let he,ce=new x;const{isSame:le}=E;function de(t,e,i,s,n,a){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||ae(n,s,i,a),!0}function ue(t,e){pe(t,z.LOAD,e)}function fe(t,e){pe(t,z.LOADED,e)}function ge(t,e,i){e.error=i,t.forceUpdate("surface"),pe(t,z.ERROR,e)}function pe(t,e,i){t.hasEvent(e)&&t.emitEvent(new z(e,i))}function _e(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:we,scale:ye,copy:me}=M,{floor:ve,ceil:xe,max:be,abs:Se}=Math;function ke(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:r,data:h}=e;let c,l,{width:d,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=h;n*=s,a*=s,f&&(f=Se(f),g=Se(g),l=we(),me(l,p),ye(l,1/f,1/g),n*=f,a*=g),d*=n,u*=a;const y=d*u;if(!_&&y>i.image.maxCacheSize)return!1;let m=i.image.maxPatternSize;if(r.isSVG){const t=d/r.width;t>1&&(c=t/xe(t))}else{const t=r.width*r.height;m>t&&(m=t)}y>m&&(c=Math.sqrt(y/m)),c&&(n/=c,a/=c,d/=c,u/=c),f&&(n/=f,a/=g);const v=w&&w.x*n,x=w&&w.y*a;if(p||1!==n||1!==a){const t=d+(v||0),e=u+(x||0);n/=t/be(ve(t),1),a/=e/be(ve(e),1),l||(l=we(),p&&me(l,p)),ye(l,1/n,1/a)}const b=r.getCanvas(d,u,h.opacity,h.filters,v,x,t.leafer&&t.leafer.config.smooth),S=r.getPattern(b,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=S,e.patternId=o,!0}}function Be(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(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(o,r)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Re={image:function(t,e,i,s,n){let a,o;const r=T.get(i);return he&&i===he.paint&&le(s,he.boxBounds)?a=he.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),he=r.use>1?{leafPaint:a,paint:i,boxBounds:ce.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(de(t,e,i,r,a,s),n&&(ue(t,o),fe(t,o))):r.error?n&&ge(t,o,r.error):(n&&(_e(t,!0),ue(t,o)),a.loadId=r.load(()=>{_e(t,!1),t.destroyed||(de(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),fe(t,o)),a.loadId=void 0},e=>{_e(t,!1),ge(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=e,{data:c}=s;if(!c||s.patternId===a+"-"+o+"-"+r&&!V.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&h.isResizing(t)||V.running)){let{width:t,height:e}=c;t*=a*r,e*=o*r,c.scaleX&&(t*=c.scaleX,e*=c.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,c),!0):(!s.style||s.sync||V.running?ke(t,s,r):s.patternTask||(s.patternTask=T.patternTasker.add(()=>Be(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ke(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:ke,recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,a,o,r;for(let h=0,c=i.length;h<c;h++)s=i[h],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,T.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],b(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===r))));return a}return null},createData:ae,getPatternData:oe,fillOrFitMode:Kt,clipMode:Zt,repeatMode:$t},{toPoint:Te}=F,{hasTransparent:Ee}=q,Le={},Ae={};function Ce(t,i,s,n){if(s){let a,o,r,h;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(r=t/(c-1),o=q.string(a,n)):(r=a.offset,o=q.string(a.color,n)),i.addColorStop(r,o),!h&&Ee(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Pe,getDistance:Me}=D,{get:We,rotateOfOuter:Oe,scaleOfOuter:De}=M,{toPoint:ze}=F,Fe={},Ie={};function Ue(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Pe(e,i);a=We(),n?(De(a,e,o/r*(s||1),1),Oe(a,e,t+90)):(De(a,e,1,o/r*(s||1)),Oe(a,e,t))}return a}const{getDistance:Ye}=D,{toPoint:Xe}=F,Ge={},Ne={};const je={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;Te(s||"top",e,Le),Te(n||"bottom",e,Ae);const r=i.canvas.createLinearGradient(Le.x,Le.y,Ae.x,Ae.y),h={type:a,style:r};return Ce(h,r,t.stops,o),h},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;ze(s||"center",e,Fe),ze(n||"bottom",e,Ie);const h=i.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Me(Fe,Ie)),c={type:a,style:h};Ce(c,h,t.stops,o);const l=Ue(e,Fe,Ie,r,!0);return l&&(c.transform=l),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Xe(s||"center",e,Ge),Xe(n||"bottom",e,Ne);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Ge.x,Ge.y):i.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,Ye(Ge,Ne)),c={type:a,style:h};Ce(c,h,t.stops,o);const l=Ue(e,Ge,Ne,r||1,i.conicGradientRotate90);return l&&(c.transform=l),c},getTransform:Ue},{copy:qe,toOffsetOutBounds:He}=E,Ve={},Qe={};function Ke(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(qe(Ve,t.bounds),Ve.x+=e.x-o.x,Ve.y+=e.y-o.y,s){const{fitMatrix:t}=n;Ve.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ve.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ve.width*=s,Ve.height*=s}t.copyWorld(n.canvas,t.bounds,Ve)}else s&&(qe(Ve,e),Ve.x-=e.width/2*(s-1),Ve.y-=e.height/2*(s-1),Ve.width*=s,Ve.height*=s),t.copyWorld(n.canvas,o,s?Ve:e)}const{toOffsetOutBounds:Ze}=E,$e={};const Je={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;He(c,Qe),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Qe.offsetX+r.x*d*_,Qe.offsetY+r.y*u*_,r.blur*d*_,q.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ke(f,Qe,n,i),s=c,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,c,a,"copy"),s=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(i.canvas,l,c,"destination-out")),y.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ze(c,$e),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow($e.offsetX+r.x*d*_,$e.offsetY+r.y*u*_,r.blur*d*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Ke(f,$e,n,i),f.restore(),h?(f.copyWorld(f,c,a,"copy"),f.copyWorld(h,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,c,"source-out"),s=c),f.fillWorld(s,q.string(r.color),"source-in"),y.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),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:ti}=v;let ei;function ii(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ei||(ei=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);ni(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ni(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function si(t){return t.getSameCanvas(!1,!0)}function ni(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}Q.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:h}=this;for(let c=0,l=h.length;c<l;c++){if(i=h[c],r=i.__.mask,r){o&&(ii(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,ei=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=si(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=si(t)),n||(n=si(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||ti(i,e)||i.__render(t,e);continue}const l=1===a&&i.__.__blendMode;l&&ii(this,o,t,n,s,a,void 0,!1),ti(i,e)||i.__render(n||t,e),l&&ii(this,o,t,n,s,a,l,!1)}ii(this,o,t,n,s,a,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",oi=ai+"_#~&*+\\=|≮≯≈≠=…",ri=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 hi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ci=hi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),li=hi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),di=hi(ai),ui=hi(oi),fi=hi("- —/~|┆·");var gi;!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"}(gi||(gi={}));const{Letter:pi,Single:_i,Before:wi,After:yi,Symbol:mi,Break:vi}=gi;function xi(t){return ci[t]?pi:fi[t]?vi:li[t]?wi:di[t]?yi:ui[t]?mi:ri.test(t)?_i:pi}const bi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)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:ki}=bi,{Letter:Bi,Single:Ri,Before:Ti,After:Ei,Symbol:Li,Break:Ai}=gi;let Ci,Pi,Mi,Wi,Oi,Di,zi,Fi,Ii,Ui,Yi,Xi,Gi,Ni,ji,qi,Hi,Vi=[];function Qi(t,e){Ii&&!Fi&&(Fi=Ii),Ci.data.push({char:t,width:e}),Mi+=e}function Ki(){Wi+=Mi,Ci.width=Mi,Pi.words.push(Ci),Ci={data:[]},Mi=0}function Zi(){Ni&&(ji.paraNumber++,Pi.paraStart=!0,Ni=!1),Ii&&(Pi.startCharSize=Fi,Pi.endCharSize=Ii,Fi=0),Pi.width=Wi,qi.width?ki(Pi):Hi&&$i(),Vi.push(Pi),Pi={words:[]},Wi=0}function $i(){Wi>(ji.maxWidth||0)&&(ji.maxWidth=Wi)}const{top:Ji,right:ts,bottom:es,left:is}=I;function ss(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 ns={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,o=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:h,__font:c,__padding:l}=s;l&&(o?(n=l[is],o-=l[ts]+l[is]):s.autoSizeAlign||(n=l[is]),r?(a=l[Ji],r-=l[Ji]+l[es]):s.autoSizeAlign||(a=l[Ji]));const d={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=c};return function(t,e,s){ji=t,Vi=t.rows,qi=t.bounds,Hi=!qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:h,height:c}=qi;if(h||c||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Ni=!0,Yi=null,Fi=zi=Ii=Mi=Wi=0,Ci={data:[]},Pi={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Di=e[s],"\n"===Di?(Mi&&Ki(),Pi.paraEnd=!0,Zi(),Ni=!0):(Ui=xi(Di),Ui===Bi&&"none"!==o&&(Di=Si(Di,o,!Mi)),zi=r.measureText(Di).width,n&&(n<0&&(Ii=zi),zi+=n),Xi=Ui===Ri&&(Yi===Ri||Yi===Bi)||Yi===Ri&&Ui!==Ei,Gi=!(Ui!==Ti&&Ui!==Ri||Yi!==Li&&Yi!==Ei),Oi=Ni&&a?h-a:h,t&&h&&Wi+Mi+zi>Oi&&(i?(Mi&&Ki(),Wi&&Zi()):(Gi||(Gi=Ui===Bi&&Yi==Ei),Xi||Gi||Ui===Ai||Ui===Ti||Ui===Ri||Mi+zi>Oi?(Mi&&Ki(),Wi&&Zi()):Wi&&Zi()))," "===Di&&!0!==Ni&&Wi+Mi===0||(Ui===Ai?(" "===Di&&Mi&&Ki(),Qi(Di,zi),Ki()):Xi||Gi?(Mi&&Ki(),Qi(Di,zi)):Qi(Di,zi)),Yi=Ui);Mi&&Ki(),Wi&&Zi(),Vi.length>0&&(Vi[Vi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{ji.paraNumber++,Wi=r.measureText(t).width,Vi.push({x:a||0,text:t,width:Wi,paraStart:!0}),Hi&&$i()})}(d,t,s),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ss(e,"x",t[is]);break;case"right":ss(e,"x",-t[ts])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ss(e,"y",t[Ji]);break;case"bottom":ss(e,"y",-t[es])}}(l,d,s,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:h,textAlign:c,verticalAlign:l,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(d?d*(t.paraNumber-1):0),y=o;if(h&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(l){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let o=0,l=n;o<l;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!h)switch(c){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&o>0&&(y+=d),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),h&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(d,s),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,h,c,l,d,u;s.forEach(t=>{t.words&&(c=a&&t.paraStart?a:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,l=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===l?(t.x+=c,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===l?(d={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(r+=h,t.width+=h)})),t.words=null)})}(d,s,o),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?i.canvas.measureText(r).width:0,l=s+n-c;("none"===e.textWrap?a:[a[o-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<l));s--){if(h<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,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)}})}}(d,s,n,o),"none"!==h&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,A(n)?(i=n.type,n.color&&(t.decorationColor=q.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,s),d}};const as={string:function(t,i){const n=s(i)&&i<1;if(e(t)){if(!n||!q.object)return t;t=q.object(t)}let a=r(t.a)?1:t.a;n&&(a*=i);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(K,ns),Object.assign(q,as),Object.assign(j,It),Object.assign(N,Re),Object.assign(H,je),Object.assign(Z,Je),Object.assign(l,{interaction:(t,e,i,s)=>new xt(t,e,i,s),hitCanvas:(t,e)=>new J(t,e),hitCanvasManager:()=>new G}),$.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&it(0,wx)}catch(t){}export{xt as Interaction,gt as Layouter,J as LeaferCanvas,yt as Picker,_t as Renderer,mt as Selector,st as Watcher,it as useCanvas};
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map