@leafer-ui/miniapp 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/miniapp.cjs CHANGED
@@ -326,7 +326,7 @@ class Watcher {
326
326
  }
327
327
  }
328
328
 
329
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = core.LeafHelper;
329
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
330
330
  const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
331
331
  function updateMatrix(updateList, levelList) {
332
332
  let layout;
@@ -369,15 +369,7 @@ function updateBounds(boundsList) {
369
369
  });
370
370
  }
371
371
  function updateChange(updateList) {
372
- let layout;
373
- updateList.list.forEach(leaf => {
374
- layout = leaf.__layout;
375
- if (layout.opacityChanged)
376
- updateAllWorldOpacity(leaf);
377
- if (layout.stateStyleChanged)
378
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
379
- leaf.__updateChange();
380
- });
372
+ updateList.list.forEach(updateOneChange);
381
373
  }
382
374
 
383
375
  const { worldBounds } = core.LeafBoundsHelper;
@@ -1073,8 +1065,10 @@ class Interaction extends core$1.InteractionBase {
1073
1065
  }
1074
1066
 
1075
1067
  function fillText(ui, canvas) {
1076
- let row, data = ui.__.__textDrawData;
1077
- const { rows, decorationY } = data;
1068
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
1069
+ if (data.__isPlacehold && data.placeholderColor)
1070
+ canvas.fillStyle = data.placeholderColor;
1071
+ let row;
1078
1072
  for (let i = 0, len = rows.length; i < len; i++) {
1079
1073
  row = rows[i];
1080
1074
  if (row.text)
@@ -1083,7 +1077,7 @@ function fillText(ui, canvas) {
1083
1077
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
1084
1078
  }
1085
1079
  if (decorationY) {
1086
- const { decorationColor, decorationHeight } = data;
1080
+ const { decorationColor, decorationHeight } = data.__textDrawData;
1087
1081
  if (decorationColor)
1088
1082
  canvas.fillStyle = decorationColor;
1089
1083
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -1092,38 +1086,44 @@ function fillText(ui, canvas) {
1092
1086
 
1093
1087
  function fill(fill, ui, canvas) {
1094
1088
  canvas.fillStyle = fill;
1095
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1089
+ fillPathOrText(ui, canvas);
1096
1090
  }
1097
1091
  function fills(fills, ui, canvas) {
1098
1092
  let item;
1099
- const { windingRule, __font } = ui.__;
1100
1093
  for (let i = 0, len = fills.length; i < len; i++) {
1101
1094
  item = fills[i];
1102
- if (item.image && draw.PaintImage.checkImage(ui, canvas, item, !__font))
1103
- continue;
1104
- if (item.style) {
1105
- canvas.fillStyle = item.style;
1106
- if (item.transform) {
1107
- canvas.save();
1108
- canvas.transform(item.transform);
1109
- if (item.blendMode)
1110
- canvas.blendMode = item.blendMode;
1111
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1112
- canvas.restore();
1095
+ if (item.image) {
1096
+ if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
1097
+ continue;
1098
+ if (!item.style) {
1099
+ if (!i && item.image.isPlacehold)
1100
+ ui.drawImagePlaceholder(canvas, item.image);
1101
+ continue;
1113
1102
  }
1114
- else {
1115
- if (item.blendMode) {
1116
- canvas.saveBlendMode(item.blendMode);
1117
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1118
- canvas.restoreBlendMode();
1119
- }
1120
- else {
1121
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1122
- }
1103
+ }
1104
+ canvas.fillStyle = item.style;
1105
+ if (item.transform) {
1106
+ canvas.save();
1107
+ canvas.transform(item.transform);
1108
+ if (item.blendMode)
1109
+ canvas.blendMode = item.blendMode;
1110
+ fillPathOrText(ui, canvas);
1111
+ canvas.restore();
1112
+ }
1113
+ else {
1114
+ if (item.blendMode) {
1115
+ canvas.saveBlendMode(item.blendMode);
1116
+ fillPathOrText(ui, canvas);
1117
+ canvas.restoreBlendMode();
1123
1118
  }
1119
+ else
1120
+ fillPathOrText(ui, canvas);
1124
1121
  }
1125
1122
  }
1126
1123
  }
1124
+ function fillPathOrText(ui, canvas) {
1125
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1126
+ }
1127
1127
 
1128
1128
  function strokeText(stroke, ui, canvas) {
1129
1129
  const { strokeAlign } = ui.__;
@@ -1363,6 +1363,7 @@ const PaintModule = {
1363
1363
  compute,
1364
1364
  fill,
1365
1365
  fills,
1366
+ fillPathOrText,
1366
1367
  fillText,
1367
1368
  stroke,
1368
1369
  strokes,
@@ -1555,6 +1556,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1555
1556
  onLoadError(ui, event, error);
1556
1557
  leafPaint.loadId = null;
1557
1558
  });
1559
+ if (ui.placeholderColor)
1560
+ setTimeout(() => {
1561
+ if (!(image.ready || image.isPlacehold)) {
1562
+ image.isPlacehold = true;
1563
+ ui.forceUpdate('surface');
1564
+ }
1565
+ }, 100);
1558
1566
  }
1559
1567
  return leafPaint;
1560
1568
  }
@@ -2655,4 +2663,3 @@ Object.keys(core$1).forEach(function (k) {
2655
2663
  get: function () { return core$1[k]; }
2656
2664
  });
2657
2665
  });
2658
- //# sourceMappingURL=miniapp.cjs.map
@@ -327,7 +327,7 @@ class Watcher {
327
327
  }
328
328
  }
329
329
 
330
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
330
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
331
331
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
332
332
  function updateMatrix(updateList, levelList) {
333
333
  let layout;
@@ -370,15 +370,7 @@ function updateBounds(boundsList) {
370
370
  });
371
371
  }
372
372
  function updateChange(updateList) {
373
- let layout;
374
- updateList.list.forEach(leaf => {
375
- layout = leaf.__layout;
376
- if (layout.opacityChanged)
377
- updateAllWorldOpacity(leaf);
378
- if (layout.stateStyleChanged)
379
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
380
- leaf.__updateChange();
381
- });
373
+ updateList.list.forEach(updateOneChange);
382
374
  }
383
375
 
384
376
  const { worldBounds } = LeafBoundsHelper;
@@ -1074,8 +1066,10 @@ class Interaction extends InteractionBase {
1074
1066
  }
1075
1067
 
1076
1068
  function fillText(ui, canvas) {
1077
- let row, data = ui.__.__textDrawData;
1078
- const { rows, decorationY } = data;
1069
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
1070
+ if (data.__isPlacehold && data.placeholderColor)
1071
+ canvas.fillStyle = data.placeholderColor;
1072
+ let row;
1079
1073
  for (let i = 0, len = rows.length; i < len; i++) {
1080
1074
  row = rows[i];
1081
1075
  if (row.text)
@@ -1084,7 +1078,7 @@ function fillText(ui, canvas) {
1084
1078
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
1085
1079
  }
1086
1080
  if (decorationY) {
1087
- const { decorationColor, decorationHeight } = data;
1081
+ const { decorationColor, decorationHeight } = data.__textDrawData;
1088
1082
  if (decorationColor)
1089
1083
  canvas.fillStyle = decorationColor;
1090
1084
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -1093,38 +1087,44 @@ function fillText(ui, canvas) {
1093
1087
 
1094
1088
  function fill(fill, ui, canvas) {
1095
1089
  canvas.fillStyle = fill;
1096
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1090
+ fillPathOrText(ui, canvas);
1097
1091
  }
1098
1092
  function fills(fills, ui, canvas) {
1099
1093
  let item;
1100
- const { windingRule, __font } = ui.__;
1101
1094
  for (let i = 0, len = fills.length; i < len; i++) {
1102
1095
  item = fills[i];
1103
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
1104
- continue;
1105
- if (item.style) {
1106
- canvas.fillStyle = item.style;
1107
- if (item.transform) {
1108
- canvas.save();
1109
- canvas.transform(item.transform);
1110
- if (item.blendMode)
1111
- canvas.blendMode = item.blendMode;
1112
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1113
- canvas.restore();
1096
+ if (item.image) {
1097
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
1098
+ continue;
1099
+ if (!item.style) {
1100
+ if (!i && item.image.isPlacehold)
1101
+ ui.drawImagePlaceholder(canvas, item.image);
1102
+ continue;
1114
1103
  }
1115
- else {
1116
- if (item.blendMode) {
1117
- canvas.saveBlendMode(item.blendMode);
1118
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1119
- canvas.restoreBlendMode();
1120
- }
1121
- else {
1122
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
1123
- }
1104
+ }
1105
+ canvas.fillStyle = item.style;
1106
+ if (item.transform) {
1107
+ canvas.save();
1108
+ canvas.transform(item.transform);
1109
+ if (item.blendMode)
1110
+ canvas.blendMode = item.blendMode;
1111
+ fillPathOrText(ui, canvas);
1112
+ canvas.restore();
1113
+ }
1114
+ else {
1115
+ if (item.blendMode) {
1116
+ canvas.saveBlendMode(item.blendMode);
1117
+ fillPathOrText(ui, canvas);
1118
+ canvas.restoreBlendMode();
1124
1119
  }
1120
+ else
1121
+ fillPathOrText(ui, canvas);
1125
1122
  }
1126
1123
  }
1127
1124
  }
1125
+ function fillPathOrText(ui, canvas) {
1126
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1127
+ }
1128
1128
 
1129
1129
  function strokeText(stroke, ui, canvas) {
1130
1130
  const { strokeAlign } = ui.__;
@@ -1364,6 +1364,7 @@ const PaintModule = {
1364
1364
  compute,
1365
1365
  fill,
1366
1366
  fills,
1367
+ fillPathOrText,
1367
1368
  fillText,
1368
1369
  stroke,
1369
1370
  strokes,
@@ -1556,6 +1557,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1556
1557
  onLoadError(ui, event, error);
1557
1558
  leafPaint.loadId = null;
1558
1559
  });
1560
+ if (ui.placeholderColor)
1561
+ setTimeout(() => {
1562
+ if (!(image.ready || image.isPlacehold)) {
1563
+ image.isPlacehold = true;
1564
+ ui.forceUpdate('surface');
1565
+ }
1566
+ }, 100);
1559
1567
  }
1560
1568
  return leafPaint;
1561
1569
  }
@@ -2633,4 +2641,3 @@ try {
2633
2641
  catch (_a) { }
2634
2642
 
2635
2643
  export { Interaction, Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
2636
- //# sourceMappingURL=miniapp.esm.js.map
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,FileHelper as a,Creator as r,LeaferImage as h,defineKey as c,LeafList as l,RenderEvent as d,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,LeafBoundsHelper as w,Bounds as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as S,Plugin as R,MatrixHelper as k,MathHelper as E,AlignHelper as L,ImageEvent as T,AroundHelper as A,PointHelper as C,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as M,InteractionBase as O,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as I,PaintGradient as z,Export as F,Group as Y,TextConvert as U,Paint as j,Effect as G,Leafer as N}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:q,fileType:H}=a;function V(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(q(H(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new X(t,e),image:t=>new h(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},c(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;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 l,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:Z,updateAllWorldOpacity:$}=p,{pushAllChildBranch:J,pushAllParent:tt}=_;const{worldBounds:et}=w;class it{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,et),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:st,updateAllChange:nt}=p,ot=m.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&J(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&$(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new l(e));e.emitEvent(new x(i,o,this.times)),at.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){st(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=m.get("Renderer");class ht{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new y(s);i.save(),s.spread(ht.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(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 y(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||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}ht.clipSpread=10;const{hitRadiusPoint:ct}=S;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new l(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new l;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new l;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new l;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new l,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ct(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=r.finder&&r.finder()}getByPoint(t,i,s){const{target:n,picker:o}=this;return e.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(r,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=at.fullLayout;const ut={convertTouch(t,e){const i=ut.getTouch(t),s=M.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class ft extends O{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ut.getTouch(t);this.pointerDown(ut.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ut.getTouch(t);this.pointerMove(ut.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ut.getTouch(t);this.pointerUp(ut.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(M.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function gt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=s;t&&(e.fillStyle=t),n.forEach((t=>o.forEach((s=>e.fillRect(t.x,t.y+s,t.width,i)))))}}function pt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?yt(t,!0,e,i):wt(e,i);break;case"inside":_t("inside",t,n,e,i);break;case"outside":_t("outside",t,n,e,i)}}function _t(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?yt(e,!0,s,r):wt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",gt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function wt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function yt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&D.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?wt(i,s):s.stroke(),s.restoreBlendMode()):e?wt(i,s):s.stroke())}function mt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:vt,getOuterOf:xt,getByMove:bt,getIntersectData:Bt}=S;let St;function Rt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:I.string(a,r)};case"image":return D.image(i,t,e,s,!St||!St[e.url]);case"linear":return z.linearGradient(e,s);case"radial":return z.radialGradient(e,s);case"angular":return z.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:I.string(e)}:void 0}}const kt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=D.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Rt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?gt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&D.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?gt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?gt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?gt(e,i):n?i.fill(n):i.fill())},fillText:gt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)pt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&mt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)pt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),yt(t,!1,e,i),s.__useArrow&&mt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),yt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),yt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:pt,drawTextStroke:wt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:c,scaleY:l}=n;if(c<0&&(c=-c),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,d=Bt(s?vt(e.bounds,c===l?s*c:[s*l,s*c]):e.bounds,n);a=e.bounds.getFitMatrix(d);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),c*=u,l*=f),r=xt(n,a),o=bt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:c,scaleY:l}}};let Et={};const{get:Lt,rotateOfOuter:Tt,translate:At,scaleOfOuter:Ct,scale:Wt,rotate:Mt}=k;function Ot(t,e,i,s,n,o,a){const r=Lt();At(r,e.x+i,e.y+s),Wt(r,n,o),a&&Tt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Pt(t,e,i,s,n,o,a){const r=Lt();At(r,e.x+i,e.y+s),n&&Wt(r,n,o),a&&Mt(r,a),t.transform=r}function Dt(t,e,i,s,n,o,a,r,h,c){const l=Lt();if(h)if("center"===c)Tt(l,{x:i/2,y:s/2},h);else switch(Mt(l,h),h){case 90:At(l,s,0);break;case 180:At(l,i,s);break;case 270:At(l,0,i)}Et.x=e.x+n,Et.y=e.y+o,At(l,Et.x,Et.y),a&&Ct(l,Et,a,r),t.transform=l}const{get:It,translate:zt}=k,Ft=new y,Yt={},Ut={};function jt(t,e,i,s){const{blendMode:n,changeful:o,sync:a}=i;n&&(t.blendMode=n),o&&(t.changeful=o),a&&(t.sync=a),t.data=Gt(i,s,e)}function Gt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ft.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:c,size:l,rotation:d,repeat:u,filters:f}=t,g=e.width===s&&e.height===n,p={mode:a},_="center"!==r&&(d||0)%180==90,w=_?n:s,y=_?s:n;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(c||l)&&(E.getScaleData(c,l,i,Ut),m=Ut.scaleX,v=Ut.scaleY);else if(!g||d){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-s*m)/2,b+=(e.height-n*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),L.toPoint(r,t,e,Yt,!0),x+=Yt.x,b+=Yt.y}switch(h&&(x+=h.x,b+=h.y),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(x||b||m||d)&&Pt(p,e,x,b,m,v,d);break;case"repeat":(!g||m||d)&&Dt(p,e,s,n,x,b,m,v,d,r),u||(p.repeat="repeat");break;default:m&&Ot(p,e,x,b,m,v,d)}return p.transform||(e.x||e.y)&&(p.transform=It(),zt(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=s,p.height=n,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Nt,Xt=new y;const{isSame:qt}=S;function Ht(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||jt(n,s,i,o),!0}function Vt(t,e){Zt(t,T.LOAD,e)}function Qt(t,e){Zt(t,T.LOADED,e)}function Kt(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,T.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Jt,scale:te,copy:ee}=k,{ceil:ie,abs:se}=Math;function ne(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=se(n),o=se(o);const{image:t,data:r}=i;let h,c,{width:l,height:d,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(c=Jt(),ee(c,g),te(c,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,d*=o;const _=l*d;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(h=Math.sqrt(_/w)),h&&(n/=h,o/=h,l/=h,d/=h),u&&(n/=u,o/=f),(g||1!==n||1!==o)&&(c||(c=Jt(),g&&ee(c,g)),te(c,1/n,1/o));const y=t.getCanvas(ie(l)||1,ie(d)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",c,i);return i.style=m,i.patternId=a,!0}}function oe(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ae}=Math;const re={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Nt&&i===Nt.paint&&qt(s,Nt.boxBounds)?o=Nt.leafPaint:(o={type:i.type,image:r},Nt=r.use>1?{leafPaint:o,paint:i,boxBounds:Xt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ht(t,e,i,r,o,s),n&&(Vt(t,a),Qt(t,a))):r.error?n&&Kt(t,a,r.error):(n&&($t(t,!0),Vt(t,a)),o.loadId=r.load((()=>{$t(t,!1),t.destroyed||(Ht(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,a)),o.loadId=null}),(e=>{$t(t,!1),Kt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:h}=i,{data:c}=s;if(!c||s.patternId===a+"-"+r+"-"+h&&!F.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||F.running)){let{width:t,height:i}=c;t*=ae(a)*h,i*=ae(r)*h,c.scaleX&&(t*=c.scaleX,i*=c.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,c),!0):(!s.style||s.sync||F.running?ne(t,s,h):s.patternTask||(s.patternTask=B.patternTasker.add((()=>oe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ne(t,s,h),t.forceUpdate("surface")}))),300)),!1)},createPattern:ne,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let h=0,c=i.length;h<c;h++)s=i[h],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[h].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:jt,getPatternData:Gt,fillOrFitMode:Ot,clipMode:Pt,repeatMode:Dt},{toPoint:he}=A,ce={},le={};function de(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),I.string(s,i)):t.addColorStop(s.offset,I.string(s.color,i))}}const{getAngle:ue,getDistance:fe}=C,{get:ge,rotateOfOuter:pe,scaleOfOuter:_e}=k,{toPoint:we}=A,ye={},me={};function ve(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=ue(e,i);o=ge(),n?(_e(o,e,a/r*(s||1),1),pe(o,e,t+90)):(_e(o,e,1,a/r*(s||1)),pe(o,e,t))}return o}const{getDistance:xe}=C,{toPoint:be}=A,Be={},Se={};const Re={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;he(s||"top",i,ce),he(n||"bottom",i,le);const h=e.canvas.createLinearGradient(ce.x,ce.y,le.x,le.y);de(h,t.stops,r);const c={type:o,style:h};return a&&(c.blendMode=a),c},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;we(s||"center",i,ye),we(n||"bottom",i,me);const c=e.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,fe(ye,me));de(c,t.stops,a);const l={type:o,style:c},d=ve(i,ye,me,h,!0);return d&&(l.transform=d),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;be(s||"center",i,Be),be(n||"bottom",i,Se);const c=e.conicGradientSupport?e.canvas.createConicGradient(0,Be.x,Be.y):e.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,xe(Be,Se));de(c,t.stops,a);const l={type:o,style:c},d=ve(i,Be,Se,h||1,e.conicGradientRotate90);return d&&(l.transform=d),r&&(l.blendMode=r),l},getTransform:ve},{copy:ke,toOffsetOutBounds:Ee}=S,Le={},Te={};function Ae(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(ke(Le,t.bounds),Le.x+=i.x-a.x,Le.y+=i.y-a.y,s){const{matrix:t}=n;Le.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Le.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Le.width*=s,Le.height*=s}t.copyWorld(n.canvas,t.bounds,Le)}else s&&(ke(Le,i),Le.x-=i.width/2*(s-1),Le.y-=i.height/2*(s-1),Le.width*=s,Le.height*=s),t.copyWorld(n.canvas,a,s?Le:i)}const{toOffsetOutBounds:Ce}=S,We={};const Me={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ee(c,Te),r.forEach(((r,p)=>{f.setWorldShadow(Te.offsetX+r.x*d,Te.offsetY+r.y*u,r.blur*d,I.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,Te,n,i),s=c,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,c,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ce(c,We),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(We.offsetX+r.x*d,We.offsetY+r.y*u,r.blur*d),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ae(f,We,n,i),f.restore(),h?(f.copyWorld(f,c,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,c,"source-out"),s=c),f.fillWorld(s,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Oe}=w;function Pe(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ie(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ie(t,i,s,o);break;case"path":i.restore()}}function De(t){return t.getSameCanvas(!1,!0)}function Ie(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let c=0,l=h.length;c<l;c++)i=h[c],r=i.__.mask,r&&(a&&(Pe(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=De(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=De(t)),n||(n=De(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Oe(i,e)||i.__render(n||t,e);Pe(this,a,t,n,s,o)};const ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Fe=ze+"_#~&*+\\=|≮≯≈≠=…",Ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ue(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const je=Ue("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ge=Ue("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ne=Ue(ze),Xe=Ue(Fe),qe=Ue("- —/~|┆·");var He;!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"}(He||(He={}));const{Letter:Ve,Single:Qe,Before:Ke,After:Ze,Symbol:$e,Break:Je}=He;function ti(t){return je[t]?Ve:qe[t]?Je:Ge[t]?Ke:Ne[t]?Ze:Xe[t]?$e:Ye.test(t)?Qe:Ve}const ei={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ii(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:si}=ei,{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:hi,Break:ci}=He;let li,di,ui,fi,gi,pi,_i,wi,yi,mi,vi,xi,bi,Bi,Si,Ri,ki,Ei=[];function Li(t,e){yi&&!wi&&(wi=yi),li.data.push({char:t,width:e}),ui+=e}function Ti(){fi+=ui,li.width=ui,di.words.push(li),li={data:[]},ui=0}function Ai(){Bi&&(Si.paraNumber++,di.paraStart=!0,Bi=!1),yi&&(di.startCharSize=wi,di.endCharSize=yi,wi=0),di.width=fi,Ri.width?si(di):ki&&Ci(),Ei.push(di),di={words:[]},fi=0}function Ci(){fi>(Si.maxWidth||0)&&(Si.maxWidth=fi)}const{top:Wi,right:Mi,bottom:Oi,left:Pi}=W;function Di(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 Ii={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:c}=i;c&&(o?(s=c[Pi],o-=c[Mi]+c[Pi]):i.autoSizeAlign||(s=c[Pi]),a?(n=c[Wi],a-=c[Wi]+c[Oi]):i.autoSizeAlign||(n=c[Wi]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Si=t,Ei=t.rows,Ri=t.bounds,ki=!Ri.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:c}=Ri;if(h||c||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Bi=!0,vi=null,wi=_i=yi=ui=fi=0,li={data:[]},di={words:[]};for(let s=0,c=i.length;s<c;s++)pi=i[s],"\n"===pi?(ui&&Ti(),di.paraEnd=!0,Ai(),Bi=!0):(mi=ti(pi),mi===ni&&"none"!==a&&(pi=ii(pi,a,!ui)),_i=r.measureText(pi).width,n&&(n<0&&(yi=_i),_i+=n),xi=mi===oi&&(vi===oi||vi===ni)||vi===oi&&mi!==ri,bi=!(mi!==ai&&mi!==oi||vi!==hi&&vi!==ri),gi=Bi&&o?h-o:h,t&&h&&fi+ui+_i>gi&&(e?(ui&&Ti(),fi&&Ai()):(bi||(bi=mi===ni&&vi==ri),xi||bi||mi===ci||mi===ai||mi===oi||ui+_i>gi?(ui&&Ti(),fi&&Ai()):fi&&Ai()))," "===pi&&!0!==Bi&&fi+ui===0||(mi===ci?(" "===pi&&ui&&Ti(),Li(pi,_i),Ti()):xi||bi?(ui&&Ti(),Li(pi,_i)):Li(pi,_i)),vi=mi);ui&&Ti(),fi&&Ai(),Ei.length>0&&(Ei[Ei.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,fi=r.measureText(t).width,Ei.push({x:o||0,text:t,width:fi,paraStart:!0}),ki&&Ci()}))}(l,t,i),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Di(e,"x",t[Pi]);break;case"right":Di(e,"x",-t[Mi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Di(e,"y",t[Wi]);break;case"bottom":Di(e,"y",-t[Oi])}}(c,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:h,textAlign:c,verticalAlign:l,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),y=a;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(l){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,l=n;a<l;a++){if(m=i[a],m.x=f,m.width<p||m.width>p&&!h)switch(c){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&a>0&&(y+=d),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),h&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,h,c,l,d,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,l=a||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===l?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===l?(d={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(r+=h,t.width+=h)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?e.canvas.measureText(r).width:0,l=s+n-c;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<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)}}))}}(l,i,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=I.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(l,i),l}};const zi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Ii),Object.assign(I,zi),Object.assign(j,kt),Object.assign(D,re),Object.assign(z,Re),Object.assign(G,Me),Object.assign(r,{interaction:(t,e,i,s)=>new ft(t,e,i,s),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new P}),N.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&V(0,wx)}catch(t){}export{ft as Interaction,at as Layouter,X as LeaferCanvas,lt as Picker,ht as Renderer,dt as Selector,Q as Watcher,V as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,FileHelper as a,Creator as r,LeaferImage as h,defineKey as c,LeafList as l,RenderEvent as d,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,LeafBoundsHelper as w,Bounds as y,Debug as m,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,Plugin as S,MatrixHelper as k,MathHelper as E,AlignHelper as L,ImageEvent as T,AroundHelper as A,PointHelper as C,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as M,InteractionBase as P,HitCanvasManager as O}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as I,PaintGradient as z,Export as F,Group as U,TextConvert as Y,Paint as j,Effect as G,Leafer as N}from"@leafer-ui/draw";class X extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:q,fileType:H}=a;function V(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(q(H(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=r.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new X(t,e),image:t=>new h(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},c(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;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 l,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:Z,updateChange:$}=p,{pushAllChildBranch:J,pushAllParent:tt}=_;const{worldBounds:et}=w;class it{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,et),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:st,updateAllChange:nt}=p,ot=m.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&J(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach($)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new l(e));e.emitEvent(new x(i,o,this.times)),at.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){st(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=m.get("Renderer");class ht{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return rt.warn("rendering");if(this.times>3)return rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new y,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new y(s);i.save(),s.spread(ht.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),b.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(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 y(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||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}ht.clipSpread=10;const{hitRadiusPoint:ct}=R;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new l(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new l;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new l;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new l;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new l,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ct(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new lt(this.target=t,this),this.finder=r.finder&&r.finder()}getByPoint(t,i,s){const{target:n,picker:o}=this;return e.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(r,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=at.fullLayout;const ut={convertTouch(t,e){const i=ut.getTouch(t),s=M.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class ft extends P{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=ut.getTouch(t);this.pointerDown(ut.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=ut.getTouch(t);this.pointerMove(ut.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=ut.getTouch(t);this.pointerUp(ut.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(M.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function gt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)o=s[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(n){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function pt(t,e){t.__.__font?gt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function _t(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?mt(t,!0,e,i):yt(e,i);break;case"inside":wt("inside",t,n,e,i);break;case"outside":wt("outside",t,n,e,i)}}function wt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?mt(e,!0,s,r):yt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",gt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function yt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function mt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&D.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?yt(i,s):s.stroke(),s.restoreBlendMode()):e?yt(i,s):s.stroke())}function vt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:xt,getOuterOf:bt,getByMove:Bt,getIntersectData:Rt}=R;let St;function kt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:I.string(a,r)};case"image":return D.image(i,t,e,s,!St||!St[e.url]);case"linear":return z.linearGradient(e,s);case"radial":return z.radialGradient(e,s);case"angular":return z.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:I.string(e)}:void 0}}const Et={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=D.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=kt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,pt(e,i)},fills:function(t,e,i){let s;for(let n=0,o=t.length;n<o;n++){if(s=t[n],s.image){if(D.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),pt(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),pt(e,i),i.restoreBlendMode()):pt(e,i)}},fillPathOrText:pt,fillText:gt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)_t(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),mt(t,!1,e,i),s.__useArrow&&vt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),mt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),mt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:_t,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:c,scaleY:l}=n;if(c<0&&(c=-c),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,d=Rt(s?xt(e.bounds,c===l?s*c:[s*l,s*c]):e.bounds,n);a=e.bounds.getFitMatrix(d);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),c*=u,l*=f),r=bt(n,a),o=Bt(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:c,scaleY:l}}};let Lt={};const{get:Tt,rotateOfOuter:At,translate:Ct,scaleOfOuter:Wt,scale:Mt,rotate:Pt}=k;function Ot(t,e,i,s,n,o,a){const r=Tt();Ct(r,e.x+i,e.y+s),Mt(r,n,o),a&&At(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Dt(t,e,i,s,n,o,a){const r=Tt();Ct(r,e.x+i,e.y+s),n&&Mt(r,n,o),a&&Pt(r,a),t.transform=r}function It(t,e,i,s,n,o,a,r,h,c){const l=Tt();if(h)if("center"===c)At(l,{x:i/2,y:s/2},h);else switch(Pt(l,h),h){case 90:Ct(l,s,0);break;case 180:Ct(l,i,s);break;case 270:Ct(l,0,i)}Lt.x=e.x+n,Lt.y=e.y+o,Ct(l,Lt.x,Lt.y),a&&Wt(l,Lt,a,r),t.transform=l}const{get:zt,translate:Ft}=k,Ut=new y,Yt={},jt={};function Gt(t,e,i,s){const{blendMode:n,changeful:o,sync:a}=i;n&&(t.blendMode=n),o&&(t.changeful=o),a&&(t.sync=a),t.data=Nt(i,s,e)}function Nt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:c,size:l,rotation:d,repeat:u,filters:f}=t,g=e.width===s&&e.height===n,p={mode:a},_="center"!==r&&(d||0)%180==90,w=_?n:s,y=_?s:n;let m,v,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(c||l)&&(E.getScaleData(c,l,i,jt),m=jt.scaleX,v=jt.scaleY);else if(!g||d){const t=e.width/w,i=e.height/y;m=v="fit"===a?Math.min(t,i):Math.max(t,i),x+=(e.width-s*m)/2,b+=(e.height-n*v)/2}if(r){const t={x:x,y:b,width:w,height:y};m&&(t.width*=m,t.height*=v),L.toPoint(r,t,e,Yt,!0),x+=Yt.x,b+=Yt.y}switch(h&&(x+=h.x,b+=h.y),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(x||b||m||d)&&Dt(p,e,x,b,m,v,d);break;case"repeat":(!g||m||d)&&It(p,e,s,n,x,b,m,v,d,r),u||(p.repeat="repeat");break;default:m&&Ot(p,e,x,b,m,v,d)}return p.transform||(e.x||e.y)&&(p.transform=zt(),Ft(p.transform,e.x,e.y)),m&&"stretch"!==a&&(p.scaleX=m,p.scaleY=v),p.width=s,p.height=n,o&&(p.opacity=o),f&&(p.filters=f),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Xt,qt=new y;const{isSame:Ht}=R;function Vt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Gt(n,s,i,o),!0}function Qt(t,e){$t(t,T.LOAD,e)}function Kt(t,e){$t(t,T.LOADED,e)}function Zt(t,e,i){e.error=i,t.forceUpdate("surface"),$t(t,T.ERROR,e)}function $t(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,scale:ee,copy:ie}=k,{ceil:se,abs:ne}=Math;function oe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ne(n),o=ne(o);const{image:t,data:r}=i;let h,c,{width:l,height:d,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(c=te(),ie(c,g),ee(c,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,d*=o;const _=l*d;if(!p&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(h=Math.sqrt(_/w)),h&&(n/=h,o/=h,l/=h,d/=h),u&&(n/=u,o/=f),(g||1!==n||1!==o)&&(c||(c=te(),g&&ie(c,g)),ee(c,1/n,1/o));const y=t.getCanvas(se(l)||1,se(d)||1,r.opacity,r.filters),m=t.getPattern(y,p||e.origin.noRepeat||"no-repeat",c,i);return i.style=m,i.patternId=a,!0}}function ae(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:re}=Math;const he={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return Xt&&i===Xt.paint&&Ht(s,Xt.boxBounds)?o=Xt.leafPaint:(o={type:i.type,image:r},Xt=r.use>1?{leafPaint:o,paint:i,boxBounds:qt.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Vt(t,e,i,r,o,s),n&&(Qt(t,a),Kt(t,a))):r.error?n&&Zt(t,a,r.error):(n&&(Jt(t,!0),Qt(t,a)),o.loadId=r.load((()=>{Jt(t,!1),t.destroyed||(Vt(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,a)),o.loadId=null}),(e=>{Jt(t,!1),Zt(t,a,e),o.loadId=null})),t.placeholderColor&&setTimeout((()=>{r.ready||r.isPlacehold||(r.isPlacehold=!0,t.forceUpdate("surface"))}),100)),o},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:h}=i,{data:c}=s;if(!c||s.patternId===a+"-"+r+"-"+h&&!F.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||o.isResizing(t)||F.running)){let{width:t,height:i}=c;t*=re(a)*h,i*=re(r)*h,c.scaleX&&(t*=c.scaleX,i*=c.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,c),!0):(!s.style||s.sync||F.running?oe(t,s,h):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ae(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&oe(t,s,h),t.forceUpdate("surface")}))),300)),!1)},createPattern:oe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a,r;for(let h=0,c=i.length;h<c;h++)s=i[h],n=s.image,r=n&&n.url,r&&(o||(o={}),o[r]=!0,B.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[h].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Gt,getPatternData:Nt,fillOrFitMode:Ot,clipMode:Dt,repeatMode:It},{toPoint:ce}=A,le={},de={};function ue(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),I.string(s,i)):t.addColorStop(s.offset,I.string(s.color,i))}}const{getAngle:fe,getDistance:ge}=C,{get:pe,rotateOfOuter:_e,scaleOfOuter:we}=k,{toPoint:ye}=A,me={},ve={};function xe(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=fe(e,i);o=pe(),n?(we(o,e,a/r*(s||1),1),_e(o,e,t+90)):(we(o,e,1,a/r*(s||1)),_e(o,e,t))}return o}const{getDistance:be}=C,{toPoint:Be}=A,Re={},Se={};const ke={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;ce(s||"top",i,le),ce(n||"bottom",i,de);const h=e.canvas.createLinearGradient(le.x,le.y,de.x,de.y);ue(h,t.stops,r);const c={type:o,style:h};return a&&(c.blendMode=a),c},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;ye(s||"center",i,me),ye(n||"bottom",i,ve);const c=e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,ge(me,ve));ue(c,t.stops,a);const l={type:o,style:c},d=xe(i,me,ve,h,!0);return d&&(l.transform=d),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Be(s||"center",i,Re),Be(n||"bottom",i,Se);const c=e.conicGradientSupport?e.canvas.createConicGradient(0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,be(Re,Se));ue(c,t.stops,a);const l={type:o,style:c},d=xe(i,Re,Se,h||1,e.conicGradientRotate90);return d&&(l.transform=d),r&&(l.blendMode=r),l},getTransform:xe},{copy:Ee,toOffsetOutBounds:Le}=R,Te={},Ae={};function Ce(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ee(Te,t.bounds),Te.x+=i.x-a.x,Te.y+=i.y-a.y,s){const{matrix:t}=n;Te.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Te.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Te.width*=s,Te.height*=s}t.copyWorld(n.canvas,t.bounds,Te)}else s&&(Ee(Te,i),Te.x-=i.width/2*(s-1),Te.y-=i.height/2*(s-1),Te.width*=s,Te.height*=s),t.copyWorld(n.canvas,a,s?Te:i)}const{toOffsetOutBounds:We}=R,Me={};const Pe={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Le(c,Ae),r.forEach(((r,p)=>{f.setWorldShadow(Ae.offsetX+r.x*d,Ae.offsetY+r.y*u,r.blur*d,I.string(r.color)),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,Ae,n,i),s=c,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,c,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:c,shapeBounds:l,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(c,Me),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Me.offsetX+r.x*d,Me.offsetY+r.y*u,r.blur*d),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ce(f,Me,n,i),f.restore(),h?(f.copyWorld(f,c,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,c,"source-out"),s=c),f.fillWorld(s,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Oe}=w;function De(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),ze(t,e,i,1)}(t,i,s,n);break;case"opacity-path":ze(t,i,s,o);break;case"path":i.restore()}}function Ie(t){return t.getSameCanvas(!1,!0)}function ze(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}U.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let c=0,l=h.length;c<l;c++)i=h[c],r=i.__.mask,r&&(a&&(De(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ie(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ie(t)),n||(n=Ie(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Oe(i,e)||i.__render(n||t,e);De(this,a,t,n,s,o)};const Fe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Fe+"_#~&*+\\=|≮≯≈≠=…",Ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ge=je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ne=je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Xe=je(Fe),qe=je(Ue),He=je("- —/~|┆·");var Ve;!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"}(Ve||(Ve={}));const{Letter:Qe,Single:Ke,Before:Ze,After:$e,Symbol:Je,Break:ti}=Ve;function ei(t){return Ge[t]?Qe:He[t]?ti:Ne[t]?Ze:Xe[t]?$e:qe[t]?Je:Ye.test(t)?Ke:Qe}const ii={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function si(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ni}=ii,{Letter:oi,Single:ai,Before:ri,After:hi,Symbol:ci,Break:li}=Ve;let di,ui,fi,gi,pi,_i,wi,yi,mi,vi,xi,bi,Bi,Ri,Si,ki,Ei,Li=[];function Ti(t,e){mi&&!yi&&(yi=mi),di.data.push({char:t,width:e}),fi+=e}function Ai(){gi+=fi,di.width=fi,ui.words.push(di),di={data:[]},fi=0}function Ci(){Ri&&(Si.paraNumber++,ui.paraStart=!0,Ri=!1),mi&&(ui.startCharSize=yi,ui.endCharSize=mi,yi=0),ui.width=gi,ki.width?ni(ui):Ei&&Wi(),Li.push(ui),ui={words:[]},gi=0}function Wi(){gi>(Si.maxWidth||0)&&(Si.maxWidth=gi)}const{top:Mi,right:Pi,bottom:Oi,left:Di}=W;function Ii(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 zi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:c}=i;c&&(o?(s=c[Di],o-=c[Pi]+c[Di]):i.autoSizeAlign||(s=c[Di]),a?(n=c[Mi],a-=c[Mi]+c[Oi]):i.autoSizeAlign||(n=c[Mi]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Si=t,Li=t.rows,ki=t.bounds,Ei=!ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:c}=ki;if(h||c||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ri=!0,xi=null,yi=wi=mi=fi=gi=0,di={data:[]},ui={words:[]};for(let s=0,c=i.length;s<c;s++)_i=i[s],"\n"===_i?(fi&&Ai(),ui.paraEnd=!0,Ci(),Ri=!0):(vi=ei(_i),vi===oi&&"none"!==a&&(_i=si(_i,a,!fi)),wi=r.measureText(_i).width,n&&(n<0&&(mi=wi),wi+=n),bi=vi===ai&&(xi===ai||xi===oi)||xi===ai&&vi!==hi,Bi=!(vi!==ri&&vi!==ai||xi!==ci&&xi!==hi),pi=Ri&&o?h-o:h,t&&h&&gi+fi+wi>pi&&(e?(fi&&Ai(),gi&&Ci()):(Bi||(Bi=vi===oi&&xi==hi),bi||Bi||vi===li||vi===ri||vi===ai||fi+wi>pi?(fi&&Ai(),gi&&Ci()):gi&&Ci()))," "===_i&&!0!==Ri&&gi+fi===0||(vi===li?(" "===_i&&fi&&Ai(),Ti(_i,wi),Ai()):bi||Bi?(fi&&Ai(),Ti(_i,wi)):Ti(_i,wi)),xi=vi);fi&&Ai(),gi&&Ci(),Li.length>0&&(Li[Li.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,gi=r.measureText(t).width,Li.push({x:o||0,text:t,width:gi,paraStart:!0}),Ei&&Wi()}))}(l,t,i),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ii(e,"x",t[Di]);break;case"right":Ii(e,"x",-t[Pi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ii(e,"y",t[Mi]);break;case"bottom":Ii(e,"y",-t[Oi])}}(c,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:h,textAlign:c,verticalAlign:l,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),y=a;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(l){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,v,x,b=p||u?p:t.maxWidth;for(let a=0,l=n;a<l;a++){if(m=i[a],m.x=f,m.width<p||m.width>p&&!h)switch(c){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&d&&a>0&&(y+=d),m.y=y,y+=o,t.overflow>a&&y>w&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),h&&p&&p<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:a}=e;let r,h,c,l,d,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,l=a||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===l?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===l?(d={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(r+=h,t.width+=h)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?e.canvas.measureText(r).width:0,l=s+n-c;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<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)}}))}}(l,i,s,o),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=I.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(l,i),l}};const Fi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(Y,zi),Object.assign(I,Fi),Object.assign(j,Et),Object.assign(D,he),Object.assign(z,ke),Object.assign(G,Pe),Object.assign(r,{interaction:(t,e,i,s)=>new ft(t,e,i,s),hitCanvas:(t,e)=>new X(t,e),hitCanvasManager:()=>new O}),N.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&V(0,wx)}catch(t){}export{ft as Interaction,at as Layouter,X as LeaferCanvas,lt as Picker,ht as Renderer,dt as Selector,Q as Watcher,V as useCanvas};
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map