leafer-ui 1.3.2 → 1.3.3
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 +14 -4
- package/dist/web.cjs +5 -5
- package/dist/web.esm.js +5 -5
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +183 -179
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +183 -179
- package/dist/web.module.min.js +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
## 场景包
|
|
32
32
|
|
|
33
|
-
高效绘图场景,推荐直接安装更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/install/draw/start.html) (
|
|
33
|
+
高效绘图场景,推荐直接安装更轻量的 [leafer-draw](https://leaferjs.com/ui/guide/install/draw/start.html) (50KB min+gzip)。
|
|
34
34
|
|
|
35
35
|
游戏开发场景,推荐直接安装更省心的 [leafer-game](https://leaferjs.com/ui/guide/install/game/start.html),已集成了游戏相关插件。
|
|
36
36
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
## 互动交流
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
有 Bug、建议可以 [提交 issue](https://github.com/leaferjs/leafer-ui/issues),留下你的贡献足迹,了解 [提问的智慧](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)
|
|
42
42
|
。
|
|
43
43
|
|
|
44
44
|
欢迎加入 [技术交流群](https://leaferjs.com/#contact) ,与小伙伴们建立联系,共同学习进步,偶尔会有特殊福利。
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
|
|
58
58
|
[test](https://github.com/leaferjs/test) 自动化测试仓库。
|
|
59
59
|
|
|
60
|
+
[code](https://github.com/leaferjs/code) 示例代码仓库。
|
|
61
|
+
|
|
62
|
+
[docs](https://github.com/leaferjs/docs) 在线文档仓库。
|
|
63
|
+
|
|
60
64
|
## 使命与愿景
|
|
61
65
|
|
|
62
66
|
LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标准,表现力丰富,便于 AI 理解,人类可视化使用,并为数字化产品开发提供跨平台、轻量化、高性能的运行时。
|
|
@@ -137,7 +141,13 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
|
|
|
137
141
|
</p>
|
|
138
142
|
<p><h3 align="center">银牌赞助</h3></p>
|
|
139
143
|
<p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 5px;">
|
|
140
|
-
<a target="_blank" href="https://
|
|
144
|
+
<a target="_blank" href="https://frameelf.com/">
|
|
145
|
+
<img width="40" title="边框水印精灵" src="https://www.leaferjs.com/image/sponsor/user/134.jpg" loading="lazy" />
|
|
146
|
+
</a>
|
|
147
|
+
<a target="_blank" href="">
|
|
148
|
+
<img width="40" title="Y" src="https://www.leaferjs.com/image/sponsor/user/131.jpg" loading="lazy" />
|
|
149
|
+
</a>
|
|
150
|
+
<a target="_blank" href="https://github.com/daodaolee">
|
|
141
151
|
<img width="40" title="道里" src="https://www.leaferjs.com/image/sponsor/user/108.jpg" loading="lazy" />
|
|
142
152
|
</a>
|
|
143
153
|
<a target="_blank" href="https://afdian.com/u/4c42d1dc97f311ef908752540025c377">
|
|
@@ -278,7 +288,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
|
|
|
278
288
|
</p>
|
|
279
289
|
<p><h3 align="center">铜牌赞助</h3></p>
|
|
280
290
|
<p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
|
|
281
|
-
|
|
291
|
+
张余🌈 Jerry 李狗嗨。💢 李维亮 朝夕 SaltedFish zhk 格子 等等 goosen 建伟F4nniu 梁福斌 江万江 杨超 ToB Dev 前端之虎陈随易 A☀️云☀️A ʚ LMT ɞ 爱发电用户_c9c82 轻简历 爱发电用户_0fac0 wangyesheji.cn 风间 爱发电用户_Tqsm 爱发电用户_6KpE dongdong zwm 爱发电用户_3725c Noth1ng 纳西妲の√ 爱发电用户_Ahb9 爱发电用户_7617d 冷漠 爱发电用户_9RXB 今日值得读 爱发电用户_49sT 爱发电用户_NFCS 爱发电用户_43ad8 爱发电用户_30455 xiaozhang 砖吐筷筷 爱发电用户_b47b3 longbow1998 爱发电用户_5d755 爱发电用户_b76b8 爱发电用户_e70c2 爱发电用户_039dc 花祁 爱发电用户_99f39 坤坤 爱发电用户_X6hp 爱发电用户_s5u9 曹吉美爸爸 啸沧海 Ronny Biu 王志强 PD.新城คิดถึง 糖颂缘冥倾 ALBERT. 爱发电用户_UXEV SaltedFish 爱发电用户_76f9d Leafer 爱发电用户_Pbm7 </p>
|
|
282
292
|
|
|
283
293
|
## License
|
|
284
294
|
|
package/dist/web.cjs
CHANGED
|
@@ -523,7 +523,7 @@ class Layouter {
|
|
|
523
523
|
}
|
|
524
524
|
partLayout() {
|
|
525
525
|
var _a;
|
|
526
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
526
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
527
527
|
return;
|
|
528
528
|
const t = core.Run.start('PartLayout');
|
|
529
529
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1906,7 +1906,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1906
1906
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1907
1907
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1908
1908
|
***************************************************************************** */
|
|
1909
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1909
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1910
1910
|
|
|
1911
1911
|
|
|
1912
1912
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -1967,7 +1967,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1967
1967
|
}
|
|
1968
1968
|
else {
|
|
1969
1969
|
if (!paint.patternTask) {
|
|
1970
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1970
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1971
1971
|
paint.patternTask = null;
|
|
1972
1972
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1973
1973
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -2123,7 +2123,7 @@ function shadow(ui, current, shape) {
|
|
|
2123
2123
|
const end = shadow.length - 1;
|
|
2124
2124
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
2125
2125
|
shadow.forEach((item, index) => {
|
|
2126
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
2126
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
|
|
2127
2127
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
2128
2128
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
2129
2129
|
copyBounds = bounds;
|
|
@@ -2199,7 +2199,7 @@ function innerShadow(ui, current, shape) {
|
|
|
2199
2199
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
2200
2200
|
copyBounds = bounds;
|
|
2201
2201
|
}
|
|
2202
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
2202
|
+
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
2203
2203
|
if (ui.__worldFlipped) {
|
|
2204
2204
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
2205
2205
|
}
|
package/dist/web.esm.js
CHANGED
|
@@ -524,7 +524,7 @@ class Layouter {
|
|
|
524
524
|
}
|
|
525
525
|
partLayout() {
|
|
526
526
|
var _a;
|
|
527
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
527
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
528
528
|
return;
|
|
529
529
|
const t = Run.start('PartLayout');
|
|
530
530
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1907,7 +1907,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1907
1907
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1908
1908
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1909
1909
|
***************************************************************************** */
|
|
1910
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1910
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1911
1911
|
|
|
1912
1912
|
|
|
1913
1913
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -1968,7 +1968,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1968
1968
|
}
|
|
1969
1969
|
else {
|
|
1970
1970
|
if (!paint.patternTask) {
|
|
1971
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1971
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1972
1972
|
paint.patternTask = null;
|
|
1973
1973
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1974
1974
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -2124,7 +2124,7 @@ function shadow(ui, current, shape) {
|
|
|
2124
2124
|
const end = shadow.length - 1;
|
|
2125
2125
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
2126
2126
|
shadow.forEach((item, index) => {
|
|
2127
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
2127
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, ColorConvert.string(item.color));
|
|
2128
2128
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
2129
2129
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
2130
2130
|
copyBounds = bounds;
|
|
@@ -2200,7 +2200,7 @@ function innerShadow(ui, current, shape) {
|
|
|
2200
2200
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
2201
2201
|
copyBounds = bounds;
|
|
2202
2202
|
}
|
|
2203
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
2203
|
+
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
2204
2204
|
if (ui.__worldFlipped) {
|
|
2205
2205
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
2206
2206
|
}
|
package/dist/web.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as r,Creator as a,LeaferImage as h,defineKey as l,FileHelper as c,LeafList as d,RenderEvent as u,ChildEvent as p,WatchEvent as g,PropertyEvent as f,LeafHelper as _,BranchHelper as w,Bounds as v,LeafBoundsHelper as y,LeafLevelList as m,LayoutEvent as b,Run as x,ImageManager as B,BoundsHelper as E,Plugin as L,MathHelper as k,MatrixHelper as T,AlignHelper as R,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as P,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint as V,Effect as Y}from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.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="string"==typeof 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 X.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.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){this.autoBounds=t;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),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,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.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:H,fileType:q}=c;function K(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,H(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(H(q(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=a.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new h(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Q.indexOf("Safari")>-1&&-1===Q.indexOf("Chrome")&&(i.fullImageShadow=!0),Q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?i.os="Mac":Q.indexOf("Linux")>-1&&(i.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;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 d,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new g(g.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(g.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity:tt}=_,{pushAllChildBranch:et,pushAllParent:it}=w;const{worldBounds:st}=y,nt={x:0,y:0,width:1e5,height:1e5};class ot{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),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:rt,updateAllChange:at}=_,ht=t.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(b.START),this.layoutOnce(),t.emitEvent(new b(b.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(g.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=b,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new b(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?(Z(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||J(s[t])}J(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new b(o,a,this.times)),i.emitEvent(new b(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=b,o=this.getBlocks(new d(e));e.emitEvent(new b(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new b(s,o,this.times)),e.emitEvent(new b(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(b.REQUEST,this.layout,this),t.on_(b.AGAIN,this.layoutAgain,this),t.on_(g.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(b.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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(e){const i=x.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=e.includes(this.target.__world),r=new v(n);s.save(),o&&!t.showRepaint?s.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0)),this.__render(n,o,r),s.restore(),x.end(i)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,s){const n=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(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 v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(b.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=E;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,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 d(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),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}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||_.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class gt{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,e,s){return i.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,e,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):L.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new gt(t,e)}),i.layout=lt.fullLayout;const ft={convert(t,e){const i=O.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=O.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=ft.getTouch(t),s=O.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},_t={convert(t){const e=O.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:wt}=O;class vt extends P{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(_t.convert(t))}onKeyUp(t){this.keyUp(_t.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(ft.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(ft.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(ft.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(ft.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(ft.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(ft.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(ft.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=ft.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&wt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(ft.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=ft.getTouch(t);this.pointerMove(ft.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=ft.getTouch(t);this.pointerUp(ft.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||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(O.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({},O.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=O.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(k.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),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&W.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function mt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):xt(e,i);break;case"inside":bt("inside",t,n,e,i);break;case"outside":bt("outside",t,n,e,i)}}function bt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?Bt(e,!0,s,a):xt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",yt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function xt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Bt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?xt(i,s):s.stroke(),s.restoreBlendMode()):e?xt(i,s):s.stroke())}function Et(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Lt,getOuterOf:kt,getByMove:Tt,getIntersectData:Rt}=E;let St;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!St||!St[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Mt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yt(e,i):n?i.fill(n):i.fill())},fillText:yt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),Bt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=Rt(s?Lt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=kt(n,r),o=Tt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let At={};const{get:Ot,rotateOfOuter:Pt,translate:Wt,scaleOfOuter:Dt,scale:It,rotate:zt}=T;function Ft(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),It(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function jt(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),n&&It(a,n,o),r&&zt(a,r),t.transform=a}function Gt(t,e,i,s,n,o,r,a,h,l){const c=Ot();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(zt(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}At.x=e.x+n,At.y=e.y+o,Wt(c,At.x,At.y),r&&Dt(c,At,r,a),t.transform=c}const{get:Ut,translate:Vt}=T,Yt=new v,Xt={},Nt={};function Ht(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=qt(i,s,e)}function qt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u}=t,p=e.width===s&&e.height===n,g={mode:r},f="center"!==a&&(d||0)%180==90,_=f?n:s,w=f?s:n;let v,y,m=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(k.getScaleData(l,c,i,Nt),v=Nt.scaleX,y=Nt.scaleY);else if(!p||d){const t=e.width/_,i=e.height/w;v=y="fit"===r?Math.min(t,i):Math.max(t,i),m+=(e.width-s*v)/2,b+=(e.height-n*y)/2}if(a){const t={x:m,y:b,width:_,height:w};v&&(t.width*=v,t.height*=y),R.toPoint(a,t,e,Xt,!0),m+=Xt.x,b+=Xt.y}switch(h&&(m+=h.x,b+=h.y),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(m||b||v||d)&&jt(g,e,m,b,v,y,d);break;case"repeat":(!p||v||d)&&Gt(g,e,s,n,m,b,v,y,d,a),u||(g.repeat="repeat");break;default:v&&Ft(g,e,m,b,v,y,d)}return g.transform||(e.x||e.y)&&(g.transform=Ut(),Vt(g.transform,e.x,e.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Kt,Qt=new v;const{isSame:$t}=E;function Zt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ht(n,s,i,o),!0}function Jt(t,e){ie(t,S.LOAD,e)}function te(t,e){ie(t,S.LOADED,e)}function ee(t,e,i){e.error=i,t.forceUpdate("surface"),ie(t,S.ERROR,e)}function ie(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:oe,copy:re}=T,{ceil:ae,abs:he}=Math;function le(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{n=he(n),o=he(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,opacity:g,transform:f,repeat:_}=a;u&&(l=ne(),re(l,f),oe(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const w=c*d;if(!_&&w>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}w>v&&(h=Math.sqrt(w/v)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=ne(),f&&re(l,f)),oe(l,1/n,1/o));const y=t.getCanvas(ae(c)||1,ae(d)||1,g),m=t.getPattern(y,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function ce(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const ue={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return Kt&&i===Kt.paint&&$t(s,Kt.boxBounds)?o=Kt.leafPaint:(o={type:i.type,image:a},Kt=a.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Zt(t,e,i,a,o,s),n&&(Jt(t,r),te(t,r))):a.error?n&&ee(t,r,a.error):(n&&(se(t,!0),Jt(t,r)),o.loadId=a.load((()=>{se(t,!1),t.destroyed||(Zt(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),te(t,r)),o.loadId=null}),(e=>{se(t,!1),ee(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:a}=e;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!j.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:e}=h;t*=de(o)*a,e*=de(r)*a,h.scaleX&&(t*=h.scaleX,e*=h.scaleY),n=t*e>i.image.maxCacheSize||j.running}return n?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),s.blendMode&&(e.blendMode=s.blendMode),h.opacity&&(e.opacity*=h.opacity),h.transform&&e.transform(h.transform),e.drawImage(s.image.view,0,0,h.width,h.height),e.restore(),!0):(!s.style||s.sync||j.running?le(t,s,a):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ce(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&le(t,s,a),t.forceUpdate("surface")}))),300)),!1)}},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:Ht,getPatternData:qt,fillOrFitMode:Ft,clipMode:jt,repeatMode:Gt},{toPoint:pe}=M,ge={},fe={};function _e(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:we,getDistance:ve}=C,{get:ye,rotateOfOuter:me,scaleOfOuter:be}=T,{toPoint:xe}=M,Be={},Ee={};function Le(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=we(e,i);o=ye(),n?(be(o,e,r/a*(s||1),1),me(o,e,t+90)):(be(o,e,1,r/a*(s||1)),me(o,e,t))}return o}const{getDistance:ke}=C,{toPoint:Te}=M,Re={},Se={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;pe(s||"top",e,ge),pe(n||"bottom",e,fe);const h=i.canvas.createLinearGradient(ge.x,ge.y,fe.x,fe.y);_e(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;xe(s||"center",e,Be),xe(n||"bottom",e,Ee);const l=i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ve(Be,Ee));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Be,Ee,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Te(s||"center",e,Re),Te(n||"bottom",e,Se);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Re.x,Re.y):i.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Se));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Re,Se,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Le},{copy:Ce,toOffsetOutBounds:Ae}=E,Oe={},Pe={};function We(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ce(Oe,t.bounds),Oe.x+=e.x-r.x,Oe.y+=e.y-r.y,s){const{matrix:t}=n;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ce(Oe,e),Oe.x-=e.width/2*(s-1),Oe.y-=e.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:e)}const{toOffsetOutBounds:De}=E,Ie={};const ze={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;Ae(l,Pe),a.forEach(((a,f)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;De(l,Ie),a.forEach(((a,f)=>{p.save(),p.setWorldShadow(Ie.offsetX+a.x*d,Ie.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Ie,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Fe}=y;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}G.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++)i=h[l],a=i.__.mask,a&&(r&&(je(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Fe(i,e)||i.__render(n||t,e);je(this,r,t,n,s,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ve+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const He=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ne(Ve),Qe=Ne(Ye),$e=Ne("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Je,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ze;function oi(t){return He[t]?Je:$e[t]?ni:qe[t]?ei:Ke[t]?ii:Qe[t]?si:Xe.test(t)?ti:Je}const ri={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 ai(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:hi}=ri,{Letter:li,Single:ci,Before:di,After:ui,Symbol:pi,Break:gi}=Ze;let fi,_i,wi,vi,yi,mi,bi,xi,Bi,Ei,Li,ki,Ti,Ri,Si,Mi,Ci,Ai=[];function Oi(t,e){Bi&&!xi&&(xi=Bi),fi.data.push({char:t,width:e}),wi+=e}function Pi(){vi+=wi,fi.width=wi,_i.words.push(fi),fi={data:[]},wi=0}function Wi(){Ri&&(Si.paraNumber++,_i.paraStart=!0,Ri=!1),Bi&&(_i.startCharSize=xi,_i.endCharSize=Bi,xi=0),_i.width=vi,Mi.width?hi(_i):Ci&&Di(),Ai.push(_i),_i={words:[]},vi=0}function Di(){vi>(Si.maxWidth||0)&&(Si.maxWidth=vi)}const Ii=0,zi=1,Fi=2;const{top:ji,right:Gi,bottom:Ui,left:Vi}=A;function Yi(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 Xi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=e;l&&(o?(s=l[Vi],o-=l[Gi]+l[Vi]):e.autoSizeAlign||(s=l[Vi]),r?(n=l[ji],r-=l[ji]+l[Ui]):e.autoSizeAlign||(n=l[ji]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Si=t,Ai=t.rows,Mi=t.bounds,Ci=!Mi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Mi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ri=!0,Li=null,xi=bi=Bi=wi=vi=0,fi={data:[]},_i={words:[]};for(let s=0,l=e.length;s<l;s++)mi=e[s],"\n"===mi?(wi&&Pi(),_i.paraEnd=!0,Wi(),Ri=!0):(Ei=oi(mi),Ei===li&&"none"!==r&&(mi=ai(mi,r,!wi)),bi=a.measureText(mi).width,n&&(n<0&&(Bi=bi),bi+=n),ki=Ei===ci&&(Li===ci||Li===li)||Li===ci&&Ei!==ui,Ti=!(Ei!==di&&Ei!==ci||Li!==pi&&Li!==ui),yi=Ri&&o?h-o:h,t&&h&&vi+wi+bi>yi&&(i?(wi&&Pi(),vi&&Wi()):(Ti||(Ti=Ei===li&&Li==ui),ki||Ti||Ei===gi||Ei===di||Ei===ci||wi+bi>yi?(wi&&Pi(),vi&&Wi()):vi&&Wi()))," "===mi&&!0!==Ri&&vi+wi===0||(Ei===gi?(" "===mi&&wi&&Pi(),Oi(mi,bi),Pi()):ki||Ti?(wi&&Pi(),Oi(mi,bi)):Oi(mi,bi)),Li=Ei);wi&&Pi(),vi&&Wi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Si.paraNumber++,vi=a.measureText(t).width,Ai.push({x:o||0,text:t,width:vi,paraStart:!0}),Ci&&Di()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Vi]);break;case"right":Yi(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[ji]);break;case"bottom":Yi(e,"y",-t[Ui])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:c,autoSizeAlign:d}=e;let{x:u,y:p,width:g,height:f}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(a&&_>f)_=Math.max(f,n),t.overflow=i.length;else if(f||d)switch(l){case"middle":p+=(f-_)/2;break;case"bottom":p+=f-_}w+=p;let v,y,m,b=g||d?g:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(v=i[o],v.x=u,v.width<g||v.width>g&&!a)switch(h){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&o>0&&(w+=c),v.y=w,w+=n,t.overflow>o&&w>_&&(v.isOverflow=!0,t.overflow=o+1),y=v.x,m=v.width,r<0&&(v.width<0?(m=-v.width+e.fontSize+r,y-=m,m+=e.fontSize):m-=r),y<s.x&&(s.x=y),m>s.width&&(s.width=m),a&&g&&g<m&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(c,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,c,d,u;n.forEach((t=>{t.words&&(c=r&&t.paraStart?r:0,l=i&&("justify"===o||"both"===o)&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,d=a||t.isOverflow?Ii:l>.01?zi:Fi,t.isOverflow&&!a&&(t.textMode=!0),d===Fi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{d===zi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==o||(h+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){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)}}))}}(c,e,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Ni={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Xi),Object.assign(z,Ni),Object.assign(V,Ct),Object.assign(I,ue),Object.assign(F,Me),Object.assign(Y,ze),Object.assign(a,{interaction:(t,e,i,s)=>new vt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{vt as Interaction,lt as Layouter,N as LeaferCanvas,pt as Picker,dt as Renderer,gt as Selector,$ as Watcher,K as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as r,Creator as a,LeaferImage as h,defineKey as l,FileHelper as c,LeafList as d,RenderEvent as u,ChildEvent as p,WatchEvent as g,PropertyEvent as f,LeafHelper as _,BranchHelper as w,Bounds as v,LeafBoundsHelper as y,LeafLevelList as m,LayoutEvent as b,Run as x,ImageManager as B,BoundsHelper as E,Plugin as L,MathHelper as k,MatrixHelper as T,AlignHelper as R,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as P,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint as V,Effect as Y}from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.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="string"==typeof 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 X.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.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){this.autoBounds=t;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),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,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.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:H,fileType:q}=c;function K(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,H(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(H(q(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=a.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new h(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Q.indexOf("Safari")>-1&&-1===Q.indexOf("Chrome")&&(i.fullImageShadow=!0),Q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?i.os="Mac":Q.indexOf("Linux")>-1&&(i.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;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 d,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new g(g.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(g.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity:tt}=_,{pushAllChildBranch:et,pushAllParent:it}=w;const{worldBounds:st}=y,nt={x:0,y:0,width:1e5,height:1e5};class ot{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),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:rt,updateAllChange:at}=_,ht=t.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(b.START),this.layoutOnce(),t.emitEvent(new b(b.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(g.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=b,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new b(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?(Z(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||J(s[t])}J(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new b(o,a,this.times)),i.emitEvent(new b(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=b,o=this.getBlocks(new d(e));e.emitEvent(new b(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new b(s,o,this.times)),e.emitEvent(new b(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(b.REQUEST,this.layout,this),t.on_(b.AGAIN,this.layoutAgain,this),t.on_(g.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(b.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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(e){const i=x.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=e.includes(this.target.__world),r=new v(n);s.save(),o&&!t.showRepaint?s.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0)),this.__render(n,o,r),s.restore(),x.end(i)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,s){const n=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(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 v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(b.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=E;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,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 d(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),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}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||_.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class gt{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,e,s){return i.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,e,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):L.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new gt(t,e)}),i.layout=lt.fullLayout;const ft={convert(t,e){const i=O.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=O.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=ft.getTouch(t),s=O.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},_t={convert(t){const e=O.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:wt}=O;class vt extends P{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(_t.convert(t))}onKeyUp(t){this.keyUp(_t.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(ft.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(ft.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(ft.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(ft.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(ft.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(ft.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(ft.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=ft.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&wt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(ft.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=ft.getTouch(t);this.pointerMove(ft.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=ft.getTouch(t);this.pointerUp(ft.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||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(O.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({},O.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=O.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(k.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),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&W.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function mt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):xt(e,i);break;case"inside":bt("inside",t,n,e,i);break;case"outside":bt("outside",t,n,e,i)}}function bt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?Bt(e,!0,s,a):xt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",yt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function xt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Bt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?xt(i,s):s.stroke(),s.restoreBlendMode()):e?xt(i,s):s.stroke())}function Et(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Lt,getOuterOf:kt,getByMove:Tt,getIntersectData:Rt}=E;let St;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!St||!St[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Mt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yt(e,i):n?i.fill(n):i.fill())},fillText:yt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),Bt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=Rt(s?Lt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=kt(n,r),o=Tt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let At={};const{get:Ot,rotateOfOuter:Pt,translate:Wt,scaleOfOuter:Dt,scale:It,rotate:zt}=T;function Ft(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),It(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function jt(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),n&&It(a,n,o),r&&zt(a,r),t.transform=a}function Gt(t,e,i,s,n,o,r,a,h,l){const c=Ot();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(zt(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}At.x=e.x+n,At.y=e.y+o,Wt(c,At.x,At.y),r&&Dt(c,At,r,a),t.transform=c}const{get:Ut,translate:Vt}=T,Yt=new v,Xt={},Nt={};function Ht(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=qt(i,s,e)}function qt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u}=t,p=e.width===s&&e.height===n,g={mode:r},f="center"!==a&&(d||0)%180==90,_=f?n:s,w=f?s:n;let v,y,m=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(k.getScaleData(l,c,i,Nt),v=Nt.scaleX,y=Nt.scaleY);else if(!p||d){const t=e.width/_,i=e.height/w;v=y="fit"===r?Math.min(t,i):Math.max(t,i),m+=(e.width-s*v)/2,b+=(e.height-n*y)/2}if(a){const t={x:m,y:b,width:_,height:w};v&&(t.width*=v,t.height*=y),R.toPoint(a,t,e,Xt,!0),m+=Xt.x,b+=Xt.y}switch(h&&(m+=h.x,b+=h.y),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(m||b||v||d)&&jt(g,e,m,b,v,y,d);break;case"repeat":(!p||v||d)&&Gt(g,e,s,n,m,b,v,y,d,a),u||(g.repeat="repeat");break;default:v&&Ft(g,e,m,b,v,y,d)}return g.transform||(e.x||e.y)&&(g.transform=Ut(),Vt(g.transform,e.x,e.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Kt,Qt=new v;const{isSame:$t}=E;function Zt(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ht(n,s,i,o),!0}function Jt(t,e){ie(t,S.LOAD,e)}function te(t,e){ie(t,S.LOADED,e)}function ee(t,e,i){e.error=i,t.forceUpdate("surface"),ie(t,S.ERROR,e)}function ie(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:oe,copy:re}=T,{ceil:ae,abs:he}=Math;function le(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{n=he(n),o=he(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,opacity:g,transform:f,repeat:_}=a;u&&(l=ne(),re(l,f),oe(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const w=c*d;if(!_&&w>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}w>v&&(h=Math.sqrt(w/v)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=ne(),f&&re(l,f)),oe(l,1/n,1/o));const y=t.getCanvas(ae(c)||1,ae(d)||1,g),m=t.getPattern(y,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function ce(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const ue={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return Kt&&i===Kt.paint&&$t(s,Kt.boxBounds)?o=Kt.leafPaint:(o={type:i.type,image:a},Kt=a.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Zt(t,e,i,a,o,s),n&&(Jt(t,r),te(t,r))):a.error?n&&ee(t,r,a.error):(n&&(se(t,!0),Jt(t,r)),o.loadId=a.load((()=>{se(t,!1),t.destroyed||(Zt(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),te(t,r)),o.loadId=null}),(e=>{se(t,!1),ee(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:a}=e;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!j.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:e}=h;t*=de(o)*a,e*=de(r)*a,h.scaleX&&(t*=h.scaleX,e*=h.scaleY),n=t*e>i.image.maxCacheSize||j.running}return n?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),s.blendMode&&(e.blendMode=s.blendMode),h.opacity&&(e.opacity*=h.opacity),h.transform&&e.transform(h.transform),e.drawImage(s.image.view,0,0,h.width,h.height),e.restore(),!0):(!s.style||s.sync||j.running?le(t,s,a):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ce(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&le(t,s,a),t.forceUpdate("surface")}))),300)),!1)}},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:Ht,getPatternData:qt,fillOrFitMode:Ft,clipMode:jt,repeatMode:Gt},{toPoint:pe}=M,ge={},fe={};function _e(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:we,getDistance:ve}=C,{get:ye,rotateOfOuter:me,scaleOfOuter:be}=T,{toPoint:xe}=M,Be={},Ee={};function Le(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=we(e,i);o=ye(),n?(be(o,e,r/a*(s||1),1),me(o,e,t+90)):(be(o,e,1,r/a*(s||1)),me(o,e,t))}return o}const{getDistance:ke}=C,{toPoint:Te}=M,Re={},Se={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;pe(s||"top",e,ge),pe(n||"bottom",e,fe);const h=i.canvas.createLinearGradient(ge.x,ge.y,fe.x,fe.y);_e(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;xe(s||"center",e,Be),xe(n||"bottom",e,Ee);const l=i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ve(Be,Ee));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Be,Ee,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Te(s||"center",e,Re),Te(n||"bottom",e,Se);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Re.x,Re.y):i.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Se));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Re,Se,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Le},{copy:Ce,toOffsetOutBounds:Ae}=E,Oe={},Pe={};function We(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ce(Oe,t.bounds),Oe.x+=e.x-r.x,Oe.y+=e.y-r.y,s){const{matrix:t}=n;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ce(Oe,e),Oe.x-=e.width/2*(s-1),Oe.y-=e.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:e)}const{toOffsetOutBounds:De}=E,Ie={};const ze={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;Ae(l,Pe),a.forEach(((a,f)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,z.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;De(l,Ie),a.forEach(((a,f)=>{p.save(),p.setWorldShadow(Ie.offsetX+a.x*d,Ie.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Ie,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,z.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Fe}=y;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}G.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++)i=h[l],a=i.__.mask,a&&(r&&(je(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Fe(i,e)||i.__render(n||t,e);je(this,r,t,n,s,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ve+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const He=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ne(Ve),Qe=Ne(Ye),$e=Ne("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Je,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ze;function oi(t){return He[t]?Je:$e[t]?ni:qe[t]?ei:Ke[t]?ii:Qe[t]?si:Xe.test(t)?ti:Je}const ri={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 ai(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:hi}=ri,{Letter:li,Single:ci,Before:di,After:ui,Symbol:pi,Break:gi}=Ze;let fi,_i,wi,vi,yi,mi,bi,xi,Bi,Ei,Li,ki,Ti,Ri,Si,Mi,Ci,Ai=[];function Oi(t,e){Bi&&!xi&&(xi=Bi),fi.data.push({char:t,width:e}),wi+=e}function Pi(){vi+=wi,fi.width=wi,_i.words.push(fi),fi={data:[]},wi=0}function Wi(){Ri&&(Si.paraNumber++,_i.paraStart=!0,Ri=!1),Bi&&(_i.startCharSize=xi,_i.endCharSize=Bi,xi=0),_i.width=vi,Mi.width?hi(_i):Ci&&Di(),Ai.push(_i),_i={words:[]},vi=0}function Di(){vi>(Si.maxWidth||0)&&(Si.maxWidth=vi)}const{top:Ii,right:zi,bottom:Fi,left:ji}=A;function Gi(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 Ui={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=e;l&&(o?(s=l[ji],o-=l[zi]+l[ji]):e.autoSizeAlign||(s=l[ji]),r?(n=l[Ii],r-=l[Ii]+l[Fi]):e.autoSizeAlign||(n=l[Ii]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Si=t,Ai=t.rows,Mi=t.bounds,Ci=!Mi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Mi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ri=!0,Li=null,xi=bi=Bi=wi=vi=0,fi={data:[]},_i={words:[]};for(let s=0,l=e.length;s<l;s++)mi=e[s],"\n"===mi?(wi&&Pi(),_i.paraEnd=!0,Wi(),Ri=!0):(Ei=oi(mi),Ei===li&&"none"!==r&&(mi=ai(mi,r,!wi)),bi=a.measureText(mi).width,n&&(n<0&&(Bi=bi),bi+=n),ki=Ei===ci&&(Li===ci||Li===li)||Li===ci&&Ei!==ui,Ti=!(Ei!==di&&Ei!==ci||Li!==pi&&Li!==ui),yi=Ri&&o?h-o:h,t&&h&&vi+wi+bi>yi&&(i?(wi&&Pi(),vi&&Wi()):(Ti||(Ti=Ei===li&&Li==ui),ki||Ti||Ei===gi||Ei===di||Ei===ci||wi+bi>yi?(wi&&Pi(),vi&&Wi()):vi&&Wi()))," "===mi&&!0!==Ri&&vi+wi===0||(Ei===gi?(" "===mi&&wi&&Pi(),Oi(mi,bi),Pi()):ki||Ti?(wi&&Pi(),Oi(mi,bi)):Oi(mi,bi)),Li=Ei);wi&&Pi(),vi&&Wi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Si.paraNumber++,vi=a.measureText(t).width,Ai.push({x:o||0,text:t,width:vi,paraStart:!0}),Ci&&Di()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[ji]);break;case"right":Gi(e,"x",-t[zi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Ii]);break;case"bottom":Gi(e,"y",-t[Fi])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:c,autoSizeAlign:d}=e;let{x:u,y:p,width:g,height:f}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(a&&_>f)_=Math.max(f,n),t.overflow=i.length;else if(f||d)switch(l){case"middle":p+=(f-_)/2;break;case"bottom":p+=f-_}w+=p;let v,y,m,b=g||d?g:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(v=i[o],v.x=u,v.width<g||v.width>g&&!a)switch(h){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&o>0&&(w+=c),v.y=w,w+=n,t.overflow>o&&w>_&&(v.isOverflow=!0,t.overflow=o+1),y=v.x,m=v.width,r<0&&(v.width<0?(m=-v.width+e.fontSize+r,y-=m,m+=e.fontSize):m-=r),y<s.x&&(s.x=y),m>s.width&&(s.width=m),a&&g&&g<m&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(c,e),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,c,d;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&("justify"===n||"both"===n)&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e=>{1===c?(d={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):a=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||(a+=h,t.width+=h)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){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)}}))}}(c,e,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(U,Ui),Object.assign(z,Vi),Object.assign(V,Ct),Object.assign(I,ue),Object.assign(F,Me),Object.assign(Y,ze),Object.assign(a,{interaction:(t,e,i,s)=>new vt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{vt as Interaction,lt as Layouter,N as LeaferCanvas,pt as Picker,dt as Renderer,gt as Selector,$ as Watcher,K as useCanvas};
|