@leafer-draw/worker 1.0.8 → 1.0.10

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/worker.cjs CHANGED
@@ -470,7 +470,8 @@ class Renderer {
470
470
  this.totalBounds = new core.Bounds();
471
471
  debug$1.log(target.innerName, '--->');
472
472
  try {
473
- target.app.emit(core.RenderEvent.CHILD_START, target);
473
+ if (!target.isApp)
474
+ target.app.emit(core.RenderEvent.CHILD_START, target);
474
475
  this.emitRender(core.RenderEvent.START);
475
476
  this.renderOnce(callback);
476
477
  this.emitRender(core.RenderEvent.END, this.totalBounds);
@@ -1579,16 +1580,16 @@ const EffectModule = {
1579
1580
 
1580
1581
  const { excludeRenderBounds } = core.LeafBoundsHelper;
1581
1582
  draw.Group.prototype.__renderMask = function (canvas, options) {
1582
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
1583
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
1583
1584
  const { children } = this;
1584
1585
  for (let i = 0, len = children.length; i < len; i++) {
1585
- child = children[i];
1586
- if (child.__.mask) {
1586
+ child = children[i], mask = child.__.mask;
1587
+ if (mask) {
1587
1588
  if (currentMask) {
1588
1589
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1589
1590
  maskCanvas = contentCanvas = null;
1590
1591
  }
1591
- if (child.__.mask === 'path') {
1592
+ if (mask === 'path' || mask === 'clipping-path') {
1592
1593
  if (child.opacity < 1) {
1593
1594
  currentMask = 'opacity-path';
1594
1595
  maskOpacity = child.opacity;
@@ -1602,14 +1603,14 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
1602
1603
  child.__clip(contentCanvas || canvas, options);
1603
1604
  }
1604
1605
  else {
1605
- currentMask = 'alpha';
1606
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
1606
1607
  if (!maskCanvas)
1607
1608
  maskCanvas = getCanvas(canvas);
1608
1609
  if (!contentCanvas)
1609
1610
  contentCanvas = getCanvas(canvas);
1610
1611
  child.__render(maskCanvas, options);
1611
1612
  }
1612
- if (child.__.mask !== 'clipping')
1613
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
1613
1614
  continue;
1614
1615
  }
1615
1616
  if (excludeRenderBounds(child, options))
@@ -1620,6 +1621,8 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
1620
1621
  };
1621
1622
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
1622
1623
  switch (maskMode) {
1624
+ case 'grayscale':
1625
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
1623
1626
  case 'alpha':
1624
1627
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
1625
1628
  break;
@@ -2324,15 +2327,12 @@ const canvas = core.LeaferCanvasBase.prototype;
2324
2327
  const debug = core.Debug.get('@leafer-ui/export');
2325
2328
  canvas.export = function (filename, options) {
2326
2329
  const { quality, blob } = core.FileHelper.getExportOptions(options);
2327
- if (filename.includes('.')) {
2330
+ if (filename.includes('.'))
2328
2331
  return this.saveAs(filename, quality);
2329
- }
2330
- else if (blob) {
2332
+ else if (blob)
2331
2333
  return this.toBlob(filename, quality);
2332
- }
2333
- else {
2334
+ else
2334
2335
  return this.toDataURL(filename, quality);
2335
- }
2336
2336
  };
2337
2337
  canvas.toBlob = function (type, quality) {
2338
2338
  return new Promise((resolve) => {
@@ -471,7 +471,8 @@ class Renderer {
471
471
  this.totalBounds = new Bounds();
472
472
  debug$1.log(target.innerName, '--->');
473
473
  try {
474
- target.app.emit(RenderEvent.CHILD_START, target);
474
+ if (!target.isApp)
475
+ target.app.emit(RenderEvent.CHILD_START, target);
475
476
  this.emitRender(RenderEvent.START);
476
477
  this.renderOnce(callback);
477
478
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -1580,16 +1581,16 @@ const EffectModule = {
1580
1581
 
1581
1582
  const { excludeRenderBounds } = LeafBoundsHelper;
1582
1583
  Group.prototype.__renderMask = function (canvas, options) {
1583
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
1584
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
1584
1585
  const { children } = this;
1585
1586
  for (let i = 0, len = children.length; i < len; i++) {
1586
- child = children[i];
1587
- if (child.__.mask) {
1587
+ child = children[i], mask = child.__.mask;
1588
+ if (mask) {
1588
1589
  if (currentMask) {
1589
1590
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1590
1591
  maskCanvas = contentCanvas = null;
1591
1592
  }
1592
- if (child.__.mask === 'path') {
1593
+ if (mask === 'path' || mask === 'clipping-path') {
1593
1594
  if (child.opacity < 1) {
1594
1595
  currentMask = 'opacity-path';
1595
1596
  maskOpacity = child.opacity;
@@ -1603,14 +1604,14 @@ Group.prototype.__renderMask = function (canvas, options) {
1603
1604
  child.__clip(contentCanvas || canvas, options);
1604
1605
  }
1605
1606
  else {
1606
- currentMask = 'alpha';
1607
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
1607
1608
  if (!maskCanvas)
1608
1609
  maskCanvas = getCanvas(canvas);
1609
1610
  if (!contentCanvas)
1610
1611
  contentCanvas = getCanvas(canvas);
1611
1612
  child.__render(maskCanvas, options);
1612
1613
  }
1613
- if (child.__.mask !== 'clipping')
1614
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
1614
1615
  continue;
1615
1616
  }
1616
1617
  if (excludeRenderBounds(child, options))
@@ -1621,6 +1622,8 @@ Group.prototype.__renderMask = function (canvas, options) {
1621
1622
  };
1622
1623
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
1623
1624
  switch (maskMode) {
1625
+ case 'grayscale':
1626
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
1624
1627
  case 'alpha':
1625
1628
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
1626
1629
  break;
@@ -2325,15 +2328,12 @@ const canvas = LeaferCanvasBase.prototype;
2325
2328
  const debug = Debug.get('@leafer-ui/export');
2326
2329
  canvas.export = function (filename, options) {
2327
2330
  const { quality, blob } = FileHelper.getExportOptions(options);
2328
- if (filename.includes('.')) {
2331
+ if (filename.includes('.'))
2329
2332
  return this.saveAs(filename, quality);
2330
- }
2331
- else if (blob) {
2333
+ else if (blob)
2332
2334
  return this.toBlob(filename, quality);
2333
- }
2334
- else {
2335
+ else
2335
2336
  return this.toDataURL(filename, quality);
2336
- }
2337
2337
  };
2338
2338
  canvas.toBlob = function (type, quality) {
2339
2339
  return new Promise((resolve) => {
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,Bounds as _,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as S,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as O,TaskProcessor as T,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as Y,Paint as X,Effect as G}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:z}=a;function N(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:z(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:z(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new U(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class V{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=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:H,updateAllWorldOpacity:Q}=f,{pushAllChildBranch:J,pushAllParent:Z}=p;const{worldBounds:$}=g,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,$),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:et,updateAllChange:nt}=f,it=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&J(t,e),Z(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||H(i[t])}H(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,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:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){et(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new tt([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=w.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,ot.log(e.innerName,"---\x3e");try{e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ot.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new _(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}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=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new _(0,0,e,n).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.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ot.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function dt(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ht(t,!0,e,n):ct(e,n);break;case"inside":lt("inside",t,s,e,n);break;case"outside":lt("outside",t,s,e,n)}}function lt(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?ht(e,!0,i,r):ct(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",rt(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function ct(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function ht(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&M.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?ct(n,i):i.stroke(),i.restoreBlendMode()):e?ct(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new V(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,n)=>new at(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=st.fullLayout;const{getSpread:ut,getOuterOf:ft,getByMove:pt,getIntersectData:_t}=B;let gt;function wt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return M.image(n,t,e,i,!gt||!gt[e.url]);case"linear":return I.linearGradient(e,i);case"radial":return I.radialGradient(e,i);case"angular":return I.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const yt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),gt=M.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=wt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?rt(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&M.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?rt(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?rt(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?rt(e,n):s?n.fill(s):n.fill())},fillText:rt,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)dt(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)dt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ht(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ht(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),ht(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:dt,drawTextStroke:ct,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=_t(i?ut(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ft(s,a),o=pt(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let mt={};const{get:vt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Rt,rotate:kt}=R;function St(t,e,n,i,s,o,a){const r=vt();bt(r,e.x+n,e.y+i),Rt(r,s,o),a&&xt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Et(t,e,n,i,s,o,a){const r=vt();bt(r,e.x+n,e.y+i),s&&Rt(r,s,o),a&&kt(r,a),t.transform=r}function Lt(t,e,n,i,s,o,a,r,d,l){const c=vt();if(d)if("center"===l)xt(c,{x:n/2,y:i/2},d);else switch(kt(c,d),d){case 90:bt(c,i,0);break;case 180:bt(c,n,i);break;case 270:bt(c,0,n)}mt.x=e.x+s,mt.y=e.y+o,bt(c,mt.x,mt.y),a&&Bt(c,mt,a,r),t.transform=c}const{get:At,translate:Wt}=R,Ot=new _,Tt={},Ct={};function Mt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(n,i,e)}function Dt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,p={mode:a},_="center"!==r&&(h||0)%180==90,g=_?s:i,w=_?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ct),y=Ct.scaleX,m=Ct.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),S.toPoint(r,t,e,Tt,!0),v+=Tt.x,x+=Tt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Et(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Lt(p,e,i,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&St(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=At(),Wt(p.transform,e.x,e.y)),y&&"stretch"!==a&&(p.scaleX=y,p.scaleY=m),p.width=i,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,Pt=new _;const{isSame:Ft}=B;function Yt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Mt(s,i,n,o),!0}function Xt(t,e){zt(t,E.LOAD,e)}function Gt(t,e){zt(t,E.LOADED,e)}function Ut(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,E.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new E(e,n))}function Nt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:jt,scale:Vt,copy:qt}=R,{ceil:Ht,abs:Qt}=Math;function Jt(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Qt(s),o=Qt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=jt(),qt(l,_),Vt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=jt(),_&&qt(l,_)),Vt(l,1/s,1/o));const m=t.getCanvas(Ht(c)||1,Ht(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Zt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:$t}=Math;const Kt={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return It&&n===It.paint&&Ft(i,It.boxBounds)?o=It.leafPaint:(o={type:n.type,image:r},It=r.use>1?{leafPaint:o,paint:n,boxBounds:Pt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Yt(t,e,n,r,o,i),s&&(Xt(t,a),Gt(t,a))):r.error?s&&Ut(t,a,r.error):(s&&(Nt(t,!0),Xt(t,a)),o.loadId=r.load((()=>{Nt(t,!1),t.destroyed||(Yt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Nt(t,!1),Ut(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!P.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=$t(o)*r,n*=$t(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||P.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||P.running?Jt(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Zt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Jt(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Jt,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Mt,getPatternData:Dt,fillOrFitMode:St,clipMode:Et,repeatMode:Lt},{toPoint:te}=L,ee={},ne={};function ie(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),D.string(i,n)):t.addColorStop(i.offset,D.string(i.color,n))}}const{getAngle:se,getDistance:oe}=A,{get:ae,rotateOfOuter:re,scaleOfOuter:de}=R,{toPoint:le}=L,ce={},he={};function ue(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=se(e,n);o=ae(),s?(de(o,e,a/r*(i||1),1),re(o,e,t+90)):(de(o,e,1,a/r*(i||1)),re(o,e,t))}return o}const{getDistance:fe}=A,{toPoint:pe}=L,_e={},ge={};const we={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;te(i||"top",n,ee),te(s||"bottom",n,ne);const d=e.canvas.createLinearGradient(ee.x,ee.y,ne.x,ne.y);ie(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;le(i||"center",n,ce),le(s||"bottom",n,he);const l=e.canvas.createRadialGradient(ce.x,ce.y,0,ce.x,ce.y,oe(ce,he));ie(l,t.stops,a);const c={type:o,style:l},h=ue(n,ce,he,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;pe(i||"center",n,_e),pe(s||"bottom",n,ge);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,fe(_e,ge));ie(l,t.stops,a);const c={type:o,style:l},h=ue(n,_e,ge,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ue},{copy:ye,toOffsetOutBounds:me}=B,ve={},xe={};function be(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(ve,t.bounds),ve.x+=n.x-a.x,ve.y+=n.y-a.y,i){const{matrix:t}=s;ve.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ve.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ve.width*=i,ve.height*=i}t.copyWorld(s.canvas,t.bounds,ve)}else i&&(ye(ve,n),ve.x-=n.width/2*(i-1),ve.y-=n.height/2*(i-1),ve.width*=i,ve.height*=i),t.copyWorld(s.canvas,a,i?ve:n)}const{toOffsetOutBounds:Be}=B,Re={};const ke={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;me(l,xe),r.forEach(((r,_)=>{f.setWorldShadow(xe.offsetX+r.x*h,xe.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,xe,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Be(l,Re),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Re.offsetX+r.x*h,Re.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,Re,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Se}=g;function Ee(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ae(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ae(t,n,i,o);break;case"path":n.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}F.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(a&&(Ee(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Le(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Le(t)),s||(s=Le(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Se(n,e)||n.__render(s||t,e);Ee(this,a,t,s,i,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=We+"_#~&*+\\=|≮≯≈≠=…",Te=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 Ce(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Ce(We),Pe=Ce(Oe),Fe=Ce("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Xe,Single:Ge,Before:Ue,After:ze,Symbol:Ne,Break:je}=Ye;function Ve(t){return Me[t]?Xe:Fe[t]?je:De[t]?Ue:Ie[t]?ze:Pe[t]?Ne:Te.test(t)?Ge:Xe}const qe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function He(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Qe}=qe,{Letter:Je,Single:Ze,Before:$e,After:Ke,Symbol:tn,Break:en}=Ye;let nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn,mn,vn=[];function xn(t,e){hn&&!cn&&(cn=hn),nn.data.push({char:t,width:e}),on+=e}function bn(){an+=on,nn.width=on,sn.words.push(nn),nn={data:[]},on=0}function Bn(){gn&&(wn.paraNumber++,sn.paraStart=!0,gn=!1),hn&&(sn.startCharSize=cn,sn.endCharSize=hn,cn=0),sn.width=an,yn.width?Qe(sn):mn&&Rn(),vn.push(sn),sn={words:[]},an=0}function Rn(){an>(wn.maxWidth||0)&&(wn.maxWidth=an)}const kn=0,Sn=1,En=2;const{top:Ln,right:An,bottom:Wn,left:On}=W;function Tn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Cn={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[On],o-=l[An]+l[On]):n.autoSizeAlign||(i=l[On]),a?(s=l[Ln],a-=l[Ln]+l[Wn]):n.autoSizeAlign||(s=l[Ln]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){wn=t,vn=t.rows,yn=t.bounds,mn=!yn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=yn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;gn=!0,fn=null,cn=ln=hn=on=an=0,nn={data:[]},sn={words:[]};for(let i=0,l=n.length;i<l;i++)dn=n[i],"\n"===dn?(on&&bn(),sn.paraEnd=!0,Bn(),gn=!0):(un=Ve(dn),un===Je&&"none"!==a&&(dn=He(dn,a,!on)),ln=r.measureText(dn).width,s&&(s<0&&(hn=ln),ln+=s),pn=un===Ze&&(fn===Ze||fn===Je)||fn===Ze&&un!==Ke,_n=!(un!==$e&&un!==Ze||fn!==tn&&fn!==Ke),rn=gn&&o?d-o:d,t&&d&&an+on+ln>rn&&(e?(on&&bn(),an&&Bn()):(_n||(_n=un===Je&&fn==Ke),pn||_n||un===en||un===$e||un===Ze||on+ln>rn?(on&&bn(),an&&Bn()):an&&Bn()))," "===dn&&!0!==gn&&an+on===0||(un===en?(" "===dn&&on&&bn(),xn(dn,ln),bn()):pn||_n?(on&&bn(),xn(dn,ln)):xn(dn,ln)),fn=un);on&&bn(),an&&Bn(),vn.length>0&&(vn[vn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{wn.paraNumber++,an=r.measureText(t).width,vn.push({x:o||0,text:t,width:an,paraStart:!0}),mn&&Rn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Tn(e,"x",t[On]);break;case"right":Tn(e,"x",-t[An])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Tn(e,"y",t[Ln]);break;case"bottom":Tn(e,"y",-t[Wn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:_}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>_)g=Math.max(_,s),t.overflow=n.length;else if(_||h)switch(l){case"middle":f+=(_-g)/2;break;case"bottom":f+=_-g}w+=f;let y,m,v,x=p||h?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<p||y.width>p&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?kn:l>.01?Sn:En,t.isOverflow&&!r&&(t.textMode=!0),h===En?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Sn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Mn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!D.object)return t;t=D.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Dn,addPoint:In,toBounds:Pn}=O;const Fn={export(t,n,s){this.running=!0;const o=a.fileType(n),r=n.includes(".");return s=a.getExportOptions(s),function(t){Yn||(Yn=new T);return new Promise((e=>{Yn.add((()=>Zt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const c=t=>{d(t),l(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===o)return r&&u(h(JSON.stringify(t.toJSON(s.json)),"text"),n),c({data:!!r||t.toJSON(s.json)});if("svg"===o)return r&&u(h(t.toSVG(),"svg"),n),c({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Xn(t),f.waitViewCompleted((()=>Zt(this,void 0,void 0,(function*(){let e,o,r=1,d=1;const{worldTransform:l,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:w}=s,y=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=h&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(n)||x,B=new C;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let n=s.relative||(h?"inner":"local");switch(r=l.scaleX,d=l.scaleY,n){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":n=t.leafer;default:B.set(l).divide(t.getTransform(n));const e=n.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",n)}const R={scaleX:1,scaleY:1};k.getScaleData(s.scale,s.size,e,R);let S=s.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:E,y:L,width:A,height:W}=new _(e).scale(R.scaleX,R.scaleY),O={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/r*R.scaleX,1/d*R.scaleY)};let T,M=i.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:S,smooth:y,contextSettings:m});if(p&&(T=t,T.__worldOpacity=0,t=f,O.bounds=M.bounds),M.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(M,O),t.fill=e}else t.__render(M,O);if(M.restore(),T&&T.__updateWorldOpacity(),g){o=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,o,a,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,o=(r-s)/e,a?In(a,s,o):Dn(a={},s,o)),r++;const d=new _;return Pn(a,d),d.scale(1/t.pixelRatio).ceil()}(M);const t=M,{width:e,height:n}=o,s={x:0,y:0,width:e,height:n,pixelRatio:S};M=i.canvas(s),M.copyWorld(t,o,s)}b&&M.fillWorld(M.bounds,x||"#FFFFFF","destination-over"),w&&w(M);const D="canvas"===n?M:yield M.export(n,s);c({data:D,width:M.pixelWidth,height:M.pixelHeight,renderBounds:e,trimBounds:o})}))))):c({data:!1})}))))}};let Yn;function Xn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Xn(t)))}const Gn=t.prototype,Un=w.get("@leafer-ui/export");Gn.export=function(t,e){const{quality:n,blob:i}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},Gn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Un.error(t),i(null)}))}))},Gn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Gn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Un.error(t),i(!1)}))}))},Object.assign(Y,Cn),Object.assign(D,Mn),Object.assign(X,yt),Object.assign(M,Kt),Object.assign(I,we),Object.assign(G,ke),Object.assign(P,Fn),N();export{st as Layouter,U as LeaferCanvas,at as Renderer,V as Watcher,N as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,Bounds as _,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as S,AlignHelper as k,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as O,TaskProcessor as T,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as Y,Paint as X,Effect as G}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:z}=a;function N(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:z(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:z(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new U(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class V{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=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:q,updateBounds:H,updateAllWorldOpacity:Q}=f,{pushAllChildBranch:J,pushAllParent:Z}=p;const{worldBounds:$}=g,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,$),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:et,updateAllChange:nt}=f,it=w.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&J(t,e),Z(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||H(i[t])}H(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,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:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),st.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){et(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),nt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new tt([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new tt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=w.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,ot.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ot.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new _(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}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=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new _(0,0,e,n).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.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ot.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function dt(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ht(t,!0,e,n):ct(e,n);break;case"inside":lt("inside",t,s,e,n);break;case"outside":lt("outside",t,s,e,n)}}function lt(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?ht(e,!0,i,r):ct(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",rt(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function ct(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function ht(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&M.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?ct(n,i):i.stroke(),i.restoreBlendMode()):e?ct(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new V(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,n)=>new at(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=st.fullLayout;const{getSpread:ut,getOuterOf:ft,getByMove:pt,getIntersectData:_t}=B;let gt;function wt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return M.image(n,t,e,i,!gt||!gt[e.url]);case"linear":return I.linearGradient(e,i);case"radial":return I.radialGradient(e,i);case"angular":return I.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const yt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),gt=M.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=wt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?rt(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&M.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?rt(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?rt(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?rt(e,n):s?n.fill(s):n.fill())},fillText:rt,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)dt(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)dt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ht(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ht(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),ht(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:dt,drawTextStroke:ct,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=_t(i?ut(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ft(s,a),o=pt(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let mt={};const{get:vt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Rt,rotate:St}=R;function kt(t,e,n,i,s,o,a){const r=vt();bt(r,e.x+n,e.y+i),Rt(r,s,o),a&&xt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Et(t,e,n,i,s,o,a){const r=vt();bt(r,e.x+n,e.y+i),s&&Rt(r,s,o),a&&St(r,a),t.transform=r}function Lt(t,e,n,i,s,o,a,r,d,l){const c=vt();if(d)if("center"===l)xt(c,{x:n/2,y:i/2},d);else switch(St(c,d),d){case 90:bt(c,i,0);break;case 180:bt(c,n,i);break;case 270:bt(c,0,n)}mt.x=e.x+s,mt.y=e.y+o,bt(c,mt.x,mt.y),a&&Bt(c,mt,a,r),t.transform=c}const{get:At,translate:Wt}=R,Ot=new _,Tt={},Ct={};function Mt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Dt(n,i,e)}function Dt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=Ot.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,p={mode:a},_="center"!==r&&(h||0)%180==90,g=_?s:i,w=_?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(S.getScaleData(l,c,n,Ct),y=Ct.scaleX,m=Ct.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),k.toPoint(r,t,e,Tt,!0),v+=Tt.x,x+=Tt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&Et(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Lt(p,e,i,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&kt(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=At(),Wt(p.transform,e.x,e.y)),y&&"stretch"!==a&&(p.scaleX=y,p.scaleY=m),p.width=i,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let It,Pt=new _;const{isSame:Ft}=B;function Yt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Mt(s,i,n,o),!0}function Xt(t,e){zt(t,E.LOAD,e)}function Gt(t,e){zt(t,E.LOADED,e)}function Ut(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,E.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new E(e,n))}function Nt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:jt,scale:Vt,copy:qt}=R,{ceil:Ht,abs:Qt}=Math;function Jt(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Qt(s),o=Qt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=jt(),qt(l,_),Vt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=jt(),_&&qt(l,_)),Vt(l,1/s,1/o));const m=t.getCanvas(Ht(c)||1,Ht(h)||1,p),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Zt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:$t}=Math;const Kt={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return It&&n===It.paint&&Ft(i,It.boxBounds)?o=It.leafPaint:(o={type:n.type,image:r},It=r.use>1?{leafPaint:o,paint:n,boxBounds:Pt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Yt(t,e,n,r,o,i),s&&(Xt(t,a),Gt(t,a))):r.error?s&&Ut(t,a,r.error):(s&&(Nt(t,!0),Xt(t,a)),o.loadId=r.load((()=>{Nt(t,!1),t.destroyed||(Yt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Nt(t,!1),Ut(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!P.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=$t(o)*r,n*=$t(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||P.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||P.running?Jt(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Zt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Jt(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Jt,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Mt,getPatternData:Dt,fillOrFitMode:kt,clipMode:Et,repeatMode:Lt},{toPoint:te}=L,ee={},ne={};function ie(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),D.string(i,n)):t.addColorStop(i.offset,D.string(i.color,n))}}const{getAngle:se,getDistance:oe}=A,{get:ae,rotateOfOuter:re,scaleOfOuter:de}=R,{toPoint:le}=L,ce={},he={};function ue(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=se(e,n);o=ae(),s?(de(o,e,a/r*(i||1),1),re(o,e,t+90)):(de(o,e,1,a/r*(i||1)),re(o,e,t))}return o}const{getDistance:fe}=A,{toPoint:pe}=L,_e={},ge={};const we={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;te(i||"top",n,ee),te(s||"bottom",n,ne);const d=e.canvas.createLinearGradient(ee.x,ee.y,ne.x,ne.y);ie(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;le(i||"center",n,ce),le(s||"bottom",n,he);const l=e.canvas.createRadialGradient(ce.x,ce.y,0,ce.x,ce.y,oe(ce,he));ie(l,t.stops,a);const c={type:o,style:l},h=ue(n,ce,he,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;pe(i||"center",n,_e),pe(s||"bottom",n,ge);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,_e.x,_e.y):e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,fe(_e,ge));ie(l,t.stops,a);const c={type:o,style:l},h=ue(n,_e,ge,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ue},{copy:ye,toOffsetOutBounds:me}=B,ve={},xe={};function be(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(ve,t.bounds),ve.x+=n.x-a.x,ve.y+=n.y-a.y,i){const{matrix:t}=s;ve.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ve.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ve.width*=i,ve.height*=i}t.copyWorld(s.canvas,t.bounds,ve)}else i&&(ye(ve,n),ve.x-=n.width/2*(i-1),ve.y-=n.height/2*(i-1),ve.width*=i,ve.height*=i),t.copyWorld(s.canvas,a,i?ve:n)}const{toOffsetOutBounds:Be}=B,Re={};const Se={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;me(l,xe),r.forEach(((r,_)=>{f.setWorldShadow(xe.offsetX+r.x*h,xe.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,xe,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Be(l,Re),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Re.offsetX+r.x*h,Re.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,Re,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:ke}=g;function Ee(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ae(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ae(t,n,i,o);break;case"path":n.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}F.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(Ee(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Le(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Le(t)),s||(s=Le(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||ke(n,e)||n.__render(s||t,e);Ee(this,a,t,s,i,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=We+"_#~&*+\\=|≮≯≈≠=…",Te=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 Ce(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ie=Ce(We),Pe=Ce(Oe),Fe=Ce("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Xe,Single:Ge,Before:Ue,After:ze,Symbol:Ne,Break:je}=Ye;function Ve(t){return Me[t]?Xe:Fe[t]?je:De[t]?Ue:Ie[t]?ze:Pe[t]?Ne:Te.test(t)?Ge:Xe}const qe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function He(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Qe}=qe,{Letter:Je,Single:Ze,Before:$e,After:Ke,Symbol:tn,Break:en}=Ye;let nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,pn,_n,gn,wn,yn,mn,vn=[];function xn(t,e){hn&&!cn&&(cn=hn),nn.data.push({char:t,width:e}),on+=e}function bn(){an+=on,nn.width=on,sn.words.push(nn),nn={data:[]},on=0}function Bn(){gn&&(wn.paraNumber++,sn.paraStart=!0,gn=!1),hn&&(sn.startCharSize=cn,sn.endCharSize=hn,cn=0),sn.width=an,yn.width?Qe(sn):mn&&Rn(),vn.push(sn),sn={words:[]},an=0}function Rn(){an>(wn.maxWidth||0)&&(wn.maxWidth=an)}const Sn=0,kn=1,En=2;const{top:Ln,right:An,bottom:Wn,left:On}=W;function Tn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Cn={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[On],o-=l[An]+l[On]):n.autoSizeAlign||(i=l[On]),a?(s=l[Ln],a-=l[Ln]+l[Wn]):n.autoSizeAlign||(s=l[Ln]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){wn=t,vn=t.rows,yn=t.bounds,mn=!yn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=yn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;gn=!0,fn=null,cn=ln=hn=on=an=0,nn={data:[]},sn={words:[]};for(let i=0,l=n.length;i<l;i++)dn=n[i],"\n"===dn?(on&&bn(),sn.paraEnd=!0,Bn(),gn=!0):(un=Ve(dn),un===Je&&"none"!==a&&(dn=He(dn,a,!on)),ln=r.measureText(dn).width,s&&(s<0&&(hn=ln),ln+=s),pn=un===Ze&&(fn===Ze||fn===Je)||fn===Ze&&un!==Ke,_n=!(un!==$e&&un!==Ze||fn!==tn&&fn!==Ke),rn=gn&&o?d-o:d,t&&d&&an+on+ln>rn&&(e?(on&&bn(),an&&Bn()):(_n||(_n=un===Je&&fn==Ke),pn||_n||un===en||un===$e||un===Ze||on+ln>rn?(on&&bn(),an&&Bn()):an&&Bn()))," "===dn&&!0!==gn&&an+on===0||(un===en?(" "===dn&&on&&bn(),xn(dn,ln),bn()):pn||_n?(on&&bn(),xn(dn,ln)):xn(dn,ln)),fn=un);on&&bn(),an&&Bn(),vn.length>0&&(vn[vn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{wn.paraNumber++,an=r.measureText(t).width,vn.push({x:o||0,text:t,width:an,paraStart:!0}),mn&&Rn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Tn(e,"x",t[On]);break;case"right":Tn(e,"x",-t[An])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Tn(e,"y",t[Ln]);break;case"bottom":Tn(e,"y",-t[Wn])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:_}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>_)g=Math.max(_,s),t.overflow=n.length;else if(_||h)switch(l){case"middle":f+=(_-g)/2;break;case"bottom":f+=_-g}w+=f;let y,m,v,x=p||h?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<p||y.width>p&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Sn:l>.01?kn:En,t.isOverflow&&!r&&(t.textMode=!0),h===En?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===kn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Mn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!D.object)return t;t=D.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Dn,addPoint:In,toBounds:Pn}=O;const Fn={export(t,n,s){this.running=!0;const o=a.fileType(n),r=n.includes(".");return s=a.getExportOptions(s),function(t){Yn||(Yn=new T);return new Promise((e=>{Yn.add((()=>Zt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const c=t=>{d(t),l(),this.running=!1},{toURL:h}=e,{download:u}=e.origin;if("json"===o)return r&&u(h(JSON.stringify(t.toJSON(s.json)),"text"),n),c({data:!!r||t.toJSON(s.json)});if("svg"===o)return r&&u(h(t.toSVG(),"svg"),n),c({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Xn(t),f.waitViewCompleted((()=>Zt(this,void 0,void 0,(function*(){let e,o,r=1,d=1;const{worldTransform:l,isLeafer:h,isFrame:u}=t,{slice:p,trim:g,onCanvas:w}=s,y=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=h&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(n)||x,B=new C;if(v)e=!0===v?h?f.canvas.bounds:t.worldRenderBounds:v;else{let n=s.relative||(h?"inner":"local");switch(r=l.scaleX,d=l.scaleY,n){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":n=t.leafer;default:B.set(l).divide(t.getTransform(n));const e=n.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",n)}const R={scaleX:1,scaleY:1};S.getScaleData(s.scale,s.size,e,R);let k=s.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:W}=new _(e).scale(R.scaleX,R.scaleY),O={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/r*R.scaleX,1/d*R.scaleY)};let T,M=i.canvas({width:Math.round(A),height:Math.round(W),pixelRatio:k,smooth:y,contextSettings:m});if(p&&(T=t,T.__worldOpacity=0,t=f,O.bounds=M.bounds),M.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(M,O),t.fill=e}else t.__render(M,O);if(M.restore(),T&&T.__updateWorldOpacity(),g){o=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,o,a,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,o=(r-s)/e,a?In(a,s,o):Dn(a={},s,o)),r++;const d=new _;return Pn(a,d),d.scale(1/t.pixelRatio).ceil()}(M);const t=M,{width:e,height:n}=o,s={x:0,y:0,width:e,height:n,pixelRatio:k};M=i.canvas(s),M.copyWorld(t,o,s)}b&&M.fillWorld(M.bounds,x||"#FFFFFF","destination-over"),w&&w(M);const D="canvas"===n?M:yield M.export(n,s);c({data:D,width:M.pixelWidth,height:M.pixelHeight,renderBounds:e,trimBounds:o})}))))):c({data:!1})}))))}};let Yn;function Xn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Xn(t)))}const Gn=t.prototype,Un=w.get("@leafer-ui/export");Gn.export=function(t,e){const{quality:n,blob:i}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},Gn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Un.error(t),i(null)}))}))},Gn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Gn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Un.error(t),i(!1)}))}))},Object.assign(Y,Cn),Object.assign(D,Mn),Object.assign(X,yt),Object.assign(M,Kt),Object.assign(I,we),Object.assign(G,Se),Object.assign(P,Fn),N();export{st as Layouter,U as LeaferCanvas,at as Renderer,V as Watcher,N as useCanvas};
package/dist/worker.js CHANGED
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
1414
1414
  list: {},
1415
1415
  register(UI) {
1416
1416
  const { __tag: tag } = UI.prototype;
1417
- if (list$1[tag]) {
1417
+ if (list$1[tag])
1418
1418
  debug$c.repeat(tag);
1419
- }
1420
- else {
1421
- list$1[tag] = UI;
1422
- }
1419
+ list$1[tag] = UI;
1423
1420
  },
1424
1421
  get(tag, data, x, y, width, height) {
1422
+ if (!list$1[tag])
1423
+ debug$c.error('not register ' + tag);
1425
1424
  const ui = new list$1[tag](data);
1426
1425
  if (x !== undefined) {
1427
1426
  ui.x = x;
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
1445
1444
  Object.keys(Event).forEach(key => {
1446
1445
  name = Event[key];
1447
1446
  if (typeof name === 'string')
1448
- nameList[name] ? debug$b.repeat(name) : nameList[name] = Event;
1447
+ nameList[name] && debug$b.repeat(name), nameList[name] = Event;
1449
1448
  });
1450
1449
  },
1451
1450
  changeName(oldName, newName) {
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
1647
1646
  const t = this;
1648
1647
  if (t.blendMode === 'pass-through') {
1649
1648
  const leaf = this.__leaf;
1650
- if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
1649
+ if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
1651
1650
  t.__single = true;
1652
1651
  }
1653
1652
  else if (t.__single) {
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
2045
2044
  takeCanvas = this.getSameCanvas();
2046
2045
  takeCanvas.copyWorld(this);
2047
2046
  }
2048
- DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2049
- this.size.pixelRatio || (this.size.pixelRatio = 1);
2047
+ const s = this.size;
2048
+ DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2049
+ canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2050
2050
  this.bounds = new Bounds(0, 0, this.width, this.height);
2051
2051
  if (this.context && !this.unreal) {
2052
2052
  this.updateViewSize();
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
2160
2160
  if (!onlyResetTransform)
2161
2161
  this.useWorldTransform();
2162
2162
  }
2163
+ useGrayscaleAlpha(bounds) {
2164
+ this.setTempBounds(bounds, true, true);
2165
+ let alpha, pixel;
2166
+ const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
2167
+ for (let i = 0, len = data.length; i < len; i += 4) {
2168
+ pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
2169
+ if (alpha = data[i + 3])
2170
+ data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
2171
+ }
2172
+ context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
2173
+ }
2163
2174
  useMask(maskCanvas, fromBounds, toBounds) {
2164
2175
  this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
2165
2176
  }
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
2170
2181
  if (blendMode)
2171
2182
  this.blendMode = blendMode;
2172
2183
  this.fillStyle = color;
2173
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2184
+ this.setTempBounds(bounds);
2174
2185
  this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2175
2186
  if (blendMode)
2176
2187
  this.blendMode = 'source-over';
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
2179
2190
  if (blendMode)
2180
2191
  this.blendMode = blendMode;
2181
2192
  this.strokeStyle = color;
2182
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2193
+ this.setTempBounds(bounds);
2183
2194
  this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2184
2195
  if (blendMode)
2185
2196
  this.blendMode = 'source-over';
2186
2197
  }
2187
2198
  clearWorld(bounds, ceilPixel) {
2188
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2189
- if (ceilPixel)
2190
- tempBounds$1.ceil();
2199
+ this.setTempBounds(bounds, ceilPixel);
2191
2200
  this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2192
2201
  }
2193
2202
  clipWorld(bounds, ceilPixel) {
2194
2203
  this.beginPath();
2195
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2196
- if (ceilPixel)
2197
- tempBounds$1.ceil();
2204
+ this.setTempBounds(bounds, ceilPixel);
2198
2205
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2199
2206
  this.clip();
2200
2207
  }
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
2202
2209
  const { pixelRatio } = this;
2203
2210
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2204
2211
  }
2212
+ setTempBounds(bounds, ceil, intersect) {
2213
+ tempBounds$1.set(bounds);
2214
+ if (intersect)
2215
+ tempBounds$1.intersect(this.bounds);
2216
+ tempBounds$1.scale(this.pixelRatio);
2217
+ if (ceil)
2218
+ tempBounds$1.ceil();
2219
+ }
2205
2220
  isSameSize(size) {
2206
2221
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2207
2222
  }
@@ -5215,13 +5230,14 @@ var LeaferUI = (function (exports) {
5215
5230
  this.__.__checkSingle();
5216
5231
  },
5217
5232
  __render(canvas, options) {
5233
+ this.__nowWorld = this.__getNowWorld(options);
5218
5234
  if (this.__worldOpacity) {
5219
5235
  if (this.__.__single) {
5220
5236
  if (this.__.eraser === 'path')
5221
5237
  return this.__renderEraser(canvas, options);
5222
5238
  const tempCanvas = canvas.getSameCanvas(false, true);
5223
5239
  this.__renderBranch(tempCanvas, options);
5224
- const nowWorld = this.__getNowWorld(options);
5240
+ const nowWorld = this.__nowWorld;
5225
5241
  canvas.opacity = this.__.opacity;
5226
5242
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
5227
5243
  tempCanvas.recycle(nowWorld);
@@ -5962,7 +5978,7 @@ var LeaferUI = (function (exports) {
5962
5978
  }
5963
5979
  }
5964
5980
 
5965
- const version = "1.0.8";
5981
+ const version = "1.0.10";
5966
5982
 
5967
5983
  class LeaferCanvas extends LeaferCanvasBase {
5968
5984
  get allowBackgroundColor() { return true; }
@@ -6431,7 +6447,8 @@ var LeaferUI = (function (exports) {
6431
6447
  this.totalBounds = new Bounds();
6432
6448
  debug$3.log(target.innerName, '--->');
6433
6449
  try {
6434
- target.app.emit(RenderEvent.CHILD_START, target);
6450
+ if (!target.isApp)
6451
+ target.app.emit(RenderEvent.CHILD_START, target);
6435
6452
  this.emitRender(RenderEvent.START);
6436
6453
  this.renderOnce(callback);
6437
6454
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6712,6 +6729,12 @@ var LeaferUI = (function (exports) {
6712
6729
  return strokeWidth;
6713
6730
  }
6714
6731
  get __hasStroke() { return this.stroke && this.strokeWidth; }
6732
+ get __hasMultiPaint() {
6733
+ const t = this;
6734
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
6735
+ return true;
6736
+ return t.fill && this.__hasStroke;
6737
+ }
6715
6738
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
6716
6739
  get __autoWidth() { return !this._width; }
6717
6740
  get __autoHeight() { return !this._height; }
@@ -7081,9 +7104,8 @@ var LeaferUI = (function (exports) {
7081
7104
  canvas.strokeRect(half, half, width, height);
7082
7105
  canvas.restore();
7083
7106
  }
7084
- else {
7107
+ else
7085
7108
  canvas.strokeRect(half, half, width, height);
7086
- }
7087
7109
  break;
7088
7110
  case 'outside':
7089
7111
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -7308,6 +7330,15 @@ var LeaferUI = (function (exports) {
7308
7330
  __decorate([
7309
7331
  boundsType(0)
7310
7332
  ], exports.UI.prototype, "padding", void 0);
7333
+ __decorate([
7334
+ boundsType(false)
7335
+ ], exports.UI.prototype, "lockRatio", void 0);
7336
+ __decorate([
7337
+ boundsType()
7338
+ ], exports.UI.prototype, "widthRange", void 0);
7339
+ __decorate([
7340
+ boundsType()
7341
+ ], exports.UI.prototype, "heightRange", void 0);
7311
7342
  __decorate([
7312
7343
  dataType(false)
7313
7344
  ], exports.UI.prototype, "draggable", void 0);
@@ -7599,8 +7630,6 @@ var LeaferUI = (function (exports) {
7599
7630
  __onResize(event) {
7600
7631
  this.emitEvent(event);
7601
7632
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
7602
- if (!event.width || !event.height)
7603
- debug$1.warn('w = 0 or h = 0');
7604
7633
  setTimeout(() => { if (this.canvasManager)
7605
7634
  this.canvasManager.clearRecycled(); }, 0);
7606
7635
  }
@@ -7925,9 +7954,6 @@ var LeaferUI = (function (exports) {
7925
7954
  __decorate([
7926
7955
  dataType(false)
7927
7956
  ], exports.Box.prototype, "resizeChildren", void 0);
7928
- __decorate([
7929
- dataType(false)
7930
- ], exports.Box.prototype, "textBox", void 0);
7931
7957
  __decorate([
7932
7958
  affectRenderBoundsType('show')
7933
7959
  ], exports.Box.prototype, "overflow", void 0);
@@ -8338,7 +8364,6 @@ var LeaferUI = (function (exports) {
8338
8364
  this.__updateTextDrawData();
8339
8365
  const { bounds } = data.__textDrawData;
8340
8366
  const b = layout.boxBounds;
8341
- console.log(bounds, autoWidth, autoHeight);
8342
8367
  if (data.__lineHeight < fontSize)
8343
8368
  spread(bounds, fontSize / 2);
8344
8369
  if (autoWidth || autoHeight) {
@@ -9390,16 +9415,16 @@ var LeaferUI = (function (exports) {
9390
9415
 
9391
9416
  const { excludeRenderBounds } = LeafBoundsHelper;
9392
9417
  exports.Group.prototype.__renderMask = function (canvas, options) {
9393
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
9418
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
9394
9419
  const { children } = this;
9395
9420
  for (let i = 0, len = children.length; i < len; i++) {
9396
- child = children[i];
9397
- if (child.__.mask) {
9421
+ child = children[i], mask = child.__.mask;
9422
+ if (mask) {
9398
9423
  if (currentMask) {
9399
9424
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
9400
9425
  maskCanvas = contentCanvas = null;
9401
9426
  }
9402
- if (child.__.mask === 'path') {
9427
+ if (mask === 'path' || mask === 'clipping-path') {
9403
9428
  if (child.opacity < 1) {
9404
9429
  currentMask = 'opacity-path';
9405
9430
  maskOpacity = child.opacity;
@@ -9413,14 +9438,14 @@ var LeaferUI = (function (exports) {
9413
9438
  child.__clip(contentCanvas || canvas, options);
9414
9439
  }
9415
9440
  else {
9416
- currentMask = 'alpha';
9441
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
9417
9442
  if (!maskCanvas)
9418
9443
  maskCanvas = getCanvas(canvas);
9419
9444
  if (!contentCanvas)
9420
9445
  contentCanvas = getCanvas(canvas);
9421
9446
  child.__render(maskCanvas, options);
9422
9447
  }
9423
- if (child.__.mask !== 'clipping')
9448
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
9424
9449
  continue;
9425
9450
  }
9426
9451
  if (excludeRenderBounds(child, options))
@@ -9431,6 +9456,8 @@ var LeaferUI = (function (exports) {
9431
9456
  };
9432
9457
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
9433
9458
  switch (maskMode) {
9459
+ case 'grayscale':
9460
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
9434
9461
  case 'alpha':
9435
9462
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
9436
9463
  break;
@@ -10135,15 +10162,12 @@ var LeaferUI = (function (exports) {
10135
10162
  const debug = Debug.get('@leafer-ui/export');
10136
10163
  canvas.export = function (filename, options) {
10137
10164
  const { quality, blob } = FileHelper.getExportOptions(options);
10138
- if (filename.includes('.')) {
10165
+ if (filename.includes('.'))
10139
10166
  return this.saveAs(filename, quality);
10140
- }
10141
- else if (blob) {
10167
+ else if (blob)
10142
10168
  return this.toBlob(filename, quality);
10143
- }
10144
- else {
10169
+ else
10145
10170
  return this.toDataURL(filename, quality);
10146
- }
10147
10171
  };
10148
10172
  canvas.toBlob = function (type, quality) {
10149
10173
  return new Promise((resolve) => {