@leafer-ui/worker 1.0.0-rc.3 → 1.0.0-rc.5

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,7 +1,7 @@
1
1
  import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, BoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, Creator, LeaferCanvasBase, canvasPatch, LeaferImage, InteractionBase, FileHelper, MatrixHelper, ImageEvent, PointHelper, MathHelper, TaskProcessor } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
- import { ColorConvert as ColorConvert$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$1 } from '@leafer-ui/core';
4
+ import { ColorConvert as ColorConvert$1, ImageManager as ImageManager$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$1 } from '@leafer-ui/core';
5
5
  export * from '@leafer-ui/core';
6
6
 
7
7
  class Watcher {
@@ -105,7 +105,7 @@ function updateMatrix(updateList, levelList) {
105
105
  let layout;
106
106
  updateList.list.forEach(leaf => {
107
107
  layout = leaf.__layout;
108
- if (levelList.without(leaf) && !layout.useZoomProxy) {
108
+ if (levelList.without(leaf) && !layout.proxyZoom) {
109
109
  if (layout.matrixChanged) {
110
110
  updateAllWorldMatrix$1(leaf);
111
111
  levelList.push(leaf);
@@ -424,8 +424,7 @@ class Renderer {
424
424
  const { canvas, updateBlocks: list } = this;
425
425
  if (!list)
426
426
  return debug.warn('PartRender: need update attr');
427
- if (list.some(block => block.includes(this.target.__world)))
428
- this.mergeBlocks();
427
+ this.mergeBlocks();
429
428
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
430
429
  this.clipRender(block); });
431
430
  }
@@ -444,7 +443,7 @@ class Renderer {
444
443
  canvas.clearWorld(bounds, true);
445
444
  canvas.clipWorld(bounds, true);
446
445
  }
447
- this.__render(bounds, realBounds);
446
+ this.__render(bounds, includes, realBounds);
448
447
  canvas.restore();
449
448
  Run.end(t);
450
449
  }
@@ -453,12 +452,12 @@ class Renderer {
453
452
  const { canvas } = this;
454
453
  canvas.save();
455
454
  canvas.clear();
456
- this.__render(canvas.bounds);
455
+ this.__render(canvas.bounds, true);
457
456
  canvas.restore();
458
457
  Run.end(t);
459
458
  }
460
- __render(bounds, realBounds) {
461
- const options = (bounds === null || bounds === void 0 ? void 0 : bounds.includes(this.target.__world)) ? {} : { bounds };
459
+ __render(bounds, includes, realBounds) {
460
+ const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
462
461
  if (this.needFill)
463
462
  this.canvas.fillWorld(bounds, this.config.fill);
464
463
  if (Debug.showRepaint)
@@ -1183,17 +1182,20 @@ function checkImage(ui, canvas, paint, allowPaint) {
1183
1182
  createPattern(ui, paint, canvas.pixelRatio);
1184
1183
  }
1185
1184
  else {
1186
- ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1187
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1188
- ui.forceUpdate('surface');
1189
- }), 300);
1185
+ if (!paint.patternTask) {
1186
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1187
+ paint.patternTask = null;
1188
+ if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
1189
+ ui.forceUpdate('surface');
1190
+ }), 300);
1191
+ }
1190
1192
  }
1191
1193
  return false;
1192
1194
  }
1193
1195
  }
1194
1196
  }
1195
1197
 
