@leafer-ui/node 1.9.4 → 1.9.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.
package/dist/node.cjs CHANGED
@@ -452,7 +452,7 @@ class Renderer {
452
452
  this.times = 0;
453
453
  this.config = {
454
454
  usePartRender: true,
455
- maxFPS: 60
455
+ maxFPS: 120
456
456
  };
457
457
  this.target = target;
458
458
  this.canvas = canvas;
@@ -607,11 +607,15 @@ class Renderer {
607
607
  if (this.requestTime || !target) return;
608
608
  if (target.parentApp) return target.parentApp.requestRender(false);
609
609
  const requestTime = this.requestTime = Date.now();
610
- core.Platform.requestRender(() => {
611
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
610
+ const render = () => {
611
+ const nowFPS = 1e3 / (Date.now() - requestTime);
612
+ const {maxFPS: maxFPS} = this.config;
613
+ if (maxFPS && nowFPS > maxFPS - .5) return core.Platform.requestRender(render);
614
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
612
615
  this.requestTime = 0;
613
616
  this.checkRender();
614
- });
617
+ };
618
+ core.Platform.requestRender(render);
615
619
  }
616
620
  __onResize(e) {
617
621
  if (this.canvas.unreal) return;
@@ -654,7 +658,8 @@ class Renderer {
654
658
  if (this.target) {
655
659
  this.stop();
656
660
  this.__removeListenEvents();
657
- this.target = this.canvas = this.config = null;
661
+ this.config = {};
662
+ this.target = this.canvas = null;
658
663
  }
659
664
  }
660
665
  }
@@ -1476,7 +1481,7 @@ function ignoreRender(ui, value) {
1476
1481
 
1477
1482
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1478
1483
 
1479
- const {floor: floor, max: max, abs: abs} = Math;
1484
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1480
1485
 
1481
1486
  function createPattern(ui, paint, pixelRatio) {
1482
1487
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1486,8 +1491,6 @@ function createPattern(ui, paint, pixelRatio) {
1486
1491
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1487
1492
  scaleX *= pixelRatio;
1488
1493
  scaleY *= pixelRatio;
1489
- const xGap = gap && gap.x * scaleX;
1490
- const yGap = gap && gap.y * scaleY;
1491
1494
  if (sx) {
1492
1495
  sx = abs(sx);
1493
1496
  sy = abs(sy);
@@ -1504,7 +1507,10 @@ function createPattern(ui, paint, pixelRatio) {
1504
1507
  if (size > core.Platform.image.maxCacheSize) return false;
1505
1508
  }
1506
1509
  let maxSize = core.Platform.image.maxPatternSize;
1507
- if (!image.isSVG) {
1510
+ if (image.isSVG) {
1511
+ const ws = width / image.width;
1512
+ if (ws > 1) imageScale = ws / ceil(ws);
1513
+ } else {
1508
1514
  const imageSize = image.width * image.height;
1509
1515
  if (maxSize > imageSize) maxSize = imageSize;
1510
1516
  }
@@ -1519,18 +1525,20 @@ function createPattern(ui, paint, pixelRatio) {
1519
1525
  scaleX /= sx;
1520
1526
  scaleY /= sy;
1521
1527
  }
1528
+ const xGap = gap && gap.x * scaleX;
1529
+ const yGap = gap && gap.y * scaleY;
1522
1530
  if (transform || scaleX !== 1 || scaleY !== 1) {
1531
+ const canvasWidth = width + (xGap || 0);
1532
+ const canvasHeight = height + (yGap || 0);
1533
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1534
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1523
1535
  if (!imageMatrix) {
1524
1536
  imageMatrix = get$1();
1525
1537
  if (transform) copy$1(imageMatrix, transform);
1526
1538
  }
1527
1539
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1528
1540
  }
1529
- if (imageMatrix) {
1530
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1531
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1532
- }
1533
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1541
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1534
1542
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1535
1543
  paint.style = pattern;
1536
1544
  paint.patternId = id;
package/dist/node.esm.js CHANGED
@@ -456,7 +456,7 @@ class Renderer {
456
456
  this.times = 0;
457
457
  this.config = {
458
458
  usePartRender: true,
459
- maxFPS: 60
459
+ maxFPS: 120
460
460
  };
461
461
  this.target = target;
462
462
  this.canvas = canvas;
@@ -611,11 +611,15 @@ class Renderer {
611
611
  if (this.requestTime || !target) return;
612
612
  if (target.parentApp) return target.parentApp.requestRender(false);
613
613
  const requestTime = this.requestTime = Date.now();
614
- Platform.requestRender(() => {
615
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
614
+ const render = () => {
615
+ const nowFPS = 1e3 / (Date.now() - requestTime);
616
+ const {maxFPS: maxFPS} = this.config;
617
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
618
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
616
619
  this.requestTime = 0;
617
620
  this.checkRender();
618
- });
621
+ };
622
+ Platform.requestRender(render);
619
623
  }
620
624
  __onResize(e) {
621
625
  if (this.canvas.unreal) return;
@@ -658,7 +662,8 @@ class Renderer {
658
662
  if (this.target) {
659
663
  this.stop();
660
664
  this.__removeListenEvents();
661
- this.target = this.canvas = this.config = null;
665
+ this.config = {};
666
+ this.target = this.canvas = null;
662
667
  }
663
668
  }
664
669
  }
@@ -1480,7 +1485,7 @@ function ignoreRender(ui, value) {
1480
1485
 
1481
1486
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1482
1487
 
1483
- const {floor: floor, max: max, abs: abs} = Math;
1488
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1484
1489
 
1485
1490
  function createPattern(ui, paint, pixelRatio) {
1486
1491
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1490,8 +1495,6 @@ function createPattern(ui, paint, pixelRatio) {
1490
1495
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1491
1496
  scaleX *= pixelRatio;
1492
1497
  scaleY *= pixelRatio;
1493
- const xGap = gap && gap.x * scaleX;
1494
- const yGap = gap && gap.y * scaleY;
1495
1498
  if (sx) {
1496
1499
  sx = abs(sx);
1497
1500
  sy = abs(sy);
@@ -1508,7 +1511,10 @@ function createPattern(ui, paint, pixelRatio) {
1508
1511
  if (size > Platform.image.maxCacheSize) return false;
1509
1512
  }
1510
1513
  let maxSize = Platform.image.maxPatternSize;
1511
- if (!image.isSVG) {
1514
+ if (image.isSVG) {
1515
+ const ws = width / image.width;
1516
+ if (ws > 1) imageScale = ws / ceil(ws);
1517
+ } else {
1512
1518
  const imageSize = image.width * image.height;
1513
1519
  if (maxSize > imageSize) maxSize = imageSize;
1514
1520
  }
@@ -1523,18 +1529,20 @@ function createPattern(ui, paint, pixelRatio) {
1523
1529
  scaleX /= sx;
1524
1530
  scaleY /= sy;
1525
1531
  }
1532
+ const xGap = gap && gap.x * scaleX;
1533
+ const yGap = gap && gap.y * scaleY;
1526
1534
  if (transform || scaleX !== 1 || scaleY !== 1) {
1535
+ const canvasWidth = width + (xGap || 0);
1536
+ const canvasHeight = height + (yGap || 0);
1537
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1538
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1527
1539
  if (!imageMatrix) {
1528
1540
  imageMatrix = get$1();
1529
1541
  if (transform) copy$1(imageMatrix, transform);
1530
1542
  }
1531
1543
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1532
1544
  }
1533
- if (imageMatrix) {
1534
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1535
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1536
- }
1537
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1545
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
1538
1546
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1539
1547
  paint.style = pattern;
1540
1548
  paint.patternId = id;
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as B,BoundsHelper as k,Plugin as S,isObject as R,Matrix as E,isUndefined as L,isString as A,getMatrixData as T,MatrixHelper as C,MathHelper as P,AlignHelper as O,PointHelper as W,ImageEvent as M,AroundHelper as D,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as U}from"fs";import{HitCanvasManager as Y,InteractionBase as X}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,Paint as N,ColorConvert as G,PaintGradient as j,Export as q,Group as H,TextConvert as V,Effect as Q,TwoPointBoundsHelper as J,Bounds as Z,FileHelper as $,Platform as K,isUndefined as tt,Matrix as et,MathHelper as it,Creator as st,TaskProcessor as nt,Resource as at,LeaferCanvasBase as ot,Debug as rt,Plugin as lt,UI as dt}from"@leafer-ui/draw";function ht(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class ct extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__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}}const{mineType:ut,fileType:ft}=s;function gt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(ut(e),i),canvasToBolb:(t,e,i)=>ht(this,void 0,void 0,function*(){return t.toBuffer(ut(e),i)}),canvasSaveAs:(t,e,i)=>ht(this,void 0,void 0,function*(){return U(e,t.toBuffer(ut(ft(e)),i))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new ct(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class pt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:_t,updateBounds:yt,updateChange:wt}=f,{pushAllChildBranch:mt,pushAllParent:xt}=g;const{worldBounds:vt}=p;class bt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,y(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,vt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,vt),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:Bt,updateAllChange:kt}=f,St=w.get("Layouter");class Rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.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(c.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=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=x,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(_t(t,!0),e.add(t),t.isBranch&&mt(t,e),xt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),xt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||yt(s[t])}yt(i)}})}(this.__levelList),function(t){t.list.forEach(wt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new x(a,r,this.times)),i.emitEvent(new x(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new r(e));e.emitEvent(new x(i,a,this.times)),Rt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){Bt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),kt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new bt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new bt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Et=w.get("Renderer");class Lt{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=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Et.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Et.error(t)}Et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Et.warn("rendering");if(this.times>3)return Et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(Lt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Et.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(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[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)}}Lt.clipSpread=10;const{hitRadiusPoint:At}=k;class Tt{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,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 r(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new r;if(t.length){let e;const{x:n,y:a}=this.point,o={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||At(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,o=a.length;s<o;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Ct{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Tt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Pt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function Ot(t,e){t.__.__font?Pt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Wt(t,e,i){switch(e.__.strokeAlign){case"center":Mt(t,1,e,i);break;case"inside":Dt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Mt(t,2,e,i):Dt(t,"outside",e,i)}}function Mt(t,e,i,s){const n=i.__;R(t)?It(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ft(i,s))}function Dt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Mt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Pt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ft(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function It(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!z.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?Ft(s,n):n.stroke(),n.restoreBlendMode()):i?Ft(s,n):n.stroke()}}function Ut(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Wt(t,e,i);else switch(s.strokeAlign){case"center":Yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Yt(t,e,i,s){const n=i.__;R(t)?It(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&N.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new pt(t,e),layouter:(t,e)=>new Rt(t,e),renderer:(t,e,i)=>new Lt(t,e,i),selector:(t,e)=>new Ct(t,e)}),e.layout=Rt.fullLayout;const{getSpread:Xt,getOuterOf:zt,getByMove:Nt,getIntersectData:Gt}=k;let jt;const{stintSet:qt}=l,{hasTransparent:Ht}=G;function Vt(t,e,i){if(!R(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=z.image(i,t,e,n,!jt||!jt[e.url]);break;case"linear":s=j.linearGradient(e,n);break;case"radial":s=j.radialGradient(e,n);break;case"angular":s=j.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:G.string(o,r)};break;default:L(e.r)||(s={type:"solid",style:G.string(e)})}if(s){if(A(s.style)&&Ht(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Qt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];y(r)||(r=[r]),jt=z.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Vt(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(qt(i,"__isAlphaPixelFill",n),qt(i,"__isTransparentFill",a)):(qt(i,"__isAlphaPixelStroke",n),qt(i,"__isTransparentStroke",a),qt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Ot(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(z.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Ot(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Ot(e,i),i.restoreBlendMode()):Ot(e,i)}},fillPathOrText:Ot,fillText:Pt,stroke:Ut,strokes:function(t,e,i){Ut(t,e,i)},strokeText:Wt,drawTextStroke:Ft,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,o=i.bounds;let r,l,d,h,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))c=n,r=h=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(e.fullImageShadow)g=a;else{const t=n?Xt(o,u===f?n*u:[n*f,n*u]):o;g=Gt(t,a)}d=o.getFitMatrix(g);let{a:p,d:_}=d;d.a<1&&(c=i.getSameCanvas(),t.__renderShape(c,s),u*=p,f*=_),h=zt(a,d),r=Nt(h,-d.e,-d.f);const y=s.matrix;y?(l=new E(d),l.multiply(y),p*=y.scaleX,_*=y.scaleY):l=d,l.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:r,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let Jt={},Zt=T();const{get:$t,rotateOfOuter:Kt,translate:te,scaleOfOuter:ee,multiplyParent:ie,scale:se,rotate:ne,skew:ae}=C;function oe(t,e,i,s,n,a,o){const r=$t();te(r,e.x+i,e.y+s),se(r,n,a),o&&Kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function re(t,e,i,s,n,a,o,r,l){const d=$t();de(d,e,i,s,n,a,o,r),l&&(Zt.a=e.width/l.width,Zt.d=e.height/l.height,ie(d,Zt)),t.transform=d}function le(t,e,i,s,n,a,o,r,l,d,h,c){const u=$t();if(c)de(u,e,n,a,o,r,l,d);else{if(l)if("center"===h)Kt(u,{x:i/2,y:s/2},l);else switch(ne(u,l),l){case 90:te(u,s,0);break;case 180:te(u,i,s);break;case 270:te(u,0,i)}Jt.x=e.x+n,Jt.y=e.y+a,te(u,Jt.x,Jt.y),o&&ee(u,Jt,o,r)}t.transform=u}function de(t,e,i,s,n,a,o,r){o&&ne(t,o),r&&ae(t,r.x,r.y),n&&se(t,n,a),te(t,e.x+i,e.y+s)}const{get:he,translate:ce}=C,ue=new _,fe={},ge={};function pe(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=_e(i,s,e)}function _e(t,e,i){t.padding&&(e=ue.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,y=e.width===s&&e.height===n,w={mode:o},m="center"!==r&&(c||0)%180==90;let x,v;switch(k.set(ge,0,0,m?n:s,m?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(P.getScaleData(d,h,i,fe),x=fe.scaleX,v=fe.scaleY),(r||p||g)&&(x&&k.scale(ge,x,v,!0),r&&O.toPoint(r,ge,e,ge,!0,!0))):y&&!c||(x=v=k.getFitScale(e,ge,"fit"!==o),k.put(e,i,r,x,!1,ge),k.scale(ge,x,v,!0)),l&&W.move(ge,l),o){case"stretch":y||(s=e.width,n=e.height);break;case"normal":case"clip":(ge.x||ge.y||x||f||c||u)&&re(w,e,ge.x,ge.y,x,v,c,u,t.clipSize);break;case"repeat":(!y||x||c||u)&&le(w,e,s,n,ge.x,ge.y,x,v,c,u,r,t.freeTransform),g||(w.repeat="repeat");const i=R(g);(p||i)&&(w.gap=function(t,e,i,s,n){let a,o;R(t)?(a=t.x,o=t.y):a=o=t;return{x:ye(a,i,n.width,e&&e.x),y:ye(o,s,n.height,e&&e.y)}}(p,i&&g,ge.width,ge.height,e));break;default:x&&oe(w,e,ge.x,ge.y,x,v,c)}return w.transform||(e.x||e.y)&&(w.transform=he(),ce(w.transform,e.x,e.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=v),w.width=s,w.height=n,a&&(w.opacity=a),_&&(w.filters=_),g&&(w.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function ye(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let we,me=new _;const{isSame:xe}=k;function ve(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||pe(n,s,i,a),!0}function be(t,e){Se(t,M.LOAD,e)}function Be(t,e){Se(t,M.LOADED,e)}function ke(t,e,i){e.error=i,t.forceUpdate("surface"),Se(t,M.ERROR,e)}function Se(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function Re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ee,scale:Le,copy:Ae}=C,{floor:Te,max:Ce,abs:Pe}=Math;function Oe(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:t,data:r}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:g,repeat:p,gap:_}=r;n*=s,a*=s;const y=_&&_.x*n,w=_&&_.y*a;u&&(u=Pe(u),f=Pe(f),d=Ee(),Ae(d,g),Le(d,1/u,1/f),n*=u,a*=f),h*=n,c*=a;const m=h*c;if(!p&&m>e.image.maxCacheSize)return!1;let x=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;x>e&&(x=e)}if(m>x&&(l=Math.sqrt(m/x)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(d||(d=Ee(),g&&Ae(d,g)),Le(d,1/n,1/a)),d){const t=h+(y||0),e=c+(w||0);Le(d,t/Ce(Te(t),1),e/Ce(Te(e),1))}const v=t.getCanvas(h,c,r.opacity,r.filters,y,w),b=t.getPattern(v,p||e.origin.noRepeat||"no-repeat",d,i);return i.style=b,i.patternId=o,!0}}const We={image:function(t,e,i,s,n){let a,o;const r=b.get(i);return we&&i===we.paint&&xe(s,we.boxBounds)?a=we.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),we=r.use>1?{leafPaint:a,paint:i,boxBounds:me.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ve(t,e,i,r,a,s),n&&(be(t,o),Be(t,o))):r.error?n&&ke(t,o,r.error):(n&&(Re(t,!0),be(t,o)),a.loadId=r.load(()=>{Re(t,!1),t.destroyed||(ve(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Be(t,o)),a.loadId=void 0},e=>{Re(t,!1),ke(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&B.isResizing(t)||q.running)){let{width:t,height:i}=l;t*=a*r,i*=o*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||q.running?Oe(t,s,r):s.patternTask||(s.patternTask=b.patternTasker.add(()=>ht(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Oe(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:Oe,recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],y(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:pe,getPatternData:_e,fillOrFitMode:oe,clipMode:re,repeatMode:le},{toPoint:Me}=D,{hasTransparent:De}=G,Fe={},Ie={};function Ue(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(o=t/(l-1),a=G.string(n,s)):(o=n.offset,a=G.string(n.color,s)),e.addColorStop(o,a),!r&&De(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Ye,getDistance:Xe}=W,{get:ze,rotateOfOuter:Ne,scaleOfOuter:Ge}=C,{toPoint:je}=D,qe={},He={};function Ve(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Ye(e,i);a=ze(),n?(Ge(a,e,o/r*(s||1),1),Ne(a,e,t+90)):(Ge(a,e,1,o/r*(s||1)),Ne(a,e,t))}return a}const{getDistance:Qe}=W,{toPoint:Je}=D,Ze={},$e={};const Ke={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;Me(s||"top",i,Fe),Me(n||"bottom",i,Ie);const r=e.canvas.createLinearGradient(Fe.x,Fe.y,Ie.x,Ie.y),l={type:a,style:r};return Ue(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;je(s||"center",i,qe),je(n||"bottom",i,He);const l=e.canvas.createRadialGradient(qe.x,qe.y,0,qe.x,qe.y,Xe(qe,He)),d={type:a,style:l};Ue(d,l,t.stops,o);const h=Ve(i,qe,He,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Je(s||"center",i,Ze),Je(n||"bottom",i,$e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ze.x,Ze.y):e.canvas.createRadialGradient(Ze.x,Ze.y,0,Ze.x,Ze.y,Qe(Ze,$e)),d={type:a,style:l};Ue(d,l,t.stops,o);const h=Ve(i,Ze,$e,r||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ve},{copy:ti,toOffsetOutBounds:ei}=k,ii={},si={};function ni(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(ti(ii,t.bounds),ii.x+=i.x-o.x,ii.y+=i.y-o.y,s){const{fitMatrix:t}=n;ii.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ii.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ii.width*=s,ii.height*=s}t.copyWorld(n.canvas,t.bounds,ii)}else s&&(ti(ii,i),ii.x-=i.width/2*(s-1),ii.y-=i.height/2*(s-1),ii.width*=s,ii.height*=s),t.copyWorld(n.canvas,o,s?ii:i)}const{toOffsetOutBounds:ai}=k,oi={};const ri={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ei(d,si),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(si.offsetX+r.x*c*y,si.offsetY+r.y*u*y,r.blur*c*y,G.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*y:0,ni(g,si,n,i),s=d,r.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,h,d,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ai(d,oi),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(oi.offsetX+r.x*c*y,oi.offsetY+r.y*u*y,r.blur*c*y),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*y:0,ni(g,oi,n,i),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,d,"source-out"),s=d),g.fillWorld(s,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:li}=p;let di;function hi(t,e,i,s,n,a,o,r){switch(e){case"grayscale":di||(di=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);ui(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ui(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ci(t){return t.getSameCanvas(!1,!0)}function ui(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}H.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],r=i.__.mask,r){o&&(hi(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,di=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ci(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ci(t)),n||(n=ci(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||li(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&hi(this,o,t,n,s,a,void 0,!1),li(i,e)||i.__render(n||t,e),h&&hi(this,o,t,n,s,a,h,!1)}hi(this,o,t,n,s,a,void 0,!0)};const fi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",gi=fi+"_#~&*+\\=|≮≯≈≠=…",pi=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 _i(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const yi=_i("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),wi=_i("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),mi=_i(fi),xi=_i(gi),vi=_i("- —/~|┆·");var bi;!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"}(bi||(bi={}));const{Letter:Bi,Single:ki,Before:Si,After:Ri,Symbol:Ei,Break:Li}=bi;function Ai(t){return yi[t]?Bi:vi[t]?Li:wi[t]?Si:mi[t]?Ri:xi[t]?Ei:pi.test(t)?ki:Bi}const Ti={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ci(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:Pi}=Ti,{Letter:Oi,Single:Wi,Before:Mi,After:Di,Symbol:Fi,Break:Ii}=bi;let Ui,Yi,Xi,zi,Ni,Gi,ji,qi,Hi,Vi,Qi,Ji,Zi,$i,Ki,ts,es,is=[];function ss(t,e){Hi&&!qi&&(qi=Hi),Ui.data.push({char:t,width:e}),Xi+=e}function ns(){zi+=Xi,Ui.width=Xi,Yi.words.push(Ui),Ui={data:[]},Xi=0}function as(){$i&&(Ki.paraNumber++,Yi.paraStart=!0,$i=!1),Hi&&(Yi.startCharSize=qi,Yi.endCharSize=Hi,qi=0),Yi.width=zi,ts.width?Pi(Yi):es&&os(),is.push(Yi),Yi={words:[]},zi=0}function os(){zi>(Ki.maxWidth||0)&&(Ki.maxWidth=zi)}const{top:rs,right:ls,bottom:ds,left:hs}=F;function cs(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const us={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(s=d[hs],a-=d[ls]+d[hs]):i.autoSizeAlign||(s=d[hs]),o?(n=d[rs],o-=d[rs]+d[ds]):i.autoSizeAlign||(n=d[rs]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Ki=t,is=t.rows,ts=t.bounds,es=!ts.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=ts;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;$i=!0,Qi=null,qi=ji=Hi=Xi=zi=0,Ui={data:[]},Yi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Gi=i[s],"\n"===Gi?(Xi&&ns(),Yi.paraEnd=!0,as(),$i=!0):(Vi=Ai(Gi),Vi===Oi&&"none"!==o&&(Gi=Ci(Gi,o,!Xi)),ji=r.measureText(Gi).width,n&&(n<0&&(Hi=ji),ji+=n),Ji=Vi===Wi&&(Qi===Wi||Qi===Oi)||Qi===Wi&&Vi!==Di,Zi=!(Vi!==Mi&&Vi!==Wi||Qi!==Fi&&Qi!==Di),Ni=$i&&a?l-a:l,t&&l&&zi+Xi+ji>Ni&&(e?(Xi&&ns(),zi&&as()):(Zi||(Zi=Vi===Oi&&Qi==Di),Ji||Zi||Vi===Ii||Vi===Mi||Vi===Wi||Xi+ji>Ni?(Xi&&ns(),zi&&as()):zi&&as()))," "===Gi&&!0!==$i&&zi+Xi===0||(Vi===Ii?(" "===Gi&&Xi&&ns(),ss(Gi,ji),ns()):Ji||Zi?(Xi&&ns(),ss(Gi,ji)):ss(Gi,ji)),Qi=Vi);Xi&&ns(),zi&&as(),is.length>0&&(is[is.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ki.paraNumber++,zi=r.measureText(t).width,is.push({x:a||0,text:t,width:zi,paraStart:!0}),es&&os()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":cs(e,"x",t[hs]);break;case"right":cs(e,"x",-t[ls])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":cs(e,"y",t[rs]);break;case"bottom":cs(e,"y",-t[ds])}}(d,h,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=o;if(l&&y>_)y=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>y&&(m.isOverflow=!0,t.overflow=o+1),x=m.x,v=m.width,r<0&&(m.width<0?(v=-m.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,h=s+n-d;("none"===i.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(h,i,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,R(n)?(i=n.type,n.color&&(t.decorationColor=G.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const fs={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!G.object)return t;t=G.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,us),Object.assign(G,fs),Object.assign(N,Qt),Object.assign(z,We),Object.assign(j,Ke),Object.assign(Q,ri);const{setPoint:gs,addPoint:ps,toBounds:_s}=J;const ys={syncExport(t,e,i){let s;q.running=!0;try{const n=$.fileType(e),a=e.includes(".");i=$.getExportOptions(i);const{toURL:o}=K,{download:r}=K.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!a||t.toJSON(i.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),s={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:h,isFrame:c}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:y}=i,w=tt(i.smooth)?!h||h.config.smooth:i.smooth,m=i.contextSettings||(h?h.config.contextSettings:void 0),x=d&&p&&tt(i.fill)?t.fill:i.fill,v=$.isOpaqueImage(e)||x,b=new et;if(p)n=!0===p?d?h.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=h||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}n=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};it.getScaleData(i.scale,i.size,n,B);let k=i.pixelRatio||1,{x:S,y:R,width:E,height:L}=new Z(n).scale(B.scaleX,B.scaleY);f&&(S+=f.x,R+=f.y,E=f.width,L=f.height);const A={exporting:!0,matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-S,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,C=st.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:w,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=h||t,A.bounds=C.bounds),C.save(),c&&!tt(x)){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),g){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?ps(o,n,a):gs(o={},n,a)),r++;const l=new Z;return o&&(_s(o,l),l.scale(1/t.pixelRatio).ceil()),l}(C);const t=C,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:k};C=st.canvas(s),C.copyWorld(t,a,s),t.destroy()}if(_){const[t,e,i,s]=it.fourNumber(_),n=C,{width:a,height:o}=n;C=st.canvas({width:a+s+e,height:o+t+i,pixelRatio:k}),C.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o}),n.destroy()}v&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),y&&y(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:n,trimBounds:a}}}catch(t){s={data:"",error:t}}return q.running=!1,s},export(t,e,i){return q.running=!0,function(t){ws||(ws=new nt);return new Promise(e=>{ws.add(()=>ht(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const a=()=>ht(this,void 0,void 0,function*(){if(!at.isComplete)return K.requestRender(a);const o=q.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),ms(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let ws;function ms(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>ms(t))}const xs=ot.prototype,vs=rt.get("@leafer-in/export");xs.export=function(t,e){const{quality:i,blob:s}=$.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},xs.toBlob=function(t,e){return new Promise(i=>{K.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{vs.error(t),i(null)})})},xs.toDataURL=function(t,e){return K.origin.canvasToDataURL(this.view,t,e)},xs.saveAs=function(t,e){return new Promise(i=>{K.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{vs.error(t),i(!1)})})},lt.add("export"),Object.assign(q,ys),dt.prototype.export=function(t,e){return q.export(this,t,e)},dt.prototype.syncExport=function(t,e){return q.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,s)=>new X(t,e,i,s),hitCanvas:(t,e)=>new ct(t,e),hitCanvasManager:()=>new Y});export{Rt as Layouter,ct as LeaferCanvas,Tt as Picker,Lt as Renderer,Ct as Selector,pt as Watcher,gt as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as y,Debug as w,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as B,BoundsHelper as k,Plugin as S,isObject as R,Matrix as E,isUndefined as L,isString as A,getMatrixData as T,MatrixHelper as C,MathHelper as P,AlignHelper as O,PointHelper as W,ImageEvent as M,AroundHelper as D,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as U}from"fs";import{HitCanvasManager as Y,InteractionBase as X}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,Paint as N,ColorConvert as q,PaintGradient as G,Export as j,Group as H,TextConvert as V,Effect as Q,TwoPointBoundsHelper as J,Bounds as Z,FileHelper as $,Platform as K,isUndefined as tt,Matrix as et,MathHelper as it,Creator as st,TaskProcessor as nt,Resource as at,LeaferCanvasBase as ot,Debug as rt,Plugin as lt,UI as dt}from"@leafer-ui/draw";function ht(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class ct extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__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}}const{mineType:ut,fileType:ft}=s;function gt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(ut(e),i),canvasToBolb:(t,e,i)=>ht(this,void 0,void 0,function*(){return t.toBuffer(ut(e),i)}),canvasSaveAs:(t,e,i)=>ht(this,void 0,void 0,function*(){return U(e,t.toBuffer(ut(ft(e)),i))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new ct(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class pt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:_t,updateBounds:yt,updateChange:wt}=f,{pushAllChildBranch:mt,pushAllParent:xt}=g;const{worldBounds:vt}=p;class bt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,y(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,vt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,vt),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:Bt,updateAllChange:kt}=f,St=w.get("Layouter");class Rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.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(c.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=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=x,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(_t(t,!0),e.add(t),t.isBranch&&mt(t,e),xt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),xt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||yt(s[t])}yt(i)}})}(this.__levelList),function(t){t.list.forEach(wt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new x(a,r,this.times)),i.emitEvent(new x(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new r(e));e.emitEvent(new x(i,a,this.times)),Rt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){Bt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),kt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new bt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new bt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Et=w.get("Renderer");class Lt{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:120},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Et.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Et.error(t)}Et.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Et.warn("rendering");if(this.times>3)return Et.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(Lt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&t>n-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Et.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(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[B.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Lt.clipSpread=10;const{hitRadiusPoint:At}=k;class Tt{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,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 r(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new r;if(t.length){let e;const{x:n,y:a}=this.point,o={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.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),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||At(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,o=a.length;s<o;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Ct{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Tt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Pt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function Ot(t,e){t.__.__font?Pt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Wt(t,e,i){switch(e.__.strokeAlign){case"center":Mt(t,1,e,i);break;case"inside":Dt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Mt(t,2,e,i):Dt(t,"outside",e,i)}}function Mt(t,e,i,s){const n=i.__;R(t)?It(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ft(i,s))}function Dt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Mt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Pt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ft(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function It(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!z.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?Ft(s,n):n.stroke(),n.restoreBlendMode()):i?Ft(s,n):n.stroke()}}function Ut(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Wt(t,e,i);else switch(s.strokeAlign){case"center":Yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Yt(t,e,i,s){const n=i.__;R(t)?It(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&N.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new pt(t,e),layouter:(t,e)=>new Rt(t,e),renderer:(t,e,i)=>new Lt(t,e,i),selector:(t,e)=>new Ct(t,e)}),e.layout=Rt.fullLayout;const{getSpread:Xt,getOuterOf:zt,getByMove:Nt,getIntersectData:qt}=k;let Gt;const{stintSet:jt}=l,{hasTransparent:Ht}=q;function Vt(t,e,i){if(!R(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=z.image(i,t,e,n,!Gt||!Gt[e.url]);break;case"linear":s=G.linearGradient(e,n);break;case"radial":s=G.radialGradient(e,n);break;case"angular":s=G.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:q.string(o,r)};break;default:L(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(A(s.style)&&Ht(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Qt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];y(r)||(r=[r]),Gt=z.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Vt(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(jt(i,"__isAlphaPixelFill",n),jt(i,"__isTransparentFill",a)):(jt(i,"__isAlphaPixelStroke",n),jt(i,"__isTransparentStroke",a),jt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Ot(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(z.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),Ot(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Ot(e,i),i.restoreBlendMode()):Ot(e,i)}},fillPathOrText:Ot,fillText:Pt,stroke:Ut,strokes:function(t,e,i){Ut(t,e,i)},strokeText:Wt,drawTextStroke:Ft,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,o=i.bounds;let r,l,d,h,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))c=n,r=h=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(e.fullImageShadow)g=a;else{const t=n?Xt(o,u===f?n*u:[n*f,n*u]):o;g=qt(t,a)}d=o.getFitMatrix(g);let{a:p,d:_}=d;d.a<1&&(c=i.getSameCanvas(),t.__renderShape(c,s),u*=p,f*=_),h=zt(a,d),r=Nt(h,-d.e,-d.f);const y=s.matrix;y?(l=new E(d),l.multiply(y),p*=y.scaleX,_*=y.scaleY):l=d,l.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:r,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let Jt={},Zt=T();const{get:$t,rotateOfOuter:Kt,translate:te,scaleOfOuter:ee,multiplyParent:ie,scale:se,rotate:ne,skew:ae}=C;function oe(t,e,i,s,n,a,o){const r=$t();te(r,e.x+i,e.y+s),se(r,n,a),o&&Kt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function re(t,e,i,s,n,a,o,r,l){const d=$t();de(d,e,i,s,n,a,o,r),l&&(Zt.a=e.width/l.width,Zt.d=e.height/l.height,ie(d,Zt)),t.transform=d}function le(t,e,i,s,n,a,o,r,l,d,h,c){const u=$t();if(c)de(u,e,n,a,o,r,l,d);else{if(l)if("center"===h)Kt(u,{x:i/2,y:s/2},l);else switch(ne(u,l),l){case 90:te(u,s,0);break;case 180:te(u,i,s);break;case 270:te(u,0,i)}Jt.x=e.x+n,Jt.y=e.y+a,te(u,Jt.x,Jt.y),o&&ee(u,Jt,o,r)}t.transform=u}function de(t,e,i,s,n,a,o,r){o&&ne(t,o),r&&ae(t,r.x,r.y),n&&se(t,n,a),te(t,e.x+i,e.y+s)}const{get:he,translate:ce}=C,ue=new _,fe={},ge={};function pe(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=_e(i,s,e)}function _e(t,e,i){t.padding&&(e=ue.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,y=e.width===s&&e.height===n,w={mode:o},m="center"!==r&&(c||0)%180==90;let x,v;switch(k.set(ge,0,0,m?n:s,m?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(P.getScaleData(d,h,i,fe),x=fe.scaleX,v=fe.scaleY),(r||p||g)&&(x&&k.scale(ge,x,v,!0),r&&O.toPoint(r,ge,e,ge,!0,!0))):y&&!c||(x=v=k.getFitScale(e,ge,"fit"!==o),k.put(e,i,r,x,!1,ge),k.scale(ge,x,v,!0)),l&&W.move(ge,l),o){case"stretch":y||(s=e.width,n=e.height);break;case"normal":case"clip":(ge.x||ge.y||x||f||c||u)&&re(w,e,ge.x,ge.y,x,v,c,u,t.clipSize);break;case"repeat":(!y||x||c||u)&&le(w,e,s,n,ge.x,ge.y,x,v,c,u,r,t.freeTransform),g||(w.repeat="repeat");const i=R(g);(p||i)&&(w.gap=function(t,e,i,s,n){let a,o;R(t)?(a=t.x,o=t.y):a=o=t;return{x:ye(a,i,n.width,e&&e.x),y:ye(o,s,n.height,e&&e.y)}}(p,i&&g,ge.width,ge.height,e));break;default:x&&oe(w,e,ge.x,ge.y,x,v,c)}return w.transform||(e.x||e.y)&&(w.transform=he(),ce(w.transform,e.x,e.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=v),w.width=s,w.height=n,a&&(w.opacity=a),_&&(w.filters=_),g&&(w.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function ye(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let we,me=new _;const{isSame:xe}=k;function ve(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||pe(n,s,i,a),!0}function be(t,e){Se(t,M.LOAD,e)}function Be(t,e){Se(t,M.LOADED,e)}function ke(t,e,i){e.error=i,t.forceUpdate("surface"),Se(t,M.ERROR,e)}function Se(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function Re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ee,scale:Le,copy:Ae}=C,{floor:Te,ceil:Ce,max:Pe,abs:Oe}=Math;function We(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:y}=l;n*=s,a*=s,f&&(f=Oe(f),g=Oe(g),h=Ee(),Ae(h,p),Le(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const w=c*u;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(r.isSVG){const t=c/r.width;t>1&&(d=t/Ce(t))}else{const t=r.width*r.height;m>t&&(m=t)}w>m&&(d=Math.sqrt(w/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=y&&y.x*n,v=y&&y.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/Pe(Te(t),1),a/=e/Pe(Te(e),1),h||(h=Ee(),p&&Ae(h,p)),Le(h,1/n,1/a)}const b=r.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),B=r.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=B,i.patternId=o,!0}}const Me={image:function(t,e,i,s,n){let a,o;const r=b.get(i);return we&&i===we.paint&&xe(s,we.boxBounds)?a=we.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),we=r.use>1?{leafPaint:a,paint:i,boxBounds:me.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ve(t,e,i,r,a,s),n&&(be(t,o),Be(t,o))):r.error?n&&ke(t,o,r.error):(n&&(Re(t,!0),be(t,o)),a.loadId=r.load(()=>{Re(t,!1),t.destroyed||(ve(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Be(t,o)),a.loadId=void 0},e=>{Re(t,!1),ke(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&B.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*r,i*=o*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?We(t,s,r):s.patternTask||(s.patternTask=b.patternTasker.add(()=>ht(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&We(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:We,recycleImage:function(t,e){const i=e["_"+t];if(y(i)){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],y(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:pe,getPatternData:_e,fillOrFitMode:oe,clipMode:re,repeatMode:le},{toPoint:De}=D,{hasTransparent:Fe}=q,Ie={},Ue={};function Ye(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(o=t/(l-1),a=q.string(n,s)):(o=n.offset,a=q.string(n.color,s)),e.addColorStop(o,a),!r&&Fe(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Xe,getDistance:ze}=W,{get:Ne,rotateOfOuter:qe,scaleOfOuter:Ge}=C,{toPoint:je}=D,He={},Ve={};function Qe(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Xe(e,i);a=Ne(),n?(Ge(a,e,o/r*(s||1),1),qe(a,e,t+90)):(Ge(a,e,1,o/r*(s||1)),qe(a,e,t))}return a}const{getDistance:Je}=W,{toPoint:Ze}=D,$e={},Ke={};const ti={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;De(s||"top",i,Ie),De(n||"bottom",i,Ue);const r=e.canvas.createLinearGradient(Ie.x,Ie.y,Ue.x,Ue.y),l={type:a,style:r};return Ye(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;je(s||"center",i,He),je(n||"bottom",i,Ve);const l=e.canvas.createRadialGradient(He.x,He.y,0,He.x,He.y,ze(He,Ve)),d={type:a,style:l};Ye(d,l,t.stops,o);const h=Qe(i,He,Ve,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ze(s||"center",i,$e),Ze(n||"bottom",i,Ke);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,$e.x,$e.y):e.canvas.createRadialGradient($e.x,$e.y,0,$e.x,$e.y,Je($e,Ke)),d={type:a,style:l};Ye(d,l,t.stops,o);const h=Qe(i,$e,Ke,r||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Qe},{copy:ei,toOffsetOutBounds:ii}=k,si={},ni={};function ai(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(ei(si,t.bounds),si.x+=i.x-o.x,si.y+=i.y-o.y,s){const{fitMatrix:t}=n;si.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),si.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),si.width*=s,si.height*=s}t.copyWorld(n.canvas,t.bounds,si)}else s&&(ei(si,i),si.x-=i.width/2*(s-1),si.y-=i.height/2*(s-1),si.width*=s,si.height*=s),t.copyWorld(n.canvas,o,s?si:i)}const{toOffsetOutBounds:oi}=k,ri={};const li={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ii(d,ni),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.setWorldShadow(ni.offsetX+r.x*c*y,ni.offsetY+r.y*u*y,r.blur*c*y,q.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*y:0,ai(g,ni,n,i),s=d,r.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,h,d,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;oi(d,ri),r.forEach((r,_)=>{let y=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(ri.offsetX+r.x*c*y,ri.offsetY+r.y*u*y,r.blur*c*y),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*y:0,ai(g,ri,n,i),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,d,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:di}=p;let hi;function ci(t,e,i,s,n,a,o,r){switch(e){case"grayscale":hi||(hi=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);fi(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":fi(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function ui(t){return t.getSameCanvas(!1,!0)}function fi(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}H.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],r=i.__.mask,r){o&&(ci(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,hi=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=ui(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=ui(t)),n||(n=ui(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||di(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&ci(this,o,t,n,s,a,void 0,!1),di(i,e)||i.__render(n||t,e),h&&ci(this,o,t,n,s,a,h,!1)}ci(this,o,t,n,s,a,void 0,!0)};const gi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",pi=gi+"_#~&*+\\=|≮≯≈≠=…",_i=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 yi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const wi=yi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),mi=yi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),xi=yi(gi),vi=yi(pi),bi=yi("- —/~|┆·");var Bi;!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"}(Bi||(Bi={}));const{Letter:ki,Single:Si,Before:Ri,After:Ei,Symbol:Li,Break:Ai}=Bi;function Ti(t){return wi[t]?ki:bi[t]?Ai:mi[t]?Ri:xi[t]?Ei:vi[t]?Li:_i.test(t)?Si:ki}const Ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Pi(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}=Ci,{Letter:Wi,Single:Mi,Before:Di,After:Fi,Symbol:Ii,Break:Ui}=Bi;let Yi,Xi,zi,Ni,qi,Gi,ji,Hi,Vi,Qi,Ji,Zi,$i,Ki,ts,es,is,ss=[];function ns(t,e){Vi&&!Hi&&(Hi=Vi),Yi.data.push({char:t,width:e}),zi+=e}function as(){Ni+=zi,Yi.width=zi,Xi.words.push(Yi),Yi={data:[]},zi=0}function os(){Ki&&(ts.paraNumber++,Xi.paraStart=!0,Ki=!1),Vi&&(Xi.startCharSize=Hi,Xi.endCharSize=Vi,Hi=0),Xi.width=Ni,es.width?Oi(Xi):is&&rs(),ss.push(Xi),Xi={words:[]},Ni=0}function rs(){Ni>(ts.maxWidth||0)&&(ts.maxWidth=Ni)}const{top:ls,right:ds,bottom:hs,left:cs}=F;function us(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const fs={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(s=d[cs],a-=d[ds]+d[cs]):i.autoSizeAlign||(s=d[cs]),o?(n=d[ls],o-=d[ls]+d[hs]):i.autoSizeAlign||(n=d[ls]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){ts=t,ss=t.rows,es=t.bounds,is=!es.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=es;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Ki=!0,Ji=null,Hi=ji=Vi=zi=Ni=0,Yi={data:[]},Xi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Gi=i[s],"\n"===Gi?(zi&&as(),Xi.paraEnd=!0,os(),Ki=!0):(Qi=Ti(Gi),Qi===Wi&&"none"!==o&&(Gi=Pi(Gi,o,!zi)),ji=r.measureText(Gi).width,n&&(n<0&&(Vi=ji),ji+=n),Zi=Qi===Mi&&(Ji===Mi||Ji===Wi)||Ji===Mi&&Qi!==Fi,$i=!(Qi!==Di&&Qi!==Mi||Ji!==Ii&&Ji!==Fi),qi=Ki&&a?l-a:l,t&&l&&Ni+zi+ji>qi&&(e?(zi&&as(),Ni&&os()):($i||($i=Qi===Wi&&Ji==Fi),Zi||$i||Qi===Ui||Qi===Di||Qi===Mi||zi+ji>qi?(zi&&as(),Ni&&os()):Ni&&os()))," "===Gi&&!0!==Ki&&Ni+zi===0||(Qi===Ui?(" "===Gi&&zi&&as(),ns(Gi,ji),as()):Zi||$i?(zi&&as(),ns(Gi,ji)):ns(Gi,ji)),Ji=Qi);zi&&as(),Ni&&os(),ss.length>0&&(ss[ss.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ts.paraNumber++,Ni=r.measureText(t).width,ss.push({x:a||0,text:t,width:Ni,paraStart:!0}),is&&rs()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":us(e,"x",t[cs]);break;case"right":us(e,"x",-t[ds])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":us(e,"y",t[ls]);break;case"bottom":us(e,"y",-t[hs])}}(d,h,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,y=a*n+(c?c*(t.paraNumber-1):0),w=o;if(l&&y>_)y=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-y)/2;break;case"bottom":g+=_-y}w+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>y&&(m.isOverflow=!0,t.overflow=o+1),x=m.x,v=m.width,r<0&&(m.width<0?(v=-m.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,h=s+n-d;("none"===i.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(h,i,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,R(n)?(i=n.type,n.color&&(t.decorationColor=q.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const gs={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!q.object)return t;t=q.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,fs),Object.assign(q,gs),Object.assign(N,Qt),Object.assign(z,Me),Object.assign(G,ti),Object.assign(Q,li);const{setPoint:ps,addPoint:_s,toBounds:ys}=J;const ws={syncExport(t,e,i){let s;j.running=!0;try{const n=$.fileType(e),a=e.includes(".");i=$.getExportOptions(i);const{toURL:o}=K,{download:r}=K.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!a||t.toJSON(i.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),s={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:h,isFrame:c}=t,{slice:u,clip:f,trim:g,screenshot:p,padding:_,onCanvas:y}=i,w=tt(i.smooth)?!h||h.config.smooth:i.smooth,m=i.contextSettings||(h?h.config.contextSettings:void 0),x=d&&p&&tt(i.fill)?t.fill:i.fill,v=$.isOpaqueImage(e)||x,b=new et;if(p)n=!0===p?d?h.canvas.bounds:t.worldRenderBounds:p;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=h||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}n=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};it.getScaleData(i.scale,i.size,n,B);let k=i.pixelRatio||1,{x:S,y:R,width:E,height:L}=new Z(n).scale(B.scaleX,B.scaleY);f&&(S+=f.x,R+=f.y,E=f.width,L=f.height);const A={exporting:!0,matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-S,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,C=st.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:w,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=h||t,A.bounds=C.bounds),C.save(),c&&!tt(x)){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),g){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?_s(o,n,a):ps(o={},n,a)),r++;const l=new Z;return o&&(ys(o,l),l.scale(1/t.pixelRatio).ceil()),l}(C);const t=C,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:k};C=st.canvas(s),C.copyWorld(t,a,s),t.destroy()}if(_){const[t,e,i,s]=it.fourNumber(_),n=C,{width:a,height:o}=n;C=st.canvas({width:a+s+e,height:o+t+i,pixelRatio:k}),C.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o}),n.destroy()}v&&C.fillWorld(C.bounds,x||"#FFFFFF","destination-over"),y&&y(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:n,trimBounds:a}}}catch(t){s={data:"",error:t}}return j.running=!1,s},export(t,e,i){return j.running=!0,function(t){ms||(ms=new nt);return new Promise(e=>{ms.add(()=>ht(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const a=()=>ht(this,void 0,void 0,function*(){if(!at.isComplete)return K.requestRender(a);const o=j.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),xs(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let ms;function xs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>xs(t))}const vs=ot.prototype,bs=rt.get("@leafer-in/export");vs.export=function(t,e){const{quality:i,blob:s}=$.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},vs.toBlob=function(t,e){return new Promise(i=>{K.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{bs.error(t),i(null)})})},vs.toDataURL=function(t,e){return K.origin.canvasToDataURL(this.view,t,e)},vs.saveAs=function(t,e){return new Promise(i=>{K.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{bs.error(t),i(!1)})})},lt.add("export"),Object.assign(j,ws),dt.prototype.export=function(t,e){return j.export(this,t,e)},dt.prototype.syncExport=function(t,e){return j.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,s)=>new X(t,e,i,s),hitCanvas:(t,e)=>new ct(t,e),hitCanvasManager:()=>new Y});export{Rt as Layouter,ct as LeaferCanvas,Tt as Picker,Lt as Renderer,Ct as Selector,pt as Watcher,gt as useCanvas};
2
2
  //# sourceMappingURL=node.esm.min.js.map