@leafer-ui/worker 1.0.0-rc.21 → 1.0.0-rc.22

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.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, Answer, MatrixHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, Answer, MatrixHelper, AroundHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { InteractionBase, HitCanvasManager } from '@leafer-ui/core';
@@ -678,32 +678,38 @@ class Picker {
678
678
  const target = options.target || this.target;
679
679
  this.exclude = options.exclude || null;
680
680
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
681
- this.findList = options.findList || [];
681
+ this.findList = new LeafList(options.findList);
682
682
  if (!options.findList)
683
- this.eachFind(target.children, target.__onlyHitMask);
684
- const list = this.findList;
685
- const leaf = this.getBestMatchLeaf();
683
+ this.hitBranch(target);
684
+ const { list } = this.findList;
685
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
686
686
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
687
687
  this.clear();
688
688
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
689
689
  }
690
- getBestMatchLeaf() {
691
- const { findList: targets } = this;
692
- if (targets.length > 1) {
690
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
691
+ if (list.length) {
693
692
  let find;
694
- this.findList = [];
693
+ this.findList = new LeafList();
695
694
  const { x, y } = this.point;
696
695
  const point = { x, y, radiusX: 0, radiusY: 0 };
697
- for (let i = 0, len = targets.length; i < len; i++) {
698
- find = targets[i];
699
- if (LeafHelper.worldHittable(find)) {
696
+ for (let i = 0, len = list.length; i < len; i++) {
697
+ find = list[i];
698
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
700
699
  this.hitChild(find, point);
701
700
  if (this.findList.length)
702
- return this.findList[0];
701
+ return this.findList.list[0];
703
702
  }
704
703
  }
705
704
  }
706
- return targets[0];
705
+ if (bottomList) {
706
+ for (let i = 0, len = bottomList.length; i < len; i++) {
707
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
708
+ if (this.findList.length)
709
+ return this.findList.list[0];
710
+ }
711
+ }
712
+ return list[0];
707
713
  }
708
714
  getPath(leaf) {
709
715
  const path = new LeafList();
@@ -745,6 +751,9 @@ class Picker {
745
751
  }
746
752
  return throughPath;
747
753
  }
754
+ hitBranch(branch) {
755
+ this.eachFind(branch.children, branch.__onlyHitMask);
756
+ }
748
757
  eachFind(children, hitMask) {
749
758
  let child, hit;
750
759
  const { point } = this, len = children.length;
@@ -766,11 +775,11 @@ class Picker {
766
775
  }
767
776
  }
768
777
  }
769
- hitChild(child, point) {
778
+ hitChild(child, point, proxy) {
770
779
  if (this.exclude && this.exclude.has(child))
771
780
  return;
772
781
  if (child.__hitWorld(point))
773
- this.findList.push(child);
782
+ this.findList.add(proxy || child);
774
783
  }
775
784
  clear() {
776
785
  this.point = null;
@@ -1216,79 +1225,75 @@ const PaintModule = {
1216
1225
 
1217
1226
  let origin = {};
1218
1227
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
1219
- function fillOrFitMode(data, mode, box, width, height, rotation) {
1228
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1220
1229
  const transform = get$4();
1221
- const swap = rotation && rotation !== 180;
1222
- const sw = box.width / (swap ? height : width);
1223
- const sh = box.height / (swap ? width : height);
1224
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
1225
- const x = box.x + (box.width - width * scale) / 2;
1226
- const y = box.y + (box.height - height * scale) / 2;
1227
- translate$1(transform, x, y);
1228
- scaleHelper(transform, scale);
1230
+ translate$1(transform, box.x + x, box.y + y);
1231
+ scaleHelper(transform, scaleX, scaleY);
1229
1232
  if (rotation)
1230
1233
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
1231
- data.scaleX = data.scaleY = scale;
1232
1234
  data.transform = transform;
1233
1235
  }
1234
1236
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1235
1237
  const transform = get$4();
1236
- translate$1(transform, box.x, box.y);
1237
- if (x || y)
1238
- translate$1(transform, x, y);
1239
- if (scaleX) {
1238
+ translate$1(transform, box.x + x, box.y + y);
1239
+ if (scaleX)
1240
1240
  scaleHelper(transform, scaleX, scaleY);
1241
- data.scaleX = transform.a;
1242
- data.scaleY = transform.d;
1243
- }
1244
1241
  if (rotation)
1245
1242
  rotate(transform, rotation);
1246
1243
  data.transform = transform;
1247
1244
  }
1248
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
1245
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
1249
1246
  const transform = get$4();
1250
1247
  if (rotation) {
1251
- rotate(transform, rotation);
1252
- switch (rotation) {
1253
- case 90:
1254
- translate$1(transform, height, 0);
1255
- break;
1256
- case 180:
1257
- translate$1(transform, width, height);
1258
- break;
1259
- case 270:
1260
- translate$1(transform, 0, width);
1261
- break;
1248
+ if (around === 'center') {
1249
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
1250
+ }
1251
+ else {
1252
+ rotate(transform, rotation);
1253
+ switch (rotation) {
1254
+ case 90:
1255
+ translate$1(transform, height, 0);
1256
+ break;
1257
+ case 180:
1258
+ translate$1(transform, width, height);
1259
+ break;
1260
+ case 270:
1261
+ translate$1(transform, 0, width);
1262
+ break;
1263
+ }
1262
1264
  }
1263
1265
  }
1264
- origin.x = box.x;
1265
- origin.y = box.y;
1266
- if (x || y)
1267
- origin.x += x, origin.y += y;
1266
+ origin.x = box.x + x;
1267
+ origin.y = box.y + y;
1268
1268
  translate$1(transform, origin.x, origin.y);
1269
- if (scaleX) {
1269
+ if (scaleX)
1270
1270
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
1271
- data.scaleX = scaleX;
1272
- data.scaleY = scaleY;
1273
- }
1274
1271
  data.transform = transform;
1275
1272
  }
1276
1273
 
1277
1274
  const { get: get$3, translate } = MatrixHelper;
1278
1275
  const tempBox = new Bounds();
1276
+ const tempPoint = {};
1279
1277
  function createData(leafPaint, image, paint, box) {
1280
1278
  let { width, height } = image;
1281
1279
  if (paint.padding)
1282
1280
  box = tempBox.set(box).shrink(paint.padding);
1283
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
1281
+ const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
1284
1282
  const sameBox = box.width === width && box.height === height;
1285
1283
  if (blendMode)
1286
1284
  leafPaint.blendMode = blendMode;
1287
1285
  const data = leafPaint.data = { mode };
1288
- let x, y, scaleX, scaleY;
1289
- if (offset)
1290
- x = offset.x, y = offset.y;
1291
- if (size) {
1286
+ const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
1287
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
1288
+ let x = 0, y = 0, scaleX, scaleY;
1289
+ if (!mode || mode === 'cover' || mode === 'fit') {
1290
+ if (!sameBox || rotation) {
1291
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
1292
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
1293
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
1294
+ }
1295
+ }
1296
+ else if (size) {
1292
1297
  scaleX = (typeof size === 'number' ? size : size.width) / width;
1293
1298
  scaleY = (typeof size === 'number' ? size : size.height) / height;
1294
1299
  }
@@ -1296,26 +1301,36 @@ function createData(leafPaint, image, paint, box) {
1296
1301
  scaleX = typeof scale === 'number' ? scale : scale.x;
1297
1302
  scaleY = typeof scale === 'number' ? scale : scale.y;
1298
1303
  }
1304
+ if (around) {
1305
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
1306
+ if (scaleX)
1307
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
1308
+ AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
1309
+ x += tempPoint.x, y += tempPoint.y;
1310
+ }
1311
+ if (offset)
1312
+ x += offset.x, y += offset.y;
1299
1313
  switch (mode) {
1300
1314
  case 'strench':
1301
1315
  if (!sameBox)
1302
1316
  width = box.width, height = box.height;
1303
1317
  break;
1318
+ case 'normal':
1304
1319
  case 'clip':
1305
- if (offset || scaleX || rotation)
1320
+ if (x || y || scaleX || rotation)
1306
1321
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
1307
1322
  break;
1308
1323
  case 'repeat':
1309
1324
  if (!sameBox || scaleX || rotation)
1310
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
1325
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
1311
1326
  if (!repeat)
1312
1327
  data.repeat = 'repeat';
1313
1328
  break;
1314
1329
  case 'fit':
1315
1330
  case 'cover':
1316
1331
  default:
1317
- if (!sameBox || rotation)
1318
- fillOrFitMode(data, mode, box, width, height, rotation);
1332
+ if (scaleX)
1333
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
1319
1334
  }
1320
1335
  if (!data.transform) {
1321
1336
  if (box.x || box.y) {
@@ -1323,6 +1338,10 @@ function createData(leafPaint, image, paint, box) {
1323
1338
  translate(data.transform, box.x, box.y);
1324
1339
  }
1325
1340
  }
1341
+ if (scaleX && mode !== 'strench') {
1342
+ data.scaleX = scaleX;
1343
+ data.scaleY = scaleY;
1344
+ }
1326
1345
  data.width = width;
1327
1346
  data.height = height;
1328
1347
  if (opacity)
@@ -2410,6 +2429,13 @@ const ExportModule = {
2410
2429
  resolve();
2411
2430
  this.running = false;
2412
2431
  };
2432
+ if (filename === 'json') {
2433
+ return over({ data: leaf.toJSON() });
2434
+ }
2435
+ else if (FileHelper.fileType(filename) === 'json') {
2436
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
2437
+ return over({ data: true });
2438
+ }
2413
2439
  const { leafer } = leaf;
2414
2440
  if (leafer) {
2415
2441
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as O,HitCanvasManager as C}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as T,ColorConvert as I,PaintGradient as P,Export as F,Group as D,TextConvert as Y,Paint as N,Effect as X}from"@leafer-ui/draw";class G extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:U}=a;function H(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:U(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:U(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:V}=navigator;V.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):V.indexOf("Safari")>-1&&-1===V.indexOf("Chrome")&&(e.fullImageShadow=!0),V.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):V.indexOf("Mac")>-1?e.os="Mac":V.indexOf("Linux")>-1&&(e.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:j,updateBounds:z,updateAllWorldOpacity:Q}=u,{pushAllChildBranch:Z,pushAllParent:K}=f;const{worldBounds:$}=_,J={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),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:et,updateAllChange:it}=u,nt=p.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(j(t,!0),e.add(t),t.isBranch&&Z(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||z(n[t])}z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),st.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){et(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const at=p.get("Renderer");class ot{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=r.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 g,at.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,at.error(t)}at.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return at.warn("rendering");if(this.times>3)return at.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return at.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.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 g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new g(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||at.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.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:rt}=B;class dt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=s?this.getPath(r):this.getHitablePath(r);return this.clear(),n?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:n}=this.point,s={x:i,y:n,radiusX:0,radiusY:0};for(let i=0,n=t.length;i<n;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,s),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;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,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||rt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ht,NoAndSkip:lt,YesAndSkip:ct}=R;class ut{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},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new dt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":const n=this.getById(t.substring(1),e);return i?n:n?[n]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}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&&u.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,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===ht||a===ct){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<lt&&this.eachFind(s.children,e,i,n)}}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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.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={})}}function ft(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function gt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?wt(t,!0,e,i):pt(e,i);break;case"inside":_t("inside",t,s,e,i);break;case"outside":_t("outside",t,s,e,i)}}function _t(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?wt(e,!0,n,r):pt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",ft(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function pt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function wt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&T.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?pt(i,n):n.stroke(),n.restoreBlendMode()):e?pt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new ut(t,e)}),e.layout=st.fullLayout;const{getSpread:yt,getOuterOf:mt,getByMove:vt,getIntersectData:xt}=B;let bt;function Bt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:I.string(o,r)};case"image":return T.image(i,t,e,n,!bt||!bt[e.url]);case"linear":return P.linearGradient(e,n);case"radial":return P.radialGradient(e,n);case"angular":return P.conicGradient(e,n);default:return e.r?{type:"solid",style:I.string(e)}:void 0}}const Rt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),bt=T.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Bt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?ft(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&T.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?ft(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?ft(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?ft(e,i):s?i.fill(s):i.fill())},fillText:ft,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)gt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)gt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),wt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),wt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),wt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:gt,drawTextStroke:pt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=xt(n?yt(e.bounds,n*h,n*l):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=mt(s,o),a=vt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let kt={};const{get:Et,rotateOfOuter:Lt,translate:St,scaleOfOuter:Mt,scale:At,rotate:Wt}=k;function Ot(t,e,i,n,s,a){const o=Et(),r=a&&180!==a,d=i.width/(r?s:n),h=i.height/(r?n:s),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-n*l)/2,u=i.y+(i.height-s*l)/2;St(o,c,u),At(o,l),a&&Lt(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function Ct(t,e,i,n,s,a,o){const r=Et();St(r,e.x,e.y),(i||n)&&St(r,i,n),s&&(At(r,s,a),t.scaleX=r.a,t.scaleY=r.d),o&&Wt(r,o),t.transform=r}function Tt(t,e,i,n,s,a,o,r,d){const h=Et();if(d)switch(Wt(h,d),d){case 90:St(h,n,0);break;case 180:St(h,i,n);break;case 270:St(h,0,i)}kt.x=e.x,kt.y=e.y,(s||a)&&(kt.x+=s,kt.y+=a),St(h,kt.x,kt.y),o&&(Mt(h,kt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:It,translate:Pt}=k,Ft=new g;function Dt(t,e,i,n){let{width:s,height:a}=e;i.padding&&(n=Ft.set(n).shrink(i.padding));const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,g=n.width===s&&n.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/s,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":g||(s=n.width,a=n.height);break;case"clip":(d||y||c)&&Ct(_,n,p,w,y,m,c);break;case"repeat":(!g||y||c)&&Tt(_,n,s,a,p,w,y,m,c),f||(_.repeat="repeat");break;default:g&&!c||Ot(_,r,n,s,a,c)}_.transform||(n.x||n.y)&&(_.transform=It(),Pt(_.transform,n.x,n.y)),_.width=s,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Yt,Nt=new g;const{isSame:Xt}=B;function Gt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Dt(s,n,i,a),!0}function Ut(t,e){qt(t,E.LOAD,e)}function Ht(t,e){qt(t,E.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,E.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function jt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:zt,scale:Qt,copy:Zt}=k,{ceil:Kt,abs:$t}=Math;function Jt(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=$t(s),a=$t(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=zt(),Zt(h,_),Qt(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(h||(h=zt(),_&&Zt(h,_)),Qt(h,1/s,1/a));const m=t.getCanvas(Kt(l)||1,Kt(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}function te(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ee}=Math;const ie={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return Yt&&i===Yt.paint&&Xt(n,Yt.boxBounds)?a=Yt.leafPaint:(a={type:i.type,image:r},Yt=r.use>1?{leafPaint:a,paint:i,boxBounds:Nt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Gt(t,e,i,r,a,n),s&&(Ut(t,o),Ht(t,o))):r.error?s&&Vt(t,o,r.error):(jt(t,!0),s&&Ut(t,o),a.loadId=r.load((()=>{jt(t,!1),t.destroyed||(Gt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ht(t,o)),a.loadId=null}),(e=>{jt(t,!1),Vt(t,o,e),a.loadId=null}))),a},createData:Dt,fillOrFitMode:Ot,clipMode:Ct,repeatMode:Tt,createPattern:Jt,checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=ee(a)*i.pixelRatio,n*=ee(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||F.running?Jt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>te(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Jt(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},ne={x:.5,y:0},se={x:.5,y:1};function ae(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],t.addColorStop(n.offset,I.string(n.color,i))}const{set:oe,getAngle:re,getDistance:de}=L,{get:he,rotateOfOuter:le,scaleOfOuter:ce}=k,ue={x:.5,y:.5},fe={x:.5,y:1},ge={},_e={};const{set:pe,getAngle:we,getDistance:ye}=L,{get:me,rotateOfOuter:ve,scaleOfOuter:xe}=k,be={x:.5,y:.5},Be={x:.5,y:1},Re={},ke={};const Ee={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;n||(n=ne),s||(s=se);const d=e.canvas.createLinearGradient(i.x+n.x*i.width,i.y+n.y*i.height,i.x+s.x*i.width,i.y+s.y*i.height);ae(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=ue),s||(s=fe);const{x:h,y:l,width:c,height:u}=i;let f;oe(ge,h+n.x*c,l+n.y*u),oe(_e,h+s.x*c,l+s.y*u),(c!==u||d)&&(f=he(),ce(f,ge,c/u*(d||1),1),le(f,ge,re(ge,_e)+90));const g=e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,de(ge,_e));ae(g,t.stops,o);const _={type:a,style:g,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=be),s||(s=Be);const{x:h,y:l,width:c,height:u}=i;pe(Re,h+n.x*c,l+n.y*u),pe(ke,h+s.x*c,l+s.y*u);const f=me(),g=we(Re,ke);e.conicGradientRotate90?(xe(f,Re,c/u*(d||1),1),ve(f,Re,g+90)):(xe(f,Re,1,c/u*(d||1)),ve(f,Re,g));const _=e.conicGradientSupport?e.canvas.createConicGradient(0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ye(Re,ke));ae(_,t.stops,o);const p={type:a,style:_,transform:f};return r&&(p.blendMode=r),p}},{copy:Le,toOffsetOutBounds:Se}=B,Me={},Ae={};function We(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Le(Me,t.bounds),Me.x+=i.x-o.x,Me.y+=i.y-o.y,n){const{matrix:t}=s;Me.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Me.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Me.width*=n,Me.height*=n}t.copyWorld(s.canvas,t.bounds,Me)}else n&&(Le(Me,i),Me.x-=i.width/2*(n-1),Me.y-=i.height/2*(n-1),Me.width*=n,Me.height*=n),t.copyWorld(s.canvas,o,n?Me:i)}const{toOffsetOutBounds:Oe}=B,Ce={};const Te={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Se(h,Ae),r.forEach(((r,_)=>{f.setWorldShadow(Ae.offsetX+r.x*c,Ae.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,We(f,Ae,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Oe(h,Ce),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,We(f,Ce,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ie}=_;function Pe(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),De(t,e,i,1)}(t,i,n,s);break;case"opacity-path":De(t,i,n,a);break;case"path":i.restore()}}function Fe(t){return t.getSameCanvas(!1,!0)}function De(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}D.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Pe(this,o,t,s,n,a),n=s=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Fe(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Fe(t)),s||(s=Fe(t)),i.__render(n,e)),"clipping"!==i.__.maskType)||Ie(i,e)||i.__render(s||t,e);Pe(this,o,t,s,n,a)};const Ye=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ne=Ye+"_#~&*+\\=|≮≯≈≠=…",Xe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ue=Ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),He=Ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ve=Ge(Ye),qe=Ge(Ne),je=Ge("- —/~|┆·");var ze;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ze||(ze={}));const{Letter:Qe,Single:Ze,Before:Ke,After:$e,Symbol:Je,Break:ti}=ze;function ei(t){return Ue[t]?Qe:je[t]?ti:He[t]?Ke:Ve[t]?$e:qe[t]?Je:Xe.test(t)?Ze:Qe}const ii={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ni(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:si}=ii,{Letter:ai,Single:oi,Before:ri,After:di,Symbol:hi,Break:li}=ze;let ci,ui,fi,gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li=[];function Si(t,e){mi&&!yi&&(yi=mi),ci.data.push({char:t,width:e}),fi+=e}function Mi(){gi+=fi,ci.width=fi,ui.words.push(ci),ci={data:[]},fi=0}function Ai(){Ri&&(ki.paraNumber++,ui.paraStart=!0,Ri=!1),mi&&(ui.startCharSize=yi,ui.endCharSize=mi,yi=0),ui.width=gi,Ei.width&&si(ui),Li.push(ui),ui={words:[]},gi=0}const Wi=0,Oi=1,Ci=2;const{top:Ti,right:Ii,bottom:Pi,left:Fi}=S;function Di(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Fi],a-=h[Ii]+h[Fi]),o&&(s=h[Ti],o-=h[Ti]+h[Pi]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){ki=t,Li=t.rows,Ei=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Ei;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ri=!0,xi=null,yi=wi=mi=fi=gi=0,ci={data:[]},ui={words:[]};for(let n=0,h=i.length;n<h;n++)pi=i[n],"\n"===pi?(fi&&Mi(),ui.paraEnd=!0,Ai(),Ri=!0):(vi=ei(pi),vi===ai&&"none"!==o&&(pi=ni(pi,o,!fi)),wi=r.measureText(pi).width,s&&(s<0&&(mi=wi),wi+=s),bi=vi===oi&&(xi===oi||xi===ai)||xi===oi&&vi!==di,Bi=!(vi!==ri&&vi!==oi||xi!==hi&&xi!==di),_i=Ri&&a?d-a:d,t&&d&&gi+fi+wi>_i&&(e?(fi&&Mi(),Ai()):(Bi||(Bi=vi===ai&&xi==di),bi||Bi||vi===li||vi===ri||vi===oi||fi+wi>_i?(fi&&Mi(),Ai()):Ai()))," "===pi&&!0!==Ri&&gi+fi===0||(vi===li?(" "===pi&&fi&&Mi(),Si(pi,wi),Mi()):bi||Bi?(fi&&Mi(),Si(pi,wi)):Si(pi,wi)),xi=vi);fi&&Mi(),gi&&Ai(),Li.length>0&&(Li[Li.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{ki.paraNumber++,Li.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Di(e,"x",t[Fi]);break;case"right":Di(e,"x",-t[Ii])}if(!s)switch(i.verticalAlign){case"top":Di(e,"y",t[Ti]);break;case"bottom":Di(e,"y",-t[Pi])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=g,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Wi:h>.01?Oi:Ci,t.isOverflow&&!r&&(t.textMode=!0),c===Ci?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Oi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&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}}(l,i),l}};const Ni={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Xi,addPoint:Gi,toBounds:Ui}=M;const Hi={export(t,e,i){return this.running=!0,function(t){Vi||(Vi=new A);return new Promise((e=>{Vi.add((()=>te(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>te(this,void 0,void 0,(function*(){i=a.getExportOptions(i);let s,o,h=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=i,y=i.scale||1,m=i.pixelRatio||1,v=i.screenshot||t.isApp,x=u&&v&&void 0===i.fill?t.fill:i.fill,b=a.isOpaqueImage(e)||x,B=new W;if(v)s=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let e=i.relative||(u?"inner":"local");switch(h=c.scaleX,l=c.scaleY,e){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),h/=t.scaleX,l/=t.scaleY;break;case"world":h=1,l=1;break;case"page":e=t.leafer;default:B.set(c).divide(t.getTransform(e));const i=e.worldTransform;h/=h/i.scaleX,l/=l/i.scaleY}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:L}=new g(s).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/h*y,1/l*y)};if(_&&(t=d,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Gi(o,s,a):Xi(o={},s,a)),r++;const d=new g;return Ui(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===e?S:yield S.export(e,i);r({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:s,trimBounds:o})})))):r({data:!1})}))))}};let Vi;const qi=t.prototype,ji=p.get("@leafer-ui/export");qi.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},qi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{ji.error(t),n(null)}))}))},qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},qi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{ji.error(t),n(!1)}))}))},Object.assign(Y,Yi),Object.assign(I,Ni),Object.assign(N,Rt),Object.assign(T,ie),Object.assign(P,Ee),Object.assign(X,Te),Object.assign(F,Hi),Object.assign(n,{interaction:(t,e,i,n)=>new O(t,e,i,n),hitCanvas:(t,e)=>new G(t,e),hitCanvasManager:()=>new C}),H();export{st as Layouter,G as LeaferCanvas,ot as Renderer,ut as Selector,q as Watcher,H as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,AroundHelper as E,ImageEvent as L,PointHelper as S,Direction4 as M,TwoPointBoundsHelper as A,TaskProcessor as O,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as C,HitCanvasManager as T}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as P,PaintGradient as F,Export as D,Group as N,TextConvert as Y,Paint as U,Effect as G}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:X}=a;function j(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:X(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:X(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{!t.startsWith("data:")&&e.image.suffix&&(t+=(t.includes("?")?"&":"?")+e.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},e.devicePixelRatio=1;const{userAgent:V}=navigator;V.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):V.indexOf("Safari")>-1&&-1===V.indexOf("Chrome")&&(e.fullImageShadow=!0),V.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):V.indexOf("Mac")>-1?e.os="Mac":V.indexOf("Linux")>-1&&(e.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:z,updateBounds:Q,updateAllWorldOpacity:J}=u,{pushAllChildBranch:Z,pushAllParent:K}=f;const{worldBounds:$}=_,tt={x:0,y:0,width:1e5,height:1e5};class et{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(tt):this.afterBounds.setListWithFn(t,$),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:it,updateAllChange:nt}=u,st=p.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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){st.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?st.warn("layouting"):this.times>3?st.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(z(t,!0),e.add(t),t.isBranch&&Z(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||Q(n[t])}Q(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&J(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),at.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){it(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new et([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new et(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_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=p.get("Renderer");class rt{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=r.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 g,ot.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ot.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.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 g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new g(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||ot.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.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:dt}=B;class ht{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,a),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 o;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,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||dt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:lt,NoAndSkip:ct,YesAndSkip:ut}=R;class ft{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},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new ht(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":const n=this.getById(t.substring(1),e);return i?n:n?[n]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}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&&u.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,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===lt||a===ut){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ct&&this.eachFind(s.children,e,i,n)}}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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.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={})}}function gt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function _t(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?yt(t,!0,e,i):wt(e,i);break;case"inside":pt("inside",t,s,e,i);break;case"outside":pt("outside",t,s,e,i)}}function pt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?yt(e,!0,n,r):wt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",gt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function wt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function yt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&I.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?wt(i,n):n.stroke(),n.restoreBlendMode()):e?wt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new rt(t,e,i),selector:(t,e)=>new ft(t,e)}),e.layout=at.fullLayout;const{getSpread:mt,getOuterOf:vt,getByMove:xt,getIntersectData:bt}=B;let Bt;function Rt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:P.string(o,r)};case"image":return I.image(i,t,e,n,!Bt||!Bt[e.url]);case"linear":return F.linearGradient(e,n);case"radial":return F.radialGradient(e,n);case"angular":return F.conicGradient(e,n);default:return e.r?{type:"solid",style:P.string(e)}:void 0}}const kt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Bt=I.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Rt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?gt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&I.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?gt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?gt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?gt(e,i):s?i.fill(s):i.fill())},fillText:gt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)_t(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)_t(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),yt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),yt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),yt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:_t,drawTextStroke:wt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=bt(n?mt(e.bounds,n*h,n*l):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=vt(s,o),a=xt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Et={};const{get:Lt,rotateOfOuter:St,translate:Mt,scaleOfOuter:At,scale:Ot,rotate:Wt}=k;function Ct(t,e,i,n,s,a,o){const r=Lt();Mt(r,e.x+i,e.y+n),Ot(r,s,a),o&&St(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Tt(t,e,i,n,s,a,o){const r=Lt();Mt(r,e.x+i,e.y+n),s&&Ot(r,s,a),o&&Wt(r,o),t.transform=r}function It(t,e,i,n,s,a,o,r,d,h){const l=Lt();if(d)if("center"===h)St(l,{x:i/2,y:n/2},d);else switch(Wt(l,d),d){case 90:Mt(l,n,0);break;case 180:Mt(l,i,n);break;case 270:Mt(l,0,i)}Et.x=e.x+s,Et.y=e.y+a,Mt(l,Et.x,Et.y),o&&At(l,Et,o,r),t.transform=l}const{get:Pt,translate:Ft}=k,Dt=new g,Nt={};function Yt(t,e,i,n){let{width:s,height:a}=e;i.padding&&(n=Dt.set(n).shrink(i.padding));const{opacity:o,mode:r,around:d,offset:h,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,_=n.width===s&&n.height===a;f&&(t.blendMode=f);const p=t.data={mode:r},w="center"!==d&&(u||0)%180==90,y=w?a:s,m=w?s:a;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/s,x=("number"==typeof c?c:c.height)/a):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!_||u){const t=n.width/y,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,B+=(n.height-a*x)/2}if(d){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),E.toPoint(d,n,Nt,!0,t),b+=Nt.x,B+=Nt.y}switch(h&&(b+=h.x,B+=h.y),r){case"strench":_||(s=n.width,a=n.height);break;case"normal":case"clip":(b||B||v||u)&&Tt(p,n,b,B,v,x,u);break;case"repeat":(!_||v||u)&&It(p,n,s,a,b,B,v,x,u,d),g||(p.repeat="repeat");break;default:v&&Ct(p,n,b,B,v,x,u)}p.transform||(n.x||n.y)&&(p.transform=Pt(),Ft(p.transform,n.x,n.y)),v&&"strench"!==r&&(p.scaleX=v,p.scaleY=x),p.width=s,p.height=a,o&&(p.opacity=o),g&&(p.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let Ut,Gt=new g;const{isSame:Ht}=B;function Xt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Yt(s,n,i,a),!0}function jt(t,e){zt(t,L.LOAD,e)}function Vt(t,e){zt(t,L.LOADED,e)}function qt(t,e,i){e.error=i,t.forceUpdate("surface"),zt(t,L.ERROR,e)}function zt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Qt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Jt,scale:Zt,copy:Kt}=k,{ceil:$t,abs:te}=Math;function ee(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=te(s),a=te(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=Jt(),Kt(h,_),Zt(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(h||(h=Jt(),_&&Kt(h,_)),Zt(h,1/s,1/a));const m=t.getCanvas($t(l)||1,$t(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}function ie(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ne}=Math;const se={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return Ut&&i===Ut.paint&&Ht(n,Ut.boxBounds)?a=Ut.leafPaint:(a={type:i.type,image:r},Ut=r.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Xt(t,e,i,r,a,n),s&&(jt(t,o),Vt(t,o))):r.error?s&&qt(t,o,r.error):(Qt(t,!0),s&&jt(t,o),a.loadId=r.load((()=>{Qt(t,!1),t.destroyed||(Xt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Vt(t,o)),a.loadId=null}),(e=>{Qt(t,!1),qt(t,o,e),a.loadId=null}))),a},createData:Yt,fillOrFitMode:Ct,clipMode:Tt,repeatMode:It,createPattern:ee,checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=ne(a)*i.pixelRatio,n*=ne(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||D.running?ee(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>ie(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ee(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},ae={x:.5,y:0},oe={x:.5,y:1};function re(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],t.addColorStop(n.offset,P.string(n.color,i))}const{set:de,getAngle:he,getDistance:le}=S,{get:ce,rotateOfOuter:ue,scaleOfOuter:fe}=k,ge={x:.5,y:.5},_e={x:.5,y:1},pe={},we={};const{set:ye,getAngle:me,getDistance:ve}=S,{get:xe,rotateOfOuter:be,scaleOfOuter:Be}=k,Re={x:.5,y:.5},ke={x:.5,y:1},Ee={},Le={};const Se={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;n||(n=ae),s||(s=oe);const d=e.canvas.createLinearGradient(i.x+n.x*i.width,i.y+n.y*i.height,i.x+s.x*i.width,i.y+s.y*i.height);re(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=ge),s||(s=_e);const{x:h,y:l,width:c,height:u}=i;let f;de(pe,h+n.x*c,l+n.y*u),de(we,h+s.x*c,l+s.y*u),(c!==u||d)&&(f=ce(),fe(f,pe,c/u*(d||1),1),ue(f,pe,he(pe,we)+90));const g=e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,le(pe,we));re(g,t.stops,o);const _={type:a,style:g,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=Re),s||(s=ke);const{x:h,y:l,width:c,height:u}=i;ye(Ee,h+n.x*c,l+n.y*u),ye(Le,h+s.x*c,l+s.y*u);const f=xe(),g=me(Ee,Le);e.conicGradientRotate90?(Be(f,Ee,c/u*(d||1),1),be(f,Ee,g+90)):(Be(f,Ee,1,c/u*(d||1)),be(f,Ee,g));const _=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,ve(Ee,Le));re(_,t.stops,o);const p={type:a,style:_,transform:f};return r&&(p.blendMode=r),p}},{copy:Me,toOffsetOutBounds:Ae}=B,Oe={},We={};function Ce(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Me(Oe,t.bounds),Oe.x+=i.x-o.x,Oe.y+=i.y-o.y,n){const{matrix:t}=s;Oe.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Oe.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Oe.width*=n,Oe.height*=n}t.copyWorld(s.canvas,t.bounds,Oe)}else n&&(Me(Oe,i),Oe.x-=i.width/2*(n-1),Oe.y-=i.height/2*(n-1),Oe.width*=n,Oe.height*=n),t.copyWorld(s.canvas,o,n?Oe:i)}const{toOffsetOutBounds:Te}=B,Ie={};const Pe={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ae(h,We),r.forEach(((r,_)=>{f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ce(f,We,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Te(h,Ie),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ie.offsetX+r.x*c,Ie.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ce(f,Ie,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Fe}=_;function De(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ye(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ye(t,i,n,a);break;case"path":i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Ye(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}N.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(De(this,o,t,s,n,a),n=s=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ne(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ne(t)),s||(s=Ne(t)),i.__render(n,e)),"clipping"!==i.__.maskType)||Fe(i,e)||i.__render(s||t,e);De(this,o,t,s,n,a)};const Ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ge=Ue+"_#~&*+\\=|≮≯≈≠=…",He=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 Xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const je=Xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=Xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=Xe(Ue),ze=Xe(Ge),Qe=Xe("- —/~|┆·");var Je;!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"}(Je||(Je={}));const{Letter:Ze,Single:Ke,Before:$e,After:ti,Symbol:ei,Break:ii}=Je;function ni(t){return je[t]?Ze:Qe[t]?ii:Ve[t]?$e:qe[t]?ti:ze[t]?ei:He.test(t)?Ke:Ze}const si={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ai(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:oi}=si,{Letter:ri,Single:di,Before:hi,After:li,Symbol:ci,Break:ui}=Je;let fi,gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li,Si,Mi=[];function Ai(t,e){xi&&!vi&&(vi=xi),fi.data.push({char:t,width:e}),_i+=e}function Oi(){pi+=_i,fi.width=_i,gi.words.push(fi),fi={data:[]},_i=0}function Wi(){Ei&&(Li.paraNumber++,gi.paraStart=!0,Ei=!1),xi&&(gi.startCharSize=vi,gi.endCharSize=xi,vi=0),gi.width=pi,Si.width&&oi(gi),Mi.push(gi),gi={words:[]},pi=0}const Ci=0,Ti=1,Ii=2;const{top:Pi,right:Fi,bottom:Di,left:Ni}=M;function Yi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ui={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Ni],a-=h[Fi]+h[Ni]),o&&(s=h[Pi],o-=h[Pi]+h[Di]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Li=t,Mi=t.rows,Si=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Si;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,Bi=null,vi=mi=xi=_i=pi=0,fi={data:[]},gi={words:[]};for(let n=0,h=i.length;n<h;n++)yi=i[n],"\n"===yi?(_i&&Oi(),gi.paraEnd=!0,Wi(),Ei=!0):(bi=ni(yi),bi===ri&&"none"!==o&&(yi=ai(yi,o,!_i)),mi=r.measureText(yi).width,s&&(s<0&&(xi=mi),mi+=s),Ri=bi===di&&(Bi===di||Bi===ri)||Bi===di&&bi!==li,ki=!(bi!==hi&&bi!==di||Bi!==ci&&Bi!==li),wi=Ei&&a?d-a:d,t&&d&&pi+_i+mi>wi&&(e?(_i&&Oi(),Wi()):(ki||(ki=bi===ri&&Bi==li),Ri||ki||bi===ui||bi===hi||bi===di||_i+mi>wi?(_i&&Oi(),Wi()):Wi()))," "===yi&&!0!==Ei&&pi+_i===0||(bi===ui?(" "===yi&&_i&&Oi(),Ai(yi,mi),Oi()):Ri||ki?(_i&&Oi(),Ai(yi,mi)):Ai(yi,mi)),Bi=bi);_i&&Oi(),pi&&Wi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,Mi.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Yi(e,"x",t[Ni]);break;case"right":Yi(e,"x",-t[Fi])}if(!s)switch(i.verticalAlign){case"top":Yi(e,"y",t[Pi]);break;case"bottom":Yi(e,"y",-t[Di])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=g,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ci:h>.01?Ti:Ii,t.isOverflow&&!r&&(t.textMode=!0),c===Ii?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ti?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&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}}(l,i),l}};const Gi={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Hi,addPoint:Xi,toBounds:ji}=A;const Vi={export(t,i,s){return this.running=!0,function(t){qi||(qi=new O);return new Promise((e=>{qi.add((()=>ie(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1};if("json"===i)return d({data:t.toJSON()});if("json"===a.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),d({data:!0});const{leafer:h}=t;h?h.waitViewCompleted((()=>ie(this,void 0,void 0,(function*(){s=a.getExportOptions(s);let e,o,r=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=s,y=s.scale||1,m=s.pixelRatio||1,v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(i)||x,B=new W;if(v)e=!0===v?u?h.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(r=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:E,height:L}=new g(e).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/l*y)};if(_&&(t=h,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Xi(o,s,a):Hi(o={},s,a)),r++;const d=new g;return ji(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===i?S:yield S.export(i,s);d({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:e,trimBounds:o})})))):d({data:!1})}))))}};let qi;const zi=t.prototype,Qi=p.get("@leafer-ui/export");zi.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},zi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Qi.error(t),n(null)}))}))},zi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},zi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Qi.error(t),n(!1)}))}))},Object.assign(Y,Ui),Object.assign(P,Gi),Object.assign(U,kt),Object.assign(I,se),Object.assign(F,Se),Object.assign(G,Pe),Object.assign(D,Vi),Object.assign(n,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new T}),j();export{at as Layouter,H as LeaferCanvas,rt as Renderer,ft as Selector,q as Watcher,j as useCanvas};