1196
- function recycleImage(data, attrName) {
1198
+ function recycleImage(attrName, data) {
1197
1199
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
1198
1200
  if (paints instanceof Array) {
1199
1201
  let image, recycleMap, input, url;
@@ -1238,11 +1240,11 @@ function fillText(ui, canvas) {
1238
1240
  }
1239
1241
  }
1240
1242
 
1241
- function fill(ui, canvas, fill) {
1243
+ function fill(fill, ui, canvas) {
1242
1244
  canvas.fillStyle = fill;
1243
1245
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
1244
1246
  }
1245
- function fills(ui, canvas, fills) {
1247
+ function fills(fills, ui, canvas) {
1246
1248
  let item;
1247
1249
  const { windingRule, __font } = ui.__;
1248
1250
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -1273,32 +1275,37 @@ function fills(ui, canvas, fills) {
1273
1275
  }
1274
1276
  }
1275
1277
 
1276
- function strokeText(ui, canvas, stroke) {
1278
+ function strokeText(stroke, ui, canvas, renderOptions) {
1277
1279
  const { strokeAlign } = ui.__;
1278
1280
  const isStrokes = typeof stroke !== 'string';
1279
1281
  switch (strokeAlign) {
1280
1282
  case 'center':
1281
1283
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
1282
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
1284
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
1283
1285
  break;
1284
1286
  case 'inside':
1285
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
1287
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
1286
1288
  break;
1287
1289
  case 'outside':
1288
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
1290
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
1289
1291
  break;
1290
1292
  }
1291
1293
  }
1292
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
1294
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
1293
1295
  const { strokeWidth, __font } = ui.__;
1294
1296
  const out = canvas.getSameCanvas(true);
1295
1297
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
1296
1298
  out.font = __font;
1297
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
1299
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
1298
1300
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
1299
1301
  fillText(ui, out);
1300
1302
  out.blendMode = 'normal';
1301
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1303
+ if (ui.__hasMirror || renderOptions.matrix) {
1304
+ canvas.copyWorldByReset(out);
1305
+ }
1306
+ else {
1307
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1308
+ }
1302
1309
  out.recycle();
1303
1310
  }
1304
1311
  function drawTextStroke(ui, canvas) {
@@ -1318,7 +1325,7 @@ function drawTextStroke(ui, canvas) {
1318
1325
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
1319
1326
  }
1320
1327
  }
1321
- function drawStrokesStyle(ui, strokes, canvas, isText) {
1328
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
1322
1329
  let item;
1323
1330
  for (let i = 0, len = strokes.length; i < len; i++) {
1324
1331
  item = strokes[i];
@@ -1338,13 +1345,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
1338
1345
  }
1339
1346
  }
1340
1347
 
1341
- function stroke(ui, canvas, stroke) {
1348
+ function stroke(stroke, ui, canvas, renderOptions) {
1342
1349
  const options = ui.__;
1343
1350
  const { strokeWidth, strokeAlign, __font } = options;
1344
1351
  if (!strokeWidth)
1345
1352
  return;
1346
1353
  if (__font) {
1347
- strokeText(ui, canvas, stroke);
1354
+ strokeText(stroke, ui, canvas, renderOptions);
1348
1355
  }
1349
1356
  else {
1350
1357
  switch (strokeAlign) {
@@ -1366,31 +1373,36 @@ function stroke(ui, canvas, stroke) {
1366
1373
  out.stroke();
1367
1374
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1368
1375
  out.clearWorld(ui.__layout.renderBounds);
1369
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1376
+ if (ui.__hasMirror || renderOptions.matrix) {
1377
+ canvas.copyWorldByReset(out);
1378
+ }
1379
+ else {
1380
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
1381
+ }
1370
1382
  out.recycle();
1371
1383
  break;
1372
1384
  }
1373
1385
  }
1374
1386
  }
1375
- function strokes(ui, canvas, strokes) {
1387
+ function strokes(strokes, ui, canvas, renderOptions) {
1376
1388
  const options = ui.__;
1377
1389
  const { strokeWidth, strokeAlign, __font } = options;
1378
1390
  if (!strokeWidth)
1379
1391
  return;
1380
1392
  if (__font) {
1381
- strokeText(ui, canvas, strokes);
1393
+ strokeText(strokes, ui, canvas, renderOptions);
1382
1394
  }
1383
1395
  else {
1384
1396
  switch (strokeAlign) {
1385
1397
  case 'center':
1386
1398
  canvas.setStroke(undefined, strokeWidth, options);
1387
- drawStrokesStyle(ui, strokes, canvas);
1399
+ drawStrokesStyle(strokes, false, ui, canvas);
1388
1400
  break;
1389
1401
  case 'inside':
1390
1402
  canvas.save();
1391
1403
  canvas.setStroke(undefined, strokeWidth * 2, options);
1392
1404
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
1393
- drawStrokesStyle(ui, strokes, canvas);
1405
+ drawStrokesStyle(strokes, false, ui, canvas);
1394
1406
  canvas.restore();
1395
1407
  break;
1396
1408
  case 'outside':
@@ -1398,10 +1410,15 @@ function strokes(ui, canvas, strokes) {
1398
1410
  const out = canvas.getSameCanvas(true);
1399
1411
  ui.__drawRenderPath(out);
1400
1412
  out.setStroke(undefined, strokeWidth * 2, ui.__);
1401
- drawStrokesStyle(ui, strokes, out);
1413
+ drawStrokesStyle(strokes, false, ui, out);
1402
1414
  options.windingRule ? out.clip(options.windingRule) : out.clip();
1403
1415
  out.clearWorld(renderBounds);
1404
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
1416
+ if (ui.__hasMirror || renderOptions.matrix) {
1417
+ canvas.copyWorldByReset(out);
1418
+ }
1419
+ else {
1420
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
1421
+ }
1405
1422
  out.recycle();
1406
1423
  break;
1407
1424
  }
@@ -1533,21 +1550,34 @@ function conicGradient(paint, box) {
1533
1550
  }
1534
1551
 
1535
1552
  let recycleMap;
1536
- function compute(ui, attrName) {
1553
+ function compute(attrName, ui) {
1537
1554
  const value = [];
1555
+ const data = ui.__;
1538
1556
  let item;
1539
- let paints = ui.__.__input[attrName];
1557
+ let paints = data.__input[attrName];
1540
1558
  if (!(paints instanceof Array))
1541
1559
  paints = [paints];
1542
- recycleMap = recycleImage(ui.__, attrName);
1560
+ recycleMap = recycleImage(attrName, data);
1543
1561
  for (let i = 0, len = paints.length; i < len; i++) {
1544
- item = getLeafPaint(ui, paints[i], attrName);
1562
+ item = getLeafPaint(attrName, paints[i], ui);
1545
1563
  if (item)
1546
1564
  value.push(item);
1547
1565
  }
1548
- ui.__['_' + attrName] = value.length ? value : undefined;
1566
+ data['_' + attrName] = value.length ? value : undefined;
1567
+ let isPixel;
1568
+ if (paints.length === 1) {
1569
+ const paint = paints[0];
1570
+ if (paint.type === 'image')
1571
+ isPixel = ImageManager$1.isPixel(paint);
1572
+ }
1573
+ if (attrName === 'fill') {
1574
+ data.__pixelFill = isPixel;
1575
+ }
1576
+ else {
1577
+ data.__pixelStroke = isPixel;
1578
+ }
1549
1579
  }
1550
- function getLeafPaint(ui, paint, attrName) {
1580
+ function getLeafPaint(attrName, paint, ui) {
1551
1581
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
1552
1582
  return undefined;
1553
1583
  const { boxBounds } = ui.__layout;
@@ -1585,7 +1615,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
1585
1615
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
1586
1616
  const tempBounds = {};
1587
1617
  const offsetOutBounds$1 = {};
1588
- function shadow(ui, current, shape, _options) {
1618
+ function shadow(ui, current, shape, renderOptions) {
1589
1619
  let copyBounds, spreadScale;
1590
1620
  const { __world, __layout } = ui;
1591
1621
  const { shadow } = ui.__;
@@ -1607,7 +1637,7 @@ function shadow(ui, current, shape, _options) {
1607
1637
  }
1608
1638
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1609
1639
  }
1610
- if (ui.__hasMirror) {
1640
+ if (ui.__hasMirror || renderOptions.matrix) {
1611
1641
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1612
1642
  }
1613
1643
  else {
@@ -1647,7 +1677,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1647
1677
 
1648
1678
  const { toOffsetOutBounds } = BoundsHelper;
1649
1679
  const offsetOutBounds = {};
1650
- function innerShadow(ui, current, shape, _options) {
1680
+ function innerShadow(ui, current, shape, renderOptions) {
1651
1681
  let copyBounds, spreadScale;
1652
1682
  const { __world, __layout: __layout } = ui;
1653
1683
  const { innerShadow } = ui.__;
@@ -1671,7 +1701,7 @@ function innerShadow(ui, current, shape, _options) {
1671
1701
  copyBounds = bounds;
1672
1702
  }
1673
1703
  other.fillWorld(copyBounds, item.color, 'source-in');
1674
- if (ui.__hasMirror) {
1704
+ if (ui.__hasMirror || renderOptions.matrix) {
1675
1705
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
1676
1706
  }
1677
1707
  else {
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as s,ChildEvent as i,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as w,ResizeEvent as y,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as L,ImageEvent as E,PointHelper as k,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,Paint as C,Effect as M,TextConvert as T,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class W{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(s,i){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=s,i&&(this.config=e.default(i,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(s.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===i.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([i.ADD,i.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:D,updateAllWorldOpacity:P}=a,{pushAllChildBranch:F,pushAllParent:N}=o;const{worldBounds:Y}=h,{setByListWithHandle:U}=l;class H{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){U(this.beforeBounds,this.updatedList.list,Y)}setAfter(){U(this.afterBounds,this.updatedList.list,Y),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:V,updateAllChange:G}=a,{pushAllBranchStack:j,updateWorldBoundsByBranchStack:q}=o,X=c.get("Layouter");class z{constructor(t,s){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,s&&(this.config=e.default(s,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(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){X.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?X.warn("layouting"):this.times>3?X.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=_.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(i);o.forEach((t=>{t.setBefore()})),s.emitEvent(new f(n,o,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(D(t),e.push(t),t.isBranch&&F(t,e),N(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),N(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&P(t),t.__updateChange()}))}(i),o.forEach((t=>t.setAfter())),s.emitEvent(new f(r,o,this.times)),s.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:s}=this,{BEFORE:i,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(s));s.emitEvent(new f(i,a,this.times)),z.fullLayout(s),a.forEach((t=>{t.setAfter()})),s.emitEvent(new f(n,a,this.times)),s.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(V(t),t.isBranch){const e=[t];j(t,e),q(e)}else t.__updateWorldBounds();G(t)}createBlock(t){return new H(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_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Q=c.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,s,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=s,i&&(this.config=e.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(s.START),this.renderOnce(t),this.emitRender(s.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(s.BEFORE),t()):(this.requestLayout(),this.emitRender(s.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(s.RENDER,this.renderBounds,this.renderOptions),this.emitRender(s.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new d).copy(i);s.save(),n&&!c.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),_.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),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 d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new d(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Q.warn(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 s(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(s.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(s.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:K}=l;class ${constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),i?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const s=new t;for(;e;)s.push(e),e=e.parent;return s.push(this.target),s}getHitablePath(e){const s=this.getPath(e);let i,n=new t;for(let t=s.list.length-1;t>-1&&(i=s.list[t],i.__.hittable)&&(n.unshift(i),i.__.hitChildren);t--);return n}getThroughPath(e){const s=new t,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=i.length;t<e;t++){n=i[t],r=i[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)s.push(a)}return s}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],!s.__.visible||e&&!s.__.isMask||(i=!!s.__.hitRadius||K(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}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()}}class J{constructor(t,s){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,s&&(this.config=e.default(s,this.config)),this.findPath=new $(t,this),this.__listenEvents()}getByPoint(t,e,s){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(i.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new W(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,s)=>new Z(t,e,s),selector:(t,e)=>new J(t,e)}),p.layout=z.fullLayout;class tt extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=t*s,this.view.height=e*s,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:et}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,s)=>new Promise(((i,n)=>{t.convertToBlob({type:et(e),quality:s}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,s)=>t.convertToBlob({type:et(e),quality:s}),canvasSaveAs:(t,e,s)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,s)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then((t=>{e(t)})).catch((t=>{s(t)}))},i.onerror=t=>s(t),i.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new tt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new tt(t,e),interaction:(t,e,s,i)=>new B(t,e,s,i)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:it}=navigator;it.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):it.indexOf("Safari")>-1&&-1===it.indexOf("Chrome")&&(p.fullImageShadow=!0),it.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):it.indexOf("Mac")>-1?p.os="Mac":it.indexOf("Linux")>-1&&(p.os="Linux");const{get:nt,rotateOfOuter:rt,translate:at,scaleOfOuter:ot,scale:dt,rotate:ht}=L;const{get:lt,translate:ct}=L;function ut(t,e,s,i){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=s,u=i.width===n&&i.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=i.width,r=i.height),(i.x||i.y)&&(f.transform=lt(),ct(f.transform,i.x,i.y));break;case"clip":(d||h||l)&&function(t,e,s,i,n){const r=nt();at(r,e.x,e.y),s&&at(r,s.x,s.y),i&&("number"==typeof i?dt(r,i):dt(r,i.x,i.y),t.scaleX=r.a,t.scaleY=r.d),n&&ht(r,n),t.transform=r}(f,i,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,s,i,n,r){const a=nt();if(r)switch(ht(a,r),r){case 90:at(a,i,0);break;case 180:at(a,s,i);break;case 270:at(a,0,s)}at(a,e.x,e.y),n&&(ot(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,i,n,r,h,l);break;default:u&&!l||function(t,e,s,i,n,r){const a=nt(),o=r&&180!==r,d=s.width/(o?n:i),h=s.height/(o?i:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=s.x+(s.width-i*l)/2,u=s.y+(s.height-n*l)/2;at(a,c,u),dt(a,l),r&&rt(a,{x:s.x+s.width/2,y:s.y+s.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,i,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function ft(t,e,s){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function _t(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function gt(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:pt,scale:wt,copy:yt}=L;function mt(t,e,s){let{scaleX:i,scaleY:n}=t.__world;const r=i+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,i=Math.abs(i),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:w,mode:y}=a;f&&(l=pt(),yt(l,w),wt(l,1/f,1/_),i*=f,n*=_),i*=s,n*=s,c*=i,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(i/=h,n/=h,c/=h,u/=h),f&&(i/=f,n/=_),(w||1!==i||1!==n)&&(l||(l=pt(),w&&yt(l,w)),wt(l,1/i,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===y?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function vt(t,e,s,i){const{scaleX:n,scaleY:r}=t.__world;if(s.data&&s.patternId!==n+"-"+r){if(i)if(s.image.isSVG&&"repeat"!==s.data.mode){let{width:t,height:a}=s.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,i=t>4096||a>4096}else i=!1;if(i){e.save(),e.clip();const{data:t}=s;return s.blendMode&&(e.blendMode=s.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(s.image.view,0,0,t.width,t.height),e.restore(),!0}return s.style?g.patternTasker.add((()=>gt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&mt(t,s,e.pixelRatio)&&t.forceUpdate("surface")}))),300):mt(t,s,e.pixelRatio),!1}return!1}function xt(t,e){const s="fill"===e?t._fill:t._stroke;if(s instanceof Array){let i,n,r,a;for(let o=0,d=s.length;o<d;o++)i=s[o].image,a=i&&i.url,a&&(n||(n={}),n[a]=!0,g.recycle(i),i.loading&&(r||(r=t.__input&&t.__input[e]||[],r instanceof Array||(r=[r])),i.unload(s[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function bt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function Bt(t,e,s){const{strokeAlign:i}=t.__,n="string"!=typeof s;switch(i){case"center":e.setStroke(n?void 0:s,t.__.strokeWidth,t.__),n?Et(t,s,e,!0):Lt(t,e);break;case"inside":Rt(t,e,s,"inside",n);break;case"outside":Rt(t,e,s,"outside",n)}}function Rt(t,e,s,i,n){const{strokeWidth:r,__font:a}=t.__,o=e.getSameCanvas(!0);o.setStroke(n?void 0:s,2*r,t.__),o.font=a,n?Et(t,s,o,!0):Lt(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",bt(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Lt(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)s=i[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function Et(t,e,s,i){let n;for(let r=0,a=e.length;r<a;r++)n=e[r],n.image&&vt(t,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),i?Lt(t,s):s.stroke(),s.restoreBlendMode()):i?Lt(t,s):s.stroke())}const{getSpread:kt,getOuterOf:St,getByMove:At,getIntersectData:Ot}=l;const Ct={x:.5,y:0},Mt={x:.5,y:1};function Tt(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,O.string(i.color,s))}const{set:It,getAngle:Wt,getDistance:Dt}=k,{get:Pt,rotateOfOuter:Ft,scaleOfOuter:Nt}=L,Yt={x:.5,y:.5},Ut={x:.5,y:1},Ht={},Vt={};const{set:Gt,getAngle:jt,getDistance:qt}=k,{get:Xt,rotateOfOuter:zt,scaleOfOuter:Qt}=L,Zt={x:.5,y:.5},Kt={x:.5,y:1},$t={},Jt={};let te;function ee(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:O.string(a,o)};case"image":return function(t,e,s,i,n){const r={type:s.type},a=r.image=g.get(s),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:s};return a.ready?(ft(t,e,a)&&ut(r,a,s,i),n&&(_t(E.LOAD,o),_t(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,_t(E.ERROR,o)):(n&&_t(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(ft(t,e,a)&&(ut(r,a,s,i),t.forceUpdate("surface")),_t(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,_t(E.ERROR,o)}))),r}(t,s,e,i,!te||!te[e.url]);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:a}=t;s||(s=Ct),i||(i=Mt);const o=p.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);Tt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Yt),i||(i=Ut);const{x:d,y:h,width:l,height:c}=e;let u;It(Ht,d+s.x*l,h+s.y*c),It(Vt,d+i.x*l,h+i.y*c),(l!==c||o)&&(u=Pt(),Nt(u,Ht,l/c*(o||1),1),Ft(u,Ht,Wt(Ht,Vt)+90));const f=p.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Dt(Ht,Vt));Tt(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:a,stretch:o}=t;s||(s=Zt),i||(i=Kt);const{x:d,y:h,width:l,height:c}=e;Gt($t,d+s.x*l,h+s.y*c),Gt(Jt,d+i.x*l,h+i.y*c);const u=Xt(),f=jt($t,Jt);p.conicGradientRotate90?(Qt(u,$t,l/c*(o||1),1),zt(u,$t,f+90)):(Qt(u,$t,1,l/c*(o||1)),zt(u,$t,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,$t.x,$t.y):p.canvas.createRadialGradient($t.x,$t.y,0,$t.x,$t.y,qt($t,Jt));Tt(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,i);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const s=[];let i,n=t.__.__input[e];n instanceof Array||(n=[n]),te=xt(t.__,e);for(let r=0,a=n.length;r<a;r++)i=ee(t,n[r],e),i&&s.push(i);t.__["_"+e]=s.length?s:void 0},drawTextStroke:Lt,fill:function(t,e,s){e.fillStyle=s,t.__.__font?bt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:bt,fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let a=0,o=s.length;a<o;a++)i=s[a],i.image&&vt(t,e,i,!r)||i.style&&(e.fillStyle=i.style,i.transform?(e.save(),e.transform(i.transform),i.blendMode&&(e.blendMode=i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restore()):i.blendMode?(e.saveBlendMode(i.blendMode),r?bt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):r?bt(t,e):n?e.fill(n):e.fill())},recycleImage:xt,shape:function(t,e,s){const i=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,s.matrix))s.matrix?(h*=s.matrix.a,l*=s.matrix.d,n=a=St(d,s.matrix)):n=a=d,o=i;else{const{renderShapeSpread:i}=t.__layout,c=Ot(i?kt(e.bounds,i*h,i*l):e.bounds,d,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,s),h*=r.a,l*=r.d),a=St(d,r),n=At(a,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:Bt,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:a}=i;if(n)if(a)Bt(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),Et(t,s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),i.windingRule?e.clip(i.windingRule):e.clip(),Et(t,s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,a=e.getSameCanvas(!0);t.__drawRenderPath(a),a.setStroke(void 0,2*n,t.__),Et(t,s,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(r),e.copyWorldToInner(a,t.__world,r),a.recycle()}}});const{copy:ie,toOffsetOutBounds:ne}=l,re={},ae={};function oe(t,e,s,i){const{bounds:n,shapeBounds:r}=i;if(p.fullImageShadow){if(ie(re,t.bounds),re.x+=e.x-r.x,re.y+=e.y-r.y,s){const{matrix:t}=i;re.x-=(n.x+(t?t.e:0)+n.width/2)*(s-1),re.y-=(n.y+(t?t.f:0)+n.height/2)*(s-1),re.width*=s,re.height*=s}t.copyWorld(i.canvas,t.bounds,re)}else s&&(ie(re,e),re.x-=e.width/2*(s-1),re.y-=e.height/2*(s-1),re.width*=s,re.height*=s),t.copyWorld(i.canvas,r,s?re:e)}const{toOffsetOutBounds:de}=l,he={};var le=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;de(l,he),d.forEach(((i,d)=>{_.save(),_.setWorldShadow(he.offsetX+i.x*u,he.offsetY+i.y*f,i.blur*u),r=i.spread?1-2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,he,r,s),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(s.canvas,c,l,"source-out"),n=l),_.fillWorld(n,i.color,"source-in"),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()},shadow:function(t,e,s,i){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=s,_=e.getSameCanvas(),g=d.length-1;ne(l,ae),d.forEach(((i,d)=>{_.setWorldShadow(ae.offsetX+i.x*u,ae.offsetY+i.y*f,i.blur*u,i.color),r=i.spread?1+2*i.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,oe(_,ae,r,s),n=l,i.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(s.canvas,c,l,"destination-out")),t.__hasMirror?e.copyWorldByReset(_,n,a,i.blendMode):e.copyWorldToInner(_,n,o.renderBounds,i.blendMode),g&&d<g&&_.clear()})),_.recycle()}});const ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ue=ce+"_#~&*+\\=|≮≯≈≠=…",fe=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 _e(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ge=_e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pe=_e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=_e(ce),ye=_e(ue),me=_e("- —/~|┆·");var ve;!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"}(ve||(ve={}));const{Letter:xe,Single:be,Before:Be,After:Re,Symbol:Le,Break:Ee}=ve;function ke(t){return ge[t]?xe:me[t]?Ee:pe[t]?Be:we[t]?Re:ye[t]?Le:fe.test(t)?be:xe}const Se={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ae(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Oe}=Se,{Letter:Ce,Single:Me,Before:Te,After:Ie,Symbol:We,Break:De}=ve;let Pe,Fe,Ne,Ye,Ue,He,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke,$e,Je=[];function ts(t,e){je&&!Ge&&(Ge=je),Pe.data.push({char:t,width:e}),Ne+=e}function es(){Ye+=Ne,Pe.width=Ne,Fe.words.push(Pe),Pe={data:[]},Ne=0}function ss(){Ze&&(Ke.paraNumber++,Fe.paraStart=!0,Ze=!1),je&&(Fe.startCharSize=Ge,Fe.endCharSize=je,Ge=0),Fe.width=Ye,$e.width&&Oe(Fe),Je.push(Fe),Fe={words:[]},Ye=0}const is={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=S.fourNumber(h);n&&(s=o,n-=e+o),r&&(i=t,r-=t+a)}const l={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,s){Ke=t,Je=t.rows,$e=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:a}=p,{width:o,height:d}=$e;if(o||d||i||"none"!==r){Ze=!0,Xe=null,Ge=Ve=je=Ne=Ye=0,Pe={data:[]},Fe={words:[]};for(let t=0,s=e.length;t<s;t++)He=e[t],"\n"===He?(Ne&&es(),Fe.paraEnd=!0,ss(),Ze=!0):(qe=ke(He),qe===Ce&&"none"!==r&&(He=Ae(He,r,!Ne)),Ve=a.measureText(He).width,i&&(i<0&&(je=Ve),Ve+=i),ze=qe===Me&&(Xe===Me||Xe===Ce)||Xe===Me&&qe!==Ie,Qe=!(qe!==Te&&qe!==Me||Xe!==We&&Xe!==Ie),Ue=Ze&&n?o-n:o,o&&Ye+Ne+Ve>Ue&&(Qe||(Qe=qe===Ce&&Xe==Ie),ze||Qe||qe===De||qe===Te||qe===Me||Ne+Ve>Ue?(Ne&&es(),ss()):ss())," "===He&&!0!==Ze&&Ye+Ne===0||(qe===De?(" "===He&&Ne&&es(),ts(He,Ve),es()):ze||Qe?(Ne&&es(),ts(He,Ve)):ts(He,Ve)),Xe=qe);Ne&&es(),Ye&&ss(),Je.length>0&&(Je[Je.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Ke.paraNumber++,Je.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=i,y=n*s.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&y>w)y=Math.max(w,n),t.overflow=s.length;else switch(d){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let r=0,d=s.length;r<d;r++){switch(c=s[r],c.x=_,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>y&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f)}i.y=g,i.height=y}(l,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=s[i-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"under":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(l,e),l}},ns={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},rs={export(t,e,s){return function(t){as||(as=new A);return new Promise((e=>{as.add((()=>gt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((i=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>gt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof s){case"object":s.quality&&(t=s.quality),s.blob&&(a=!0);break;case"number":t=s;break;case"boolean":a=s}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),i({data:o}),n(),h&&d.recycle()})))):(i({data:!1}),n())}))))}};let as;Object.assign(C,se),Object.assign(M,le),Object.assign(T,is),Object.assign(O,ns),Object.assign(I,rs),st();export{z as Layouter,tt as LeaferCanvas,Z as Renderer,J as Selector,W as Watcher,st as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as L,ImageEvent as E,PointHelper as k,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,ImageManager as C,Paint as M,Effect as T,TextConvert as W,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:P,updateAllWorldOpacity:F}=a,{pushAllChildBranch:N,pushAllParent:Y}=o;const{worldBounds:U}=h,{setByListWithHandle:H}=l;class V{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){H(this.beforeBounds,this.updatedList.list,U)}setAfter(){H(this.afterBounds,this.updatedList.list,U),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:G,updateAllChange:j}=a,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:X}=o,z=c.get("Layouter");class Q{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.default(i,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(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?z.warn("layouting"):this.times>3?z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=_.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(s);o.forEach((t=>{t.setBefore()})),i.emitEvent(new f(n,o,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(P(t),e.push(t),t.isBranch&&N(t,e),Y(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Y(t,e)))}))}(s,this.__levelList),function(t){let e,i;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)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&F(t),t.__updateChange()}))}(s),o.forEach((t=>t.setAfter())),i.emitEvent(new f(r,o,this.times)),i.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(i));i.emitEvent(new f(s,a,this.times)),Q.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new f(n,a,this.times)),i.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(G(t),t.isBranch){const e=[t];q(t,e),X(e)}else t.__updateWorldBounds();j(t)}createBlock(t){return new V(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_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Z=c.get("Renderer");class K{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Z.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Z.error(t)}Z.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Z.warn("rendering"):this.times>3?Z.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Z.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),r=(new d).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,r),i.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),_.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),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 d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Z.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:$}=l;class J{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;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=s.length;t<e;t++){n=s[t],r=s[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)i.push(a)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let r=t.length-1;r>-1;r--)i=t[r],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(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){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()}}class tt{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new J(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new Q(t,e),renderer:(t,e,i)=>new K(t,e,i),selector:(t,e)=>new tt(t,e)}),p.layout=Q.fullLayout;class et extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:it}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:it(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:it(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new et(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new et(t,e),interaction:(t,e,i,s)=>new B(t,e,i,s)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):nt.indexOf("Safari")>-1&&-1===nt.indexOf("Chrome")&&(p.fullImageShadow=!0),nt.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?p.os="Mac":nt.indexOf("Linux")>-1&&(p.os="Linux");const{get:rt,rotateOfOuter:at,translate:ot,scaleOfOuter:dt,scale:ht,rotate:lt}=L;const{get:ct,translate:ut}=L;function ft(t,e,i,s){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=s.width,r=s.height),(s.x||s.y)&&(f.transform=ct(),ut(f.transform,s.x,s.y));break;case"clip":(d||h||l)&&function(t,e,i,s,n){const r=rt();ot(r,e.x,e.y),i&&ot(r,i.x,i.y),s&&("number"==typeof s?ht(r,s):ht(r,s.x,s.y),t.scaleX=r.a,t.scaleY=r.d),n&&lt(r,n),t.transform=r}(f,s,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,i,s,n,r){const a=rt();if(r)switch(lt(a,r),r){case 90:ot(a,s,0);break;case 180:ot(a,i,s);break;case 270:ot(a,0,i)}ot(a,e.x,e.y),n&&(dt(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,s,n,r,h,l);break;default:u&&!l||function(t,e,i,s,n,r){const a=rt(),o=r&&180!==r,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ot(a,c,u),ht(a,l),r&&at(a,{x:i.x+i.width/2,y:i.y+i.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,s,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function _t(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function gt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function pt(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{d(s.next(t))}catch(t){r(t)}}function o(t){try{d(s.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:yt,scale:wt,copy:mt}=L;function vt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const r=s+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,s=Math.abs(s),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:y,mode:w}=a;f&&(l=yt(),mt(l,y),wt(l,1/f,1/_),s*=f,n*=_),s*=i,n*=i,c*=s,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(s/=h,n/=h,c/=h,u/=h),f&&(s/=f,n/=_),(y||1!==s||1!==n)&&(l||(l=yt(),y&&mt(l,y)),wt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function xt(t,e,i,s){const{scaleX:n,scaleY:r}=t.__world;if(i.data&&i.patternId!==n+"-"+r){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:a}=i.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,s=t>4096||a>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?i.patternTask||(i.patternTask=g.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&vt(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300)):vt(t,i,e.pixelRatio),!1}return!1}function bt(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,r,a;for(let o=0,d=i.length;o<d;o++)s=i[o].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,g.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function Bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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,r)}function Rt(t,e,i,s){const{strokeAlign:n}=e.__,r="string"!=typeof t;switch(n){case"center":i.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?kt(t,!0,e,i):Et(e,i);break;case"inside":Lt("inside",t,r,e,i,s);break;case"outside":Lt("outside",t,r,e,i,s)}}function Lt(t,e,i,s,n,r){const{strokeWidth:a,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*a,s.__),d.font=o,i?kt(e,!0,s,d):Et(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",Bt(s,d),d.blendMode="normal",s.__hasMirror||r.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Et(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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,r)}function kt(t,e,i,s){let n;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&xt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Et(i,s):s.stroke(),s.restoreBlendMode()):e?Et(i,s):s.stroke())}const{getSpread:St,getOuterOf:At,getByMove:Ot,getIntersectData:Ct}=l;const Mt={x:.5,y:0},Tt={x:.5,y:1};function Wt(t,e,i){let s;for(let n=0,r=e.length;n<r;n++)s=e[n],t.addColorStop(s.offset,O.string(s.color,i))}const{set:It,getAngle:Dt,getDistance:Pt}=k,{get:Ft,rotateOfOuter:Nt,scaleOfOuter:Yt}=L,Ut={x:.5,y:.5},Ht={x:.5,y:1},Vt={},Gt={};const{set:jt,getAngle:qt,getDistance:Xt}=k,{get:zt,rotateOfOuter:Qt,scaleOfOuter:Zt}=L,Kt={x:.5,y:.5},$t={x:.5,y:1},Jt={},te={};let ee;function ie(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:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:O.string(a,o)};case"image":return function(t,e,i,s,n){const r={type:i.type},a=r.image=g.get(i),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:i};return a.ready?(_t(t,e,a)&&ft(r,a,i,s),n&&(gt(E.LOAD,o),gt(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,gt(E.ERROR,o)):(n&&gt(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(_t(t,e,a)&&(ft(r,a,i,s),t.forceUpdate("surface")),gt(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,gt(E.ERROR,o)}))),r}(i,t,e,s,!ee||!ee[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:r,opacity:a}=t;i||(i=Mt),s||(s=Tt);const o=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Wt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Ut),s||(s=Ht);const{x:d,y:h,width:l,height:c}=e;let u;It(Vt,d+i.x*l,h+i.y*c),It(Gt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Ft(),Yt(u,Vt,l/c*(o||1),1),Nt(u,Vt,Dt(Vt,Gt)+90));const f=p.canvas.createRadialGradient(Vt.x,Vt.y,0,Vt.x,Vt.y,Pt(Vt,Gt));Wt(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Kt),s||(s=$t);const{x:d,y:h,width:l,height:c}=e;jt(Jt,d+i.x*l,h+i.y*c),jt(te,d+s.x*l,h+s.y*c);const u=zt(),f=qt(Jt,te);p.conicGradientRotate90?(Zt(u,Jt,l/c*(o||1),1),Qt(u,Jt,f+90)):(Zt(u,Jt,1,l/c*(o||1)),Qt(u,Jt,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,Jt.x,Jt.y):p.canvas.createRadialGradient(Jt.x,Jt.y,0,Jt.x,Jt.y,Xt(Jt,te));Wt(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,s);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,r,a=s.__input[t];a instanceof Array||(a=[a]),ee=bt(t,s);for(let s=0,r=a.length;s<r;s++)n=ie(t,a[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===a.length){const t=a[0];"image"===t.type&&(r=C.isPixel(t))}"fill"===t?s.__pixelFill=r:s.__pixelStroke=r},drawTextStroke:Et,fill:function(t,e,i){i.fillStyle=t,e.__.__font?Bt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:Bt,fills:function(t,e,i){let s;const{windingRule:n,__font:r}=e.__;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&xt(e,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?Bt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?Bt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):r?Bt(e,i):n?i.fill(n):i.fill())},recycleImage:bt,shape:function(t,e,i){const s=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=a=At(d,i.matrix)):n=a=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Ct(s?St(e.bounds,s*h,s*l):e.bounds,d,i.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=r.a,l*=r.d),a=At(d,r),n=Ot(a,-r.e,-r.f),i.matrix&&r.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:r})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(t,r,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0);a.setStroke(t,2*r,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:Rt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(void 0,r,n),kt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),kt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*r,e.__),kt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__hasMirror||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,a),o.recycle()}}});const{copy:ne,toOffsetOutBounds:re}=l,ae={},oe={};function de(t,e,i,s){const{bounds:n,shapeBounds:r}=s;if(p.fullImageShadow){if(ne(ae,t.bounds),ae.x+=e.x-r.x,ae.y+=e.y-r.y,i){const{matrix:t}=s;ae.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ae.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ae.width*=i,ae.height*=i}t.copyWorld(s.canvas,t.bounds,ae)}else i&&(ne(ae,e),ae.x-=e.width/2*(i-1),ae.y-=e.height/2*(i-1),ae.width*=i,ae.height*=i),t.copyWorld(s.canvas,r,i?ae:e)}const{toOffsetOutBounds:he}=l,le={};var ce=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;he(l,le),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(le.offsetX+d.x*u,le.offsetY+d.y*f,d.blur*u),r=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,le,r,i),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;re(l,oe),d.forEach(((d,p)=>{_.setWorldShadow(oe.offsetX+d.x*u,oe.offsetY+d.y*f,d.blur*u,d.color),r=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,oe,r,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",fe=ue+"_#~&*+\\=|≮≯≈≠=…",_e=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 pe=ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ye=ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=ge(ue),me=ge(fe),ve=ge("- —/~|┆·");var xe;!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"}(xe||(xe={}));const{Letter:be,Single:Be,Before:Re,After:Le,Symbol:Ee,Break:ke}=xe;function Se(t){return pe[t]?be:ve[t]?ke:ye[t]?Re:we[t]?Le:me[t]?Ee:_e.test(t)?Be:be}const Ae={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Oe(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:Ce}=Ae,{Letter:Me,Single:Te,Before:We,After:Ie,Symbol:De,Break:Pe}=xe;let Fe,Ne,Ye,Ue,He,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke,$e,Je,ti=[];function ei(t,e){qe&&!je&&(je=qe),Fe.data.push({char:t,width:e}),Ye+=e}function ii(){Ue+=Ye,Fe.width=Ye,Ne.words.push(Fe),Fe={data:[]},Ye=0}function si(){Ke&&($e.paraNumber++,Ne.paraStart=!0,Ke=!1),qe&&(Ne.startCharSize=je,Ne.endCharSize=qe,je=0),Ne.width=Ue,Je.width&&Ce(Ne),ti.push(Ne),Ne={words:[]},Ue=0}const ni={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=S.fourNumber(h);n&&(i=o,n-=e+o),r&&(s=t,r-=t+a)}const l={bounds:{x:i,y:s,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,i){$e=t,ti=t.rows,Je=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:a}=p,{width:o,height:d}=Je;if(o||d||s||"none"!==r){Ke=!0,ze=null,je=Ge=qe=Ye=Ue=0,Fe={data:[]},Ne={words:[]};for(let t=0,i=e.length;t<i;t++)Ve=e[t],"\n"===Ve?(Ye&&ii(),Ne.paraEnd=!0,si(),Ke=!0):(Xe=Se(Ve),Xe===Me&&"none"!==r&&(Ve=Oe(Ve,r,!Ye)),Ge=a.measureText(Ve).width,s&&(s<0&&(qe=Ge),Ge+=s),Qe=Xe===Te&&(ze===Te||ze===Me)||ze===Te&&Xe!==Ie,Ze=!(Xe!==We&&Xe!==Te||ze!==De&&ze!==Ie),He=Ke&&n?o-n:o,o&&Ue+Ye+Ge>He&&(Ze||(Ze=Xe===Me&&ze==Ie),Qe||Ze||Xe===Pe||Xe===We||Xe===Te||Ye+Ge>He?(Ye&&ii(),si()):si())," "===Ve&&!0!==Ke&&Ue+Ye===0||(Xe===Pe?(" "===Ve&&Ye&&ii(),ei(Ve,Ge),ii()):Qe||Ze?(Ye&&ii(),ei(Ve,Ge)):ei(Ve,Ge)),ze=Xe);Ye&&ii(),Ue&&si(),ti.length>0&&(ti[ti.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{$e.paraNumber++,ti.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,f,{x:_,y:g,width:p,height:y}=s,w=n*i.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&w>y)w=Math.max(y,n),t.overflow=i.length;else switch(d){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,d=i.length;r<d;r++){switch(c=i[r],c.x=_,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f)}s.y=g,s.height=w}(l,e),function(t,e,i,s){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=i&&"justify"===r&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(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,e,n),l.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=i[s-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,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}}(l,e),l}},ri={string(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+")"}},ai={export(t,e,i){return function(t){oi||(oi=new A);return new Promise((e=>{oi.add((()=>pt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(a=!0);break;case"number":t=i;break;case"boolean":a=i}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),h&&d.recycle()})))):(s({data:!1}),n())}))))}};let oi;Object.assign(M,se),Object.assign(T,ce),Object.assign(W,ni),Object.assign(O,ri),Object.assign(I,ai),st();export{Q as Layouter,et as LeaferCanvas,K as Renderer,tt as Selector,D as Watcher,st as useCanvas};