@leafer-draw/worker 1.9.9 → 1.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.cjs CHANGED
@@ -1015,7 +1015,14 @@ const PaintModule = {
1015
1015
 
1016
1016
  let origin = {}, tempMatrix$1 = core.getMatrixData();
1017
1017
 
1018
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1018
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1019
+
1020
+ function stretchMode(data, box, scaleX, scaleY) {
1021
+ const transform = get$3();
1022
+ translate$1(transform, box.x, box.y);
1023
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1024
+ data.transform = transform;
1025
+ }
1019
1026
 
1020
1027
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1021
1028
  const transform = get$3();
@@ -1032,8 +1039,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1032
1039
  const transform = get$3();
1033
1040
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1034
1041
  if (clipScaleX) {
1035
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1036
- multiplyParent(transform, tempMatrix$1);
1042
+ if (rotation || skew) {
1043
+ set(tempMatrix$1);
1044
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1045
+ multiplyParent(transform, tempMatrix$1);
1046
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1037
1047
  }
1038
1048
  data.transform = transform;
1039
1049
  }
@@ -1129,7 +1139,10 @@ function getPatternData(paint, box, image) {
1129
1139
  if (offset) core.PointHelper.move(tempImage, offset);
1130
1140
  switch (mode) {
1131
1141
  case "stretch":
1132
- if (!sameBox) width = box.width, height = box.height;
1142
+ if (!sameBox) {
1143
+ scaleX = box.width / width, scaleY = box.height / height;
1144
+ stretchMode(data, box, scaleX, scaleY);
1145
+ }
1133
1146
  break;
1134
1147
 
1135
1148
  case "normal":
@@ -1138,7 +1151,7 @@ function getPatternData(paint, box, image) {
1138
1151
  let clipScaleX, clipScaleY;
1139
1152
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1140
1153
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1141
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1154
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1142
1155
  }
1143
1156
  break;
1144
1157
 
@@ -1155,17 +1168,14 @@ function getPatternData(paint, box, image) {
1155
1168
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1156
1169
  }
1157
1170
  if (!data.transform) {
1158
- if (box.x || box.y) {
1159
- data.transform = get$2();
1160
- translate(data.transform, box.x, box.y);
1161
- }
1171
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1162
1172
  }
1163
- if (scaleX && mode !== "stretch") {
1173
+ data.width = width;
1174
+ data.height = height;
1175
+ if (scaleX) {
1164
1176
  data.scaleX = scaleX;
1165
1177
  data.scaleY = scaleY;
1166
1178
  }
1167
- data.width = width;
1168
- data.height = height;
1169
1179
  if (opacity) data.opacity = opacity;
1170
1180
  if (filters) data.filters = filters;
1171
1181
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -1297,7 +1307,7 @@ function ignoreRender(ui, value) {
1297
1307
 
1298
1308
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1299
1309
 
1300
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
1310
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
1301
1311
 
1302
1312
  function createPattern(ui, paint, pixelRatio) {
1303
1313
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1308,8 +1318,8 @@ function createPattern(ui, paint, pixelRatio) {
1308
1318
  scaleX *= pixelRatio;
1309
1319
  scaleY *= pixelRatio;
1310
1320
  if (sx) {
1311
- sx = abs(sx);
1312
- sy = abs(sy);
1321
+ sx = abs$1(sx);
1322
+ sy = abs$1(sy);
1313
1323
  imageMatrix = get$1();
1314
1324
  copy$1(imageMatrix, transform);
1315
1325
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1484,6 +1494,7 @@ const PaintImageModule = {
1484
1494
  recycleImage: recycleImage,
1485
1495
  createData: createData,
1486
1496
  getPatternData: getPatternData,
1497
+ stretchMode: stretchMode,
1487
1498
  fillOrFitMode: fillOrFitMode,
1488
1499
  clipMode: clipMode,
1489
1500
  repeatMode: repeatMode
@@ -1594,7 +1605,7 @@ const PaintGradientModule = {
1594
1605
  getTransform: getTransform
1595
1606
  };
1596
1607
 
1597
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max} = Math;
1608
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max, abs: abs} = Math;
1598
1609
 
1599
1610
  const tempBounds = {}, tempMatrix = new core.Matrix;
1600
1611
 
@@ -1638,7 +1649,7 @@ function shadow(ui, current, shape) {
1638
1649
  function getShadowRenderSpread(_ui, shadow) {
1639
1650
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
1640
1651
  shadow.forEach(item => {
1641
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
1652
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
1642
1653
  top = max(top, spread + blur - y);
1643
1654
  right = max(right, spread + blur + x);
1644
1655
  bottom = max(bottom, spread + blur + y);
@@ -1649,11 +1660,11 @@ function getShadowRenderSpread(_ui, shadow) {
1649
1660
 
1650
1661
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
1651
1662
  if (shadow.spread) {
1652
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
1663
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
1653
1664
  tempMatrix.set().scaleOfOuter({
1654
1665
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
1655
1666
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
1656
- }, spreadScale);
1667
+ }, 1 + spread / width, 1 + spread / height);
1657
1668
  return tempMatrix;
1658
1669
  }
1659
1670
  return undefined;
@@ -1019,7 +1019,14 @@ const PaintModule = {
1019
1019
 
1020
1020
  let origin = {}, tempMatrix$1 = getMatrixData();
1021
1021
 
1022
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1022
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1023
+
1024
+ function stretchMode(data, box, scaleX, scaleY) {
1025
+ const transform = get$3();
1026
+ translate$1(transform, box.x, box.y);
1027
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1028
+ data.transform = transform;
1029
+ }
1023
1030
 
1024
1031
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1025
1032
  const transform = get$3();
@@ -1036,8 +1043,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1036
1043
  const transform = get$3();
1037
1044
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1038
1045
  if (clipScaleX) {
1039
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1040
- multiplyParent(transform, tempMatrix$1);
1046
+ if (rotation || skew) {
1047
+ set(tempMatrix$1);
1048
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1049
+ multiplyParent(transform, tempMatrix$1);
1050
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1041
1051
  }
1042
1052
  data.transform = transform;
1043
1053
  }
@@ -1133,7 +1143,10 @@ function getPatternData(paint, box, image) {
1133
1143
  if (offset) PointHelper.move(tempImage, offset);
1134
1144
  switch (mode) {
1135
1145
  case "stretch":
1136
- if (!sameBox) width = box.width, height = box.height;
1146
+ if (!sameBox) {
1147
+ scaleX = box.width / width, scaleY = box.height / height;
1148
+ stretchMode(data, box, scaleX, scaleY);
1149
+ }
1137
1150
  break;
1138
1151
 
1139
1152
  case "normal":
@@ -1142,7 +1155,7 @@ function getPatternData(paint, box, image) {
1142
1155
  let clipScaleX, clipScaleY;
1143
1156
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1144
1157
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1145
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1158
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1146
1159
  }
1147
1160
  break;
1148
1161
 
@@ -1159,17 +1172,14 @@ function getPatternData(paint, box, image) {
1159
1172
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1160
1173
  }
1161
1174
  if (!data.transform) {
1162
- if (box.x || box.y) {
1163
- data.transform = get$2();
1164
- translate(data.transform, box.x, box.y);
1165
- }
1175
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1166
1176
  }
1167
- if (scaleX && mode !== "stretch") {
1177
+ data.width = width;
1178
+ data.height = height;
1179
+ if (scaleX) {
1168
1180
  data.scaleX = scaleX;
1169
1181
  data.scaleY = scaleY;
1170
1182
  }
1171
- data.width = width;
1172
- data.height = height;
1173
1183
  if (opacity) data.opacity = opacity;
1174
1184
  if (filters) data.filters = filters;
1175
1185
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -1301,7 +1311,7 @@ function ignoreRender(ui, value) {
1301
1311
 
1302
1312
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1303
1313
 
1304
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
1314
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
1305
1315
 
1306
1316
  function createPattern(ui, paint, pixelRatio) {
1307
1317
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1312,8 +1322,8 @@ function createPattern(ui, paint, pixelRatio) {
1312
1322
  scaleX *= pixelRatio;
1313
1323
  scaleY *= pixelRatio;
1314
1324
  if (sx) {
1315
- sx = abs(sx);
1316
- sy = abs(sy);
1325
+ sx = abs$1(sx);
1326
+ sy = abs$1(sy);
1317
1327
  imageMatrix = get$1();
1318
1328
  copy$1(imageMatrix, transform);
1319
1329
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1488,6 +1498,7 @@ const PaintImageModule = {
1488
1498
  recycleImage: recycleImage,
1489
1499
  createData: createData,
1490
1500
  getPatternData: getPatternData,
1501
+ stretchMode: stretchMode,
1491
1502
  fillOrFitMode: fillOrFitMode,
1492
1503
  clipMode: clipMode,
1493
1504
  repeatMode: repeatMode
@@ -1598,7 +1609,7 @@ const PaintGradientModule = {
1598
1609
  getTransform: getTransform
1599
1610
  };
1600
1611
 
1601
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
1612
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max, abs: abs} = Math;
1602
1613
 
1603
1614
  const tempBounds = {}, tempMatrix = new Matrix;
1604
1615
 
@@ -1642,7 +1653,7 @@ function shadow(ui, current, shape) {
1642
1653
  function getShadowRenderSpread(_ui, shadow) {
1643
1654
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
1644
1655
  shadow.forEach(item => {
1645
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
1656
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
1646
1657
  top = max(top, spread + blur - y);
1647
1658
  right = max(right, spread + blur + x);
1648
1659
  bottom = max(bottom, spread + blur + y);
@@ -1653,11 +1664,11 @@ function getShadowRenderSpread(_ui, shadow) {
1653
1664
 
1654
1665
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
1655
1666
  if (shadow.spread) {
1656
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
1667
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
1657
1668
  tempMatrix.set().scaleOfOuter({
1658
1669
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
1659
1670
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
1660
- }, spreadScale);
1671
+ }, 1 + spread / width, 1 + spread / height);
1661
1672
  return tempMatrix;
1662
1673
  }
1663
1674
  return undefined;
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as s,FileHelper as i,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,isObject as k,BoundsHelper as B,FourNumberHelper as E,Matrix as R,isUndefined as A,isString as L,getMatrixData as T,MatrixHelper as O,MathHelper as W,AlignHelper as C,PointHelper as M,ImageEvent as D,AroundHelper as P,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as Y,Paint as z,ColorConvert as U,PaintGradient as G,Export as q,Effect as X,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=Math.ceil(t*s),this.view.height=Math.ceil(e*s),this.clientBounds=this.bounds}}s(OffscreenCanvasRenderingContext2D.prototype),s(Path2D.prototype);const{mineType:V}=i;function Q(t,s){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise((i,n)=>{t.convertToBlob({type:V(e),quality:s}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,s)=>t.convertToBlob({type:V(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((s,i)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{s(t)}).catch(t=>{i(t)})},n.onerror=t=>i(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?e.os="Mac":Z.indexOf("Linux")>-1&&(e.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=l.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===c.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,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=f,{pushAllChildBranch:et,pushAllParent:st}=p;const{worldBounds:it}=g;class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,it),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:at,updateAllChange:rt}=f,ot=m.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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(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(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(i);o.forEach(t=>t.setBefore()),s.emitEvent(new x(n,o,this.times)),this.extraBlock=null,i.sort(),function(t,e){let s;t.list.forEach(t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),st(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))})}(i,this.__levelList),function(t){let e,s,i;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber){i=s.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||K(i[t])}K(s)}})}(this.__levelList),function(t){t.list.forEach(tt)}(i),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),s.emitEvent(new x(a,o,this.times)),s.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(s,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(i,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){at(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new nt([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=m.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,s&&(this.config=l.default(s,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 _,dt.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,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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=v.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=new _(i);s.save(),i.spread(ct.clipSpread).ceil(),s.clearWorld(i),s.clipWorld(i),this.__render(i,n),s.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,s){const{canvas:i}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),e.render(this.target,i,a),this.renderBounds=s=s||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),i.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;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 s=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return e.requestRender(s);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()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;if(!new _(0,0,e,s).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,s){this.target.emitEvent(new d(t,this.times,e,s))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let a;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,s=i.length;t<s;t++)a=i[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=s.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,a)))}}function ut(t,e){t.__.__font?ht(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,s){switch(e.__.strokeAlign){case"center":pt(t,1,e,s);break;case"inside":gt(t,"inside",e,s);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,s):gt(t,"outside",e,s)}}function pt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!0,s,i):(i.setStroke(t,n.__strokeWidth*e,n),_t(s,i))}function gt(t,e,s,i){const n=i.getSameCanvas(!0,!0);n.font=s.__.__font,pt(t,2,s,n),n.blendMode="outside"===e?"destination-out":"destination-in",ht(s,n),n.blendMode="normal",f.copyCanvasByWorld(s,i,n),n.recycle(s.__nowWorld)}function _t(t,e){let s,i=t.__.__textDrawData;const{rows:n,decorationY:a}=i;for(let t=0,i=n.length;t<i;t++)s=n[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(a){const{decorationHeight:t}=i;n.forEach(s=>a.forEach(i=>e.strokeRect(s.x,s.y+i,s.width,t)))}}function wt(t,e,s,i,n){let a;const r=i.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!Y.checkImage(i,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),s?_t(i,n):n.stroke(),n.restoreBlendMode()):s?_t(i,n):n.stroke()}}function mt(t,e,s){const i=e.__;if(i.__strokeWidth)if(i.__font)ft(t,e,s);else switch(i.strokeAlign){case"center":yt(t,1,e,s);break;case"inside":!function(t,e,s){s.save(),s.clipUI(e),yt(t,2,e,s),s.restore()}(t,e,s);break;case"outside":!function(t,e,s){const i=e.__;if(i.__fillAfterStroke)yt(t,2,e,s);else{const{renderBounds:n}=e.__layout,a=s.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(i),a.clearWorld(n),f.copyCanvasByWorld(e,s,a),a.recycle(e.__nowWorld)}}(t,e,s)}}function yt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!1,s,i):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&z.strokeArrow(t,s,i)}ct.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,s)=>new ct(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,i)=>{}}),e.layout=lt.fullLayout,e.render=function(t,e,s){const i=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new o,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,i))};const{getSpread:xt,copyAndSpread:vt,toOuterOf:bt,getOuterOf:St,getByMove:kt,move:Bt,getIntersectData:Et}=B,Rt={};let At;const{stintSet:Lt}=l,{hasTransparent:Tt}=U;function Ot(t,e,s){if(!k(e)||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:n}=s.__layout;switch(e.type){case"image":i=Y.image(s,t,e,n,!At||!At[e.url]);break;case"linear":i=G.linearGradient(e,n);break;case"radial":i=G.radialGradient(e,n);break;case"angular":i=G.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;i={type:a,style:U.string(r,o)};break;default:A(e.r)||(i={type:"solid",style:U.string(e)})}if(i){if(L(i.style)&&Tt(i.style)&&(i.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;i.strokeStyle=e.style}e.editing&&(i.editing=e.editing),e.blendMode&&(i.blendMode=e.blendMode)}return i}const Wt={compute:function(t,e){const s=e.__,i=[];let n,a,r,o=s.__input[t];w(o)||(o=[o]),At=Y.recycleImage(t,s);for(let s,n=0,a=o.length;n<a;n++)(s=Ot(t,o[n],e))&&(i.push(s),s.strokeStyle&&(r||(r=1),s.strokeStyle.strokeWidth&&(r=Math.max(r,s.strokeStyle.strokeWidth))));s["_"+t]=i.length?i:void 0,i.length&&i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Lt(s,"__isAlphaPixelFill",n),Lt(s,"__isTransparentFill",a)):(Lt(s,"__isAlphaPixelStroke",n),Lt(s,"__isTransparentStroke",a),Lt(s,"__hasMultiStrokeStyle",r))},fill:function(t,e,s){s.fillStyle=t,ut(e,s)},fills:function(t,e,s){let i;for(let n=0,a=t.length;n<a;n++){if(i=t[n],i.image){if(Y.checkImage(e,s,i,!e.__.__font))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(s,i.image);continue}}if(s.fillStyle=i.style,i.transform||i.scaleFixed){if(s.save(),i.transform&&s.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&n>1)&&s.scale(1/t,1/n)}i.blendMode&&(s.blendMode=i.blendMode),ut(e,s),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),ut(e,s),s.restoreBlendMode()):ut(e,s)}},fillPathOrText:ut,fillText:ht,stroke:mt,strokes:function(t,e,s){mt(t,e,s)},strokeText:ft,drawTextStroke:_t,shape:function(t,s,i){const n=s.getSameCanvas(),a=s.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;bt(o.strokeSpread?(vt(Rt,o.boxBounds,o.strokeSpread),Rt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,d=f=l,c=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?xt(a,E.swapAndScale(o.renderShapeSpread,g,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=s.getSameCanvas(),t.__renderShape(p,i),g*=w,_*=m),f=St(l,u),d=kt(f,-u.e,-u.f),c=St(r,u),Bt(c,-u.e,-u.f);const y=i.matrix;y?(h=new R(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),i=Object.assign(Object.assign({},i),{matrix:h})}return t.__renderShape(n,i),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Ct={},Mt=T();const{get:Dt,rotateOfOuter:Pt,translate:It,scaleOfOuter:Ft,multiplyParent:Yt,scale:zt,rotate:Ut,skew:Gt}=O;function qt(t,e,s,i,n,a,r){const o=Dt();It(o,e.x+s,e.y+i),zt(o,n,a),r&&Pt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Xt(t,e,s,i,n,a,r,o,l,d){const c=Dt();jt(c,e,s,i,n,a,r,o),l&&(Mt.a=l,Mt.d=d,Yt(c,Mt)),t.transform=c}function Nt(t,e,s,i,n,a,r,o,l,d,c,h){const u=Dt();if(h)jt(u,e,n,a,r,o,l,d);else{if(l)if("center"===c)Pt(u,{x:s/2,y:i/2},l);else switch(Ut(u,l),l){case 90:It(u,i,0);break;case 180:It(u,s,i);break;case 270:It(u,0,s)}Ct.x=e.x+n,Ct.y=e.y+a,It(u,Ct.x,Ct.y),r&&Ft(u,Ct,r,o)}t.transform=u}function jt(t,e,s,i,n,a,r,o){r&&Ut(t,r),o&&Gt(t,o.x,o.y),n&&zt(t,n,a),It(t,e.x+s,e.y+i)}const{get:Ht,translate:Vt}=O,Qt=new _,Zt={},$t={};function Jt(t,e,s,i){const{changeful:n,sync:a,scaleFixed:r}=s;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=Kt(s,i,e)}function Kt(t,e,s){t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:n}=s;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===i&&e.height===n,m={mode:r},y="center"!==o&&(h||0)%180==90;let x,v;switch(B.set($t,0,0,y?n:i,y?i:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(W.getScaleData(d,c,s,Zt),x=Zt.scaleX,v=Zt.scaleY),(o||g||p)&&(x&&B.scale($t,x,v,!0),o&&C.toPoint(o,$t,e,$t,!0,!0))):w&&!h||(x=v=B.getFitScale(e,$t,"fit"!==r),B.put(e,s,o,x,!1,$t),B.scale($t,x,v,!0)),l&&M.move($t,l),r){case"stretch":w||(i=e.width,n=e.height);break;case"normal":case"clip":if($t.x||$t.y||x||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),Xt(m,e,$t.x,$t.y,x,v,h,u,t,s),t&&(x=x?x*t:x,v=v?v*s:s)}break;case"repeat":(!w||x||h||u)&&Nt(m,e,i,n,$t.x,$t.y,x,v,h,u,o,t.freeTransform),p||(m.repeat="repeat");const s=k(p);(g||s)&&(m.gap=function(t,e,s,i,n){let a,r;k(t)?(a=t.x,r=t.y):a=r=t;return{x:te(a,s,n.width,e&&e.x),y:te(r,i,n.height,e&&e.y)}}(g,s&&p,$t.width,$t.height,e));break;default:x&&qt(m,e,$t.x,$t.y,x,v,h)}return m.transform||(e.x||e.y)&&(m.transform=Ht(),Vt(m.transform,e.x,e.y)),x&&"stretch"!==r&&(m.scaleX=x,m.scaleY=v),m.width=i,m.height=n,a&&(m.opacity=a),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function te(t,e,s,i){const n=L(t)||i?(i?s-i*e:s%e)/((i||Math.floor(s/e))-1):t;return"auto"===t&&n<0?0:n}let ee,se=new _;const{isSame:ie}=B;function ne(t,e,s,i,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Jt(n,i,s,a),!0}function ae(t,e){le(t,D.LOAD,e)}function re(t,e){le(t,D.LOADED,e)}function oe(t,e,s){e.error=s,t.forceUpdate("surface"),le(t,D.ERROR,e)}function le(t,e,s){t.hasEvent(e)&&t.emitEvent(new D(e,s))}function de(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:ce,scale:he,copy:ue}=O,{floor:fe,ceil:pe,max:ge,abs:_e}=Math;function we(t,s,i){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,s.scaleFixed);const r=n+"-"+a+"-"+i;if(s.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=s;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=i,a*=i,f&&(f=_e(f),p=_e(p),c=ce(),ue(c,g),he(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const m=h*u;if(!_&&m>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/pe(t))}else{const t=o.width*o.height;y>t&&(y=t)}m>y&&(d=Math.sqrt(m/y)),d&&(n/=d,a/=d,h/=d,u/=d),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(x||0),e=u+(v||0);n/=t/ge(fe(t),1),a/=e/ge(fe(e),1),c||(c=ce(),g&&ue(c,g)),he(c,1/n,1/a)}const b=o.getCanvas(h,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),S=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,s);return s.style=S,s.patternId=r,!0}}function me(t,e,s,i){return new(s||(s=Promise))(function(n,a){function r(t){try{l(i.next(t))}catch(t){a(t)}}function o(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(r,o)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const ye={image:function(t,e,s,i,n){let a,r;const o=b.get(s);return ee&&s===ee.paint&&ie(i,ee.boxBounds)?a=ee.leafPaint:(a={type:s.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ee=o.use>1?{leafPaint:a,paint:s,boxBounds:se.set(i)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:s}),o.ready?(ne(t,e,s,o,a,i),n&&(ae(t,r),re(t,r))):o.error?n&&oe(t,r,o.error):(n&&(de(t,!0),ae(t,r)),a.loadId=o.load(()=>{de(t,!1),t.destroyed||(ne(t,e,s,o,a,i)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),re(t,r)),a.loadId=void 0},e=>{de(t,!1),oe(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,s,i,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:o}=s,{data:l}=i;if(!l||i.patternId===a+"-"+r+"-"+o&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(i.changeful||"miniapp"===e.name&&S.isResizing(t)||q.running)){let{width:t,height:s}=l;t*=a*o,s*=r*o,l.scaleX&&(t*=l.scaleX,s*=l.scaleY),n=t*s>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),function(t,e,s,i){e.save(),e.clipUI(t),s.blendMode&&(e.blendMode=s.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(s.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,s,i,l),!0):(!i.style||i.sync||q.running?we(t,i,o):i.patternTask||(i.patternTask=b.patternTasker.add(()=>me(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(t.__nowWorld)&&we(t,i,o),t.forceUpdate("surface")}),300)),!1)},createPattern:we,recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let i,n,a,r,o;for(let l=0,d=s.length;l<d;l++)i=s[l],n=i.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(s[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Jt,getPatternData:Kt,fillOrFitMode:qt,clipMode:Xt,repeatMode:Nt},{toPoint:xe}=P,{hasTransparent:ve}=U,be={},Se={};function ke(t,e,s,i){if(s){let n,a,r,o;for(let t=0,l=s.length;t<l;t++)n=s[t],L(n)?(r=t/(l-1),a=U.string(n,i)):(r=n.offset,a=U.string(n.color,i)),e.addColorStop(r,a),!o&&ve(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Be,getDistance:Ee}=M,{get:Re,rotateOfOuter:Ae,scaleOfOuter:Le}=O,{toPoint:Te}=P,Oe={},We={};function Ce(t,e,s,i,n){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Be(e,s);a=Re(),n?(Le(a,e,r/o*(i||1),1),Ae(a,e,t+90)):(Le(a,e,1,r/o*(i||1)),Ae(a,e,t))}return a}const{getDistance:Me}=M,{toPoint:De}=P,Pe={},Ie={};const Fe={linearGradient:function(t,s){let{from:i,to:n,type:a,opacity:r}=t;xe(i||"top",s,be),xe(n||"bottom",s,Se);const o=e.canvas.createLinearGradient(be.x,be.y,Se.x,Se.y),l={type:a,style:o};return ke(l,o,t.stops,r),l},radialGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;Te(i||"center",s,Oe),Te(n||"bottom",s,We);const l=e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Ee(Oe,We)),d={type:a,style:l};ke(d,l,t.stops,r);const c=Ce(s,Oe,We,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;De(i||"center",s,Pe),De(n||"bottom",s,Ie);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Pe.x,Pe.y):e.canvas.createRadialGradient(Pe.x,Pe.y,0,Pe.x,Pe.y,Me(Pe,Ie)),d={type:a,style:l};ke(d,l,t.stops,r);const c=Ce(s,Pe,Ie,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ce},{copy:Ye,move:ze,toOffsetOutBounds:Ue}=B,{max:Ge}=Math,qe={},Xe=new R,Ne={};function je(t,e){let s,i,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,i=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),r=Ge(r,n+a-i),o=Ge(o,n+a+s),l=Ge(l,n+a+i),d=Ge(d,n+a-s)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function He(t,s,i){const{shapeBounds:n}=i;let a,r;e.fullImageShadow?(Ye(qe,t.bounds),ze(qe,s.x-n.x,s.y-n.y),a=t.bounds,r=qe):(a=n,r=s),t.copyWorld(i.canvas,a,r)}const{toOffsetOutBounds:Ve}=B,Qe={};const Ze=je;const $e={shadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;Ue(l,Ne,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ne.offsetX+(r.x||0)*h*w,Ne.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,U.string(r.color)),n=X.getShadowTransform(t,p,s,r,Ne,w),n&&p.setTransform(n),He(p,Ne,s),n&&p.resetTransform(),i=d,r.box&&(p.restore(),p.save(),o&&(p.copyWorld(p,d,a,"copy"),i=a),o?p.copyWorld(o,a,a,"destination-out"):p.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;Ve(l,Qe,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Qe.offsetX+(r.x||0)*h*w,Qe.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),n=X.getShadowTransform(t,p,s,r,Qe,w,!0),n&&p.setTransform(n),He(p,Qe,s),p.restore(),o?(p.copyWorld(p,d,a,"copy"),p.copyWorld(o,a,a,"source-out"),i=a):(p.copyWorld(s.canvas,c,l,"source-out"),i=d),p.fillWorld(i,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__nowWorld.a),s.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),s.filter="none"},backgroundBlur:function(t,e,s){},getShadowRenderSpread:je,getShadowTransform:function(t,e,s,i,n,a,r){if(i.spread){const s=1+2*i.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Xe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},s),Xe}},isTransformShadow(t){},getInnerShadowSpread:Ze},{excludeRenderBounds:Je}=g;let Ke;function ts(t,e,s,i,n,a,r,o){switch(e){case"grayscale":Ke||(Ke=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,i,n,a){const r=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(i,r),a&&i.recycle(r);ss(t,e,s,1,n,a)}(t,s,i,n,r,o);break;case"opacity-path":ss(t,s,i,a,r,o);break;case"path":o&&s.restore()}}function es(t){return t.getSameCanvas(!1,!0)}function ss(t,e,s,i,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(s,r,void 0,n),a?s.recycle(r):s.clearWorld(r)}N.prototype.__renderMask=function(t,e){let s,i,n,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],o=s.__.mask,o){r&&(ts(this,r,t,n,i,a,void 0,!0),i=n=null),"clipping"!==o&&"clipping-path"!==o||Je(s,e)||s.__render(t,e),a=s.__.opacity,Ke=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=es(t))):(r="path",t.save()),s.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=es(t)),n||(n=es(t)),s.__render(i,e));continue}const c=1===a&&s.__.__blendMode;c&&ts(this,r,t,n,i,a,void 0,!1),Je(s,e)||s.__render(n||t,e),c&&ts(this,r,t,n,i,a,c,!1)}ts(this,r,t,n,i,a,void 0,!0)};const is=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ns=is+"_#~&*+\\=|≮≯≈≠=…",as=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 rs(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const os=rs("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ls=rs("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ds=rs(is),cs=rs(ns),hs=rs("- —/~|┆·");var us;!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"}(us||(us={}));const{Letter:fs,Single:ps,Before:gs,After:_s,Symbol:ws,Break:ms}=us;function ys(t){return os[t]?fs:hs[t]?ms:ls[t]?gs:ds[t]?_s:cs[t]?ws:as.test(t)?ps:fs}const xs={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let a=n-1;a>-1&&(s=e[a].data[0]," "===s.char);a--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function vs(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:bs}=xs,{Letter:Ss,Single:ks,Before:Bs,After:Es,Symbol:Rs,Break:As}=us;let Ls,Ts,Os,Ws,Cs,Ms,Ds,Ps,Is,Fs,Ys,zs,Us,Gs,qs,Xs,Ns,js=[];function Hs(t,e){Is&&!Ps&&(Ps=Is),Ls.data.push({char:t,width:e}),Os+=e}function Vs(){Ws+=Os,Ls.width=Os,Ts.words.push(Ls),Ls={data:[]},Os=0}function Qs(){Gs&&(qs.paraNumber++,Ts.paraStart=!0,Gs=!1),Is&&(Ts.startCharSize=Ps,Ts.endCharSize=Is,Ps=0),Ts.width=Ws,Xs.width?bs(Ts):Ns&&Zs(),js.push(Ts),Ts={words:[]},Ws=0}function Zs(){Ws>(qs.maxWidth||0)&&(qs.maxWidth=Ws)}const{top:$s,right:Js,bottom:Ks,left:ti}=I;function ei(t,e,s){const{bounds:i,rows:n}=t;i[e]+=s;for(let t=0;t<n.length;t++)n[t][e]+=s}const si={getDrawData:function(t,s){L(t)||(t=String(t));let i=0,n=0,a=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=s;d&&(a?(i=d[ti],a-=d[Js]+d[ti]):s.autoSizeAlign||(i=d[ti]),r?(n=d[$s],r-=d[$s]+d[Ks]):s.autoSizeAlign||(n=d[$s]));const c={bounds:{x:i,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,s,i){qs=t,js=t.rows,Xs=t.bounds,Ns=!Xs.width&&!i.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=i,{canvas:o}=e,{width:l,height:d}=Xs;if(l||d||n||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Gs=!0,Ys=null,Ps=Ds=Is=Os=Ws=0,Ls={data:[]},Ts={words:[]},n&&(s=[...s]);for(let i=0,d=s.length;i<d;i++)Ms=s[i],"\n"===Ms?(Os&&Vs(),Ts.paraEnd=!0,Qs(),Gs=!0):(Fs=ys(Ms),Fs===Ss&&"none"!==r&&(Ms=vs(Ms,r,!Os)),Ds=o.measureText(Ms).width,n&&(n<0&&(Is=Ds),Ds+=n),zs=Fs===ks&&(Ys===ks||Ys===Ss)||Ys===ks&&Fs!==Es,Us=!(Fs!==Bs&&Fs!==ks||Ys!==Rs&&Ys!==Es),Cs=Gs&&a?l-a:l,t&&l&&Ws+Os+Ds>Cs&&(e?(Os&&Vs(),Ws&&Qs()):(Us||(Us=Fs===Ss&&Ys==Es),zs||Us||Fs===As||Fs===Bs||Fs===ks||Os+Ds>Cs?(Os&&Vs(),Ws&&Qs()):Ws&&Qs()))," "===Ms&&!0!==Gs&&Ws+Os===0||(Fs===As?(" "===Ms&&Os&&Vs(),Hs(Ms,Ds),Vs()):zs||Us?(Os&&Vs(),Hs(Ms,Ds)):Hs(Ms,Ds)),Ys=Fs);Os&&Vs(),Ws&&Qs(),js.length>0&&(js[js.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{qs.paraNumber++,Ws=o.measureText(t).width,js.push({x:a||0,text:t,width:Ws,paraStart:!0}),Ns&&Zs()})}(c,t,s),d&&function(t,e,s,i,n){if(!i&&s.autoSizeAlign)switch(s.textAlign){case"left":ei(e,"x",t[ti]);break;case"right":ei(e,"x",-t[Js])}if(!n&&s.autoSizeAlign)switch(s.verticalAlign){case"top":ei(e,"y",t[$s]);break;case"bottom":ei(e,"y",-t[Ks])}}(d,c,s,a,r),function(t,e){const{rows:s,bounds:i}=t,n=s.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=s[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<i.x&&(i.x=x),v>i.width&&(i.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=s.length))}i.y=p,i.height=w}(c,s),function(t,e,s){const{rows:i}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;i.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=s&&("justify"===n||"both"===n)&&u>1?(s-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,s)=>{1===c?(h={char:"",x:o},o=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,s,i){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||s===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,s,a),c.overflow&&function(t,s,i,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=s;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=i+n-d;("none"===s.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let s=e.data.length-1;for(let i=s;i>-1&&(t=e.data[i],l=t.x+t.width,!(i===s&&l<c));i--){if(l<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,i,a),"none"!==o&&function(t,e){let s,i=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,k(a)?(s=a.type,a.color&&(t.decorationColor=U.string(a.color)),a.offset&&(i=Math.min(.3*n,Math.max(a.offset,.15*-n)))):s=a,s){case"under":t.decorationY=[.15*n+i];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+i,.35*-n]}}(c,s),c}};const ii={string:function(t,e){if(!t)return"#000";const s=F(e)&&e<1;if(L(t)){if(!s||!U.object)return t;t=U.object(t)}let i=A(t.a)?1:t.a;s&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}};Object.assign(j,si),Object.assign(U,ii),Object.assign(z,Wt),Object.assign(Y,ye),Object.assign(G,Fe),Object.assign(X,$e),Q();export{lt as Layouter,H as LeaferCanvas,ct as Renderer,$ as Watcher,Q as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as s,FileHelper as i,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,isObject as k,BoundsHelper as B,FourNumberHelper as E,Matrix as R,isUndefined as A,isString as L,getMatrixData as T,MatrixHelper as O,MathHelper as W,AlignHelper as C,PointHelper as M,ImageEvent as D,AroundHelper as P,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as Y,Paint as z,ColorConvert as U,PaintGradient as G,Export as q,Effect as X,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=Math.ceil(t*s),this.view.height=Math.ceil(e*s),this.clientBounds=this.bounds}}s(OffscreenCanvasRenderingContext2D.prototype),s(Path2D.prototype);const{mineType:V}=i;function Q(t,s){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise((i,n)=>{t.convertToBlob({type:V(e),quality:s}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,s)=>t.convertToBlob({type:V(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((s,i)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{s(t)}).catch(t=>{i(t)})},n.onerror=t=>i(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Z.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?e.os="Mac":Z.indexOf("Linux")>-1&&(e.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=l.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===c.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,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=f,{pushAllChildBranch:et,pushAllParent:st}=p;const{worldBounds:it}=g;class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,it),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:at,updateAllChange:rt}=f,ot=m.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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(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(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(i);o.forEach(t=>t.setBefore()),s.emitEvent(new x(n,o,this.times)),this.extraBlock=null,i.sort(),function(t,e){let s;t.list.forEach(t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),st(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))})}(i,this.__levelList),function(t){let e,s,i;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber){i=s.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||K(i[t])}K(s)}})}(this.__levelList),function(t){t.list.forEach(tt)}(i),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),s.emitEvent(new x(a,o,this.times)),s.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(s,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(i,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){at(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new nt([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=m.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,s&&(this.config=l.default(s,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 _,dt.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,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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=v.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=new _(i);s.save(),i.spread(ct.clipSpread).ceil(),s.clearWorld(i),s.clipWorld(i),this.__render(i,n),s.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,s){const{canvas:i}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),e.render(this.target,i,a),this.renderBounds=s=s||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),i.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;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 s=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return e.requestRender(s);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()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;if(!new _(0,0,e,s).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,s){this.target.emitEvent(new d(t,this.times,e,s))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let a;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,s=i.length;t<s;t++)a=i[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=s.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,a)))}}function ut(t,e){t.__.__font?ht(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,s){switch(e.__.strokeAlign){case"center":pt(t,1,e,s);break;case"inside":gt(t,"inside",e,s);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,s):gt(t,"outside",e,s)}}function pt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!0,s,i):(i.setStroke(t,n.__strokeWidth*e,n),_t(s,i))}function gt(t,e,s,i){const n=i.getSameCanvas(!0,!0);n.font=s.__.__font,pt(t,2,s,n),n.blendMode="outside"===e?"destination-out":"destination-in",ht(s,n),n.blendMode="normal",f.copyCanvasByWorld(s,i,n),n.recycle(s.__nowWorld)}function _t(t,e){let s,i=t.__.__textDrawData;const{rows:n,decorationY:a}=i;for(let t=0,i=n.length;t<i;t++)s=n[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(a){const{decorationHeight:t}=i;n.forEach(s=>a.forEach(i=>e.strokeRect(s.x,s.y+i,s.width,t)))}}function wt(t,e,s,i,n){let a;const r=i.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!Y.checkImage(i,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),s?_t(i,n):n.stroke(),n.restoreBlendMode()):s?_t(i,n):n.stroke()}}function mt(t,e,s){const i=e.__;if(i.__strokeWidth)if(i.__font)ft(t,e,s);else switch(i.strokeAlign){case"center":yt(t,1,e,s);break;case"inside":!function(t,e,s){s.save(),s.clipUI(e),yt(t,2,e,s),s.restore()}(t,e,s);break;case"outside":!function(t,e,s){const i=e.__;if(i.__fillAfterStroke)yt(t,2,e,s);else{const{renderBounds:n}=e.__layout,a=s.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(i),a.clearWorld(n),f.copyCanvasByWorld(e,s,a),a.recycle(e.__nowWorld)}}(t,e,s)}}function yt(t,e,s,i){const n=s.__;k(t)?wt(t,e,!1,s,i):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&z.strokeArrow(t,s,i)}ct.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,s)=>new ct(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,i)=>{}}),e.layout=lt.fullLayout,e.render=function(t,e,s){const i=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new o,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,i))};const{getSpread:xt,copyAndSpread:vt,toOuterOf:bt,getOuterOf:St,getByMove:kt,move:Bt,getIntersectData:Et}=B,Rt={};let At;const{stintSet:Lt}=l,{hasTransparent:Tt}=U;function Ot(t,e,s){if(!k(e)||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:n}=s.__layout;switch(e.type){case"image":i=Y.image(s,t,e,n,!At||!At[e.url]);break;case"linear":i=G.linearGradient(e,n);break;case"radial":i=G.radialGradient(e,n);break;case"angular":i=G.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;i={type:a,style:U.string(r,o)};break;default:A(e.r)||(i={type:"solid",style:U.string(e)})}if(i){if(L(i.style)&&Tt(i.style)&&(i.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;i.strokeStyle=e.style}e.editing&&(i.editing=e.editing),e.blendMode&&(i.blendMode=e.blendMode)}return i}const Wt={compute:function(t,e){const s=e.__,i=[];let n,a,r,o=s.__input[t];w(o)||(o=[o]),At=Y.recycleImage(t,s);for(let s,n=0,a=o.length;n<a;n++)(s=Ot(t,o[n],e))&&(i.push(s),s.strokeStyle&&(r||(r=1),s.strokeStyle.strokeWidth&&(r=Math.max(r,s.strokeStyle.strokeWidth))));s["_"+t]=i.length?i:void 0,i.length&&i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Lt(s,"__isAlphaPixelFill",n),Lt(s,"__isTransparentFill",a)):(Lt(s,"__isAlphaPixelStroke",n),Lt(s,"__isTransparentStroke",a),Lt(s,"__hasMultiStrokeStyle",r))},fill:function(t,e,s){s.fillStyle=t,ut(e,s)},fills:function(t,e,s){let i;for(let n=0,a=t.length;n<a;n++){if(i=t[n],i.image){if(Y.checkImage(e,s,i,!e.__.__font))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(s,i.image);continue}}if(s.fillStyle=i.style,i.transform||i.scaleFixed){if(s.save(),i.transform&&s.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&n>1)&&s.scale(1/t,1/n)}i.blendMode&&(s.blendMode=i.blendMode),ut(e,s),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),ut(e,s),s.restoreBlendMode()):ut(e,s)}},fillPathOrText:ut,fillText:ht,stroke:mt,strokes:function(t,e,s){mt(t,e,s)},strokeText:ft,drawTextStroke:_t,shape:function(t,s,i){const n=s.getSameCanvas(),a=s.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;bt(o.strokeSpread?(vt(Rt,o.boxBounds,o.strokeSpread),Rt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,d=f=l,c=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?xt(a,E.swapAndScale(o.renderShapeSpread,g,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=s.getSameCanvas(),t.__renderShape(p,i),g*=w,_*=m),f=St(l,u),d=kt(f,-u.e,-u.f),c=St(r,u),Bt(c,-u.e,-u.f);const y=i.matrix;y?(h=new R(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),i=Object.assign(Object.assign({},i),{matrix:h})}return t.__renderShape(n,i),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Ct={},Mt=T();const{get:Dt,set:Pt,rotateOfOuter:It,translate:Ft,scaleOfOuter:Yt,multiplyParent:zt,scale:Ut,rotate:Gt,skew:qt}=O;function Xt(t,e,s,i){const n=Dt();Ft(n,e.x,e.y),s&&Ut(n,s,i),t.transform=n}function Nt(t,e,s,i,n,a,r){const o=Dt();Ft(o,e.x+s,e.y+i),Ut(o,n,a),r&&It(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function jt(t,e,s,i,n,a,r,o,l,d){const c=Dt();Vt(c,e,s,i,n,a,r,o),l&&(r||o?(Pt(Mt),Yt(Mt,e,l,d),zt(c,Mt)):Yt(c,e,l,d)),t.transform=c}function Ht(t,e,s,i,n,a,r,o,l,d,c,h){const u=Dt();if(h)Vt(u,e,n,a,r,o,l,d);else{if(l)if("center"===c)It(u,{x:s/2,y:i/2},l);else switch(Gt(u,l),l){case 90:Ft(u,i,0);break;case 180:Ft(u,s,i);break;case 270:Ft(u,0,s)}Ct.x=e.x+n,Ct.y=e.y+a,Ft(u,Ct.x,Ct.y),r&&Yt(u,Ct,r,o)}t.transform=u}function Vt(t,e,s,i,n,a,r,o){r&&Gt(t,r),o&&qt(t,o.x,o.y),n&&Ut(t,n,a),Ft(t,e.x+s,e.y+i)}const{get:Qt,translate:Zt}=O,$t=new _,Jt={},Kt={};function te(t,e,s,i){const{changeful:n,sync:a,scaleFixed:r}=s;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ee(s,i,e)}function ee(t,e,s){t.padding&&(e=$t.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:n}=s;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===i&&e.height===n,m={mode:r},y="center"!==o&&(h||0)%180==90;let x,v;switch(B.set(Kt,0,0,y?n:i,y?i:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(W.getScaleData(d,c,s,Jt),x=Jt.scaleX,v=Jt.scaleY),(o||g||p)&&(x&&B.scale(Kt,x,v,!0),o&&C.toPoint(o,Kt,e,Kt,!0,!0))):w&&!h||(x=v=B.getFitScale(e,Kt,"fit"!==r),B.put(e,s,o,x,!1,Kt),B.scale(Kt,x,v,!0)),l&&M.move(Kt,l),r){case"stretch":w||(x=e.width/i,v=e.height/n,Xt(m,e,x,v));break;case"normal":case"clip":if(Kt.x||Kt.y||x||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),jt(m,e,Kt.x,Kt.y,x,v,h,u,t,s),t&&(x=x?x*t:t,v=v?v*s:s)}break;case"repeat":(!w||x||h||u)&&Ht(m,e,i,n,Kt.x,Kt.y,x,v,h,u,o,t.freeTransform),p||(m.repeat="repeat");const s=k(p);(g||s)&&(m.gap=function(t,e,s,i,n){let a,r;k(t)?(a=t.x,r=t.y):a=r=t;return{x:se(a,s,n.width,e&&e.x),y:se(r,i,n.height,e&&e.y)}}(g,s&&p,Kt.width,Kt.height,e));break;default:x&&Nt(m,e,Kt.x,Kt.y,x,v,h)}return m.transform||(e.x||e.y)&&Zt(m.transform=Qt(),e.x,e.y),m.width=i,m.height=n,x&&(m.scaleX=x,m.scaleY=v),a&&(m.opacity=a),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function se(t,e,s,i){const n=L(t)||i?(i?s-i*e:s%e)/((i||Math.floor(s/e))-1):t;return"auto"===t&&n<0?0:n}let ie,ne=new _;const{isSame:ae}=B;function re(t,e,s,i,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||te(n,i,s,a),!0}function oe(t,e){ce(t,D.LOAD,e)}function le(t,e){ce(t,D.LOADED,e)}function de(t,e,s){e.error=s,t.forceUpdate("surface"),ce(t,D.ERROR,e)}function ce(t,e,s){t.hasEvent(e)&&t.emitEvent(new D(e,s))}function he(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:ue,scale:fe,copy:pe}=O,{floor:ge,ceil:_e,max:we,abs:me}=Math;function ye(t,s,i){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,s.scaleFixed);const r=n+"-"+a+"-"+i;if(s.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=s;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=i,a*=i,f&&(f=me(f),p=me(p),c=ue(),pe(c,g),fe(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const m=h*u;if(!_&&m>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/_e(t))}else{const t=o.width*o.height;y>t&&(y=t)}m>y&&(d=Math.sqrt(m/y)),d&&(n/=d,a/=d,h/=d,u/=d),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(x||0),e=u+(v||0);n/=t/we(ge(t),1),a/=e/we(ge(e),1),c||(c=ue(),g&&pe(c,g)),fe(c,1/n,1/a)}const b=o.getCanvas(h,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),S=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,s);return s.style=S,s.patternId=r,!0}}function xe(t,e,s,i){return new(s||(s=Promise))(function(n,a){function r(t){try{l(i.next(t))}catch(t){a(t)}}function o(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(r,o)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const ve={image:function(t,e,s,i,n){let a,r;const o=b.get(s);return ie&&s===ie.paint&&ae(i,ie.boxBounds)?a=ie.leafPaint:(a={type:s.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ie=o.use>1?{leafPaint:a,paint:s,boxBounds:ne.set(i)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:s}),o.ready?(re(t,e,s,o,a,i),n&&(oe(t,r),le(t,r))):o.error?n&&de(t,r,o.error):(n&&(he(t,!0),oe(t,r)),a.loadId=o.load(()=>{he(t,!1),t.destroyed||(re(t,e,s,o,a,i)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),le(t,r)),a.loadId=void 0},e=>{he(t,!1),de(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,s,i,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:o}=s,{data:l}=i;if(!l||i.patternId===a+"-"+r+"-"+o&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(i.changeful||"miniapp"===e.name&&S.isResizing(t)||q.running)){let{width:t,height:s}=l;t*=a*o,s*=r*o,l.scaleX&&(t*=l.scaleX,s*=l.scaleY),n=t*s>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),function(t,e,s,i){e.save(),e.clipUI(t),s.blendMode&&(e.blendMode=s.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(s.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,s,i,l),!0):(!i.style||i.sync||q.running?ye(t,i,o):i.patternTask||(i.patternTask=b.patternTasker.add(()=>xe(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(t.__nowWorld)&&ye(t,i,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ye,recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let i,n,a,r,o;for(let l=0,d=s.length;l<d;l++)i=s[l],n=i.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(s[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:te,getPatternData:ee,stretchMode:Xt,fillOrFitMode:Nt,clipMode:jt,repeatMode:Ht},{toPoint:be}=P,{hasTransparent:Se}=U,ke={},Be={};function Ee(t,e,s,i){if(s){let n,a,r,o;for(let t=0,l=s.length;t<l;t++)n=s[t],L(n)?(r=t/(l-1),a=U.string(n,i)):(r=n.offset,a=U.string(n.color,i)),e.addColorStop(r,a),!o&&Se(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Re,getDistance:Ae}=M,{get:Le,rotateOfOuter:Te,scaleOfOuter:Oe}=O,{toPoint:We}=P,Ce={},Me={};function De(t,e,s,i,n){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Re(e,s);a=Le(),n?(Oe(a,e,r/o*(i||1),1),Te(a,e,t+90)):(Oe(a,e,1,r/o*(i||1)),Te(a,e,t))}return a}const{getDistance:Pe}=M,{toPoint:Ie}=P,Fe={},Ye={};const ze={linearGradient:function(t,s){let{from:i,to:n,type:a,opacity:r}=t;be(i||"top",s,ke),be(n||"bottom",s,Be);const o=e.canvas.createLinearGradient(ke.x,ke.y,Be.x,Be.y),l={type:a,style:o};return Ee(l,o,t.stops,r),l},radialGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;We(i||"center",s,Ce),We(n||"bottom",s,Me);const l=e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Ae(Ce,Me)),d={type:a,style:l};Ee(d,l,t.stops,r);const c=De(s,Ce,Me,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:i,to:n,type:a,opacity:r,stretch:o}=t;Ie(i||"center",s,Fe),Ie(n||"bottom",s,Ye);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Fe.x,Fe.y):e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Pe(Fe,Ye)),d={type:a,style:l};Ee(d,l,t.stops,r);const c=De(s,Fe,Ye,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:De},{copy:Ue,move:Ge,toOffsetOutBounds:qe}=B,{max:Xe,abs:Ne}=Math,je={},He=new R,Ve={};function Qe(t,e){let s,i,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,i=t.y||0,a=1.5*(t.blur||0),n=Ne(t.spread||0),r=Xe(r,n+a-i),o=Xe(o,n+a+s),l=Xe(l,n+a+i),d=Xe(d,n+a-s)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ze(t,s,i){const{shapeBounds:n}=i;let a,r;e.fullImageShadow?(Ue(je,t.bounds),Ge(je,s.x-n.x,s.y-n.y),a=t.bounds,r=je):(a=n,r=s),t.copyWorld(i.canvas,a,r)}const{toOffsetOutBounds:$e}=B,Je={};const Ke=Qe;const ts={shadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;qe(l,Ve,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ve.offsetX+(r.x||0)*h*w,Ve.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w,U.string(r.color)),n=X.getShadowTransform(t,p,s,r,Ve,w),n&&p.setTransform(n),Ze(p,Ve,s),n&&p.resetTransform(),i=d,r.box&&(p.restore(),p.save(),o&&(p.copyWorld(p,d,a,"copy"),i=a),o?p.copyWorld(o,a,a,"destination-out"):p.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=r.length-1;$e(l,Je,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Je.offsetX+(r.x||0)*h*w,Je.offsetY+(r.y||0)*u*w,(r.blur||0)*h*w),n=X.getShadowTransform(t,p,s,r,Je,w,!0),n&&p.setTransform(n),Ze(p,Je,s),p.restore(),o?(p.copyWorld(p,d,a,"copy"),p.copyWorld(o,a,a,"source-out"),i=a):(p.copyWorld(s.canvas,c,l,"source-out"),i=d),p.fillWorld(i,U.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,r.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__nowWorld.a),s.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),s.filter="none"},backgroundBlur:function(t,e,s){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,s,i,n,a,r){if(i.spread){const s=2*i.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return He.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+s/o,1+s/l),He}},isTransformShadow(t){},getInnerShadowSpread:Ke},{excludeRenderBounds:es}=g;let ss;function is(t,e,s,i,n,a,r,o){switch(e){case"grayscale":ss||(ss=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,i,n,a){const r=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(i,r),a&&i.recycle(r);as(t,e,s,1,n,a)}(t,s,i,n,r,o);break;case"opacity-path":as(t,s,i,a,r,o);break;case"path":o&&s.restore()}}function ns(t){return t.getSameCanvas(!1,!0)}function as(t,e,s,i,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(s,r,void 0,n),a?s.recycle(r):s.clearWorld(r)}N.prototype.__renderMask=function(t,e){let s,i,n,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],o=s.__.mask,o){r&&(is(this,r,t,n,i,a,void 0,!0),i=n=null),"clipping"!==o&&"clipping-path"!==o||es(s,e)||s.__render(t,e),a=s.__.opacity,ss=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=ns(t))):(r="path",t.save()),s.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=ns(t)),n||(n=ns(t)),s.__render(i,e));continue}const c=1===a&&s.__.__blendMode;c&&is(this,r,t,n,i,a,void 0,!1),es(s,e)||s.__render(n||t,e),c&&is(this,r,t,n,i,a,c,!1)}is(this,r,t,n,i,a,void 0,!0)};const rs=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",os=rs+"_#~&*+\\=|≮≯≈≠=…",ls=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 ds(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const cs=ds("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),hs=ds("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),us=ds(rs),fs=ds(os),ps=ds("- —/~|┆·");var gs;!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"}(gs||(gs={}));const{Letter:_s,Single:ws,Before:ms,After:ys,Symbol:xs,Break:vs}=gs;function bs(t){return cs[t]?_s:ps[t]?vs:hs[t]?ms:us[t]?ys:fs[t]?xs:ls.test(t)?ws:_s}const Ss={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let a=n-1;a>-1&&(s=e[a].data[0]," "===s.char);a--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function ks(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Bs}=Ss,{Letter:Es,Single:Rs,Before:As,After:Ls,Symbol:Ts,Break:Os}=gs;let Ws,Cs,Ms,Ds,Ps,Is,Fs,Ys,zs,Us,Gs,qs,Xs,Ns,js,Hs,Vs,Qs=[];function Zs(t,e){zs&&!Ys&&(Ys=zs),Ws.data.push({char:t,width:e}),Ms+=e}function $s(){Ds+=Ms,Ws.width=Ms,Cs.words.push(Ws),Ws={data:[]},Ms=0}function Js(){Ns&&(js.paraNumber++,Cs.paraStart=!0,Ns=!1),zs&&(Cs.startCharSize=Ys,Cs.endCharSize=zs,Ys=0),Cs.width=Ds,Hs.width?Bs(Cs):Vs&&Ks(),Qs.push(Cs),Cs={words:[]},Ds=0}function Ks(){Ds>(js.maxWidth||0)&&(js.maxWidth=Ds)}const{top:ti,right:ei,bottom:si,left:ii}=I;function ni(t,e,s){const{bounds:i,rows:n}=t;i[e]+=s;for(let t=0;t<n.length;t++)n[t][e]+=s}const ai={getDrawData:function(t,s){L(t)||(t=String(t));let i=0,n=0,a=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=s;d&&(a?(i=d[ii],a-=d[ei]+d[ii]):s.autoSizeAlign||(i=d[ii]),r?(n=d[ti],r-=d[ti]+d[si]):s.autoSizeAlign||(n=d[ti]));const c={bounds:{x:i,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,s,i){js=t,Qs=t.rows,Hs=t.bounds,Vs=!Hs.width&&!i.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=i,{canvas:o}=e,{width:l,height:d}=Hs;if(l||d||n||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ns=!0,Gs=null,Ys=Fs=zs=Ms=Ds=0,Ws={data:[]},Cs={words:[]},n&&(s=[...s]);for(let i=0,d=s.length;i<d;i++)Is=s[i],"\n"===Is?(Ms&&$s(),Cs.paraEnd=!0,Js(),Ns=!0):(Us=bs(Is),Us===Es&&"none"!==r&&(Is=ks(Is,r,!Ms)),Fs=o.measureText(Is).width,n&&(n<0&&(zs=Fs),Fs+=n),qs=Us===Rs&&(Gs===Rs||Gs===Es)||Gs===Rs&&Us!==Ls,Xs=!(Us!==As&&Us!==Rs||Gs!==Ts&&Gs!==Ls),Ps=Ns&&a?l-a:l,t&&l&&Ds+Ms+Fs>Ps&&(e?(Ms&&$s(),Ds&&Js()):(Xs||(Xs=Us===Es&&Gs==Ls),qs||Xs||Us===Os||Us===As||Us===Rs||Ms+Fs>Ps?(Ms&&$s(),Ds&&Js()):Ds&&Js()))," "===Is&&!0!==Ns&&Ds+Ms===0||(Us===Os?(" "===Is&&Ms&&$s(),Zs(Is,Fs),$s()):qs||Xs?(Ms&&$s(),Zs(Is,Fs)):Zs(Is,Fs)),Gs=Us);Ms&&$s(),Ds&&Js(),Qs.length>0&&(Qs[Qs.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{js.paraNumber++,Ds=o.measureText(t).width,Qs.push({x:a||0,text:t,width:Ds,paraStart:!0}),Vs&&Ks()})}(c,t,s),d&&function(t,e,s,i,n){if(!i&&s.autoSizeAlign)switch(s.textAlign){case"left":ni(e,"x",t[ii]);break;case"right":ni(e,"x",-t[ei])}if(!n&&s.autoSizeAlign)switch(s.verticalAlign){case"top":ni(e,"y",t[ti]);break;case"bottom":ni(e,"y",-t[si])}}(d,c,s,a,r),function(t,e){const{rows:s,bounds:i}=t,n=s.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=s[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<i.x&&(i.x=x),v>i.width&&(i.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=s.length))}i.y=p,i.height=w}(c,s),function(t,e,s){const{rows:i}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;i.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=s&&("justify"===n||"both"===n)&&u>1?(s-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,s)=>{1===c?(h={char:"",x:o},o=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,s,i){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||s===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,s,a),c.overflow&&function(t,s,i,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=s;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=i+n-d;("none"===s.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let s=e.data.length-1;for(let i=s;i>-1&&(t=e.data[i],l=t.x+t.width,!(i===s&&l<c));i--){if(l<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,i,a),"none"!==o&&function(t,e){let s,i=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,k(a)?(s=a.type,a.color&&(t.decorationColor=U.string(a.color)),a.offset&&(i=Math.min(.3*n,Math.max(a.offset,.15*-n)))):s=a,s){case"under":t.decorationY=[.15*n+i];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+i,.35*-n]}}(c,s),c}};const ri={string:function(t,e){if(!t)return"#000";const s=F(e)&&e<1;if(L(t)){if(!s||!U.object)return t;t=U.object(t)}let i=A(t.a)?1:t.a;s&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}};Object.assign(j,ai),Object.assign(U,ri),Object.assign(z,Wt),Object.assign(Y,ve),Object.assign(G,ze),Object.assign(X,ts),Q();export{lt as Layouter,H as LeaferCanvas,ct as Renderer,$ as Watcher,Q as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map