@leafer-ui/worker 1.9.9 → 1.9.10

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
@@ -670,7 +670,7 @@ class Picker {
670
670
  children: [ target ]
671
671
  } : target);
672
672
  const {list: list} = this.findList;
673
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
673
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
674
674
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
675
675
  this.clear();
676
676
  return through ? {
@@ -685,7 +685,7 @@ class Picker {
685
685
  hitPoint(hitPoint, hitRadius, options) {
686
686
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
687
687
  }
688
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
688
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
689
689
  const findList = this.findList = new core.LeafList;
690
690
  if (list.length) {
691
691
  let find;
@@ -716,15 +716,27 @@ class Picker {
716
716
  if (findList.length) return findList.list[0];
717
717
  }
718
718
  }
719
+ if (allowNull) return null;
719
720
  return ignoreHittable ? list[0] : list.find(item => core.LeafHelper.worldHittable(item));
720
721
  }
721
722
  getPath(leaf) {
722
- const path = new core.LeafList;
723
+ const path = new core.LeafList, syncList = [], {target: target} = this;
723
724
  while (leaf) {
725
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
724
726
  path.add(leaf);
725
727
  leaf = leaf.parent;
728
+ if (leaf === target) break;
729
+ }
730
+ if (syncList.length) {
731
+ syncList.forEach(item => {
732
+ while (item) {
733
+ if (item.__.hittable) path.add(item);
734
+ item = item.parent;
735
+ if (item === target) break;
736
+ }
737
+ });
726
738
  }
727
- if (this.target) path.add(this.target);
739
+ if (target) path.add(target);
728
740
  return path;
729
741
  }
730
742
  getHitablePath(leaf) {
@@ -1200,7 +1212,14 @@ const PaintModule = {
1200
1212
 
1201
1213
  let origin = {}, tempMatrix$1 = core.getMatrixData();
1202
1214
 
1203
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1215
+ 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;
1216
+
1217
+ function stretchMode(data, box, scaleX, scaleY) {
1218
+ const transform = get$3();
1219
+ translate$1(transform, box.x, box.y);
1220
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1221
+ data.transform = transform;
1222
+ }
1204
1223
 
1205
1224
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1206
1225
  const transform = get$3();
@@ -1217,8 +1236,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1217
1236
  const transform = get$3();
1218
1237
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1219
1238
  if (clipScaleX) {
1220
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1221
- multiplyParent(transform, tempMatrix$1);
1239
+ if (rotation || skew) {
1240
+ set(tempMatrix$1);
1241
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1242
+ multiplyParent(transform, tempMatrix$1);
1243
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1222
1244
  }
1223
1245
  data.transform = transform;
1224
1246
  }
@@ -1314,7 +1336,10 @@ function getPatternData(paint, box, image) {
1314
1336
  if (offset) core.PointHelper.move(tempImage, offset);
1315
1337
  switch (mode) {
1316
1338
  case "stretch":
1317
- if (!sameBox) width = box.width, height = box.height;
1339
+ if (!sameBox) {
1340
+ scaleX = box.width / width, scaleY = box.height / height;
1341
+ stretchMode(data, box, scaleX, scaleY);
1342
+ }
1318
1343
  break;
1319
1344
 
1320
1345
  case "normal":
@@ -1323,7 +1348,7 @@ function getPatternData(paint, box, image) {
1323
1348
  let clipScaleX, clipScaleY;
1324
1349
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1325
1350
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1326
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1351
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1327
1352
  }
1328
1353
  break;
1329
1354
 
@@ -1340,17 +1365,14 @@ function getPatternData(paint, box, image) {
1340
1365
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1341
1366
  }
1342
1367
  if (!data.transform) {
1343
- if (box.x || box.y) {
1344
- data.transform = get$2();
1345
- translate(data.transform, box.x, box.y);
1346
- }
1368
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1347
1369
  }
1348
- if (scaleX && mode !== "stretch") {
1370
+ data.width = width;
1371
+ data.height = height;
1372
+ if (scaleX) {
1349
1373
  data.scaleX = scaleX;
1350
1374
  data.scaleY = scaleY;
1351
1375
  }
1352
- data.width = width;
1353
- data.height = height;
1354
1376
  if (opacity) data.opacity = opacity;
1355
1377
  if (filters) data.filters = filters;
1356
1378
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -1482,7 +1504,7 @@ function ignoreRender(ui, value) {
1482
1504
 
1483
1505
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1484
1506
 
1485
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
1507
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
1486
1508
 
1487
1509
  function createPattern(ui, paint, pixelRatio) {
1488
1510
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1493,8 +1515,8 @@ function createPattern(ui, paint, pixelRatio) {
1493
1515
  scaleX *= pixelRatio;
1494
1516
  scaleY *= pixelRatio;
1495
1517
  if (sx) {
1496
- sx = abs(sx);
1497
- sy = abs(sy);
1518
+ sx = abs$1(sx);
1519
+ sy = abs$1(sy);
1498
1520
  imageMatrix = get$1();
1499
1521
  copy$1(imageMatrix, transform);
1500
1522
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1669,6 +1691,7 @@ const PaintImageModule = {
1669
1691
  recycleImage: recycleImage,
1670
1692
  createData: createData,
1671
1693
  getPatternData: getPatternData,
1694
+ stretchMode: stretchMode,
1672
1695
  fillOrFitMode: fillOrFitMode,
1673
1696
  clipMode: clipMode,
1674
1697
  repeatMode: repeatMode
@@ -1779,7 +1802,7 @@ const PaintGradientModule = {
1779
1802
  getTransform: getTransform
1780
1803
  };
1781
1804
 
1782
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max} = Math;
1805
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper, {max: max, abs: abs} = Math;
1783
1806
 
1784
1807
  const tempBounds = {}, tempMatrix = new core.Matrix;
1785
1808
 
@@ -1823,7 +1846,7 @@ function shadow(ui, current, shape) {
1823
1846
  function getShadowRenderSpread(_ui, shadow) {
1824
1847
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
1825
1848
  shadow.forEach(item => {
1826
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
1849
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
1827
1850
  top = max(top, spread + blur - y);
1828
1851
  right = max(right, spread + blur + x);
1829
1852
  bottom = max(bottom, spread + blur + y);
@@ -674,7 +674,7 @@ class Picker {
674
674
  children: [ target ]
675
675
  } : target);
676
676
  const {list: list} = this.findList;
677
- const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
677
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList);
678
678
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
679
679
  this.clear();
680
680
  return through ? {
@@ -689,7 +689,7 @@ class Picker {
689
689
  hitPoint(hitPoint, hitRadius, options) {
690
690
  return !!this.getByPoint(hitPoint, hitRadius, options).target;
691
691
  }
692
- getBestMatchLeaf(list, bottomList, ignoreHittable) {
692
+ getBestMatchLeaf(list, bottomList, ignoreHittable, allowNull) {
693
693
  const findList = this.findList = new LeafList;
694
694
  if (list.length) {
695
695
  let find;
@@ -720,15 +720,27 @@ class Picker {
720
720
  if (findList.length) return findList.list[0];
721
721
  }
722
722
  }
723
+ if (allowNull) return null;
723
724
  return ignoreHittable ? list[0] : list.find(item => LeafHelper.worldHittable(item));
724
725
  }
725
726
  getPath(leaf) {
726
- const path = new LeafList;
727
+ const path = new LeafList, syncList = [], {target: target} = this;
727
728
  while (leaf) {
729
+ if (leaf.syncEventer) syncList.push(leaf.syncEventer);
728
730
  path.add(leaf);
729
731
  leaf = leaf.parent;
732
+ if (leaf === target) break;
733
+ }
734
+ if (syncList.length) {
735
+ syncList.forEach(item => {
736
+ while (item) {
737
+ if (item.__.hittable) path.add(item);
738
+ item = item.parent;
739
+ if (item === target) break;
740
+ }
741
+ });
730
742
  }
731
- if (this.target) path.add(this.target);
743
+ if (target) path.add(target);
732
744
  return path;
733
745
  }
734
746
  getHitablePath(leaf) {
@@ -1204,7 +1216,14 @@ const PaintModule = {
1204
1216
 
1205
1217
  let origin = {}, tempMatrix$1 = getMatrixData();
1206
1218
 
1207
- const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1219
+ const {get: get$3, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1220
+
1221
+ function stretchMode(data, box, scaleX, scaleY) {
1222
+ const transform = get$3();
1223
+ translate$1(transform, box.x, box.y);
1224
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1225
+ data.transform = transform;
1226
+ }
1208
1227
 
1209
1228
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1210
1229
  const transform = get$3();
@@ -1221,8 +1240,11 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, c
1221
1240
  const transform = get$3();
1222
1241
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1223
1242
  if (clipScaleX) {
1224
- tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1225
- multiplyParent(transform, tempMatrix$1);
1243
+ if (rotation || skew) {
1244
+ set(tempMatrix$1);
1245
+ scaleOfOuter$1(tempMatrix$1, box, clipScaleX, clipScaleY);
1246
+ multiplyParent(transform, tempMatrix$1);
1247
+ } else scaleOfOuter$1(transform, box, clipScaleX, clipScaleY);
1226
1248
  }
1227
1249
  data.transform = transform;
1228
1250
  }
@@ -1318,7 +1340,10 @@ function getPatternData(paint, box, image) {
1318
1340
  if (offset) PointHelper.move(tempImage, offset);
1319
1341
  switch (mode) {
1320
1342
  case "stretch":
1321
- if (!sameBox) width = box.width, height = box.height;
1343
+ if (!sameBox) {
1344
+ scaleX = box.width / width, scaleY = box.height / height;
1345
+ stretchMode(data, box, scaleX, scaleY);
1346
+ }
1322
1347
  break;
1323
1348
 
1324
1349
  case "normal":
@@ -1327,7 +1352,7 @@ function getPatternData(paint, box, image) {
1327
1352
  let clipScaleX, clipScaleY;
1328
1353
  if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1329
1354
  clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1330
- if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1355
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : clipScaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1331
1356
  }
1332
1357
  break;
1333
1358
 
@@ -1344,17 +1369,14 @@ function getPatternData(paint, box, image) {
1344
1369
  if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1345
1370
  }
1346
1371
  if (!data.transform) {
1347
- if (box.x || box.y) {
1348
- data.transform = get$2();
1349
- translate(data.transform, box.x, box.y);
1350
- }
1372
+ if (box.x || box.y) translate(data.transform = get$2(), box.x, box.y);
1351
1373
  }
1352
- if (scaleX && mode !== "stretch") {
1374
+ data.width = width;
1375
+ data.height = height;
1376
+ if (scaleX) {
1353
1377
  data.scaleX = scaleX;
1354
1378
  data.scaleY = scaleY;
1355
1379
  }
1356
- data.width = width;
1357
- data.height = height;
1358
1380
  if (opacity) data.opacity = opacity;
1359
1381
  if (filters) data.filters = filters;
1360
1382
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
@@ -1486,7 +1508,7 @@ function ignoreRender(ui, value) {
1486
1508
 
1487
1509
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1488
1510
 
1489
- const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
1511
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs$1} = Math;
1490
1512
 
1491
1513
  function createPattern(ui, paint, pixelRatio) {
1492
1514
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1497,8 +1519,8 @@ function createPattern(ui, paint, pixelRatio) {
1497
1519
  scaleX *= pixelRatio;
1498
1520
  scaleY *= pixelRatio;
1499
1521
  if (sx) {
1500
- sx = abs(sx);
1501
- sy = abs(sy);
1522
+ sx = abs$1(sx);
1523
+ sy = abs$1(sy);
1502
1524
  imageMatrix = get$1();
1503
1525
  copy$1(imageMatrix, transform);
1504
1526
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -1673,6 +1695,7 @@ const PaintImageModule = {
1673
1695
  recycleImage: recycleImage,
1674
1696
  createData: createData,
1675
1697
  getPatternData: getPatternData,
1698
+ stretchMode: stretchMode,
1676
1699
  fillOrFitMode: fillOrFitMode,
1677
1700
  clipMode: clipMode,
1678
1701
  repeatMode: repeatMode
@@ -1783,7 +1806,7 @@ const PaintGradientModule = {
1783
1806
  getTransform: getTransform
1784
1807
  };
1785
1808
 
1786
- const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
1809
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max, abs: abs} = Math;
1787
1810
 
1788
1811
  const tempBounds = {}, tempMatrix = new Matrix;
1789
1812
 
@@ -1827,7 +1850,7 @@ function shadow(ui, current, shape) {
1827
1850
  function getShadowRenderSpread(_ui, shadow) {
1828
1851
  let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
1829
1852
  shadow.forEach(item => {
1830
- x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
1853
+ x = item.x || 0, y = item.y || 0, blur = (item.blur || 0) * 1.5, spread = abs(item.spread || 0);
1831
1854
  top = max(top, spread + blur - y);
1832
1855
  right = max(right, spread + blur + x);
1833
1856
  bottom = max(bottom, spread + blur + y);
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as A,isString as T,getMatrixData as C,MatrixHelper as O,MathHelper as W,AlignHelper as P,PointHelper as M,ImageEvent as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as z,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,Paint as X,ColorConvert as q,PaintGradient as N,Export as j,Effect as H,Group as V,TextConvert as Q}from"@leafer-ui/draw";class Z 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:$}=s;function J(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:$(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:$(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Z(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:K}=navigator;K.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),K.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):K.indexOf("Mac")>-1?e.os="Mac":K.indexOf("Linux")>-1&&(e.os="Linux");class tt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:et,updateBounds:it,updateChange:st}=f,{pushAllChildBranch:nt,pushAllParent:at}=g;const{worldBounds:rt}=p;class ot{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,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ht=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,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?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(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||it(s[t])}it(i)}})}(this.__levelList),function(t){t.list.forEach(st)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.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:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.get("Renderer");class ft{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.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 _,ut.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,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.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:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ft.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.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,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}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 i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);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(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(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 _(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||ut.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(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ft.clipSpread=10;const{hitRadiusPoint:gt}=B;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;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 o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function wt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function mt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":vt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):vt(t,"outside",e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?kt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),bt(i,s))}function vt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,xt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",wt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function bt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function kt(t,e,i,s,n){let a;const r=s.__,{__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||!G.checkImage(s,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),i?bt(s,n):n.stroke(),n.restoreBlendMode()):i?bt(s,n):n.stroke()}}function Bt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)mt(t,e,i);else switch(s.strokeAlign){case"center":St(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),St(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)St(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),St(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function St(t,e,i,s){const n=i.__;E(t)?kt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ct.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Et,copyAndSpread:Rt,toOuterOf:Lt,getOuterOf:At,getByMove:Tt,move:Ct,getIntersectData:Ot}=B,Wt={};let Pt;const{stintSet:Mt}=l,{hasTransparent:Dt}=q;function Ft(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=G.image(i,t,e,n,!Pt||!Pt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:A(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(T(s.style)&&Dt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const It={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Pt=G.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Ft(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Mt(i,"__isAlphaPixelFill",n),Mt(i,"__isTransparentFill",a)):(Mt(i,"__isAlphaPixelStroke",n),Mt(i,"__isTransparentStroke",a),Mt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(G.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:wt,stroke:Bt,strokes:function(t,e,i){Bt(t,e,i)},strokeText:mt,drawTextStroke:bt,shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;Lt(o.strokeSpread?(Rt(Wt,o.boxBounds,o.strokeSpread),Wt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?Et(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Ot(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=At(l,u),d=Tt(f,-u.e,-u.f),h=At(r,u),Ct(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt={},zt=C();const{get:Ut,rotateOfOuter:Gt,translate:Xt,scaleOfOuter:qt,multiplyParent:Nt,scale:jt,rotate:Ht,skew:Vt}=O;function Qt(t,e,i,s,n,a,r){const o=Ut();Xt(o,e.x+i,e.y+s),jt(o,n,a),r&&Gt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Zt(t,e,i,s,n,a,r,o,l,d){const h=Ut();Jt(h,e,i,s,n,a,r,o),l&&(zt.a=l,zt.d=d,Nt(h,zt)),t.transform=h}function $t(t,e,i,s,n,a,r,o,l,d,h,c){const u=Ut();if(c)Jt(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Gt(u,{x:i/2,y:s/2},l);else switch(Ht(u,l),l){case 90:Xt(u,s,0);break;case 180:Xt(u,i,s);break;case 270:Xt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+a,Xt(u,Yt.x,Yt.y),r&&qt(u,Yt,r,o)}t.transform=u}function Jt(t,e,i,s,n,a,r,o){r&&Ht(t,r),o&&Vt(t,o.x,o.y),n&&jt(t,n,a),Xt(t,e.x+i,e.y+s)}const{get:Kt,translate:te}=O,ee=new _,ie={},se={};function ne(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ae(i,s,e)}function ae(t,e,i){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(se,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(W.getScaleData(d,h,i,ie),x=ie.scaleX,v=ie.scaleY),(o||p||g)&&(x&&B.scale(se,x,v,!0),o&&P.toPoint(o,se,e,se,!0,!0))):w&&!c||(x=v=B.getFitScale(e,se,"fit"!==r),B.put(e,i,o,x,!1,se),B.scale(se,x,v,!0)),l&&M.move(se,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":if(se.x||se.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Zt(y,e,se.x,se.y,x,v,c,u,t,i),t&&(x=x?x*t:x,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&$t(y,e,s,n,se.x,se.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:re(a,i,n.width,e&&e.x),y:re(r,s,n.height,e&&e.y)}}(p,i&&g,se.width,se.height,e));break;default:x&&Qt(y,e,se.x,se.y,x,v,c)}return y.transform||(e.x||e.y)&&(y.transform=Kt(),te(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function re(t,e,i,s){const n=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let oe,le=new _;const{isSame:de}=B;function he(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ne(n,s,i,a),!0}function ce(t,e){ge(t,D.LOAD,e)}function ue(t,e){ge(t,D.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),ge(t,D.ERROR,e)}function ge(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=O,{floor:me,ceil:xe,max:ve,abs:be}=Math;function ke(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=be(f),g=be(g),h=_e(),ye(h,p),we(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xe(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/ve(me(t),1),a/=e/ve(me(e),1),h||(h=_e(),p&&ye(h,p)),we(h,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=k,i.patternId=r,!0}}function Be(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return oe&&i===oe.paint&&de(s,oe.boxBounds)?a=oe.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),oe=o.use>1?{leafPaint:a,paint:i,boxBounds:le.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(he(t,e,i,o,a,s),n&&(ce(t,r),ue(t,r))):o.error?n&&fe(t,r,o.error):(n&&(pe(t,!0),ce(t,r)),a.loadId=o.load(()=>{pe(t,!1),t.destroyed||(he(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,r)),a.loadId=void 0},e=>{pe(t,!1),fe(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,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?ke(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>Be(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ke(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ke,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.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(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:ne,getPatternData:ae,fillOrFitMode:Qt,clipMode:Zt,repeatMode:$t},{toPoint:Ee}=F,{hasTransparent:Re}=q,Le={},Ae={};function Te(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],T(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&Re(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ce,getDistance:Oe}=M,{get:We,rotateOfOuter:Pe,scaleOfOuter:Me}=O,{toPoint:De}=F,Fe={},Ie={};function Ye(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Ce(e,i);a=We(),n?(Me(a,e,r/o*(s||1),1),Pe(a,e,t+90)):(Me(a,e,1,r/o*(s||1)),Pe(a,e,t))}return a}const{getDistance:ze}=M,{toPoint:Ue}=F,Ge={},Xe={};const qe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;Ee(s||"top",i,Le),Ee(n||"bottom",i,Ae);const o=e.canvas.createLinearGradient(Le.x,Le.y,Ae.x,Ae.y),l={type:a,style:o};return Te(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;De(s||"center",i,Fe),De(n||"bottom",i,Ie);const l=e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Oe(Fe,Ie)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Fe,Ie,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ue(s||"center",i,Ge),Ue(n||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ge.x,Ge.y):e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,ze(Ge,Xe)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Ge,Xe,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ye},{copy:Ne,move:je,toOffsetOutBounds:He}=B,{max:Ve}=Math,Qe={},Ze=new L,$e={};function Je(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),r=Ve(r,n+a-s),o=Ve(o,n+a+i),l=Ve(l,n+a+s),d=Ve(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ke(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Ne(Qe,t.bounds),je(Qe,i.x-n.x,i.y-n.y),a=t.bounds,r=Qe):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:ti}=B,ei={};const ii=Je;const si={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;He(l,$e,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow($e.offsetX+(r.x||0)*c*w,$e.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w,q.string(r.color)),n=H.getShadowTransform(t,g,i,r,$e,w),n&&g.setTransform(n),Ke(g,$e,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ti(l,ei,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ei.offsetX+(r.x||0)*c*w,ei.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w),n=H.getShadowTransform(t,g,i,r,ei,w,!0),n&&g.setTransform(n),Ke(g,ei,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Je,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Ze.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Ze}},isTransformShadow(t){},getInnerShadowSpread:ii},{excludeRenderBounds:ni}=p;let ai;function ri(t,e,i,s,n,a,r,o){switch(e){case"grayscale":ai||(ai=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);li(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":li(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function li(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(ri(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||ni(i,e)||i.__render(t,e),a=i.__.opacity,ai=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&ri(this,r,t,n,s,a,void 0,!1),ni(i,e)||i.__render(n||t,e),h&&ri(this,r,t,n,s,a,h,!1)}ri(this,r,t,n,s,a,void 0,!0)};const di=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=di+"_#~&*+\\=|≮≯≈≠=…",ci=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 ui(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const fi=ui("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),gi=ui("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=ui(di),_i=ui(hi),wi=ui("- —/~|┆·");var yi;!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"}(yi||(yi={}));const{Letter:mi,Single:xi,Before:vi,After:bi,Symbol:ki,Break:Bi}=yi;function Si(t){return fi[t]?mi:wi[t]?Bi:gi[t]?vi:pi[t]?bi:_i[t]?ki:ci.test(t)?xi:mi}const Ei={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ri(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:Li}=Ei,{Letter:Ai,Single:Ti,Before:Ci,After:Oi,Symbol:Wi,Break:Pi}=yi;let Mi,Di,Fi,Ii,Yi,zi,Ui,Gi,Xi,qi,Ni,ji,Hi,Vi,Qi,Zi,$i,Ji=[];function Ki(t,e){Xi&&!Gi&&(Gi=Xi),Mi.data.push({char:t,width:e}),Fi+=e}function ts(){Ii+=Fi,Mi.width=Fi,Di.words.push(Mi),Mi={data:[]},Fi=0}function es(){Vi&&(Qi.paraNumber++,Di.paraStart=!0,Vi=!1),Xi&&(Di.startCharSize=Gi,Di.endCharSize=Xi,Gi=0),Di.width=Ii,Zi.width?Li(Di):$i&&is(),Ji.push(Di),Di={words:[]},Ii=0}function is(){Ii>(Qi.maxWidth||0)&&(Qi.maxWidth=Ii)}const{top:ss,right:ns,bottom:as,left:rs}=I;function os(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 ls={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[rs],a-=d[ns]+d[rs]):i.autoSizeAlign||(s=d[rs]),r?(n=d[ss],r-=d[ss]+d[as]):i.autoSizeAlign||(n=d[ss]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Qi=t,Ji=t.rows,Zi=t.bounds,$i=!Zi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Zi;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Vi=!0,Ni=null,Gi=Ui=Xi=Fi=Ii=0,Mi={data:[]},Di={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)zi=i[s],"\n"===zi?(Fi&&ts(),Di.paraEnd=!0,es(),Vi=!0):(qi=Si(zi),qi===Ai&&"none"!==r&&(zi=Ri(zi,r,!Fi)),Ui=o.measureText(zi).width,n&&(n<0&&(Xi=Ui),Ui+=n),ji=qi===Ti&&(Ni===Ti||Ni===Ai)||Ni===Ti&&qi!==Oi,Hi=!(qi!==Ci&&qi!==Ti||Ni!==Wi&&Ni!==Oi),Yi=Vi&&a?l-a:l,t&&l&&Ii+Fi+Ui>Yi&&(e?(Fi&&ts(),Ii&&es()):(Hi||(Hi=qi===Ai&&Ni==Oi),ji||Hi||qi===Pi||qi===Ci||qi===Ti||Fi+Ui>Yi?(Fi&&ts(),Ii&&es()):Ii&&es()))," "===zi&&!0!==Vi&&Ii+Fi===0||(qi===Pi?(" "===zi&&Fi&&ts(),Ki(zi,Ui),ts()):ji||Hi?(Fi&&ts(),Ki(zi,Ui)):Ki(zi,Ui)),Ni=qi);Fi&&ts(),Ii&&es(),Ji.length>0&&(Ji[Ji.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Qi.paraNumber++,Ii=o.measureText(t).width,Ji.push({x:a||0,text:t,width:Ii,paraStart:!0}),$i&&is()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[rs]);break;case"right":os(e,"x",-t[ns])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[ss]);break;case"bottom":os(e,"y",-t[as])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(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,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;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,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+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)}})}}(h,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,i),h}};const ds={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(T(t)){if(!i||!q.object)return t;t=q.object(t)}let s=A(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(Q,ls),Object.assign(q,ds),Object.assign(X,It),Object.assign(G,Se),Object.assign(N,qe),Object.assign(H,si),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Z(t,e),hitCanvasManager:()=>new z}),J();export{ct as Layouter,Z as LeaferCanvas,pt as Picker,ft as Renderer,_t as Selector,tt as Watcher,J as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as A,isString as T,getMatrixData as C,MatrixHelper as O,MathHelper as W,AlignHelper as P,PointHelper as M,ImageEvent as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as z,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,Paint as X,ColorConvert as q,PaintGradient as N,Export as j,Effect as H,Group as V,TextConvert as Q}from"@leafer-ui/draw";class Z 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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:$}=s;function J(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:$(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:$(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Z(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:K}=navigator;K.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),K.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):K.indexOf("Mac")>-1?e.os="Mac":K.indexOf("Linux")>-1&&(e.os="Linux");class tt{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===h.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 c(c.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],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:et,updateBounds:it,updateChange:st}=f,{pushAllChildBranch:nt,pushAllParent:at}=g;const{worldBounds:rt}=p;class ot{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,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ht=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,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?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(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||it(s[t])}it(i)}})}(this.__levelList),function(t){t.list.forEach(st)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.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:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.get("Renderer");class ft{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.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 _,ut.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,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.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:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ft.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.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,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}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 i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);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(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(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 _(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||ut.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(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ft.clipSpread=10;const{hitRadiusPoint:gt}=B;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new o;if(t.length){let e;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=t.length;s<a;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function wt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function mt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":vt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):vt(t,"outside",e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?kt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),bt(i,s))}function vt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,xt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",wt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function bt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function kt(t,e,i,s,n){let a;const r=s.__,{__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||!G.checkImage(s,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),i?bt(s,n):n.stroke(),n.restoreBlendMode()):i?bt(s,n):n.stroke()}}function Bt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)mt(t,e,i);else switch(s.strokeAlign){case"center":St(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),St(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)St(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),St(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function St(t,e,i,s){const n=i.__;E(t)?kt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ct.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Et,copyAndSpread:Rt,toOuterOf:Lt,getOuterOf:At,getByMove:Tt,move:Ct,getIntersectData:Ot}=B,Wt={};let Pt;const{stintSet:Mt}=l,{hasTransparent:Dt}=q;function Ft(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=G.image(i,t,e,n,!Pt||!Pt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:A(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(T(s.style)&&Dt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const It={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Pt=G.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Ft(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Mt(i,"__isAlphaPixelFill",n),Mt(i,"__isTransparentFill",a)):(Mt(i,"__isAlphaPixelStroke",n),Mt(i,"__isTransparentStroke",a),Mt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(G.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:wt,stroke:Bt,strokes:function(t,e,i){Bt(t,e,i)},strokeText:mt,drawTextStroke:bt,shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;Lt(o.strokeSpread?(Rt(Wt,o.boxBounds,o.strokeSpread),Wt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?Et(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Ot(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=At(l,u),d=Tt(f,-u.e,-u.f),h=At(r,u),Ct(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt={},zt=C();const{get:Ut,set:Gt,rotateOfOuter:Xt,translate:qt,scaleOfOuter:Nt,multiplyParent:jt,scale:Ht,rotate:Vt,skew:Qt}=O;function Zt(t,e,i,s){const n=Ut();qt(n,e.x,e.y),i&&Ht(n,i,s),t.transform=n}function $t(t,e,i,s,n,a,r){const o=Ut();qt(o,e.x+i,e.y+s),Ht(o,n,a),r&&Xt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Jt(t,e,i,s,n,a,r,o,l,d){const h=Ut();te(h,e,i,s,n,a,r,o),l&&(r||o?(Gt(zt),Nt(zt,e,l,d),jt(h,zt)):Nt(h,e,l,d)),t.transform=h}function Kt(t,e,i,s,n,a,r,o,l,d,h,c){const u=Ut();if(c)te(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Xt(u,{x:i/2,y:s/2},l);else switch(Vt(u,l),l){case 90:qt(u,s,0);break;case 180:qt(u,i,s);break;case 270:qt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+a,qt(u,Yt.x,Yt.y),r&&Nt(u,Yt,r,o)}t.transform=u}function te(t,e,i,s,n,a,r,o){r&&Vt(t,r),o&&Qt(t,o.x,o.y),n&&Ht(t,n,a),qt(t,e.x+i,e.y+s)}const{get:ee,translate:ie}=O,se=new _,ne={},ae={};function re(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=oe(i,s,e)}function oe(t,e,i){t.padding&&(e=se.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(ae,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(W.getScaleData(d,h,i,ne),x=ne.scaleX,v=ne.scaleY),(o||p||g)&&(x&&B.scale(ae,x,v,!0),o&&P.toPoint(o,ae,e,ae,!0,!0))):w&&!c||(x=v=B.getFitScale(e,ae,"fit"!==r),B.put(e,i,o,x,!1,ae),B.scale(ae,x,v,!0)),l&&M.move(ae,l),r){case"stretch":w||(x=e.width/s,v=e.height/n,Zt(y,e,x,v));break;case"normal":case"clip":if(ae.x||ae.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Jt(y,e,ae.x,ae.y,x,v,c,u,t,i),t&&(x=x?x*t:t,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&Kt(y,e,s,n,ae.x,ae.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:le(a,i,n.width,e&&e.x),y:le(r,s,n.height,e&&e.y)}}(p,i&&g,ae.width,ae.height,e));break;default:x&&$t(y,e,ae.x,ae.y,x,v,c)}return y.transform||(e.x||e.y)&&ie(y.transform=ee(),e.x,e.y),y.width=s,y.height=n,x&&(y.scaleX=x,y.scaleY=v),a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function le(t,e,i,s){const n=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let de,he=new _;const{isSame:ce}=B;function ue(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||re(n,s,i,a),!0}function fe(t,e){_e(t,D.LOAD,e)}function ge(t,e){_e(t,D.LOADED,e)}function pe(t,e,i){e.error=i,t.forceUpdate("surface"),_e(t,D.ERROR,e)}function _e(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function we(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ye,scale:me,copy:xe}=O,{floor:ve,ceil:be,max:ke,abs:Be}=Math;function Se(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=Be(f),g=Be(g),h=ye(),xe(h,p),me(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/be(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/ke(ve(t),1),a/=e/ke(ve(e),1),h||(h=ye(),p&&xe(h,p)),me(h,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=k,i.patternId=r,!0}}function Ee(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Re={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return de&&i===de.paint&&ce(s,de.boxBounds)?a=de.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),de=o.use>1?{leafPaint:a,paint:i,boxBounds:he.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ue(t,e,i,o,a,s),n&&(fe(t,r),ge(t,r))):o.error?n&&pe(t,r,o.error):(n&&(we(t,!0),fe(t,r)),a.loadId=o.load(()=>{we(t,!1),t.destroyed||(ue(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ge(t,r)),a.loadId=void 0},e=>{we(t,!1),pe(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,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?Se(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>Ee(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Se(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:Se,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.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(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:re,getPatternData:oe,stretchMode:Zt,fillOrFitMode:$t,clipMode:Jt,repeatMode:Kt},{toPoint:Le}=F,{hasTransparent:Ae}=q,Te={},Ce={};function Oe(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],T(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&Ae(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:We,getDistance:Pe}=M,{get:Me,rotateOfOuter:De,scaleOfOuter:Fe}=O,{toPoint:Ie}=F,Ye={},ze={};function Ue(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=We(e,i);a=Me(),n?(Fe(a,e,r/o*(s||1),1),De(a,e,t+90)):(Fe(a,e,1,r/o*(s||1)),De(a,e,t))}return a}const{getDistance:Ge}=M,{toPoint:Xe}=F,qe={},Ne={};const je={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;Le(s||"top",i,Te),Le(n||"bottom",i,Ce);const o=e.canvas.createLinearGradient(Te.x,Te.y,Ce.x,Ce.y),l={type:a,style:o};return Oe(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ie(s||"center",i,Ye),Ie(n||"bottom",i,ze);const l=e.canvas.createRadialGradient(Ye.x,Ye.y,0,Ye.x,Ye.y,Pe(Ye,ze)),d={type:a,style:l};Oe(d,l,t.stops,r);const h=Ue(i,Ye,ze,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Xe(s||"center",i,qe),Xe(n||"bottom",i,Ne);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,qe.x,qe.y):e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Ge(qe,Ne)),d={type:a,style:l};Oe(d,l,t.stops,r);const h=Ue(i,qe,Ne,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ue},{copy:He,move:Ve,toOffsetOutBounds:Qe}=B,{max:Ze,abs:$e}=Math,Je={},Ke=new L,ti={};function ei(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=$e(t.spread||0),r=Ze(r,n+a-s),o=Ze(o,n+a+i),l=Ze(l,n+a+s),d=Ze(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ii(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(He(Je,t.bounds),Ve(Je,i.x-n.x,i.y-n.y),a=t.bounds,r=Je):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:si}=B,ni={};const ai=ei;const ri={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Qe(l,ti,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ti.offsetX+(r.x||0)*c*w,ti.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w,q.string(r.color)),n=H.getShadowTransform(t,g,i,r,ti,w),n&&g.setTransform(n),ii(g,ti,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;si(l,ni,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ni.offsetX+(r.x||0)*c*w,ni.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w),n=H.getShadowTransform(t,g,i,r,ni,w,!0),n&&g.setTransform(n),ii(g,ni,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:ei,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Ke.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Ke}},isTransformShadow(t){},getInnerShadowSpread:ai},{excludeRenderBounds:oi}=p;let li;function di(t,e,i,s,n,a,r,o){switch(e){case"grayscale":li||(li=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);ci(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":ci(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function hi(t){return t.getSameCanvas(!1,!0)}function ci(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}V.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(di(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||oi(i,e)||i.__render(t,e),a=i.__.opacity,li=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=hi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=hi(t)),n||(n=hi(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&di(this,r,t,n,s,a,void 0,!1),oi(i,e)||i.__render(n||t,e),h&&di(this,r,t,n,s,a,h,!1)}di(this,r,t,n,s,a,void 0,!0)};const ui=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",fi=ui+"_#~&*+\\=|≮≯≈≠=…",gi=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 pi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const _i=pi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),wi=pi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),yi=pi(ui),mi=pi(fi),xi=pi("- —/~|┆·");var vi;!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"}(vi||(vi={}));const{Letter:bi,Single:ki,Before:Bi,After:Si,Symbol:Ei,Break:Ri}=vi;function Li(t){return _i[t]?bi:xi[t]?Ri:wi[t]?Bi:yi[t]?Si:mi[t]?Ei:gi.test(t)?ki:bi}const Ai={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ti(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:Ci}=Ai,{Letter:Oi,Single:Wi,Before:Pi,After:Mi,Symbol:Di,Break:Fi}=vi;let Ii,Yi,zi,Ui,Gi,Xi,qi,Ni,ji,Hi,Vi,Qi,Zi,$i,Ji,Ki,ts,es=[];function is(t,e){ji&&!Ni&&(Ni=ji),Ii.data.push({char:t,width:e}),zi+=e}function ss(){Ui+=zi,Ii.width=zi,Yi.words.push(Ii),Ii={data:[]},zi=0}function ns(){$i&&(Ji.paraNumber++,Yi.paraStart=!0,$i=!1),ji&&(Yi.startCharSize=Ni,Yi.endCharSize=ji,Ni=0),Yi.width=Ui,Ki.width?Ci(Yi):ts&&as(),es.push(Yi),Yi={words:[]},Ui=0}function as(){Ui>(Ji.maxWidth||0)&&(Ji.maxWidth=Ui)}const{top:rs,right:os,bottom:ls,left:ds}=I;function hs(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 cs={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[ds],a-=d[os]+d[ds]):i.autoSizeAlign||(s=d[ds]),r?(n=d[rs],r-=d[rs]+d[ls]):i.autoSizeAlign||(n=d[rs]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Ji=t,es=t.rows,Ki=t.bounds,ts=!Ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Ki;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;$i=!0,Vi=null,Ni=qi=ji=zi=Ui=0,Ii={data:[]},Yi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Xi=i[s],"\n"===Xi?(zi&&ss(),Yi.paraEnd=!0,ns(),$i=!0):(Hi=Li(Xi),Hi===Oi&&"none"!==r&&(Xi=Ti(Xi,r,!zi)),qi=o.measureText(Xi).width,n&&(n<0&&(ji=qi),qi+=n),Qi=Hi===Wi&&(Vi===Wi||Vi===Oi)||Vi===Wi&&Hi!==Mi,Zi=!(Hi!==Pi&&Hi!==Wi||Vi!==Di&&Vi!==Mi),Gi=$i&&a?l-a:l,t&&l&&Ui+zi+qi>Gi&&(e?(zi&&ss(),Ui&&ns()):(Zi||(Zi=Hi===Oi&&Vi==Mi),Qi||Zi||Hi===Fi||Hi===Pi||Hi===Wi||zi+qi>Gi?(zi&&ss(),Ui&&ns()):Ui&&ns()))," "===Xi&&!0!==$i&&Ui+zi===0||(Hi===Fi?(" "===Xi&&zi&&ss(),is(Xi,qi),ss()):Qi||Zi?(zi&&ss(),is(Xi,qi)):is(Xi,qi)),Vi=Hi);zi&&ss(),Ui&&ns(),es.length>0&&(es[es.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ji.paraNumber++,Ui=o.measureText(t).width,es.push({x:a||0,text:t,width:Ui,paraStart:!0}),ts&&as()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":hs(e,"x",t[ds]);break;case"right":hs(e,"x",-t[os])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":hs(e,"y",t[rs]);break;case"bottom":hs(e,"y",-t[ls])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(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,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;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,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+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)}})}}(h,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,i),h}};const us={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(T(t)){if(!i||!q.object)return t;t=q.object(t)}let s=A(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(Q,cs),Object.assign(q,us),Object.assign(X,It),Object.assign(G,Re),Object.assign(N,je),Object.assign(H,ri),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Z(t,e),hitCanvasManager:()=>new z}),J();export{ct as Layouter,Z as LeaferCanvas,pt as Picker,ft as Renderer,_t as Selector,tt as Watcher,J as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map