leafer-ui 2.0.8 → 2.0.9

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
@@ -1,116 +1,172 @@
1
- # leafer-ui
1
+ English | [简体中文](./README-CN.md)
2
2
 
3
- 一款革新、好用的 Canvas 引擎, 革新的开发体验。适用于图形编辑、小游戏、互动应用、组态软件、生成图片与短视频等场景。
3
+ <br/>
4
4
 
5
- [![LeaferJS](https://www.leaferjs.com/image/leaferjs.jpg?d=1126)](https://www.leaferjs.com)
5
+ # LeaferJS: An Easy-to-Use Canvas Engine
6
6
 
7
- 提供了丰富的 UI 绘图元素,和开箱即用的功能,如自动布局、图形编辑、SVG 导出等,方便与 PS、 Figma、Sketch 等产品进行对接。并为跨平台开发提供了统一的交互事件,如拖拽、旋转、缩放手势等。
7
+ Effortlessly build graphic interaction and editing — an infinite canvas engine for the AI era
8
8
 
9
- 📗 [图文并茂、由浅入深的了解 LeaferJS](https://leaferjs.com/ui/blog/2024-07-09.html)
9
+ Official Website: [leaferjs.com](https://www.leaferjs.com)
10
10
 
11
- 📙 [全新动画、状态、过渡、游戏功能](https://leaferjs.com/ui/blog/2024-09-20.html)
11
+ **👉 A Canvas engine that can handle 1 million graphics in the browser**
12
+ **👉 The first Canvas core capable of building a “Figma-level editor”**
12
13
 
13
- 如果你觉得不错,请帮我们点个 [Star](https://github.com/leaferjs/leafer-ui) 🌟 ,让这个库被更多的人看见 ✨ ✨ ✨
14
+ <p align="center">
15
+ <a href="https://www.youtube.com/watch?v=bJ6fHMQdATs" target="_blank">
16
+ <img src="https://www.leaferjs.com/image/video/leaferjs-en.jpg" />
17
+ </a>
18
+ </p>
19
+ <p align="center">
20
+ <b>Extreme Performance · Ultra-Low Memory · DOM-like API · Graphic Editing · Cross-Platform · Zero Dependencies · Lightweight (70KB min+gzip)</b>
21
+ </p>
14
22
 
15
- <div style="display:flex; gap: 12px">
16
- <a target="_blank" href="https://github.com/leaferjs/leafer-ui" aria-label="github" rel="noopener">
17
- <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=20260317" />
18
- </a>
19
- </div>
23
+ <div align="center">
24
+
25
+ [![NPM Downloads](https://img.shields.io/npm/dm/leafer-ui?style=flat-square&color=32cd79)](https://www.npmjs.com/package/leafer-ui)
26
+ [![GitHub Stars](https://img.shields.io/github/stars/leaferjs/leafer-ui?style=flat-square&label=Stars&color=ffd700)](https://github.com/leaferjs/leafer-ui/stargazers)
27
+ [![GitHub Release](https://img.shields.io/github/v/release/leaferjs/leafer-ui)](https://github.com/leaferjs/leafer-ui/releases)
28
+ [![GitHub License](https://img.shields.io/github/license/leaferjs/leafer-ui)](https://github.com/leaferjs/leafer-ui/blob/main/LICENSE)
20
29
 
21
- ## 快速入门
30
+ </div>
22
31
 
23
- [1. 准备在线 Playground 环境](https://leaferjs.com/ui/guide/runtime.html)
32
+ ## 🧐 Why Choose LeaferJS?
24
33
 
25
- 用于运行、练习后续的示例代码。
34
+ In Web graphics development, developers often face a trade-off between **performance and usability**.
26
35
 
27
- [2. 学习 LeaferJS 快速入门教程](https://leaferjs.com/ui/guide/basic/app.html)
36
+ **LeaferJS aims to eliminate this compromise.** Rebuilt from the ground up, it not only pushes the limits of Web rendering and interaction performance, but also pursues ultimate simplicity in developer experience. It is a standardized engine designed for productivity tools handling **large-scale, high-density, and massive-layer graphics**.
28
37
 
29
- 跟随官网教程步骤(文档底部有下一步引导按钮)从浅到深的学习,动手调试每一段示例代码。
38
+ ## 🏗️ Why an Infinite Canvas Engine for the AI Era?
30
39
 
31
- ## 快速安装
40
+ With the explosion of AI-generated content, the challenge for graphics engines has shifted from **“how to render”** to **“how to organize and refine”**:
32
41
 
33
- 🚀 想马上在产品中使用,请安装 [leafer-ui](https://leaferjs.com/ui/guide/install/ui/start.html)(66KB min+gzip 零依赖),开始你的探索之旅。
42
+ - **⚡ Extreme Capacity:** Handles millions of interactive layers smoothly, perfectly accommodating massive AI-generated fragments.
43
+ - **🤖 Semantic Editing:** A structured scene tree allows AI to manipulate graphics like the DOM, enabling true AI collaborative workflows.
44
+ - **🛠️ Native Editor:** Built-in Editor plugin enables one-click access to industrial-grade editing features such as rotation, scaling, and multi-selection for AI-generated content.
34
45
 
35
- 也可直接安装 [leafer](https://leaferjs.com/ui/guide/install/leafer/start.md) 全量包, 会自动安装 `leafer-ui` 包和 `@leafer-in/*` 所有插件包。
46
+ [Leafer AI Knowledge Base](https://github.com/leaferjs/ai-docs) | [MCP & Skills](https://context7.com/leaferjs/ai-docs?tab=skills) | [Ask AI](https://context7.com/leaferjs/ai-docs?tab=chat)
36
47
 
37
- ## AI
48
+ ## 🎨 Use Cases
38
49
 
39
- [Leafer AI 知识库](https://github.com/leaferjs/ai-docs)
50
+ With its extreme performance and standardized capabilities, LeaferJS is an ideal foundation for:
40
51
 
41
- [Skills - Context7](https://context7.com/leaferjs/ai-docs?tab=skills)
52
+ - 🤖 **AI Applications:** Infinite AI canvas, AI design tools, generative UI interactions.
53
+ - 🛠️ **Productivity Tools:** Graphic editors, online design platforms (Figma/Canva-like), whiteboards, low-code engines.
54
+ - 📊 **Industrial Visualization:** Large-scale node systems, flowcharts, asset monitoring, massive topology diagrams.
55
+ - 🎬 **Digital Content Generation:** Batch image/poster generation, short video frame rendering (Node.js), interactive H5.
56
+ - 🎮 **Interactive Applications:** Lightweight games, brand interactive apps, high-frequency data dashboards.
42
57
 
43
- [Ask AI - Context7](https://context7.com/leaferjs/ai-docs?tab=chat)
58
+ ## 🔥 Performance
44
59
 
45
- [Ask AI - DeepWiki](https://deepwiki.com/leaferjs/ai-docs)
60
+ LeaferJS pushes the ceiling of Web graphics processing by approximately **10x**.
46
61
 
47
- ## 仓库组成
62
+ | Test (1M Interactive Rectangles) | Traditional Canvas Libraries | **LeaferJS** | Improvement |
63
+ | :------------------------------- | :--------------------------- | :----------- | :------------------- |
64
+ | **Initial Render Time** | ~10–15 seconds | **1.28s** | **~10x faster 🎉** |
65
+ | **Memory Usage** | ~3GB (may crash browser) | **320MB** | **~10x lower** |
66
+ | **Drag FPS (single element)** | 0–1 FPS | **60 FPS** | **Perfectly smooth** |
48
67
 
49
- [LeaferJS](https://github.com/leaferjs/LeaferJS) 主集成仓库,可直接运行代码。
68
+ Test environment: 2K laptop screen / Chrome V143.0. Results are for reference only; actual performance depends on hardware.
50
69
 
51
- [leafer](https://github.com/leaferjs/leafer) 核心仓库。
70
+ [Performance Details](https://www.leaferjs.com/#performance) | [Benchmark](https://benchmark.leaferjs.com/leafer/)
52
71
 
53
- [leafer-ui](https://github.com/leaferjs/leafer-ui) UI 仓库。
72
+ ## ⚡️ Core Capabilities
54
73
 
55
- [leafer-in](https://github.com/leaferjs/leafer-in) 插件仓库。
74
+ - **🎨 Powerful Graphics System:** Complete scene tree supporting vector graphics, SVG paths, and pixel operations.
75
+ - **🧠 Ultra-Fast Interaction:** Native support for drag, zoom, multi-touch, and millisecond-level hit testing.
76
+ - **🛠️ Built-in Editor Support:** Integrated **Editor plugin** enabling **scale, rotate, move, multi-select** with one click.
77
+ - **🧩 Modern Layout Engine:** Rare native **Flexbox layout** support in a Canvas engine — as natural as writing HTML.
78
+ - **🎬 State-Driven Animation:** Built-in high-performance transitions and path animations for smooth dynamic interactions.
79
+ - **🌍 Cross-Platform:** One codebase runs seamlessly on Web, Node.js, WeChat Mini Programs, and mobile H5.
56
80
 
57
- [leafer-x](https://github.com/leaferjs/leafer-x) 社区插件提交仓库。
81
+ [Full Feature List](https://www.leaferjs.com/#different) | [Live Examples](https://www.leaferjs.com/examples/)
58
82
 
59
- [test](https://github.com/leaferjs/test) 自动化测试仓库。
83
+ ## 🛠️ Quick Start
60
84
 
61
- [code](https://github.com/leaferjs/code) 示例代码仓库。
85
+ ```sh
86
+ npm install leafer-ui
62
87
 
63
- [docs](https://github.com/leaferjs/docs) 在线文档仓库。
88
+ # When using plugins, it is recommended to install core packages together
89
+ # to avoid version mismatch issues
90
+ npm install leafer-ui @leafer-ui/core @leafer-ui/draw
91
+ ```
64
92
 
65
- ## 使命与愿景
93
+ ```ts
94
+ import { Leafer, Rect } from 'leafer-ui'
66
95
 
67
- LeaferJS 不仅致力打造前沿的 2D 和未来的 3D 引擎技术,更希望创造一套简洁、开放、现代化的 UI 绘图标准,表现力丰富,便于 AI 理解,人类可视化使用,并为数字化产品开发提供跨平台、轻量化、高性能的运行时。
96
+ // Create an interactive app that adapts to the window
97
+ const leafer = new Leafer({ view: window })
68
98
 
69
- 让不同的软件之间能够沟通、协作、共享绘图数据,让数字化产品开发可以更快、更简单。
99
+ // Create a draggable rectangle
100
+ const rect = new Rect({
101
+ x: 100,
102
+ y: 100,
103
+ width: 200,
104
+ height: 200,
105
+ fill: '#32cd79',
106
+ draggable: true,
107
+ })
70
108
 
71
- 通过不断革新的图形渲染技术、配套支持, 吸引更多的开发者加入使用,建立起一个开放的生态环境,沟通有无,互相从中受益,推动行业的快速发展。
109
+ leafer.add(rect)
110
+ ```
72
111
 
73
- 让开发者能够快速地构建 AI 时代的网页、应用、设计、画布、游戏和动画等可视化生产力工具,推动下一代本地优先的 Figma、Miro、Notion、Unity、Adobe、Canva、Webflow 等创新产品诞生,并激发更多创意技术和应用。
112
+ [Run Online Example](https://www.leaferjs.com/examples/#official%2Fstart%2Fcreate.ts) | [Editor Example](https://www.leaferjs.com/examples/#official%2Fplugin%2Feditor%2Fframe%2Ftransparent.ts)
74
113
 
75
- ![leaferjs](https://www.leaferjs.com/ui/svg/leaferjs.svg?d=013007)
114
+ ## 💼 Commercial Support & Sustainability
76
115
 
77
- ![覆盖场景](https://www.leaferjs.com/ui/image/blog/20241120/plan.jpg)
116
+ There is a significant gap between “an engine” and “a mature product.” To ensure long-term maintenance of the open-source engine and help enterprises overcome complex development challenges, we’ve built a transparent and sustainable ecosystem:
78
117
 
79
- 这是一段漫长而又充满乐趣的旅程,我们正在年复一年、坚定地向这个目标持续前进,可以通过 [开发计划](https://www.leaferjs.com/ui/plan/) 了解更多信息。
118
+ - **LeaferJS Forever Open Source (MIT):** Core features and foundational plugins remain open and free, ensuring developer freedom and control.
119
+ - **[PxGrow](https://www.pxgrow.com/) Commercial Plugins (Optional):** Focused on solving **complex industrial scenarios**, including advanced editor suites, extreme performance optimizations, and complex graphic algorithms — saving months or even years of development time.
120
+ - **Sustainable Growth:** All commercial revenue is reinvested into the open-source engine to ensure LeaferJS stays at the forefront of Web graphics technology.
80
121
 
81
- ## 卓越文化
122
+ ### LeaferJS Repository Overview
82
123
 
83
- 我们追求慢慢打造出这样的团队与社区氛围:
124
+ | Repository | Description | Link |
125
+ | :------------ | :------------------------------- | :---------------------------------------------- |
126
+ | **LeaferJS** | Main integration repo (runnable) | [GitHub](https://github.com/leaferjs/LeaferJS) |
127
+ | **leafer** | Core engine | [GitHub](https://github.com/leaferjs/leafer) |
128
+ | **leafer-ui** | UI layer | [GitHub](https://github.com/leaferjs/leafer-ui) |
129
+ | **leafer-in** | Official plugins | [GitHub](https://github.com/leaferjs/leafer-in) |
130
+ | **leafer-x** | Community plugins showcase | [GitHub](https://github.com/leaferjs/leafer-x) |
131
+ | **test** | Automated testing | [GitHub](https://github.com/leaferjs/test) |
132
+ | **code** | Example code | [GitHub](https://github.com/leaferjs/code) |
133
+ | **docs** | Documentation | [GitHub](https://github.com/leaferjs/docs) |
84
134
 
85
- **真诚坚韧、追求卓越、热爱生活、与众不同、倾听、互帮互助、懂得取舍、不怕失败、结果导向**
135
+ ## 🌟 Contribute: Five Years of Craftsmanship, Built from Passion
86
136
 
87
- 我们相信当一个人身心强健,对这个世界充满无限好奇的时候,会产生出源源不断的生命力和创造力,所以我们鼓励追求卓越与热爱生活,也许我们会因为健身、美食、旅行、摄影、音乐、写作、绘画、舞蹈、游戏等热爱而了解彼此,也许我们还会有自己的乐队、画展、读书会...
137
+ LeaferJS is an original open-source engine refined over five years. Our mission is to standardize the **graphics system foundation**, so developers can focus on creativity rather than low-level implementation.
88
138
 
89
- 我们要一起去攀登一座座别人从未到达过的高峰,同时我们也了解自己的能力边界,将聪明才智都聚焦到我们最感兴趣,也对用户最有价值的那个点上,在那里做出前人未曾有过的东西。
139
+ **If you value originality and extreme performance, please give us a Star!**
90
140
 
91
- 我们知道成功并非一蹴而就,所以我们接纳路途中的失败、偶尔的躺平,只要拥有坚韧的气质和永不放弃的精神,从失败中吸取教训,不断成长,积累一个个小小的胜利,就一定会抵达目的地。
141
+ <div style="display:flex; gap: 12px">
142
+ <a target="_blank" href="https://github.com/leaferjs/leafer-ui" aria-label="github" rel="noopener">
143
+ <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=20260416" />
144
+ </a>
145
+ </div>
92
146
 
93
- 希望我们能一起创办出 **一家像胖东来一样的新型互联网企业和社区,** 如果你喜欢这样的文化,欢迎阅读 [贡献指南](https://www.leaferjs.com/ui/contribute/guide.html),可以一起参与进来。
147
+ - 🌟 **Star the repo:** Your support means everything.
148
+ - 🐞 **Report issues:** Every issue helps us improve.
149
+ - 🤝 **Join the community:** Explore the limits of Web graphics together.
94
150
 
95
- ## 贡献指南
151
+ ## Contribution Guide
96
152
 
97
- 当你使用 LeaferJS 时, 你就已成为了 这个充满活力的大家庭 的一员,踏入这座建设中的“技术城堡”。只有通过每位成员的热情参与与贡献,这座城堡才能逐步走向完善。
153
+ When you use LeaferJS, you become part of this vibrant community — stepping into a growing “tech castle.” Only through collective participation can it truly flourish.
98
154
 
99
- [社区行为准则](./contributor/CODE_OF_CONDUCT.md)
155
+ [Code of Conduct](./contributor/CODE_OF_CONDUCT.md)
100
156
 
101
- [代码提交规范](./contributor/COMMIT_CONVENTION.md)
157
+ [Commit Convention](./contributor/COMMIT_CONVENTION.md)
102
158
 
103
- [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E6%8F%90%E9%97%AE%E7%9A%84%E6%99%BA%E6%85%A7)
159
+ [How to Ask Questions the Smart Way](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E6%8F%90%E9%97%AE%E7%9A%84%E6%99%BA%E6%85%A7)
104
160
 
105
- ## 致谢贡献者
161
+ ## Acknowledgements
106
162
 
107
- [每一位贡献代码的社区成员](https://github.com/leaferjs/leafer-ui/graphs/contributors)
163
+ [All code contributors](https://github.com/leaferjs/leafer-ui/graphs/contributors)
108
164
 
109
- [每一位参与生态的社区成员](https://www.leaferjs.com/ui/contribute/)
165
+ [All community contributors](https://www.leaferjs.com/ui/contribute/)
110
166
 
111
- ## 赞助商
167
+ ## Sponsors
112
168
 
113
- <p><h3 align="center">金牌赞助商</h3></p>
169
+ <p><h3 align="center">Gold Sponsors</h3></p>
114
170
  <p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
115
171
  <a target="_blank" href="https://easysearch.cn">
116
172
  <img width="180" title="Easysearch - 企业级的分布式搜索型数据库" src="https://www.leaferjs.com/image/sponsor/gold/easysearch.png" loading="lazy" />
@@ -153,7 +209,7 @@ LeaferJS 不仅致力打造前沿的 2D 和未来的 3D 引擎技术,更希望
153
209
  </a>
154
210
  </p>
155
211
 
156
- <p><h3 align="center">银牌赞助</h3></p>
212
+ <p><h3 align="center">Silver Sponsors</h3></p>
157
213
  <p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 5px;">
158
214
  <a target="_blank" href="">
159
215
  <img width="40" title="black" src="https://api.pxgrow.com/uploads/avatar/249/AzA/4v/u.jpg" loading="lazy" />
@@ -328,12 +384,12 @@ LeaferJS 不仅致力打造前沿的 2D 和未来的 3D 引擎技术,更希望
328
384
  </a>
329
385
  </p>
330
386
 
331
- <p><h3 align="center">铜牌赞助</h3></p>
387
+ <p><h3 align="center">Bronze Sponsors</h3></p>
332
388
  <p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
333
389
  用户zw8T394C &nbsp;&nbsp;用户zw8T398C &nbsp;&nbsp;龙眼吃多了上火 &nbsp;&nbsp;用户zw8T392T &nbsp;&nbsp;用户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;赞助我们 &nbsp;&nbsp;</p>
334
390
 
335
391
  ## License
336
392
 
337
- MIT 开源许可协议,可以免费使用,且能用于商业场景。
393
+ MIT License — free to use, including for commercial applications.
338
394
 
339
395
  Copyright © 2023-present Chao (Leafer) Wan
package/dist/web.cjs CHANGED
@@ -1513,6 +1513,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
1513
1513
  if (!data.__strokeWidth) return;
1514
1514
  if (data.__font) {
1515
1515
  draw.Paint.strokeText(stroke, ui, canvas, renderOptions);
1516
+ } else if (data.__pathForStroke) {
1517
+ draw.Paint.fillStroke(stroke, ui, canvas, renderOptions);
1516
1518
  } else {
1517
1519
  switch (data.strokeAlign) {
1518
1520
  case "center":
package/dist/web.esm.js CHANGED
@@ -1517,6 +1517,8 @@ function stroke(stroke, ui, canvas, renderOptions) {
1517
1517
  if (!data.__strokeWidth) return;
1518
1518
  if (data.__font) {
1519
1519
  Paint.strokeText(stroke, ui, canvas, renderOptions);
1520
+ } else if (data.__pathForStroke) {
1521
+ Paint.fillStroke(stroke, ui, canvas, renderOptions);
1520
1522
  } else {
1521
1523
  switch (data.strokeAlign) {
1522
1524
  case "center":
@@ -1,2 +1,2 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,DataHelper as n,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as a,canvasPatch as h,Creator as l,LeaferImage as c,defineKey as d,FileHelper as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,LeafHelper as m,BranchHelper as v,LeafBoundsHelper as y,Bounds as x,isArray as b,LeafLevelList as S,LayoutEvent as L,Run as k,ImageManager as T,PointHelper as B,BoundsHelper as E,Plugin as P,MathHelper as R,isObject as M,FourNumberHelper as C,Matrix as A,ImageEvent as D,MatrixHelper as O,AlignHelper as W,isNumber as I,getMatrixData as F,AroundHelper as z,OneRadian as j,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{InteractionHelper as Y,InteractionBase as G,Cursor as X,HitCanvasManager as V}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as N,PaintImage as H,ColorConvert as q,PaintGradient as K,Effect as Q,Group as $,TextConvert as Z}from"@leafer-ui/draw";var J;function tt(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(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(J||(J={})),"function"==typeof SuppressedError&&SuppressedError;const et=t.get("LeaferCanvas");class it 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",this.view.classList.add("leafer-canvas-view")}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 et.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;s.width=t+"px",s.height=e+"px",this.unreal||(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),et.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={};n.copyAttrs(e,this,o),this.resize(t),this.resizeListener&&!r(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}}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=u.mimeType(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,u.mimeType(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(u.mimeType(u.fileType(e)),s);return i.origin.download(n,e)},download(t,e){return tt(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,e,s)=>new Promise((s,n)=>{const o=new i.origin.Image;e&&(o.setAttribute("crossOrigin",e),o.crossOrigin=e),o.onload=()=>{s(o)},o.onerror=t=>{n(t)},o.src=i.image.getRealURL(t)}),loadContent(t){return tt(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=l.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype),Object.assign(l,{canvas:(t,e)=>new it(t,e),image:t=>new c(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},d(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(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=n.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.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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 w(w.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_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.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 wt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new S,this.target=t,e&&(this.config=n.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(L.START),this.layoutOnce(),t.emitEvent(new L(L.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(w.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=k.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=L,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new L(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 L(o,a,this.times)),i.emitEvent(new L(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,k.end(e)}fullLayout(){const t=k.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=L,o=this.getBlocks(new f(e));e.emitEvent(new L(i,o,this.times)),wt.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new L(s,o,this.times)),e.emitEvent(new L(n,o,this.times)),this.addBlocks(o),k.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_([[L.REQUEST,this.layout,this],[L.AGAIN,this.layoutAgain,this],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=n.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(L.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,_t.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,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(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=k.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil();const{ceilPartPixel:o}=this.config;i.clipWorld(s,o),i.clearWorld(s,o),this.__render(s,n),i.restore(),k.end(e)}fullRender(){const t=k.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),k.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,e){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;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||_t.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}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],[L.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 vt={},{copyRadiusPoint:yt}=B,{hitRadiusPoint:xt}=E;class bt{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,n;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],n=i.__,n.visible&&(!e||n.mask))if(s=xt(i.__world,n.hitRadius?yt(vt,o,n.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o)}}else s&&this.hitChild(i,o)}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 St{constructor(t,e){this.config={},e&&(this.config=n.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=l.finder&&l.finder(t,this.config)}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):P.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new St(t,e)}),i.layout=wt.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 Lt={convert(t,e){const i=Y.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=Y.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=Lt.getTouch(t),s=Y.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]},kt={convert(t){const e=Y.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Tt}=Y;class Bt extends G{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}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),this.windowTarget.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)this.windowTarget.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&&(!this.config.shadowDOM||!t.composedPath||!t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(kt.convert(t))}onKeyUp(t){this.keyUp(kt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(Lt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(Lt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=Lt.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(Lt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(Lt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(Lt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(Lt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=Lt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Tt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(Lt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=Lt.getTouch(t);this.pointerMove(Lt.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=Lt.getTouch(t);this.pointerUp(Lt.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(Y.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},Y.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=Y.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),M(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>M(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)&&X.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 Et(t,e,i){t.__.__font?N.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Pt(t,e,i,s,n){const o=i.__;M(t)?N.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&N.strokeArrow(t,i,s,n)}function Rt(t,e,i,s,n){const o=i.__;M(t)?N.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),N.drawTextStroke(i,s,n))}function Mt(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Rt(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",N.fillText(i,o,n),o.blendMode="normal",m.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}const{getSpread:Ct,copyAndSpread:At,toOuterOf:Dt,getOuterOf:Ot,getByMove:Wt,move:It,getIntersectData:Ft}=E,zt={};let jt;const{stintSet:Ut}=n,{hasTransparent:Yt}=q;function Gt(t,e,i){if(!M(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout,{type:a}=e;switch(a){case"image":case"film":case"video":if(!e.url)return;n=H.image(i,t,e,o,!jt||!jt[e.url]),"image"!==a&&H[a](n);break;case"linear":n=K.linearGradient(e,o);break;case"radial":n=K.radialGradient(e,o);break;case"angular":n=K.conicGradient(e,o);break;case"solid":const{color:s,opacity:h}=e;n={type:a,style:q.string(s,h)};break;default:r(e.r)||(n={type:"solid",style:q.string(e)})}if(n&&(n.originPaint=e,s(n.style)&&Yt(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const Xt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),jt=H.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Gt(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?(Ut(i,"__isAlphaPixelFill",n),Ut(i,"__isTransparentFill",o)):(Ut(i,"__isAlphaPixelStroke",n),Ut(i,"__isTransparentStroke",o),Ut(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Et(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,o.scaleFixed,!1);1!==t&&i.scale(t,s)}o.blendMode&&(i.blendMode=o.blendMode),Et(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Et(e,i,s),i.restoreBlendMode()):Et(e,i,s)}},fillPathOrText:Et,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)N.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Pt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Pt(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)Pt(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Pt(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){N.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i,s);break;case"inside":Mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i,s):Mt(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?N.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?N.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;Dt(a.strokeSpread?(At(zt,a.boxBounds,a.strokeSpread),zt):a.boxBounds,r,h);let{scaleX:g,scaleY:w}=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?Ct(o,C.swapAndScale(a.renderShapeSpread,g,w)):o;n=Ft(t,h)}u=o.getFitMatrix(n);let{a:_,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=_,w*=m),f=Ot(h,u),l=Wt(f,-u.e,-u.f),c=Ot(r,u),It(c,-u.e,-u.f);const v=s.matrix;v?(d=new A(u),d.multiply(v),_*=v.scaleX,m*=v.scaleY):d=u,d.withScale(_,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:w}}};let Vt,Nt=new x;const{isSame:Ht}=E;function qt(t,e,i,s,n,o){let r=!0;const a=t.__;if("fill"!==e||a.__naturalWidth||(a.__naturalWidth=s.width/a.pixelRatio,a.__naturalHeight=s.height/a.pixelRatio,a.__autoSide&&(t.forceUpdate("width"),m.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",a.width),t.setProxyAttr("height",a.height)),r=!1)),!n.data){H.createData(n,s,i,o);const{transform:t}=n.data,{opacity:e,blendMode:r}=i,h=t&&!t.onlyScale||a.path||a.cornerRadius;(h||e&&e<1||r)&&(n.complex=!h||2)}return i.filter&&H.applyFilter(n,s,i.filter,t),r}function Kt(t,e){Zt(t,D.LOAD,e)}function Qt(t,e){Zt(t,D.LOADED,e)}function $t(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,D.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,translate:ee}=O,ie=new x,se={},ne={};function oe(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 re={},ae=F();const{get:he,set:le,rotateOfOuter:ce,translate:de,scaleOfOuter:ue,multiplyParent:fe,scale:pe,rotate:ge,skew:we}=O;function _e(t,e,i,s,n,o,r,a){r&&ge(t,r),a&&we(t,a.x,a.y),n&&pe(t,n,o),de(t,e.x+i,e.y+s)}const{get:me,scale:ve,copy:ye}=O,{getFloorScale:xe}=R,{abs:be}=Math;const Se={image:function(t,e,i,s,n){let o,r;const a=T.get(i,i.type);return Vt&&i===Vt.paint&&Ht(s,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Vt=a.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(qt(t,e,i,a,o,s),n&&(Kt(t,r),Qt(t,r))):a.error?n&&$t(t,r,a.error):(n&&(Jt(t,!0),Kt(t,r)),o.loadId=a.load(()=>{Jt(t,!1),t.destroyed||(qt(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,r)),o.loadId=void 0},e=>{Jt(t,!1),$t(t,r,e),o.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),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:a}=H.getImageRenderScaleData(t,s,n,o),h=t.film?t.nowIndex:r+"-"+a,{image:l,data:c,originPaint:d}=t,{exporting:u,snapshot:f}=o;return!(!c||t.patternId===h&&!u||f)&&(e&&(c.repeat?e=!1:d.changeful||t.film||"miniapp"===i.name||u||(e=i.image.isLarge(l,r,a)||l.width*r>8096||l.height*a>8096)),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),H.drawImage(t,r,a,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,complex:h}=t;let{width:l,height:c}=a;if(h){const{blendMode:o,opacity:d}=t.originPaint,{transform:u}=r;n.save(),2===h&&n.clipUI(s),o&&(n.blendMode=o),d&&(n.opacity*=d),u&&n.transform(u),a.render(n,0,0,l,c,s,t,e,i),n.restore()}else r.scaleX&&(l*=r.scaleX,c*=r.scaleY),a.render(n,0,0,l,c,s,t,e,i)},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.recyclePaint(s),e.__willDestroy&&n.parent&&H.recycleFilter(n,e.__leaf),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(()=>tt(this,void 0,void 0,function*(){H.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:o,scaleY:r}=H.getImageRenderScaleData(t,e,s,n),a=t.film?t.nowIndex:o+"-"+r;if(t.patternId!==a&&!e.destroyed&&(!i.image.isLarge(t.image,o,r)||t.data.repeat)){const{image:s,data:n}=t,{opacity:h}=t.originPaint,{transform:l,gap:c}=n,d=H.getPatternFixScale(t,o,r);let u,f,p,{width:g,height:w}=s;d&&(o*=d,r*=d),g*=o,w*=r,c&&(f=c.x*o/be(n.scaleX||1),p=c.y*r/be(n.scaleY||1)),(l||1!==o||1!==r)&&(o*=xe(g+(f||0)),r*=xe(w+(p||0)),u=me(),l&&ye(u,l),ve(u,1/o,1/r));const _=s.getCanvas(g,w,h,void 0,f,p,e.leafer&&e.leafer.config.smooth,n.interlace),m=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",u,t);t.style=m,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=ie.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:o}=i,{mode:r,align:a,offset:h,scale:l,size:c,rotation:d,skew:u,clipSize:f,repeat:p,gap:g,interlace:w}=t,_=e.width===n&&e.height===o,m={mode:r},v="center"!==a&&(d||0)%180==90;let y,x;switch(E.set(ne,0,0,v?o:n,v?n:o),r&&"cover"!==r&&"fit"!==r?((l||c)&&(R.getScaleData(l,c,i,se),y=se.scaleX,x=se.scaleY),(a||g||p)&&(y&&E.scale(ne,y,x,!0),a&&W.toPoint(a,ne,e,ne,!0,!0))):_&&!d||(y=x=E.getFitScale(e,ne,"fit"!==r),E.put(e,i,a,y,!1,ne),E.scale(ne,y,x,!0)),h&&B.move(ne,h),r){case"stretch":_?y&&(y=x=void 0):(y=e.width/n,x=e.height/o,H.stretchMode(m,e,y,x));break;case"normal":case"clip":if(ne.x||ne.y||y||f||d||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),H.clipMode(m,e,ne.x,ne.y,y,x,d,u,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||d||u)&&H.repeatMode(m,e,n,o,ne.x,ne.y,y,x,d,u,a,t.freeTransform),p||(m.repeat="repeat");const i=M(p);(g||i)&&(m.gap=function(t,e,i,s,n){let o,r;M(t)?(o=t.x,r=t.y):o=r=t;return{x:oe(o,i,n.width,e&&e.x),y:oe(r,s,n.height,e&&e.y)}}(g,i&&p,ne.width,ne.height,e));break;default:y&&H.fillOrFitMode(m,e,ne.x,ne.y,y,x,d)}return m.transform||(e.x||e.y)&&ee(m.transform=te(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),p&&(m.repeat=s(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),w&&(m.interlace=I(w)||"percent"===w.type?{type:"x",offset:w}:w),m},stretchMode:function(t,e,i,s){const n=he(),{x:o,y:r}=e;o||r?de(n,o,r):i>0&&s>0&&(n.onlyScale=!0),pe(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=he();de(a,e.x+i,e.y+s),pe(a,n,o),r&&ce(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=he();_e(c,e,i,s,n,o,r,a),h&&(r||a?(le(ae),ue(ae,e,h,l),fe(c,ae)):ue(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,s,n,o,r,a,h,l,c,d){const u=he();if(d)_e(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)ce(u,{x:i/2,y:s/2},h);else switch(ge(u,h),h){case 90:de(u,s,0);break;case 180:de(u,i,s);break;case 270:de(u,0,i)}re.x=e.x+n,re.y=e.y+o,de(u,re.x,re.y),r&&ue(u,re,r,a)}t.transform=u}},{toPoint:Le}=z,{hasTransparent:ke}=q,Te={},Be={};function Ee(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=q.string(o,n)):(a=o.offset,r=q.string(o.color,n)),e.addColorStop(a,r),!h&&ke(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Pe,getDistance:Re}=B,{get:Me,rotateOfOuter:Ce,scaleOfOuter:Ae}=O,{toPoint:De}=z,Oe={},We={};function Ie(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Pe(e,i);o=Me(),n?(Ae(o,e,r/a*(s||1),1),Ce(o,e,t+90)):(Ae(o,e,1,r/a*(s||1)),Ce(o,e,t))}return o}const{getDistance:Fe}=B,{toPoint:ze}=z,je={},Ue={};const Ye={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;Le(s||"top",e,Te),Le(n||"bottom",e,Be);const a=i.canvas.createLinearGradient(Te.x,Te.y,Be.x,Be.y),h={type:o,style:a};return Ee(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;De(s||"center",e,Oe),De(n||"bottom",e,We);const h=i.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Re(Oe,We)),l={type:o,style:h};Ee(l,h,t.stops,r);const c=Ie(e,Oe,We,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,rotation:a,stretch:h}=t;ze(s||"center",e,je),ze(n||"bottom",e,Ue);const l=i.conicGradientSupport?i.canvas.createConicGradient(a?a*j:0,je.x,je.y):i.canvas.createRadialGradient(je.x,je.y,0,je.x,je.y,Fe(je,Ue)),c={type:o,style:l};Ee(c,l,t.stops,r);const d=Ie(e,je,Ue,h||1,i.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Ie},{copy:Ge,move:Xe,toOffsetOutBounds:Ve}=E,{max:Ne,abs:He}=Math,qe={},Ke=new A,Qe={};function $e(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=Ne(r,n+o-s),a=Ne(a,n+o+i),h=Ne(h,n+o+s),l=Ne(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function Ze(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(Ge(qe,t.bounds),Xe(qe,e.x-n.x,e.y-n.y),o=t.bounds,r=qe):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:Je}=E,ti={};const ei=$e;const ii={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;Ve(h,Qe,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(Qe.offsetX+(r.x||0)*d*w,Qe.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w,q.string(r.color)),n=Q.getShadowTransform(t,f,i,r,Qe,w),n&&f.setTransform(n),Ze(f,Qe,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;Je(h,ti,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(ti.offsetX+(r.x||0)*d*w,ti.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w),n=Q.getShadowTransform(t,f,i,r,ti,w,!0),n&&f.setTransform(n),Ze(f,ti,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,q.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:$e,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 Ke.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),Ke}},isTransformShadow(t){},getInnerShadowSpread:ei},{excludeRenderBounds:si}=y;let ni;function oi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":ni||(ni=!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);ai(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ai(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function ri(t){return t.getSameCanvas(!1,!0)}function ai(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)}$.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&&(oi(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||si(i,e)||i.__render(t,e),o=i.__.opacity,ni=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=ri(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=ri(t)),n||(n=ri(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&oi(this,r,t,n,s,o,void 0,!1),si(i,e)||i.__render(n||t,e),c&&oi(this,r,t,n,s,o,c,!1)}oi(this,r,t,n,s,o,void 0,!0)};const hi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",li=hi+"_#~&*+\\=|≮≯≈≠=…",ci=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function di(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ui=di("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fi=di("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=di(hi),gi=di(li),wi=di("- —/~|┆·");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:mi,Single:vi,Before:yi,After:xi,Symbol:bi,Break:Si}=_i;function Li(t){return ui[t]?mi:wi[t]?Si:fi[t]?yi:pi[t]?xi:gi[t]?bi:ci.test(t)?vi:mi}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 Ti(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Bi}=ki,{Letter:Ei,Single:Pi,Before:Ri,After:Mi,Symbol:Ci,Break:Ai}=_i;let Di,Oi,Wi,Ii,Fi,zi,ji,Ui,Yi,Gi,Xi,Vi,Ni,Hi,qi,Ki,Qi,$i=[];function Zi(t,e){Yi&&!Ui&&(Ui=Yi),Di.data.push({char:t,width:e}),Wi+=e}function Ji(){Ii+=Wi,Di.width=Wi,Oi.words.push(Di),Di={data:[]},Wi=0}function ts(){Hi&&(qi.paraNumber++,Oi.paraStart=!0,Hi=!1),Yi&&(Oi.startCharSize=Ui,Oi.endCharSize=Yi,Ui=0),Oi.width=Ii,Ki.width?Bi(Oi):Qi&&es(),$i.push(Oi),Oi={words:[]},Ii=0}function es(){Ii>(qi.maxWidth||0)&&(qi.maxWidth=Ii)}const{top:is,right:ss,bottom:ns,left:os}=U;function rs(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const as={getDrawData:function(t,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[os],r-=h[ss]+h[os],!r&&(r=.01)):e.autoSizeAlign||(n=h[os]),a?(o=h[is],a-=h[is]+h[ns],!a&&(a=.01)):e.autoSizeAlign||(o=h[is]));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){qi=t,$i=t.rows,Ki=t.bounds,Qi=!Ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h}=Ki;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Hi=!0,Xi=null,Ui=ji=Yi=Wi=Ii=0,Di={data:[]},Oi={words:[]};for(let s=0,l=(e=[...e]).length;s<l;s++)zi=e[s],"\n"===zi?(Wi&&Ji(),Oi.paraEnd=!0,ts(),Hi=!0):(Gi=Li(zi),Gi===Ei&&"none"!==r&&(zi=Ti(zi,r,!Wi)),ji=a.measureText(zi).width,n&&(n<0&&(Yi=ji),ji+=n),Vi=Gi===Pi&&(Xi===Pi||Xi===Ei)||Xi===Pi&&Gi!==Mi,Ni=!(Gi!==Ri&&Gi!==Pi||Xi!==Ci&&Xi!==Mi),Fi=Hi&&o?h-o:h,t&&h&&Ii+Wi+ji>Fi&&(i?(Wi&&Ji(),Ii&&ts()):(Ni||(Ni=Gi===Ei&&Xi==Mi),Vi||Ni||Gi===Ai||Gi===Ri||Gi===Pi||Wi+ji>Fi?(Wi&&Ji(),Ii&&ts()):Ii&&ts()))," "===zi&&!0!==Hi&&Ii+Wi===0||(Gi===Ai?(" "===zi&&Wi&&Ji(),Zi(zi,ji),Ji()):Vi||Ni?(Wi&&Ji(),Zi(zi,ji)):Zi(zi,ji)),Xi=Gi);Wi&&Ji(),Ii&&ts(),$i.length>0&&($i[$i.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{qi.paraNumber++,Ii=a.measureText(t).width,$i.push({x:o||0,text:t,width:Ii,paraStart:!0}),Qi&&es()})}(l,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":rs(e,"x",t[os]);break;case"right":rs(e,"x",-t[ss])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":rs(e,"y",t[is]);break;case"bottom":rs(e,"y",-t[ns])}}(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:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&_>w)_=Math.max(e.__autoHeight?_:w,o),n>1&&(t.overflow=n);else if(w||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>_&&(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=_}(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,_=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=_>1?d/(_-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?(w={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,w),(t.isOverflow||" "!==w.char)&&t.data.push(w)):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===_-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){const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(r&&o.splice(r),n&&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,M(o)?(i=o.type,o.color&&(t.decorationColor=q.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 hs={string:function(t,e){if(!t)return"#000";const i=I(e)&&e<1;if(s(t)){if(!i||!q.object)return t;t=q.object(t)}let n=r(t.a)?1:t.a;i&&(n*=e);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};Object.assign(Z,as),Object.assign(q,hs),Object.assign(N,Xt),Object.assign(H,Se),Object.assign(K,Ye),Object.assign(Q,ii),Object.assign(l,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new V}),st();export{Bt as Interaction,wt as Layouter,it as LeaferCanvas,J as PathNodeHandleType,bt as Picker,mt as Renderer,St as Selector,ot as Watcher,st as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,isString as s,DataHelper as n,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as a,canvasPatch as h,Creator as l,LeaferImage as c,defineKey as d,FileHelper as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as w,PropertyEvent as _,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 T,PointHelper as B,BoundsHelper as E,Plugin as P,MathHelper as R,isObject as M,FourNumberHelper as C,Matrix as A,ImageEvent as D,MatrixHelper as O,AlignHelper as W,isNumber as I,getMatrixData as F,AroundHelper as z,OneRadian as j,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{InteractionHelper as Y,InteractionBase as G,Cursor as X,HitCanvasManager as V}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as N,PaintImage as H,ColorConvert as q,PaintGradient as K,Effect as Q,Group as $,TextConvert as Z}from"@leafer-ui/draw";var J;function tt(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(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(J||(J={})),"function"==typeof SuppressedError&&SuppressedError;const et=t.get("LeaferCanvas");class it 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",this.view.classList.add("leafer-canvas-view")}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 et.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;s.width=t+"px",s.height=e+"px",this.unreal||(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),et.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={};n.copyAttrs(e,this,o),this.resize(t),this.resizeListener&&!r(this.width)&&this.resizeListener(new a(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}}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=u.mimeType(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,u.mimeType(e),i)),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(u.mimeType(u.fileType(e)),s);return i.origin.download(n,e)},download(t,e){return tt(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,e,s)=>new Promise((s,n)=>{const o=new i.origin.Image;e&&(o.setAttribute("crossOrigin",e),o.crossOrigin=e),o.onload=()=>{s(o)},o.onerror=t=>{n(t)},o.src=i.image.getRealURL(t)}),loadContent(t){return tt(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=l.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}h(CanvasRenderingContext2D.prototype),h(Path2D.prototype),Object.assign(l,{canvas:(t,e)=>new it(t,e),image:t=>new c(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},d(i,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(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=n.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.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(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 w(w.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_([[_.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[w.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 wt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new S,this.target=t,e&&(this.config=n.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(w.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)),wt.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),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],[w.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const _t=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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=n.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(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,_t.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,_t.error(t)}_t.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return _t.warn("rendering");if(this.times>3)return _t.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(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=L.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(mt.clipSpread).ceil();const{ceilPartPixel:o}=this.config;i.clipWorld(s,o),i.clearWorld(s,o),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,e){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;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||_t.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}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 vt={},{copyRadiusPoint:yt}=B,{hitRadiusPoint:xt}=E;class bt{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,n;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],n=i.__,n.visible&&(!e||n.mask))if(s=xt(i.__world,n.hitRadius?yt(vt,o,n.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o)}}else s&&this.hitChild(i,o)}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 St{constructor(t,e){this.config={},e&&(this.config=n.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=l.finder&&l.finder(t,this.config)}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):P.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(l,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new St(t,e)}),i.layout=wt.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 kt={convert(t,e){const i=Y.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=Y.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=kt.getTouch(t),s=Y.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]},Lt={convert(t){const e=Y.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Tt}=Y;class Bt extends G{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}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),this.windowTarget.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)this.windowTarget.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&&(!this.config.shadowDOM||!t.composedPath||!t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(Lt.convert(t))}onKeyUp(t){this.keyUp(Lt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(kt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(kt.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=kt.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(kt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(kt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(kt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(kt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=kt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Tt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(kt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=kt.getTouch(t);this.pointerMove(kt.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=kt.getTouch(t);this.pointerUp(kt.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(Y.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},Y.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=Y.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),M(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>M(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)&&X.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 Et(t,e,i){t.__.__font?N.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Pt(t,e,i,s,n){const o=i.__;M(t)?N.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&N.strokeArrow(t,i,s,n)}function Rt(t,e,i,s,n){const o=i.__;M(t)?N.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),N.drawTextStroke(i,s,n))}function Mt(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Rt(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",N.fillText(i,o,n),o.blendMode="normal",m.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}const{getSpread:Ct,copyAndSpread:At,toOuterOf:Dt,getOuterOf:Ot,getByMove:Wt,move:It,getIntersectData:Ft}=E,zt={};let jt;const{stintSet:Ut}=n,{hasTransparent:Yt}=q;function Gt(t,e,i){if(!M(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout,{type:a}=e;switch(a){case"image":case"film":case"video":if(!e.url)return;n=H.image(i,t,e,o,!jt||!jt[e.url]),"image"!==a&&H[a](n);break;case"linear":n=K.linearGradient(e,o);break;case"radial":n=K.radialGradient(e,o);break;case"angular":n=K.conicGradient(e,o);break;case"solid":const{color:s,opacity:h}=e;n={type:a,style:q.string(s,h)};break;default:r(e.r)||(n={type:"solid",style:q.string(e)})}if(n&&(n.originPaint=e,s(n.style)&&Yt(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const Xt={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];b(a)||(a=[a]),jt=H.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Gt(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?(Ut(i,"__isAlphaPixelFill",n),Ut(i,"__isTransparentFill",o)):(Ut(i,"__isAlphaPixelStroke",n),Ut(i,"__isTransparentStroke",o),Ut(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Et(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,o.scaleFixed,!1);1!==t&&i.scale(t,s)}o.blendMode&&(i.blendMode=o.blendMode),Et(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Et(e,i,s),i.restoreBlendMode()):Et(e,i,s)}},fillPathOrText:Et,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)N.strokeText(t,e,i,s);else if(n.__pathForStroke)N.fillStroke(t,e,i,s);else switch(n.strokeAlign){case"center":Pt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Pt(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)Pt(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),Pt(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){N.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Rt(t,1,e,i,s);break;case"inside":Mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Rt(t,2,e,i,s):Mt(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?N.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?N.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;Dt(a.strokeSpread?(At(zt,a.boxBounds,a.strokeSpread),zt):a.boxBounds,r,h);let{scaleX:g,scaleY:w}=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?Ct(o,C.swapAndScale(a.renderShapeSpread,g,w)):o;n=Ft(t,h)}u=o.getFitMatrix(n);let{a:_,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=_,w*=m),f=Ot(h,u),l=Wt(f,-u.e,-u.f),c=Ot(r,u),It(c,-u.e,-u.f);const v=s.matrix;v?(d=new A(u),d.multiply(v),_*=v.scaleX,m*=v.scaleY):d=u,d.withScale(_,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:w}}};let Vt,Nt=new x;const{isSame:Ht}=E;function qt(t,e,i,s,n,o){let r=!0;const a=t.__;if("fill"!==e||a.__naturalWidth||(a.__naturalWidth=s.width/a.pixelRatio,a.__naturalHeight=s.height/a.pixelRatio,a.__autoSide&&(t.forceUpdate("width"),m.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",a.width),t.setProxyAttr("height",a.height)),r=!1)),!n.data){H.createData(n,s,i,o);const{transform:t}=n.data,{opacity:e,blendMode:r}=i,h=t&&!t.onlyScale||a.path||a.cornerRadius;(h||e&&e<1||r)&&(n.complex=!h||2)}return i.filter&&H.applyFilter(n,s,i.filter,t),r}function Kt(t,e){Zt(t,D.LOAD,e)}function Qt(t,e){Zt(t,D.LOADED,e)}function $t(t,e,i){e.error=i,t.forceUpdate("surface"),Zt(t,D.ERROR,e)}function Zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function Jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:te,translate:ee}=O,ie=new x,se={},ne={};function oe(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 re={},ae=F();const{get:he,set:le,rotateOfOuter:ce,translate:de,scaleOfOuter:ue,multiplyParent:fe,scale:pe,rotate:ge,skew:we}=O;function _e(t,e,i,s,n,o,r,a){r&&ge(t,r),a&&we(t,a.x,a.y),n&&pe(t,n,o),de(t,e.x+i,e.y+s)}const{get:me,scale:ve,copy:ye}=O,{getFloorScale:xe}=R,{abs:be}=Math;const Se={image:function(t,e,i,s,n){let o,r;const a=T.get(i,i.type);return Vt&&i===Vt.paint&&Ht(s,Vt.boxBounds)?o=Vt.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Vt=a.use>1?{leafPaint:o,paint:i,boxBounds:Nt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(qt(t,e,i,a,o,s),n&&(Kt(t,r),Qt(t,r))):a.error?n&&$t(t,r,a.error):(n&&(Jt(t,!0),Kt(t,r)),o.loadId=a.load(()=>{Jt(t,!1),t.destroyed||(qt(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,r)),o.loadId=void 0},e=>{Jt(t,!1),$t(t,r,e),o.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),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:a}=H.getImageRenderScaleData(t,s,n,o),h=t.film?t.nowIndex:r+"-"+a,{image:l,data:c,originPaint:d}=t,{exporting:u,snapshot:f}=o;return!(!c||t.patternId===h&&!u||f)&&(e&&(c.repeat?e=!1:d.changeful||t.film||"miniapp"===i.name||u||(e=i.image.isLarge(l,r,a)||l.width*r>8096||l.height*a>8096)),e?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),H.drawImage(t,r,a,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,complex:h}=t;let{width:l,height:c}=a;if(h){const{blendMode:o,opacity:d}=t.originPaint,{transform:u}=r;n.save(),2===h&&n.clipUI(s),o&&(n.blendMode=o),d&&(n.opacity*=d),u&&n.transform(u),a.render(n,0,0,l,c,s,t,e,i),n.restore()}else r.scaleX&&(l*=r.scaleX,c*=r.scaleY),a.render(n,0,0,l,c,s,t,e,i)},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.recyclePaint(s),e.__willDestroy&&n.parent&&H.recycleFilter(n,e.__leaf),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(()=>tt(this,void 0,void 0,function*(){H.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:o,scaleY:r}=H.getImageRenderScaleData(t,e,s,n),a=t.film?t.nowIndex:o+"-"+r;if(t.patternId!==a&&!e.destroyed&&(!i.image.isLarge(t.image,o,r)||t.data.repeat)){const{image:s,data:n}=t,{opacity:h}=t.originPaint,{transform:l,gap:c}=n,d=H.getPatternFixScale(t,o,r);let u,f,p,{width:g,height:w}=s;d&&(o*=d,r*=d),g*=o,w*=r,c&&(f=c.x*o/be(n.scaleX||1),p=c.y*r/be(n.scaleY||1)),(l||1!==o||1!==r)&&(o*=xe(g+(f||0)),r*=xe(w+(p||0)),u=me(),l&&ye(u,l),ve(u,1/o,1/r));const _=s.getCanvas(g,w,h,void 0,f,p,e.leafer&&e.leafer.config.smooth,n.interlace),m=s.getPattern(_,n.repeat||i.origin.noRepeat||"no-repeat",u,t);t.style=m,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=ie.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:n,height:o}=i,{mode:r,align:a,offset:h,scale:l,size:c,rotation:d,skew:u,clipSize:f,repeat:p,gap:g,interlace:w}=t,_=e.width===n&&e.height===o,m={mode:r},v="center"!==a&&(d||0)%180==90;let y,x;switch(E.set(ne,0,0,v?o:n,v?n:o),r&&"cover"!==r&&"fit"!==r?((l||c)&&(R.getScaleData(l,c,i,se),y=se.scaleX,x=se.scaleY),(a||g||p)&&(y&&E.scale(ne,y,x,!0),a&&W.toPoint(a,ne,e,ne,!0,!0))):_&&!d||(y=x=E.getFitScale(e,ne,"fit"!==r),E.put(e,i,a,y,!1,ne),E.scale(ne,y,x,!0)),h&&B.move(ne,h),r){case"stretch":_?y&&(y=x=void 0):(y=e.width/n,x=e.height/o,H.stretchMode(m,e,y,x));break;case"normal":case"clip":if(ne.x||ne.y||y||f||d||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),H.clipMode(m,e,ne.x,ne.y,y,x,d,u,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||d||u)&&H.repeatMode(m,e,n,o,ne.x,ne.y,y,x,d,u,a,t.freeTransform),p||(m.repeat="repeat");const i=M(p);(g||i)&&(m.gap=function(t,e,i,s,n){let o,r;M(t)?(o=t.x,r=t.y):o=r=t;return{x:oe(o,i,n.width,e&&e.x),y:oe(r,s,n.height,e&&e.y)}}(g,i&&p,ne.width,ne.height,e));break;default:y&&H.fillOrFitMode(m,e,ne.x,ne.y,y,x,d)}return m.transform||(e.x||e.y)&&ee(m.transform=te(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),p&&(m.repeat=s(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),w&&(m.interlace=I(w)||"percent"===w.type?{type:"x",offset:w}:w),m},stretchMode:function(t,e,i,s){const n=he(),{x:o,y:r}=e;o||r?de(n,o,r):i>0&&s>0&&(n.onlyScale=!0),pe(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=he();de(a,e.x+i,e.y+s),pe(a,n,o),r&&ce(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=he();_e(c,e,i,s,n,o,r,a),h&&(r||a?(le(ae),ue(ae,e,h,l),fe(c,ae)):ue(c,e,h,l)),t.transform=c},repeatMode:function(t,e,i,s,n,o,r,a,h,l,c,d){const u=he();if(d)_e(u,e,n,o,r,a,h,l);else{if(h)if("center"===c)ce(u,{x:i/2,y:s/2},h);else switch(ge(u,h),h){case 90:de(u,s,0);break;case 180:de(u,i,s);break;case 270:de(u,0,i)}re.x=e.x+n,re.y=e.y+o,de(u,re.x,re.y),r&&ue(u,re,r,a)}t.transform=u}},{toPoint:ke}=z,{hasTransparent:Le}=q,Te={},Be={};function Ee(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=q.string(o,n)):(a=o.offset,r=q.string(o.color,n)),e.addColorStop(a,r),!h&&Le(r)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Pe,getDistance:Re}=B,{get:Me,rotateOfOuter:Ce,scaleOfOuter:Ae}=O,{toPoint:De}=z,Oe={},We={};function Ie(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Pe(e,i);o=Me(),n?(Ae(o,e,r/a*(s||1),1),Ce(o,e,t+90)):(Ae(o,e,1,r/a*(s||1)),Ce(o,e,t))}return o}const{getDistance:Fe}=B,{toPoint:ze}=z,je={},Ue={};const Ye={linearGradient:function(t,e){let{from:s,to:n,type:o,opacity:r}=t;ke(s||"top",e,Te),ke(n||"bottom",e,Be);const a=i.canvas.createLinearGradient(Te.x,Te.y,Be.x,Be.y),h={type:o,style:a};return Ee(h,a,t.stops,r),h},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,stretch:a}=t;De(s||"center",e,Oe),De(n||"bottom",e,We);const h=i.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Re(Oe,We)),l={type:o,style:h};Ee(l,h,t.stops,r);const c=Ie(e,Oe,We,a,!0);return c&&(l.transform=c),l},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,rotation:a,stretch:h}=t;ze(s||"center",e,je),ze(n||"bottom",e,Ue);const l=i.conicGradientSupport?i.canvas.createConicGradient(a?a*j:0,je.x,je.y):i.canvas.createRadialGradient(je.x,je.y,0,je.x,je.y,Fe(je,Ue)),c={type:o,style:l};Ee(c,l,t.stops,r);const d=Ie(e,je,Ue,h||1,i.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Ie},{copy:Ge,move:Xe,toOffsetOutBounds:Ve}=E,{max:Ne,abs:He}=Math,qe={},Ke=new A,Qe={};function $e(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=Ne(r,n+o-s),a=Ne(a,n+o+i),h=Ne(h,n+o+s),l=Ne(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function Ze(t,e,s){const{shapeBounds:n}=s;let o,r;i.fullImageShadow?(Ge(qe,t.bounds),Xe(qe,e.x-n.x,e.y-n.y),o=t.bounds,r=qe):(o=n,r=e),t.copyWorld(s.canvas,o,r)}const{toOffsetOutBounds:Je}=E,ti={};const ei=$e;const ii={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;Ve(h,Qe,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.setWorldShadow(Qe.offsetX+(r.x||0)*d*w,Qe.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w,q.string(r.color)),n=Q.getShadowTransform(t,f,i,r,Qe,w),n&&f.setTransform(n),Ze(f,Qe,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;Je(h,ti,l),r.forEach((r,g)=>{let w=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}f.save(),f.setWorldShadow(ti.offsetX+(r.x||0)*d*w,ti.offsetY+(r.y||0)*u*w,(r.blur||0)*d*w),n=Q.getShadowTransform(t,f,i,r,ti,w,!0),n&&f.setTransform(n),Ze(f,ti,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,q.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:$e,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 Ke.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),Ke}},isTransformShadow(t){},getInnerShadowSpread:ei},{excludeRenderBounds:si}=y;let ni;function oi(t,e,i,s,n,o,r,a){switch(e){case"grayscale":ni||(ni=!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);ai(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":ai(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function ri(t){return t.getSameCanvas(!1,!0)}function ai(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)}$.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&&(oi(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||si(i,e)||i.__render(t,e),o=i.__.opacity,ni=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=ri(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=ri(t)),n||(n=ri(t)),i.__render(s,e));continue}const c=1===o&&i.__.__blendMode;c&&oi(this,r,t,n,s,o,void 0,!1),si(i,e)||i.__render(n||t,e),c&&oi(this,r,t,n,s,o,c,!1)}oi(this,r,t,n,s,o,void 0,!0)};const hi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",li=hi+"_#~&*+\\=|≮≯≈≠=…",ci=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function di(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ui=di("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fi=di("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=di(hi),gi=di(li),wi=di("- —/~|┆·");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:mi,Single:vi,Before:yi,After:xi,Symbol:bi,Break:Si}=_i;function ki(t){return ui[t]?mi:wi[t]?Si:fi[t]?yi:pi[t]?xi:gi[t]?bi:ci.test(t)?vi:mi}const Li={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 Ti(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Bi}=Li,{Letter:Ei,Single:Pi,Before:Ri,After:Mi,Symbol:Ci,Break:Ai}=_i;let Di,Oi,Wi,Ii,Fi,zi,ji,Ui,Yi,Gi,Xi,Vi,Ni,Hi,qi,Ki,Qi,$i=[];function Zi(t,e){Yi&&!Ui&&(Ui=Yi),Di.data.push({char:t,width:e}),Wi+=e}function Ji(){Ii+=Wi,Di.width=Wi,Oi.words.push(Di),Di={data:[]},Wi=0}function ts(){Hi&&(qi.paraNumber++,Oi.paraStart=!0,Hi=!1),Yi&&(Oi.startCharSize=Ui,Oi.endCharSize=Yi,Ui=0),Oi.width=Ii,Ki.width?Bi(Oi):Qi&&es(),$i.push(Oi),Oi={words:[]},Ii=0}function es(){Ii>(qi.maxWidth||0)&&(qi.maxWidth=Ii)}const{top:is,right:ss,bottom:ns,left:os}=U;function rs(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const as={getDrawData:function(t,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[os],r-=h[ss]+h[os],!r&&(r=.01)):e.autoSizeAlign||(n=h[os]),a?(o=h[is],a-=h[is]+h[ns],!a&&(a=.01)):e.autoSizeAlign||(o=h[is]));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){qi=t,$i=t.rows,Ki=t.bounds,Qi=!Ki.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h}=Ki;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Hi=!0,Xi=null,Ui=ji=Yi=Wi=Ii=0,Di={data:[]},Oi={words:[]};for(let s=0,l=(e=[...e]).length;s<l;s++)zi=e[s],"\n"===zi?(Wi&&Ji(),Oi.paraEnd=!0,ts(),Hi=!0):(Gi=ki(zi),Gi===Ei&&"none"!==r&&(zi=Ti(zi,r,!Wi)),ji=a.measureText(zi).width,n&&(n<0&&(Yi=ji),ji+=n),Vi=Gi===Pi&&(Xi===Pi||Xi===Ei)||Xi===Pi&&Gi!==Mi,Ni=!(Gi!==Ri&&Gi!==Pi||Xi!==Ci&&Xi!==Mi),Fi=Hi&&o?h-o:h,t&&h&&Ii+Wi+ji>Fi&&(i?(Wi&&Ji(),Ii&&ts()):(Ni||(Ni=Gi===Ei&&Xi==Mi),Vi||Ni||Gi===Ai||Gi===Ri||Gi===Pi||Wi+ji>Fi?(Wi&&Ji(),Ii&&ts()):Ii&&ts()))," "===zi&&!0!==Hi&&Ii+Wi===0||(Gi===Ai?(" "===zi&&Wi&&Ji(),Zi(zi,ji),Ji()):Vi||Ni?(Wi&&Ji(),Zi(zi,ji)):Zi(zi,ji)),Xi=Gi);Wi&&Ji(),Ii&&ts(),$i.length>0&&($i[$i.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{qi.paraNumber++,Ii=a.measureText(t).width,$i.push({x:o||0,text:t,width:Ii,paraStart:!0}),Qi&&es()})}(l,t,e),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":rs(e,"x",t[os]);break;case"right":rs(e,"x",-t[ss])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":rs(e,"y",t[is]);break;case"bottom":rs(e,"y",-t[ns])}}(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:w}=s,_=o*n+(d?d*(t.paraNumber-1):0),m=r;if(h&&_>w)_=Math.max(e.__autoHeight?_:w,o),n>1&&(t.overflow=n);else if(w||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>_&&(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=_}(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,_=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=_>1?d/(_-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?(w={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,w),(t.isOverflow||" "!==w.char)&&t.data.push(w)):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===_-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){const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(r&&o.splice(r),n&&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,M(o)?(i=o.type,o.color&&(t.decorationColor=q.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 hs={string:function(t,e){if(!t)return"#000";const i=I(e)&&e<1;if(s(t)){if(!i||!q.object)return t;t=q.object(t)}let n=r(t.a)?1:t.a;i&&(n*=e);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};Object.assign(Z,as),Object.assign(q,hs),Object.assign(N,Xt),Object.assign(H,Se),Object.assign(K,Ye),Object.assign(Q,ii),Object.assign(l,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new V}),st();export{Bt as Interaction,wt as Layouter,it as LeaferCanvas,J as PathNodeHandleType,bt as Picker,mt as Renderer,St as Selector,ot as Watcher,st as useCanvas};
2
2
  //# sourceMappingURL=web.esm.min.js.map