leafer-ui 1.11.2 → 1.12.1

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/README.md CHANGED
@@ -15,11 +15,8 @@
15
15
  如果你觉得不错,请帮我们点个 [Star](https://github.com/leaferjs/leafer-ui) 🌟 ,让这个库被更多的人看见 ✨ ✨ ✨
16
16
 
17
17
  <div style="display:flex; gap: 12px">
18
- <!-- <a href="https://gitee.com/leaferjs/leafer-ui" aria-label="gitee" target="_blank" rel="noopener" >
19
- <img width="98" titel="gitee" src="https://www.leaferjs.com/svg/gitee-stars.svg" />
20
- </a> -->
21
18
  <a target="_blank" href="https://github.com/leaferjs/leafer-ui" aria-label="github" rel="noopener">
22
- <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=0912" />
19
+ <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=1204" />
23
20
  </a>
24
21
  </div>
25
22
 
@@ -27,7 +24,7 @@
27
24
 
28
25
  [1. 准备在线 Playground 环境](https://leaferjs.com/ui/guide/runtime.html)
29
26
 
30
- 可通过 **Cloud Studio** 模版创建一个 **LeaferJS 项目**,用于运行、练习后续的示例代码。
27
+ 用于运行、练习后续的示例代码。
31
28
 
32
29
  [2. 学习 LeaferJS 快速入门教程](https://leaferjs.com/ui/guide/basic/app.html)
33
30
 
@@ -35,15 +32,9 @@
35
32
 
36
33
  ## 快速安装
37
34
 
38
- 🚀 想马上在产品中使用,请安装 [leafer-ui](https://leaferjs.com/ui/guide/install/ui/start.html)(66KB min+gzip),开始你的探索之旅。
35
+ 🚀 想马上在产品中使用,请安装 [leafer-ui](https://leaferjs.com/ui/guide/install/ui/start.html)(66KB min+gzip 零依赖),开始你的探索之旅。
39
36
 
40
- <!-- ### 场景包
41
-
42
- 高效绘图场景,推荐直接安装更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/install/draw/start.html) (50KB min+gzip)。
43
-
44
- 游戏开发场景,推荐直接安装更省心的 [leafer-game](https://leaferjs.com/ui/guide/install/game/start.html),已集成了游戏相关插件。
45
-
46
- 图形编辑场景,推荐直接安装更省心的 [leafer-editor](https://leaferjs.com/ui/guide/install/editor/start.html),已集成了图形编辑器相关插件。 -->
37
+ 也可直接安装 [leafer](https://leaferjs.com/ui/guide/install/leafer/start.md) 全量包, 会自动安装 `leafer-ui` 包和 `@leafer-in/*` 所有插件包。
47
38
 
48
39
  ## 仓库组成
49
40
 
@@ -316,7 +307,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
316
307
 
317
308
  <p><h3 align="center">铜牌赞助</h3></p>
318
309
  <p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
319
- 用户CzP9SCAz &nbsp;&nbsp;Kim &nbsp;&nbsp;用户249AzA8v &nbsp;&nbsp;l0f5c7bf &nbsp;&nbsp;夏先生 &nbsp;&nbsp;yinuo &nbsp;&nbsp;用户3wTwAz78 &nbsp;&nbsp;用户zw8T39zT &nbsp;&nbsp;用户249AzA82 &nbsp;&nbsp;用户CzP9SCvz &nbsp;&nbsp;用户39A334xT &nbsp;&nbsp;用户3wTwAz3x &nbsp;&nbsp;用户zw8T39zC &nbsp;&nbsp;稀饭、微凉 &nbsp;&nbsp;用户CzP9SCT4 &nbsp;&nbsp;便宜VPS服务器 &nbsp;&nbsp;菲鸽 &nbsp;&nbsp;szhua &nbsp;&nbsp;Cheng &nbsp;&nbsp;Suezp &nbsp;&nbsp;beyond &nbsp;&nbsp;用户3PvP2S63 &nbsp;&nbsp;o &nbsp;&nbsp;Arvin &nbsp;&nbsp;finallycc &nbsp;&nbsp;用户39A3346C &nbsp;&nbsp;大雷 &nbsp;&nbsp;用户CzP9SC4z &nbsp;&nbsp;随风 &nbsp;&nbsp;用户z89CSwT9 &nbsp;&nbsp;用户3wTwAzCx &nbsp;&nbsp;UPMuling &nbsp;&nbsp;军杨 &nbsp;&nbsp;桔子雨工作室 &nbsp;&nbsp;用户zw8T37xC &nbsp;&nbsp;前端炒饭仔 &nbsp;&nbsp;用户z89CSw46 &nbsp;&nbsp;崮生 &nbsp;&nbsp;互动矩阵 &nbsp;&nbsp;ZhanYoHo &nbsp;&nbsp;何佳Q &nbsp;&nbsp;coderhyh &nbsp;&nbsp;早上好啊 &nbsp;&nbsp;快图设计 &nbsp;&nbsp;do &nbsp;&nbsp;毛哥哥 &nbsp;&nbsp;迅排设计 &nbsp;&nbsp;用户z89CSw86 &nbsp;&nbsp;糖果 &nbsp;&nbsp;南城以北 &nbsp;&nbsp;黑色摩天仑 &nbsp;&nbsp;Charm &nbsp;&nbsp;Lauginwing &nbsp;&nbsp;在路上 &nbsp;&nbsp;Jerry &nbsp;&nbsp;张余🌈 &nbsp;&nbsp;李狗嗨。💢 &nbsp;&nbsp;用户zw8T376T &nbsp;&nbsp;用户249AzA2v &nbsp;&nbsp;ʚ LMT ɞ &nbsp;&nbsp;格子 &nbsp;&nbsp;等等 &nbsp;&nbsp;goosen &nbsp;&nbsp;F4nniu &nbsp;&nbsp;梁福斌 &nbsp;&nbsp;江万江 &nbsp;&nbsp;杨超 &nbsp;&nbsp;ToB Dev &nbsp;&nbsp;前端之虎陈随易 &nbsp;&nbsp;A☀️云☀️A &nbsp;&nbsp;zhk &nbsp;&nbsp;爱发电用户_c9c82 &nbsp;&nbsp;轻简历 &nbsp;&nbsp;爱发电用户_0fac0 &nbsp;&nbsp;wangyesheji.cn &nbsp;&nbsp;风间 &nbsp;&nbsp;爱发电用户_Tqsm &nbsp;&nbsp;爱发电用户_6KpE &nbsp;&nbsp;星小志 &nbsp;&nbsp;zwm &nbsp;&nbsp;爱发电用户_3725c &nbsp;&nbsp;Noth1ng &nbsp;&nbsp;纳西妲の√ &nbsp;&nbsp;爱发电用户_Ahb9 &nbsp;&nbsp;爱发电用户_7617d &nbsp;&nbsp;冷漠 &nbsp;&nbsp;爱发电用户_9RXB &nbsp;&nbsp;今日值得读 &nbsp;&nbsp;爱发电用户_49sT &nbsp;&nbsp;爱发电用户_NFCS &nbsp;&nbsp;爱发电用户_43ad8 &nbsp;&nbsp;爱发电用户_30455 &nbsp;&nbsp;砖吐筷筷 &nbsp;&nbsp;xiaozhang &nbsp;&nbsp;爱发电用户_b47b3 &nbsp;&nbsp;longbow1998 &nbsp;&nbsp;爱发电用户_5d755 &nbsp;&nbsp;爱发电用户_b76b8 &nbsp;&nbsp;爱发电用户_e70c2 &nbsp;&nbsp;xiaou@截图工具 &nbsp;&nbsp;ousiri &nbsp;&nbsp;爱发电用户_039dc &nbsp;&nbsp;花祁 &nbsp;&nbsp;爱发电用户_99f39 &nbsp;&nbsp;坤坤 &nbsp;&nbsp;爱发电用户_X6hp &nbsp;&nbsp;ycteng &nbsp;&nbsp;曹吉美爸爸 &nbsp;&nbsp;啸沧海 &nbsp;&nbsp;Ronny &nbsp;&nbsp;爱发电用户_UXEV &nbsp;&nbsp;Biu &nbsp;&nbsp;王志强 &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;爱发电用户_76f9d &nbsp;&nbsp;PD.新城คิดถึง &nbsp;&nbsp;糖颂缘冥倾 &nbsp;&nbsp;ALBERT. &nbsp;&nbsp;爱发电用户_Pbm7 &nbsp;&nbsp;Leafer &nbsp;&nbsp;</p>
310
+ 用户z89CSw69 &nbsp;&nbsp;用户CzP9SCAz &nbsp;&nbsp;Kim &nbsp;&nbsp;用户249AzA8v &nbsp;&nbsp;l0f5c7bf &nbsp;&nbsp;夏先生 &nbsp;&nbsp;yinuo &nbsp;&nbsp;用户3wTwAz78 &nbsp;&nbsp;用户zw8T39zT &nbsp;&nbsp;用户249AzA82 &nbsp;&nbsp;用户CzP9SCvz &nbsp;&nbsp;用户39A334xT &nbsp;&nbsp;用户3wTwAz3x &nbsp;&nbsp;用户zw8T39zC &nbsp;&nbsp;稀饭、微凉 &nbsp;&nbsp;用户CzP9SCT4 &nbsp;&nbsp;便宜VPS服务器 &nbsp;&nbsp;菲鸽 &nbsp;&nbsp;szhua &nbsp;&nbsp;Cheng &nbsp;&nbsp;Suezp &nbsp;&nbsp;beyond &nbsp;&nbsp;用户3PvP2S63 &nbsp;&nbsp;o &nbsp;&nbsp;Arvin &nbsp;&nbsp;finallycc &nbsp;&nbsp;用户39A3346C &nbsp;&nbsp;大雷 &nbsp;&nbsp;用户CzP9SC4z &nbsp;&nbsp;随风 &nbsp;&nbsp;用户z89CSwT9 &nbsp;&nbsp;用户3wTwAzCx &nbsp;&nbsp;UPMuling &nbsp;&nbsp;军杨 &nbsp;&nbsp;桔子雨工作室 &nbsp;&nbsp;用户zw8T37xC &nbsp;&nbsp;前端炒饭仔 &nbsp;&nbsp;用户z89CSw46 &nbsp;&nbsp;崮生 &nbsp;&nbsp;互动矩阵 &nbsp;&nbsp;ZhanYoHo &nbsp;&nbsp;何佳Q &nbsp;&nbsp;coderhyh &nbsp;&nbsp;早上好啊 &nbsp;&nbsp;快图设计 &nbsp;&nbsp;do &nbsp;&nbsp;毛哥哥 &nbsp;&nbsp;迅排设计 &nbsp;&nbsp;用户z89CSw86 &nbsp;&nbsp;糖果 &nbsp;&nbsp;南城以北 &nbsp;&nbsp;黑色摩天仑 &nbsp;&nbsp;Charm &nbsp;&nbsp;Lauginwing &nbsp;&nbsp;在路上 &nbsp;&nbsp;Jerry &nbsp;&nbsp;张余🌈 &nbsp;&nbsp;李狗嗨。💢 &nbsp;&nbsp;用户zw8T376T &nbsp;&nbsp;用户249AzA2v &nbsp;&nbsp;ʚ LMT ɞ &nbsp;&nbsp;格子 &nbsp;&nbsp;等等 &nbsp;&nbsp;goosen &nbsp;&nbsp;F4nniu &nbsp;&nbsp;梁福斌 &nbsp;&nbsp;江万江 &nbsp;&nbsp;杨超 &nbsp;&nbsp;ToB Dev &nbsp;&nbsp;前端之虎陈随易 &nbsp;&nbsp;A☀️云☀️A &nbsp;&nbsp;zhk &nbsp;&nbsp;爱发电用户_c9c82 &nbsp;&nbsp;轻简历 &nbsp;&nbsp;爱发电用户_0fac0 &nbsp;&nbsp;wangyesheji.cn &nbsp;&nbsp;风间 &nbsp;&nbsp;爱发电用户_Tqsm &nbsp;&nbsp;爱发电用户_6KpE &nbsp;&nbsp;星小志 &nbsp;&nbsp;zwm &nbsp;&nbsp;爱发电用户_3725c &nbsp;&nbsp;Noth1ng &nbsp;&nbsp;纳西妲の√ &nbsp;&nbsp;爱发电用户_Ahb9 &nbsp;&nbsp;爱发电用户_7617d &nbsp;&nbsp;冷漠 &nbsp;&nbsp;爱发电用户_9RXB &nbsp;&nbsp;今日值得读 &nbsp;&nbsp;爱发电用户_49sT &nbsp;&nbsp;爱发电用户_NFCS &nbsp;&nbsp;爱发电用户_43ad8 &nbsp;&nbsp;爱发电用户_30455 &nbsp;&nbsp;砖吐筷筷 &nbsp;&nbsp;xiaozhang &nbsp;&nbsp;爱发电用户_b47b3 &nbsp;&nbsp;longbow1998 &nbsp;&nbsp;爱发电用户_5d755 &nbsp;&nbsp;爱发电用户_b76b8 &nbsp;&nbsp;爱发电用户_e70c2 &nbsp;&nbsp;xiaou@截图工具 &nbsp;&nbsp;ousiri &nbsp;&nbsp;爱发电用户_039dc &nbsp;&nbsp;花祁 &nbsp;&nbsp;爱发电用户_99f39 &nbsp;&nbsp;坤坤 &nbsp;&nbsp;爱发电用户_X6hp &nbsp;&nbsp;ycteng &nbsp;&nbsp;曹吉美爸爸 &nbsp;&nbsp;啸沧海 &nbsp;&nbsp;Ronny &nbsp;&nbsp;爱发电用户_UXEV &nbsp;&nbsp;Biu &nbsp;&nbsp;王志强 &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;爱发电用户_76f9d &nbsp;&nbsp;PD.新城คิดถึง &nbsp;&nbsp;糖颂缘冥倾 &nbsp;&nbsp;ALBERT. &nbsp;&nbsp;爱发电用户_Pbm7 &nbsp;&nbsp;Leafer &nbsp;&nbsp;</p>
320
311
 
321
312
  ## License
322
313
 
package/dist/web.cjs CHANGED
@@ -336,7 +336,7 @@ class Watcher {
336
336
  return this.hasAdd || this.hasRemove || this.hasVisible;
337
337
  }
338
338
  get updatedList() {
339
- if (this.hasRemove) {
339
+ if (this.hasRemove && this.config.usePartLayout) {
340
340
  const updatedList = new core.LeafList;
341
341
  this.__updatedList.list.forEach(item => {
342
342
  if (item.leafer) updatedList.add(item);
@@ -371,16 +371,18 @@ class Watcher {
371
371
  if (this.running) this.target.emit(core.RenderEvent.REQUEST);
372
372
  }
373
373
  __onAttrChange(event) {
374
- this.__updatedList.add(event.target);
374
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
375
375
  this.update();
376
376
  }
377
377
  __onChildEvent(event) {
378
- if (event.type === core.ChildEvent.ADD) {
379
- this.hasAdd = true;
380
- this.__pushChild(event.child);
381
- } else {
382
- this.hasRemove = true;
383
- this.__updatedList.add(event.parent);
378
+ if (this.config.usePartLayout) {
379
+ if (event.type === core.ChildEvent.ADD) {
380
+ this.hasAdd = true;
381
+ this.__pushChild(event.child);
382
+ } else {
383
+ this.hasRemove = true;
384
+ this.__updatedList.add(event.parent);
385
+ }
384
386
  }
385
387
  this.update();
386
388
  }
@@ -497,7 +499,9 @@ const debug$1 = core.Debug.get("Layouter");
497
499
  class Layouter {
498
500
  constructor(target, userConfig) {
499
501
  this.totalTimes = 0;
500
- this.config = {};
502
+ this.config = {
503
+ usePartLayout: true
504
+ };
501
505
  this.__levelList = new core.LeafLevelList;
502
506
  this.target = target;
503
507
  if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
@@ -542,7 +546,7 @@ class Layouter {
542
546
  this.totalTimes++;
543
547
  this.layouting = true;
544
548
  this.target.emit(core.WatchEvent.REQUEST);
545
- if (this.totalTimes > 1) {
549
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
546
550
  this.partLayout();
547
551
  } else {
548
552
  this.fullLayout();
@@ -659,7 +663,7 @@ class Renderer {
659
663
  }
660
664
  update(change = true) {
661
665
  if (!this.changed) this.changed = change;
662
- this.__requestRender();
666
+ if (!this.requestTime) this.__requestRender();
663
667
  }
664
668
  requestLayout() {
665
669
  this.target.emit(core.LayoutEvent.REQUEST);
@@ -766,7 +770,7 @@ class Renderer {
766
770
  core.Run.end(t);
767
771
  }
768
772
  __render(bounds, realBounds) {
769
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
773
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
770
774
  includes: includes
771
775
  } : {
772
776
  bounds: bounds,
@@ -774,12 +778,16 @@ class Renderer {
774
778
  };
775
779
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
776
780
  if (core.Debug.showRepaint) core.Debug.drawRepaint(canvas, bounds);
777
- core.Platform.render(this.target, canvas, options);
781
+ if (this.config.useCellRender) options.cellList = this.getCellList();
782
+ core.Platform.render(target, canvas, options);
778
783
  this.renderBounds = realBounds = realBounds || bounds;
779
784
  this.renderOptions = options;
780
785
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
781
786
  canvas.updateRender(realBounds);
782
787
  }
788
+ getCellList() {
789
+ return undefined;
790
+ }
783
791
  addBlock(block) {
784
792
  if (!this.updateBlocks) this.updateBlocks = [];
785
793
  this.updateBlocks.push(block);
@@ -994,7 +1002,7 @@ class Picker {
994
1002
  hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point);
995
1003
  if (child.isBranch) {
996
1004
  if (hit || child.__ignoreHitWorld) {
997
- if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
1005
+ if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point, true)) continue;
998
1006
  if (child.topChildren) this.eachFind(child.topChildren, false);
999
1007
  this.eachFind(child.children, child.__onlyHitMask);
1000
1008
  if (child.isBranchLeaf) this.hitChild(child, point);
@@ -1703,6 +1711,7 @@ function getLeafPaint(attrName, paint, ui) {
1703
1711
  const {boxBounds: boxBounds} = ui.__layout;
1704
1712
  switch (paint.type) {
1705
1713
  case "image":
1714
+ if (!paint.url) return undefined;
1706
1715
  leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1707
1716
  break;
1708
1717
 
@@ -2140,7 +2149,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
2140
2149
  if (data.repeat) {
2141
2150
  drawImage = false;
2142
2151
  } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
2143
- drawImage = core.Platform.image.isLarge(image, scaleX, scaleY);
2152
+ drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
2144
2153
  }
2145
2154
  }
2146
2155
  if (drawImage) {
@@ -2199,7 +2208,7 @@ function recycleImage(attrName, data) {
2199
2208
  if (url) {
2200
2209
  if (!recycleMap) recycleMap = {};
2201
2210
  recycleMap[url] = true;
2202
- core.ImageManager.recycle(image);
2211
+ core.ImageManager.recyclePaint(paint);
2203
2212
  if (image.loading) {
2204
2213
  if (!input) {
2205
2214
  input = data.__input && data.__input[attrName] || [];
package/dist/web.esm.js CHANGED
@@ -340,7 +340,7 @@ class Watcher {
340
340
  return this.hasAdd || this.hasRemove || this.hasVisible;
341
341
  }
342
342
  get updatedList() {
343
- if (this.hasRemove) {
343
+ if (this.hasRemove && this.config.usePartLayout) {
344
344
  const updatedList = new LeafList;
345
345
  this.__updatedList.list.forEach(item => {
346
346
  if (item.leafer) updatedList.add(item);
@@ -375,16 +375,18 @@ class Watcher {
375
375
  if (this.running) this.target.emit(RenderEvent.REQUEST);
376
376
  }
377
377
  __onAttrChange(event) {
378
- this.__updatedList.add(event.target);
378
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
379
379
  this.update();
380
380
  }
381
381
  __onChildEvent(event) {
382
- if (event.type === ChildEvent.ADD) {
383
- this.hasAdd = true;
384
- this.__pushChild(event.child);
385
- } else {
386
- this.hasRemove = true;
387
- this.__updatedList.add(event.parent);
382
+ if (this.config.usePartLayout) {
383
+ if (event.type === ChildEvent.ADD) {
384
+ this.hasAdd = true;
385
+ this.__pushChild(event.child);
386
+ } else {
387
+ this.hasRemove = true;
388
+ this.__updatedList.add(event.parent);
389
+ }
388
390
  }
389
391
  this.update();
390
392
  }
@@ -501,7 +503,9 @@ const debug$1 = Debug.get("Layouter");
501
503
  class Layouter {
502
504
  constructor(target, userConfig) {
503
505
  this.totalTimes = 0;
504
- this.config = {};
506
+ this.config = {
507
+ usePartLayout: true
508
+ };
505
509
  this.__levelList = new LeafLevelList;
506
510
  this.target = target;
507
511
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -546,7 +550,7 @@ class Layouter {
546
550
  this.totalTimes++;
547
551
  this.layouting = true;
548
552
  this.target.emit(WatchEvent.REQUEST);
549
- if (this.totalTimes > 1) {
553
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
550
554
  this.partLayout();
551
555
  } else {
552
556
  this.fullLayout();
@@ -663,7 +667,7 @@ class Renderer {
663
667
  }
664
668
  update(change = true) {
665
669
  if (!this.changed) this.changed = change;
666
- this.__requestRender();
670
+ if (!this.requestTime) this.__requestRender();
667
671
  }
668
672
  requestLayout() {
669
673
  this.target.emit(LayoutEvent.REQUEST);
@@ -770,7 +774,7 @@ class Renderer {
770
774
  Run.end(t);
771
775
  }
772
776
  __render(bounds, realBounds) {
773
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
777
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
774
778
  includes: includes
775
779
  } : {
776
780
  bounds: bounds,
@@ -778,12 +782,16 @@ class Renderer {
778
782
  };
779
783
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
780
784
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
781
- Platform.render(this.target, canvas, options);
785
+ if (this.config.useCellRender) options.cellList = this.getCellList();
786
+ Platform.render(target, canvas, options);
782
787
  this.renderBounds = realBounds = realBounds || bounds;
783
788
  this.renderOptions = options;
784
789
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
785
790
  canvas.updateRender(realBounds);
786
791
  }
792
+ getCellList() {
793
+ return undefined;
794
+ }
787
795
  addBlock(block) {
788
796
  if (!this.updateBlocks) this.updateBlocks = [];
789
797
  this.updateBlocks.push(block);
@@ -998,7 +1006,7 @@ class Picker {
998
1006
  hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point);
999
1007
  if (child.isBranch) {
1000
1008
  if (hit || child.__ignoreHitWorld) {
1001
- if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point)) continue;
1009
+ if (child.isBranchLeaf && child.__.__clipAfterFill && !child.__hitWorld(point, true)) continue;
1002
1010
  if (child.topChildren) this.eachFind(child.topChildren, false);
1003
1011
  this.eachFind(child.children, child.__onlyHitMask);
1004
1012
  if (child.isBranchLeaf) this.hitChild(child, point);
@@ -1707,6 +1715,7 @@ function getLeafPaint(attrName, paint, ui) {
1707
1715
  const {boxBounds: boxBounds} = ui.__layout;
1708
1716
  switch (paint.type) {
1709
1717
  case "image":
1718
+ if (!paint.url) return undefined;
1710
1719
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1711
1720
  break;
1712
1721
 
@@ -2144,7 +2153,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
2144
2153
  if (data.repeat) {
2145
2154
  drawImage = false;
2146
2155
  } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
2147
- drawImage = Platform.image.isLarge(image, scaleX, scaleY);
2156
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
2148
2157
  }
2149
2158
  }
2150
2159
  if (drawImage) {
@@ -2203,7 +2212,7 @@ function recycleImage(attrName, data) {
2203
2212
  if (url) {
2204
2213
  if (!recycleMap) recycleMap = {};
2205
2214
  recycleMap[url] = true;
2206
- ImageManager.recycle(image);
2215
+ ImageManager.recyclePaint(paint);
2207
2216
  if (image.loading) {
2208
2217
  if (!input) {
2209
2218
  input = data.__input && data.__input[attrName] || [];
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as S,LayoutEvent as k,Run as B,ImageManager as T,BoundsHelper as L,Plugin as E,MathHelper as R,isObject as P,FourNumberHelper as M,Matrix as C,ImageEvent as A,MatrixHelper as O,AlignHelper as D,PointHelper as W,getMatrixData as I,AroundHelper as F,Direction4 as z,isNumber as j}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as G,Cursor as Y,HitCanvasManager as X}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as V,PaintImage as H,ColorConvert as N,PaintGradient as q,Effect as K,Group as Q,TextConvert as $}from"@leafer-ui/draw";var Z;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(Z||(Z={}));const J=t.get("LeaferCanvas");class tt extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else J.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),J.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:et,fileType:it}=l;function st(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=et(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,et(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(et(it(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new tt(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),nt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?i.os="Mac":nt.indexOf("Linux")>-1&&(i.os="Linux");class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=o.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(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:at,updateChange:ht}=m,{pushAllChildBranch:lt,pushAllParent:ct}=v;const{worldBounds:dt}=y;class ut{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dt),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:ft,updateAllChange:pt}=m,gt=t.get("Layouter");class _t{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new S,this.target=t,e&&(this.config=o.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(k.START),this.layoutOnce(),t.emitEvent(new k(k.END,this.layoutedBlocks,this.times))}catch(t){gt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gt.warn("layouting"):this.times>3?gt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=B.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=k,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new k(n,a,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?(rt(t,!0),e.add(t),t.isBranch&&lt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new k(o,a,this.times)),i.emitEvent(new k(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,B.end(e)}fullLayout(){const t=B.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=k,o=this.getBlocks(new f(e));e.emitEvent(new k(i,o,this.times)),_t.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new k(s,o,this.times)),e.emitEvent(new k(n,o,this.times)),this.addBlocks(o),B.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?v.updateBounds(t):m.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(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_([[k.REQUEST,this.layout,this],[k.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const wt=t.get("Renderer");class mt{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=o.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(k.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,wt.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),T.clearRecycled()}catch(t){this.rendering=!1,wt.error(t)}wt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return wt.warn("rendering");if(this.times>3)return wt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=B.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),B.end(e)}fullRender(){const t=B.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),B.end(t)}__render(e,s){const{canvas:n}=this,o=e.includes(this.target.__world),r=o?{includes:o}:{bounds:e,includes:o};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),i.render(this.target,n,r),this.renderBounds=s=s||e,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||wt.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 p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[k.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}mt.clipSpread=10;const{hitRadiusPoint:vt}=L;class yt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new f;if(t.length){let e;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=t.length;s<o;s++)if(e=t[s],(i||m.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],i.__.visible&&(!e||i.__.mask))if(s=!!i.__.hitRadius||vt(i.__world,n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&i.__.__clipAfterFill&&!i.__hitWorld(n))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else 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:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[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 xt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):E.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new xt(t,e)}),i.layout=_t.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convert(t,e){const i=U.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=U.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=bt.getTouch(t),s=U.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},St={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:kt}=U;class Bt extends G{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(St.convert(t))}onKeyUp(t){this.keyUp(St.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(bt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(bt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=bt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(bt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(bt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(bt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(bt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=bt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&kt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(bt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=bt.getTouch(t);this.pointerUp(bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(U.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&Y.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Tt(t,e,i){t.__.__font?V.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Lt(t,e,i,s,n){const o=i.__;P(t)?V.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&V.strokeArrow(t,i,s,n)}function Et(t,e,i,s,n){const o=i.__;P(t)?V.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),V.drawTextStroke(i,s,n))}function Rt(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Et(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",V.fillText(i,o,n),o.blendMode="normal",m.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}const{getSpread:Pt,copyAndSpread:Mt,toOuterOf:Ct,getOuterOf:At,getByMove:Ot,move:Dt,getIntersectData:Wt}=L,It={};let Ft;const{stintSet:zt}=o,{hasTransparent:jt}=N;function Ut(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":o=H.image(i,t,e,r,!Ft||!Ft[e.url]);break;case"linear":o=q.linearGradient(e,r);break;case"radial":o=q.radialGradient(e,r);break;case"angular":o=q.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:N.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:N.string(e)})}if(o&&(o.originPaint=e,s(o.style)&&jt(o.style)&&(o.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}return o}const Gt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),Ft=H.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ut(t,a[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),o=!0),"fill"===t?(zt(i,"__isAlphaPixelFill",n),zt(i,"__isTransparentFill",o)):(zt(i,"__isAlphaPixelStroke",n),zt(i,"__isTransparentStroke",o),zt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Tt(e,i,s)},fills:function(t,e,i,s){let n,o,r;for(let a=0,h=t.length;a<h;a++){if(n=t[a],o=n.originPaint,n.image){if(r?r++:r=1,H.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||o.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===o.scaleFixed||"zoom-in"===o.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}o.blendMode&&(i.blendMode=o.blendMode),Tt(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Tt(e,i,s),i.restoreBlendMode()):Tt(e,i,s)}},fillPathOrText:Tt,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:o}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)V.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Lt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Lt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)Lt(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Lt(t,2,e,r,s),r.clipUI(n),r.clearWorld(o),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){V.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Et(t,1,e,i,s);break;case"inside":Rt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Et(t,2,e,i,s):Rt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:o,decorationY:r}=n;for(let t=0,i=o.length;t<i;t++)s=o[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;o.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,o){let r;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,c=t.length;l<c;l++)if(r=t[l],(!r.image||!H.checkImage(r,!1,s,n,o))&&r.style){if(h){const{strokeStyle:t}=r;t?n.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(r.style,a.__strokeWidth*e,a)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?V.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?V.drawTextStroke(s,n,o):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),o=e.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,p;Ct(a.strokeSpread?(Mt(It,a.boxBounds,a.strokeSpread),It):a.boxBounds,r,h);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(o.includes(h))p=n,l=f=h,c=r;else{let n;if(i.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Pt(o,M.swapAndScale(a.renderShapeSpread,g,_)):o;n=Wt(t,h)}u=o.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=At(h,u),l=Ot(f,-u.e,-u.f),c=At(r,u),Dt(c,-u.e,-u.f);const v=s.matrix;v?(d=new C(u),d.multiply(v),w*=v.scaleX,m*=v.scaleY):d=u,d.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Yt,Xt=new x;const{isSame:Vt}=L;function Ht(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||H.createData(n,s,i,o),!0}function Nt(t,e){Qt(t,A.LOAD,e)}function qt(t,e){Qt(t,A.LOADED,e)}function Kt(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,A.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,translate:Jt}=O,te=new x,ee={},ie={};function se(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let ne={},oe=I();const{get:re,set:ae,rotateOfOuter:he,translate:le,scaleOfOuter:ce,multiplyParent:de,scale:ue,rotate:fe,skew:pe}=O;function ge(t,e,i,s,n,o,r,a){r&&fe(t,r),a&&pe(t,a.x,a.y),n&&ue(t,n,o),le(t,e.x+i,e.y+s)}function _e(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:we,scale:me,copy:ve}=O,{getFloorScale:ye}=R,{abs:xe}=Math;const be={image:function(t,e,i,s,n){let o,r;const a=T.get(i);return Yt&&i===Yt.paint&&Vt(s,Yt.boxBounds)?o=Yt.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Yt=a.use>1?{leafPaint:o,paint:i,boxBounds:Xt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Ht(t,e,i,a,o,s),n&&(Nt(t,r),qt(t,r))):a.error?n&&Kt(t,r,a.error):(n&&($t(t,!0),Nt(t,r)),o.loadId=a.load(()=>{$t(t,!1),t.destroyed||(Ht(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),qt(t,r)),o.loadId=void 0},e=>{$t(t,!1),Kt(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n,o){const{scaleX:r,scaleY:h}=H.getImageRenderScaleData(t,s,n,o),{image:l,data:c,originPaint:d}=t,{exporting:u}=o;return!(!c||t.patternId===r+"-"+h&&!u)&&(e&&(c.repeat?e=!1:d.changeful||"miniapp"===i.name&&a.isResizing(s)||u||(e=i.image.isLarge(l,r,h))),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),H.drawImage(t,r,h,s,n,o),!0):(!t.style||d.sync||u?H.createPattern(t,s,n,o):H.createPatternTask(t,s,n,o),!1))},drawImage:function(t,e,i,s,n,o){const{data:r,image:a}=t,{blendMode:h}=t.originPaint,{opacity:l,transform:c}=r,d=a.getFull(r.filters),u=s.__;let f,{width:p,height:g}=a;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),f&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),c&&n.transform(c),n.drawImage(d,0,0,p,g),n.restore()):(r.scaleX&&(p*=r.scaleX,g*=r.scaleY),n.drawImage(d,0,0,p,g))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return o&&o.scaleX&&(n.scaleX*=Math.abs(o.scaleX),n.scaleY*=Math.abs(o.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,T.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=T.patternTasker.add(()=>_e(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&H.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,s,n){let{scaleX:o,scaleY:r}=H.getImageRenderScaleData(t,e,s,n),a=o+"-"+r;if(t.patternId!==a&&!e.destroyed&&(!i.image.isLarge(t.image,o,r)||t.data.repeat)){const{image:s,data:n}=t,{transform:h,gap:l}=n,c=H.getPatternFixScale(t,o,r);let d,u,f,{width:p,height:g}=s;c&&(o*=c,r*=c),p*=o,g*=r,l&&(u=l.x*o/xe(n.scaleX||1),f=l.y*r/xe(n.scaleY||1)),(h||1!==o||1!==r)&&(o*=ye(p+(u||0)),r*=ye(g+(f||0)),d=we(),h&&ve(d,h),me(d,1/o,1/r));const _=s.getCanvas(p,g,n.opacity,n.filters,u,f,e.leafer&&e.leafer.config.smooth),w=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",d,t);t.style=w,t.patternId=a}},getPatternFixScale:function(t,e,s){const{image:n}=t;let o,r=i.image.maxPatternSize,a=n.width*n.height;return n.isSVG?e>1&&(o=Math.ceil(e)/e):r>a&&(r=a),(a*=e*s)>r&&(o=Math.sqrt(r/a)),o},createData:function(t,e,i,s){t.data=H.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=te.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:o}=i,{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=e.width===n&&e.height===o,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(L.set(ie,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,ee),x=ee.scaleX,b=ee.scaleY),(h||_||g)&&(x&&L.scale(ie,x,b,!0),h&&D.toPoint(h,ie,e,ie,!0,!0))):m&&!u||(x=b=L.getFitScale(e,ie,"fit"!==a),L.put(e,i,h,x,!1,ie),L.scale(ie,x,b,!0)),l&&W.move(ie,l),a){case"stretch":m?x&&(x=b=void 0):(x=e.width/n,b=e.height/o,H.stretchMode(v,e,x,b));break;case"normal":case"clip":if(ie.x||ie.y||x||p||u||f){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),H.clipMode(v,e,ie.x,ie.y,x,b,u,f,t,i),t&&(x=x?x*t:t,b=b?b*i:i)}break;case"repeat":(!m||x||u||f)&&H.repeatMode(v,e,n,o,ie.x,ie.y,x,b,u,f,h,t.freeTransform),g||(v.repeat="repeat");const i=P(g);(_||i)&&(v.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:se(o,i,n.width,e&&e.x),y:se(r,s,n.height,e&&e.y)}}(_,i&&g,ie.width,ie.height,e));break;default:x&&H.fillOrFitMode(v,e,ie.x,ie.y,x,b,u)}return v.transform||(e.x||e.y)&&Jt(v.transform=Zt(),e.x,e.y),x&&(v.scaleX=x,v.scaleY=b),r&&r<1&&(v.opacity=r),w&&(v.filters=w),g&&(v.repeat=s(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,i,s){const n=re(),{x:o,y:r}=e;o||r?le(n,o,r):n.onlyScale=!0,ue(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=re();le(a,e.x+i,e.y+s),ue(a,n,o),r&&he(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,s,n,o,r,a,h,l){const c=re();ge(c,e,i,s,n,o,r,a),h&&(r||a?(ae(oe),ce(oe,e,h,l),de(c,oe)):ce(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,s,n,o,r,a,h,l,c,d){const u=re();if(d)ge(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)he(u,{x:i/2,y:s/2},h);else switch(fe(u,h),h){case 90:le(u,s,0);break;case 180:le(u,i,s);break;case 270:le(u,0,i)}ne.x=e.x+n,ne.y=e.y+o,le(u,ne.x,ne.y),r&&ce(u,ne,r,a)}t.transform=u}},{toPoint:Se}=F,{hasTransparent:ke}=N,Be={},Te={};function Le(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&ke(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Ee,getDistance:Re}=W,{get:Pe,rotateOfOuter:Me,scaleOfOuter:Ce}=O,{toPoint:Ae}=F,Oe={},De={};function We(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Ee(e,i);o=Pe(),n?(Ce(o,e,r/a*(s||1),1),Me(o,e,t+90)):(Ce(o,e,1,r/a*(s||1)),Me(o,e,t))}return o}const{getDistance:Ie}=W,{toPoint:Fe}=F,ze={},je={};const Ue={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Se(s||"top",e,Be),Se(n||"bottom",e,Te);const a=i.canvas.createLinearGradient(Be.x,Be.y,Te.x,Te.y),h={type:o,style:a};return Le(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Ae(s||"center",e,Oe),Ae(n||"bottom",e,De);const h=i.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Re(Oe,De)),l={type:o,style:h};Le(l,h,t.stops,r);const c=We(e,Oe,De,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Fe(s||"center",e,ze),Fe(n||"bottom",e,je);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,ze.x,ze.y):i.canvas.createRadialGradient(ze.x,ze.y,0,ze.x,ze.y,Ie(ze,je)),l={type:o,style:h};Le(l,h,t.stops,r);const c=We(e,ze,je,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:We},{copy:Ge,move:Ye,toOffsetOutBounds:Xe}=L,{max:Ve,abs:He}=Math,Ne={},qe=new C,Ke={};function Qe(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,o=1.5*(t.blur||0),n=He(t.spread||0),r=Ve(r,n+o-s),a=Ve(a,n+o+i),h=Ve(h,n+o+s),l=Ve(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function $e(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(Ge(Ne,t.bounds),Ye(Ne,e.x-n.x,e.y-n.y),o=t.bounds,r=Ne):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:Ze}=L,Je={};const ti=Qe;const ei={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Xe(h,Ke,l),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ke.offsetX+(r.x||0)*d*_,Ke.offsetY+(r.y||0)*u*_,(r.blur||0)*d*_,N.string(r.color)),n=K.getShadowTransform(t,f,i,r,Ke,_),n&&f.setTransform(n),$e(f,Ke,i),n&&f.resetTransform(),s=l,r.box&&(f.restore(),f.save(),a&&(f.copyWorld(f,l,o,"copy"),s=o),a?f.copyWorld(a,o,o,"destination-out"):f.copyWorld(i.canvas,c,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ze(h,Je,l),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Je.offsetX+(r.x||0)*d*_,Je.offsetY+(r.y||0)*u*_,(r.blur||0)*d*_),n=K.getShadowTransform(t,f,i,r,Je,_,!0),n&&f.setTransform(n),$e(f,Je,i),f.restore(),a?(f.copyWorld(f,l,o,"copy"),f.copyWorld(a,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,h,"source-out"),s=l),f.fillWorld(s,N.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=2*s.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return qe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),qe}},isTransformShadow(t){},getInnerShadowSpread:ti},{excludeRenderBounds:ii}=y;let si;function ni(t,e,i,s,n,o,r,a){switch(e){case"grayscale":si||(si=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);ri(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ri(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}Q.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(ni(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||ii(i,e)||i.__render(t,e),o=i.__.opacity,si=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&ni(this,r,t,n,s,o,void 0,!1),ii(i,e)||i.__render(n||t,e),c&&ni(this,r,t,n,s,o,c,!1)}ni(this,r,t,n,s,o,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=ai+"_#~&*+\\=|≮≯≈≠=…",li=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const di=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ui=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fi=ci(ai),pi=ci(hi),gi=ci("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:wi,Single:mi,Before:vi,After:yi,Symbol:xi,Break:bi}=_i;function Si(t){return di[t]?wi:gi[t]?bi:ui[t]?vi:fi[t]?yi:pi[t]?xi:li.test(t)?mi:wi}const ki={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Bi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ti}=ki,{Letter:Li,Single:Ei,Before:Ri,After:Pi,Symbol:Mi,Break:Ci}=_i;let Ai,Oi,Di,Wi,Ii,Fi,zi,ji,Ui,Gi,Yi,Xi,Vi,Hi,Ni,qi,Ki,Qi=[];function $i(t,e){Ui&&!ji&&(ji=Ui),Ai.data.push({char:t,width:e}),Di+=e}function Zi(){Wi+=Di,Ai.width=Di,Oi.words.push(Ai),Ai={data:[]},Di=0}function Ji(){Hi&&(Ni.paraNumber++,Oi.paraStart=!0,Hi=!1),Ui&&(Oi.startCharSize=ji,Oi.endCharSize=Ui,ji=0),Oi.width=Wi,qi.width?Ti(Oi):Ki&&ts(),Qi.push(Oi),Oi={words:[]},Wi=0}function ts(){Wi>(Ni.maxWidth||0)&&(Ni.maxWidth=Wi)}const{top:es,right:is,bottom:ss,left:ns}=z;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 rs={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{__padding:h}=e;h&&(r?(n=h[ns],r-=h[is]+h[ns],!r&&(r=.01)):e.autoSizeAlign||(n=h[ns]),a?(o=h[es],a-=h[es]+h[ss],!a&&(a=.01)):e.autoSizeAlign||(o=h[es]));const l={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=e.__font};return function(t,e,s){Ni=t,Qi=t.rows,qi=t.bounds,Ki=!qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h}=qi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Hi=!0,Yi=null,ji=zi=Ui=Di=Wi=0,Ai={data:[]},Oi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Fi=e[s],"\n"===Fi?(Di&&Zi(),Oi.paraEnd=!0,Ji(),Hi=!0):(Gi=Si(Fi),Gi===Li&&"none"!==r&&(Fi=Bi(Fi,r,!Di)),zi=a.measureText(Fi).width,n&&(n<0&&(Ui=zi),zi+=n),Xi=Gi===Ei&&(Yi===Ei||Yi===Li)||Yi===Ei&&Gi!==Pi,Vi=!(Gi!==Ri&&Gi!==Ei||Yi!==Mi&&Yi!==Pi),Ii=Hi&&o?h-o:h,t&&h&&Wi+Di+zi>Ii&&(i?(Di&&Zi(),Wi&&Ji()):(Vi||(Vi=Gi===Li&&Yi==Pi),Xi||Vi||Gi===Ci||Gi===Ri||Gi===Ei||Di+zi>Ii?(Di&&Zi(),Wi&&Ji()):Wi&&Ji()))," "===Fi&&!0!==Hi&&Wi+Di===0||(Gi===Ci?(" "===Fi&&Di&&Zi(),$i(Fi,zi),Zi()):Xi||Vi?(Di&&Zi(),$i(Fi,zi)):$i(Fi,zi)),Yi=Gi);Di&&Zi(),Wi&&Ji(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ni.paraNumber++,Wi=a.measureText(t).width,Qi.push({x:o||0,text:t,width:Wi,paraStart:!0}),Ki&&ts()})}(l,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[ns]);break;case"right":os(e,"x",-t[is])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[es]);break;case"bottom":os(e,"y",-t[ss])}}(h,l,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let v,y,x,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&d&&r>0&&(m+=d),v.y=m,m+=o,t.overflow>r&&m>w&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(l,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let c,d,u,f,p,g,_,w,m,v;s.forEach(t=>{t.words&&(p=o&&t.paraStart?o:0,w=t.words.length,h&&(v=!t.paraEnd||a,d=i-t.width-p,l?f=d/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?d/(w-1):0),g=r||t.isOverflow||l?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,c,t.data,t.isOverflow,v&&f),v&&(m=i===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,e,r),l.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,e,n,r),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=N.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,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]}}(l,e),l}};const as={string:function(t,e){if(!t)return"#000";const i=j(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign($,rs),Object.assign(N,as),Object.assign(V,Gt),Object.assign(H,be),Object.assign(q,Ue),Object.assign(K,ei),Object.assign(c,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new X}),st();export{Bt as Interaction,_t as Layouter,tt as LeaferCanvas,Z as PathNodeHandleType,yt as Picker,mt as Renderer,xt as Selector,ot as Watcher,st as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,isUndefined as n,DataHelper as o,canvasSizeAttrs as r,ResizeEvent as a,canvasPatch as h,FileHelper as l,Creator as c,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as g,ChildEvent as p,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as S,LayoutEvent as k,Run as L,ImageManager as B,BoundsHelper as T,Plugin as E,MathHelper as R,isObject as P,FourNumberHelper as M,Matrix as C,ImageEvent as A,MatrixHelper as O,AlignHelper as D,PointHelper as W,getMatrixData as I,AroundHelper as F,Direction4 as z,isNumber as j}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as U,InteractionBase as G,Cursor as Y,HitCanvasManager as X}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as V,PaintImage as H,ColorConvert as N,PaintGradient as q,Effect as K,Group as Q,TextConvert as $}from"@leafer-ui/draw";var Z;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(Z||(Z={}));const J=t.get("LeaferCanvas");class tt extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=s(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else J.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;if(this.unreal){const{config:t,autoWidthStr:e,autoHeightStr:i}=this;t.width?(n(e)&&(this.autoWidthStr=s.width||""),s.width=t.width+"px"):n(e)||(s.width=e),t.height?(n(i)&&(this.autoHeightStr=s.height||""),s.height=t.height+"px"):n(i)||(s.height=i)}else s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),J.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=i.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};o.copyAttrs(e,this,r),this.resize(t),this.resizeListener&&!n(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype);const{mineType:et,fileType:it}=l;function st(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=et(e),n=t.toDataURL(s,i);return"image/bmp"===s?n.replace("image/png;","image/bmp;"):n},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,et(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(et(it(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise(i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()}),loadImage:t=>new Promise((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new tt(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},u(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(i.fullImageShadow=!0),nt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?i.os="Mac":nt.indexOf("Linux")>-1&&(i.os="Linux");class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=o.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(g.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===p.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[p.ADD,p.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:at,updateChange:ht}=m,{pushAllChildBranch:lt,pushAllParent:ct}=v;const{worldBounds:dt}=y;class ut{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,b(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dt),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:ft,updateAllChange:gt}=m,pt=t.get("Layouter");class _t{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new S,this.target=t,e&&(this.config=o.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(k.START),this.layoutOnce(),t.emitEvent(new k(k.END,this.layoutedBlocks,this.times))}catch(t){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=L.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=k,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new k(n,a,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?(rt(t,!0),e.add(t),t.isBranch&&lt(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||at(s[t])}at(i)}})}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new k(o,a,this.times)),i.emitEvent(new k(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,L.end(e)}fullLayout(){const t=L.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=k,o=this.getBlocks(new f(e));e.emitEvent(new k(i,o,this.times)),_t.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new k(s,o,this.times)),e.emitEvent(new k(n,o,this.times)),this.addBlocks(o),L.end(t)}static fullLayout(t){ft(t,!0),t.isBranch?v.updateBounds(t):m.updateBounds(t),gt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ut([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ut(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_([[k.REQUEST,this.layout,this],[k.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const wt=t.get("Renderer");class mt{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=o.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(k.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(g.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(g.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(g.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,wt.log(e.innerName,"---\x3e");try{this.emitRender(g.START),this.renderOnce(t),this.emitRender(g.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,wt.error(t)}wt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return wt.warn("rendering");if(this.times>3)return wt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(g.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(g.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(g.RENDER,this.renderBounds,this.renderOptions),this.emitRender(g.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=L.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),L.end(e)}fullRender(){const t=L.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),L.end(t)}__render(e,s){const{canvas:n,target:o}=this,r=e.includes(o.__world),a=r?{includes:r}:{bounds:e,includes:r};this.needFill&&n.fillWorld(e,this.config.fill),t.showRepaint&&t.drawRepaint(n,e),this.config.useCellRender&&(a.cellList=this.getCellList()),i.render(o,n,a),this.renderBounds=s=s||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),n.updateRender(s)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||wt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new g(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[g.REQUEST,this.update,this],[k.END,this.__onLayoutEnd,this],[g.AGAIN,this.renderAgain,this],[a.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}mt.clipSpread=10;const{hitRadiusPoint:vt}=T;class yt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new f(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new f;if(t.length){let e;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=t.length;s<o;s++)if(e=t[s],(i||m.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&m.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>m.worldHittable(t))}getPath(t){const e=new f,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new f;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new f,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)if(i=t[o],i.__.visible&&(!e||i.__.mask))if(s=!!i.__.hitRadius||vt(i.__world,n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&i.__.__clipAfterFill&&!i.__hitWorld(n,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else 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:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[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 xt{constructor(t,e){this.config={},e&&(this.config=o.default(e,this.config)),this.picker=new yt(this.target=t,this),this.finder=c.finder&&c.finder()}getByPoint(t,e,s){const{target:n,picker:o}=this;return i.backgrounder&&n&&n.updateLayout(),o.getByPoint(t,e,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):E.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(c,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new _t(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new xt(t,e)}),i.layout=_t.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const bt={convert(t,e){const i=U.getBase(t),{x:s,y:n}=e,o=Object.assign(Object.assign({},i),{x:s,y:n,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=U.getBase(t),{x:s,y:n}=e;return Object.assign(Object.assign({},i),{x:s,y:n,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=bt.getTouch(t),s=U.getBase(t),{x:n,y:o}=e;return Object.assign(Object.assign({},s),{x:n,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},St={convert(t){const e=U.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:kt}=U;class Lt extends G{get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(St.convert(t))}onKeyUp(t){this.keyUp(St.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(bt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(bt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=bt.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(bt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(bt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(bt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(bt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=bt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&kt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(bt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=bt.getTouch(t);this.pointerUp(bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(U.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},U.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=U.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(R.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),P(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>P(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,b(t))t.forEach(t=>this.eachCursor(t,e,i));else{const n=s(t)&&Y.get(t);n&&i<2?this.eachCursor(n,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function Bt(t,e,i){t.__.__font?V.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,i,s,n){const o=i.__;P(t)?V.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&V.strokeArrow(t,i,s,n)}function Et(t,e,i,s,n){const o=i.__;P(t)?V.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),V.drawTextStroke(i,s,n))}function Rt(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Et(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",V.fillText(i,o,n),o.blendMode="normal",m.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}const{getSpread:Pt,copyAndSpread:Mt,toOuterOf:Ct,getOuterOf:At,getByMove:Ot,move:Dt,getIntersectData:Wt}=T,It={};let Ft;const{stintSet:zt}=o,{hasTransparent:jt}=N;function Ut(t,e,i){if(!P(e)||!1===e.visible||0===e.opacity)return;let o;const{boxBounds:r}=i.__layout;switch(e.type){case"image":if(!e.url)return;o=H.image(i,t,e,r,!Ft||!Ft[e.url]);break;case"linear":o=q.linearGradient(e,r);break;case"radial":o=q.radialGradient(e,r);break;case"angular":o=q.conicGradient(e,r);break;case"solid":const{type:s,color:a,opacity:h}=e;o={type:s,style:N.string(a,h)};break;default:n(e.r)||(o={type:"solid",style:N.string(e)})}if(o&&(o.originPaint=e,s(o.style)&&jt(o.style)&&(o.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;o.strokeStyle=e.style}return o}const Gt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),Ft=H.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ut(t,a[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),o=!0),"fill"===t?(zt(i,"__isAlphaPixelFill",n),zt(i,"__isTransparentFill",o)):(zt(i,"__isAlphaPixelStroke",n),zt(i,"__isTransparentStroke",o),zt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Bt(e,i,s)},fills:function(t,e,i,s){let n,o,r;for(let a=0,h=t.length;a<h;a++){if(n=t[a],o=n.originPaint,n.image){if(r?r++:r=1,H.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||o.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===o.scaleFixed||"zoom-in"===o.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}o.blendMode&&(i.blendMode=o.blendMode),Bt(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Bt(e,i,s),i.restoreBlendMode()):Bt(e,i,s)}},fillPathOrText:Bt,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:o}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)V.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Tt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Tt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)Tt(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Tt(t,2,e,r,s),r.clipUI(n),r.clearWorld(o),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){V.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Et(t,1,e,i,s);break;case"inside":Rt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Et(t,2,e,i,s):Rt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:o,decorationY:r}=n;for(let t=0,i=o.length;t<i;t++)s=o[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;o.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,o){let r;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,c=t.length;l<c;l++)if(r=t[l],(!r.image||!H.checkImage(r,!1,s,n,o))&&r.style){if(h){const{strokeStyle:t}=r;t?n.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(r.style,a.__strokeWidth*e,a)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?V.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?V.drawTextStroke(s,n,o):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),o=e.bounds,r=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,c,d,u,f,g;Ct(a.strokeSpread?(Mt(It,a.boxBounds,a.strokeSpread),It):a.boxBounds,r,h);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(o.includes(h))g=n,l=f=h,c=r;else{let n;if(i.fullImageShadow)n=h;else{const t=a.renderShapeSpread?Pt(o,M.swapAndScale(a.renderShapeSpread,p,_)):o;n=Wt(t,h)}u=o.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(g=e.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=m),f=At(h,u),l=Ot(f,-u.e,-u.f),c=At(r,u),Dt(c,-u.e,-u.f);const v=s.matrix;v?(d=new C(u),d.multiply(v),w*=v.scaleX,m*=v.scaleY):d=u,d.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:d})}return t.__renderShape(n,s),{canvas:n,matrix:d,fitMatrix:u,bounds:l,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt,Xt=new x;const{isSame:Vt}=T;function Ht(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||H.createData(n,s,i,o),!0}function Nt(t,e){Qt(t,A.LOAD,e)}function qt(t,e){Qt(t,A.LOADED,e)}function Kt(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,A.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function $t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Zt,translate:Jt}=O,te=new x,ee={},ie={};function se(t,e,i,n){const o=s(t)||n?(n?i-n*e:i%e)/((n||Math.floor(i/e))-1):t;return"auto"===t&&o<0?0:o}let ne={},oe=I();const{get:re,set:ae,rotateOfOuter:he,translate:le,scaleOfOuter:ce,multiplyParent:de,scale:ue,rotate:fe,skew:ge}=O;function pe(t,e,i,s,n,o,r,a){r&&fe(t,r),a&&ge(t,a.x,a.y),n&&ue(t,n,o),le(t,e.x+i,e.y+s)}function _e(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}h((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:we,scale:me,copy:ve}=O,{getFloorScale:ye}=R,{abs:xe}=Math;const be={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return Yt&&i===Yt.paint&&Vt(s,Yt.boxBounds)?o=Yt.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Yt=a.use>1?{leafPaint:o,paint:i,boxBounds:Xt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Ht(t,e,i,a,o,s),n&&(Nt(t,r),qt(t,r))):a.error?n&&Kt(t,r,a.error):(n&&($t(t,!0),Nt(t,r)),o.loadId=a.load(()=>{$t(t,!1),t.destroyed||(Ht(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),qt(t,r)),o.loadId=void 0},e=>{$t(t,!1),Kt(t,r,e),o.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,s,n,o){const{scaleX:r,scaleY:h}=H.getImageRenderScaleData(t,s,n,o),{image:l,data:c,originPaint:d}=t,{exporting:u}=o;return!(!c||t.patternId===r+"-"+h&&!u)&&(e&&(c.repeat?e=!1:d.changeful||"miniapp"===i.name&&a.isResizing(s)||u||(e=i.image.isLarge(l,r,h)||l.width*r>8096||l.height*h>8096)),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),H.drawImage(t,r,h,s,n,o),!0):(!t.style||d.sync||u?H.createPattern(t,s,n,o):H.createPatternTask(t,s,n,o),!1))},drawImage:function(t,e,i,s,n,o){const{data:r,image:a}=t,{blendMode:h}=t.originPaint,{opacity:l,transform:c}=r,d=a.getFull(r.filters),u=s.__;let f,{width:g,height:p}=a;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),f&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),c&&n.transform(c),n.drawImage(d,0,0,g,p),n.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),n.drawImage(d,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return o&&o.scaleX&&(n.scaleX*=Math.abs(o.scaleX),n.scaleY*=Math.abs(o.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(b(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,B.recyclePaint(s),n.loading&&(r||(r=e.__input&&e.__input[t]||[],b(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=B.patternTasker.add(()=>_e(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&H.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,s,n){let{scaleX:o,scaleY:r}=H.getImageRenderScaleData(t,e,s,n),a=o+"-"+r;if(t.patternId!==a&&!e.destroyed&&(!i.image.isLarge(t.image,o,r)||t.data.repeat)){const{image:s,data:n}=t,{transform:h,gap:l}=n,c=H.getPatternFixScale(t,o,r);let d,u,f,{width:g,height:p}=s;c&&(o*=c,r*=c),g*=o,p*=r,l&&(u=l.x*o/xe(n.scaleX||1),f=l.y*r/xe(n.scaleY||1)),(h||1!==o||1!==r)&&(o*=ye(g+(u||0)),r*=ye(p+(f||0)),d=we(),h&&ve(d,h),me(d,1/o,1/r));const _=s.getCanvas(g,p,n.opacity,n.filters,u,f,e.leafer&&e.leafer.config.smooth),w=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",d,t);t.style=w,t.patternId=a}},getPatternFixScale:function(t,e,s){const{image:n}=t;let o,r=i.image.maxPatternSize,a=n.width*n.height;return n.isSVG?e>1&&(o=Math.ceil(e)/e):r>a&&(r=a),(a*=e*s)>r&&(o=Math.sqrt(r/a)),o},createData:function(t,e,i,s){t.data=H.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=te.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:o}=i,{opacity:r,mode:a,align:h,offset:l,scale:c,size:d,rotation:u,skew:f,clipSize:g,repeat:p,gap:_,filters:w}=t,m=e.width===n&&e.height===o,v={mode:a},y="center"!==h&&(u||0)%180==90;let x,b;switch(T.set(ie,0,0,y?o:n,y?n:o),a&&"cover"!==a&&"fit"!==a?((c||d)&&(R.getScaleData(c,d,i,ee),x=ee.scaleX,b=ee.scaleY),(h||_||p)&&(x&&T.scale(ie,x,b,!0),h&&D.toPoint(h,ie,e,ie,!0,!0))):m&&!u||(x=b=T.getFitScale(e,ie,"fit"!==a),T.put(e,i,h,x,!1,ie),T.scale(ie,x,b,!0)),l&&W.move(ie,l),a){case"stretch":m?x&&(x=b=void 0):(x=e.width/n,b=e.height/o,H.stretchMode(v,e,x,b));break;case"normal":case"clip":if(ie.x||ie.y||x||g||u||f){let t,i;g&&(t=e.width/g.width,i=e.height/g.height),H.clipMode(v,e,ie.x,ie.y,x,b,u,f,t,i),t&&(x=x?x*t:t,b=b?b*i:i)}break;case"repeat":(!m||x||u||f)&&H.repeatMode(v,e,n,o,ie.x,ie.y,x,b,u,f,h,t.freeTransform),p||(v.repeat="repeat");const i=P(p);(_||i)&&(v.gap=function(t,e,i,s,n){let o,r;P(t)?(o=t.x,r=t.y):o=r=t;return{x:se(o,i,n.width,e&&e.x),y:se(r,s,n.height,e&&e.y)}}(_,i&&p,ie.width,ie.height,e));break;default:x&&H.fillOrFitMode(v,e,ie.x,ie.y,x,b,u)}return v.transform||(e.x||e.y)&&Jt(v.transform=Zt(),e.x,e.y),x&&(v.scaleX=x,v.scaleY=b),r&&r<1&&(v.opacity=r),w&&(v.filters=w),p&&(v.repeat=s(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,i,s){const n=re(),{x:o,y:r}=e;o||r?le(n,o,r):n.onlyScale=!0,ue(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=re();le(a,e.x+i,e.y+s),ue(a,n,o),r&&he(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,s,n,o,r,a,h,l){const c=re();pe(c,e,i,s,n,o,r,a),h&&(r||a?(ae(oe),ce(oe,e,h,l),de(c,oe)):ce(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,s,n,o,r,a,h,l,c,d){const u=re();if(d)pe(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)he(u,{x:i/2,y:s/2},h);else switch(fe(u,h),h){case 90:le(u,s,0);break;case 180:le(u,i,s);break;case 270:le(u,0,i)}ne.x=e.x+n,ne.y=e.y+o,le(u,ne.x,ne.y),r&&ce(u,ne,r,a)}t.transform=u}},{toPoint:Se}=F,{hasTransparent:ke}=N,Le={},Be={};function Te(t,e,i,n){if(i){let o,r,a,h;for(let t=0,l=i.length;t<l;t++)o=i[t],s(o)?(a=t/(l-1),r=N.string(o,n)):(a=o.offset,r=N.string(o.color,n)),e.addColorStop(a,r),!h&&ke(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Ee,getDistance:Re}=W,{get:Pe,rotateOfOuter:Me,scaleOfOuter:Ce}=O,{toPoint:Ae}=F,Oe={},De={};function We(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Ee(e,i);o=Pe(),n?(Ce(o,e,r/a*(s||1),1),Me(o,e,t+90)):(Ce(o,e,1,r/a*(s||1)),Me(o,e,t))}return o}const{getDistance:Ie}=W,{toPoint:Fe}=F,ze={},je={};const Ue={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Se(s||"top",e,Le),Se(n||"bottom",e,Be);const a=i.canvas.createLinearGradient(Le.x,Le.y,Be.x,Be.y),h={type:o,style:a};return Te(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Ae(s||"center",e,Oe),Ae(n||"bottom",e,De);const h=i.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Re(Oe,De)),l={type:o,style:h};Te(l,h,t.stops,r);const c=We(e,Oe,De,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;Fe(s||"center",e,ze),Fe(n||"bottom",e,je);const h=i.conicGradientSupport?i.canvas.createConicGradient(0,ze.x,ze.y):i.canvas.createRadialGradient(ze.x,ze.y,0,ze.x,ze.y,Ie(ze,je)),l={type:o,style:h};Te(l,h,t.stops,r);const c=We(e,ze,je,a||1,i.conicGradientRotate90);return c&&(l.transform=c),l},getTransform:We},{copy:Ge,move:Ye,toOffsetOutBounds:Xe}=T,{max:Ve,abs:He}=Math,Ne={},qe=new C,Ke={};function Qe(t,e){let i,s,n,o,r=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,o=1.5*(t.blur||0),n=He(t.spread||0),r=Ve(r,n+o-s),a=Ve(a,n+o+i),h=Ve(h,n+o+s),l=Ve(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function $e(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(Ge(Ne,t.bounds),Ye(Ne,e.x-n.x,e.y-n.y),o=t.bounds,r=Ne):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:Ze}=T,Je={};const ti=Qe;const ei={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Xe(h,Ke,l),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ke.offsetX+(r.x||0)*d*_,Ke.offsetY+(r.y||0)*u*_,(r.blur||0)*d*_,N.string(r.color)),n=K.getShadowTransform(t,f,i,r,Ke,_),n&&f.setTransform(n),$e(f,Ke,i),n&&f.resetTransform(),s=l,r.box&&(f.restore(),f.save(),a&&(f.copyWorld(f,l,o,"copy"),s=o),a?f.copyWorld(a,o,o,"destination-out"):f.copyWorld(i.canvas,c,h,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ze(h,Je,l),r.forEach((r,p)=>{let _=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Je.offsetX+(r.x||0)*d*_,Je.offsetY+(r.y||0)*u*_,(r.blur||0)*d*_),n=K.getShadowTransform(t,f,i,r,Je,_,!0),n&&f.setTransform(n),$e(f,Je,i),f.restore(),a?(f.copyWorld(f,l,o,"copy"),f.copyWorld(a,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,h,"source-out"),s=l),f.fillWorld(s,N.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),g&&p<g&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Qe,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=2*s.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return qe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),qe}},isTransformShadow(t){},getInnerShadowSpread:ti},{excludeRenderBounds:ii}=y;let si;function ni(t,e,i,s,n,o,r,a){switch(e){case"grayscale":si||(si=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);ri(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ri(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}Q.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++){if(i=h[l],a=i.__.mask,a){r&&(ni(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||ii(i,e)||i.__render(t,e),o=i.__.opacity,si=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=oi(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&ni(this,r,t,n,s,o,void 0,!1),ii(i,e)||i.__render(n||t,e),c&&ni(this,r,t,n,s,o,c,!1)}ni(this,r,t,n,s,o,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",hi=ai+"_#~&*+\\=|≮≯≈≠=…",li=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function ci(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const di=ci("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ui=ci("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fi=ci(ai),gi=ci(hi),pi=ci("- —/~|┆·");var _i;!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"}(_i||(_i={}));const{Letter:wi,Single:mi,Before:vi,After:yi,Symbol:xi,Break:bi}=_i;function Si(t){return di[t]?wi:pi[t]?bi:ui[t]?vi:fi[t]?yi:gi[t]?xi:li.test(t)?mi:wi}const ki={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Li(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Bi}=ki,{Letter:Ti,Single:Ei,Before:Ri,After:Pi,Symbol:Mi,Break:Ci}=_i;let Ai,Oi,Di,Wi,Ii,Fi,zi,ji,Ui,Gi,Yi,Xi,Vi,Hi,Ni,qi,Ki,Qi=[];function $i(t,e){Ui&&!ji&&(ji=Ui),Ai.data.push({char:t,width:e}),Di+=e}function Zi(){Wi+=Di,Ai.width=Di,Oi.words.push(Ai),Ai={data:[]},Di=0}function Ji(){Hi&&(Ni.paraNumber++,Oi.paraStart=!0,Hi=!1),Ui&&(Oi.startCharSize=ji,Oi.endCharSize=Ui,ji=0),Oi.width=Wi,qi.width?Bi(Oi):Ki&&ts(),Qi.push(Oi),Oi={words:[]},Wi=0}function ts(){Wi>(Ni.maxWidth||0)&&(Ni.maxWidth=Wi)}const{top:es,right:is,bottom:ss,left:ns}=z;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 rs={getDrawData:function(t,e){s(t)||(t=String(t));let n=0,o=0,r=e.__getInput("width")||0,a=e.__getInput("height")||0;const{__padding:h}=e;h&&(r?(n=h[ns],r-=h[is]+h[ns],!r&&(r=.01)):e.autoSizeAlign||(n=h[ns]),a?(o=h[es],a-=h[es]+h[ss],!a&&(a=.01)):e.autoSizeAlign||(o=h[es]));const l={bounds:{x:n,y:o,width:r,height:a},rows:[],paraNumber:0,font:i.canvas.font=e.__font};return function(t,e,s){Ni=t,Qi=t.rows,qi=t.bounds,Ki=!qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h}=qi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Hi=!0,Yi=null,ji=zi=Ui=Di=Wi=0,Ai={data:[]},Oi={words:[]},n&&(e=[...e]);for(let s=0,l=e.length;s<l;s++)Fi=e[s],"\n"===Fi?(Di&&Zi(),Oi.paraEnd=!0,Ji(),Hi=!0):(Gi=Si(Fi),Gi===Ti&&"none"!==r&&(Fi=Li(Fi,r,!Di)),zi=a.measureText(Fi).width,n&&(n<0&&(Ui=zi),zi+=n),Xi=Gi===Ei&&(Yi===Ei||Yi===Ti)||Yi===Ei&&Gi!==Pi,Vi=!(Gi!==Ri&&Gi!==Ei||Yi!==Mi&&Yi!==Pi),Ii=Hi&&o?h-o:h,t&&h&&Wi+Di+zi>Ii&&(i?(Di&&Zi(),Wi&&Ji()):(Vi||(Vi=Gi===Ti&&Yi==Pi),Xi||Vi||Gi===Ci||Gi===Ri||Gi===Ei||Di+zi>Ii?(Di&&Zi(),Wi&&Ji()):Wi&&Ji()))," "===Fi&&!0!==Hi&&Wi+Di===0||(Gi===Ci?(" "===Fi&&Di&&Zi(),$i(Fi,zi),Zi()):Xi||Vi?(Di&&Zi(),$i(Fi,zi)):$i(Fi,zi)),Yi=Gi);Di&&Zi(),Wi&&Ji(),Qi.length>0&&(Qi[Qi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ni.paraNumber++,Wi=a.measureText(t).width,Qi.push({x:o||0,text:t,width:Wi,paraStart:!0}),Ki&&ts()})}(l,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[ns]);break;case"right":os(e,"x",-t[is])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[es]);break;case"bottom":os(e,"y",-t[ss])}}(h,l,e,r,a),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&w>_)w=Math.max(_,o),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}m+=g;let v,y,x,b=p||u?p:t.maxWidth;for(let r=0,c=n;r<c;r++){if(v=i[r],v.x=f,v.width<p||v.width>p&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&d&&r>0&&(m+=d),v.y=m,m+=o,t.overflow>r&&m>w&&(v.isOverflow=!0,t.overflow=r+1),y=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,y-=x,x+=e.fontSize):x-=a),y<s.x&&(s.x=y),x>s.width&&(s.width=x),h&&p&&p<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let c,d,u,f,g,p,_,w,m,v;s.forEach(t=>{t.words&&(g=o&&t.paraStart?o:0,w=t.words.length,h&&(v=!t.paraEnd||a,d=i-t.width-g,l?f=d/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?d/(w-1):0),p=r||t.isOverflow||l?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,c,t.data,t.isOverflow,v&&f),v&&(m=i===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,e,r),l.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,e,n,r),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,P(o)?(i=o.type,o.color&&(t.decorationColor=N.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,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]}}(l,e),l}};const as={string:function(t,e){if(!t)return"#000";const i=j(e)&&e<1;if(s(t)){if(!i||!N.object)return t;t=N.object(t)}let o=n(t.a)?1:t.a;i&&(o*=e);const r=t.r+","+t.g+","+t.b;return 1===o?"rgb("+r+")":"rgba("+r+","+o+")"}};Object.assign($,rs),Object.assign(N,as),Object.assign(V,Gt),Object.assign(H,be),Object.assign(q,Ue),Object.assign(K,ei),Object.assign(c,{interaction:(t,e,i,s)=>new Lt(t,e,i,s),hitCanvas:(t,e)=>new tt(t,e),hitCanvasManager:()=>new X}),st();export{Lt as Interaction,_t as Layouter,tt as LeaferCanvas,Z as PathNodeHandleType,yt as Picker,mt as Renderer,xt as Selector,ot as Watcher,st as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map