leafer-ui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,10 @@ Leafer UI 是基于 [Leafer](https://github.com/leaferjs/leafer) 开发的一套
6
6
 
7
7
  可用于高效绘图、组态、开发图形图像编辑软件。随着生态的不断发展,未来将支撑可视化开发网页、应用、游戏、动画。
8
8
 
9
+ v1.0 正式版已发布 🎉🎉🎉
10
+
11
+ 📗[图文并茂、由浅入深的了解 LeaferJS](https://leaferjs.com/ui/blog/2024-07-09.html)
12
+
9
13
  ## 快速安装
10
14
 
11
15
  🚀 想马上使用,请 [安装 leafer-ui](https://leaferjs.com/ui/guide/install/ui/start.html),开始你的探索之旅。
@@ -18,13 +22,13 @@ Leafer UI 是基于 [Leafer](https://github.com/leaferjs/leafer) 开发的一套
18
22
 
19
23
  有问题、建议可以 [提交 issue](https://github.com/leaferjs/ui/issues),留下你的贡献足迹。
20
24
 
21
- 欢迎加入 [技术交流群](https://leaferjs.com/#contact) ,与小伙伴们建立联系,共同学习进步。
25
+ 欢迎加入 [技术交流群](https://leaferjs.com/#contact) ,与小伙伴们建立联系,共同学习进步,偶尔会有特殊福利。
22
26
 
23
27
  🌟 记得前往 [GitHub](https://github.com/leaferjs/ui) / [Gitee](https://gitee.com/leaferjs/ui) 点亮你的 [小星星](https://github.com/leaferjs/ui) ✨ ✨ ✨
24
28
 
25
29
  ## 使命与愿景
26
30
 
27
- Leafer UI 致力于实现一套简洁、开放、现代化的 UI 绘图语言标准,表现力丰富,并提供跨平台、轻量化、高性能的运行时。
31
+ Leafer UI 致力于实现一套简洁、开放、现代化的 UI 绘图语言标准,表现力丰富,便于 AI 理解,人类可视化使用,并为数字化产品开发提供跨平台、轻量化、高性能的运行时。
28
32
 
29
33
  让不同的软件之间能够沟通、协作、共享绘图数据,让数字化产品开发可以更快、更简单。
30
34
 
@@ -44,6 +48,8 @@ Leafer UI 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
44
48
 
45
49
  [Leafer 仓库](https://github.com/leaferjs/leafer)
46
50
 
51
+ [LeaferIN 官方插件仓库](https://github.com/leaferjs/in)
52
+
47
53
  ### License
48
54
 
49
55
  Leafer UI 是采用 MIT 许可的开源项目,可以永久免费使用。
package/dist/web.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MathHelper, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { Debug, LeaferCanvasBase, Platform, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MathHelper, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { InteractionHelper, InteractionBase, Cursor, HitCanvasManager } from '@leafer-ui/core';
@@ -26,7 +26,8 @@ class LeaferCanvas extends LeaferCanvasBase {
26
26
  }
27
27
  }
28
28
  init() {
29
- const { view } = this.config;
29
+ const { config } = this;
30
+ const view = config.view || config.canvas;
30
31
  view ? this.__createViewFrom(view) : this.__createView();
31
32
  const { style } = this.view;
32
33
  style.display || (style.display = 'block');
@@ -41,7 +42,7 @@ class LeaferCanvas extends LeaferCanvasBase {
41
42
  }
42
43
  this.__createContext();
43
44
  if (!this.autoLayout)
44
- this.resize(this.config);
45
+ this.resize(config);
45
46
  }
46
47
  set backgroundColor(color) { this.view.style.backgroundColor = color; }
47
48
  get backgroundColor() { return this.view.style.backgroundColor; }
@@ -97,26 +98,37 @@ class LeaferCanvas extends LeaferCanvasBase {
97
98
  this.clientBounds = this.view.getBoundingClientRect();
98
99
  }
99
100
  startAutoLayout(autoBounds, listener) {
100
- this.autoBounds = autoBounds;
101
101
  this.resizeListener = listener;
102
- try {
103
- this.resizeObserver = new ResizeObserver((entries) => {
104
- this.updateClientBounds();
105
- for (const entry of entries)
106
- this.checkAutoBounds(entry.contentRect);
107
- });
108
- const parent = this.parentView;
109
- if (parent) {
110
- this.resizeObserver.observe(parent);
111
- this.checkAutoBounds(parent.getBoundingClientRect());
102
+ if (autoBounds) {
103
+ this.autoBounds = autoBounds;
104
+ try {
105
+ this.resizeObserver = new ResizeObserver((entries) => {
106
+ this.updateClientBounds();
107
+ for (const entry of entries)
108
+ this.checkAutoBounds(entry.contentRect);
109
+ });
110
+ const parent = this.parentView;
111
+ if (parent) {
112
+ this.resizeObserver.observe(parent);
113
+ this.checkAutoBounds(parent.getBoundingClientRect());
114
+ }
115
+ else {
116
+ this.checkAutoBounds(this.view);
117
+ debug$3.warn('no parent');
118
+ }
112
119
  }
113
- else {
114
- this.checkAutoBounds(this.view);
115
- debug$3.warn('no parent');
120
+ catch (_a) {
121
+ this.imitateResizeObserver();
116
122
  }
117
123
  }
118
- catch (_a) {
119
- this.imitateResizeObserver();
124
+ else {
125
+ window.addEventListener('resize', () => {
126
+ const pixelRatio = Platform.devicePixelRatio;
127
+ if (this.pixelRatio !== pixelRatio) {
128
+ const { width, height } = this;
129
+ this.emitResize({ width, height, pixelRatio });
130
+ }
131
+ });
120
132
  }
121
133
  }
122
134
  imitateResizeObserver() {
@@ -129,17 +141,12 @@ class LeaferCanvas extends LeaferCanvasBase {
129
141
  checkAutoBounds(parentSize) {
130
142
  const view = this.view;
131
143
  const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
132
- if (width !== this.width || height !== this.height) {
144
+ const size = { width, height, pixelRatio: Platform.devicePixelRatio };
145
+ if (!this.isSameSize(size)) {
133
146
  const { style } = view;
134
- const { pixelRatio } = this;
135
147
  style.marginLeft = x + 'px';
136
148
  style.marginTop = y + 'px';
137
- const size = { width, height, pixelRatio };
138
- const oldSize = {};
139
- DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
140
- this.resize(size);
141
- if (this.width !== undefined)
142
- this.resizeListener(new ResizeEvent(size, oldSize));
149
+ this.emitResize(size);
143
150
  }
144
151
  }
145
152
  stopAutoLayout() {
@@ -150,6 +157,13 @@ class LeaferCanvas extends LeaferCanvasBase {
150
157
  this.resizeObserver = null;
151
158
  }
152
159
  }
160
+ emitResize(size) {
161
+ const oldSize = {};
162
+ DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
163
+ this.resize(size);
164
+ if (this.width !== undefined)
165
+ this.resizeListener(new ResizeEvent(size, oldSize));
166
+ }
153
167
  unrealCanvas() {
154
168
  if (!this.unreal && this.parentView) {
155
169
  const view = this.view;
@@ -230,7 +244,7 @@ function useCanvas(_canvasType, _power) {
230
244
  Platform.name = 'web';
231
245
  Platform.isMobile = 'ontouchstart' in window;
232
246
  Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
233
- Platform.devicePixelRatio = Math.max(1, devicePixelRatio);
247
+ defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
234
248
  const { userAgent } = navigator;
235
249
  if (userAgent.indexOf("Firefox") > -1) {
236
250
  Platform.conicGradientRotate90 = true;
@@ -727,14 +741,14 @@ class Renderer {
727
741
  if (Debug.showRepaint)
728
742
  this.canvas.strokeWorld(bounds, 'red');
729
743
  this.target.__render(this.canvas, options);
730
- this.renderBounds = realBounds || bounds;
744
+ this.renderBounds = realBounds = realBounds || bounds;
731
745
  this.renderOptions = options;
732
- this.totalBounds.isEmpty() ? this.totalBounds = this.renderBounds : this.totalBounds.add(this.renderBounds);
746
+ this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
733
747
  if (Debug.showHitView)
734
748
  this.renderHitView(options);
735
749
  if (Debug.showBoundsView)
736
750
  this.renderBoundsView(options);
737
- this.canvas.updateRender();
751
+ this.canvas.updateRender(realBounds);
738
752
  }
739
753
  renderHitView(_options) { }
740
754
  renderBoundsView(_options) { }
@@ -1121,7 +1135,7 @@ const PointerEventHelper = {
1121
1135
  convertTouch(e, local) {
1122
1136
  const touch = PointerEventHelper.getTouch(e);
1123
1137
  const base = InteractionHelper.getBase(e);
1124
- return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', pressure: touch.force });
1138
+ return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', multiTouch: e.touches.length > 1, pressure: touch.force });
1125
1139
  },
1126
1140
  getTouch(e) {
1127
1141
  return e.targetTouches[0] || e.changedTouches[0];
@@ -1262,21 +1276,21 @@ class Interaction extends InteractionBase {
1262
1276
  }
1263
1277
  onPointerDown(e) {
1264
1278
  this.preventDefaultPointer(e);
1265
- this.usePointer || (this.usePointer = true);
1266
- if (this.useMultiTouch)
1279
+ if (this.config.pointer.touch || this.useMultiTouch)
1267
1280
  return;
1281
+ this.usePointer || (this.usePointer = true);
1268
1282
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
1269
1283
  }
1270
1284
  onPointerMove(e) {
1271
- this.usePointer || (this.usePointer = true);
1272
- if (this.useMultiTouch || this.preventWindowPointer(e))
1285
+ if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
1273
1286
  return;
1287
+ this.usePointer || (this.usePointer = true);
1274
1288
  this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
1275
1289
  }
1276
1290
  onPointerUp(e) {
1277
1291
  if (this.downData)
1278
1292
  this.preventDefaultPointer(e);
1279
- if (this.useMultiTouch || this.preventWindowPointer(e))
1293
+ if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
1280
1294
  return;
1281
1295
  this.pointerUp(PointerEventHelper.convert(e, this.getLocal(e)));
1282
1296
  }
@@ -1346,7 +1360,7 @@ class Interaction extends InteractionBase {
1346
1360
  this.pointerCancel();
1347
1361
  }
1348
1362
  multiTouchStart(e) {
1349
- this.useMultiTouch = (e.touches.length >= 2);
1363
+ this.useMultiTouch = (e.touches.length > 1);
1350
1364
  this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined;
1351
1365
  if (this.useMultiTouch)
1352
1366
  this.pointerCancel();
@@ -2068,7 +2082,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
2068
2082
  const { abs } = Math;
2069
2083
  function checkImage(ui, canvas, paint, allowPaint) {
2070
2084
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
2071
- if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
2085
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
2072
2086
  return false;
2073
2087
  }
2074
2088
  else {
@@ -3046,7 +3060,10 @@ const ExportModule = {
3046
3060
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
3047
3061
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
3048
3062
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
3063
+ let sliceLeaf;
3049
3064
  if (slice) {
3065
+ sliceLeaf = leaf;
3066
+ sliceLeaf.__worldOpacity = 0;
3050
3067
  leaf = leafer;
3051
3068
  renderOptions.bounds = canvas.bounds;
3052
3069
  }
@@ -3061,6 +3078,8 @@ const ExportModule = {
3061
3078
  leaf.__render(canvas, renderOptions);
3062
3079
  }
3063
3080
  canvas.restore();
3081
+ if (sliceLeaf)
3082
+ sliceLeaf.__updateWorldOpacity();
3064
3083
  if (trim) {
3065
3084
  trimBounds = getTrimBounds(canvas);
3066
3085
  const old = canvas, { width, height } = trimBounds;
@@ -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,FileHelper as l,LeafList as d,RenderEvent as c,ChildEvent as u,WatchEvent as p,PropertyEvent as f,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as v,LeafLevelList as m,LayoutEvent as y,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as E,Answer as L,MathHelper as k,MatrixHelper as R,AlignHelper as M,ImageEvent as T,AroundHelper as S,PointHelper as C,Direction4 as P,TwoPointBoundsHelper as A,TaskProcessor as O,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as D,InteractionBase as I,Cursor as F,HitCanvasManager as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,ColorConvert as V,PaintGradient as Y,Export as z,Group as N,TextConvert as j,Paint as X,Effect as H}from"@leafer-ui/draw";const q=t.get("LeaferCanvas");class K 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{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;if(e.display||(e.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(e.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}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 q.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.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;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),q.warn("no parent"))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:i,y:r,width:a,height:h}=this.autoBounds.getBoundsFrom(t);if(a!==this.width||h!==this.height){const{style:t}=e,{pixelRatio:l}=this;t.marginLeft=i+"px",t.marginTop=r+"px";const d={width:a,height:h,pixelRatio:l},c={};s.copyAttrs(c,this,n),this.resize(d),void 0!==this.width&&this.resizeListener(new o(d,c))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}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:Q,fileType:$}=l;function J(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(Q(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,Q(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(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 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)}))},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 K(t,e),image:t=>new h(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},i.devicePixelRatio=Math.max(1,devicePixelRatio);const{userAgent:Z}=navigator;Z.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Z.indexOf("Safari")>-1&&-1===Z.indexOf("Chrome")&&(i.fullImageShadow=!0),Z.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Z.indexOf("Mac")>-1?i.os="Mac":Z.indexOf("Linux")>-1&&(i.os="Linux");class tt{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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 p(p.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_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(p.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:et,updateBounds:it,updateAllWorldOpacity:st}=g,{pushAllChildBranch:nt,pushAllParent:ot}=_;const{worldBounds:rt}=v,at={x:0,y:0,width:1e5,height:1e5};class ht{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,rt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(at):this.afterBounds.setListWithFn(t,rt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:lt,updateAllChange:dt}=g,ct=t.get("Layouter");class ut{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(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){ct.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ct.warn("layouting"):this.times>3?ct.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(p.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}=y,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new y(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?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),ot(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ot(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||it(s[t])}it(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&st(t),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new y(o,a,this.times)),i.emitEvent(new y(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}=y,o=this.getBlocks(new d(e));e.emitEvent(new y(i,o,this.times)),ut.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,o,this.times)),e.emitEvent(new y(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ht([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ht(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(p.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const pt=t.get("Renderer");class ft{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,pt.log(e.innerName,"---\x3e");try{this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,pt.error(t)}pt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return pt.warn("rendering");if(this.times>3)return pt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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;if(!e)return pt.warn("PartRender: need update attr");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 w(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||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__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||pt.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 c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(c.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:gt}=E;class _t{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||g.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 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||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&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()}}const{Yes:wt,NoAndSkip:vt,YesAndSkip:mt}=L,yt={},xt={},bt={};class Bt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new _t(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":yt.id=t.substring(1),t=yt;break;case".":xt.className=t.substring(1),t=xt;break;default:bt.tag=t,t=bt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,e,s){return"node"===i.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,e,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&g.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===wt||o===mt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<vt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(u.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ut(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new Bt(t,e)}),i.layout=ut.fullLayout;const Et={convert(t,e){const i=D.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=D.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=Et.getTouch(t),s=D.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Lt={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let s,n=1,{zoomMode:o,zoomSpeed:r}=e;const a=t.deltaY||t.deltaX;if(o?(s="mouse"===o||!t.deltaX&&(i.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(t.shiftKey||t.metaKey||t.ctrlKey)&&(s=!0)):s=!t.shiftKey&&(t.metaKey||t.ctrlKey),s){r=k.within(r,0,1);n=1-a/(4*(t.deltaY?e.delta.y:e.delta.x))*r,n<.5&&(n=.5),n>=1.5&&(n=1.5)}return n}},kt={convert(t){const e=D.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:Rt,getZoomEventData:Mt,getRotateEventData:Tt}=D;class St extends I{__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(kt.convert(t))}onKeyUp(t){this.keyUp(kt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(Et.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.pointerDown(Et.convert(t,this.getLocal(t)))}onPointerMove(t){this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerMove(Et.convert(t,this.getLocal(t,!0)))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(Et.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(Et.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(Et.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(Et.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=Et.getTouch(t);this.pointerDown(Et.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=Et.getTouch(t);this.pointerMove(Et.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=Et.getTouch(t);this.pointerUp(Et.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,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(D.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);const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):Lt.getScale(t,e),s=this.getLocal(t),n=D.getBase(t);1!==i?this.zoom(Mt(s,i,n)):this.move(Rt(s,e.getMove?e.getMove(t,e):Lt.getMove(t,e),n))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=this.getLocal(t),i=D.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=k.within(o,0,1),this.zoom(Mt(e,s*s,i)),this.rotate(Tt(e,n/Math.PI*180*(o/4+.1),i)),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&&F.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 Ct(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 Pt(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?Wt(t,!0,e,i):Ot(e,i);break;case"inside":At("inside",t,n,e,i);break;case"outside":At("outside",t,n,e,i)}}function At(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?Wt(e,!0,s,a):Ot(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",Ct(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 Ot(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 Wt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&G.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ot(i,s):s.stroke(),s.restoreBlendMode()):e?Ot(i,s):s.stroke())}const{getSpread:Dt,getOuterOf:It,getByMove:Ft,getIntersectData:Ut}=E;let Gt;function Vt(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:V.string(r,a)};case"image":return G.image(i,t,e,s,!Gt||!Gt[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:V.string(e)}:void 0}}const Yt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Gt=G.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Vt(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?Ct(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&&G.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?Ct(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Ct(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Ct(e,i):n?i.fill(n):i.fill())},fillText:Ct,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Pt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();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)Pt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Wt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Wt(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),Wt(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:Pt,drawTextStroke:Ot,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=n;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,c=Ut(s?Dt(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=p),a=It(n,r),o=Ft(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:d}}};let zt={};const{get:Nt,rotateOfOuter:jt,translate:Xt,scaleOfOuter:Ht,scale:qt,rotate:Kt}=R;function Qt(t,e,i,s,n,o,r){const a=Nt();Xt(a,e.x+i,e.y+s),qt(a,n,o),r&&jt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function $t(t,e,i,s,n,o,r){const a=Nt();Xt(a,e.x+i,e.y+s),n&&qt(a,n,o),r&&Kt(a,r),t.transform=a}function Jt(t,e,i,s,n,o,r,a,h,l){const d=Nt();if(h)if("center"===l)jt(d,{x:i/2,y:s/2},h);else switch(Kt(d,h),h){case 90:Xt(d,s,0);break;case 180:Xt(d,i,s);break;case 270:Xt(d,0,i)}zt.x=e.x+n,zt.y=e.y+o,Xt(d,zt.x,zt.y),r&&Ht(d,zt,r,a),t.transform=d}const{get:Zt,translate:te}=R,ee=new w,ie={};function se(t,e,i,s){const{blendMode:n}=i;n&&(t.blendMode=n),t.data=ne(i,s,e)}function ne(t,e,i){let{width:s,height:n}=i;t.padding&&(e=ee.set(e).shrink(t.padding));const{opacity:o,mode:r,align:a,offset:h,scale:l,size:d,rotation:c,repeat:u}=t,p=e.width===s&&e.height===n,f={mode:r},g="center"!==a&&(c||0)%180==90,_=g?n:s,w=g?s:n;let v,m,y=0,x=0;if(r&&"cover"!==r&&"fit"!==r)d?(v=("number"==typeof d?d:d.width)/s,m=("number"==typeof d?d:d.height)/n):l&&(v="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!p||c){const t=e.width/_,i=e.height/w;v=m="fit"===r?Math.min(t,i):Math.max(t,i),y+=(e.width-s*v)/2,x+=(e.height-n*m)/2}if(a){const t={x:y,y:x,width:_,height:w};v&&(t.width*=v,t.height*=m),M.toPoint(a,t,e,ie,!0),y+=ie.x,x+=ie.y}switch(h&&(y+=h.x,x+=h.y),r){case"strench":p||(s=e.width,n=e.height);break;case"normal":case"clip":(y||x||v||c)&&$t(f,e,y,x,v,m,c);break;case"repeat":(!p||v||c)&&Jt(f,e,s,n,y,x,v,m,c,a),u||(f.repeat="repeat");break;default:v&&Qt(f,e,y,x,v,m,c)}return f.transform||(e.x||e.y)&&(f.transform=Zt(),te(f.transform,e.x,e.y)),v&&"strench"!==r&&(f.scaleX=v,f.scaleY=m),f.width=s,f.height=n,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let oe,re=new w;const{isSame:ae}=E;function he(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||se(n,s,i,o),!0}function le(t,e){ue(t,T.LOAD,e)}function de(t,e){ue(t,T.LOADED,e)}function ce(t,e,i){e.error=i,t.forceUpdate("surface"),ue(t,T.ERROR,e)}function ue(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:fe,scale:ge,copy:_e}=R,{ceil:we,abs:ve}=Math;function me(t,e,s){let{scaleX:n,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o;if(e.patternId===r||t.destroyed)return!1;{n=ve(n),o=ve(o);const{image:t,data:a}=e;let h,l,{width:d,height:c,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=a;u&&(l=fe(),_e(l,g),ge(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,d*=n,c*=o;const w=d*c;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,d/=h,c/=h),u&&(n/=u,o/=p),(g||1!==n||1!==o)&&(l||(l=fe(),g&&_e(l,g)),ge(l,1/n,1/o));const m=t.getCanvas(we(d)||1,we(c)||1,f),y=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=y,e.patternId=r,!0}}function ye(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:xe}=Math;const be={image:function(t,e,i,s,n){let o,r;const a=b.get(i);return oe&&i===oe.paint&&ae(s,oe.boxBounds)?o=oe.leafPaint:(o={type:i.type,image:a},oe=a.use>1?{leafPaint:o,paint:i,boxBounds:re.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(he(t,e,i,a,o,s),n&&(le(t,r),de(t,r))):a.error?n&&ce(t,r,a.error):(pe(t,!0),n&&le(t,r),o.loadId=a.load((()=>{pe(t,!1),t.destroyed||(he(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),de(t,r)),o.loadId=null}),(e=>{pe(t,!1),ce(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=b.patternLocked?t.__world:t.__nowWorld;if(s.data&&s.patternId!==o+"-"+r){const{data:a}=s;if(n)if(a.repeat)n=!1;else{let{width:t,height:s}=a;t*=xe(o)*e.pixelRatio,s*=xe(r)*e.pixelRatio,a.scaleX&&(t*=a.scaleX,s*=a.scaleY),n=t*s>i.image.maxCacheSize||z.running}return n?(e.save(),e.clip(),s.blendMode&&(e.blendMode=s.blendMode),a.opacity&&(e.opacity*=a.opacity),a.transform&&e.transform(a.transform),e.drawImage(s.image.view,0,0,a.width,a.height),e.restore(),!0):(!s.style||z.running?me(t,s,e.pixelRatio):s.patternTask||(s.patternTask=b.patternTasker.add((()=>ye(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&me(t,s,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:me,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:se,getPatternData:ne,fillOrFitMode:Qt,clipMode:$t,repeatMode:Jt},{toPoint:Be}=S,Ee={},Le={};function ke(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),V.string(s,i)):t.addColorStop(s.offset,V.string(s.color,i))}const{getAngle:Re,getDistance:Me}=C,{get:Te,rotateOfOuter:Se,scaleOfOuter:Ce}=R,{toPoint:Pe}=S,Ae={},Oe={};function We(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Re(e,i);o=Te(),n?(Ce(o,e,r/a*(s||1),1),Se(o,e,t+90)):(Ce(o,e,1,r/a*(s||1)),Se(o,e,t))}return o}const{getDistance:De}=C,{toPoint:Ie}=S,Fe={},Ue={};const Ge={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;Be(s||"top",e,Ee),Be(n||"bottom",e,Le);const h=i.canvas.createLinearGradient(Ee.x,Ee.y,Le.x,Le.y);ke(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;Pe(s||"center",e,Ae),Pe(n||"bottom",e,Oe);const l=i.canvas.createRadialGradient(Ae.x,Ae.y,0,Ae.x,Ae.y,Me(Ae,Oe));ke(l,t.stops,r);const d={type:o,style:l},c=We(e,Ae,Oe,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Ie(s||"center",e,Fe),Ie(n||"bottom",e,Ue);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Fe.x,Fe.y):i.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,De(Fe,Ue));ke(l,t.stops,r);const d={type:o,style:l},c=We(e,Fe,Ue,h||1,i.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:We},{copy:Ve,toOffsetOutBounds:Ye}=E,ze={},Ne={};function je(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ve(ze,t.bounds),ze.x+=e.x-r.x,ze.y+=e.y-r.y,s){const{matrix:t}=n;ze.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),ze.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),ze.width*=s,ze.height*=s}t.copyWorld(n.canvas,t.bounds,ze)}else s&&(Ve(ze,e),ze.x-=e.width/2*(s-1),ze.y-=e.height/2*(s-1),ze.width*=s,ze.height*=s),t.copyWorld(n.canvas,r,s?ze:e)}const{toOffsetOutBounds:Xe}=E,He={};const qe={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Ye(l,Ne),a.forEach(((a,g)=>{p.setWorldShadow(Ne.offsetX+a.x*c,Ne.offsetY+a.y*u,a.blur*c,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,je(p,Ne,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,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),f&&g<f&&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:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Xe(l,He),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(He.offsetX+a.x*c,He.offsetY+a.y*u,a.blur*c),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,je(p,He,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,d,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),f&&g<f&&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:Ke}=v;function Qe(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Je(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Je(t,i,s,o);break;case"path":i.restore()}}function $e(t){return t.getSameCanvas(!1,!0)}function Je(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}N.prototype.__renderMask=function(t,e){let i,s,n,o,r;const{children:a}=this;for(let h=0,l=a.length;h<l;h++)i=a[h],i.__.mask&&(r&&(Qe(this,r,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=$e(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="alpha",s||(s=$e(t)),n||(n=$e(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ke(i,e)||i.__render(n||t,e);Qe(this,r,t,n,s,o)};const Ze=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ti=Ze+"_#~&*+\\=|≮≯≈≠=…",ei=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 ii(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const si=ii("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ni=ii("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oi=ii(Ze),ri=ii(ti),ai=ii("- —/~|┆·");var hi;!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"}(hi||(hi={}));const{Letter:li,Single:di,Before:ci,After:ui,Symbol:pi,Break:fi}=hi;function gi(t){return si[t]?li:ai[t]?fi:ni[t]?ci:oi[t]?ui:ri[t]?pi:ei.test(t)?di:li}const _i={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 wi(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:vi}=_i,{Letter:mi,Single:yi,Before:xi,After:bi,Symbol:Bi,Break:Ei}=hi;let Li,ki,Ri,Mi,Ti,Si,Ci,Pi,Ai,Oi,Wi,Di,Ii,Fi,Ui,Gi,Vi=[];function Yi(t,e){Ai&&!Pi&&(Pi=Ai),Li.data.push({char:t,width:e}),Ri+=e}function zi(){Mi+=Ri,Li.width=Ri,ki.words.push(Li),Li={data:[]},Ri=0}function Ni(){Fi&&(Ui.paraNumber++,ki.paraStart=!0,Fi=!1),Ai&&(ki.startCharSize=Pi,ki.endCharSize=Ai,Pi=0),ki.width=Mi,Gi.width&&vi(ki),Vi.push(ki),ki={words:[]},Mi=0}const ji=0,Xi=1,Hi=2;const{top:qi,right:Ki,bottom:Qi,left:$i}=P;function Ji(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 Zi={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[$i],o-=l[Ki]+l[$i]),r&&(n=l[qi],r-=l[qi]+l[Qi]));const d={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Ui=t,Vi=t.rows,Gi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Gi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Fi=!0,Wi=null,Pi=Ci=Ai=Ri=Mi=0,Li={data:[]},ki={words:[]};for(let s=0,l=e.length;s<l;s++)Si=e[s],"\n"===Si?(Ri&&zi(),ki.paraEnd=!0,Ni(),Fi=!0):(Oi=gi(Si),Oi===mi&&"none"!==r&&(Si=wi(Si,r,!Ri)),Ci=a.measureText(Si).width,n&&(n<0&&(Ai=Ci),Ci+=n),Di=Oi===yi&&(Wi===yi||Wi===mi)||Wi===yi&&Oi!==bi,Ii=!(Oi!==xi&&Oi!==yi||Wi!==Bi&&Wi!==bi),Ti=Fi&&o?h-o:h,t&&h&&Mi+Ri+Ci>Ti&&(i?(Ri&&zi(),Mi&&Ni()):(Ii||(Ii=Oi===mi&&Wi==bi),Di||Ii||Oi===Ei||Oi===xi||Oi===yi||Ri+Ci>Ti?(Ri&&zi(),Mi&&Ni()):Mi&&Ni()))," "===Si&&!0!==Fi&&Mi+Ri===0||(Oi===Ei?(" "===Si&&Ri&&zi(),Yi(Si,Ci),zi()):Di||Ii?(Ri&&zi(),Yi(Si,Ci)):Yi(Si,Ci)),Wi=Oi);Ri&&zi(),Mi&&Ni(),Vi.length>0&&(Vi[Vi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ui.paraNumber++,Vi.push({x:o||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(d,t,e),l&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Ji(e,"x",t[$i]);break;case"right":Ji(e,"x",-t[Ki])}if(!n)switch(i.verticalAlign){case"top":Ji(e,"y",t[qi]);break;case"bottom":Ji(e,"y",-t[Qi])}}(l,d,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:d}=e;let c,u,p,{x:f,y:g,width:_,height:w}=s,v=n*i.length+(d?d*(t.paraNumber-1):0),m=o;if(a&&v>w)v=Math.max(w,n),t.overflow=i.length;else switch(l){case"middle":g+=(w-v)/2;break;case"bottom":g+=w-v}m+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=f,c.width<_||c.width>_&&!a)switch(h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&d&&o>0&&(m+=d),c.y=m,m+=n,t.overflow>o&&m>v&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,p=c.width,r<0&&(c.width<0?(p=-c.width+e.fontSize+r,u-=p,p+=e.fontSize):p-=r),u<s.x&&(s.x=u),p>s.width&&(s.width=p),a&&_&&_<p&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=v}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;n.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?ji:l>.01?Xi:Hi,t.isOverflow&&!a&&(t.textMode=!0),c===Hi?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Xi?(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),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,e,o),d.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,d=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<d));s--){if(h<d&&" "!==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)}}))}}(d,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}}(d,e),d}};const ts={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:es,addPoint:is,toBounds:ss}=A;const ns={export(t,e,s){this.running=!0;const n=l.fileType(e);return s=l.getExportOptions(s),function(t){os||(os=new O);return new Promise((e=>{os.add((()=>ye(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const h=t=>{o(t),r(),this.running=!1},{toURL:d}=i,{download:c}=i.origin;if("json"===e)return h({data:t.toJSON(s.json)});if("json"===n)return c(d(JSON.stringify(t.toJSON(s.json)),"text"),e),h({data:!0});if("svg"===e)return h({data:t.toSVG()});if("svg"===n)return c(d(t.toSVG(),"svg"),e),h({data:!0});const{leafer:u}=t;u?(rs(t),u.waitViewCompleted((()=>ye(this,void 0,void 0,(function*(){let i,n,o=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:p}=t,{slice:f,trim:g,onCanvas:_}=s;let v=s.scale||1,m=s.pixelRatio||1;const y=void 0===s.smooth?u.config.smooth:s.smooth,x=s.contextSettings||u.config.contextSettings;t.isApp&&(v*=m,m=t.app.pixelRatio);const b=s.screenshot||t.isApp,B=c&&b&&void 0===s.fill?t.fill:s.fill,E=l.isOpaqueImage(e)||B,L=new W;if(b)i=!0===b?c?u.canvas.bounds:t.worldRenderBounds:b;else{let e=s.relative||(c?"inner":"local");switch(o=d.scaleX,r=d.scaleY,e){case"inner":L.set(d);break;case"local":L.set(d).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:L.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}i=t.getBounds("render",e)}const{x:k,y:R,width:M,height:T}=new w(i).scale(v);let S=a.canvas({width:Math.round(M),height:Math.round(T),pixelRatio:m,smooth:y,contextSettings:x});const C={matrix:L.scale(1/v).invert().translate(-k,-R).withScale(1/o*v,1/r*v)};if(f&&(t=u,C.bounds=S.bounds),S.save(),p&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(S,C),t.fill=e}else t.__render(S,C);if(S.restore(),g){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?is(r,n,o):es(r={},n,o)),a++;const h=new w;return ss(r,h),h.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=a.canvas(s),S.copyWorld(t,n,s)}E&&S.fillWorld(S.bounds,B||"#FFFFFF","destination-over"),_&&_(S);const P="canvas"===e?S:yield S.export(e,s);h({data:P,width:S.pixelWidth,height:S.pixelHeight,renderBounds:i,trimBounds:n})}))))):h({data:!1})}))))}};let os;function rs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>rs(t)))}const as=e.prototype,hs=t.get("@leafer-ui/export");as.export=function(t,e){const{quality:i,blob:s}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},as.toBlob=function(t,e){return new Promise((s=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{s(t)})).catch((t=>{hs.error(t),s(null)}))}))},as.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},as.saveAs=function(t,e){return new Promise((s=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{s(!0)})).catch((t=>{hs.error(t),s(!1)}))}))},Object.assign(j,Zi),Object.assign(V,ts),Object.assign(X,Yt),Object.assign(G,be),Object.assign(Y,Ge),Object.assign(H,qe),Object.assign(z,ns),Object.assign(a,{interaction:(t,e,i,s)=>new St(t,e,i,s),hitCanvas:(t,e)=>new K(t,e),hitCanvasManager:()=>new U}),J();export{St as Interaction,ut as Layouter,K as LeaferCanvas,ft as Renderer,Bt as Selector,tt as Watcher,J 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 d,LeafList as c,RenderEvent as u,ChildEvent as p,WatchEvent as f,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as v,LeafBoundsHelper as m,LeafLevelList as y,LayoutEvent as x,Run as b,ImageManager as B,AnimateEvent as E,BoundsHelper as L,Answer as R,MathHelper as k,MatrixHelper as M,AlignHelper as T,ImageEvent as S,AroundHelper as C,PointHelper as P,Direction4 as O,TwoPointBoundsHelper as A,TaskProcessor as W,Matrix as D}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as I,InteractionBase as F,Cursor as z,HitCanvasManager as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,ColorConvert as V,PaintGradient as Y,Export as N,Group as j,TextConvert as X,Paint as H,Effect as q}from"@leafer-ui/draw";const K=t.get("LeaferCanvas");class Q 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 K.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.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),K.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),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:$,fileType:J}=d;function Z(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($(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,$(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL($(J(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 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)}))},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 Q(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:tt}=navigator;tt.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):tt.indexOf("Safari")>-1&&-1===tt.indexOf("Chrome")&&(i.fullImageShadow=!0),tt.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):tt.indexOf("Mac")>-1?i.os="Mac":tt.indexOf("Linux")>-1&&(i.os="Linux");class et{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.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:it,updateBounds:st,updateAllWorldOpacity:nt}=_,{pushAllChildBranch:ot,pushAllParent:rt}=w;const{worldBounds:at}=m,ht={x:0,y:0,width:1e5,height:1e5};class lt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ht):this.afterBounds.setListWithFn(t,at),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:dt,updateAllChange:ct}=_,ut=t.get("Layouter");class pt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ut.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ut.warn("layouting"):this.times>3?ut.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=x,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new x(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?(it(t,!0),e.add(t),t.isBranch&&ot(t,e),rt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),rt(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||st(s[t])}st(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&nt(t),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new x(o,a,this.times)),i.emitEvent(new x(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),pt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){dt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),ct(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new lt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new lt(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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ft=t.get("Renderer");class gt{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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new v,ft.log(e.innerName,"---\x3e");try{this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ft.error(t)}ft.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ft.warn("rendering");if(this.times>3)return ft.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;if(!e)return ft.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.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(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.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(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(E.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT)),this.target&&this.__requestRender()}))}__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.changed=!0}}__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||ft.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_(x.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:_t}=L;class wt{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 c(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 c;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 c;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new c;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 c,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||_t(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&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()}}const{Yes:vt,NoAndSkip:mt,YesAndSkip:yt}=R,xt={},bt={},Bt={};class Et{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new wt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":xt.id=t.substring(1),t=xt;break;case".":bt.className=t.substring(1),t=bt;break;default:Bt.tag=t,t=Bt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,e,s){return"node"===i.name&&this.target.emit(x.CHECK_UPDATE),this.picker.getByPoint(t,e,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&_.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===vt||o===yt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<mt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(p.REMOVE,this.__onRemoveChild,this),this.target.on_(g.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new et(t,e),layouter:(t,e)=>new pt(t,e),renderer:(t,e,i)=>new gt(t,e,i),selector:(t,e)=>new Et(t,e)}),i.layout=pt.fullLayout;const Lt={convert(t,e){const i=I.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=I.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=Lt.getTouch(t),s=I.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]},Rt={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let s,n=1,{zoomMode:o,zoomSpeed:r}=e;const a=t.deltaY||t.deltaX;if(o?(s="mouse"===o||!t.deltaX&&(i.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(t.shiftKey||t.metaKey||t.ctrlKey)&&(s=!0)):s=!t.shiftKey&&(t.metaKey||t.ctrlKey),s){r=k.within(r,0,1);n=1-a/(4*(t.deltaY?e.delta.y:e.delta.x))*r,n<.5&&(n=.5),n>=1.5&&(n=1.5)}return n}},kt={convert(t){const e=I.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:Mt,getZoomEventData:Tt,getRotateEventData:St}=I;class Ct extends F{__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(kt.convert(t))}onKeyUp(t){this.keyUp(kt.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(Lt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(Lt.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(Lt.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(Lt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(Lt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(Lt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(Lt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=Lt.getTouch(t);this.pointerDown(Lt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=Lt.getTouch(t);this.pointerMove(Lt.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=Lt.getTouch(t);this.pointerUp(Lt.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(I.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);const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):Rt.getScale(t,e),s=this.getLocal(t),n=I.getBase(t);1!==i?this.zoom(Tt(s,i,n)):this.move(Mt(s,e.getMove?e.getMove(t,e):Rt.getMove(t,e),n))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=this.getLocal(t),i=I.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=k.within(o,0,1),this.zoom(Tt(e,s*s,i)),this.rotate(St(e,n/Math.PI*180*(o/4+.1),i)),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&&z.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 Pt(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 Ot(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?Dt(t,!0,e,i):Wt(e,i);break;case"inside":At("inside",t,n,e,i);break;case"outside":At("outside",t,n,e,i)}}function At(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?Dt(e,!0,s,a):Wt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",Pt(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 Wt(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 Dt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&G.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Wt(i,s):s.stroke(),s.restoreBlendMode()):e?Wt(i,s):s.stroke())}const{getSpread:It,getOuterOf:Ft,getByMove:zt,getIntersectData:Ut}=L;let Gt;function Vt(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:V.string(r,a)};case"image":return G.image(i,t,e,s,!Gt||!Gt[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:V.string(e)}:void 0}}const Yt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Gt=G.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Vt(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?Pt(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&&G.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?Pt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Pt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Pt(e,i):n?i.fill(n):i.fill())},fillText:Pt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Ot(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();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)Ot(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Dt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Dt(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),Dt(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:Ot,drawTextStroke:Wt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=n;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,c=Ut(s?It(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=p),a=Ft(n,r),o=zt(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:d}}};let Nt={};const{get:jt,rotateOfOuter:Xt,translate:Ht,scaleOfOuter:qt,scale:Kt,rotate:Qt}=M;function $t(t,e,i,s,n,o,r){const a=jt();Ht(a,e.x+i,e.y+s),Kt(a,n,o),r&&Xt(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=jt();Ht(a,e.x+i,e.y+s),n&&Kt(a,n,o),r&&Qt(a,r),t.transform=a}function Zt(t,e,i,s,n,o,r,a,h,l){const d=jt();if(h)if("center"===l)Xt(d,{x:i/2,y:s/2},h);else switch(Qt(d,h),h){case 90:Ht(d,s,0);break;case 180:Ht(d,i,s);break;case 270:Ht(d,0,i)}Nt.x=e.x+n,Nt.y=e.y+o,Ht(d,Nt.x,Nt.y),r&&qt(d,Nt,r,a),t.transform=d}const{get:te,translate:ee}=M,ie=new v,se={};function ne(t,e,i,s){const{blendMode:n}=i;n&&(t.blendMode=n),t.data=oe(i,s,e)}function oe(t,e,i){let{width:s,height:n}=i;t.padding&&(e=ie.set(e).shrink(t.padding));const{opacity:o,mode:r,align:a,offset:h,scale:l,size:d,rotation:c,repeat:u}=t,p=e.width===s&&e.height===n,f={mode:r},g="center"!==a&&(c||0)%180==90,_=g?n:s,w=g?s:n;let v,m,y=0,x=0;if(r&&"cover"!==r&&"fit"!==r)d?(v=("number"==typeof d?d:d.width)/s,m=("number"==typeof d?d:d.height)/n):l&&(v="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!p||c){const t=e.width/_,i=e.height/w;v=m="fit"===r?Math.min(t,i):Math.max(t,i),y+=(e.width-s*v)/2,x+=(e.height-n*m)/2}if(a){const t={x:y,y:x,width:_,height:w};v&&(t.width*=v,t.height*=m),T.toPoint(a,t,e,se,!0),y+=se.x,x+=se.y}switch(h&&(y+=h.x,x+=h.y),r){case"strench":p||(s=e.width,n=e.height);break;case"normal":case"clip":(y||x||v||c)&&Jt(f,e,y,x,v,m,c);break;case"repeat":(!p||v||c)&&Zt(f,e,s,n,y,x,v,m,c,a),u||(f.repeat="repeat");break;default:v&&$t(f,e,y,x,v,m,c)}return f.transform||(e.x||e.y)&&(f.transform=te(),ee(f.transform,e.x,e.y)),v&&"strench"!==r&&(f.scaleX=v,f.scaleY=m),f.width=s,f.height=n,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let re,ae=new v;const{isSame:he}=L;function le(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||ne(n,s,i,o),!0}function de(t,e){pe(t,S.LOAD,e)}function ce(t,e){pe(t,S.LOADED,e)}function ue(t,e,i){e.error=i,t.forceUpdate("surface"),pe(t,S.ERROR,e)}function pe(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function fe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ge,scale:_e,copy:we}=M,{ceil:ve,abs:me}=Math;function ye(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o;if(e.patternId===r||t.destroyed)return!1;{n=me(n),o=me(o);const{image:t,data:a}=e;let h,l,{width:d,height:c,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=a;u&&(l=ge(),we(l,g),_e(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,d*=n,c*=o;const w=d*c;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,d/=h,c/=h),u&&(n/=u,o/=p),(g||1!==n||1!==o)&&(l||(l=ge(),g&&we(l,g)),_e(l,1/n,1/o));const m=t.getCanvas(ve(d)||1,ve(c)||1,f),y=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=y,e.patternId=r,!0}}function xe(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:be}=Math;const Be={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return re&&i===re.paint&&he(s,re.boxBounds)?o=re.leafPaint:(o={type:i.type,image:a},re=a.use>1?{leafPaint:o,paint:i,boxBounds:ae.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(le(t,e,i,a,o,s),n&&(de(t,r),ce(t,r))):a.error?n&&ue(t,r,a.error):(fe(t,!0),n&&de(t,r),o.loadId=a.load((()=>{fe(t,!1),t.destroyed||(le(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ce(t,r)),o.loadId=null}),(e=>{fe(t,!1),ue(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld;if(!s.data||s.patternId===o+"-"+r&&!N.running)return!1;{const{data:a}=s;if(n)if(a.repeat)n=!1;else{let{width:t,height:s}=a;t*=be(o)*e.pixelRatio,s*=be(r)*e.pixelRatio,a.scaleX&&(t*=a.scaleX,s*=a.scaleY),n=t*s>i.image.maxCacheSize||N.running}return n?(e.save(),e.clip(),s.blendMode&&(e.blendMode=s.blendMode),a.opacity&&(e.opacity*=a.opacity),a.transform&&e.transform(a.transform),e.drawImage(s.image.view,0,0,a.width,a.height),e.restore(),!0):(!s.style||N.running?ye(t,s,e.pixelRatio):s.patternTask||(s.patternTask=B.patternTasker.add((()=>xe(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&ye(t,s,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ye,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:ne,getPatternData:oe,fillOrFitMode:$t,clipMode:Jt,repeatMode:Zt},{toPoint:Ee}=C,Le={},Re={};function ke(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),V.string(s,i)):t.addColorStop(s.offset,V.string(s.color,i))}const{getAngle:Me,getDistance:Te}=P,{get:Se,rotateOfOuter:Ce,scaleOfOuter:Pe}=M,{toPoint:Oe}=C,Ae={},We={};function De(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=Me(e,i);o=Se(),n?(Pe(o,e,r/a*(s||1),1),Ce(o,e,t+90)):(Pe(o,e,1,r/a*(s||1)),Ce(o,e,t))}return o}const{getDistance:Ie}=P,{toPoint:Fe}=C,ze={},Ue={};const Ge={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;Ee(s||"top",e,Le),Ee(n||"bottom",e,Re);const h=i.canvas.createLinearGradient(Le.x,Le.y,Re.x,Re.y);ke(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;Oe(s||"center",e,Ae),Oe(n||"bottom",e,We);const l=i.canvas.createRadialGradient(Ae.x,Ae.y,0,Ae.x,Ae.y,Te(Ae,We));ke(l,t.stops,r);const d={type:o,style:l},c=De(e,Ae,We,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Fe(s||"center",e,ze),Fe(n||"bottom",e,Ue);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ze.x,ze.y):i.canvas.createRadialGradient(ze.x,ze.y,0,ze.x,ze.y,Ie(ze,Ue));ke(l,t.stops,r);const d={type:o,style:l},c=De(e,ze,Ue,h||1,i.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:De},{copy:Ve,toOffsetOutBounds:Ye}=L,Ne={},je={};function Xe(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ve(Ne,t.bounds),Ne.x+=e.x-r.x,Ne.y+=e.y-r.y,s){const{matrix:t}=n;Ne.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Ne.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Ne.width*=s,Ne.height*=s}t.copyWorld(n.canvas,t.bounds,Ne)}else s&&(Ve(Ne,e),Ne.x-=e.width/2*(s-1),Ne.y-=e.height/2*(s-1),Ne.width*=s,Ne.height*=s),t.copyWorld(n.canvas,r,s?Ne:e)}const{toOffsetOutBounds:He}=L,qe={};const Ke={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Ye(l,je),a.forEach(((a,g)=>{p.setWorldShadow(je.offsetX+a.x*c,je.offsetY+a.y*u,a.blur*c,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Xe(p,je,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,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),f&&g<f&&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:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;He(l,qe),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(qe.offsetX+a.x*c,qe.offsetY+a.y*u,a.blur*c),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Xe(p,qe,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,d,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),f&&g<f&&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:Qe}=m;function $e(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ze(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ze(t,i,s,o);break;case"path":i.restore()}}function Je(t){return t.getSameCanvas(!1,!0)}function Ze(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}j.prototype.__renderMask=function(t,e){let i,s,n,o,r;const{children:a}=this;for(let h=0,l=a.length;h<l;h++)i=a[h],i.__.mask&&(r&&($e(this,r,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Je(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="alpha",s||(s=Je(t)),n||(n=Je(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Qe(i,e)||i.__render(n||t,e);$e(this,r,t,n,s,o)};const ti=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ei=ti+"_#~&*+\\=|≮≯≈≠=…",ii=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 si(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ni=si("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oi=si("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ri=si(ti),ai=si(ei),hi=si("- —/~|┆·");var li;!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"}(li||(li={}));const{Letter:di,Single:ci,Before:ui,After:pi,Symbol:fi,Break:gi}=li;function _i(t){return ni[t]?di:hi[t]?gi:oi[t]?ui:ri[t]?pi:ai[t]?fi:ii.test(t)?ci:di}const wi={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 vi(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:mi}=wi,{Letter:yi,Single:xi,Before:bi,After:Bi,Symbol:Ei,Break:Li}=li;let Ri,ki,Mi,Ti,Si,Ci,Pi,Oi,Ai,Wi,Di,Ii,Fi,zi,Ui,Gi,Vi=[];function Yi(t,e){Ai&&!Oi&&(Oi=Ai),Ri.data.push({char:t,width:e}),Mi+=e}function Ni(){Ti+=Mi,Ri.width=Mi,ki.words.push(Ri),Ri={data:[]},Mi=0}function ji(){zi&&(Ui.paraNumber++,ki.paraStart=!0,zi=!1),Ai&&(ki.startCharSize=Oi,ki.endCharSize=Ai,Oi=0),ki.width=Ti,Gi.width&&mi(ki),Vi.push(ki),ki={words:[]},Ti=0}const Xi=0,Hi=1,qi=2;const{top:Ki,right:Qi,bottom:$i,left:Ji}=O;function Zi(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 ts={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[Qi]+l[Ji]),r&&(n=l[Ki],r-=l[Ki]+l[$i]));const d={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Ui=t,Vi=t.rows,Gi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Gi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;zi=!0,Di=null,Oi=Pi=Ai=Mi=Ti=0,Ri={data:[]},ki={words:[]};for(let s=0,l=e.length;s<l;s++)Ci=e[s],"\n"===Ci?(Mi&&Ni(),ki.paraEnd=!0,ji(),zi=!0):(Wi=_i(Ci),Wi===yi&&"none"!==r&&(Ci=vi(Ci,r,!Mi)),Pi=a.measureText(Ci).width,n&&(n<0&&(Ai=Pi),Pi+=n),Ii=Wi===xi&&(Di===xi||Di===yi)||Di===xi&&Wi!==Bi,Fi=!(Wi!==bi&&Wi!==xi||Di!==Ei&&Di!==Bi),Si=zi&&o?h-o:h,t&&h&&Ti+Mi+Pi>Si&&(i?(Mi&&Ni(),Ti&&ji()):(Fi||(Fi=Wi===yi&&Di==Bi),Ii||Fi||Wi===Li||Wi===bi||Wi===xi||Mi+Pi>Si?(Mi&&Ni(),Ti&&ji()):Ti&&ji()))," "===Ci&&!0!==zi&&Ti+Mi===0||(Wi===Li?(" "===Ci&&Mi&&Ni(),Yi(Ci,Pi),Ni()):Ii||Fi?(Mi&&Ni(),Yi(Ci,Pi)):Yi(Ci,Pi)),Di=Wi);Mi&&Ni(),Ti&&ji(),Vi.length>0&&(Vi[Vi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ui.paraNumber++,Vi.push({x:o||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(d,t,e),l&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Zi(e,"x",t[Ji]);break;case"right":Zi(e,"x",-t[Qi])}if(!n)switch(i.verticalAlign){case"top":Zi(e,"y",t[Ki]);break;case"bottom":Zi(e,"y",-t[$i])}}(l,d,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:d}=e;let c,u,p,{x:f,y:g,width:_,height:w}=s,v=n*i.length+(d?d*(t.paraNumber-1):0),m=o;if(a&&v>w)v=Math.max(w,n),t.overflow=i.length;else switch(l){case"middle":g+=(w-v)/2;break;case"bottom":g+=w-v}m+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=f,c.width<_||c.width>_&&!a)switch(h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&d&&o>0&&(m+=d),c.y=m,m+=n,t.overflow>o&&m>v&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,p=c.width,r<0&&(c.width<0?(p=-c.width+e.fontSize+r,u-=p,p+=e.fontSize):p-=r),u<s.x&&(s.x=u),p>s.width&&(s.width=p),a&&_&&_<p&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=v}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;n.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?Xi:l>.01?Hi:qi,t.isOverflow&&!a&&(t.textMode=!0),c===qi?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Hi?(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),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,e,o),d.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,d=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<d));s--){if(h<d&&" "!==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)}}))}}(d,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}}(d,e),d}};const es={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:is,addPoint:ss,toBounds:ns}=A;const os={export(t,e,s){this.running=!0;const n=d.fileType(e);return s=d.getExportOptions(s),function(t){rs||(rs=new W);return new Promise((e=>{rs.add((()=>xe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const h=t=>{o(t),r(),this.running=!1},{toURL:l}=i,{download:c}=i.origin;if("json"===e)return h({data:t.toJSON(s.json)});if("json"===n)return c(l(JSON.stringify(t.toJSON(s.json)),"text"),e),h({data:!0});if("svg"===e)return h({data:t.toSVG()});if("svg"===n)return c(l(t.toSVG(),"svg"),e),h({data:!0});const{leafer:u}=t;u?(as(t),u.waitViewCompleted((()=>xe(this,void 0,void 0,(function*(){let i,n,o=1,r=1;const{worldTransform:l,isLeafer:c,isFrame:p}=t,{slice:f,trim:g,onCanvas:_}=s;let w=s.scale||1,m=s.pixelRatio||1;const y=void 0===s.smooth?u.config.smooth:s.smooth,x=s.contextSettings||u.config.contextSettings;t.isApp&&(w*=m,m=t.app.pixelRatio);const b=s.screenshot||t.isApp,B=c&&b&&void 0===s.fill?t.fill:s.fill,E=d.isOpaqueImage(e)||B,L=new D;if(b)i=!0===b?c?u.canvas.bounds:t.worldRenderBounds:b;else{let e=s.relative||(c?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":L.set(l);break;case"local":L.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:L.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}i=t.getBounds("render",e)}const{x:R,y:k,width:M,height:T}=new v(i).scale(w);let S=a.canvas({width:Math.round(M),height:Math.round(T),pixelRatio:m,smooth:y,contextSettings:x});const C={matrix:L.scale(1/w).invert().translate(-R,-k).withScale(1/o*w,1/r*w)};let P;if(f&&(P=t,P.__worldOpacity=0,t=u,C.bounds=S.bounds),S.save(),p&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(S,C),t.fill=e}else t.__render(S,C);if(S.restore(),P&&P.__updateWorldOpacity(),g){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?ss(r,n,o):is(r={},n,o)),a++;const h=new v;return ns(r,h),h.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=a.canvas(s),S.copyWorld(t,n,s)}E&&S.fillWorld(S.bounds,B||"#FFFFFF","destination-over"),_&&_(S);const O="canvas"===e?S:yield S.export(e,s);h({data:O,width:S.pixelWidth,height:S.pixelHeight,renderBounds:i,trimBounds:n})}))))):h({data:!1})}))))}};let rs;function as(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>as(t)))}const hs=e.prototype,ls=t.get("@leafer-ui/export");hs.export=function(t,e){const{quality:i,blob:s}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},hs.toBlob=function(t,e){return new Promise((s=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{s(t)})).catch((t=>{ls.error(t),s(null)}))}))},hs.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},hs.saveAs=function(t,e){return new Promise((s=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{s(!0)})).catch((t=>{ls.error(t),s(!1)}))}))},Object.assign(X,ts),Object.assign(V,es),Object.assign(H,Yt),Object.assign(G,Be),Object.assign(Y,Ge),Object.assign(q,Ke),Object.assign(N,os),Object.assign(a,{interaction:(t,e,i,s)=>new Ct(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new U}),Z();export{Ct as Interaction,pt as Layouter,Q as LeaferCanvas,gt as Renderer,Et as Selector,et as Watcher,Z as useCanvas};