@leafer-ui/miniapp 1.12.4 → 2.0.0

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
@@ -593,6 +593,7 @@ class Renderer {
593
593
  this.times = 0;
594
594
  this.config = {
595
595
  usePartRender: true,
596
+ ceilPartPixel: true,
596
597
  maxFPS: 120
597
598
  };
598
599
  this.frames = [];
@@ -701,8 +702,9 @@ class Renderer {
701
702
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
702
703
  canvas.save();
703
704
  bounds.spread(Renderer.clipSpread).ceil();
704
- canvas.clearWorld(bounds);
705
- canvas.clipWorld(bounds);
705
+ const {ceilPartPixel: ceilPartPixel} = this.config;
706
+ canvas.clipWorld(bounds, ceilPartPixel);
707
+ canvas.clearWorld(bounds, ceilPartPixel);
706
708
  this.__render(bounds, realBounds);
707
709
  canvas.restore();
708
710
  core.Run.end(t);
@@ -1624,7 +1626,7 @@ function getPatternData(paint, box, image) {
1624
1626
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1625
1627
  if (paint.mode === "strench") paint.mode = "stretch";
1626
1628
  const {width: width, height: height} = image;
1627
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
1629
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1628
1630
  const sameBox = box.width === width && box.height === height;
1629
1631
  const data = {
1630
1632
  mode: mode
@@ -1690,6 +1692,10 @@ function getPatternData(paint, box, image) {
1690
1692
  if (opacity && opacity < 1) data.opacity = opacity;
1691
1693
  if (filters) data.filters = filters;
1692
1694
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1695
+ if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1696
+ type: "x",
1697
+ offset: interlace
1698
+ } : interlace;
1693
1699
  return data;
1694
1700
  }
1695
1701
 
@@ -1856,7 +1862,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1856
1862
  if (transform) copy$1(imageMatrix, transform);
1857
1863
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1858
1864
  }
1859
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1865
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1860
1866
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1861
1867
  paint.style = pattern;
1862
1868
  paint.patternId = id;
@@ -1878,8 +1884,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1878
1884
 
1879
1885
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1880
1886
  const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1881
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1882
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1887
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1888
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1883
1889
  return false;
1884
1890
  } else {
1885
1891
  if (drawImage) {
@@ -2553,7 +2559,7 @@ const TextMode = 2;
2553
2559
 
2554
2560
  function layoutChar(drawData, style, width, _height) {
2555
2561
  const {rows: rows} = drawData;
2556
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
2562
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
2557
2563
  const justifyLast = width && textAlign.includes("both");
2558
2564
  const justify = justifyLast || width && textAlign.includes("justify");
2559
2565
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2566,8 +2572,8 @@ function layoutChar(drawData, style, width, _height) {
2566
2572
  remainingWidth = width - row.width - indentWidth;
2567
2573
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2568
2574
  }
2569
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2570
- if (row.isOverflow && !letterSpacing) row.textMode = true;
2575
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2576
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
2571
2577
  if (mode === TextMode) {
2572
2578
  row.x += indentWidth;
2573
2579
  toTextChar$1(row);
@@ -597,6 +597,7 @@ class Renderer {
597
597
  this.times = 0;
598
598
  this.config = {
599
599
  usePartRender: true,
600
+ ceilPartPixel: true,
600
601
  maxFPS: 120
601
602
  };
602
603
  this.frames = [];
@@ -705,8 +706,9 @@ class Renderer {
705
706
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
706
707
  canvas.save();
707
708
  bounds.spread(Renderer.clipSpread).ceil();
708
- canvas.clearWorld(bounds);
709
- canvas.clipWorld(bounds);
709
+ const {ceilPartPixel: ceilPartPixel} = this.config;
710
+ canvas.clipWorld(bounds, ceilPartPixel);
711
+ canvas.clearWorld(bounds, ceilPartPixel);
710
712
  this.__render(bounds, realBounds);
711
713
  canvas.restore();
712
714
  Run.end(t);
@@ -1628,7 +1630,7 @@ function getPatternData(paint, box, image) {
1628
1630
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1629
1631
  if (paint.mode === "strench") paint.mode = "stretch";
1630
1632
  const {width: width, height: height} = image;
1631
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
1633
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1632
1634
  const sameBox = box.width === width && box.height === height;
1633
1635
  const data = {
1634
1636
  mode: mode
@@ -1694,6 +1696,10 @@ function getPatternData(paint, box, image) {
1694
1696
  if (opacity && opacity < 1) data.opacity = opacity;
1695
1697
  if (filters) data.filters = filters;
1696
1698
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1699
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1700
+ type: "x",
1701
+ offset: interlace
1702
+ } : interlace;
1697
1703
  return data;
1698
1704
  }
1699
1705
 
@@ -1860,7 +1866,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1860
1866
  if (transform) copy$1(imageMatrix, transform);
1861
1867
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1862
1868
  }
1863
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1869
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1864
1870
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1865
1871
  paint.style = pattern;
1866
1872
  paint.patternId = id;
@@ -1882,8 +1888,8 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1882
1888
 
1883
1889
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1884
1890
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1885
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1886
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1891
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1892
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1887
1893
  return false;
1888
1894
  } else {
1889
1895
  if (drawImage) {
@@ -2557,7 +2563,7 @@ const TextMode = 2;
2557
2563
 
2558
2564
  function layoutChar(drawData, style, width, _height) {
2559
2565
  const {rows: rows} = drawData;
2560
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
2566
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
2561
2567
  const justifyLast = width && textAlign.includes("both");
2562
2568
  const justify = justifyLast || width && textAlign.includes("justify");
2563
2569
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2570,8 +2576,8 @@ function layoutChar(drawData, style, width, _height) {
2570
2576
  remainingWidth = width - row.width - indentWidth;
2571
2577
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2572
2578
  }
2573
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2574
- if (row.isOverflow && !letterSpacing) row.textMode = true;
2579
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2580
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
2575
2581
  if (mode === TextMode) {
2576
2582
  row.x += indentWidth;
2577
2583
  toTextChar$1(row);
@@ -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 m,BranchHelper as y,LeafBoundsHelper as v,Bounds as x,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as T,ImageManager as R,PointHelper as L,BoundsHelper as E,Plugin as A,isObject as P,FourNumberHelper as C,Matrix as M,ImageEvent as O,MatrixHelper as W,MathHelper as D,AlignHelper as I,getMatrixData as F,AroundHelper as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as Y,InteractionBase as X,isUndefined as j,HitCanvasManager as q}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as G,PaintImage as N,ColorConvert as H,PaintGradient as V,Effect as Q,Group as K,TextConvert as Z,Leafer as $}from"@leafer-ui/draw";var J;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(J||(J={}));class tt 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:et,fileType:it}=c;function st(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(et(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(et(it(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 tt(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 nt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){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.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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:at,updateBounds:ot,updateChange:rt}=m,{pushAllChildBranch:ht,pushAllParent:ct}=y;const{worldBounds:lt}=v;class dt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,lt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,lt),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:ut,updateAllChange:ft}=m,gt=b.get("Layouter");class pt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},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){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=T.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?(at(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||ot(s[t])}ot(i)}})}(this.__levelList),function(t){t.list.forEach(rt)}(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,T.end(e)}fullLayout(){const t=T.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)),pt.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),T.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new dt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new dt(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 _t=b.get("Renderer");class wt{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.frames=[],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.requestTime||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,_t.log(e.innerName,"---\x3e");try{this.emitRender(g.START),this.renderOnce(t),this.emitRender(g.END,this.totalBounds),R.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.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=T.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(wt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),T.end(e)}fullRender(){const t=T.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),T.end(t)}__render(t,e){const{canvas:s,target:n}=this,a=t.includes(n.__world),o=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(o.cellList=this.getCellList()),i.render(n,s,o),this.renderBounds=e=e||t,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}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);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__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||_t.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)}}wt.clipSpread=10;const mt={},{copyRadiusPoint:yt}=L,{hitRadiusPoint:vt}=E;class xt{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,!!i.findList),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,s){const n=this.findList=new f;if(t.length){let e;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=t.length;s<a;s++)if(e=t[s],(i||m.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){n.reset();break}return n.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),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),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&&(!i.isLeafer||"draw"!==i.mode));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,n;const{point:a}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],n=i.__,n.visible&&(!e||n.mask))if(s=vt(i.__world,n.hitRadius?yt(mt,a,n.hitRadius):a),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(a,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)}}else s&&this.hitChild(i,a)}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 St{constructor(t,e){this.config={},e&&(this.config=a.default(e,this.config)),this.picker=new xt(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):A.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new nt(t,e),layouter:(t,e)=>new pt(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>new St(t,e)}),i.layout=pt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convertTouch(t,e){const i=bt.getTouch(t),s=Y.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 kt extends X{__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 j(t.x)?super.getLocal(t,e):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=bt.getTouch(t);this.pointerDown(bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=bt.getTouch(t);this.pointerUp(bt.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(Y.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,i){t.__.__font?G.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i,s,n){const a=i.__;P(t)?G.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&G.strokeArrow(t,i,s,n)}function Rt(t,e,i,s,n){const a=i.__;P(t)?G.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),G.drawTextStroke(i,s,n))}function Lt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,Rt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",G.fillText(i,a,n),a.blendMode="normal",m.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}const{getSpread:Et,copyAndSpread:At,toOuterOf:Pt,getOuterOf:Ct,getByMove:Mt,move:Ot,getIntersectData:Wt}=E,Dt={};let It;const{stintSet:Ft}=a,{hasTransparent:zt}=H;function Ut(t,i,s){if(!P(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":if(!i.url)return;n=N.image(s,t,i,a,!It||!It[i.url]);break;case"linear":n=V.linearGradient(i,a);break;case"radial":n=V.radialGradient(i,a);break;case"angular":n=V.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&&(n.originPaint=i,e(n.style)&&zt(n.style)&&(n.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}return n}const Yt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];S(r)||(r=[r]),It=N.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Ut(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?(Ft(i,"__isAlphaPixelFill",n),Ft(i,"__isTransparentFill",a)):(Ft(i,"__isAlphaPixelStroke",n),Ft(i,"__isTransparentStroke",a),Ft(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Bt(e,i,s)},fills:function(t,e,i,s){let n,a,o;for(let r=0,h=t.length;r<h;r++){if(n=t[r],a=n.originPaint,n.image){if(o?o++:o=1,N.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===o&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}a.blendMode&&(i.blendMode=a.blendMode),Bt(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),Bt(e,i,s),i.restoreBlendMode()):Bt(e,i,s)}},fillPathOrText:Bt,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)G.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Tt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Tt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)Tt(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Tt(t,2,e,o,s),o.clipUI(n),o.clearWorld(a),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){G.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i,s);break;case"inside":Lt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i,s):Lt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:o}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(o){const{decorationHeight:t}=n;a.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let o;const r=s.__,{__hasMultiStrokeStyle:h}=r;h||n.setStroke(void 0,r.__strokeWidth*e,r);for(let c=0,l=t.length;c<l;c++)if(o=t[c],(!o.image||!N.checkImage(o,!1,s,n,a))&&o.style){if(h){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.originPaint.blendMode?(n.saveBlendMode(o.originPaint.blendMode),i?G.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?G.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,o=t.__nowWorld,r=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,l,d,u,f,g;Pt(r.strokeSpread?(At(Dt,r.boxBounds,r.strokeSpread),Dt):r.boxBounds,o,h);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(h))g=n,c=f=h,l=o;else{let n;if(i.fullImageShadow)n=h;else{const t=r.renderShapeSpread?Et(a,C.swapAndScale(r.renderShapeSpread,p,_)):a;n=Wt(t,h)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(g=e.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=m),f=Ct(h,u),c=Mt(f,-u.e,-u.f),l=Ct(o,u),Ot(l,-u.e,-u.f);const y=s.matrix;y?(d=new M(u),d.multiply(y),w*=y.scaleX,m*=y.scaleY):d=u,d.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:c,renderBounds:l,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Xt,jt=new x;const{isSame:qt}=E;function Gt(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||N.createData(n,s,i,a),!0}function Nt(t,e){Qt(t,O.LOAD,e)}function Ht(t,e){Qt(t,O.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,O.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new O(e,i))}function Kt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,translate:$t}=W,Jt=new x,te={},ee={};function ie(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 se={},ne=F();const{get:ae,set:oe,rotateOfOuter:re,translate:he,scaleOfOuter:ce,multiplyParent:le,scale:de,rotate:ue,skew:fe}=W;function ge(t,e,i,s,n,a,o,r){o&&ue(t,o),r&&fe(t,r.x,r.y),n&&de(t,n,a),he(t,e.x+i,e.y+s)}function pe(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{get:_e,scale:we,copy:me}=W,{getFloorScale:ye}=D,{abs:ve}=Math;const xe={image:function(t,e,i,s,n){let a,o;const r=R.get(i);return Xt&&i===Xt.paint&&qt(s,Xt.boxBounds)?a=Xt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Xt=r.use>1?{leafPaint:a,paint:i,boxBounds:jt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,s),n&&(Nt(t,o),Ht(t,o))):r.error?n&&Vt(t,o,r.error):(n&&(Kt(t,!0),Nt(t,o)),a.loadId=r.load(()=>{Kt(t,!1),t.destroyed||(Gt(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,o)),a.loadId=void 0},e=>{Kt(t,!1),Vt(t,o,e),a.loadId=void 0},i.lod&&r.getThumbSize(i.lod)),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,a){const{scaleX:o,scaleY:r}=N.getImageRenderScaleData(t,s,n,a),{image:c,data:l,originPaint:d}=t,{exporting:u}=a;return!(!l||t.patternId===o+"-"+r&&!u)&&(e&&(l.repeat?e=!1:d.changeful||"miniapp"===i.name&&h.isResizing(s)||u||(e=i.image.isLarge(c,o,r)||c.width*o>8096||c.height*r>8096)),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),N.drawImage(t,o,r,s,n,a),!0):(!t.style||d.sync||u?N.createPattern(t,s,n,a):N.createPatternTask(t,s,n,a),!1))},drawImage:function(t,e,i,s,n,a){const{data:o,image:r}=t,{blendMode:h}=t.originPaint,{opacity:c,transform:l}=o,d=r.getFull(o.filters),u=s.__;let f,{width:g,height:p}=r;(f=l&&!l.onlyScale||u.path||u.cornerRadius)||c||h?(n.save(),f&&n.clipUI(s),h&&(n.blendMode=h),c&&(n.opacity*=c),l&&n.transform(l),n.drawImage(d,0,0,g,p),n.restore()):(o.scaleX&&(g*=o.scaleX,p*=o.scaleY),n.drawImage(d,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(S(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,R.recyclePaint(s),n.loading&&(o||(o=e.__input&&e.__input[t]||[],S(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===r))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=R.patternTasker.add(()=>pe(this,void 0,void 0,function*(){N.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:a,scaleY:o}=N.getImageRenderScaleData(t,e,s,n),r=a+"-"+o;if(t.patternId!==r&&!e.destroyed&&(!i.image.isLarge(t.image,a,o)||t.data.repeat)){const{image:s,data:n}=t,{transform:h,gap:c}=n,l=N.getPatternFixScale(t,a,o);let d,u,f,{width:g,height:p}=s;l&&(a*=l,o*=l),g*=a,p*=o,c&&(u=c.x*a/ve(n.scaleX||1),f=c.y*o/ve(n.scaleY||1)),(h||1!==a||1!==o)&&(a*=ye(g+(u||0)),o*=ye(p+(f||0)),d=_e(),h&&me(d,h),we(d,1/a,1/o));const _=s.getCanvas(g,p,n.opacity,n.filters,u,f,e.leafer&&e.leafer.config.smooth),w=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",d,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,e,s){const{image:n}=t;let a,o=i.image.maxPatternSize,r=n.width*n.height;return n.isSVG?e>1&&(a=Math.ceil(e)/e):o>r&&(o=r),(r*=e*s)>o&&(a=Math.sqrt(o/r)),a},createData:function(t,e,i,s){t.data=N.getPatternData(i,s,e)},getPatternData:function(t,i,s){t.padding&&(i=Jt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:a}=s,{opacity:o,mode:r,align:h,offset:c,scale:l,size:d,rotation:u,skew:f,clipSize:g,repeat:p,gap:_,filters:w}=t,m=i.width===n&&i.height===a,y={mode:r},v="center"!==h&&(u||0)%180==90;let x,S;switch(E.set(ee,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((l||d)&&(D.getScaleData(l,d,s,te),x=te.scaleX,S=te.scaleY),(h||_||p)&&(x&&E.scale(ee,x,S,!0),h&&I.toPoint(h,ee,i,ee,!0,!0))):m&&!u||(x=S=E.getFitScale(i,ee,"fit"!==r),E.put(i,s,h,x,!1,ee),E.scale(ee,x,S,!0)),c&&L.move(ee,c),r){case"stretch":m?x&&(x=S=void 0):(x=i.width/n,S=i.height/a,N.stretchMode(y,i,x,S));break;case"normal":case"clip":if(ee.x||ee.y||x||g||u||f){let t,e;g&&(t=i.width/g.width,e=i.height/g.height),N.clipMode(y,i,ee.x,ee.y,x,S,u,f,t,e),t&&(x=x?x*t:t,S=S?S*e:e)}break;case"repeat":(!m||x||u||f)&&N.repeatMode(y,i,n,a,ee.x,ee.y,x,S,u,f,h,t.freeTransform),p||(y.repeat="repeat");const e=P(p);(_||e)&&(y.gap=function(t,e,i,s,n){let a,o;P(t)?(a=t.x,o=t.y):a=o=t;return{x:ie(a,i,n.width,e&&e.x),y:ie(o,s,n.height,e&&e.y)}}(_,e&&p,ee.width,ee.height,i));break;default:x&&N.fillOrFitMode(y,i,ee.x,ee.y,x,S,u)}return y.transform||(i.x||i.y)&&$t(y.transform=Zt(),i.x,i.y),x&&(y.scaleX=x,y.scaleY=S),o&&o<1&&(y.opacity=o),w&&(y.filters=w),p&&(y.repeat=e(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const n=ae(),{x:a,y:o}=e;a||o?he(n,a,o):n.onlyScale=!0,de(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,o){const r=ae();he(r,e.x+i,e.y+s),de(r,n,a),o&&re(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,i,s,n,a,o,r,h,c){const l=ae();ge(l,e,i,s,n,a,o,r),h&&(o||r?(oe(ne),ce(ne,e,h,c),le(l,ne)):ce(l,e,h,c)),t.transform=l},repeatMode:function(t,e,i,s,n,a,o,r,h,c,l,d){const u=ae();if(d)ge(u,e,n,a,o,r,h,c);else{if(h)if("center"===l)re(u,{x:i/2,y:s/2},h);else switch(ue(u,h),h){case 90:he(u,s,0);break;case 180:he(u,i,s);break;case 270:he(u,0,i)}se.x=e.x+n,se.y=e.y+a,he(u,se.x,se.y),o&&ce(u,se,o,r)}t.transform=u}},{toPoint:Se}=z,{hasTransparent:be}=H,ke={},Be={};function Te(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&&be(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Re,getDistance:Le}=L,{get:Ee,rotateOfOuter:Ae,scaleOfOuter:Pe}=W,{toPoint:Ce}=z,Me={},Oe={};function We(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Re(e,i);a=Ee(),n?(Pe(a,e,o/r*(s||1),1),Ae(a,e,t+90)):(Pe(a,e,1,o/r*(s||1)),Ae(a,e,t))}return a}const{getDistance:De}=L,{toPoint:Ie}=z,Fe={},ze={};const Ue={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;Se(s||"top",e,ke),Se(n||"bottom",e,Be);const r=i.canvas.createLinearGradient(ke.x,ke.y,Be.x,Be.y),h={type:a,style:r};return Te(h,r,t.stops,o),h},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ce(s||"center",e,Me),Ce(n||"bottom",e,Oe);const h=i.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Le(Me,Oe)),c={type:a,style:h};Te(c,h,t.stops,o);const l=We(e,Me,Oe,r,!0);return l&&(c.transform=l),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ie(s||"center",e,Fe),Ie(n||"bottom",e,ze);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Fe.x,Fe.y):i.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,De(Fe,ze)),c={type:a,style:h};Te(c,h,t.stops,o);const l=We(e,Fe,ze,r||1,i.conicGradientRotate90);return l&&(c.transform=l),c},getTransform:We},{copy:Ye,move:Xe,toOffsetOutBounds:je}=E,{max:qe,abs:Ge}=Math,Ne={},He=new M,Ve={};function Qe(t,e){let i,s,n,a,o=0,r=0,h=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=Ge(t.spread||0),o=qe(o,n+a-s),r=qe(r,n+a+i),h=qe(h,n+a+s),c=qe(c,n+a-i)}),o===r&&r===h&&h===c?o:[o,r,h,c]}function Ke(t,e,s){const{shapeBounds:n}=s;let a,o;i.fullImageShadow?(Ye(Ne,t.bounds),Xe(Ne,e.x-n.x,e.y-n.y),a=t.bounds,o=Ne):(a=n,o=e),t.copyWorld(s.canvas,a,o)}const{toOffsetOutBounds:Ze}=E,$e={};const Je=Qe;const ti={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:h,renderBounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;je(h,Ve,c),o.forEach((o,p)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ve.offsetX+(o.x||0)*d*_,Ve.offsetY+(o.y||0)*u*_,(o.blur||0)*d*_,H.string(o.color)),n=Q.getShadowTransform(t,f,i,o,Ve,_),n&&f.setTransform(n),Ke(f,Ve,i),n&&f.resetTransform(),s=c,o.box&&(f.restore(),f.save(),r&&(f.copyWorld(f,c,a,"copy"),s=a),r?f.copyWorld(r,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,o.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:h,renderBounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;Ze(h,$e,c),o.forEach((o,p)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow($e.offsetX+(o.x||0)*d*_,$e.offsetY+(o.y||0)*u*_,(o.blur||0)*d*_),n=Q.getShadowTransform(t,f,i,o,$e,_,!0),n&&f.setTransform(n),Ke(f,$e,i),f.restore(),r?(f.copyWorld(f,c,a,"copy"),f.copyWorld(r,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=c),f.fillWorld(s,H.string(o.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,o.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){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,i,s,n,a,o){if(s.spread){const i=2*s.spread*a*(o?-1:1),{width:r,height:h}=t.__layout.strokeBounds;return He.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/r,1+i/h),He}},isTransformShadow(t){},getInnerShadowSpread:Je},{excludeRenderBounds:ei}=v;let ii;function si(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ii||(ii=!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);ai(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ai(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ni(t){return t.getSameCanvas(!1,!0)}function ai(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)}K.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&&(si(this,o,t,n,s,a,void 0,!0),s=n=null),"clipping"!==r&&"clipping-path"!==r||ei(i,e)||i.__render(t,e),a=i.__.opacity,ii=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ni(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ni(t)),n||(n=ni(t)),i.__render(s,e));continue}const l=1===a&&i.__.__blendMode;l&&si(this,o,t,n,s,a,void 0,!1),ei(i,e)||i.__render(n||t,e),l&&si(this,o,t,n,s,a,l,!1)}si(this,o,t,n,s,a,void 0,!0)};const oi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ri=oi+"_#~&*+\\=|≮≯≈≠=…",hi=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 ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const li=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),di=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ui=ci(oi),fi=ci(ri),gi=ci("- —/~|┆·");var pi;!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"}(pi||(pi={}));const{Letter:_i,Single:wi,Before:mi,After:yi,Symbol:vi,Break:xi}=pi;function Si(t){return li[t]?_i:gi[t]?xi:di[t]?mi:ui[t]?yi:fi[t]?vi:hi.test(t)?wi:_i}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 ki(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:Bi}=bi,{Letter:Ti,Single:Ri,Before:Li,After:Ei,Symbol:Ai,Break:Pi}=pi;let Ci,Mi,Oi,Wi,Di,Ii,Fi,zi,Ui,Yi,Xi,ji,qi,Gi,Ni,Hi,Vi,Qi=[];function Ki(t,e){Ui&&!zi&&(zi=Ui),Ci.data.push({char:t,width:e}),Oi+=e}function Zi(){Wi+=Oi,Ci.width=Oi,Mi.words.push(Ci),Ci={data:[]},Oi=0}function $i(){Gi&&(Ni.paraNumber++,Mi.paraStart=!0,Gi=!1),Ui&&(Mi.startCharSize=zi,Mi.endCharSize=Ui,zi=0),Mi.width=Wi,Hi.width?Bi(Mi):Vi&&Ji(),Qi.push(Mi),Mi={words:[]},Wi=0}function Ji(){Wi>(Ni.maxWidth||0)&&(Ni.maxWidth=Wi)}const{top:ts,right:es,bottom:is,left:ss}=U;function ns(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 as={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{__padding:h}=s;h&&(o?(n=h[ss],o-=h[es]+h[ss],!o&&(o=.01)):s.autoSizeAlign||(n=h[ss]),r?(a=h[ts],r-=h[ts]+h[is],!r&&(r=.01)):s.autoSizeAlign||(a=h[ts]));const c={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Ni=t,Qi=t.rows,Hi=t.bounds,Vi=!Hi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:h}=Hi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Gi=!0,Xi=null,zi=Fi=Ui=Oi=Wi=0,Ci={data:[]},Mi={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Ii=e[s],"\n"===Ii?(Oi&&Zi(),Mi.paraEnd=!0,$i(),Gi=!0):(Yi=Si(Ii),Yi===Ti&&"none"!==o&&(Ii=ki(Ii,o,!Oi)),Fi=r.measureText(Ii).width,n&&(n<0&&(Ui=Fi),Fi+=n),ji=Yi===Ri&&(Xi===Ri||Xi===Ti)||Xi===Ri&&Yi!==Ei,qi=!(Yi!==Li&&Yi!==Ri||Xi!==Ai&&Xi!==Ei),Di=Gi&&a?h-a:h,t&&h&&Wi+Oi+Fi>Di&&(i?(Oi&&Zi(),Wi&&$i()):(qi||(qi=Yi===Ti&&Xi==Ei),ji||qi||Yi===Pi||Yi===Li||Yi===Ri||Oi+Fi>Di?(Oi&&Zi(),Wi&&$i()):Wi&&$i()))," "===Ii&&!0!==Gi&&Wi+Oi===0||(Yi===Pi?(" "===Ii&&Oi&&Zi(),Ki(Ii,Fi),Zi()):ji||qi?(Oi&&Zi(),Ki(Ii,Fi)):Ki(Ii,Fi)),Xi=Yi);Oi&&Zi(),Wi&&$i(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ni.paraNumber++,Wi=r.measureText(t).width,Qi.push({x:a||0,text:t,width:Wi,paraStart:!0}),Vi&&Ji()})}(c,t,s),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ns(e,"x",t[ss]);break;case"right":ns(e,"x",-t[es])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ns(e,"y",t[ts]);break;case"bottom":ns(e,"y",-t[is])}}(h,c,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),m=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}m+=g;let y,v,x,S=p||u?p:t.maxWidth;for(let o=0,l=n;o<l;o++){if(y=i[o],y.x=f,y.width<p||y.width>p&&!h)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&d&&o>0&&(m+=d),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.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&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e,r=i&&n.includes("both"),h=r||i&&n.includes("justify"),c=h&&n.includes("letter");let l,d,u,f,g,p,_,w,m,y;s.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,w=t.words.length,h&&(y=!t.paraEnd||r,d=i-t.width-g,c?f=d/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?d/(w-1):0),p=o||t.isOverflow||c?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,l=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:l},l=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,l,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):l=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,l,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(l+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,o),c.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)}})}}(c,s,n,o),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,P(a)?(i=a.type,a.color&&(t.decorationColor=H.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,s),c}};const os={string:function(t,i){if(!t)return"#000";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(Z,as),Object.assign(H,os),Object.assign(G,Yt),Object.assign(N,xe),Object.assign(V,Ue),Object.assign(Q,ti),Object.assign(l,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new q}),$.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&st(0,wx)}catch(t){}export{kt as Interaction,pt as Layouter,tt as LeaferCanvas,J as PathNodeHandleType,xt as Picker,wt as Renderer,St as Selector,nt as Watcher,st 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 m,BranchHelper as y,LeafBoundsHelper as v,Bounds as x,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as T,ImageManager as R,PointHelper as L,BoundsHelper as E,Plugin as A,isObject as P,FourNumberHelper as C,Matrix as M,ImageEvent as O,MatrixHelper as W,MathHelper as D,AlignHelper as I,getMatrixData as F,AroundHelper as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as Y,InteractionBase as X,isUndefined as j,HitCanvasManager as q}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as G,PaintImage as N,ColorConvert as H,PaintGradient as V,Effect as Q,Group as K,TextConvert as Z,Leafer as $}from"@leafer-ui/draw";var J;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(J||(J={}));class tt 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:et,fileType:it}=c;function st(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(et(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(et(it(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 tt(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 nt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){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.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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:at,updateBounds:ot,updateChange:rt}=m,{pushAllChildBranch:ht,pushAllParent:ct}=y;const{worldBounds:lt}=v;class dt{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,lt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,lt),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:ut,updateAllChange:ft}=m,gt=b.get("Layouter");class pt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},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){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=T.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?(at(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||ot(s[t])}ot(i)}})}(this.__levelList),function(t){t.list.forEach(rt)}(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,T.end(e)}fullLayout(){const t=T.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)),pt.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),T.end(t)}static fullLayout(t){ut(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),ft(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new dt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new dt(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 _t=b.get("Renderer");class wt{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],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.requestTime||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,_t.log(e.innerName,"---\x3e");try{this.emitRender(g.START),this.renderOnce(t),this.emitRender(g.END,this.totalBounds),R.clearRecycled()}catch(t){this.rendering=!1,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.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=T.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(wt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(s,a),i.clearWorld(s,a),this.__render(s,n),i.restore(),T.end(e)}fullRender(){const t=T.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),T.end(t)}__render(t,e){const{canvas:s,target:n}=this,a=t.includes(n.__world),o=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(o.cellList=this.getCellList()),i.render(n,s,o),this.renderBounds=e=e||t,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}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);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__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||_t.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)}}wt.clipSpread=10;const mt={},{copyRadiusPoint:yt}=L,{hitRadiusPoint:vt}=E;class xt{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,!!i.findList),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,s){const n=this.findList=new f;if(t.length){let e;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=t.length;s<a;s++)if(e=t[s],(i||m.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){n.reset();break}return n.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),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),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&&(!i.isLeafer||"draw"!==i.mode));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,n;const{point:a}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],n=i.__,n.visible&&(!e||n.mask))if(s=vt(i.__world,n.hitRadius?yt(mt,a,n.hitRadius):a),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(a,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)}}else s&&this.hitChild(i,a)}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 St{constructor(t,e){this.config={},e&&(this.config=a.default(e,this.config)),this.picker=new xt(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):A.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new nt(t,e),layouter:(t,e)=>new pt(t,e),renderer:(t,e,i)=>new wt(t,e,i),selector:(t,e)=>new St(t,e)}),i.layout=pt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convertTouch(t,e){const i=bt.getTouch(t),s=Y.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 kt extends X{__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 j(t.x)?super.getLocal(t,e):{x:t.x,y:t.y}}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=bt.getTouch(t);this.pointerDown(bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=bt.getTouch(t);this.pointerUp(bt.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(Y.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,i){t.__.__font?G.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i,s,n){const a=i.__;P(t)?G.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&G.strokeArrow(t,i,s,n)}function Rt(t,e,i,s,n){const a=i.__;P(t)?G.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),G.drawTextStroke(i,s,n))}function Lt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,Rt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",G.fillText(i,a,n),a.blendMode="normal",m.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}const{getSpread:Et,copyAndSpread:At,toOuterOf:Pt,getOuterOf:Ct,getByMove:Mt,move:Ot,getIntersectData:Wt}=E,Dt={};let It;const{stintSet:Ft}=a,{hasTransparent:zt}=H;function Ut(t,i,s){if(!P(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":if(!i.url)return;n=N.image(s,t,i,a,!It||!It[i.url]);break;case"linear":n=V.linearGradient(i,a);break;case"radial":n=V.radialGradient(i,a);break;case"angular":n=V.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&&(n.originPaint=i,e(n.style)&&zt(n.style)&&(n.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}return n}const Yt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];S(r)||(r=[r]),It=N.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Ut(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?(Ft(i,"__isAlphaPixelFill",n),Ft(i,"__isTransparentFill",a)):(Ft(i,"__isAlphaPixelStroke",n),Ft(i,"__isTransparentStroke",a),Ft(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Bt(e,i,s)},fills:function(t,e,i,s){let n,a,o;for(let r=0,h=t.length;r<h;r++){if(n=t[r],a=n.originPaint,n.image){if(o?o++:o=1,N.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===o&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}a.blendMode&&(i.blendMode=a.blendMode),Bt(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),Bt(e,i,s),i.restoreBlendMode()):Bt(e,i,s)}},fillPathOrText:Bt,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)G.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Tt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Tt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)Tt(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Tt(t,2,e,o,s),o.clipUI(n),o.clearWorld(a),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){G.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i,s);break;case"inside":Lt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i,s):Lt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:o}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(o){const{decorationHeight:t}=n;a.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let o;const r=s.__,{__hasMultiStrokeStyle:h}=r;h||n.setStroke(void 0,r.__strokeWidth*e,r);for(let c=0,l=t.length;c<l;c++)if(o=t[c],(!o.image||!N.checkImage(o,!1,s,n,a))&&o.style){if(h){const{strokeStyle:t}=o;t?n.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(o.style,r.__strokeWidth*e,r)}else n.strokeStyle=o.style;o.originPaint.blendMode?(n.saveBlendMode(o.originPaint.blendMode),i?G.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?G.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,o=t.__nowWorld,r=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,l,d,u,f,g;Pt(r.strokeSpread?(At(Dt,r.boxBounds,r.strokeSpread),Dt):r.boxBounds,o,h);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(h))g=n,c=f=h,l=o;else{let n;if(i.fullImageShadow)n=h;else{const t=r.renderShapeSpread?Et(a,C.swapAndScale(r.renderShapeSpread,p,_)):a;n=Wt(t,h)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(g=e.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=m),f=Ct(h,u),c=Mt(f,-u.e,-u.f),l=Ct(o,u),Ot(l,-u.e,-u.f);const y=s.matrix;y?(d=new M(u),d.multiply(y),w*=y.scaleX,m*=y.scaleY):d=u,d.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:c,renderBounds:l,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Xt,jt=new x;const{isSame:qt}=E;function Gt(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||N.createData(n,s,i,a),!0}function Nt(t,e){Qt(t,O.LOAD,e)}function Ht(t,e){Qt(t,O.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,O.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new O(e,i))}function Kt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,translate:$t}=W,Jt=new x,te={},ee={};function ie(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 se={},ne=F();const{get:ae,set:oe,rotateOfOuter:re,translate:he,scaleOfOuter:ce,multiplyParent:le,scale:de,rotate:ue,skew:fe}=W;function ge(t,e,i,s,n,a,o,r){o&&ue(t,o),r&&fe(t,r.x,r.y),n&&de(t,n,a),he(t,e.x+i,e.y+s)}function pe(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{get:_e,scale:we,copy:me}=W,{getFloorScale:ye}=D,{abs:ve}=Math;const xe={image:function(t,e,i,s,n){let a,o;const r=R.get(i);return Xt&&i===Xt.paint&&qt(s,Xt.boxBounds)?a=Xt.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),Xt=r.use>1?{leafPaint:a,paint:i,boxBounds:jt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,s),n&&(Nt(t,o),Ht(t,o))):r.error?n&&Vt(t,o,r.error):(n&&(Kt(t,!0),Nt(t,o)),a.loadId=r.load(()=>{Kt(t,!1),t.destroyed||(Gt(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,o)),a.loadId=void 0},e=>{Kt(t,!1),Vt(t,o,e),a.loadId=void 0},i.lod&&r.getThumbSize(i.lod)),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,a){const{scaleX:o,scaleY:r}=N.getImageRenderScaleData(t,s,n,a),{image:c,data:l,originPaint:d}=t,{exporting:u,snapshot:f}=a;return!(!l||t.patternId===o+"-"+r&&!u||f)&&(e&&(l.repeat?e=!1:d.changeful||"miniapp"===i.name&&h.isResizing(s)||u||(e=i.image.isLarge(c,o,r)||c.width*o>8096||c.height*r>8096)),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),N.drawImage(t,o,r,s,n,a),!0):(!t.style||d.sync||u?N.createPattern(t,s,n,a):N.createPatternTask(t,s,n,a),!1))},drawImage:function(t,e,i,s,n,a){const{data:o,image:r}=t,{blendMode:h}=t.originPaint,{opacity:c,transform:l}=o,d=r.getFull(o.filters),u=s.__;let f,{width:g,height:p}=r;(f=l&&!l.onlyScale||u.path||u.cornerRadius)||c||h?(n.save(),f&&n.clipUI(s),h&&(n.blendMode=h),c&&(n.opacity*=c),l&&n.transform(l),n.drawImage(d,0,0,g,p),n.restore()):(o.scaleX&&(g*=o.scaleX,p*=o.scaleY),n.drawImage(d,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(S(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,R.recyclePaint(s),n.loading&&(o||(o=e.__input&&e.__input[t]||[],S(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===r))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=R.patternTasker.add(()=>pe(this,void 0,void 0,function*(){N.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:a,scaleY:o}=N.getImageRenderScaleData(t,e,s,n),r=a+"-"+o;if(t.patternId!==r&&!e.destroyed&&(!i.image.isLarge(t.image,a,o)||t.data.repeat)){const{image:s,data:n}=t,{transform:h,gap:c}=n,l=N.getPatternFixScale(t,a,o);let d,u,f,{width:g,height:p}=s;l&&(a*=l,o*=l),g*=a,p*=o,c&&(u=c.x*a/ve(n.scaleX||1),f=c.y*o/ve(n.scaleY||1)),(h||1!==a||1!==o)&&(a*=ye(g+(u||0)),o*=ye(p+(f||0)),d=_e(),h&&me(d,h),we(d,1/a,1/o));const _=s.getCanvas(g,p,n.opacity,n.filters,u,f,e.leafer&&e.leafer.config.smooth,n.interlace),w=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",d,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,e,s){const{image:n}=t;let a,o=i.image.maxPatternSize,r=n.width*n.height;return n.isSVG?e>1&&(a=Math.ceil(e)/e):o>r&&(o=r),(r*=e*s)>o&&(a=Math.sqrt(o/r)),a},createData:function(t,e,i,s){t.data=N.getPatternData(i,s,e)},getPatternData:function(t,i,n){t.padding&&(i=Jt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:o}=n,{opacity:r,mode:h,align:c,offset:l,scale:d,size:u,rotation:f,skew:g,clipSize:p,repeat:_,gap:w,filters:m,interlace:y}=t,v=i.width===a&&i.height===o,x={mode:h},S="center"!==c&&(f||0)%180==90;let b,k;switch(E.set(ee,0,0,S?o:a,S?a:o),h&&"cover"!==h&&"fit"!==h?((d||u)&&(D.getScaleData(d,u,n,te),b=te.scaleX,k=te.scaleY),(c||w||_)&&(b&&E.scale(ee,b,k,!0),c&&I.toPoint(c,ee,i,ee,!0,!0))):v&&!f||(b=k=E.getFitScale(i,ee,"fit"!==h),E.put(i,n,c,b,!1,ee),E.scale(ee,b,k,!0)),l&&L.move(ee,l),h){case"stretch":v?b&&(b=k=void 0):(b=i.width/a,k=i.height/o,N.stretchMode(x,i,b,k));break;case"normal":case"clip":if(ee.x||ee.y||b||p||f||g){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),N.clipMode(x,i,ee.x,ee.y,b,k,f,g,t,e),t&&(b=b?b*t:t,k=k?k*e:e)}break;case"repeat":(!v||b||f||g)&&N.repeatMode(x,i,a,o,ee.x,ee.y,b,k,f,g,c,t.freeTransform),_||(x.repeat="repeat");const e=P(_);(w||e)&&(x.gap=function(t,e,i,s,n){let a,o;P(t)?(a=t.x,o=t.y):a=o=t;return{x:ie(a,i,n.width,e&&e.x),y:ie(o,s,n.height,e&&e.y)}}(w,e&&_,ee.width,ee.height,i));break;default:b&&N.fillOrFitMode(x,i,ee.x,ee.y,b,k,f)}return x.transform||(i.x||i.y)&&$t(x.transform=Zt(),i.x,i.y),b&&(x.scaleX=b,x.scaleY=k),r&&r<1&&(x.opacity=r),m&&(x.filters=m),_&&(x.repeat=e(_)?"x"===_?"repeat-x":"repeat-y":"repeat"),y&&(x.interlace=s(y)||"percent"===y.type?{type:"x",offset:y}:y),x},stretchMode:function(t,e,i,s){const n=ae(),{x:a,y:o}=e;a||o?he(n,a,o):n.onlyScale=!0,de(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,o){const r=ae();he(r,e.x+i,e.y+s),de(r,n,a),o&&re(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,i,s,n,a,o,r,h,c){const l=ae();ge(l,e,i,s,n,a,o,r),h&&(o||r?(oe(ne),ce(ne,e,h,c),le(l,ne)):ce(l,e,h,c)),t.transform=l},repeatMode:function(t,e,i,s,n,a,o,r,h,c,l,d){const u=ae();if(d)ge(u,e,n,a,o,r,h,c);else{if(h)if("center"===l)re(u,{x:i/2,y:s/2},h);else switch(ue(u,h),h){case 90:he(u,s,0);break;case 180:he(u,i,s);break;case 270:he(u,0,i)}se.x=e.x+n,se.y=e.y+a,he(u,se.x,se.y),o&&ce(u,se,o,r)}t.transform=u}},{toPoint:Se}=z,{hasTransparent:be}=H,ke={},Be={};function Te(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&&be(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Re,getDistance:Le}=L,{get:Ee,rotateOfOuter:Ae,scaleOfOuter:Pe}=W,{toPoint:Ce}=z,Me={},Oe={};function We(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Re(e,i);a=Ee(),n?(Pe(a,e,o/r*(s||1),1),Ae(a,e,t+90)):(Pe(a,e,1,o/r*(s||1)),Ae(a,e,t))}return a}const{getDistance:De}=L,{toPoint:Ie}=z,Fe={},ze={};const Ue={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;Se(s||"top",e,ke),Se(n||"bottom",e,Be);const r=i.canvas.createLinearGradient(ke.x,ke.y,Be.x,Be.y),h={type:a,style:r};return Te(h,r,t.stops,o),h},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ce(s||"center",e,Me),Ce(n||"bottom",e,Oe);const h=i.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Le(Me,Oe)),c={type:a,style:h};Te(c,h,t.stops,o);const l=We(e,Me,Oe,r,!0);return l&&(c.transform=l),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ie(s||"center",e,Fe),Ie(n||"bottom",e,ze);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,Fe.x,Fe.y):i.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,De(Fe,ze)),c={type:a,style:h};Te(c,h,t.stops,o);const l=We(e,Fe,ze,r||1,i.conicGradientRotate90);return l&&(c.transform=l),c},getTransform:We},{copy:Ye,move:Xe,toOffsetOutBounds:je}=E,{max:qe,abs:Ge}=Math,Ne={},He=new M,Ve={};function Qe(t,e){let i,s,n,a,o=0,r=0,h=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=Ge(t.spread||0),o=qe(o,n+a-s),r=qe(r,n+a+i),h=qe(h,n+a+s),c=qe(c,n+a-i)}),o===r&&r===h&&h===c?o:[o,r,h,c]}function Ke(t,e,s){const{shapeBounds:n}=s;let a,o;i.fullImageShadow?(Ye(Ne,t.bounds),Xe(Ne,e.x-n.x,e.y-n.y),a=t.bounds,o=Ne):(a=n,o=e),t.copyWorld(s.canvas,a,o)}const{toOffsetOutBounds:Ze}=E,$e={};const Je=Qe;const ti={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:h,renderBounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;je(h,Ve,c),o.forEach((o,p)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ve.offsetX+(o.x||0)*d*_,Ve.offsetY+(o.y||0)*u*_,(o.blur||0)*d*_,H.string(o.color)),n=Q.getShadowTransform(t,f,i,o,Ve,_),n&&f.setTransform(n),Ke(f,Ve,i),n&&f.resetTransform(),s=c,o.box&&(f.restore(),f.save(),r&&(f.copyWorld(f,c,a,"copy"),s=a),r?f.copyWorld(r,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,o.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:h,renderBounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=o.length-1;Ze(h,$e,c),o.forEach((o,p)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow($e.offsetX+(o.x||0)*d*_,$e.offsetY+(o.y||0)*u*_,(o.blur||0)*d*_),n=Q.getShadowTransform(t,f,i,o,$e,_,!0),n&&f.setTransform(n),Ke(f,$e,i),f.restore(),r?(f.copyWorld(f,c,a,"copy"),f.copyWorld(r,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=c),f.fillWorld(s,H.string(o.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,o.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){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,i,s,n,a,o){if(s.spread){const i=2*s.spread*a*(o?-1:1),{width:r,height:h}=t.__layout.strokeBounds;return He.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/r,1+i/h),He}},isTransformShadow(t){},getInnerShadowSpread:Je},{excludeRenderBounds:ei}=v;let ii;function si(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ii||(ii=!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);ai(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ai(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ni(t){return t.getSameCanvas(!1,!0)}function ai(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)}K.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&&(si(this,o,t,n,s,a,void 0,!0),s=n=null),"clipping"!==r&&"clipping-path"!==r||ei(i,e)||i.__render(t,e),a=i.__.opacity,ii=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ni(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ni(t)),n||(n=ni(t)),i.__render(s,e));continue}const l=1===a&&i.__.__blendMode;l&&si(this,o,t,n,s,a,void 0,!1),ei(i,e)||i.__render(n||t,e),l&&si(this,o,t,n,s,a,l,!1)}si(this,o,t,n,s,a,void 0,!0)};const oi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ri=oi+"_#~&*+\\=|≮≯≈≠=…",hi=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 ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const li=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),di=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ui=ci(oi),fi=ci(ri),gi=ci("- —/~|┆·");var pi;!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"}(pi||(pi={}));const{Letter:_i,Single:wi,Before:mi,After:yi,Symbol:vi,Break:xi}=pi;function Si(t){return li[t]?_i:gi[t]?xi:di[t]?mi:ui[t]?yi:fi[t]?vi:hi.test(t)?wi:_i}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 ki(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:Bi}=bi,{Letter:Ti,Single:Ri,Before:Li,After:Ei,Symbol:Ai,Break:Pi}=pi;let Ci,Mi,Oi,Wi,Di,Ii,Fi,zi,Ui,Yi,Xi,ji,qi,Gi,Ni,Hi,Vi,Qi=[];function Ki(t,e){Ui&&!zi&&(zi=Ui),Ci.data.push({char:t,width:e}),Oi+=e}function Zi(){Wi+=Oi,Ci.width=Oi,Mi.words.push(Ci),Ci={data:[]},Oi=0}function $i(){Gi&&(Ni.paraNumber++,Mi.paraStart=!0,Gi=!1),Ui&&(Mi.startCharSize=zi,Mi.endCharSize=Ui,zi=0),Mi.width=Wi,Hi.width?Bi(Mi):Vi&&Ji(),Qi.push(Mi),Mi={words:[]},Wi=0}function Ji(){Wi>(Ni.maxWidth||0)&&(Ni.maxWidth=Wi)}const{top:ts,right:es,bottom:is,left:ss}=U;function ns(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 as={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{__padding:h}=s;h&&(o?(n=h[ss],o-=h[es]+h[ss],!o&&(o=.01)):s.autoSizeAlign||(n=h[ss]),r?(a=h[ts],r-=h[ts]+h[is],!r&&(r=.01)):s.autoSizeAlign||(a=h[ts]));const c={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Ni=t,Qi=t.rows,Hi=t.bounds,Vi=!Hi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:h}=Hi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Gi=!0,Xi=null,zi=Fi=Ui=Oi=Wi=0,Ci={data:[]},Mi={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Ii=e[s],"\n"===Ii?(Oi&&Zi(),Mi.paraEnd=!0,$i(),Gi=!0):(Yi=Si(Ii),Yi===Ti&&"none"!==o&&(Ii=ki(Ii,o,!Oi)),Fi=r.measureText(Ii).width,n&&(n<0&&(Ui=Fi),Fi+=n),ji=Yi===Ri&&(Xi===Ri||Xi===Ti)||Xi===Ri&&Yi!==Ei,qi=!(Yi!==Li&&Yi!==Ri||Xi!==Ai&&Xi!==Ei),Di=Gi&&a?h-a:h,t&&h&&Wi+Oi+Fi>Di&&(i?(Oi&&Zi(),Wi&&$i()):(qi||(qi=Yi===Ti&&Xi==Ei),ji||qi||Yi===Pi||Yi===Li||Yi===Ri||Oi+Fi>Di?(Oi&&Zi(),Wi&&$i()):Wi&&$i()))," "===Ii&&!0!==Gi&&Wi+Oi===0||(Yi===Pi?(" "===Ii&&Oi&&Zi(),Ki(Ii,Fi),Zi()):ji||qi?(Oi&&Zi(),Ki(Ii,Fi)):Ki(Ii,Fi)),Xi=Yi);Oi&&Zi(),Wi&&$i(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ni.paraNumber++,Wi=r.measureText(t).width,Qi.push({x:a||0,text:t,width:Wi,paraStart:!0}),Vi&&Ji()})}(c,t,s),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ns(e,"x",t[ss]);break;case"right":ns(e,"x",-t[es])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ns(e,"y",t[ts]);break;case"bottom":ns(e,"y",-t[is])}}(h,c,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),m=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}m+=g;let y,v,x,S=p||u?p:t.maxWidth;for(let o=0,l=n;o<l;o++){if(y=i[o],y.x=f,y.width<p||y.width>p&&!h)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&d&&o>0&&(m+=d),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.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&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,__letterSpacing:o}=e,r=i&&n.includes("both"),h=r||i&&n.includes("justify"),c=h&&n.includes("letter");let l,d,u,f,g,p,_,w,m,y;s.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,w=t.words.length,h&&(y=!t.paraEnd||r,d=i-t.width-g,c?f=d/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?d/(w-1):0),p=o||t.isOverflow||c?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,l=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:l},l=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,l,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):l=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,l,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(l+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,o),c.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)}})}}(c,s,n,o),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,P(a)?(i=a.type,a.color&&(t.decorationColor=H.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,s),c}};const os={string:function(t,i){if(!t)return"#000";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(Z,as),Object.assign(H,os),Object.assign(G,Yt),Object.assign(N,xe),Object.assign(V,Ue),Object.assign(Q,ti),Object.assign(l,{interaction:(t,e,i,s)=>new kt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new q}),$.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&st(0,wx)}catch(t){}export{kt as Interaction,pt as Layouter,tt as LeaferCanvas,J as PathNodeHandleType,xt as Picker,wt as Renderer,St as Selector,nt as Watcher,st as useCanvas};
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map